Completed
Branch dev (64e3a7)
by
unknown
13:10 queued 05:44
created
core/EE_Error.core.php 2 patches
Indentation   +1130 added lines, -1130 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 // if you're a dev and want to receive all errors via email
13 13
 // add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE );
14 14
 if (defined('WP_DEBUG') && WP_DEBUG === true && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === true) {
15
-    set_error_handler(array('EE_Error', 'error_handler'));
16
-    register_shutdown_function(array('EE_Error', 'fatal_error_handler'));
15
+	set_error_handler(array('EE_Error', 'error_handler'));
16
+	register_shutdown_function(array('EE_Error', 'fatal_error_handler'));
17 17
 }
18 18
 
19 19
 
@@ -26,251 +26,251 @@  discard block
 block discarded – undo
26 26
  */
27 27
 class EE_Error extends Exception
28 28
 {
29
-    const OPTIONS_KEY_NOTICES = 'ee_notices';
30
-
31
-
32
-    /**
33
-     * name of the file to log exceptions to
34
-     *
35
-     * @var string
36
-     */
37
-    private static $_exception_log_file = 'espresso_error_log.txt';
38
-
39
-    /**
40
-     *    stores details for all exception
41
-     *
42
-     * @var array
43
-     */
44
-    private static $_all_exceptions = array();
45
-
46
-    /**
47
-     *    tracks number of errors
48
-     *
49
-     * @var int
50
-     */
51
-    private static $_error_count = 0;
52
-
53
-    /**
54
-     * @var array $_espresso_notices
55
-     */
56
-    private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false);
57
-
58
-
59
-    /**
60
-     * @override default exception handling
61
-     * @param string         $message
62
-     * @param int            $code
63
-     * @param Exception|null $previous
64
-     */
65
-    public function __construct($message, $code = 0, Exception $previous = null)
66
-    {
67
-        if (version_compare(PHP_VERSION, '5.3.0', '<')) {
68
-            parent::__construct($message, $code);
69
-        } else {
70
-            parent::__construct($message, $code, $previous);
71
-        }
72
-    }
73
-
74
-
75
-    /**
76
-     *    error_handler
77
-     *
78
-     * @param $code
79
-     * @param $message
80
-     * @param $file
81
-     * @param $line
82
-     * @return void
83
-     */
84
-    public static function error_handler($code, $message, $file, $line)
85
-    {
86
-        $type = EE_Error::error_type($code);
87
-        $site = site_url();
88
-        switch ($site) {
89
-            case 'http://ee4.eventespresso.com/':
90
-            case 'http://ee4decaf.eventespresso.com/':
91
-            case 'http://ee4hf.eventespresso.com/':
92
-            case 'http://ee4a.eventespresso.com/':
93
-            case 'http://ee4ad.eventespresso.com/':
94
-            case 'http://ee4b.eventespresso.com/':
95
-            case 'http://ee4bd.eventespresso.com/':
96
-            case 'http://ee4d.eventespresso.com/':
97
-            case 'http://ee4dd.eventespresso.com/':
98
-                $to = '[email protected]';
99
-                break;
100
-            default:
101
-                $to = get_option('admin_email');
102
-        }
103
-        $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
104
-        $msg = EE_Error::_format_error($type, $message, $file, $line);
105
-        if (function_exists('wp_mail')) {
106
-            add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
107
-            wp_mail($to, $subject, $msg);
108
-        }
109
-        echo '<div id="message" class="espresso-notices error"><p>';
110
-        echo wp_kses($type . ': ' . $message . '<br />' . $file . ' line ' . $line, AllowedTags::getWithFormTags());
111
-        echo '<br /></p></div>';
112
-    }
113
-
114
-
115
-    /**
116
-     * error_type
117
-     * http://www.php.net/manual/en/errorfunc.constants.php#109430
118
-     *
119
-     * @param $code
120
-     * @return string
121
-     */
122
-    public static function error_type($code)
123
-    {
124
-        switch ($code) {
125
-            case E_ERROR: // 1 //
126
-                return 'E_ERROR';
127
-            case E_WARNING: // 2 //
128
-                return 'E_WARNING';
129
-            case E_PARSE: // 4 //
130
-                return 'E_PARSE';
131
-            case E_NOTICE: // 8 //
132
-                return 'E_NOTICE';
133
-            case E_CORE_ERROR: // 16 //
134
-                return 'E_CORE_ERROR';
135
-            case E_CORE_WARNING: // 32 //
136
-                return 'E_CORE_WARNING';
137
-            case E_COMPILE_ERROR: // 64 //
138
-                return 'E_COMPILE_ERROR';
139
-            case E_COMPILE_WARNING: // 128 //
140
-                return 'E_COMPILE_WARNING';
141
-            case E_USER_ERROR: // 256 //
142
-                return 'E_USER_ERROR';
143
-            case E_USER_WARNING: // 512 //
144
-                return 'E_USER_WARNING';
145
-            case E_USER_NOTICE: // 1024 //
146
-                return 'E_USER_NOTICE';
147
-            case E_STRICT: // 2048 //
148
-                return 'E_STRICT';
149
-            case E_RECOVERABLE_ERROR: // 4096 //
150
-                return 'E_RECOVERABLE_ERROR';
151
-            case E_DEPRECATED: // 8192 //
152
-                return 'E_DEPRECATED';
153
-            case E_USER_DEPRECATED: // 16384 //
154
-                return 'E_USER_DEPRECATED';
155
-            case E_ALL: // 16384 //
156
-                return 'E_ALL';
157
-        }
158
-        return '';
159
-    }
160
-
161
-
162
-    /**
163
-     *    fatal_error_handler
164
-     *
165
-     * @return void
166
-     */
167
-    public static function fatal_error_handler()
168
-    {
169
-        $last_error = error_get_last();
170
-        if ($last_error['type'] === E_ERROR) {
171
-            EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
172
-        }
173
-    }
174
-
175
-
176
-    /**
177
-     * _format_error
178
-     *
179
-     * @param $code
180
-     * @param $message
181
-     * @param $file
182
-     * @param $line
183
-     * @return string
184
-     */
185
-    private static function _format_error($code, $message, $file, $line)
186
-    {
187
-        $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>";
188
-        $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>";
189
-        $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>";
190
-        $html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>";
191
-        $html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>";
192
-        $html .= '</tbody></table>';
193
-        return $html;
194
-    }
195
-
196
-
197
-    /**
198
-     * set_content_type
199
-     *
200
-     * @param $content_type
201
-     * @return string
202
-     */
203
-    public static function set_content_type($content_type)
204
-    {
205
-        return 'text/html';
206
-    }
207
-
208
-
209
-    /**
210
-     * @return void
211
-     * @throws EE_Error
212
-     * @throws ReflectionException
213
-     */
214
-    public function get_error()
215
-    {
216
-        if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) {
217
-            throw $this;
218
-        }
219
-        // get separate user and developer messages if they exist
220
-        $msg = explode('||', $this->getMessage());
221
-        $user_msg = $msg[0];
222
-        $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
223
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
224
-        // add details to _all_exceptions array
225
-        $x_time = time();
226
-        self::$_all_exceptions[ $x_time ]['name'] = get_class($this);
227
-        self::$_all_exceptions[ $x_time ]['file'] = $this->getFile();
228
-        self::$_all_exceptions[ $x_time ]['line'] = $this->getLine();
229
-        self::$_all_exceptions[ $x_time ]['msg'] = $msg;
230
-        self::$_all_exceptions[ $x_time ]['code'] = $this->getCode();
231
-        self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace();
232
-        self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString();
233
-        self::$_error_count++;
234
-        // add_action( 'shutdown', array( $this, 'display_errors' ));
235
-        $this->display_errors();
236
-    }
237
-
238
-
239
-    /**
240
-     * @param bool   $check_stored
241
-     * @param string $type_to_check
242
-     * @return bool
243
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
244
-     * @throws \InvalidArgumentException
245
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
246
-     * @throws InvalidInterfaceException
247
-     */
248
-    public static function has_error($check_stored = false, $type_to_check = 'errors')
249
-    {
250
-        $has_error = isset(self::$_espresso_notices[ $type_to_check ])
251
-                     && ! empty(self::$_espresso_notices[ $type_to_check ])
252
-            ? true
253
-            : false;
254
-        if ($check_stored && ! $has_error) {
255
-            $notices = EE_Error::getStoredNotices();
256
-            foreach ($notices as $type => $notice) {
257
-                if ($type === $type_to_check && $notice) {
258
-                    return true;
259
-                }
260
-            }
261
-        }
262
-        return $has_error;
263
-    }
264
-
265
-
266
-    /**
267
-     * @echo string
268
-     * @throws \ReflectionException
269
-     */
270
-    public function display_errors()
271
-    {
272
-        $trace_details = '';
273
-        $output = '
29
+	const OPTIONS_KEY_NOTICES = 'ee_notices';
30
+
31
+
32
+	/**
33
+	 * name of the file to log exceptions to
34
+	 *
35
+	 * @var string
36
+	 */
37
+	private static $_exception_log_file = 'espresso_error_log.txt';
38
+
39
+	/**
40
+	 *    stores details for all exception
41
+	 *
42
+	 * @var array
43
+	 */
44
+	private static $_all_exceptions = array();
45
+
46
+	/**
47
+	 *    tracks number of errors
48
+	 *
49
+	 * @var int
50
+	 */
51
+	private static $_error_count = 0;
52
+
53
+	/**
54
+	 * @var array $_espresso_notices
55
+	 */
56
+	private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false);
57
+
58
+
59
+	/**
60
+	 * @override default exception handling
61
+	 * @param string         $message
62
+	 * @param int            $code
63
+	 * @param Exception|null $previous
64
+	 */
65
+	public function __construct($message, $code = 0, Exception $previous = null)
66
+	{
67
+		if (version_compare(PHP_VERSION, '5.3.0', '<')) {
68
+			parent::__construct($message, $code);
69
+		} else {
70
+			parent::__construct($message, $code, $previous);
71
+		}
72
+	}
73
+
74
+
75
+	/**
76
+	 *    error_handler
77
+	 *
78
+	 * @param $code
79
+	 * @param $message
80
+	 * @param $file
81
+	 * @param $line
82
+	 * @return void
83
+	 */
84
+	public static function error_handler($code, $message, $file, $line)
85
+	{
86
+		$type = EE_Error::error_type($code);
87
+		$site = site_url();
88
+		switch ($site) {
89
+			case 'http://ee4.eventespresso.com/':
90
+			case 'http://ee4decaf.eventespresso.com/':
91
+			case 'http://ee4hf.eventespresso.com/':
92
+			case 'http://ee4a.eventespresso.com/':
93
+			case 'http://ee4ad.eventespresso.com/':
94
+			case 'http://ee4b.eventespresso.com/':
95
+			case 'http://ee4bd.eventespresso.com/':
96
+			case 'http://ee4d.eventespresso.com/':
97
+			case 'http://ee4dd.eventespresso.com/':
98
+				$to = '[email protected]';
99
+				break;
100
+			default:
101
+				$to = get_option('admin_email');
102
+		}
103
+		$subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
104
+		$msg = EE_Error::_format_error($type, $message, $file, $line);
105
+		if (function_exists('wp_mail')) {
106
+			add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
107
+			wp_mail($to, $subject, $msg);
108
+		}
109
+		echo '<div id="message" class="espresso-notices error"><p>';
110
+		echo wp_kses($type . ': ' . $message . '<br />' . $file . ' line ' . $line, AllowedTags::getWithFormTags());
111
+		echo '<br /></p></div>';
112
+	}
113
+
114
+
115
+	/**
116
+	 * error_type
117
+	 * http://www.php.net/manual/en/errorfunc.constants.php#109430
118
+	 *
119
+	 * @param $code
120
+	 * @return string
121
+	 */
122
+	public static function error_type($code)
123
+	{
124
+		switch ($code) {
125
+			case E_ERROR: // 1 //
126
+				return 'E_ERROR';
127
+			case E_WARNING: // 2 //
128
+				return 'E_WARNING';
129
+			case E_PARSE: // 4 //
130
+				return 'E_PARSE';
131
+			case E_NOTICE: // 8 //
132
+				return 'E_NOTICE';
133
+			case E_CORE_ERROR: // 16 //
134
+				return 'E_CORE_ERROR';
135
+			case E_CORE_WARNING: // 32 //
136
+				return 'E_CORE_WARNING';
137
+			case E_COMPILE_ERROR: // 64 //
138
+				return 'E_COMPILE_ERROR';
139
+			case E_COMPILE_WARNING: // 128 //
140
+				return 'E_COMPILE_WARNING';
141
+			case E_USER_ERROR: // 256 //
142
+				return 'E_USER_ERROR';
143
+			case E_USER_WARNING: // 512 //
144
+				return 'E_USER_WARNING';
145
+			case E_USER_NOTICE: // 1024 //
146
+				return 'E_USER_NOTICE';
147
+			case E_STRICT: // 2048 //
148
+				return 'E_STRICT';
149
+			case E_RECOVERABLE_ERROR: // 4096 //
150
+				return 'E_RECOVERABLE_ERROR';
151
+			case E_DEPRECATED: // 8192 //
152
+				return 'E_DEPRECATED';
153
+			case E_USER_DEPRECATED: // 16384 //
154
+				return 'E_USER_DEPRECATED';
155
+			case E_ALL: // 16384 //
156
+				return 'E_ALL';
157
+		}
158
+		return '';
159
+	}
160
+
161
+
162
+	/**
163
+	 *    fatal_error_handler
164
+	 *
165
+	 * @return void
166
+	 */
167
+	public static function fatal_error_handler()
168
+	{
169
+		$last_error = error_get_last();
170
+		if ($last_error['type'] === E_ERROR) {
171
+			EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
172
+		}
173
+	}
174
+
175
+
176
+	/**
177
+	 * _format_error
178
+	 *
179
+	 * @param $code
180
+	 * @param $message
181
+	 * @param $file
182
+	 * @param $line
183
+	 * @return string
184
+	 */
185
+	private static function _format_error($code, $message, $file, $line)
186
+	{
187
+		$html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>";
188
+		$html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>";
189
+		$html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>";
190
+		$html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>";
191
+		$html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>";
192
+		$html .= '</tbody></table>';
193
+		return $html;
194
+	}
195
+
196
+
197
+	/**
198
+	 * set_content_type
199
+	 *
200
+	 * @param $content_type
201
+	 * @return string
202
+	 */
203
+	public static function set_content_type($content_type)
204
+	{
205
+		return 'text/html';
206
+	}
207
+
208
+
209
+	/**
210
+	 * @return void
211
+	 * @throws EE_Error
212
+	 * @throws ReflectionException
213
+	 */
214
+	public function get_error()
215
+	{
216
+		if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) {
217
+			throw $this;
218
+		}
219
+		// get separate user and developer messages if they exist
220
+		$msg = explode('||', $this->getMessage());
221
+		$user_msg = $msg[0];
222
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
223
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
224
+		// add details to _all_exceptions array
225
+		$x_time = time();
226
+		self::$_all_exceptions[ $x_time ]['name'] = get_class($this);
227
+		self::$_all_exceptions[ $x_time ]['file'] = $this->getFile();
228
+		self::$_all_exceptions[ $x_time ]['line'] = $this->getLine();
229
+		self::$_all_exceptions[ $x_time ]['msg'] = $msg;
230
+		self::$_all_exceptions[ $x_time ]['code'] = $this->getCode();
231
+		self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace();
232
+		self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString();
233
+		self::$_error_count++;
234
+		// add_action( 'shutdown', array( $this, 'display_errors' ));
235
+		$this->display_errors();
236
+	}
237
+
238
+
239
+	/**
240
+	 * @param bool   $check_stored
241
+	 * @param string $type_to_check
242
+	 * @return bool
243
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
244
+	 * @throws \InvalidArgumentException
245
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
246
+	 * @throws InvalidInterfaceException
247
+	 */
248
+	public static function has_error($check_stored = false, $type_to_check = 'errors')
249
+	{
250
+		$has_error = isset(self::$_espresso_notices[ $type_to_check ])
251
+					 && ! empty(self::$_espresso_notices[ $type_to_check ])
252
+			? true
253
+			: false;
254
+		if ($check_stored && ! $has_error) {
255
+			$notices = EE_Error::getStoredNotices();
256
+			foreach ($notices as $type => $notice) {
257
+				if ($type === $type_to_check && $notice) {
258
+					return true;
259
+				}
260
+			}
261
+		}
262
+		return $has_error;
263
+	}
264
+
265
+
266
+	/**
267
+	 * @echo string
268
+	 * @throws \ReflectionException
269
+	 */
270
+	public function display_errors()
271
+	{
272
+		$trace_details = '';
273
+		$output = '
274 274
 <style type="text/css">
275 275
 	#ee-error-message {
276 276
 		max-width:90% !important;
@@ -326,21 +326,21 @@  discard block
 block discarded – undo
326 326
 	}
327 327
 </style>
328 328
 <div id="ee-error-message" class="error">';
329
-        if (! WP_DEBUG) {
330
-            $output .= '
329
+		if (! WP_DEBUG) {
330
+			$output .= '
331 331
 	<p>';
332
-        }
333
-        // cycle thru errors
334
-        foreach (self::$_all_exceptions as $time => $ex) {
335
-            $error_code = '';
336
-            // process trace info
337
-            if (empty($ex['trace'])) {
338
-                $trace_details .= esc_html__(
339
-                    'Sorry, but no trace information was available for this exception.',
340
-                    'event_espresso'
341
-                );
342
-            } else {
343
-                $trace_details .= '
332
+		}
333
+		// cycle thru errors
334
+		foreach (self::$_all_exceptions as $time => $ex) {
335
+			$error_code = '';
336
+			// process trace info
337
+			if (empty($ex['trace'])) {
338
+				$trace_details .= esc_html__(
339
+					'Sorry, but no trace information was available for this exception.',
340
+					'event_espresso'
341
+				);
342
+			} else {
343
+				$trace_details .= '
344 344
 			<div id="ee-trace-details">
345 345
 			<table width="100%" border="0" cellpadding="5" cellspacing="0">
346 346
 				<tr>
@@ -350,43 +350,43 @@  discard block
 block discarded – undo
350 350
 					<th scope="col" align="left">Class</th>
351 351
 					<th scope="col" align="left">Method( arguments )</th>
352 352
 				</tr>';
353
-                $last_on_stack = count($ex['trace']) - 1;
354
-                // reverse array so that stack is in proper chronological order
355
-                $sorted_trace = array_reverse($ex['trace']);
356
-                foreach ($sorted_trace as $nmbr => $trace) {
357
-                    $file = isset($trace['file']) ? $trace['file'] : '';
358
-                    $class = isset($trace['class']) ? $trace['class'] : '';
359
-                    $type = isset($trace['type']) ? $trace['type'] : '';
360
-                    $function = isset($trace['function']) ? $trace['function'] : '';
361
-                    $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
362
-                    $line = isset($trace['line']) ? $trace['line'] : '';
363
-                    $zebra = ($nmbr % 2) ? ' odd' : '';
364
-                    if (empty($file) && ! empty($class)) {
365
-                        $a = new ReflectionClass($class);
366
-                        $file = $a->getFileName();
367
-                        if (empty($line) && ! empty($function)) {
368
-                            try {
369
-                                // if $function is a closure, this throws an exception
370
-                                $b = new ReflectionMethod($class, $function);
371
-                                $line = $b->getStartLine();
372
-                            } catch (Exception $closure_exception) {
373
-                                $line = 'unknown';
374
-                            }
375
-                        }
376
-                    }
377
-                    if ($nmbr === $last_on_stack) {
378
-                        $file = $ex['file'] !== '' ? $ex['file'] : $file;
379
-                        $line = $ex['line'] !== '' ? $ex['line'] : $line;
380
-                        $error_code = self::generate_error_code($file, $trace['function'], $line);
381
-                    }
382
-                    $nmbr_dsply = ! empty($nmbr) ? $nmbr : '&nbsp;';
383
-                    $line_dsply = ! empty($line) ? $line : '&nbsp;';
384
-                    $file_dsply = ! empty($file) ? $file : '&nbsp;';
385
-                    $class_dsply = ! empty($class) ? $class : '&nbsp;';
386
-                    $type_dsply = ! empty($type) ? $type : '&nbsp;';
387
-                    $function_dsply = ! empty($function) ? $function : '&nbsp;';
388
-                    $args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
389
-                    $trace_details .= '
353
+				$last_on_stack = count($ex['trace']) - 1;
354
+				// reverse array so that stack is in proper chronological order
355
+				$sorted_trace = array_reverse($ex['trace']);
356
+				foreach ($sorted_trace as $nmbr => $trace) {
357
+					$file = isset($trace['file']) ? $trace['file'] : '';
358
+					$class = isset($trace['class']) ? $trace['class'] : '';
359
+					$type = isset($trace['type']) ? $trace['type'] : '';
360
+					$function = isset($trace['function']) ? $trace['function'] : '';
361
+					$args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
362
+					$line = isset($trace['line']) ? $trace['line'] : '';
363
+					$zebra = ($nmbr % 2) ? ' odd' : '';
364
+					if (empty($file) && ! empty($class)) {
365
+						$a = new ReflectionClass($class);
366
+						$file = $a->getFileName();
367
+						if (empty($line) && ! empty($function)) {
368
+							try {
369
+								// if $function is a closure, this throws an exception
370
+								$b = new ReflectionMethod($class, $function);
371
+								$line = $b->getStartLine();
372
+							} catch (Exception $closure_exception) {
373
+								$line = 'unknown';
374
+							}
375
+						}
376
+					}
377
+					if ($nmbr === $last_on_stack) {
378
+						$file = $ex['file'] !== '' ? $ex['file'] : $file;
379
+						$line = $ex['line'] !== '' ? $ex['line'] : $line;
380
+						$error_code = self::generate_error_code($file, $trace['function'], $line);
381
+					}
382
+					$nmbr_dsply = ! empty($nmbr) ? $nmbr : '&nbsp;';
383
+					$line_dsply = ! empty($line) ? $line : '&nbsp;';
384
+					$file_dsply = ! empty($file) ? $file : '&nbsp;';
385
+					$class_dsply = ! empty($class) ? $class : '&nbsp;';
386
+					$type_dsply = ! empty($type) ? $type : '&nbsp;';
387
+					$function_dsply = ! empty($function) ? $function : '&nbsp;';
388
+					$args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
389
+					$trace_details .= '
390 390
 					<tr>
391 391
 						<td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td>
392 392
 						<td align="right" class="' . $zebra . '">' . $line_dsply . '</td>
@@ -394,628 +394,628 @@  discard block
 block discarded – undo
394 394
 						<td align="left" class="' . $zebra . '">' . $class_dsply . '</td>
395 395
 						<td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td>
396 396
 					</tr>';
397
-                }
398
-                $trace_details .= '
397
+				}
398
+				$trace_details .= '
399 399
 			 </table>
400 400
 			</div>';
401
-            }
402
-            $ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
403
-            // add generic non-identifying messages for non-privileged users
404
-            if (! WP_DEBUG) {
405
-                $output .= '<span class="ee-error-user-msg-spn">'
406
-                           . trim($ex['msg'])
407
-                           . '</span> &nbsp; <sup>'
408
-                           . $ex['code']
409
-                           . '</sup><br />';
410
-            } else {
411
-                // or helpful developer messages if debugging is on
412
-                $output .= '
401
+			}
402
+			$ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
403
+			// add generic non-identifying messages for non-privileged users
404
+			if (! WP_DEBUG) {
405
+				$output .= '<span class="ee-error-user-msg-spn">'
406
+						   . trim($ex['msg'])
407
+						   . '</span> &nbsp; <sup>'
408
+						   . $ex['code']
409
+						   . '</sup><br />';
410
+			} else {
411
+				// or helpful developer messages if debugging is on
412
+				$output .= '
413 413
 		<div class="ee-error-dev-msg-dv">
414 414
 			<p class="ee-error-dev-msg-pg">
415 415
 				<strong class="ee-error-dev-msg-str">An '
416
-                           . $ex['name']
417
-                           . ' exception was thrown!</strong>  &nbsp; <span>code: '
418
-                           . $ex['code']
419
-                           . '</span><br />
416
+						   . $ex['name']
417
+						   . ' exception was thrown!</strong>  &nbsp; <span>code: '
418
+						   . $ex['code']
419
+						   . '</span><br />
420 420
 				<span class="big-text">"'
421
-                           . trim($ex['msg'])
422
-                           . '"</span><br/>
421
+						   . trim($ex['msg'])
422
+						   . '"</span><br/>
423 423
 				<a id="display-ee-error-trace-'
424
-                           . self::$_error_count
425
-                           . $time
426
-                           . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'
427
-                           . self::$_error_count
428
-                           . $time
429
-                           . '">
424
+						   . self::$_error_count
425
+						   . $time
426
+						   . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'
427
+						   . self::$_error_count
428
+						   . $time
429
+						   . '">
430 430
 					'
431
-                           . esc_html__('click to view backtrace and class/method details', 'event_espresso')
432
-                           . '
431
+						   . esc_html__('click to view backtrace and class/method details', 'event_espresso')
432
+						   . '
433 433
 				</a><br />
434 434
 				<span class="small-text lt-grey-text">'
435
-                           . $ex['file']
436
-                           . ' &nbsp; ( line no: '
437
-                           . $ex['line']
438
-                           . ' )</span>
435
+						   . $ex['file']
436
+						   . ' &nbsp; ( line no: '
437
+						   . $ex['line']
438
+						   . ' )</span>
439 439
 			</p>
440 440
 			<div id="ee-error-trace-'
441
-                           . self::$_error_count
442
-                           . $time
443
-                           . '-dv" class="ee-error-trace-dv" style="display: none;">
441
+						   . self::$_error_count
442
+						   . $time
443
+						   . '-dv" class="ee-error-trace-dv" style="display: none;">
444 444
 				'
445
-                           . $trace_details;
446
-                if (! empty($class)) {
447
-                    $output .= '
445
+						   . $trace_details;
446
+				if (! empty($class)) {
447
+					$output .= '
448 448
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;">
449 449
 					<div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;">
450 450
 						<h3>Class Details</h3>';
451
-                    $a = new ReflectionClass($class);
452
-                    $output .= '
451
+					$a = new ReflectionClass($class);
452
+					$output .= '
453 453
 						<pre>' . $a . '</pre>
454 454
 					</div>
455 455
 				</div>';
456
-                }
457
-                $output .= '
456
+				}
457
+				$output .= '
458 458
 			</div>
459 459
 		</div>
460 460
 		<br />';
461
-            }
462
-            $this->write_to_error_log($time, $ex);
463
-        }
464
-        // remove last linebreak
465
-        $output = substr($output, 0, -6);
466
-        if (! WP_DEBUG) {
467
-            $output .= '
461
+			}
462
+			$this->write_to_error_log($time, $ex);
463
+		}
464
+		// remove last linebreak
465
+		$output = substr($output, 0, -6);
466
+		if (! WP_DEBUG) {
467
+			$output .= '
468 468
 	</p>';
469
-        }
470
-        $output .= '
469
+		}
470
+		$output .= '
471 471
 </div>';
472
-        $output .= self::_print_scripts(true);
473
-        if (defined('DOING_AJAX')) {
474
-            echo wp_json_encode(array('error' => $output));
475
-            exit();
476
-        }
477
-        echo $output;
478
-        die();
479
-    }
480
-
481
-
482
-    /**
483
-     *    generate string from exception trace args
484
-     *
485
-     * @param array $arguments
486
-     * @param bool  $array
487
-     * @return string
488
-     */
489
-    private function _convert_args_to_string($arguments = array(), $array = false)
490
-    {
491
-        $arg_string = '';
492
-        if (! empty($arguments)) {
493
-            $args = array();
494
-            foreach ($arguments as $arg) {
495
-                if (! empty($arg)) {
496
-                    if (is_string($arg)) {
497
-                        $args[] = " '" . $arg . "'";
498
-                    } elseif (is_array($arg)) {
499
-                        $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
500
-                    } elseif ($arg === null) {
501
-                        $args[] = ' NULL';
502
-                    } elseif (is_bool($arg)) {
503
-                        $args[] = ($arg) ? ' TRUE' : ' FALSE';
504
-                    } elseif (is_object($arg)) {
505
-                        $args[] = ' OBJECT ' . get_class($arg);
506
-                    } elseif (is_resource($arg)) {
507
-                        $args[] = get_resource_type($arg);
508
-                    } else {
509
-                        $args[] = $arg;
510
-                    }
511
-                }
512
-            }
513
-            $arg_string = implode(', ', $args);
514
-        }
515
-        if ($array) {
516
-            $arg_string .= ' )';
517
-        }
518
-        return $arg_string;
519
-    }
520
-
521
-
522
-    /**
523
-     *    add error message
524
-     *
525
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
526
-     *                            separate messages for user || dev
527
-     * @param        string $file the file that the error occurred in - just use __FILE__
528
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
529
-     * @param        string $line the line number where the error occurred - just use __LINE__
530
-     * @return        void
531
-     */
532
-    public static function add_error($msg = null, $file = null, $func = null, $line = null)
533
-    {
534
-        self::_add_notice('errors', $msg, $file, $func, $line);
535
-        self::$_error_count++;
536
-    }
537
-
538
-
539
-    /**
540
-     * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just
541
-     * adds an error
542
-     *
543
-     * @param string $msg
544
-     * @param string $file
545
-     * @param string $func
546
-     * @param string $line
547
-     * @throws EE_Error
548
-     */
549
-    public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null)
550
-    {
551
-        if (WP_DEBUG) {
552
-            throw new EE_Error($msg);
553
-        }
554
-        EE_Error::add_error($msg, $file, $func, $line);
555
-    }
556
-
557
-
558
-    /**
559
-     *    add success message
560
-     *
561
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
562
-     *                            separate messages for user || dev
563
-     * @param        string $file the file that the error occurred in - just use __FILE__
564
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
565
-     * @param        string $line the line number where the error occurred - just use __LINE__
566
-     * @return        void
567
-     */
568
-    public static function add_success($msg = null, $file = null, $func = null, $line = null)
569
-    {
570
-        self::_add_notice('success', $msg, $file, $func, $line);
571
-    }
572
-
573
-
574
-    /**
575
-     *    add attention message
576
-     *
577
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
578
-     *                            separate messages for user || dev
579
-     * @param        string $file the file that the error occurred in - just use __FILE__
580
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
581
-     * @param        string $line the line number where the error occurred - just use __LINE__
582
-     * @return        void
583
-     */
584
-    public static function add_attention($msg = null, $file = null, $func = null, $line = null)
585
-    {
586
-        self::_add_notice('attention', $msg, $file, $func, $line);
587
-    }
588
-
589
-
590
-    /**
591
-     * @param string $type whether the message is for a success or error notification
592
-     * @param string $msg  the message to display to users or developers
593
-     *                     - adding a double pipe || (OR) creates separate messages for user || dev
594
-     * @param string $file the file that the error occurred in - just use __FILE__
595
-     * @param string $func the function/method that the error occurred in - just use __FUNCTION__
596
-     * @param string $line the line number where the error occurred - just use __LINE__
597
-     * @return void
598
-     */
599
-    private static function _add_notice($type = 'success', $msg = '', $file = '', $func = '', $line = '')
600
-    {
601
-        if (empty($msg)) {
602
-            EE_Error::doing_it_wrong(
603
-                'EE_Error::add_' . $type . '()',
604
-                sprintf(
605
-                    esc_html__(
606
-                        'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
607
-                        'event_espresso'
608
-                    ),
609
-                    $type,
610
-                    $file,
611
-                    $line
612
-                ),
613
-                EVENT_ESPRESSO_VERSION
614
-            );
615
-        }
616
-        if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) {
617
-            EE_Error::doing_it_wrong(
618
-                'EE_Error::add_error()',
619
-                esc_html__(
620
-                    'You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.',
621
-                    'event_espresso'
622
-                ),
623
-                EVENT_ESPRESSO_VERSION
624
-            );
625
-        }
626
-        // get separate user and developer messages if they exist
627
-        $msg = explode('||', $msg);
628
-        $user_msg = $msg[0];
629
-        $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
630
-        /**
631
-         * Do an action so other code can be triggered when a notice is created
632
-         *
633
-         * @param string $type     can be 'errors', 'attention', or 'success'
634
-         * @param string $user_msg message displayed to user when WP_DEBUG is off
635
-         * @param string $user_msg message displayed to user when WP_DEBUG is on
636
-         * @param string $file     file where error was generated
637
-         * @param string $func     function where error was generated
638
-         * @param string $line     line where error was generated
639
-         */
640
-        do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
641
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
642
-        // add notice if message exists
643
-        if (! empty($msg)) {
644
-            // get error code
645
-            $notice_code = EE_Error::generate_error_code($file, $func, $line);
646
-            if (WP_DEBUG && $type === 'errors') {
647
-                $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
648
-            }
649
-            // add notice. Index by code if it's not blank
650
-            if ($notice_code) {
651
-                self::$_espresso_notices[ $type ][ $notice_code ] = $msg;
652
-            } else {
653
-                self::$_espresso_notices[ $type ][] = $msg;
654
-            }
655
-            add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
656
-        }
657
-    }
658
-
659
-
660
-    /**
661
-     * in some case it may be necessary to overwrite the existing success messages
662
-     *
663
-     * @return        void
664
-     */
665
-    public static function overwrite_success()
666
-    {
667
-        self::$_espresso_notices['success'] = false;
668
-    }
669
-
670
-
671
-    /**
672
-     * in some case it may be necessary to overwrite the existing attention messages
673
-     *
674
-     * @return void
675
-     */
676
-    public static function overwrite_attention()
677
-    {
678
-        self::$_espresso_notices['attention'] = false;
679
-    }
680
-
681
-
682
-    /**
683
-     * in some case it may be necessary to overwrite the existing error messages
684
-     *
685
-     * @return void
686
-     */
687
-    public static function overwrite_errors()
688
-    {
689
-        self::$_espresso_notices['errors'] = false;
690
-    }
691
-
692
-
693
-    /**
694
-     * @return void
695
-     */
696
-    public static function reset_notices()
697
-    {
698
-        self::$_espresso_notices['success'] = false;
699
-        self::$_espresso_notices['attention'] = false;
700
-        self::$_espresso_notices['errors'] = false;
701
-    }
702
-
703
-
704
-    /**
705
-     * @return int
706
-     */
707
-    public static function has_notices()
708
-    {
709
-        $has_notices = 0;
710
-        // check for success messages
711
-        $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])
712
-            ? 3
713
-            : $has_notices;
714
-        // check for attention messages
715
-        $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])
716
-            ? 2
717
-            : $has_notices;
718
-        // check for error messages
719
-        $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])
720
-            ? 1
721
-            : $has_notices;
722
-        return $has_notices;
723
-    }
724
-
725
-
726
-    /**
727
-     * This simply returns non formatted error notices as they were sent into the EE_Error object.
728
-     *
729
-     * @since 4.9.0
730
-     * @return array
731
-     */
732
-    public static function get_vanilla_notices()
733
-    {
734
-        return array(
735
-            'success'   => isset(self::$_espresso_notices['success'])
736
-                ? self::$_espresso_notices['success']
737
-                : array(),
738
-            'attention' => isset(self::$_espresso_notices['attention'])
739
-                ? self::$_espresso_notices['attention']
740
-                : array(),
741
-            'errors'    => isset(self::$_espresso_notices['errors'])
742
-                ? self::$_espresso_notices['errors']
743
-                : array(),
744
-        );
745
-    }
746
-
747
-
748
-    /**
749
-     * @return array
750
-     * @throws InvalidArgumentException
751
-     * @throws InvalidDataTypeException
752
-     * @throws InvalidInterfaceException
753
-     */
754
-    public static function getStoredNotices()
755
-    {
756
-        if ($user_id = get_current_user_id()) {
757
-            // get notices for logged in user
758
-            $notices = get_user_option(EE_Error::OPTIONS_KEY_NOTICES, $user_id);
759
-            return is_array($notices) ? $notices : array();
760
-        }
761
-        if (EE_Session::isLoadedAndActive()) {
762
-            // get notices for user currently engaged in a session
763
-            $session_data = EE_Session::instance()->get_session_data(EE_Error::OPTIONS_KEY_NOTICES);
764
-            return is_array($session_data) ? $session_data : array();
765
-        }
766
-        // get global notices and hope they apply to the current site visitor
767
-        $notices = get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
768
-        return is_array($notices) ? $notices : array();
769
-    }
770
-
771
-
772
-    /**
773
-     * @param array $notices
774
-     * @return bool
775
-     * @throws InvalidArgumentException
776
-     * @throws InvalidDataTypeException
777
-     * @throws InvalidInterfaceException
778
-     */
779
-    public static function storeNotices(array $notices)
780
-    {
781
-        if ($user_id = get_current_user_id()) {
782
-            // store notices for logged in user
783
-            return (bool) update_user_option(
784
-                $user_id,
785
-                EE_Error::OPTIONS_KEY_NOTICES,
786
-                $notices
787
-            );
788
-        }
789
-        if (EE_Session::isLoadedAndActive()) {
790
-            // store notices for user currently engaged in a session
791
-            return EE_Session::instance()->set_session_data(
792
-                array(EE_Error::OPTIONS_KEY_NOTICES => $notices)
793
-            );
794
-        }
795
-        // store global notices and hope they apply to the same site visitor on the next request
796
-        return update_option(EE_Error::OPTIONS_KEY_NOTICES, $notices);
797
-    }
798
-
799
-
800
-    /**
801
-     * @return bool|TRUE
802
-     * @throws InvalidArgumentException
803
-     * @throws InvalidDataTypeException
804
-     * @throws InvalidInterfaceException
805
-     */
806
-    public static function clearNotices()
807
-    {
808
-        if ($user_id = get_current_user_id()) {
809
-            // clear notices for logged in user
810
-            return (bool) update_user_option(
811
-                $user_id,
812
-                EE_Error::OPTIONS_KEY_NOTICES,
813
-                array()
814
-            );
815
-        }
816
-        if (EE_Session::isLoadedAndActive()) {
817
-            // clear notices for user currently engaged in a session
818
-            return EE_Session::instance()->reset_data(EE_Error::OPTIONS_KEY_NOTICES);
819
-        }
820
-        // clear global notices and hope none belonged to some for some other site visitor
821
-        return update_option(EE_Error::OPTIONS_KEY_NOTICES, array());
822
-    }
823
-
824
-
825
-    /**
826
-     * saves notices to the db for retrieval on next request
827
-     *
828
-     * @return void
829
-     * @throws InvalidArgumentException
830
-     * @throws InvalidDataTypeException
831
-     * @throws InvalidInterfaceException
832
-     */
833
-    public static function stashNoticesBeforeRedirect()
834
-    {
835
-        EE_Error::get_notices(false, true);
836
-    }
837
-
838
-
839
-    /**
840
-     * compile all error or success messages into one string
841
-     *
842
-     * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them
843
-     * @param boolean $format_output            whether or not to format the messages for display in the WP admin
844
-     * @param boolean $save_to_transient        whether or not to save notices to the db for retrieval on next request
845
-     *                                          - ONLY do this just before redirecting
846
-     * @param boolean $remove_empty             whether or not to unset empty messages
847
-     * @return array
848
-     * @throws InvalidArgumentException
849
-     * @throws InvalidDataTypeException
850
-     * @throws InvalidInterfaceException
851
-     */
852
-    public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true)
853
-    {
854
-        $success_messages = '';
855
-        $attention_messages = '';
856
-        $error_messages = '';
857
-        /** @var RequestInterface $request */
858
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
859
-        // either save notices to the db
860
-        if ($save_to_transient || $request->requestParamIsSet('activate-selected')) {
861
-            self::$_espresso_notices = array_merge(
862
-                EE_Error::getStoredNotices(),
863
-                self::$_espresso_notices
864
-            );
865
-            EE_Error::storeNotices(self::$_espresso_notices);
866
-            return array();
867
-        }
868
-        $print_scripts = EE_Error::combineExistingAndNewNotices();
869
-        // check for success messages
870
-        if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
871
-            // combine messages
872
-            $success_messages .= implode('<br />', self::$_espresso_notices['success']);
873
-            $print_scripts = true;
874
-        }
875
-        // check for attention messages
876
-        if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
877
-            // combine messages
878
-            $attention_messages .= implode('<br />', self::$_espresso_notices['attention']);
879
-            $print_scripts = true;
880
-        }
881
-        // check for error messages
882
-        if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
883
-            $error_messages .= count(self::$_espresso_notices['errors']) > 1
884
-                ? esc_html__('The following errors have occurred:', 'event_espresso')
885
-                : esc_html__('An error has occurred:', 'event_espresso');
886
-            // combine messages
887
-            $error_messages .= '<br />' . implode('<br />', self::$_espresso_notices['errors']);
888
-            $print_scripts = true;
889
-        }
890
-        if ($format_output) {
891
-            $notices = EE_Error::formatNoticesOutput(
892
-                $success_messages,
893
-                $attention_messages,
894
-                $error_messages
895
-            );
896
-        } else {
897
-            $notices = array(
898
-                'success'   => $success_messages,
899
-                'attention' => $attention_messages,
900
-                'errors'    => $error_messages,
901
-            );
902
-            if ($remove_empty) {
903
-                // remove empty notices
904
-                foreach ($notices as $type => $notice) {
905
-                    if (empty($notice)) {
906
-                        unset($notices[ $type ]);
907
-                    }
908
-                }
909
-            }
910
-        }
911
-        if ($print_scripts) {
912
-            self::_print_scripts();
913
-        }
914
-        return $notices;
915
-    }
916
-
917
-
918
-    /**
919
-     * @return bool
920
-     * @throws InvalidArgumentException
921
-     * @throws InvalidDataTypeException
922
-     * @throws InvalidInterfaceException
923
-     */
924
-    private static function combineExistingAndNewNotices()
925
-    {
926
-        $print_scripts = false;
927
-        // grab any notices that have been previously saved
928
-        $notices = EE_Error::getStoredNotices();
929
-        if (! empty($notices)) {
930
-            foreach ($notices as $type => $notice) {
931
-                if (is_array($notice) && ! empty($notice)) {
932
-                    // make sure that existing notice type is an array
933
-                    self::$_espresso_notices[ $type ] = is_array(self::$_espresso_notices[ $type ])
934
-                                                        && ! empty(self::$_espresso_notices[ $type ])
935
-                        ? self::$_espresso_notices[ $type ]
936
-                        : array();
937
-                    // add newly created notices to existing ones
938
-                    self::$_espresso_notices[ $type ] += $notice;
939
-                    $print_scripts = true;
940
-                }
941
-            }
942
-            // now clear any stored notices
943
-            EE_Error::clearNotices();
944
-        }
945
-        return $print_scripts;
946
-    }
947
-
948
-
949
-    /**
950
-     * @param string $success_messages
951
-     * @param string $attention_messages
952
-     * @param string $error_messages
953
-     * @return string
954
-     */
955
-    private static function formatNoticesOutput($success_messages, $attention_messages, $error_messages)
956
-    {
957
-        $notices = '<div id="espresso-notices">';
958
-        $close = is_admin()
959
-            ? ''
960
-            : '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"/></a>';
961
-        if ($success_messages !== '') {
962
-            $css_id = is_admin() ? 'ee-success-message' : 'espresso-notices-success';
963
-            $css_class = is_admin() ? 'updated fade' : 'success fade-away';
964
-            // showMessage( $success_messages );
965
-            $notices .= '<div id="' . $css_id . '" '
966
-                        . 'class="espresso-notices ' . $css_class . '" '
967
-                        . 'style="display:none;">'
968
-                        . '<p>' . $success_messages . '</p>'
969
-                        . $close
970
-                        . '</div>';
971
-        }
972
-        if ($attention_messages !== '') {
973
-            $css_id = is_admin() ? 'ee-attention-message' : 'espresso-notices-attention';
974
-            $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
975
-            // showMessage( $error_messages, TRUE );
976
-            $notices .= '<div id="' . $css_id . '" '
977
-                        . 'class="espresso-notices ' . $css_class . '" '
978
-                        . 'style="display:none;">'
979
-                        . '<p>' . $attention_messages . '</p>'
980
-                        . $close
981
-                        . '</div>';
982
-        }
983
-        if ($error_messages !== '') {
984
-            $css_id = is_admin() ? 'ee-error-message' : 'espresso-notices-error';
985
-            $css_class = is_admin() ? 'error' : 'error fade-away';
986
-            // showMessage( $error_messages, TRUE );
987
-            $notices .= '<div id="' . $css_id . '" '
988
-                        . 'class="espresso-notices ' . $css_class . '" '
989
-                        . 'style="display:none;">'
990
-                        . '<p>' . $error_messages . '</p>'
991
-                        . $close
992
-                        . '</div>';
993
-        }
994
-        $notices .= '</div>';
995
-        return $notices;
996
-    }
997
-
998
-
999
-    /**
1000
-     * _print_scripts
1001
-     *
1002
-     * @param    bool $force_print
1003
-     * @return    string
1004
-     */
1005
-    private static function _print_scripts($force_print = false)
1006
-    {
1007
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
1008
-            if (wp_script_is('ee_error_js', 'registered')) {
1009
-                wp_enqueue_style('espresso_default');
1010
-                wp_enqueue_style('espresso_custom_css');
1011
-                wp_enqueue_script('ee_error_js');
1012
-            }
1013
-            if (wp_script_is('ee_error_js', 'enqueued')) {
1014
-                wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
1015
-                return '';
1016
-            }
1017
-        } else {
1018
-            return '
472
+		$output .= self::_print_scripts(true);
473
+		if (defined('DOING_AJAX')) {
474
+			echo wp_json_encode(array('error' => $output));
475
+			exit();
476
+		}
477
+		echo $output;
478
+		die();
479
+	}
480
+
481
+
482
+	/**
483
+	 *    generate string from exception trace args
484
+	 *
485
+	 * @param array $arguments
486
+	 * @param bool  $array
487
+	 * @return string
488
+	 */
489
+	private function _convert_args_to_string($arguments = array(), $array = false)
490
+	{
491
+		$arg_string = '';
492
+		if (! empty($arguments)) {
493
+			$args = array();
494
+			foreach ($arguments as $arg) {
495
+				if (! empty($arg)) {
496
+					if (is_string($arg)) {
497
+						$args[] = " '" . $arg . "'";
498
+					} elseif (is_array($arg)) {
499
+						$args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
500
+					} elseif ($arg === null) {
501
+						$args[] = ' NULL';
502
+					} elseif (is_bool($arg)) {
503
+						$args[] = ($arg) ? ' TRUE' : ' FALSE';
504
+					} elseif (is_object($arg)) {
505
+						$args[] = ' OBJECT ' . get_class($arg);
506
+					} elseif (is_resource($arg)) {
507
+						$args[] = get_resource_type($arg);
508
+					} else {
509
+						$args[] = $arg;
510
+					}
511
+				}
512
+			}
513
+			$arg_string = implode(', ', $args);
514
+		}
515
+		if ($array) {
516
+			$arg_string .= ' )';
517
+		}
518
+		return $arg_string;
519
+	}
520
+
521
+
522
+	/**
523
+	 *    add error message
524
+	 *
525
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
526
+	 *                            separate messages for user || dev
527
+	 * @param        string $file the file that the error occurred in - just use __FILE__
528
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
529
+	 * @param        string $line the line number where the error occurred - just use __LINE__
530
+	 * @return        void
531
+	 */
532
+	public static function add_error($msg = null, $file = null, $func = null, $line = null)
533
+	{
534
+		self::_add_notice('errors', $msg, $file, $func, $line);
535
+		self::$_error_count++;
536
+	}
537
+
538
+
539
+	/**
540
+	 * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just
541
+	 * adds an error
542
+	 *
543
+	 * @param string $msg
544
+	 * @param string $file
545
+	 * @param string $func
546
+	 * @param string $line
547
+	 * @throws EE_Error
548
+	 */
549
+	public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null)
550
+	{
551
+		if (WP_DEBUG) {
552
+			throw new EE_Error($msg);
553
+		}
554
+		EE_Error::add_error($msg, $file, $func, $line);
555
+	}
556
+
557
+
558
+	/**
559
+	 *    add success message
560
+	 *
561
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
562
+	 *                            separate messages for user || dev
563
+	 * @param        string $file the file that the error occurred in - just use __FILE__
564
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
565
+	 * @param        string $line the line number where the error occurred - just use __LINE__
566
+	 * @return        void
567
+	 */
568
+	public static function add_success($msg = null, $file = null, $func = null, $line = null)
569
+	{
570
+		self::_add_notice('success', $msg, $file, $func, $line);
571
+	}
572
+
573
+
574
+	/**
575
+	 *    add attention message
576
+	 *
577
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
578
+	 *                            separate messages for user || dev
579
+	 * @param        string $file the file that the error occurred in - just use __FILE__
580
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
581
+	 * @param        string $line the line number where the error occurred - just use __LINE__
582
+	 * @return        void
583
+	 */
584
+	public static function add_attention($msg = null, $file = null, $func = null, $line = null)
585
+	{
586
+		self::_add_notice('attention', $msg, $file, $func, $line);
587
+	}
588
+
589
+
590
+	/**
591
+	 * @param string $type whether the message is for a success or error notification
592
+	 * @param string $msg  the message to display to users or developers
593
+	 *                     - adding a double pipe || (OR) creates separate messages for user || dev
594
+	 * @param string $file the file that the error occurred in - just use __FILE__
595
+	 * @param string $func the function/method that the error occurred in - just use __FUNCTION__
596
+	 * @param string $line the line number where the error occurred - just use __LINE__
597
+	 * @return void
598
+	 */
599
+	private static function _add_notice($type = 'success', $msg = '', $file = '', $func = '', $line = '')
600
+	{
601
+		if (empty($msg)) {
602
+			EE_Error::doing_it_wrong(
603
+				'EE_Error::add_' . $type . '()',
604
+				sprintf(
605
+					esc_html__(
606
+						'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
607
+						'event_espresso'
608
+					),
609
+					$type,
610
+					$file,
611
+					$line
612
+				),
613
+				EVENT_ESPRESSO_VERSION
614
+			);
615
+		}
616
+		if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) {
617
+			EE_Error::doing_it_wrong(
618
+				'EE_Error::add_error()',
619
+				esc_html__(
620
+					'You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.',
621
+					'event_espresso'
622
+				),
623
+				EVENT_ESPRESSO_VERSION
624
+			);
625
+		}
626
+		// get separate user and developer messages if they exist
627
+		$msg = explode('||', $msg);
628
+		$user_msg = $msg[0];
629
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
630
+		/**
631
+		 * Do an action so other code can be triggered when a notice is created
632
+		 *
633
+		 * @param string $type     can be 'errors', 'attention', or 'success'
634
+		 * @param string $user_msg message displayed to user when WP_DEBUG is off
635
+		 * @param string $user_msg message displayed to user when WP_DEBUG is on
636
+		 * @param string $file     file where error was generated
637
+		 * @param string $func     function where error was generated
638
+		 * @param string $line     line where error was generated
639
+		 */
640
+		do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
641
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
642
+		// add notice if message exists
643
+		if (! empty($msg)) {
644
+			// get error code
645
+			$notice_code = EE_Error::generate_error_code($file, $func, $line);
646
+			if (WP_DEBUG && $type === 'errors') {
647
+				$msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
648
+			}
649
+			// add notice. Index by code if it's not blank
650
+			if ($notice_code) {
651
+				self::$_espresso_notices[ $type ][ $notice_code ] = $msg;
652
+			} else {
653
+				self::$_espresso_notices[ $type ][] = $msg;
654
+			}
655
+			add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
656
+		}
657
+	}
658
+
659
+
660
+	/**
661
+	 * in some case it may be necessary to overwrite the existing success messages
662
+	 *
663
+	 * @return        void
664
+	 */
665
+	public static function overwrite_success()
666
+	{
667
+		self::$_espresso_notices['success'] = false;
668
+	}
669
+
670
+
671
+	/**
672
+	 * in some case it may be necessary to overwrite the existing attention messages
673
+	 *
674
+	 * @return void
675
+	 */
676
+	public static function overwrite_attention()
677
+	{
678
+		self::$_espresso_notices['attention'] = false;
679
+	}
680
+
681
+
682
+	/**
683
+	 * in some case it may be necessary to overwrite the existing error messages
684
+	 *
685
+	 * @return void
686
+	 */
687
+	public static function overwrite_errors()
688
+	{
689
+		self::$_espresso_notices['errors'] = false;
690
+	}
691
+
692
+
693
+	/**
694
+	 * @return void
695
+	 */
696
+	public static function reset_notices()
697
+	{
698
+		self::$_espresso_notices['success'] = false;
699
+		self::$_espresso_notices['attention'] = false;
700
+		self::$_espresso_notices['errors'] = false;
701
+	}
702
+
703
+
704
+	/**
705
+	 * @return int
706
+	 */
707
+	public static function has_notices()
708
+	{
709
+		$has_notices = 0;
710
+		// check for success messages
711
+		$has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])
712
+			? 3
713
+			: $has_notices;
714
+		// check for attention messages
715
+		$has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])
716
+			? 2
717
+			: $has_notices;
718
+		// check for error messages
719
+		$has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])
720
+			? 1
721
+			: $has_notices;
722
+		return $has_notices;
723
+	}
724
+
725
+
726
+	/**
727
+	 * This simply returns non formatted error notices as they were sent into the EE_Error object.
728
+	 *
729
+	 * @since 4.9.0
730
+	 * @return array
731
+	 */
732
+	public static function get_vanilla_notices()
733
+	{
734
+		return array(
735
+			'success'   => isset(self::$_espresso_notices['success'])
736
+				? self::$_espresso_notices['success']
737
+				: array(),
738
+			'attention' => isset(self::$_espresso_notices['attention'])
739
+				? self::$_espresso_notices['attention']
740
+				: array(),
741
+			'errors'    => isset(self::$_espresso_notices['errors'])
742
+				? self::$_espresso_notices['errors']
743
+				: array(),
744
+		);
745
+	}
746
+
747
+
748
+	/**
749
+	 * @return array
750
+	 * @throws InvalidArgumentException
751
+	 * @throws InvalidDataTypeException
752
+	 * @throws InvalidInterfaceException
753
+	 */
754
+	public static function getStoredNotices()
755
+	{
756
+		if ($user_id = get_current_user_id()) {
757
+			// get notices for logged in user
758
+			$notices = get_user_option(EE_Error::OPTIONS_KEY_NOTICES, $user_id);
759
+			return is_array($notices) ? $notices : array();
760
+		}
761
+		if (EE_Session::isLoadedAndActive()) {
762
+			// get notices for user currently engaged in a session
763
+			$session_data = EE_Session::instance()->get_session_data(EE_Error::OPTIONS_KEY_NOTICES);
764
+			return is_array($session_data) ? $session_data : array();
765
+		}
766
+		// get global notices and hope they apply to the current site visitor
767
+		$notices = get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
768
+		return is_array($notices) ? $notices : array();
769
+	}
770
+
771
+
772
+	/**
773
+	 * @param array $notices
774
+	 * @return bool
775
+	 * @throws InvalidArgumentException
776
+	 * @throws InvalidDataTypeException
777
+	 * @throws InvalidInterfaceException
778
+	 */
779
+	public static function storeNotices(array $notices)
780
+	{
781
+		if ($user_id = get_current_user_id()) {
782
+			// store notices for logged in user
783
+			return (bool) update_user_option(
784
+				$user_id,
785
+				EE_Error::OPTIONS_KEY_NOTICES,
786
+				$notices
787
+			);
788
+		}
789
+		if (EE_Session::isLoadedAndActive()) {
790
+			// store notices for user currently engaged in a session
791
+			return EE_Session::instance()->set_session_data(
792
+				array(EE_Error::OPTIONS_KEY_NOTICES => $notices)
793
+			);
794
+		}
795
+		// store global notices and hope they apply to the same site visitor on the next request
796
+		return update_option(EE_Error::OPTIONS_KEY_NOTICES, $notices);
797
+	}
798
+
799
+
800
+	/**
801
+	 * @return bool|TRUE
802
+	 * @throws InvalidArgumentException
803
+	 * @throws InvalidDataTypeException
804
+	 * @throws InvalidInterfaceException
805
+	 */
806
+	public static function clearNotices()
807
+	{
808
+		if ($user_id = get_current_user_id()) {
809
+			// clear notices for logged in user
810
+			return (bool) update_user_option(
811
+				$user_id,
812
+				EE_Error::OPTIONS_KEY_NOTICES,
813
+				array()
814
+			);
815
+		}
816
+		if (EE_Session::isLoadedAndActive()) {
817
+			// clear notices for user currently engaged in a session
818
+			return EE_Session::instance()->reset_data(EE_Error::OPTIONS_KEY_NOTICES);
819
+		}
820
+		// clear global notices and hope none belonged to some for some other site visitor
821
+		return update_option(EE_Error::OPTIONS_KEY_NOTICES, array());
822
+	}
823
+
824
+
825
+	/**
826
+	 * saves notices to the db for retrieval on next request
827
+	 *
828
+	 * @return void
829
+	 * @throws InvalidArgumentException
830
+	 * @throws InvalidDataTypeException
831
+	 * @throws InvalidInterfaceException
832
+	 */
833
+	public static function stashNoticesBeforeRedirect()
834
+	{
835
+		EE_Error::get_notices(false, true);
836
+	}
837
+
838
+
839
+	/**
840
+	 * compile all error or success messages into one string
841
+	 *
842
+	 * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them
843
+	 * @param boolean $format_output            whether or not to format the messages for display in the WP admin
844
+	 * @param boolean $save_to_transient        whether or not to save notices to the db for retrieval on next request
845
+	 *                                          - ONLY do this just before redirecting
846
+	 * @param boolean $remove_empty             whether or not to unset empty messages
847
+	 * @return array
848
+	 * @throws InvalidArgumentException
849
+	 * @throws InvalidDataTypeException
850
+	 * @throws InvalidInterfaceException
851
+	 */
852
+	public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true)
853
+	{
854
+		$success_messages = '';
855
+		$attention_messages = '';
856
+		$error_messages = '';
857
+		/** @var RequestInterface $request */
858
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
859
+		// either save notices to the db
860
+		if ($save_to_transient || $request->requestParamIsSet('activate-selected')) {
861
+			self::$_espresso_notices = array_merge(
862
+				EE_Error::getStoredNotices(),
863
+				self::$_espresso_notices
864
+			);
865
+			EE_Error::storeNotices(self::$_espresso_notices);
866
+			return array();
867
+		}
868
+		$print_scripts = EE_Error::combineExistingAndNewNotices();
869
+		// check for success messages
870
+		if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
871
+			// combine messages
872
+			$success_messages .= implode('<br />', self::$_espresso_notices['success']);
873
+			$print_scripts = true;
874
+		}
875
+		// check for attention messages
876
+		if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
877
+			// combine messages
878
+			$attention_messages .= implode('<br />', self::$_espresso_notices['attention']);
879
+			$print_scripts = true;
880
+		}
881
+		// check for error messages
882
+		if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
883
+			$error_messages .= count(self::$_espresso_notices['errors']) > 1
884
+				? esc_html__('The following errors have occurred:', 'event_espresso')
885
+				: esc_html__('An error has occurred:', 'event_espresso');
886
+			// combine messages
887
+			$error_messages .= '<br />' . implode('<br />', self::$_espresso_notices['errors']);
888
+			$print_scripts = true;
889
+		}
890
+		if ($format_output) {
891
+			$notices = EE_Error::formatNoticesOutput(
892
+				$success_messages,
893
+				$attention_messages,
894
+				$error_messages
895
+			);
896
+		} else {
897
+			$notices = array(
898
+				'success'   => $success_messages,
899
+				'attention' => $attention_messages,
900
+				'errors'    => $error_messages,
901
+			);
902
+			if ($remove_empty) {
903
+				// remove empty notices
904
+				foreach ($notices as $type => $notice) {
905
+					if (empty($notice)) {
906
+						unset($notices[ $type ]);
907
+					}
908
+				}
909
+			}
910
+		}
911
+		if ($print_scripts) {
912
+			self::_print_scripts();
913
+		}
914
+		return $notices;
915
+	}
916
+
917
+
918
+	/**
919
+	 * @return bool
920
+	 * @throws InvalidArgumentException
921
+	 * @throws InvalidDataTypeException
922
+	 * @throws InvalidInterfaceException
923
+	 */
924
+	private static function combineExistingAndNewNotices()
925
+	{
926
+		$print_scripts = false;
927
+		// grab any notices that have been previously saved
928
+		$notices = EE_Error::getStoredNotices();
929
+		if (! empty($notices)) {
930
+			foreach ($notices as $type => $notice) {
931
+				if (is_array($notice) && ! empty($notice)) {
932
+					// make sure that existing notice type is an array
933
+					self::$_espresso_notices[ $type ] = is_array(self::$_espresso_notices[ $type ])
934
+														&& ! empty(self::$_espresso_notices[ $type ])
935
+						? self::$_espresso_notices[ $type ]
936
+						: array();
937
+					// add newly created notices to existing ones
938
+					self::$_espresso_notices[ $type ] += $notice;
939
+					$print_scripts = true;
940
+				}
941
+			}
942
+			// now clear any stored notices
943
+			EE_Error::clearNotices();
944
+		}
945
+		return $print_scripts;
946
+	}
947
+
948
+
949
+	/**
950
+	 * @param string $success_messages
951
+	 * @param string $attention_messages
952
+	 * @param string $error_messages
953
+	 * @return string
954
+	 */
955
+	private static function formatNoticesOutput($success_messages, $attention_messages, $error_messages)
956
+	{
957
+		$notices = '<div id="espresso-notices">';
958
+		$close = is_admin()
959
+			? ''
960
+			: '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"/></a>';
961
+		if ($success_messages !== '') {
962
+			$css_id = is_admin() ? 'ee-success-message' : 'espresso-notices-success';
963
+			$css_class = is_admin() ? 'updated fade' : 'success fade-away';
964
+			// showMessage( $success_messages );
965
+			$notices .= '<div id="' . $css_id . '" '
966
+						. 'class="espresso-notices ' . $css_class . '" '
967
+						. 'style="display:none;">'
968
+						. '<p>' . $success_messages . '</p>'
969
+						. $close
970
+						. '</div>';
971
+		}
972
+		if ($attention_messages !== '') {
973
+			$css_id = is_admin() ? 'ee-attention-message' : 'espresso-notices-attention';
974
+			$css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
975
+			// showMessage( $error_messages, TRUE );
976
+			$notices .= '<div id="' . $css_id . '" '
977
+						. 'class="espresso-notices ' . $css_class . '" '
978
+						. 'style="display:none;">'
979
+						. '<p>' . $attention_messages . '</p>'
980
+						. $close
981
+						. '</div>';
982
+		}
983
+		if ($error_messages !== '') {
984
+			$css_id = is_admin() ? 'ee-error-message' : 'espresso-notices-error';
985
+			$css_class = is_admin() ? 'error' : 'error fade-away';
986
+			// showMessage( $error_messages, TRUE );
987
+			$notices .= '<div id="' . $css_id . '" '
988
+						. 'class="espresso-notices ' . $css_class . '" '
989
+						. 'style="display:none;">'
990
+						. '<p>' . $error_messages . '</p>'
991
+						. $close
992
+						. '</div>';
993
+		}
994
+		$notices .= '</div>';
995
+		return $notices;
996
+	}
997
+
998
+
999
+	/**
1000
+	 * _print_scripts
1001
+	 *
1002
+	 * @param    bool $force_print
1003
+	 * @return    string
1004
+	 */
1005
+	private static function _print_scripts($force_print = false)
1006
+	{
1007
+		if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
1008
+			if (wp_script_is('ee_error_js', 'registered')) {
1009
+				wp_enqueue_style('espresso_default');
1010
+				wp_enqueue_style('espresso_custom_css');
1011
+				wp_enqueue_script('ee_error_js');
1012
+			}
1013
+			if (wp_script_is('ee_error_js', 'enqueued')) {
1014
+				wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
1015
+				return '';
1016
+			}
1017
+		} else {
1018
+			return '
1019 1019
 <script>
1020 1020
 /* <![CDATA[ */
1021 1021
 var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
@@ -1025,221 +1025,221 @@  discard block
 block discarded – undo
1025 1025
 <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1026 1026
 <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1027 1027
 ';
1028
-        }
1029
-        return '';
1030
-    }
1031
-
1032
-
1033
-    /**
1034
-     * @return void
1035
-     */
1036
-    public static function enqueue_error_scripts()
1037
-    {
1038
-        self::_print_scripts();
1039
-    }
1040
-
1041
-
1042
-    /**
1043
-     * create error code from filepath, function name,
1044
-     * and line number where exception or error was thrown
1045
-     *
1046
-     * @param string $file
1047
-     * @param string $func
1048
-     * @param string $line
1049
-     * @return string
1050
-     */
1051
-    public static function generate_error_code($file = '', $func = '', $line = '')
1052
-    {
1053
-        $file = explode('.', basename($file));
1054
-        $error_code = ! empty($file[0]) ? $file[0] : '';
1055
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
1056
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
1057
-        return $error_code;
1058
-    }
1059
-
1060
-
1061
-    /**
1062
-     * write exception details to log file
1063
-     * Since 4.9.53.rc.006 this writes to the standard PHP log file, not EE's custom log file
1064
-     *
1065
-     * @param int   $time
1066
-     * @param array $ex
1067
-     * @param bool  $clear
1068
-     * @return void
1069
-     */
1070
-    public function write_to_error_log($time = 0, $ex = array(), $clear = false)
1071
-    {
1072
-        if (empty($ex)) {
1073
-            return;
1074
-        }
1075
-        if (! $time) {
1076
-            $time = time();
1077
-        }
1078
-        $exception_log = '----------------------------------------------------------------------------------------'
1079
-                         . PHP_EOL;
1080
-        $exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
1081
-        $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
1082
-        $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
1083
-        $exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
1084
-        $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
1085
-        $exception_log .= 'Stack trace: ' . PHP_EOL;
1086
-        $exception_log .= $ex['string'] . PHP_EOL;
1087
-        $exception_log .= '----------------------------------------------------------------------------------------'
1088
-                          . PHP_EOL;
1089
-        try {
1090
-            error_log($exception_log);
1091
-        } catch (EE_Error $e) {
1092
-            EE_Error::add_error(
1093
-                sprintf(
1094
-                    esc_html__(
1095
-                        'Event Espresso error logging could not be setup because: %s',
1096
-                        'event_espresso'
1097
-                    ),
1098
-                    $e->getMessage()
1099
-                )
1100
-            );
1101
-        }
1102
-    }
1103
-
1104
-
1105
-    /**
1106
-     * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method.
1107
-     * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown,
1108
-     * but the code execution is done in a manner that could lead to unexpected results
1109
-     * (i.e. running to early, or too late in WP or EE loading process).
1110
-     * A good test for knowing whether to use this method is:
1111
-     * 1. Is there going to be a PHP error if something isn't setup/used correctly?
1112
-     * Yes -> use EE_Error::add_error() or throw new EE_Error()
1113
-     * 2. If this is loaded before something else, it won't break anything,
1114
-     * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong()
1115
-     *
1116
-     * @uses   constant WP_DEBUG test if wp_debug is on or not
1117
-     * @param string $function      The function that was called
1118
-     * @param string $message       A message explaining what has been done incorrectly
1119
-     * @param string $version       The version of Event Espresso where the error was added
1120
-     * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
1121
-     *                              for a deprecated function. This allows deprecation to occur during one version,
1122
-     *                              but not have any notices appear until a later version. This allows developers
1123
-     *                              extra time to update their code before notices appear.
1124
-     * @param int    $error_type
1125
-     */
1126
-    public static function doing_it_wrong(
1127
-        $function,
1128
-        $message,
1129
-        $version,
1130
-        $applies_when = '',
1131
-        $error_type = null
1132
-    ) {
1133
-        if (defined('WP_DEBUG') && WP_DEBUG) {
1134
-            EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type);
1135
-        }
1136
-    }
1137
-
1138
-
1139
-    /**
1140
-     * Like get_notices, but returns an array of all the notices of the given type.
1141
-     *
1142
-     * @return array {
1143
-     * @type array $success   all the success messages
1144
-     * @type array $errors    all the error messages
1145
-     * @type array $attention all the attention messages
1146
-     * }
1147
-     */
1148
-    public static function get_raw_notices()
1149
-    {
1150
-        return self::$_espresso_notices;
1151
-    }
1152
-
1153
-
1154
-    /**
1155
-     * @deprecated 4.9.27
1156
-     * @param string $pan_name     the name, or key of the Persistent Admin Notice to be stored
1157
-     * @param string $pan_message  the message to be stored persistently until dismissed
1158
-     * @param bool   $force_update allows one to enforce the reappearance of a persistent message.
1159
-     * @return void
1160
-     * @throws InvalidDataTypeException
1161
-     */
1162
-    public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false)
1163
-    {
1164
-        new PersistentAdminNotice(
1165
-            $pan_name,
1166
-            $pan_message,
1167
-            $force_update
1168
-        );
1169
-        EE_Error::doing_it_wrong(
1170
-            __METHOD__,
1171
-            sprintf(
1172
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1173
-                '\EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
1174
-            ),
1175
-            '4.9.27'
1176
-        );
1177
-    }
1178
-
1179
-
1180
-    /**
1181
-     * @deprecated 4.9.27
1182
-     * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
1183
-     * @param bool   $purge
1184
-     * @param bool   $return
1185
-     * @throws DomainException
1186
-     * @throws InvalidInterfaceException
1187
-     * @throws InvalidDataTypeException
1188
-     * @throws ServiceNotFoundException
1189
-     * @throws InvalidArgumentException
1190
-     */
1191
-    public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return = false)
1192
-    {
1193
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
1194
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
1195
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1196
-        );
1197
-        $persistent_admin_notice_manager->dismissNotice($pan_name, $purge, $return);
1198
-        EE_Error::doing_it_wrong(
1199
-            __METHOD__,
1200
-            sprintf(
1201
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1202
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1203
-            ),
1204
-            '4.9.27'
1205
-        );
1206
-    }
1207
-
1208
-
1209
-    /**
1210
-     * @deprecated 4.9.27
1211
-     * @param  string $pan_name    the name, or key of the Persistent Admin Notice to be stored
1212
-     * @param  string $pan_message the message to be stored persistently until dismissed
1213
-     * @param  string $return_url  URL to go back to after nag notice is dismissed
1214
-     */
1215
-    public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '')
1216
-    {
1217
-        EE_Error::doing_it_wrong(
1218
-            __METHOD__,
1219
-            sprintf(
1220
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1221
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1222
-            ),
1223
-            '4.9.27'
1224
-        );
1225
-    }
1226
-
1227
-
1228
-    /**
1229
-     * @deprecated 4.9.27
1230
-     * @param string $return_url
1231
-     */
1232
-    public static function get_persistent_admin_notices($return_url = '')
1233
-    {
1234
-        EE_Error::doing_it_wrong(
1235
-            __METHOD__,
1236
-            sprintf(
1237
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1238
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1239
-            ),
1240
-            '4.9.27'
1241
-        );
1242
-    }
1028
+		}
1029
+		return '';
1030
+	}
1031
+
1032
+
1033
+	/**
1034
+	 * @return void
1035
+	 */
1036
+	public static function enqueue_error_scripts()
1037
+	{
1038
+		self::_print_scripts();
1039
+	}
1040
+
1041
+
1042
+	/**
1043
+	 * create error code from filepath, function name,
1044
+	 * and line number where exception or error was thrown
1045
+	 *
1046
+	 * @param string $file
1047
+	 * @param string $func
1048
+	 * @param string $line
1049
+	 * @return string
1050
+	 */
1051
+	public static function generate_error_code($file = '', $func = '', $line = '')
1052
+	{
1053
+		$file = explode('.', basename($file));
1054
+		$error_code = ! empty($file[0]) ? $file[0] : '';
1055
+		$error_code .= ! empty($func) ? ' - ' . $func : '';
1056
+		$error_code .= ! empty($line) ? ' - ' . $line : '';
1057
+		return $error_code;
1058
+	}
1059
+
1060
+
1061
+	/**
1062
+	 * write exception details to log file
1063
+	 * Since 4.9.53.rc.006 this writes to the standard PHP log file, not EE's custom log file
1064
+	 *
1065
+	 * @param int   $time
1066
+	 * @param array $ex
1067
+	 * @param bool  $clear
1068
+	 * @return void
1069
+	 */
1070
+	public function write_to_error_log($time = 0, $ex = array(), $clear = false)
1071
+	{
1072
+		if (empty($ex)) {
1073
+			return;
1074
+		}
1075
+		if (! $time) {
1076
+			$time = time();
1077
+		}
1078
+		$exception_log = '----------------------------------------------------------------------------------------'
1079
+						 . PHP_EOL;
1080
+		$exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
1081
+		$exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
1082
+		$exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
1083
+		$exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
1084
+		$exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
1085
+		$exception_log .= 'Stack trace: ' . PHP_EOL;
1086
+		$exception_log .= $ex['string'] . PHP_EOL;
1087
+		$exception_log .= '----------------------------------------------------------------------------------------'
1088
+						  . PHP_EOL;
1089
+		try {
1090
+			error_log($exception_log);
1091
+		} catch (EE_Error $e) {
1092
+			EE_Error::add_error(
1093
+				sprintf(
1094
+					esc_html__(
1095
+						'Event Espresso error logging could not be setup because: %s',
1096
+						'event_espresso'
1097
+					),
1098
+					$e->getMessage()
1099
+				)
1100
+			);
1101
+		}
1102
+	}
1103
+
1104
+
1105
+	/**
1106
+	 * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method.
1107
+	 * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown,
1108
+	 * but the code execution is done in a manner that could lead to unexpected results
1109
+	 * (i.e. running to early, or too late in WP or EE loading process).
1110
+	 * A good test for knowing whether to use this method is:
1111
+	 * 1. Is there going to be a PHP error if something isn't setup/used correctly?
1112
+	 * Yes -> use EE_Error::add_error() or throw new EE_Error()
1113
+	 * 2. If this is loaded before something else, it won't break anything,
1114
+	 * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong()
1115
+	 *
1116
+	 * @uses   constant WP_DEBUG test if wp_debug is on or not
1117
+	 * @param string $function      The function that was called
1118
+	 * @param string $message       A message explaining what has been done incorrectly
1119
+	 * @param string $version       The version of Event Espresso where the error was added
1120
+	 * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
1121
+	 *                              for a deprecated function. This allows deprecation to occur during one version,
1122
+	 *                              but not have any notices appear until a later version. This allows developers
1123
+	 *                              extra time to update their code before notices appear.
1124
+	 * @param int    $error_type
1125
+	 */
1126
+	public static function doing_it_wrong(
1127
+		$function,
1128
+		$message,
1129
+		$version,
1130
+		$applies_when = '',
1131
+		$error_type = null
1132
+	) {
1133
+		if (defined('WP_DEBUG') && WP_DEBUG) {
1134
+			EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type);
1135
+		}
1136
+	}
1137
+
1138
+
1139
+	/**
1140
+	 * Like get_notices, but returns an array of all the notices of the given type.
1141
+	 *
1142
+	 * @return array {
1143
+	 * @type array $success   all the success messages
1144
+	 * @type array $errors    all the error messages
1145
+	 * @type array $attention all the attention messages
1146
+	 * }
1147
+	 */
1148
+	public static function get_raw_notices()
1149
+	{
1150
+		return self::$_espresso_notices;
1151
+	}
1152
+
1153
+
1154
+	/**
1155
+	 * @deprecated 4.9.27
1156
+	 * @param string $pan_name     the name, or key of the Persistent Admin Notice to be stored
1157
+	 * @param string $pan_message  the message to be stored persistently until dismissed
1158
+	 * @param bool   $force_update allows one to enforce the reappearance of a persistent message.
1159
+	 * @return void
1160
+	 * @throws InvalidDataTypeException
1161
+	 */
1162
+	public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false)
1163
+	{
1164
+		new PersistentAdminNotice(
1165
+			$pan_name,
1166
+			$pan_message,
1167
+			$force_update
1168
+		);
1169
+		EE_Error::doing_it_wrong(
1170
+			__METHOD__,
1171
+			sprintf(
1172
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1173
+				'\EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
1174
+			),
1175
+			'4.9.27'
1176
+		);
1177
+	}
1178
+
1179
+
1180
+	/**
1181
+	 * @deprecated 4.9.27
1182
+	 * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
1183
+	 * @param bool   $purge
1184
+	 * @param bool   $return
1185
+	 * @throws DomainException
1186
+	 * @throws InvalidInterfaceException
1187
+	 * @throws InvalidDataTypeException
1188
+	 * @throws ServiceNotFoundException
1189
+	 * @throws InvalidArgumentException
1190
+	 */
1191
+	public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return = false)
1192
+	{
1193
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
1194
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
1195
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1196
+		);
1197
+		$persistent_admin_notice_manager->dismissNotice($pan_name, $purge, $return);
1198
+		EE_Error::doing_it_wrong(
1199
+			__METHOD__,
1200
+			sprintf(
1201
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1202
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1203
+			),
1204
+			'4.9.27'
1205
+		);
1206
+	}
1207
+
1208
+
1209
+	/**
1210
+	 * @deprecated 4.9.27
1211
+	 * @param  string $pan_name    the name, or key of the Persistent Admin Notice to be stored
1212
+	 * @param  string $pan_message the message to be stored persistently until dismissed
1213
+	 * @param  string $return_url  URL to go back to after nag notice is dismissed
1214
+	 */
1215
+	public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '')
1216
+	{
1217
+		EE_Error::doing_it_wrong(
1218
+			__METHOD__,
1219
+			sprintf(
1220
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1221
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1222
+			),
1223
+			'4.9.27'
1224
+		);
1225
+	}
1226
+
1227
+
1228
+	/**
1229
+	 * @deprecated 4.9.27
1230
+	 * @param string $return_url
1231
+	 */
1232
+	public static function get_persistent_admin_notices($return_url = '')
1233
+	{
1234
+		EE_Error::doing_it_wrong(
1235
+			__METHOD__,
1236
+			sprintf(
1237
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1238
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1239
+			),
1240
+			'4.9.27'
1241
+		);
1242
+	}
1243 1243
 }
1244 1244
 
1245 1245
 // end of Class EE_Exceptions
@@ -1252,29 +1252,29 @@  discard block
 block discarded – undo
1252 1252
  */
1253 1253
 function espresso_error_enqueue_scripts()
1254 1254
 {
1255
-    // js for error handling
1256
-    if (! wp_script_is('espresso_core', 'registered')) {
1257
-        wp_register_script(
1258
-            'espresso_core',
1259
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1260
-            ['jquery'],
1261
-            EVENT_ESPRESSO_VERSION,
1262
-            false
1263
-        );
1264
-    }
1265
-    wp_register_script(
1266
-        'ee_error_js',
1267
-        EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1268
-        array('espresso_core'),
1269
-        EVENT_ESPRESSO_VERSION
1270
-    );
1271
-    wp_localize_script('ee_error_js', 'ee_settings', ['wp_debug' => WP_DEBUG]);
1255
+	// js for error handling
1256
+	if (! wp_script_is('espresso_core', 'registered')) {
1257
+		wp_register_script(
1258
+			'espresso_core',
1259
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1260
+			['jquery'],
1261
+			EVENT_ESPRESSO_VERSION,
1262
+			false
1263
+		);
1264
+	}
1265
+	wp_register_script(
1266
+		'ee_error_js',
1267
+		EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1268
+		array('espresso_core'),
1269
+		EVENT_ESPRESSO_VERSION
1270
+	);
1271
+	wp_localize_script('ee_error_js', 'ee_settings', ['wp_debug' => WP_DEBUG]);
1272 1272
 }
1273 1273
 
1274 1274
 if (is_admin()) {
1275
-    add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 5);
1275
+	add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 5);
1276 1276
 } else {
1277
-    add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 5);
1277
+	add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 5);
1278 1278
 }
1279 1279
 
1280 1280
 
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
             default:
101 101
                 $to = get_option('admin_email');
102 102
         }
103
-        $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
103
+        $subject = $type.' '.$message.' in '.EVENT_ESPRESSO_VERSION.' on '.site_url();
104 104
         $msg = EE_Error::_format_error($type, $message, $file, $line);
105 105
         if (function_exists('wp_mail')) {
106 106
             add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
107 107
             wp_mail($to, $subject, $msg);
108 108
         }
109 109
         echo '<div id="message" class="espresso-notices error"><p>';
110
-        echo wp_kses($type . ': ' . $message . '<br />' . $file . ' line ' . $line, AllowedTags::getWithFormTags());
110
+        echo wp_kses($type.': '.$message.'<br />'.$file.' line '.$line, AllowedTags::getWithFormTags());
111 111
         echo '<br /></p></div>';
112 112
     }
113 113
 
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
         $msg = WP_DEBUG ? $dev_msg : $user_msg;
224 224
         // add details to _all_exceptions array
225 225
         $x_time = time();
226
-        self::$_all_exceptions[ $x_time ]['name'] = get_class($this);
227
-        self::$_all_exceptions[ $x_time ]['file'] = $this->getFile();
228
-        self::$_all_exceptions[ $x_time ]['line'] = $this->getLine();
229
-        self::$_all_exceptions[ $x_time ]['msg'] = $msg;
230
-        self::$_all_exceptions[ $x_time ]['code'] = $this->getCode();
231
-        self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace();
232
-        self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString();
226
+        self::$_all_exceptions[$x_time]['name'] = get_class($this);
227
+        self::$_all_exceptions[$x_time]['file'] = $this->getFile();
228
+        self::$_all_exceptions[$x_time]['line'] = $this->getLine();
229
+        self::$_all_exceptions[$x_time]['msg'] = $msg;
230
+        self::$_all_exceptions[$x_time]['code'] = $this->getCode();
231
+        self::$_all_exceptions[$x_time]['trace'] = $this->getTrace();
232
+        self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString();
233 233
         self::$_error_count++;
234 234
         // add_action( 'shutdown', array( $this, 'display_errors' ));
235 235
         $this->display_errors();
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public static function has_error($check_stored = false, $type_to_check = 'errors')
249 249
     {
250
-        $has_error = isset(self::$_espresso_notices[ $type_to_check ])
251
-                     && ! empty(self::$_espresso_notices[ $type_to_check ])
250
+        $has_error = isset(self::$_espresso_notices[$type_to_check])
251
+                     && ! empty(self::$_espresso_notices[$type_to_check])
252 252
             ? true
253 253
             : false;
254 254
         if ($check_stored && ! $has_error) {
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	}
327 327
 </style>
328 328
 <div id="ee-error-message" class="error">';
329
-        if (! WP_DEBUG) {
329
+        if ( ! WP_DEBUG) {
330 330
             $output .= '
331 331
 	<p>';
332 332
         }
@@ -385,14 +385,14 @@  discard block
 block discarded – undo
385 385
                     $class_dsply = ! empty($class) ? $class : '&nbsp;';
386 386
                     $type_dsply = ! empty($type) ? $type : '&nbsp;';
387 387
                     $function_dsply = ! empty($function) ? $function : '&nbsp;';
388
-                    $args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
388
+                    $args_dsply = ! empty($args) ? '( '.$args.' )' : '';
389 389
                     $trace_details .= '
390 390
 					<tr>
391
-						<td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td>
392
-						<td align="right" class="' . $zebra . '">' . $line_dsply . '</td>
393
-						<td align="left" class="' . $zebra . '">' . $file_dsply . '</td>
394
-						<td align="left" class="' . $zebra . '">' . $class_dsply . '</td>
395
-						<td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td>
391
+						<td align="right" class="' . $zebra.'">'.$nmbr_dsply.'</td>
392
+						<td align="right" class="' . $zebra.'">'.$line_dsply.'</td>
393
+						<td align="left" class="' . $zebra.'">'.$file_dsply.'</td>
394
+						<td align="left" class="' . $zebra.'">'.$class_dsply.'</td>
395
+						<td align="left" class="' . $zebra.'">'.$type_dsply.$function_dsply.$args_dsply.'</td>
396 396
 					</tr>';
397 397
                 }
398 398
                 $trace_details .= '
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
             }
402 402
             $ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
403 403
             // add generic non-identifying messages for non-privileged users
404
-            if (! WP_DEBUG) {
404
+            if ( ! WP_DEBUG) {
405 405
                 $output .= '<span class="ee-error-user-msg-spn">'
406 406
                            . trim($ex['msg'])
407 407
                            . '</span> &nbsp; <sup>'
@@ -443,14 +443,14 @@  discard block
 block discarded – undo
443 443
                            . '-dv" class="ee-error-trace-dv" style="display: none;">
444 444
 				'
445 445
                            . $trace_details;
446
-                if (! empty($class)) {
446
+                if ( ! empty($class)) {
447 447
                     $output .= '
448 448
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;">
449 449
 					<div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;">
450 450
 						<h3>Class Details</h3>';
451 451
                     $a = new ReflectionClass($class);
452 452
                     $output .= '
453
-						<pre>' . $a . '</pre>
453
+						<pre>' . $a.'</pre>
454 454
 					</div>
455 455
 				</div>';
456 456
                 }
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
         }
464 464
         // remove last linebreak
465 465
         $output = substr($output, 0, -6);
466
-        if (! WP_DEBUG) {
466
+        if ( ! WP_DEBUG) {
467 467
             $output .= '
468 468
 	</p>';
469 469
         }
@@ -489,20 +489,20 @@  discard block
 block discarded – undo
489 489
     private function _convert_args_to_string($arguments = array(), $array = false)
490 490
     {
491 491
         $arg_string = '';
492
-        if (! empty($arguments)) {
492
+        if ( ! empty($arguments)) {
493 493
             $args = array();
494 494
             foreach ($arguments as $arg) {
495
-                if (! empty($arg)) {
495
+                if ( ! empty($arg)) {
496 496
                     if (is_string($arg)) {
497
-                        $args[] = " '" . $arg . "'";
497
+                        $args[] = " '".$arg."'";
498 498
                     } elseif (is_array($arg)) {
499
-                        $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
499
+                        $args[] = 'ARRAY('.$this->_convert_args_to_string($arg, true);
500 500
                     } elseif ($arg === null) {
501 501
                         $args[] = ' NULL';
502 502
                     } elseif (is_bool($arg)) {
503 503
                         $args[] = ($arg) ? ' TRUE' : ' FALSE';
504 504
                     } elseif (is_object($arg)) {
505
-                        $args[] = ' OBJECT ' . get_class($arg);
505
+                        $args[] = ' OBJECT '.get_class($arg);
506 506
                     } elseif (is_resource($arg)) {
507 507
                         $args[] = get_resource_type($arg);
508 508
                     } else {
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
     {
601 601
         if (empty($msg)) {
602 602
             EE_Error::doing_it_wrong(
603
-                'EE_Error::add_' . $type . '()',
603
+                'EE_Error::add_'.$type.'()',
604 604
                 sprintf(
605 605
                     esc_html__(
606 606
                         'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
@@ -640,17 +640,17 @@  discard block
 block discarded – undo
640 640
         do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
641 641
         $msg = WP_DEBUG ? $dev_msg : $user_msg;
642 642
         // add notice if message exists
643
-        if (! empty($msg)) {
643
+        if ( ! empty($msg)) {
644 644
             // get error code
645 645
             $notice_code = EE_Error::generate_error_code($file, $func, $line);
646 646
             if (WP_DEBUG && $type === 'errors') {
647
-                $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
647
+                $msg .= '<br/><span class="tiny-text">'.$notice_code.'</span>';
648 648
             }
649 649
             // add notice. Index by code if it's not blank
650 650
             if ($notice_code) {
651
-                self::$_espresso_notices[ $type ][ $notice_code ] = $msg;
651
+                self::$_espresso_notices[$type][$notice_code] = $msg;
652 652
             } else {
653
-                self::$_espresso_notices[ $type ][] = $msg;
653
+                self::$_espresso_notices[$type][] = $msg;
654 654
             }
655 655
             add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
656 656
         }
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
                 ? esc_html__('The following errors have occurred:', 'event_espresso')
885 885
                 : esc_html__('An error has occurred:', 'event_espresso');
886 886
             // combine messages
887
-            $error_messages .= '<br />' . implode('<br />', self::$_espresso_notices['errors']);
887
+            $error_messages .= '<br />'.implode('<br />', self::$_espresso_notices['errors']);
888 888
             $print_scripts = true;
889 889
         }
890 890
         if ($format_output) {
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
                 // remove empty notices
904 904
                 foreach ($notices as $type => $notice) {
905 905
                     if (empty($notice)) {
906
-                        unset($notices[ $type ]);
906
+                        unset($notices[$type]);
907 907
                     }
908 908
                 }
909 909
             }
@@ -926,16 +926,16 @@  discard block
 block discarded – undo
926 926
         $print_scripts = false;
927 927
         // grab any notices that have been previously saved
928 928
         $notices = EE_Error::getStoredNotices();
929
-        if (! empty($notices)) {
929
+        if ( ! empty($notices)) {
930 930
             foreach ($notices as $type => $notice) {
931 931
                 if (is_array($notice) && ! empty($notice)) {
932 932
                     // make sure that existing notice type is an array
933
-                    self::$_espresso_notices[ $type ] = is_array(self::$_espresso_notices[ $type ])
934
-                                                        && ! empty(self::$_espresso_notices[ $type ])
935
-                        ? self::$_espresso_notices[ $type ]
933
+                    self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type])
934
+                                                        && ! empty(self::$_espresso_notices[$type])
935
+                        ? self::$_espresso_notices[$type]
936 936
                         : array();
937 937
                     // add newly created notices to existing ones
938
-                    self::$_espresso_notices[ $type ] += $notice;
938
+                    self::$_espresso_notices[$type] += $notice;
939 939
                     $print_scripts = true;
940 940
                 }
941 941
             }
@@ -962,10 +962,10 @@  discard block
 block discarded – undo
962 962
             $css_id = is_admin() ? 'ee-success-message' : 'espresso-notices-success';
963 963
             $css_class = is_admin() ? 'updated fade' : 'success fade-away';
964 964
             // showMessage( $success_messages );
965
-            $notices .= '<div id="' . $css_id . '" '
966
-                        . 'class="espresso-notices ' . $css_class . '" '
965
+            $notices .= '<div id="'.$css_id.'" '
966
+                        . 'class="espresso-notices '.$css_class.'" '
967 967
                         . 'style="display:none;">'
968
-                        . '<p>' . $success_messages . '</p>'
968
+                        . '<p>'.$success_messages.'</p>'
969 969
                         . $close
970 970
                         . '</div>';
971 971
         }
@@ -973,10 +973,10 @@  discard block
 block discarded – undo
973 973
             $css_id = is_admin() ? 'ee-attention-message' : 'espresso-notices-attention';
974 974
             $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
975 975
             // showMessage( $error_messages, TRUE );
976
-            $notices .= '<div id="' . $css_id . '" '
977
-                        . 'class="espresso-notices ' . $css_class . '" '
976
+            $notices .= '<div id="'.$css_id.'" '
977
+                        . 'class="espresso-notices '.$css_class.'" '
978 978
                         . 'style="display:none;">'
979
-                        . '<p>' . $attention_messages . '</p>'
979
+                        . '<p>'.$attention_messages.'</p>'
980 980
                         . $close
981 981
                         . '</div>';
982 982
         }
@@ -984,10 +984,10 @@  discard block
 block discarded – undo
984 984
             $css_id = is_admin() ? 'ee-error-message' : 'espresso-notices-error';
985 985
             $css_class = is_admin() ? 'error' : 'error fade-away';
986 986
             // showMessage( $error_messages, TRUE );
987
-            $notices .= '<div id="' . $css_id . '" '
988
-                        . 'class="espresso-notices ' . $css_class . '" '
987
+            $notices .= '<div id="'.$css_id.'" '
988
+                        . 'class="espresso-notices '.$css_class.'" '
989 989
                         . 'style="display:none;">'
990
-                        . '<p>' . $error_messages . '</p>'
990
+                        . '<p>'.$error_messages.'</p>'
991 991
                         . $close
992 992
                         . '</div>';
993 993
         }
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
      */
1005 1005
     private static function _print_scripts($force_print = false)
1006 1006
     {
1007
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
1007
+        if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
1008 1008
             if (wp_script_is('ee_error_js', 'registered')) {
1009 1009
                 wp_enqueue_style('espresso_default');
1010 1010
                 wp_enqueue_style('espresso_custom_css');
@@ -1018,12 +1018,12 @@  discard block
 block discarded – undo
1018 1018
             return '
1019 1019
 <script>
1020 1020
 /* <![CDATA[ */
1021
-var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
1021
+var ee_settings = {"wp_debug":"' . WP_DEBUG.'"};
1022 1022
 /* ]]> */
1023 1023
 </script>
1024
-<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script>
1025
-<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1026
-<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1024
+<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script>
1025
+<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script>
1026
+<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script>
1027 1027
 ';
1028 1028
         }
1029 1029
         return '';
@@ -1052,8 +1052,8 @@  discard block
 block discarded – undo
1052 1052
     {
1053 1053
         $file = explode('.', basename($file));
1054 1054
         $error_code = ! empty($file[0]) ? $file[0] : '';
1055
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
1056
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
1055
+        $error_code .= ! empty($func) ? ' - '.$func : '';
1056
+        $error_code .= ! empty($line) ? ' - '.$line : '';
1057 1057
         return $error_code;
1058 1058
     }
1059 1059
 
@@ -1072,18 +1072,18 @@  discard block
 block discarded – undo
1072 1072
         if (empty($ex)) {
1073 1073
             return;
1074 1074
         }
1075
-        if (! $time) {
1075
+        if ( ! $time) {
1076 1076
             $time = time();
1077 1077
         }
1078 1078
         $exception_log = '----------------------------------------------------------------------------------------'
1079 1079
                          . PHP_EOL;
1080
-        $exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
1081
-        $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
1082
-        $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
1083
-        $exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
1084
-        $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
1085
-        $exception_log .= 'Stack trace: ' . PHP_EOL;
1086
-        $exception_log .= $ex['string'] . PHP_EOL;
1080
+        $exception_log .= '['.date('Y-m-d H:i:s', $time).']  Exception Details'.PHP_EOL;
1081
+        $exception_log .= 'Message: '.$ex['msg'].PHP_EOL;
1082
+        $exception_log .= 'Code: '.$ex['code'].PHP_EOL;
1083
+        $exception_log .= 'File: '.$ex['file'].PHP_EOL;
1084
+        $exception_log .= 'Line No: '.$ex['line'].PHP_EOL;
1085
+        $exception_log .= 'Stack trace: '.PHP_EOL;
1086
+        $exception_log .= $ex['string'].PHP_EOL;
1087 1087
         $exception_log .= '----------------------------------------------------------------------------------------'
1088 1088
                           . PHP_EOL;
1089 1089
         try {
@@ -1253,10 +1253,10 @@  discard block
 block discarded – undo
1253 1253
 function espresso_error_enqueue_scripts()
1254 1254
 {
1255 1255
     // js for error handling
1256
-    if (! wp_script_is('espresso_core', 'registered')) {
1256
+    if ( ! wp_script_is('espresso_core', 'registered')) {
1257 1257
         wp_register_script(
1258 1258
             'espresso_core',
1259
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1259
+            EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
1260 1260
             ['jquery'],
1261 1261
             EVENT_ESPRESSO_VERSION,
1262 1262
             false
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
     }
1265 1265
     wp_register_script(
1266 1266
         'ee_error_js',
1267
-        EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1267
+        EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js',
1268 1268
         array('espresso_core'),
1269 1269
         EVENT_ESPRESSO_VERSION
1270 1270
     );
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/Pricing_Admin_Page.core.php 2 patches
Indentation   +1271 added lines, -1271 removed lines patch added patch discarded remove patch
@@ -11,1282 +11,1282 @@
 block discarded – undo
11 11
  */
12 12
 class Pricing_Admin_Page extends EE_Admin_Page
13 13
 {
14
-    protected function _init_page_props()
15
-    {
16
-        $this->page_slug        = PRICING_PG_SLUG;
17
-        $this->page_label       = PRICING_LABEL;
18
-        $this->_admin_base_url  = PRICING_ADMIN_URL;
19
-        $this->_admin_base_path = PRICING_ADMIN;
20
-    }
21
-
22
-
23
-    protected function _ajax_hooks()
24
-    {
25
-        add_action('wp_ajax_espresso_update_prices_order', [$this, 'update_price_order']);
26
-    }
27
-
28
-
29
-    protected function _define_page_props()
30
-    {
31
-        $this->_admin_page_title = PRICING_LABEL;
32
-        $this->_labels           = [
33
-            'buttons' => [
34
-                'add'         => esc_html__('Add New Default Price', 'event_espresso'),
35
-                'edit'        => esc_html__('Edit Default Price', 'event_espresso'),
36
-                'delete'      => esc_html__('Delete Default Price', 'event_espresso'),
37
-                'add_type'    => esc_html__('Add New Default Price Type', 'event_espresso'),
38
-                'edit_type'   => esc_html__('Edit Price Type', 'event_espresso'),
39
-                'delete_type' => esc_html__('Delete Price Type', 'event_espresso'),
40
-            ],
41
-        ];
42
-    }
43
-
44
-
45
-    /**
46
-     * an array for storing request actions and their corresponding methods
47
-     *
48
-     * @return void
49
-     */
50
-    protected function _set_page_routes()
51
-    {
52
-        $PRC_ID             = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER);
53
-        $PRT_ID             = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
54
-        $this->_page_routes = [
55
-            'default'                     => [
56
-                'func'       => '_price_overview_list_table',
57
-                'capability' => 'ee_read_default_prices',
58
-            ],
59
-            'add_new_price'               => [
60
-                'func'       => '_edit_price_details',
61
-                'args'       => ['new_price' => true],
62
-                'capability' => 'ee_edit_default_prices',
63
-            ],
64
-            'edit_price'                  => [
65
-                'func'       => '_edit_price_details',
66
-                'args'       => ['new_price' => false],
67
-                'capability' => 'ee_edit_default_price',
68
-                'obj_id'     => $PRC_ID,
69
-            ],
70
-            'insert_price'                => [
71
-                'func'       => '_insert_or_update_price',
72
-                'args'       => ['new_price' => true],
73
-                'noheader'   => true,
74
-                'capability' => 'ee_edit_default_prices',
75
-            ],
76
-            'update_price'                => [
77
-                'func'       => '_insert_or_update_price',
78
-                'args'       => ['new_price' => false],
79
-                'noheader'   => true,
80
-                'capability' => 'ee_edit_default_price',
81
-                'obj_id'     => $PRC_ID,
82
-            ],
83
-            'trash_price'                 => [
84
-                'func'       => '_trash_or_restore_price',
85
-                'args'       => ['trash' => true],
86
-                'noheader'   => true,
87
-                'capability' => 'ee_delete_default_price',
88
-                'obj_id'     => $PRC_ID,
89
-            ],
90
-            'restore_price'               => [
91
-                'func'       => '_trash_or_restore_price',
92
-                'args'       => ['trash' => false],
93
-                'noheader'   => true,
94
-                'capability' => 'ee_delete_default_price',
95
-                'obj_id'     => $PRC_ID,
96
-            ],
97
-            'delete_price'                => [
98
-                'func'       => '_delete_price',
99
-                'noheader'   => true,
100
-                'capability' => 'ee_delete_default_price',
101
-                'obj_id'     => $PRC_ID,
102
-            ],
103
-            'espresso_update_price_order' => [
104
-                'func'       => 'update_price_order',
105
-                'noheader'   => true,
106
-                'capability' => 'ee_edit_default_prices',
107
-            ],
108
-            // price types
109
-            'price_types'                 => [
110
-                'func'       => '_price_types_overview_list_table',
111
-                'capability' => 'ee_read_default_price_types',
112
-            ],
113
-            'add_new_price_type'          => [
114
-                'func'       => '_edit_price_type_details',
115
-                'capability' => 'ee_edit_default_price_types',
116
-            ],
117
-            'edit_price_type'             => [
118
-                'func'       => '_edit_price_type_details',
119
-                'capability' => 'ee_edit_default_price_type',
120
-                'obj_id'     => $PRT_ID,
121
-            ],
122
-            'insert_price_type'           => [
123
-                'func'       => '_insert_or_update_price_type',
124
-                'args'       => ['new_price_type' => true],
125
-                'noheader'   => true,
126
-                'capability' => 'ee_edit_default_price_types',
127
-            ],
128
-            'update_price_type'           => [
129
-                'func'       => '_insert_or_update_price_type',
130
-                'args'       => ['new_price_type' => false],
131
-                'noheader'   => true,
132
-                'capability' => 'ee_edit_default_price_type',
133
-                'obj_id'     => $PRT_ID,
134
-            ],
135
-            'trash_price_type'            => [
136
-                'func'       => '_trash_or_restore_price_type',
137
-                'args'       => ['trash' => true],
138
-                'noheader'   => true,
139
-                'capability' => 'ee_delete_default_price_type',
140
-                'obj_id'     => $PRT_ID,
141
-            ],
142
-            'restore_price_type'          => [
143
-                'func'       => '_trash_or_restore_price_type',
144
-                'args'       => ['trash' => false],
145
-                'noheader'   => true,
146
-                'capability' => 'ee_delete_default_price_type',
147
-                'obj_id'     => $PRT_ID,
148
-            ],
149
-            'delete_price_type'           => [
150
-                'func'       => '_delete_price_type',
151
-                'noheader'   => true,
152
-                'capability' => 'ee_delete_default_price_type',
153
-                'obj_id'     => $PRT_ID,
154
-            ],
155
-            'tax_settings'                => [
156
-                'func'       => '_tax_settings',
157
-                'capability' => 'manage_options',
158
-            ],
159
-            'update_tax_settings'         => [
160
-                'func'       => '_update_tax_settings',
161
-                'capability' => 'manage_options',
162
-                'noheader'   => true,
163
-            ],
164
-        ];
165
-    }
166
-
167
-
168
-    protected function _set_page_config()
169
-    {
170
-        $PRC_ID             = $this->request->getRequestParam('id', 0, DataType::INTEGER);
171
-        $this->_page_config = [
172
-            'default'            => [
173
-                'nav'           => [
174
-                    'label' => esc_html__('Default Pricing', 'event_espresso'),
175
-                    'order' => 10,
176
-                ],
177
-                'list_table'    => 'Prices_List_Table',
178
-                'metaboxes'     => $this->_default_espresso_metaboxes,
179
-                'help_tabs'     => [
180
-                    'pricing_default_pricing_help_tab'                           => [
181
-                        'title'    => esc_html__('Default Pricing', 'event_espresso'),
182
-                        'filename' => 'pricing_default_pricing',
183
-                    ],
184
-                    'pricing_default_pricing_table_column_headings_help_tab'     => [
185
-                        'title'    => esc_html__('Default Pricing Table Column Headings', 'event_espresso'),
186
-                        'filename' => 'pricing_default_pricing_table_column_headings',
187
-                    ],
188
-                    'pricing_default_pricing_views_bulk_actions_search_help_tab' => [
189
-                        'title'    => esc_html__('Default Pricing Views & Bulk Actions & Search', 'event_espresso'),
190
-                        'filename' => 'pricing_default_pricing_views_bulk_actions_search',
191
-                    ],
192
-                ],
193
-                'require_nonce' => false,
194
-            ],
195
-            'add_new_price'      => [
196
-                'nav'           => [
197
-                    'label'      => esc_html__('Add New Default Price', 'event_espresso'),
198
-                    'order'      => 20,
199
-                    'persistent' => false,
200
-                ],
201
-                'help_tabs'     => [
202
-                    'add_new_default_price_help_tab' => [
203
-                        'title'    => esc_html__('Add New Default Price', 'event_espresso'),
204
-                        'filename' => 'pricing_add_new_default_price',
205
-                    ],
206
-                ],
207
-                'metaboxes'     => array_merge(
208
-                    ['_publish_post_box'],
209
-                    $this->_default_espresso_metaboxes
210
-                ),
211
-                'require_nonce' => false,
212
-            ],
213
-            'edit_price'         => [
214
-                'nav'           => [
215
-                    'label'      => esc_html__('Edit Default Price', 'event_espresso'),
216
-                    'order'      => 20,
217
-                    'url'        => $PRC_ID
218
-                        ? add_query_arg(['id' => $PRC_ID], $this->_current_page_view_url)
219
-                        : $this->_admin_base_url,
220
-                    'persistent' => false,
221
-                ],
222
-                'metaboxes'     => array_merge(
223
-                    ['_publish_post_box'],
224
-                    $this->_default_espresso_metaboxes
225
-                ),
226
-                'help_tabs'     => [
227
-                    'edit_default_price_help_tab' => [
228
-                        'title'    => esc_html__('Edit Default Price', 'event_espresso'),
229
-                        'filename' => 'pricing_edit_default_price',
230
-                    ],
231
-                ],
232
-                'require_nonce' => false,
233
-            ],
234
-            'price_types'        => [
235
-                'nav'           => [
236
-                    'label' => esc_html__('Price Types', 'event_espresso'),
237
-                    'order' => 30,
238
-                ],
239
-                'list_table'    => 'Price_Types_List_Table',
240
-                'help_tabs'     => [
241
-                    'pricing_price_types_help_tab'                           => [
242
-                        'title'    => esc_html__('Price Types', 'event_espresso'),
243
-                        'filename' => 'pricing_price_types',
244
-                    ],
245
-                    'pricing_price_types_table_column_headings_help_tab'     => [
246
-                        'title'    => esc_html__('Price Types Table Column Headings', 'event_espresso'),
247
-                        'filename' => 'pricing_price_types_table_column_headings',
248
-                    ],
249
-                    'pricing_price_types_views_bulk_actions_search_help_tab' => [
250
-                        'title'    => esc_html__('Price Types Views & Bulk Actions & Search', 'event_espresso'),
251
-                        'filename' => 'pricing_price_types_views_bulk_actions_search',
252
-                    ],
253
-                ],
254
-                'metaboxes'     => $this->_default_espresso_metaboxes,
255
-                'require_nonce' => false,
256
-            ],
257
-            'add_new_price_type' => [
258
-                'nav'           => [
259
-                    'label'      => esc_html__('Add New Price Type', 'event_espresso'),
260
-                    'order'      => 40,
261
-                    'persistent' => false,
262
-                ],
263
-                'help_tabs'     => [
264
-                    'add_new_price_type_help_tab' => [
265
-                        'title'    => esc_html__('Add New Price Type', 'event_espresso'),
266
-                        'filename' => 'pricing_add_new_price_type',
267
-                    ],
268
-                ],
269
-                'metaboxes'     => array_merge(
270
-                    ['_publish_post_box'],
271
-                    $this->_default_espresso_metaboxes
272
-                ),
273
-                'require_nonce' => false,
274
-            ],
275
-            'edit_price_type'    => [
276
-                'nav'           => [
277
-                    'label'      => esc_html__('Edit Price Type', 'event_espresso'),
278
-                    'order'      => 40,
279
-                    'persistent' => false,
280
-                ],
281
-                'help_tabs'     => [
282
-                    'edit_price_type_help_tab' => [
283
-                        'title'    => esc_html__('Edit Price Type', 'event_espresso'),
284
-                        'filename' => 'pricing_edit_price_type',
285
-                    ],
286
-                ],
287
-                'metaboxes'     => array_merge(
288
-                    ['_publish_post_box'],
289
-                    $this->_default_espresso_metaboxes
290
-                ),
291
-                'require_nonce' => false,
292
-            ],
293
-            'tax_settings'       => [
294
-                'nav'           => [
295
-                    'label' => esc_html__('Tax Settings', 'event_espresso'),
296
-                    'order' => 40,
297
-                ],
298
-                'labels'        => [
299
-                    'publishbox' => esc_html__('Update Tax Settings', 'event_espresso'),
300
-                ],
301
-                'metaboxes'     => array_merge(
302
-                    ['_publish_post_box'],
303
-                    $this->_default_espresso_metaboxes
304
-                ),
305
-                'require_nonce' => true,
306
-            ],
307
-        ];
308
-    }
309
-
310
-
311
-    protected function _add_screen_options()
312
-    {
313
-        // todo
314
-    }
315
-
316
-
317
-    protected function _add_screen_options_default()
318
-    {
319
-        $this->_per_page_screen_option();
320
-    }
321
-
322
-
323
-    protected function _add_screen_options_price_types()
324
-    {
325
-        $page_title              = $this->_admin_page_title;
326
-        $this->_admin_page_title = esc_html__('Price Types', 'event_espresso');
327
-        $this->_per_page_screen_option();
328
-        $this->_admin_page_title = $page_title;
329
-    }
330
-
331
-
332
-    protected function _add_feature_pointers()
333
-    {
334
-    }
335
-
336
-
337
-    public function load_scripts_styles()
338
-    {
339
-        // styles
340
-        wp_enqueue_style('espresso-ui-theme');
341
-        wp_register_style(
342
-            'espresso_PRICING',
343
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.css',
344
-            [],
345
-            EVENT_ESPRESSO_VERSION
346
-        );
347
-        wp_enqueue_style('espresso_PRICING');
348
-
349
-        // scripts
350
-        wp_enqueue_script('ee_admin_js');
351
-        wp_enqueue_script('jquery-ui-position');
352
-        wp_enqueue_script('jquery-ui-widget');
353
-        wp_register_script(
354
-            'espresso_PRICING',
355
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.js',
356
-            ['jquery'],
357
-            EVENT_ESPRESSO_VERSION,
358
-            true
359
-        );
360
-        wp_enqueue_script('espresso_PRICING');
361
-    }
362
-
363
-
364
-    public function load_scripts_styles_default()
365
-    {
366
-        wp_enqueue_script('espresso_ajax_table_sorting');
367
-    }
368
-
369
-
370
-    public function admin_footer_scripts()
371
-    {
372
-    }
373
-
374
-
375
-    public function admin_init()
376
-    {
377
-    }
378
-
379
-
380
-    public function admin_notices()
381
-    {
382
-    }
383
-
384
-
385
-    protected function _set_list_table_views_default()
386
-    {
387
-        $this->_views = [
388
-            'all' => [
389
-                'slug'        => 'all',
390
-                'label'       => esc_html__('View All Default Pricing', 'event_espresso'),
391
-                'count'       => 0,
392
-                'bulk_action' => [
393
-                    'trash_price' => esc_html__('Move to Trash', 'event_espresso'),
394
-                ],
395
-            ],
396
-        ];
397
-
398
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) {
399
-            $this->_views['trashed'] = [
400
-                'slug'        => 'trashed',
401
-                'label'       => esc_html__('Trash', 'event_espresso'),
402
-                'count'       => 0,
403
-                'bulk_action' => [
404
-                    'restore_price' => esc_html__('Restore from Trash', 'event_espresso'),
405
-                    'delete_price'  => esc_html__('Delete Permanently', 'event_espresso'),
406
-                ],
407
-            ];
408
-        }
409
-    }
410
-
411
-
412
-    protected function _set_list_table_views_price_types()
413
-    {
414
-        $this->_views = [
415
-            'all' => [
416
-                'slug'        => 'all',
417
-                'label'       => esc_html__('All', 'event_espresso'),
418
-                'count'       => 0,
419
-                'bulk_action' => [
420
-                    'trash_price_type' => esc_html__('Move to Trash', 'event_espresso'),
421
-                ],
422
-            ],
423
-        ];
424
-
425
-        if (
426
-            EE_Registry::instance()->CAP->current_user_can(
427
-                'ee_delete_default_price_types',
428
-                'pricing_trash_price_type'
429
-            )
430
-        ) {
431
-            $this->_views['trashed'] = [
432
-                'slug'        => 'trashed',
433
-                'label'       => esc_html__('Trash', 'event_espresso'),
434
-                'count'       => 0,
435
-                'bulk_action' => [
436
-                    'restore_price_type' => esc_html__('Restore from Trash', 'event_espresso'),
437
-                    'delete_price_type'  => esc_html__('Delete Permanently', 'event_espresso'),
438
-                ],
439
-            ];
440
-        }
441
-    }
442
-
443
-
444
-    /**
445
-     * generates HTML for main Prices Admin page
446
-     *
447
-     * @return void
448
-     * @throws EE_Error
449
-     */
450
-    protected function _price_overview_list_table()
451
-    {
452
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
453
-            'add_new_price',
454
-            'add',
455
-            [],
456
-            'add-new-h2'
457
-        );
458
-        $this->_admin_page_title .= $this->_learn_more_about_pricing_link();
459
-        $this->_search_btn_label = esc_html__('Default Prices', 'event_espresso');
460
-        $this->display_admin_list_table_page_with_sidebar();
461
-    }
462
-
463
-
464
-    /**
465
-     * retrieve data for Prices List table
466
-     *
467
-     * @param int  $per_page how many prices displayed per page
468
-     * @param bool $count    return the count or objects
469
-     * @param bool $trashed  whether the current view is of the trash can - eww yuck!
470
-     * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects
471
-     * @throws EE_Error
472
-     * @throws ReflectionException
473
-     */
474
-    public function get_prices_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
475
-    {
476
-        // start with an empty array
477
-        $event_pricing = [];
478
-
479
-        require_once(PRICING_ADMIN . 'Prices_List_Table.class.php');
480
-
481
-        $orderby = $this->request->getRequestParam('orderby', '');
482
-        $order   = $this->request->getRequestParam('order', 'ASC');
483
-
484
-        switch ($orderby) {
485
-            case 'name':
486
-                $orderby = ['PRC_name' => $order];
487
-                break;
488
-            case 'type':
489
-                $orderby = ['Price_Type.PRT_name' => $order];
490
-                break;
491
-            case 'amount':
492
-                $orderby = ['PRC_amount' => $order];
493
-                break;
494
-            default:
495
-                $orderby = ['PRC_order' => $order, 'Price_Type.PRT_order' => $order, 'PRC_ID' => $order];
496
-        }
497
-
498
-        $current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER);
499
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER);
500
-
501
-        $where = [
502
-            'PRC_is_default' => 1,
503
-            'PRC_deleted'    => $trashed,
504
-        ];
505
-
506
-        $offset = ($current_page - 1) * $per_page;
507
-        $limit  = [$offset, $per_page];
508
-
509
-        $search_term = $this->request->getRequestParam('s');
510
-        if ($search_term) {
511
-            $search_term = "%{$search_term}%";
512
-            $where['OR'] = [
513
-                'PRC_name'            => ['LIKE', $search_term],
514
-                'PRC_desc'            => ['LIKE', $search_term],
515
-                'PRC_amount'          => ['LIKE', $search_term],
516
-                'Price_Type.PRT_name' => ['LIKE', $search_term],
517
-            ];
518
-        }
519
-
520
-        $query_params = [
521
-            $where,
522
-            'order_by' => $orderby,
523
-            'limit'    => $limit,
524
-            'group_by' => 'PRC_ID',
525
-        ];
526
-
527
-        if ($count) {
528
-            return $trashed
529
-                ? EEM_Price::instance()->count([$where])
530
-                : EEM_Price::instance()->count_deleted_and_undeleted([$where]);
531
-        }
532
-        return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params);
533
-    }
534
-
535
-
536
-    /**
537
-     * @return void
538
-     * @throws EE_Error
539
-     * @throws ReflectionException
540
-     */
541
-    protected function _edit_price_details()
542
-    {
543
-        // grab price ID
544
-        $PRC_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER);
545
-        // change page title based on request action
546
-        switch ($this->_req_action) {
547
-            case 'add_new_price':
548
-                $this->_admin_page_title = esc_html__('Add New Price', 'event_espresso');
549
-                break;
550
-            case 'edit_price':
551
-                $this->_admin_page_title = esc_html__('Edit Price', 'event_espresso');
552
-                break;
553
-            default:
554
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
555
-        }
556
-        // add PRC_ID to title if editing
557
-        $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title;
558
-
559
-        if ($PRC_ID) {
560
-            $price                    = EEM_Price::instance()->get_one_by_ID($PRC_ID);
561
-            $additional_hidden_fields = [
562
-                'PRC_ID' => ['type' => 'hidden', 'value' => $PRC_ID],
563
-            ];
564
-            $this->_set_add_edit_form_tags('update_price', $additional_hidden_fields);
565
-        } else {
566
-            $price = EEM_Price::instance()->get_new_price();
567
-            $this->_set_add_edit_form_tags('insert_price');
568
-        }
569
-
570
-        if (! $price instanceof EE_Price) {
571
-            throw new RuntimeException(
572
-                sprintf(
573
-                    esc_html__(
574
-                        'A valid Price could not be retrieved from the database with ID: %1$s',
575
-                        'event_espresso'
576
-                    ),
577
-                    $PRC_ID
578
-                )
579
-            );
580
-        }
581
-
582
-        $this->_template_args['PRC_ID'] = $PRC_ID;
583
-        $this->_template_args['price']  = $price;
584
-
585
-        $default_base_price = $price->type_obj() && $price->type_obj()->base_type() === 1;
586
-
587
-        $this->_template_args['default_base_price'] = $default_base_price;
588
-
589
-        // get price types
590
-        $price_types = EEM_Price_Type::instance()->get_all([['PBT_ID' => ['!=', 1]]]);
591
-        if (empty($price_types)) {
592
-            $msg = esc_html__(
593
-                'You have no price types defined. Please add a price type before adding a price.',
594
-                'event_espresso'
595
-            );
596
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
597
-            $this->display_admin_page_with_sidebar();
598
-        }
599
-        $attributes       = [];
600
-        $price_type_names = [];
601
-        $attributes[]     = 'id="PRT_ID"';
602
-        if ($default_base_price) {
603
-            $attributes[]       = 'disabled="disabled"';
604
-            $price_type_names[] = ['id' => 1, 'text' => esc_html__('Base Price', 'event_espresso')];
605
-        }
606
-        foreach ($price_types as $type) {
607
-            $price_type_names[] = ['id' => $type->ID(), 'text' => $type->name()];
608
-        }
609
-        $this->_template_args['attributes']  = implode(' ', $attributes);
610
-        $this->_template_args['price_types'] = $price_type_names;
611
-
612
-        $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
613
-        $this->_template_args['admin_page_content']            = $this->_edit_price_details_meta_box();
614
-
615
-        $this->_set_publish_post_box_vars('id', $PRC_ID);
616
-        // the details template wrapper
617
-        $this->display_admin_page_with_sidebar();
618
-    }
619
-
620
-
621
-    /**
622
-     *
623
-     * @return string
624
-     */
625
-    public function _edit_price_details_meta_box(): string
626
-    {
627
-        return EEH_Template::display_template(
628
-            PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php',
629
-            $this->_template_args,
630
-            true
631
-        );
632
-    }
633
-
634
-
635
-    /**
636
-     * @return array
637
-     * @throws EE_Error
638
-     * @throws ReflectionException
639
-     */
640
-    protected function set_price_column_values(): array
641
-    {
642
-        $PRC_order = 0;
643
-        $PRT_ID    = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
644
-        if ($PRT_ID) {
645
-            /** @var EE_Price_Type $price_type */
646
-            $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
647
-            if ($price_type instanceof EE_Price_Type) {
648
-                $PRC_order = $price_type->order();
649
-            }
650
-        }
651
-        return [
652
-            'PRT_ID'         => $PRT_ID,
653
-            'PRC_amount'     => $this->request->getRequestParam('PRC_amount', 0, DataType::FLOAT),
654
-            'PRC_name'       => $this->request->getRequestParam('PRC_name'),
655
-            'PRC_desc'       => $this->request->getRequestParam('PRC_desc'),
656
-            'PRC_is_default' => 1,
657
-            'PRC_overrides'  => null,
658
-            'PRC_order'      => $PRC_order,
659
-            'PRC_deleted'    => 0,
660
-            'PRC_parent'     => 0,
661
-        ];
662
-    }
663
-
664
-
665
-    /**
666
-     * @param bool $insert - whether to insert or update
667
-     * @return void
668
-     * @throws EE_Error
669
-     * @throws ReflectionException
670
-     */
671
-    protected function _insert_or_update_price(bool $insert = false)
672
-    {
673
-        // why be so pessimistic ???  : (
674
-        $updated = 0;
675
-
676
-        $set_column_values = $this->set_price_column_values();
677
-        // is this a new Price ?
678
-        if ($insert) {
679
-            // run the insert
680
-            $PRC_ID = EEM_Price::instance()->insert($set_column_values);
681
-            if ($PRC_ID) {
682
-                // make sure this new price modifier is attached to the ticket but ONLY if it is not a tax type
683
-                $price = EEM_price::instance()->get_one_by_ID($PRC_ID);
684
-                if (
685
-                    $price instanceof EE_Price
686
-                    && $price->type_obj() instanceof EE_Price_type
687
-                    && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax
688
-                ) {
689
-                    $ticket = EEM_Ticket::instance()->get_one_by_ID(1);
690
-                    $ticket->_add_relation_to($price, 'Price');
691
-                    $ticket->save();
692
-                }
693
-                $updated = 1;
694
-            }
695
-            $action_desc = 'created';
696
-        } else {
697
-            $PRC_ID = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER);
698
-            // run the update
699
-            $where_cols_n_values = ['PRC_ID' => $PRC_ID];
700
-            $updated             = EEM_Price::instance()->update($set_column_values, [$where_cols_n_values]);
701
-
702
-            $price = EEM_Price::instance()->get_one_by_ID($PRC_ID);
703
-            if ($price instanceof EE_Price && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
704
-                // if this is $PRC_ID == 1,
705
-                // then we need to update the default ticket attached to this price so the TKT_price value is updated.
706
-                if ($PRC_ID === 1) {
707
-                    $ticket = $price->get_first_related('Ticket');
708
-                    if ($ticket) {
709
-                        $ticket->set('TKT_price', $price->get('PRC_amount'));
710
-                        $ticket->set('TKT_name', $price->get('PRC_name'));
711
-                        $ticket->set('TKT_description', $price->get('PRC_desc'));
712
-                        $ticket->save();
713
-                    }
714
-                } else {
715
-                    // we make sure this price is attached to base ticket. but ONLY if its not a tax ticket type.
716
-                    $ticket = EEM_Ticket::instance()->get_one_by_ID(1);
717
-                    $ticket->_add_relation_to($PRC_ID, 'Price');
718
-                    $ticket->save();
719
-                }
720
-            }
721
-
722
-            $action_desc = 'updated';
723
-        }
724
-
725
-        $query_args = ['action' => 'edit_price', 'id' => $PRC_ID];
726
-
727
-        $this->_redirect_after_action($updated, 'Prices', $action_desc, $query_args);
728
-    }
729
-
730
-
731
-    /**
732
-     * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE)
733
-     * @return void
734
-     * @throws EE_Error
735
-     * @throws ReflectionException
736
-     */
737
-    protected function _trash_or_restore_price(bool $trash = true)
738
-    {
739
-        $entity_model = EEM_Price::instance();
740
-        $action       = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE;
741
-        $result       = $this->trashRestoreDeleteEntities(
742
-            $entity_model,
743
-            'id',
744
-            $action,
745
-            'PRC_deleted',
746
-            [$this, 'adjustTicketRelations']
747
-        );
748
-
749
-        if ($result) {
750
-            $msg = $trash
751
-                ? esc_html(
752
-                    _n(
753
-                        'The Price has been trashed',
754
-                        'The Prices have been trashed',
755
-                        $result,
756
-                        'event_espresso'
757
-                    )
758
-                )
759
-                : esc_html(
760
-                    _n(
761
-                        'The Price has been restored',
762
-                        'The Prices have been restored',
763
-                        $result,
764
-                        'event_espresso'
765
-                    )
766
-                );
767
-            EE_Error::add_success($msg);
768
-        }
769
-
770
-        $this->_redirect_after_action(
771
-            $result,
772
-            _n('Price', 'Prices', $result, 'event_espresso'),
773
-            $trash ? 'trashed' : 'restored',
774
-            ['action' => 'default'],
775
-            true
776
-        );
777
-    }
778
-
779
-
780
-    /**
781
-     * @param EEM_Base   $entity_model
782
-     * @param int|string $entity_ID
783
-     * @param string     $action
784
-     * @param int        $result
785
-     * @throws EE_Error
786
-     * @throws ReflectionException
787
-     * @since 4.10.30.p
788
-     */
789
-    public function adjustTicketRelations(
790
-        EEM_Base $entity_model,
791
-        $entity_ID,
792
-        string $action,
793
-        int $result
794
-    ) {
795
-        if (! $entity_ID || (float) $result < 1) {
796
-            return;
797
-        }
798
-
799
-        $entity = $entity_model->get_one_by_ID($entity_ID);
800
-        if (! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) {
801
-            return;
802
-        }
803
-
804
-        // get default tickets for updating
805
-        $default_tickets = EEM_Ticket::instance()->get_all_default_tickets();
806
-        foreach ($default_tickets as $default_ticket) {
807
-            if (! $default_ticket instanceof EE_Ticket) {
808
-                continue;
809
-            }
810
-            switch ($action) {
811
-                case EE_Admin_List_Table::ACTION_DELETE:
812
-                case EE_Admin_List_Table::ACTION_TRASH:
813
-                    // if trashing then remove relations to base default ticket.
814
-                    $default_ticket->_remove_relation_to($entity_ID, 'Price');
815
-                    break;
816
-                case EE_Admin_List_Table::ACTION_RESTORE:
817
-                    // if restoring then add back to base default ticket
818
-                    $default_ticket->_add_relation_to($entity_ID, 'Price');
819
-                    break;
820
-            }
821
-            $default_ticket->save();
822
-        }
823
-    }
824
-
825
-
826
-    /**
827
-     * @return void
828
-     * @throws EE_Error
829
-     * @throws ReflectionException
830
-     */
831
-    protected function _delete_price()
832
-    {
833
-        $entity_model = EEM_Price::instance();
834
-        $deleted      = $this->trashRestoreDeleteEntities($entity_model, 'id');
835
-        $entity       = $entity_model->item_name($deleted);
836
-        $this->_redirect_after_action(
837
-            $deleted,
838
-            $entity,
839
-            'deleted',
840
-            ['action' => 'default']
841
-        );
842
-    }
843
-
844
-
845
-    /**
846
-     * @throws EE_Error
847
-     * @throws ReflectionException
848
-     */
849
-    public function update_price_order()
850
-    {
851
-        // grab our row IDs
852
-        $row_ids = $this->request->getRequestParam('row_ids', '');
853
-        $row_ids = explode(',', rtrim($row_ids, ','));
854
-
855
-        $all_updated = true;
856
-        foreach ($row_ids as $i => $row_id) {
857
-            // Update the prices when re-ordering
858
-            $fields_n_values = ['PRC_order' => $i + 1];
859
-            $query_params    = [['PRC_ID' => absint($row_id)]];
860
-            // any failure will toggle $all_updated to false
861
-            $all_updated = $row_id && EEM_Price::instance()->update($fields_n_values, $query_params) !== false
862
-                ? $all_updated
863
-                : false;
864
-        }
865
-        $success = $all_updated
866
-            ? esc_html__('Price order was updated successfully.', 'event_espresso')
867
-            : false;
868
-        $errors  = ! $all_updated
869
-            ? esc_html__('An error occurred. The price order was not updated.', 'event_espresso')
870
-            : false;
871
-
872
-        echo wp_json_encode(['return_data' => false, 'success' => $success, 'errors' => $errors]);
873
-        die();
874
-    }
875
-
876
-
877
-    /******************************************************************************************************************
14
+	protected function _init_page_props()
15
+	{
16
+		$this->page_slug        = PRICING_PG_SLUG;
17
+		$this->page_label       = PRICING_LABEL;
18
+		$this->_admin_base_url  = PRICING_ADMIN_URL;
19
+		$this->_admin_base_path = PRICING_ADMIN;
20
+	}
21
+
22
+
23
+	protected function _ajax_hooks()
24
+	{
25
+		add_action('wp_ajax_espresso_update_prices_order', [$this, 'update_price_order']);
26
+	}
27
+
28
+
29
+	protected function _define_page_props()
30
+	{
31
+		$this->_admin_page_title = PRICING_LABEL;
32
+		$this->_labels           = [
33
+			'buttons' => [
34
+				'add'         => esc_html__('Add New Default Price', 'event_espresso'),
35
+				'edit'        => esc_html__('Edit Default Price', 'event_espresso'),
36
+				'delete'      => esc_html__('Delete Default Price', 'event_espresso'),
37
+				'add_type'    => esc_html__('Add New Default Price Type', 'event_espresso'),
38
+				'edit_type'   => esc_html__('Edit Price Type', 'event_espresso'),
39
+				'delete_type' => esc_html__('Delete Price Type', 'event_espresso'),
40
+			],
41
+		];
42
+	}
43
+
44
+
45
+	/**
46
+	 * an array for storing request actions and their corresponding methods
47
+	 *
48
+	 * @return void
49
+	 */
50
+	protected function _set_page_routes()
51
+	{
52
+		$PRC_ID             = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER);
53
+		$PRT_ID             = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
54
+		$this->_page_routes = [
55
+			'default'                     => [
56
+				'func'       => '_price_overview_list_table',
57
+				'capability' => 'ee_read_default_prices',
58
+			],
59
+			'add_new_price'               => [
60
+				'func'       => '_edit_price_details',
61
+				'args'       => ['new_price' => true],
62
+				'capability' => 'ee_edit_default_prices',
63
+			],
64
+			'edit_price'                  => [
65
+				'func'       => '_edit_price_details',
66
+				'args'       => ['new_price' => false],
67
+				'capability' => 'ee_edit_default_price',
68
+				'obj_id'     => $PRC_ID,
69
+			],
70
+			'insert_price'                => [
71
+				'func'       => '_insert_or_update_price',
72
+				'args'       => ['new_price' => true],
73
+				'noheader'   => true,
74
+				'capability' => 'ee_edit_default_prices',
75
+			],
76
+			'update_price'                => [
77
+				'func'       => '_insert_or_update_price',
78
+				'args'       => ['new_price' => false],
79
+				'noheader'   => true,
80
+				'capability' => 'ee_edit_default_price',
81
+				'obj_id'     => $PRC_ID,
82
+			],
83
+			'trash_price'                 => [
84
+				'func'       => '_trash_or_restore_price',
85
+				'args'       => ['trash' => true],
86
+				'noheader'   => true,
87
+				'capability' => 'ee_delete_default_price',
88
+				'obj_id'     => $PRC_ID,
89
+			],
90
+			'restore_price'               => [
91
+				'func'       => '_trash_or_restore_price',
92
+				'args'       => ['trash' => false],
93
+				'noheader'   => true,
94
+				'capability' => 'ee_delete_default_price',
95
+				'obj_id'     => $PRC_ID,
96
+			],
97
+			'delete_price'                => [
98
+				'func'       => '_delete_price',
99
+				'noheader'   => true,
100
+				'capability' => 'ee_delete_default_price',
101
+				'obj_id'     => $PRC_ID,
102
+			],
103
+			'espresso_update_price_order' => [
104
+				'func'       => 'update_price_order',
105
+				'noheader'   => true,
106
+				'capability' => 'ee_edit_default_prices',
107
+			],
108
+			// price types
109
+			'price_types'                 => [
110
+				'func'       => '_price_types_overview_list_table',
111
+				'capability' => 'ee_read_default_price_types',
112
+			],
113
+			'add_new_price_type'          => [
114
+				'func'       => '_edit_price_type_details',
115
+				'capability' => 'ee_edit_default_price_types',
116
+			],
117
+			'edit_price_type'             => [
118
+				'func'       => '_edit_price_type_details',
119
+				'capability' => 'ee_edit_default_price_type',
120
+				'obj_id'     => $PRT_ID,
121
+			],
122
+			'insert_price_type'           => [
123
+				'func'       => '_insert_or_update_price_type',
124
+				'args'       => ['new_price_type' => true],
125
+				'noheader'   => true,
126
+				'capability' => 'ee_edit_default_price_types',
127
+			],
128
+			'update_price_type'           => [
129
+				'func'       => '_insert_or_update_price_type',
130
+				'args'       => ['new_price_type' => false],
131
+				'noheader'   => true,
132
+				'capability' => 'ee_edit_default_price_type',
133
+				'obj_id'     => $PRT_ID,
134
+			],
135
+			'trash_price_type'            => [
136
+				'func'       => '_trash_or_restore_price_type',
137
+				'args'       => ['trash' => true],
138
+				'noheader'   => true,
139
+				'capability' => 'ee_delete_default_price_type',
140
+				'obj_id'     => $PRT_ID,
141
+			],
142
+			'restore_price_type'          => [
143
+				'func'       => '_trash_or_restore_price_type',
144
+				'args'       => ['trash' => false],
145
+				'noheader'   => true,
146
+				'capability' => 'ee_delete_default_price_type',
147
+				'obj_id'     => $PRT_ID,
148
+			],
149
+			'delete_price_type'           => [
150
+				'func'       => '_delete_price_type',
151
+				'noheader'   => true,
152
+				'capability' => 'ee_delete_default_price_type',
153
+				'obj_id'     => $PRT_ID,
154
+			],
155
+			'tax_settings'                => [
156
+				'func'       => '_tax_settings',
157
+				'capability' => 'manage_options',
158
+			],
159
+			'update_tax_settings'         => [
160
+				'func'       => '_update_tax_settings',
161
+				'capability' => 'manage_options',
162
+				'noheader'   => true,
163
+			],
164
+		];
165
+	}
166
+
167
+
168
+	protected function _set_page_config()
169
+	{
170
+		$PRC_ID             = $this->request->getRequestParam('id', 0, DataType::INTEGER);
171
+		$this->_page_config = [
172
+			'default'            => [
173
+				'nav'           => [
174
+					'label' => esc_html__('Default Pricing', 'event_espresso'),
175
+					'order' => 10,
176
+				],
177
+				'list_table'    => 'Prices_List_Table',
178
+				'metaboxes'     => $this->_default_espresso_metaboxes,
179
+				'help_tabs'     => [
180
+					'pricing_default_pricing_help_tab'                           => [
181
+						'title'    => esc_html__('Default Pricing', 'event_espresso'),
182
+						'filename' => 'pricing_default_pricing',
183
+					],
184
+					'pricing_default_pricing_table_column_headings_help_tab'     => [
185
+						'title'    => esc_html__('Default Pricing Table Column Headings', 'event_espresso'),
186
+						'filename' => 'pricing_default_pricing_table_column_headings',
187
+					],
188
+					'pricing_default_pricing_views_bulk_actions_search_help_tab' => [
189
+						'title'    => esc_html__('Default Pricing Views & Bulk Actions & Search', 'event_espresso'),
190
+						'filename' => 'pricing_default_pricing_views_bulk_actions_search',
191
+					],
192
+				],
193
+				'require_nonce' => false,
194
+			],
195
+			'add_new_price'      => [
196
+				'nav'           => [
197
+					'label'      => esc_html__('Add New Default Price', 'event_espresso'),
198
+					'order'      => 20,
199
+					'persistent' => false,
200
+				],
201
+				'help_tabs'     => [
202
+					'add_new_default_price_help_tab' => [
203
+						'title'    => esc_html__('Add New Default Price', 'event_espresso'),
204
+						'filename' => 'pricing_add_new_default_price',
205
+					],
206
+				],
207
+				'metaboxes'     => array_merge(
208
+					['_publish_post_box'],
209
+					$this->_default_espresso_metaboxes
210
+				),
211
+				'require_nonce' => false,
212
+			],
213
+			'edit_price'         => [
214
+				'nav'           => [
215
+					'label'      => esc_html__('Edit Default Price', 'event_espresso'),
216
+					'order'      => 20,
217
+					'url'        => $PRC_ID
218
+						? add_query_arg(['id' => $PRC_ID], $this->_current_page_view_url)
219
+						: $this->_admin_base_url,
220
+					'persistent' => false,
221
+				],
222
+				'metaboxes'     => array_merge(
223
+					['_publish_post_box'],
224
+					$this->_default_espresso_metaboxes
225
+				),
226
+				'help_tabs'     => [
227
+					'edit_default_price_help_tab' => [
228
+						'title'    => esc_html__('Edit Default Price', 'event_espresso'),
229
+						'filename' => 'pricing_edit_default_price',
230
+					],
231
+				],
232
+				'require_nonce' => false,
233
+			],
234
+			'price_types'        => [
235
+				'nav'           => [
236
+					'label' => esc_html__('Price Types', 'event_espresso'),
237
+					'order' => 30,
238
+				],
239
+				'list_table'    => 'Price_Types_List_Table',
240
+				'help_tabs'     => [
241
+					'pricing_price_types_help_tab'                           => [
242
+						'title'    => esc_html__('Price Types', 'event_espresso'),
243
+						'filename' => 'pricing_price_types',
244
+					],
245
+					'pricing_price_types_table_column_headings_help_tab'     => [
246
+						'title'    => esc_html__('Price Types Table Column Headings', 'event_espresso'),
247
+						'filename' => 'pricing_price_types_table_column_headings',
248
+					],
249
+					'pricing_price_types_views_bulk_actions_search_help_tab' => [
250
+						'title'    => esc_html__('Price Types Views & Bulk Actions & Search', 'event_espresso'),
251
+						'filename' => 'pricing_price_types_views_bulk_actions_search',
252
+					],
253
+				],
254
+				'metaboxes'     => $this->_default_espresso_metaboxes,
255
+				'require_nonce' => false,
256
+			],
257
+			'add_new_price_type' => [
258
+				'nav'           => [
259
+					'label'      => esc_html__('Add New Price Type', 'event_espresso'),
260
+					'order'      => 40,
261
+					'persistent' => false,
262
+				],
263
+				'help_tabs'     => [
264
+					'add_new_price_type_help_tab' => [
265
+						'title'    => esc_html__('Add New Price Type', 'event_espresso'),
266
+						'filename' => 'pricing_add_new_price_type',
267
+					],
268
+				],
269
+				'metaboxes'     => array_merge(
270
+					['_publish_post_box'],
271
+					$this->_default_espresso_metaboxes
272
+				),
273
+				'require_nonce' => false,
274
+			],
275
+			'edit_price_type'    => [
276
+				'nav'           => [
277
+					'label'      => esc_html__('Edit Price Type', 'event_espresso'),
278
+					'order'      => 40,
279
+					'persistent' => false,
280
+				],
281
+				'help_tabs'     => [
282
+					'edit_price_type_help_tab' => [
283
+						'title'    => esc_html__('Edit Price Type', 'event_espresso'),
284
+						'filename' => 'pricing_edit_price_type',
285
+					],
286
+				],
287
+				'metaboxes'     => array_merge(
288
+					['_publish_post_box'],
289
+					$this->_default_espresso_metaboxes
290
+				),
291
+				'require_nonce' => false,
292
+			],
293
+			'tax_settings'       => [
294
+				'nav'           => [
295
+					'label' => esc_html__('Tax Settings', 'event_espresso'),
296
+					'order' => 40,
297
+				],
298
+				'labels'        => [
299
+					'publishbox' => esc_html__('Update Tax Settings', 'event_espresso'),
300
+				],
301
+				'metaboxes'     => array_merge(
302
+					['_publish_post_box'],
303
+					$this->_default_espresso_metaboxes
304
+				),
305
+				'require_nonce' => true,
306
+			],
307
+		];
308
+	}
309
+
310
+
311
+	protected function _add_screen_options()
312
+	{
313
+		// todo
314
+	}
315
+
316
+
317
+	protected function _add_screen_options_default()
318
+	{
319
+		$this->_per_page_screen_option();
320
+	}
321
+
322
+
323
+	protected function _add_screen_options_price_types()
324
+	{
325
+		$page_title              = $this->_admin_page_title;
326
+		$this->_admin_page_title = esc_html__('Price Types', 'event_espresso');
327
+		$this->_per_page_screen_option();
328
+		$this->_admin_page_title = $page_title;
329
+	}
330
+
331
+
332
+	protected function _add_feature_pointers()
333
+	{
334
+	}
335
+
336
+
337
+	public function load_scripts_styles()
338
+	{
339
+		// styles
340
+		wp_enqueue_style('espresso-ui-theme');
341
+		wp_register_style(
342
+			'espresso_PRICING',
343
+			PRICING_ASSETS_URL . 'espresso_pricing_admin.css',
344
+			[],
345
+			EVENT_ESPRESSO_VERSION
346
+		);
347
+		wp_enqueue_style('espresso_PRICING');
348
+
349
+		// scripts
350
+		wp_enqueue_script('ee_admin_js');
351
+		wp_enqueue_script('jquery-ui-position');
352
+		wp_enqueue_script('jquery-ui-widget');
353
+		wp_register_script(
354
+			'espresso_PRICING',
355
+			PRICING_ASSETS_URL . 'espresso_pricing_admin.js',
356
+			['jquery'],
357
+			EVENT_ESPRESSO_VERSION,
358
+			true
359
+		);
360
+		wp_enqueue_script('espresso_PRICING');
361
+	}
362
+
363
+
364
+	public function load_scripts_styles_default()
365
+	{
366
+		wp_enqueue_script('espresso_ajax_table_sorting');
367
+	}
368
+
369
+
370
+	public function admin_footer_scripts()
371
+	{
372
+	}
373
+
374
+
375
+	public function admin_init()
376
+	{
377
+	}
378
+
379
+
380
+	public function admin_notices()
381
+	{
382
+	}
383
+
384
+
385
+	protected function _set_list_table_views_default()
386
+	{
387
+		$this->_views = [
388
+			'all' => [
389
+				'slug'        => 'all',
390
+				'label'       => esc_html__('View All Default Pricing', 'event_espresso'),
391
+				'count'       => 0,
392
+				'bulk_action' => [
393
+					'trash_price' => esc_html__('Move to Trash', 'event_espresso'),
394
+				],
395
+			],
396
+		];
397
+
398
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) {
399
+			$this->_views['trashed'] = [
400
+				'slug'        => 'trashed',
401
+				'label'       => esc_html__('Trash', 'event_espresso'),
402
+				'count'       => 0,
403
+				'bulk_action' => [
404
+					'restore_price' => esc_html__('Restore from Trash', 'event_espresso'),
405
+					'delete_price'  => esc_html__('Delete Permanently', 'event_espresso'),
406
+				],
407
+			];
408
+		}
409
+	}
410
+
411
+
412
+	protected function _set_list_table_views_price_types()
413
+	{
414
+		$this->_views = [
415
+			'all' => [
416
+				'slug'        => 'all',
417
+				'label'       => esc_html__('All', 'event_espresso'),
418
+				'count'       => 0,
419
+				'bulk_action' => [
420
+					'trash_price_type' => esc_html__('Move to Trash', 'event_espresso'),
421
+				],
422
+			],
423
+		];
424
+
425
+		if (
426
+			EE_Registry::instance()->CAP->current_user_can(
427
+				'ee_delete_default_price_types',
428
+				'pricing_trash_price_type'
429
+			)
430
+		) {
431
+			$this->_views['trashed'] = [
432
+				'slug'        => 'trashed',
433
+				'label'       => esc_html__('Trash', 'event_espresso'),
434
+				'count'       => 0,
435
+				'bulk_action' => [
436
+					'restore_price_type' => esc_html__('Restore from Trash', 'event_espresso'),
437
+					'delete_price_type'  => esc_html__('Delete Permanently', 'event_espresso'),
438
+				],
439
+			];
440
+		}
441
+	}
442
+
443
+
444
+	/**
445
+	 * generates HTML for main Prices Admin page
446
+	 *
447
+	 * @return void
448
+	 * @throws EE_Error
449
+	 */
450
+	protected function _price_overview_list_table()
451
+	{
452
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
453
+			'add_new_price',
454
+			'add',
455
+			[],
456
+			'add-new-h2'
457
+		);
458
+		$this->_admin_page_title .= $this->_learn_more_about_pricing_link();
459
+		$this->_search_btn_label = esc_html__('Default Prices', 'event_espresso');
460
+		$this->display_admin_list_table_page_with_sidebar();
461
+	}
462
+
463
+
464
+	/**
465
+	 * retrieve data for Prices List table
466
+	 *
467
+	 * @param int  $per_page how many prices displayed per page
468
+	 * @param bool $count    return the count or objects
469
+	 * @param bool $trashed  whether the current view is of the trash can - eww yuck!
470
+	 * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects
471
+	 * @throws EE_Error
472
+	 * @throws ReflectionException
473
+	 */
474
+	public function get_prices_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
475
+	{
476
+		// start with an empty array
477
+		$event_pricing = [];
478
+
479
+		require_once(PRICING_ADMIN . 'Prices_List_Table.class.php');
480
+
481
+		$orderby = $this->request->getRequestParam('orderby', '');
482
+		$order   = $this->request->getRequestParam('order', 'ASC');
483
+
484
+		switch ($orderby) {
485
+			case 'name':
486
+				$orderby = ['PRC_name' => $order];
487
+				break;
488
+			case 'type':
489
+				$orderby = ['Price_Type.PRT_name' => $order];
490
+				break;
491
+			case 'amount':
492
+				$orderby = ['PRC_amount' => $order];
493
+				break;
494
+			default:
495
+				$orderby = ['PRC_order' => $order, 'Price_Type.PRT_order' => $order, 'PRC_ID' => $order];
496
+		}
497
+
498
+		$current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER);
499
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER);
500
+
501
+		$where = [
502
+			'PRC_is_default' => 1,
503
+			'PRC_deleted'    => $trashed,
504
+		];
505
+
506
+		$offset = ($current_page - 1) * $per_page;
507
+		$limit  = [$offset, $per_page];
508
+
509
+		$search_term = $this->request->getRequestParam('s');
510
+		if ($search_term) {
511
+			$search_term = "%{$search_term}%";
512
+			$where['OR'] = [
513
+				'PRC_name'            => ['LIKE', $search_term],
514
+				'PRC_desc'            => ['LIKE', $search_term],
515
+				'PRC_amount'          => ['LIKE', $search_term],
516
+				'Price_Type.PRT_name' => ['LIKE', $search_term],
517
+			];
518
+		}
519
+
520
+		$query_params = [
521
+			$where,
522
+			'order_by' => $orderby,
523
+			'limit'    => $limit,
524
+			'group_by' => 'PRC_ID',
525
+		];
526
+
527
+		if ($count) {
528
+			return $trashed
529
+				? EEM_Price::instance()->count([$where])
530
+				: EEM_Price::instance()->count_deleted_and_undeleted([$where]);
531
+		}
532
+		return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params);
533
+	}
534
+
535
+
536
+	/**
537
+	 * @return void
538
+	 * @throws EE_Error
539
+	 * @throws ReflectionException
540
+	 */
541
+	protected function _edit_price_details()
542
+	{
543
+		// grab price ID
544
+		$PRC_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER);
545
+		// change page title based on request action
546
+		switch ($this->_req_action) {
547
+			case 'add_new_price':
548
+				$this->_admin_page_title = esc_html__('Add New Price', 'event_espresso');
549
+				break;
550
+			case 'edit_price':
551
+				$this->_admin_page_title = esc_html__('Edit Price', 'event_espresso');
552
+				break;
553
+			default:
554
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
555
+		}
556
+		// add PRC_ID to title if editing
557
+		$this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title;
558
+
559
+		if ($PRC_ID) {
560
+			$price                    = EEM_Price::instance()->get_one_by_ID($PRC_ID);
561
+			$additional_hidden_fields = [
562
+				'PRC_ID' => ['type' => 'hidden', 'value' => $PRC_ID],
563
+			];
564
+			$this->_set_add_edit_form_tags('update_price', $additional_hidden_fields);
565
+		} else {
566
+			$price = EEM_Price::instance()->get_new_price();
567
+			$this->_set_add_edit_form_tags('insert_price');
568
+		}
569
+
570
+		if (! $price instanceof EE_Price) {
571
+			throw new RuntimeException(
572
+				sprintf(
573
+					esc_html__(
574
+						'A valid Price could not be retrieved from the database with ID: %1$s',
575
+						'event_espresso'
576
+					),
577
+					$PRC_ID
578
+				)
579
+			);
580
+		}
581
+
582
+		$this->_template_args['PRC_ID'] = $PRC_ID;
583
+		$this->_template_args['price']  = $price;
584
+
585
+		$default_base_price = $price->type_obj() && $price->type_obj()->base_type() === 1;
586
+
587
+		$this->_template_args['default_base_price'] = $default_base_price;
588
+
589
+		// get price types
590
+		$price_types = EEM_Price_Type::instance()->get_all([['PBT_ID' => ['!=', 1]]]);
591
+		if (empty($price_types)) {
592
+			$msg = esc_html__(
593
+				'You have no price types defined. Please add a price type before adding a price.',
594
+				'event_espresso'
595
+			);
596
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
597
+			$this->display_admin_page_with_sidebar();
598
+		}
599
+		$attributes       = [];
600
+		$price_type_names = [];
601
+		$attributes[]     = 'id="PRT_ID"';
602
+		if ($default_base_price) {
603
+			$attributes[]       = 'disabled="disabled"';
604
+			$price_type_names[] = ['id' => 1, 'text' => esc_html__('Base Price', 'event_espresso')];
605
+		}
606
+		foreach ($price_types as $type) {
607
+			$price_type_names[] = ['id' => $type->ID(), 'text' => $type->name()];
608
+		}
609
+		$this->_template_args['attributes']  = implode(' ', $attributes);
610
+		$this->_template_args['price_types'] = $price_type_names;
611
+
612
+		$this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
613
+		$this->_template_args['admin_page_content']            = $this->_edit_price_details_meta_box();
614
+
615
+		$this->_set_publish_post_box_vars('id', $PRC_ID);
616
+		// the details template wrapper
617
+		$this->display_admin_page_with_sidebar();
618
+	}
619
+
620
+
621
+	/**
622
+	 *
623
+	 * @return string
624
+	 */
625
+	public function _edit_price_details_meta_box(): string
626
+	{
627
+		return EEH_Template::display_template(
628
+			PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php',
629
+			$this->_template_args,
630
+			true
631
+		);
632
+	}
633
+
634
+
635
+	/**
636
+	 * @return array
637
+	 * @throws EE_Error
638
+	 * @throws ReflectionException
639
+	 */
640
+	protected function set_price_column_values(): array
641
+	{
642
+		$PRC_order = 0;
643
+		$PRT_ID    = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
644
+		if ($PRT_ID) {
645
+			/** @var EE_Price_Type $price_type */
646
+			$price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
647
+			if ($price_type instanceof EE_Price_Type) {
648
+				$PRC_order = $price_type->order();
649
+			}
650
+		}
651
+		return [
652
+			'PRT_ID'         => $PRT_ID,
653
+			'PRC_amount'     => $this->request->getRequestParam('PRC_amount', 0, DataType::FLOAT),
654
+			'PRC_name'       => $this->request->getRequestParam('PRC_name'),
655
+			'PRC_desc'       => $this->request->getRequestParam('PRC_desc'),
656
+			'PRC_is_default' => 1,
657
+			'PRC_overrides'  => null,
658
+			'PRC_order'      => $PRC_order,
659
+			'PRC_deleted'    => 0,
660
+			'PRC_parent'     => 0,
661
+		];
662
+	}
663
+
664
+
665
+	/**
666
+	 * @param bool $insert - whether to insert or update
667
+	 * @return void
668
+	 * @throws EE_Error
669
+	 * @throws ReflectionException
670
+	 */
671
+	protected function _insert_or_update_price(bool $insert = false)
672
+	{
673
+		// why be so pessimistic ???  : (
674
+		$updated = 0;
675
+
676
+		$set_column_values = $this->set_price_column_values();
677
+		// is this a new Price ?
678
+		if ($insert) {
679
+			// run the insert
680
+			$PRC_ID = EEM_Price::instance()->insert($set_column_values);
681
+			if ($PRC_ID) {
682
+				// make sure this new price modifier is attached to the ticket but ONLY if it is not a tax type
683
+				$price = EEM_price::instance()->get_one_by_ID($PRC_ID);
684
+				if (
685
+					$price instanceof EE_Price
686
+					&& $price->type_obj() instanceof EE_Price_type
687
+					&& $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax
688
+				) {
689
+					$ticket = EEM_Ticket::instance()->get_one_by_ID(1);
690
+					$ticket->_add_relation_to($price, 'Price');
691
+					$ticket->save();
692
+				}
693
+				$updated = 1;
694
+			}
695
+			$action_desc = 'created';
696
+		} else {
697
+			$PRC_ID = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER);
698
+			// run the update
699
+			$where_cols_n_values = ['PRC_ID' => $PRC_ID];
700
+			$updated             = EEM_Price::instance()->update($set_column_values, [$where_cols_n_values]);
701
+
702
+			$price = EEM_Price::instance()->get_one_by_ID($PRC_ID);
703
+			if ($price instanceof EE_Price && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
704
+				// if this is $PRC_ID == 1,
705
+				// then we need to update the default ticket attached to this price so the TKT_price value is updated.
706
+				if ($PRC_ID === 1) {
707
+					$ticket = $price->get_first_related('Ticket');
708
+					if ($ticket) {
709
+						$ticket->set('TKT_price', $price->get('PRC_amount'));
710
+						$ticket->set('TKT_name', $price->get('PRC_name'));
711
+						$ticket->set('TKT_description', $price->get('PRC_desc'));
712
+						$ticket->save();
713
+					}
714
+				} else {
715
+					// we make sure this price is attached to base ticket. but ONLY if its not a tax ticket type.
716
+					$ticket = EEM_Ticket::instance()->get_one_by_ID(1);
717
+					$ticket->_add_relation_to($PRC_ID, 'Price');
718
+					$ticket->save();
719
+				}
720
+			}
721
+
722
+			$action_desc = 'updated';
723
+		}
724
+
725
+		$query_args = ['action' => 'edit_price', 'id' => $PRC_ID];
726
+
727
+		$this->_redirect_after_action($updated, 'Prices', $action_desc, $query_args);
728
+	}
729
+
730
+
731
+	/**
732
+	 * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE)
733
+	 * @return void
734
+	 * @throws EE_Error
735
+	 * @throws ReflectionException
736
+	 */
737
+	protected function _trash_or_restore_price(bool $trash = true)
738
+	{
739
+		$entity_model = EEM_Price::instance();
740
+		$action       = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE;
741
+		$result       = $this->trashRestoreDeleteEntities(
742
+			$entity_model,
743
+			'id',
744
+			$action,
745
+			'PRC_deleted',
746
+			[$this, 'adjustTicketRelations']
747
+		);
748
+
749
+		if ($result) {
750
+			$msg = $trash
751
+				? esc_html(
752
+					_n(
753
+						'The Price has been trashed',
754
+						'The Prices have been trashed',
755
+						$result,
756
+						'event_espresso'
757
+					)
758
+				)
759
+				: esc_html(
760
+					_n(
761
+						'The Price has been restored',
762
+						'The Prices have been restored',
763
+						$result,
764
+						'event_espresso'
765
+					)
766
+				);
767
+			EE_Error::add_success($msg);
768
+		}
769
+
770
+		$this->_redirect_after_action(
771
+			$result,
772
+			_n('Price', 'Prices', $result, 'event_espresso'),
773
+			$trash ? 'trashed' : 'restored',
774
+			['action' => 'default'],
775
+			true
776
+		);
777
+	}
778
+
779
+
780
+	/**
781
+	 * @param EEM_Base   $entity_model
782
+	 * @param int|string $entity_ID
783
+	 * @param string     $action
784
+	 * @param int        $result
785
+	 * @throws EE_Error
786
+	 * @throws ReflectionException
787
+	 * @since 4.10.30.p
788
+	 */
789
+	public function adjustTicketRelations(
790
+		EEM_Base $entity_model,
791
+		$entity_ID,
792
+		string $action,
793
+		int $result
794
+	) {
795
+		if (! $entity_ID || (float) $result < 1) {
796
+			return;
797
+		}
798
+
799
+		$entity = $entity_model->get_one_by_ID($entity_ID);
800
+		if (! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) {
801
+			return;
802
+		}
803
+
804
+		// get default tickets for updating
805
+		$default_tickets = EEM_Ticket::instance()->get_all_default_tickets();
806
+		foreach ($default_tickets as $default_ticket) {
807
+			if (! $default_ticket instanceof EE_Ticket) {
808
+				continue;
809
+			}
810
+			switch ($action) {
811
+				case EE_Admin_List_Table::ACTION_DELETE:
812
+				case EE_Admin_List_Table::ACTION_TRASH:
813
+					// if trashing then remove relations to base default ticket.
814
+					$default_ticket->_remove_relation_to($entity_ID, 'Price');
815
+					break;
816
+				case EE_Admin_List_Table::ACTION_RESTORE:
817
+					// if restoring then add back to base default ticket
818
+					$default_ticket->_add_relation_to($entity_ID, 'Price');
819
+					break;
820
+			}
821
+			$default_ticket->save();
822
+		}
823
+	}
824
+
825
+
826
+	/**
827
+	 * @return void
828
+	 * @throws EE_Error
829
+	 * @throws ReflectionException
830
+	 */
831
+	protected function _delete_price()
832
+	{
833
+		$entity_model = EEM_Price::instance();
834
+		$deleted      = $this->trashRestoreDeleteEntities($entity_model, 'id');
835
+		$entity       = $entity_model->item_name($deleted);
836
+		$this->_redirect_after_action(
837
+			$deleted,
838
+			$entity,
839
+			'deleted',
840
+			['action' => 'default']
841
+		);
842
+	}
843
+
844
+
845
+	/**
846
+	 * @throws EE_Error
847
+	 * @throws ReflectionException
848
+	 */
849
+	public function update_price_order()
850
+	{
851
+		// grab our row IDs
852
+		$row_ids = $this->request->getRequestParam('row_ids', '');
853
+		$row_ids = explode(',', rtrim($row_ids, ','));
854
+
855
+		$all_updated = true;
856
+		foreach ($row_ids as $i => $row_id) {
857
+			// Update the prices when re-ordering
858
+			$fields_n_values = ['PRC_order' => $i + 1];
859
+			$query_params    = [['PRC_ID' => absint($row_id)]];
860
+			// any failure will toggle $all_updated to false
861
+			$all_updated = $row_id && EEM_Price::instance()->update($fields_n_values, $query_params) !== false
862
+				? $all_updated
863
+				: false;
864
+		}
865
+		$success = $all_updated
866
+			? esc_html__('Price order was updated successfully.', 'event_espresso')
867
+			: false;
868
+		$errors  = ! $all_updated
869
+			? esc_html__('An error occurred. The price order was not updated.', 'event_espresso')
870
+			: false;
871
+
872
+		echo wp_json_encode(['return_data' => false, 'success' => $success, 'errors' => $errors]);
873
+		die();
874
+	}
875
+
876
+
877
+	/******************************************************************************************************************
878 878
      ***********************************************  TICKET PRICE TYPES  *********************************************
879 879
      ******************************************************************************************************************/
880 880
 
881 881
 
882
-    /**
883
-     * generates HTML for main Prices Admin page
884
-     *
885
-     * @return void
886
-     * @throws EE_Error
887
-     */
888
-    protected function _price_types_overview_list_table()
889
-    {
890
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
891
-            'add_new_price_type',
892
-            'add_type',
893
-            [],
894
-            'add-new-h2'
895
-        );
896
-        $this->_admin_page_title .= $this->_learn_more_about_pricing_link();
897
-        $this->_search_btn_label = esc_html__('Price Types', 'event_espresso');
898
-        $this->display_admin_list_table_page_with_sidebar();
899
-    }
900
-
901
-
902
-    /**
903
-     * retrieve data for Price Types List table
904
-     *
905
-     * @param int  $per_page how many prices displayed per page
906
-     * @param bool $count    return the count or objects
907
-     * @param bool $trashed  whether the current view is of the trash can - eww yuck!
908
-     * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects
909
-     * @throws EE_Error
910
-     * @throws ReflectionException
911
-     */
912
-    public function get_price_types_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
913
-    {
914
-        // start with an empty array
915
-        require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php');
916
-
917
-        $orderby = $this->request->getRequestParam('orderby', '');
918
-        $order   = $this->request->getRequestParam('order', 'ASC');
919
-
920
-        switch ($orderby) {
921
-            case 'name':
922
-                $orderby = ['PRT_name' => $order];
923
-                break;
924
-            default:
925
-                $orderby = ['PRT_order' => $order];
926
-        }
927
-
928
-        $current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER);
929
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER);
930
-
931
-        $offset = ($current_page - 1) * $per_page;
932
-        $limit  = [$offset, $per_page];
933
-
934
-        $where = ['PRT_deleted' => $trashed, 'PBT_ID' => ['!=', 1]];
935
-
936
-        $search_term = $this->request->getRequestParam('s');
937
-        if ($search_term) {
938
-            $where['OR'] = [
939
-                'PRT_name' => ['LIKE', "%{$search_term}%"],
940
-            ];
941
-        }
942
-        $query_params = [
943
-            $where,
944
-            'order_by' => $orderby,
945
-            'limit'    => $limit,
946
-        ];
947
-        return $count
948
-            ? EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params)
949
-            : EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params);
950
-    }
951
-
952
-
953
-    /**
954
-     * _edit_price_type_details
955
-     *
956
-     * @return void
957
-     * @throws EE_Error
958
-     * @throws ReflectionException
959
-     */
960
-    protected function _edit_price_type_details()
961
-    {
962
-        // grab price type ID
963
-        $PRT_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER);
964
-        // change page title based on request action
965
-        switch ($this->_req_action) {
966
-            case 'add_new_price_type':
967
-                $this->_admin_page_title = esc_html__('Add New Price Type', 'event_espresso');
968
-                break;
969
-            case 'edit_price_type':
970
-                $this->_admin_page_title = esc_html__('Edit Price Type', 'event_espresso');
971
-                break;
972
-            default:
973
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
974
-        }
975
-        // add PRT_ID to title if editing
976
-        $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title;
977
-
978
-        if ($PRT_ID) {
979
-            $price_type               = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
980
-            $additional_hidden_fields = ['PRT_ID' => ['type' => 'hidden', 'value' => $PRT_ID]];
981
-            $this->_set_add_edit_form_tags('update_price_type', $additional_hidden_fields);
982
-        } else {
983
-            $price_type = EEM_Price_Type::instance()->get_new_price_type();
984
-            $this->_set_add_edit_form_tags('insert_price_type');
985
-        }
986
-
987
-        if (! $price_type instanceof EE_Price_Type) {
988
-            throw new RuntimeException(
989
-                sprintf(
990
-                    esc_html__(
991
-                        'A valid Price Type could not be retrieved from the database with ID: %1$s',
992
-                        'event_espresso'
993
-                    ),
994
-                    $PRT_ID
995
-                )
996
-            );
997
-        }
998
-
999
-        $this->_template_args['PRT_ID']     = $PRT_ID;
1000
-        $this->_template_args['price_type'] = $price_type;
1001
-
1002
-        $base_types    = EEM_Price_Type::instance()->get_base_types();
1003
-        $select_values = [];
1004
-        foreach ($base_types as $ref => $text) {
1005
-            if ($ref == EEM_Price_Type::base_type_base_price) {
1006
-                // do not allow creation of base_type_base_prices because that's a system only base type.
1007
-                continue;
1008
-            }
1009
-            $select_values[] = ['id' => $ref, 'text' => $text];
1010
-        }
1011
-
1012
-        $this->_template_args['base_type_select'] = EEH_Form_Fields::select_input(
1013
-            'base_type',
1014
-            $select_values,
1015
-            $price_type->base_type(),
1016
-            'id="price-type-base-type-slct"'
1017
-        );
1018
-
1019
-        $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
1020
-        $this->_template_args['admin_page_content']            = $this->_edit_price_type_details_meta_box();
1021
-
1022
-        $redirect_URL = add_query_arg(['action' => 'price_types'], $this->_admin_base_url);
1023
-        $this->_set_publish_post_box_vars('id', $PRT_ID, false, $redirect_URL);
1024
-        // the details template wrapper
1025
-        $this->display_admin_page_with_sidebar();
1026
-    }
1027
-
1028
-
1029
-    /**
1030
-     * _edit_price_type_details_meta_box
1031
-     *
1032
-     * @return string
1033
-     */
1034
-    public function _edit_price_type_details_meta_box(): string
1035
-    {
1036
-        return EEH_Template::display_template(
1037
-            PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php',
1038
-            $this->_template_args,
1039
-            true
1040
-        );
1041
-    }
1042
-
1043
-
1044
-    /**
1045
-     * @return array
1046
-     */
1047
-    protected function set_price_type_column_values(): array
1048
-    {
1049
-        $base_type  = $this->request->getRequestParam(
1050
-            'base_type',
1051
-            EEM_Price_Type::base_type_base_price,
1052
-            DataType::INTEGER
1053
-        );
1054
-        $is_percent = $this->request->getRequestParam('PRT_is_percent', 0, DataType::INTEGER);
1055
-        $order      = $this->request->getRequestParam('PRT_order', 0, DataType::INTEGER);
1056
-        switch ($base_type) {
1057
-            case EEM_Price_Type::base_type_base_price:
1058
-                $is_percent = 0;
1059
-                $order      = 0;
1060
-                break;
1061
-
1062
-            case EEM_Price_Type::base_type_discount:
1063
-            case EEM_Price_Type::base_type_surcharge:
1064
-                break;
1065
-
1066
-            case EEM_Price_Type::base_type_tax:
1067
-                $is_percent = 1;
1068
-                break;
1069
-        }
1070
-
1071
-        return [
1072
-            'PBT_ID'         => $base_type,
1073
-            'PRT_name'       => $this->request->getRequestParam('PRT_name', ''),
1074
-            'PRT_is_percent' => $is_percent,
1075
-            'PRT_order'      => $order,
1076
-            'PRT_deleted'    => 0,
1077
-        ];
1078
-    }
1079
-
1080
-
1081
-    /**
1082
-     * @param bool $new_price_type - whether to insert or update
1083
-     * @return void
1084
-     * @throws EE_Error
1085
-     * @throws ReflectionException
1086
-     */
1087
-    protected function _insert_or_update_price_type(bool $new_price_type = false)
1088
-    {
1089
-        // why be so pessimistic ???  : (
1090
-        $success = 0;
1091
-
1092
-        $set_column_values = $this->set_price_type_column_values();
1093
-        // is this a new Price ?
1094
-        if ($new_price_type) {
1095
-            // run the insert
1096
-            if ($PRT_ID = EEM_Price_Type::instance()->insert($set_column_values)) {
1097
-                $success = 1;
1098
-            }
1099
-            $action_desc = 'created';
1100
-        } else {
1101
-            $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
1102
-            // run the update
1103
-            $where_cols_n_values = ['PRT_ID' => $PRT_ID];
1104
-            if (EEM_Price_Type::instance()->update($set_column_values, [$where_cols_n_values])) {
1105
-                $success = 1;
1106
-            }
1107
-            $action_desc = 'updated';
1108
-        }
1109
-
1110
-        $query_args = ['action' => 'edit_price_type', 'id' => $PRT_ID];
1111
-        $this->_redirect_after_action($success, 'Price Type', $action_desc, $query_args);
1112
-    }
1113
-
1114
-
1115
-    /**
1116
-     * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE)
1117
-     * @return void
1118
-     * @throws EE_Error
1119
-     * @throws ReflectionException
1120
-     */
1121
-    protected function _trash_or_restore_price_type(bool $trash = true)
1122
-    {
1123
-        $entity_model = EEM_Price_Type::instance();
1124
-        $action       = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE;
1125
-        $success      = $this->trashRestoreDeleteEntities($entity_model, 'id', $action, 'PRT_deleted');
1126
-        if ($success) {
1127
-            $msg = $trash
1128
-                ? esc_html(
1129
-                    _n(
1130
-                        'The Price Type has been trashed',
1131
-                        'The Price Types have been trashed',
1132
-                        $success,
1133
-                        'event_espresso'
1134
-                    )
1135
-                )
1136
-                : esc_html(
1137
-                    _n(
1138
-                        'The Price Type has been restored',
1139
-                        'The Price Types have been restored',
1140
-                        $success,
1141
-                        'event_espresso'
1142
-                    )
1143
-                );
1144
-            EE_Error::add_success($msg);
1145
-        }
1146
-        $this->_redirect_after_action('', '', '', ['action' => 'price_types'], true);
1147
-    }
1148
-
1149
-
1150
-    /**
1151
-     * @return void
1152
-     * @throws EE_Error
1153
-     * @throws ReflectionException
1154
-     */
1155
-    protected function _delete_price_type()
1156
-    {
1157
-        $entity_model = EEM_Price_Type::instance();
1158
-        $deleted      = $this->trashRestoreDeleteEntities($entity_model, 'id');
1159
-        $this->_redirect_after_action(
1160
-            $deleted,
1161
-            $entity_model->item_name($deleted),
1162
-            'deleted',
1163
-            ['action' => 'price_types']
1164
-        );
1165
-    }
1166
-
1167
-
1168
-    /**
1169
-     * @return string
1170
-     */
1171
-    protected function _learn_more_about_pricing_link(): string
1172
-    {
1173
-        return '
882
+	/**
883
+	 * generates HTML for main Prices Admin page
884
+	 *
885
+	 * @return void
886
+	 * @throws EE_Error
887
+	 */
888
+	protected function _price_types_overview_list_table()
889
+	{
890
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
891
+			'add_new_price_type',
892
+			'add_type',
893
+			[],
894
+			'add-new-h2'
895
+		);
896
+		$this->_admin_page_title .= $this->_learn_more_about_pricing_link();
897
+		$this->_search_btn_label = esc_html__('Price Types', 'event_espresso');
898
+		$this->display_admin_list_table_page_with_sidebar();
899
+	}
900
+
901
+
902
+	/**
903
+	 * retrieve data for Price Types List table
904
+	 *
905
+	 * @param int  $per_page how many prices displayed per page
906
+	 * @param bool $count    return the count or objects
907
+	 * @param bool $trashed  whether the current view is of the trash can - eww yuck!
908
+	 * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects
909
+	 * @throws EE_Error
910
+	 * @throws ReflectionException
911
+	 */
912
+	public function get_price_types_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
913
+	{
914
+		// start with an empty array
915
+		require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php');
916
+
917
+		$orderby = $this->request->getRequestParam('orderby', '');
918
+		$order   = $this->request->getRequestParam('order', 'ASC');
919
+
920
+		switch ($orderby) {
921
+			case 'name':
922
+				$orderby = ['PRT_name' => $order];
923
+				break;
924
+			default:
925
+				$orderby = ['PRT_order' => $order];
926
+		}
927
+
928
+		$current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER);
929
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER);
930
+
931
+		$offset = ($current_page - 1) * $per_page;
932
+		$limit  = [$offset, $per_page];
933
+
934
+		$where = ['PRT_deleted' => $trashed, 'PBT_ID' => ['!=', 1]];
935
+
936
+		$search_term = $this->request->getRequestParam('s');
937
+		if ($search_term) {
938
+			$where['OR'] = [
939
+				'PRT_name' => ['LIKE', "%{$search_term}%"],
940
+			];
941
+		}
942
+		$query_params = [
943
+			$where,
944
+			'order_by' => $orderby,
945
+			'limit'    => $limit,
946
+		];
947
+		return $count
948
+			? EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params)
949
+			: EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params);
950
+	}
951
+
952
+
953
+	/**
954
+	 * _edit_price_type_details
955
+	 *
956
+	 * @return void
957
+	 * @throws EE_Error
958
+	 * @throws ReflectionException
959
+	 */
960
+	protected function _edit_price_type_details()
961
+	{
962
+		// grab price type ID
963
+		$PRT_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER);
964
+		// change page title based on request action
965
+		switch ($this->_req_action) {
966
+			case 'add_new_price_type':
967
+				$this->_admin_page_title = esc_html__('Add New Price Type', 'event_espresso');
968
+				break;
969
+			case 'edit_price_type':
970
+				$this->_admin_page_title = esc_html__('Edit Price Type', 'event_espresso');
971
+				break;
972
+			default:
973
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
974
+		}
975
+		// add PRT_ID to title if editing
976
+		$this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title;
977
+
978
+		if ($PRT_ID) {
979
+			$price_type               = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
980
+			$additional_hidden_fields = ['PRT_ID' => ['type' => 'hidden', 'value' => $PRT_ID]];
981
+			$this->_set_add_edit_form_tags('update_price_type', $additional_hidden_fields);
982
+		} else {
983
+			$price_type = EEM_Price_Type::instance()->get_new_price_type();
984
+			$this->_set_add_edit_form_tags('insert_price_type');
985
+		}
986
+
987
+		if (! $price_type instanceof EE_Price_Type) {
988
+			throw new RuntimeException(
989
+				sprintf(
990
+					esc_html__(
991
+						'A valid Price Type could not be retrieved from the database with ID: %1$s',
992
+						'event_espresso'
993
+					),
994
+					$PRT_ID
995
+				)
996
+			);
997
+		}
998
+
999
+		$this->_template_args['PRT_ID']     = $PRT_ID;
1000
+		$this->_template_args['price_type'] = $price_type;
1001
+
1002
+		$base_types    = EEM_Price_Type::instance()->get_base_types();
1003
+		$select_values = [];
1004
+		foreach ($base_types as $ref => $text) {
1005
+			if ($ref == EEM_Price_Type::base_type_base_price) {
1006
+				// do not allow creation of base_type_base_prices because that's a system only base type.
1007
+				continue;
1008
+			}
1009
+			$select_values[] = ['id' => $ref, 'text' => $text];
1010
+		}
1011
+
1012
+		$this->_template_args['base_type_select'] = EEH_Form_Fields::select_input(
1013
+			'base_type',
1014
+			$select_values,
1015
+			$price_type->base_type(),
1016
+			'id="price-type-base-type-slct"'
1017
+		);
1018
+
1019
+		$this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
1020
+		$this->_template_args['admin_page_content']            = $this->_edit_price_type_details_meta_box();
1021
+
1022
+		$redirect_URL = add_query_arg(['action' => 'price_types'], $this->_admin_base_url);
1023
+		$this->_set_publish_post_box_vars('id', $PRT_ID, false, $redirect_URL);
1024
+		// the details template wrapper
1025
+		$this->display_admin_page_with_sidebar();
1026
+	}
1027
+
1028
+
1029
+	/**
1030
+	 * _edit_price_type_details_meta_box
1031
+	 *
1032
+	 * @return string
1033
+	 */
1034
+	public function _edit_price_type_details_meta_box(): string
1035
+	{
1036
+		return EEH_Template::display_template(
1037
+			PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php',
1038
+			$this->_template_args,
1039
+			true
1040
+		);
1041
+	}
1042
+
1043
+
1044
+	/**
1045
+	 * @return array
1046
+	 */
1047
+	protected function set_price_type_column_values(): array
1048
+	{
1049
+		$base_type  = $this->request->getRequestParam(
1050
+			'base_type',
1051
+			EEM_Price_Type::base_type_base_price,
1052
+			DataType::INTEGER
1053
+		);
1054
+		$is_percent = $this->request->getRequestParam('PRT_is_percent', 0, DataType::INTEGER);
1055
+		$order      = $this->request->getRequestParam('PRT_order', 0, DataType::INTEGER);
1056
+		switch ($base_type) {
1057
+			case EEM_Price_Type::base_type_base_price:
1058
+				$is_percent = 0;
1059
+				$order      = 0;
1060
+				break;
1061
+
1062
+			case EEM_Price_Type::base_type_discount:
1063
+			case EEM_Price_Type::base_type_surcharge:
1064
+				break;
1065
+
1066
+			case EEM_Price_Type::base_type_tax:
1067
+				$is_percent = 1;
1068
+				break;
1069
+		}
1070
+
1071
+		return [
1072
+			'PBT_ID'         => $base_type,
1073
+			'PRT_name'       => $this->request->getRequestParam('PRT_name', ''),
1074
+			'PRT_is_percent' => $is_percent,
1075
+			'PRT_order'      => $order,
1076
+			'PRT_deleted'    => 0,
1077
+		];
1078
+	}
1079
+
1080
+
1081
+	/**
1082
+	 * @param bool $new_price_type - whether to insert or update
1083
+	 * @return void
1084
+	 * @throws EE_Error
1085
+	 * @throws ReflectionException
1086
+	 */
1087
+	protected function _insert_or_update_price_type(bool $new_price_type = false)
1088
+	{
1089
+		// why be so pessimistic ???  : (
1090
+		$success = 0;
1091
+
1092
+		$set_column_values = $this->set_price_type_column_values();
1093
+		// is this a new Price ?
1094
+		if ($new_price_type) {
1095
+			// run the insert
1096
+			if ($PRT_ID = EEM_Price_Type::instance()->insert($set_column_values)) {
1097
+				$success = 1;
1098
+			}
1099
+			$action_desc = 'created';
1100
+		} else {
1101
+			$PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
1102
+			// run the update
1103
+			$where_cols_n_values = ['PRT_ID' => $PRT_ID];
1104
+			if (EEM_Price_Type::instance()->update($set_column_values, [$where_cols_n_values])) {
1105
+				$success = 1;
1106
+			}
1107
+			$action_desc = 'updated';
1108
+		}
1109
+
1110
+		$query_args = ['action' => 'edit_price_type', 'id' => $PRT_ID];
1111
+		$this->_redirect_after_action($success, 'Price Type', $action_desc, $query_args);
1112
+	}
1113
+
1114
+
1115
+	/**
1116
+	 * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE)
1117
+	 * @return void
1118
+	 * @throws EE_Error
1119
+	 * @throws ReflectionException
1120
+	 */
1121
+	protected function _trash_or_restore_price_type(bool $trash = true)
1122
+	{
1123
+		$entity_model = EEM_Price_Type::instance();
1124
+		$action       = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE;
1125
+		$success      = $this->trashRestoreDeleteEntities($entity_model, 'id', $action, 'PRT_deleted');
1126
+		if ($success) {
1127
+			$msg = $trash
1128
+				? esc_html(
1129
+					_n(
1130
+						'The Price Type has been trashed',
1131
+						'The Price Types have been trashed',
1132
+						$success,
1133
+						'event_espresso'
1134
+					)
1135
+				)
1136
+				: esc_html(
1137
+					_n(
1138
+						'The Price Type has been restored',
1139
+						'The Price Types have been restored',
1140
+						$success,
1141
+						'event_espresso'
1142
+					)
1143
+				);
1144
+			EE_Error::add_success($msg);
1145
+		}
1146
+		$this->_redirect_after_action('', '', '', ['action' => 'price_types'], true);
1147
+	}
1148
+
1149
+
1150
+	/**
1151
+	 * @return void
1152
+	 * @throws EE_Error
1153
+	 * @throws ReflectionException
1154
+	 */
1155
+	protected function _delete_price_type()
1156
+	{
1157
+		$entity_model = EEM_Price_Type::instance();
1158
+		$deleted      = $this->trashRestoreDeleteEntities($entity_model, 'id');
1159
+		$this->_redirect_after_action(
1160
+			$deleted,
1161
+			$entity_model->item_name($deleted),
1162
+			'deleted',
1163
+			['action' => 'price_types']
1164
+		);
1165
+	}
1166
+
1167
+
1168
+	/**
1169
+	 * @return string
1170
+	 */
1171
+	protected function _learn_more_about_pricing_link(): string
1172
+	{
1173
+		return '
1174 1174
             <a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >
1175 1175
                 ' . esc_html__('learn more about how pricing works', 'event_espresso') . '
1176 1176
             </a>';
1177
-    }
1178
-
1179
-
1180
-    /**
1181
-     * @throws EE_Error
1182
-     */
1183
-    protected function _tax_settings()
1184
-    {
1185
-        $this->_set_add_edit_form_tags('update_tax_settings');
1186
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1187
-        $this->_template_args['admin_page_content'] = $this->tax_settings_form()->get_html();
1188
-        $this->display_admin_page_with_sidebar();
1189
-    }
1190
-
1191
-
1192
-    /**
1193
-     * @return EE_Form_Section_Proper
1194
-     * @throws EE_Error
1195
-     */
1196
-    protected function tax_settings_form(): EE_Form_Section_Proper
1197
-    {
1198
-        $tax_settings = EE_Config::instance()->tax_settings;
1199
-        return new EE_Form_Section_Proper(
1200
-            [
1201
-                'name'            => 'tax_settings_form',
1202
-                'html_id'         => 'tax_settings_form',
1203
-                'html_class'      => 'padding',
1204
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
1205
-                'subsections'     => apply_filters(
1206
-                    'FHEE__Pricing_Admin_Page__tax_settings_form__form_subsections',
1207
-                    [
1208
-                        'tax_settings' => new EE_Form_Section_Proper(
1209
-                            [
1210
-                                'name'            => 'tax_settings_tbl',
1211
-                                'html_id'         => 'tax_settings_tbl',
1212
-                                'html_class'      => 'form-table',
1213
-                                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1214
-                                'subsections'     => [
1215
-                                    'prices_displayed_including_taxes' => new EE_Yes_No_Input(
1216
-                                        [
1217
-                                            'html_label_text'         => esc_html__(
1218
-                                                'Show Prices With Taxes Included?',
1219
-                                                'event_espresso'
1220
-                                            ),
1221
-                                            'html_help_text'          => esc_html__(
1222
-                                                'Indicates whether or not to display prices with the taxes included',
1223
-                                                'event_espresso'
1224
-                                            ),
1225
-                                            'default'                 => $tax_settings->prices_displayed_including_taxes
1226
-                                                                         ?? true,
1227
-                                            'display_html_label_text' => false,
1228
-                                        ]
1229
-                                    ),
1230
-                                ],
1231
-                            ]
1232
-                        ),
1233
-                    ]
1234
-                ),
1235
-            ]
1236
-        );
1237
-    }
1238
-
1239
-
1240
-    /**
1241
-     * _update_tax_settings
1242
-     *
1243
-     * @return void
1244
-     * @throws EE_Error
1245
-     * @throws ReflectionException
1246
-     * @since 4.9.13
1247
-     */
1248
-    public function _update_tax_settings()
1249
-    {
1250
-        $tax_settings = EE_Config::instance()->tax_settings;
1251
-        if (! $tax_settings instanceof EE_Tax_Config) {
1252
-            $tax_settings = new EE_Tax_Config();
1253
-        }
1254
-        try {
1255
-            $tax_form = $this->tax_settings_form();
1256
-            // check for form submission
1257
-            if ($tax_form->was_submitted()) {
1258
-                // capture form data
1259
-                $tax_form->receive_form_submission();
1260
-                // validate form data
1261
-                if ($tax_form->is_valid()) {
1262
-                    // grab validated data from form
1263
-                    $valid_data = $tax_form->valid_data();
1264
-                    // set data on config
1265
-                    $tax_settings->prices_displayed_including_taxes =
1266
-                        $valid_data['tax_settings']['prices_displayed_including_taxes'];
1267
-                } else {
1268
-                    if ($tax_form->submission_error_message() !== '') {
1269
-                        EE_Error::add_error(
1270
-                            $tax_form->submission_error_message(),
1271
-                            __FILE__,
1272
-                            __FUNCTION__,
1273
-                            __LINE__
1274
-                        );
1275
-                    }
1276
-                }
1277
-            }
1278
-        } catch (EE_Error $e) {
1279
-            EE_Error::add_error($e->get_error(), __FILE__, __FUNCTION__, __LINE__);
1280
-        }
1281
-
1282
-        $what    = 'Tax Settings';
1283
-        $success = $this->_update_espresso_configuration(
1284
-            $what,
1285
-            $tax_settings,
1286
-            __FILE__,
1287
-            __FUNCTION__,
1288
-            __LINE__
1289
-        );
1290
-        $this->_redirect_after_action($success, $what, 'updated', ['action' => 'tax_settings']);
1291
-    }
1177
+	}
1178
+
1179
+
1180
+	/**
1181
+	 * @throws EE_Error
1182
+	 */
1183
+	protected function _tax_settings()
1184
+	{
1185
+		$this->_set_add_edit_form_tags('update_tax_settings');
1186
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1187
+		$this->_template_args['admin_page_content'] = $this->tax_settings_form()->get_html();
1188
+		$this->display_admin_page_with_sidebar();
1189
+	}
1190
+
1191
+
1192
+	/**
1193
+	 * @return EE_Form_Section_Proper
1194
+	 * @throws EE_Error
1195
+	 */
1196
+	protected function tax_settings_form(): EE_Form_Section_Proper
1197
+	{
1198
+		$tax_settings = EE_Config::instance()->tax_settings;
1199
+		return new EE_Form_Section_Proper(
1200
+			[
1201
+				'name'            => 'tax_settings_form',
1202
+				'html_id'         => 'tax_settings_form',
1203
+				'html_class'      => 'padding',
1204
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1205
+				'subsections'     => apply_filters(
1206
+					'FHEE__Pricing_Admin_Page__tax_settings_form__form_subsections',
1207
+					[
1208
+						'tax_settings' => new EE_Form_Section_Proper(
1209
+							[
1210
+								'name'            => 'tax_settings_tbl',
1211
+								'html_id'         => 'tax_settings_tbl',
1212
+								'html_class'      => 'form-table',
1213
+								'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1214
+								'subsections'     => [
1215
+									'prices_displayed_including_taxes' => new EE_Yes_No_Input(
1216
+										[
1217
+											'html_label_text'         => esc_html__(
1218
+												'Show Prices With Taxes Included?',
1219
+												'event_espresso'
1220
+											),
1221
+											'html_help_text'          => esc_html__(
1222
+												'Indicates whether or not to display prices with the taxes included',
1223
+												'event_espresso'
1224
+											),
1225
+											'default'                 => $tax_settings->prices_displayed_including_taxes
1226
+																		 ?? true,
1227
+											'display_html_label_text' => false,
1228
+										]
1229
+									),
1230
+								],
1231
+							]
1232
+						),
1233
+					]
1234
+				),
1235
+			]
1236
+		);
1237
+	}
1238
+
1239
+
1240
+	/**
1241
+	 * _update_tax_settings
1242
+	 *
1243
+	 * @return void
1244
+	 * @throws EE_Error
1245
+	 * @throws ReflectionException
1246
+	 * @since 4.9.13
1247
+	 */
1248
+	public function _update_tax_settings()
1249
+	{
1250
+		$tax_settings = EE_Config::instance()->tax_settings;
1251
+		if (! $tax_settings instanceof EE_Tax_Config) {
1252
+			$tax_settings = new EE_Tax_Config();
1253
+		}
1254
+		try {
1255
+			$tax_form = $this->tax_settings_form();
1256
+			// check for form submission
1257
+			if ($tax_form->was_submitted()) {
1258
+				// capture form data
1259
+				$tax_form->receive_form_submission();
1260
+				// validate form data
1261
+				if ($tax_form->is_valid()) {
1262
+					// grab validated data from form
1263
+					$valid_data = $tax_form->valid_data();
1264
+					// set data on config
1265
+					$tax_settings->prices_displayed_including_taxes =
1266
+						$valid_data['tax_settings']['prices_displayed_including_taxes'];
1267
+				} else {
1268
+					if ($tax_form->submission_error_message() !== '') {
1269
+						EE_Error::add_error(
1270
+							$tax_form->submission_error_message(),
1271
+							__FILE__,
1272
+							__FUNCTION__,
1273
+							__LINE__
1274
+						);
1275
+					}
1276
+				}
1277
+			}
1278
+		} catch (EE_Error $e) {
1279
+			EE_Error::add_error($e->get_error(), __FILE__, __FUNCTION__, __LINE__);
1280
+		}
1281
+
1282
+		$what    = 'Tax Settings';
1283
+		$success = $this->_update_espresso_configuration(
1284
+			$what,
1285
+			$tax_settings,
1286
+			__FILE__,
1287
+			__FUNCTION__,
1288
+			__LINE__
1289
+		);
1290
+		$this->_redirect_after_action($success, $what, 'updated', ['action' => 'tax_settings']);
1291
+	}
1292 1292
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
         wp_enqueue_style('espresso-ui-theme');
341 341
         wp_register_style(
342 342
             'espresso_PRICING',
343
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.css',
343
+            PRICING_ASSETS_URL.'espresso_pricing_admin.css',
344 344
             [],
345 345
             EVENT_ESPRESSO_VERSION
346 346
         );
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
         wp_enqueue_script('jquery-ui-widget');
353 353
         wp_register_script(
354 354
             'espresso_PRICING',
355
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.js',
355
+            PRICING_ASSETS_URL.'espresso_pricing_admin.js',
356 356
             ['jquery'],
357 357
             EVENT_ESPRESSO_VERSION,
358 358
             true
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
      */
450 450
     protected function _price_overview_list_table()
451 451
     {
452
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
452
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
453 453
             'add_new_price',
454 454
             'add',
455 455
             [],
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
         // start with an empty array
477 477
         $event_pricing = [];
478 478
 
479
-        require_once(PRICING_ADMIN . 'Prices_List_Table.class.php');
479
+        require_once(PRICING_ADMIN.'Prices_List_Table.class.php');
480 480
 
481 481
         $orderby = $this->request->getRequestParam('orderby', '');
482 482
         $order   = $this->request->getRequestParam('order', 'ASC');
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
                 $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
555 555
         }
556 556
         // add PRC_ID to title if editing
557
-        $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title;
557
+        $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title.' # '.$PRC_ID : $this->_admin_page_title;
558 558
 
559 559
         if ($PRC_ID) {
560 560
             $price                    = EEM_Price::instance()->get_one_by_ID($PRC_ID);
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
             $this->_set_add_edit_form_tags('insert_price');
568 568
         }
569 569
 
570
-        if (! $price instanceof EE_Price) {
570
+        if ( ! $price instanceof EE_Price) {
571 571
             throw new RuntimeException(
572 572
                 sprintf(
573 573
                     esc_html__(
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
     public function _edit_price_details_meta_box(): string
626 626
     {
627 627
         return EEH_Template::display_template(
628
-            PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php',
628
+            PRICING_TEMPLATE_PATH.'pricing_details_main_meta_box.template.php',
629 629
             $this->_template_args,
630 630
             true
631 631
         );
@@ -792,19 +792,19 @@  discard block
 block discarded – undo
792 792
         string $action,
793 793
         int $result
794 794
     ) {
795
-        if (! $entity_ID || (float) $result < 1) {
795
+        if ( ! $entity_ID || (float) $result < 1) {
796 796
             return;
797 797
         }
798 798
 
799 799
         $entity = $entity_model->get_one_by_ID($entity_ID);
800
-        if (! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) {
800
+        if ( ! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) {
801 801
             return;
802 802
         }
803 803
 
804 804
         // get default tickets for updating
805 805
         $default_tickets = EEM_Ticket::instance()->get_all_default_tickets();
806 806
         foreach ($default_tickets as $default_ticket) {
807
-            if (! $default_ticket instanceof EE_Ticket) {
807
+            if ( ! $default_ticket instanceof EE_Ticket) {
808 808
                 continue;
809 809
             }
810 810
             switch ($action) {
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
      */
888 888
     protected function _price_types_overview_list_table()
889 889
     {
890
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
890
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
891 891
             'add_new_price_type',
892 892
             'add_type',
893 893
             [],
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
     public function get_price_types_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
913 913
     {
914 914
         // start with an empty array
915
-        require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php');
915
+        require_once(PRICING_ADMIN.'Price_Types_List_Table.class.php');
916 916
 
917 917
         $orderby = $this->request->getRequestParam('orderby', '');
918 918
         $order   = $this->request->getRequestParam('order', 'ASC');
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
                 $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
974 974
         }
975 975
         // add PRT_ID to title if editing
976
-        $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title;
976
+        $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title.' # '.$PRT_ID : $this->_admin_page_title;
977 977
 
978 978
         if ($PRT_ID) {
979 979
             $price_type               = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
             $this->_set_add_edit_form_tags('insert_price_type');
985 985
         }
986 986
 
987
-        if (! $price_type instanceof EE_Price_Type) {
987
+        if ( ! $price_type instanceof EE_Price_Type) {
988 988
             throw new RuntimeException(
989 989
                 sprintf(
990 990
                     esc_html__(
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
     public function _edit_price_type_details_meta_box(): string
1035 1035
     {
1036 1036
         return EEH_Template::display_template(
1037
-            PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php',
1037
+            PRICING_TEMPLATE_PATH.'pricing_type_details_main_meta_box.template.php',
1038 1038
             $this->_template_args,
1039 1039
             true
1040 1040
         );
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
      */
1047 1047
     protected function set_price_type_column_values(): array
1048 1048
     {
1049
-        $base_type  = $this->request->getRequestParam(
1049
+        $base_type = $this->request->getRequestParam(
1050 1050
             'base_type',
1051 1051
             EEM_Price_Type::base_type_base_price,
1052 1052
             DataType::INTEGER
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
     {
1173 1173
         return '
1174 1174
             <a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >
1175
-                ' . esc_html__('learn more about how pricing works', 'event_espresso') . '
1175
+                ' . esc_html__('learn more about how pricing works', 'event_espresso').'
1176 1176
             </a>';
1177 1177
     }
1178 1178
 
@@ -1248,7 +1248,7 @@  discard block
 block discarded – undo
1248 1248
     public function _update_tax_settings()
1249 1249
     {
1250 1250
         $tax_settings = EE_Config::instance()->tax_settings;
1251
-        if (! $tax_settings instanceof EE_Tax_Config) {
1251
+        if ( ! $tax_settings instanceof EE_Tax_Config) {
1252 1252
             $tax_settings = new EE_Tax_Config();
1253 1253
         }
1254 1254
         try {
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 2 patches
Indentation   +1414 added lines, -1414 removed lines patch added patch discarded remove patch
@@ -19,1431 +19,1431 @@
 block discarded – undo
19 19
  */
20 20
 class General_Settings_Admin_Page extends EE_Admin_Page
21 21
 {
22
-    /**
23
-     * @var EE_Core_Config
24
-     */
25
-    public $core_config;
26
-
27
-
28
-    /**
29
-     * Initialize basic properties.
30
-     */
31
-    protected function _init_page_props()
32
-    {
33
-        $this->page_slug        = GEN_SET_PG_SLUG;
34
-        $this->page_label       = GEN_SET_LABEL;
35
-        $this->_admin_base_url  = GEN_SET_ADMIN_URL;
36
-        $this->_admin_base_path = GEN_SET_ADMIN;
37
-    }
38
-
39
-
40
-    /**
41
-     * Set ajax hooks
42
-     */
43
-    protected function _ajax_hooks()
44
-    {
45
-        add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
46
-        add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
47
-        add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
48
-        add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
49
-    }
50
-
51
-
52
-    /**
53
-     * More page properties initialization.
54
-     */
55
-    protected function _define_page_props()
56
-    {
57
-        $this->_admin_page_title = GEN_SET_LABEL;
58
-        $this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
59
-    }
60
-
61
-
62
-    /**
63
-     * Set page routes property.
64
-     */
65
-    protected function _set_page_routes()
66
-    {
67
-        $this->_page_routes = [
68
-            'critical_pages'                => [
69
-                'func'       => '_espresso_page_settings',
70
-                'capability' => 'manage_options',
71
-            ],
72
-            'update_espresso_page_settings' => [
73
-                'func'       => '_update_espresso_page_settings',
74
-                'capability' => 'manage_options',
75
-                'noheader'   => true,
76
-            ],
77
-            'default'                       => [
78
-                'func'       => '_your_organization_settings',
79
-                'capability' => 'manage_options',
80
-            ],
81
-
82
-            'update_your_organization_settings' => [
83
-                'func'       => '_update_your_organization_settings',
84
-                'capability' => 'manage_options',
85
-                'noheader'   => true,
86
-            ],
87
-
88
-            'admin_option_settings' => [
89
-                'func'       => '_admin_option_settings',
90
-                'capability' => 'manage_options',
91
-            ],
92
-
93
-            'update_admin_option_settings' => [
94
-                'func'       => '_update_admin_option_settings',
95
-                'capability' => 'manage_options',
96
-                'noheader'   => true,
97
-            ],
98
-
99
-            'country_settings' => [
100
-                'func'       => '_country_settings',
101
-                'capability' => 'manage_options',
102
-            ],
103
-
104
-            'update_country_settings' => [
105
-                'func'       => '_update_country_settings',
106
-                'capability' => 'manage_options',
107
-                'noheader'   => true,
108
-            ],
109
-
110
-            'display_country_settings' => [
111
-                'func'       => 'display_country_settings',
112
-                'capability' => 'manage_options',
113
-                'noheader'   => true,
114
-            ],
115
-
116
-            'add_new_state' => [
117
-                'func'       => 'add_new_state',
118
-                'capability' => 'manage_options',
119
-                'noheader'   => true,
120
-            ],
121
-
122
-            'delete_state'            => [
123
-                'func'       => 'delete_state',
124
-                'capability' => 'manage_options',
125
-                'noheader'   => true,
126
-            ],
127
-            'privacy_settings'        => [
128
-                'func'       => 'privacySettings',
129
-                'capability' => 'manage_options',
130
-            ],
131
-            'update_privacy_settings' => [
132
-                'func'               => 'updatePrivacySettings',
133
-                'capability'         => 'manage_options',
134
-                'noheader'           => true,
135
-                'headers_sent_route' => 'privacy_settings',
136
-            ],
137
-        ];
138
-    }
139
-
140
-
141
-    /**
142
-     * Set page configuration property
143
-     */
144
-    protected function _set_page_config()
145
-    {
146
-        $this->_page_config = [
147
-            'critical_pages'        => [
148
-                'nav'           => [
149
-                    'label' => esc_html__('Critical Pages', 'event_espresso'),
150
-                    'order' => 50,
151
-                ],
152
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
153
-                'help_tabs'     => [
154
-                    'general_settings_critical_pages_help_tab' => [
155
-                        'title'    => esc_html__('Critical Pages', 'event_espresso'),
156
-                        'filename' => 'general_settings_critical_pages',
157
-                    ],
158
-                ],
159
-                'require_nonce' => false,
160
-            ],
161
-            'default'               => [
162
-                'nav'           => [
163
-                    'label' => esc_html__('Your Organization', 'event_espresso'),
164
-                    'order' => 20,
165
-                ],
166
-                'help_tabs'     => [
167
-                    'general_settings_your_organization_help_tab' => [
168
-                        'title'    => esc_html__('Your Organization', 'event_espresso'),
169
-                        'filename' => 'general_settings_your_organization',
170
-                    ],
171
-                ],
172
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
173
-                'require_nonce' => false,
174
-            ],
175
-            'admin_option_settings' => [
176
-                'nav'           => [
177
-                    'label' => esc_html__('Admin Options', 'event_espresso'),
178
-                    'order' => 60,
179
-                ],
180
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
181
-                'help_tabs'     => [
182
-                    'general_settings_admin_options_help_tab' => [
183
-                        'title'    => esc_html__('Admin Options', 'event_espresso'),
184
-                        'filename' => 'general_settings_admin_options',
185
-                    ],
186
-                ],
187
-                'require_nonce' => false,
188
-            ],
189
-            'country_settings'      => [
190
-                'nav'           => [
191
-                    'label' => esc_html__('Countries', 'event_espresso'),
192
-                    'order' => 70,
193
-                ],
194
-                'help_tabs'     => [
195
-                    'general_settings_countries_help_tab' => [
196
-                        'title'    => esc_html__('Countries', 'event_espresso'),
197
-                        'filename' => 'general_settings_countries',
198
-                    ],
199
-                ],
200
-                'require_nonce' => false,
201
-            ],
202
-            'privacy_settings'      => [
203
-                'nav'           => [
204
-                    'label' => esc_html__('Privacy', 'event_espresso'),
205
-                    'order' => 80,
206
-                ],
207
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
208
-                'require_nonce' => false,
209
-            ],
210
-        ];
211
-    }
212
-
213
-
214
-    protected function _add_screen_options()
215
-    {
216
-    }
217
-
218
-
219
-    protected function _add_feature_pointers()
220
-    {
221
-    }
222
-
223
-
224
-    /**
225
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
226
-     */
227
-    public function load_scripts_styles()
228
-    {
229
-        // styles
230
-        wp_enqueue_style('espresso-ui-theme');
231
-        // scripts
232
-        wp_enqueue_script('ee_admin_js');
233
-    }
234
-
235
-
236
-    /**
237
-     * Execute logic running on `admin_init`
238
-     */
239
-    public function admin_init()
240
-    {
241
-        $this->core_config = EE_Registry::instance()->CFG->core;
242
-
243
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
244
-            esc_html__(
245
-                'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
246
-                'event_espresso'
247
-            )
248
-        );
249
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
250
-            esc_html__(
251
-                'An error occurred! Please refresh the page and try again.',
252
-                'event_espresso'
253
-            )
254
-        );
255
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
256
-            esc_html__(
257
-                'Are you sure you want to delete this State / Province?',
258
-                'event_espresso'
259
-            )
260
-        );
261
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
262
-            'admin-ajax.php?page=espresso_general_settings',
263
-            is_ssl() ? 'https://' : 'http://'
264
-        );
265
-    }
266
-
267
-
268
-    public function admin_notices()
269
-    {
270
-    }
271
-
272
-
273
-    public function admin_footer_scripts()
274
-    {
275
-    }
276
-
277
-
278
-    /**
279
-     * Enqueue scripts and styles for the default route.
280
-     */
281
-    public function load_scripts_styles_default()
282
-    {
283
-        // styles
284
-        wp_enqueue_style('thickbox');
285
-        // scripts
286
-        wp_enqueue_script('media-upload');
287
-        wp_enqueue_script('thickbox');
288
-        wp_register_script(
289
-            'organization_settings',
290
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
291
-            ['jquery', 'media-upload', 'thickbox'],
292
-            EVENT_ESPRESSO_VERSION,
293
-            true
294
-        );
295
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
296
-        wp_enqueue_script('organization_settings');
297
-        wp_enqueue_style('organization-css');
298
-        $confirm_image_delete = [
299
-            'text' => wp_strip_all_tags(
300
-                esc_html__(
301
-                    'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
302
-                    'event_espresso'
303
-                )
304
-            ),
305
-        ];
306
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
307
-    }
308
-
309
-
310
-    /**
311
-     * Enqueue scripts and styles for the country settings route.
312
-     */
313
-    public function load_scripts_styles_country_settings()
314
-    {
315
-        // scripts
316
-        wp_register_script(
317
-            'gen_settings_countries',
318
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
319
-            ['ee_admin_js'],
320
-            EVENT_ESPRESSO_VERSION,
321
-            true
322
-        );
323
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
324
-        wp_enqueue_script('gen_settings_countries');
325
-        wp_enqueue_style('organization-css');
326
-    }
327
-
328
-
329
-    /*************        Espresso Pages        *************/
330
-    /**
331
-     * _espresso_page_settings
332
-     *
333
-     * @throws EE_Error
334
-     * @throws DomainException
335
-     * @throws DomainException
336
-     * @throws InvalidDataTypeException
337
-     * @throws InvalidArgumentException
338
-     */
339
-    protected function _espresso_page_settings()
340
-    {
341
-        // Check to make sure all of the main pages are set up properly,
342
-        // if not create the default pages and display an admin notice
343
-        EEH_Activation::verify_default_pages_exist();
344
-        $this->_transient_garbage_collection();
345
-
346
-        $this->_template_args['values'] = $this->_yes_no_values;
347
-
348
-        $this->_template_args['reg_page_id']  = $this->core_config->reg_page_id ?? null;
349
-        $this->_template_args['reg_page_obj'] = isset($this->core_config->reg_page_id)
350
-            ? get_post($this->core_config->reg_page_id)
351
-            : false;
352
-
353
-        $this->_template_args['txn_page_id']  = $this->core_config->txn_page_id ?? null;
354
-        $this->_template_args['txn_page_obj'] = isset($this->core_config->txn_page_id)
355
-            ? get_post($this->core_config->txn_page_id)
356
-            : false;
357
-
358
-        $this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
359
-        $this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
360
-            ? get_post($this->core_config->thank_you_page_id)
361
-            : false;
362
-
363
-        $this->_template_args['cancel_page_id']  = $this->core_config->cancel_page_id ?? null;
364
-        $this->_template_args['cancel_page_obj'] = isset($this->core_config->cancel_page_id)
365
-            ? get_post($this->core_config->cancel_page_id)
366
-            : false;
367
-
368
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
369
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
370
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
371
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
372
-            $this->_template_args,
373
-            true
374
-        );
375
-        $this->display_admin_page_with_sidebar();
376
-    }
377
-
378
-
379
-    /**
380
-     * Handler for updating espresso page settings.
381
-     *
382
-     * @throws EE_Error
383
-     */
384
-    protected function _update_espresso_page_settings()
385
-    {
386
-        $this->core_config = EE_Registry::instance()->CFG->core;
387
-        // capture incoming request data && set page IDs
388
-        $this->core_config->reg_page_id       = $this->request->getRequestParam(
389
-            'reg_page_id',
390
-            $this->core_config->reg_page_id,
391
-            DataType::INT
392
-        );
393
-        $this->core_config->txn_page_id       = $this->request->getRequestParam(
394
-            'txn_page_id',
395
-            $this->core_config->txn_page_id,
396
-            DataType::INT
397
-        );
398
-        $this->core_config->thank_you_page_id = $this->request->getRequestParam(
399
-            'thank_you_page_id',
400
-            $this->core_config->thank_you_page_id,
401
-            DataType::INT
402
-        );
403
-        $this->core_config->cancel_page_id    = $this->request->getRequestParam(
404
-            'cancel_page_id',
405
-            $this->core_config->cancel_page_id,
406
-            DataType::INT
407
-        );
408
-
409
-        $this->core_config = apply_filters(
410
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
411
-            $this->core_config,
412
-            $this->request->requestParams()
413
-        );
414
-
415
-        $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
416
-        $this->_redirect_after_action(
417
-            $this->_update_espresso_configuration(
418
-                $what,
419
-                $this->core_config,
420
-                __FILE__,
421
-                __FUNCTION__,
422
-                __LINE__
423
-            ),
424
-            $what,
425
-            '',
426
-            [
427
-                'action' => 'critical_pages',
428
-            ],
429
-            true
430
-        );
431
-    }
432
-
433
-
434
-    /*************        Your Organization        *************/
435
-
436
-
437
-    /**
438
-     * @throws DomainException
439
-     * @throws EE_Error
440
-     * @throws InvalidArgumentException
441
-     * @throws InvalidDataTypeException
442
-     * @throws InvalidInterfaceException
443
-     */
444
-    protected function _your_organization_settings()
445
-    {
446
-        $this->_template_args['admin_page_content'] = '';
447
-        try {
448
-            /** @var OrganizationSettings $organization_settings_form */
449
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
450
-
451
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
452
-                $organization_settings_form->display(),
453
-                '',
454
-                'padding'
455
-            );
456
-        } catch (Exception $e) {
457
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
458
-        }
459
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
460
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
461
-        $this->display_admin_page_with_sidebar();
462
-    }
463
-
464
-
465
-    /**
466
-     * Handler for updating organization settings.
467
-     *
468
-     * @throws EE_Error
469
-     */
470
-    protected function _update_your_organization_settings()
471
-    {
472
-        try {
473
-            /** @var OrganizationSettings $organization_settings_form */
474
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
475
-
476
-            $success = $organization_settings_form->process($this->request->requestParams());
477
-
478
-            EE_Registry::instance()->CFG = apply_filters(
479
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
480
-                EE_Registry::instance()->CFG
481
-            );
482
-        } catch (Exception $e) {
483
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
484
-            $success = false;
485
-        }
486
-
487
-        if ($success) {
488
-            $success = $this->_update_espresso_configuration(
489
-                esc_html__('Your Organization Settings', 'event_espresso'),
490
-                EE_Registry::instance()->CFG,
491
-                __FILE__,
492
-                __FUNCTION__,
493
-                __LINE__
494
-            );
495
-        }
496
-
497
-        $this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
498
-    }
499
-
500
-
501
-
502
-    /*************        Admin Options        *************/
503
-
504
-
505
-    /**
506
-     * _admin_option_settings
507
-     *
508
-     * @throws EE_Error
509
-     * @throws LogicException
510
-     */
511
-    protected function _admin_option_settings()
512
-    {
513
-        $this->_template_args['admin_page_content'] = '';
514
-        try {
515
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
516
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
517
-            $this->_template_args['values'] = $this->_yes_no_values;
518
-            // also need to account for the do_action that was in the old template
519
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
520
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
521
-                $admin_options_settings_form->display(),
522
-                '',
523
-                'padding'
524
-            );
525
-        } catch (Exception $e) {
526
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
527
-        }
528
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
529
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
530
-        $this->display_admin_page_with_sidebar();
531
-    }
532
-
533
-
534
-    /**
535
-     * _update_admin_option_settings
536
-     *
537
-     * @throws EE_Error
538
-     * @throws InvalidDataTypeException
539
-     * @throws InvalidFormSubmissionException
540
-     * @throws InvalidArgumentException
541
-     * @throws LogicException
542
-     */
543
-    protected function _update_admin_option_settings()
544
-    {
545
-        try {
546
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
547
-            $admin_options_settings_form->process(
548
-                $this->request->getRequestParam(
549
-                    $admin_options_settings_form->slug(),
550
-                    [],
551
-                    DataType::STRING,
552
-                    true
553
-                )
554
-            );
555
-            EE_Registry::instance()->CFG->admin = apply_filters(
556
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
557
-                EE_Registry::instance()->CFG->admin
558
-            );
559
-        } catch (Exception $e) {
560
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
561
-        }
562
-        $this->_redirect_after_action(
563
-            apply_filters(
564
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
565
-                $this->_update_espresso_configuration(
566
-                    esc_html__('Admin Options', 'event_espresso'),
567
-                    EE_Registry::instance()->CFG->admin,
568
-                    __FILE__,
569
-                    __FUNCTION__,
570
-                    __LINE__
571
-                )
572
-            ),
573
-            esc_html__('Admin Options', 'event_espresso'),
574
-            'updated',
575
-            ['action' => 'admin_option_settings']
576
-        );
577
-    }
578
-
579
-
580
-    /*************        Countries        *************/
581
-
582
-
583
-    /**
584
-     * @param string|null $default
585
-     * @return string
586
-     */
587
-    protected function getCountryISO(?string $default = null): string
588
-    {
589
-        $default = $default ?? $this->getCountryIsoForSite();
590
-        $CNT_ISO = $this->request->getRequestParam('country', $default);
591
-        $CNT_ISO = $this->request->getRequestParam('CNT_ISO', $CNT_ISO);
592
-        return strtoupper($CNT_ISO);
593
-    }
594
-
595
-
596
-    /**
597
-     * @return string
598
-     */
599
-    protected function getCountryIsoForSite(): string
600
-    {
601
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
602
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
603
-            : 'US';
604
-    }
605
-
606
-
607
-    /**
608
-     * @param string          $CNT_ISO
609
-     * @param EE_Country|null $country
610
-     * @return EE_Base_Class|EE_Country
611
-     * @throws EE_Error
612
-     * @throws InvalidArgumentException
613
-     * @throws InvalidDataTypeException
614
-     * @throws InvalidInterfaceException
615
-     * @throws ReflectionException
616
-     */
617
-    protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
618
-    {
619
-        /** @var EE_Country $country */
620
-        return $country instanceof EE_Country && $country->ID() === $CNT_ISO
621
-            ? $country
622
-            : EEM_Country::instance()->get_one_by_ID($CNT_ISO);
623
-    }
624
-
625
-
626
-    /**
627
-     * Output Country Settings view.
628
-     *
629
-     * @throws DomainException
630
-     * @throws EE_Error
631
-     * @throws InvalidArgumentException
632
-     * @throws InvalidDataTypeException
633
-     * @throws InvalidInterfaceException
634
-     * @throws ReflectionException
635
-     */
636
-    protected function _country_settings()
637
-    {
638
-        $CNT_ISO = $this->getCountryISO();
639
-
640
-        $this->_template_args['values']    = $this->_yes_no_values;
641
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
642
-            EE_Question::new_instance(
643
-                [
644
-                  'QST_ID'           => 0,
645
-                  'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
646
-                  'QST_system'       => 'admin-country',
647
-                ]
648
-            ),
649
-            EE_Answer::new_instance(
650
-                [
651
-                    'ANS_ID'    => 0,
652
-                    'ANS_value' => $CNT_ISO,
653
-                ]
654
-            ),
655
-            [
656
-                'input_id'       => 'country',
657
-                'input_name'     => 'country',
658
-                'input_prefix'   => '',
659
-                'append_qstn_id' => false,
660
-            ]
661
-        );
662
-
663
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
664
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
665
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
666
-        $this->_template_args['country_details_settings'] = $this->display_country_settings(
667
-            $country->ID(),
668
-            $country
669
-        );
670
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
671
-            $country->ID(),
672
-            $country
673
-        );
674
-        $this->_template_args['CNT_name_for_site']        = $country->name();
675
-
676
-        $this->_set_add_edit_form_tags('update_country_settings');
677
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
678
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
679
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
680
-            $this->_template_args,
681
-            true
682
-        );
683
-        $this->display_admin_page_with_no_sidebar();
684
-    }
685
-
686
-
687
-    /**
688
-     * @param string          $CNT_ISO
689
-     * @param EE_Country|null $country
690
-     * @return string
691
-     * @throws DomainException
692
-     * @throws EE_Error
693
-     * @throws InvalidArgumentException
694
-     * @throws InvalidDataTypeException
695
-     * @throws InvalidInterfaceException
696
-     * @throws ReflectionException
697
-     */
698
-    public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
699
-    {
700
-        $CNT_ISO          = $this->getCountryISO($CNT_ISO);
701
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
702
-
703
-        if (! $CNT_ISO) {
704
-            return '';
705
-        }
706
-
707
-        // for ajax
708
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
709
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
710
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
711
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
712
-        $country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
713
-        $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
714
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
715
-
716
-        $country_input_types            = [
717
-            'CNT_active'      => [
718
-                'type'             => 'RADIO_BTN',
719
-                'input_name'       => "cntry[$CNT_ISO]",
720
-                'class'            => '',
721
-                'options'          => $this->_yes_no_values,
722
-                'use_desc_4_label' => true,
723
-            ],
724
-            'CNT_ISO'         => [
725
-                'type'       => 'TEXT',
726
-                'input_name' => "cntry[$CNT_ISO]",
727
-                'class'      => 'ee-input-width--small',
728
-            ],
729
-            'CNT_ISO3'        => [
730
-                'type'       => 'TEXT',
731
-                'input_name' => "cntry[$CNT_ISO]",
732
-                'class'      => 'ee-input-width--small',
733
-            ],
734
-            // 'RGN_ID'          => [
735
-            //     'type'       => 'TEXT',
736
-            //     'input_name' => "cntry[$CNT_ISO]",
737
-            //     'class'      => 'ee-input-width--small',
738
-            // ],
739
-            'CNT_name'        => [
740
-                'type'       => 'TEXT',
741
-                'input_name' => "cntry[$CNT_ISO]",
742
-                'class'      => 'ee-input-width--big',
743
-            ],
744
-            'CNT_cur_code'    => [
745
-                'type'       => 'TEXT',
746
-                'input_name' => "cntry[$CNT_ISO]",
747
-                'class'      => 'ee-input-width--small',
748
-                'disabled'   => $CNT_cur_disabled,
749
-            ],
750
-            'CNT_cur_single'  => [
751
-                'type'       => 'TEXT',
752
-                'input_name' => "cntry[$CNT_ISO]",
753
-                'class'      => 'ee-input-width--reg',
754
-                'disabled'   => $CNT_cur_disabled,
755
-            ],
756
-            'CNT_cur_plural'  => [
757
-                'type'       => 'TEXT',
758
-                'input_name' => "cntry[$CNT_ISO]",
759
-                'class'      => 'ee-input-width--reg',
760
-                'disabled'   => $CNT_cur_disabled,
761
-            ],
762
-            'CNT_cur_sign'    => [
763
-                'type'         => 'TEXT',
764
-                'input_name'   => "cntry[$CNT_ISO]",
765
-                'class'        => 'ee-input-width--small',
766
-                'htmlentities' => false,
767
-                'disabled'     => $CNT_cur_disabled,
768
-            ],
769
-            'CNT_cur_sign_b4' => [
770
-                'type'             => 'RADIO_BTN',
771
-                'input_name'       => "cntry[$CNT_ISO]",
772
-                'class'            => '',
773
-                'options'          => $this->_yes_no_values,
774
-                'use_desc_4_label' => true,
775
-                'disabled'         => $CNT_cur_disabled,
776
-            ],
777
-            'CNT_cur_dec_plc' => [
778
-                'type'       => 'RADIO_BTN',
779
-                'input_name' => "cntry[$CNT_ISO]",
780
-                'class'      => '',
781
-                'options'    => [
782
-                    ['id' => 0, 'text' => ''],
783
-                    ['id' => 1, 'text' => ''],
784
-                    ['id' => 2, 'text' => ''],
785
-                    ['id' => 3, 'text' => ''],
786
-                ],
787
-                'disabled'   => $CNT_cur_disabled,
788
-            ],
789
-            'CNT_cur_dec_mrk' => [
790
-                'type'             => 'RADIO_BTN',
791
-                'input_name'       => "cntry[$CNT_ISO]",
792
-                'class'            => '',
793
-                'options'          => [
794
-                    [
795
-                        'id'   => ',',
796
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
797
-                    ],
798
-                    ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
799
-                ],
800
-                'use_desc_4_label' => true,
801
-                'disabled'         => $CNT_cur_disabled,
802
-            ],
803
-            'CNT_cur_thsnds'  => [
804
-                'type'             => 'RADIO_BTN',
805
-                'input_name'       => "cntry[$CNT_ISO]",
806
-                'class'            => '',
807
-                'options'          => [
808
-                    [
809
-                        'id'   => ',',
810
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
811
-                    ],
812
-                    [
813
-                        'id'   => '.',
814
-                        'text' => esc_html__('. (decimal)', 'event_espresso'),
815
-                    ],
816
-                    [
817
-                        'id'   => '&nbsp;',
818
-                        'text' => esc_html__('(space)', 'event_espresso'),
819
-                    ],
820
-                ],
821
-                'use_desc_4_label' => true,
822
-                'disabled'         => $CNT_cur_disabled,
823
-            ],
824
-            'CNT_tel_code'    => [
825
-                'type'       => 'TEXT',
826
-                'input_name' => "cntry[$CNT_ISO]",
827
-                'class'      => 'ee-input-width--small',
828
-            ],
829
-            'CNT_is_EU'       => [
830
-                'type'             => 'RADIO_BTN',
831
-                'input_name'       => "cntry[$CNT_ISO]",
832
-                'class'            => '',
833
-                'options'          => $this->_yes_no_values,
834
-                'use_desc_4_label' => true,
835
-            ],
836
-        ];
837
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
838
-            $country,
839
-            $country_input_types
840
-        );
841
-        $country_details_settings       = EEH_Template::display_template(
842
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
843
-            $this->_template_args,
844
-            true
845
-        );
846
-
847
-        if (defined('DOING_AJAX')) {
848
-            $notices = EE_Error::get_notices(false, false, false);
849
-            echo wp_json_encode(
850
-                [
851
-                    'return_data' => $country_details_settings,
852
-                    'success'     => $notices['success'],
853
-                    'errors'      => $notices['errors'],
854
-                ]
855
-            );
856
-            die();
857
-        }
858
-        return $country_details_settings;
859
-    }
860
-
861
-
862
-    /**
863
-     * @param string          $CNT_ISO
864
-     * @param EE_Country|null $country
865
-     * @return string
866
-     * @throws DomainException
867
-     * @throws EE_Error
868
-     * @throws InvalidArgumentException
869
-     * @throws InvalidDataTypeException
870
-     * @throws InvalidInterfaceException
871
-     * @throws ReflectionException
872
-     */
873
-    public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
874
-    {
875
-        $CNT_ISO = $this->getCountryISO($CNT_ISO);
876
-        if (! $CNT_ISO) {
877
-            return '';
878
-        }
879
-        // for ajax
880
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
881
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
882
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
883
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
884
-        $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
885
-        if (empty($states)) {
886
-            /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
887
-            $countrySubRegionDao = $this->loader->getShared(
888
-                'EventEspresso\core\services\address\CountrySubRegionDao'
889
-            );
890
-            if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
891
-                $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
892
-                if ($countrySubRegionDao->saveCountrySubRegions($country)) {
893
-                    $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
894
-                }
895
-            }
896
-        }
897
-        if (is_array($states)) {
898
-            foreach ($states as $STA_ID => $state) {
899
-                if ($state instanceof EE_State) {
900
-                    $inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
901
-                        $state,
902
-                        [
903
-                            'STA_abbrev' => [
904
-                                'type'             => 'TEXT',
905
-                                'label'            => esc_html__('Code', 'event_espresso'),
906
-                                'input_name'       => "states[$STA_ID]",
907
-                                'class'            => 'ee-input-width--tiny',
908
-                                'add_mobile_label' => true,
909
-                            ],
910
-                            'STA_name'   => [
911
-                                'type'             => 'TEXT',
912
-                                'label'            => esc_html__('Name', 'event_espresso'),
913
-                                'input_name'       => "states[$STA_ID]",
914
-                                'class'            => 'ee-input-width--big',
915
-                                'add_mobile_label' => true,
916
-                            ],
917
-                            'STA_active' => [
918
-                                'type'             => 'RADIO_BTN',
919
-                                'label'            => esc_html__(
920
-                                    'State Appears in Dropdown Select Lists',
921
-                                    'event_espresso'
922
-                                ),
923
-                                'input_name'       => "states[$STA_ID]",
924
-                                'options'          => $this->_yes_no_values,
925
-                                'use_desc_4_label' => true,
926
-                                'add_mobile_label' => true,
927
-                            ],
928
-                        ]
929
-                    );
930
-
931
-                    $delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
932
-                        [
933
-                            'action'     => 'delete_state',
934
-                            'STA_ID'     => $STA_ID,
935
-                            'CNT_ISO'    => $CNT_ISO,
936
-                            'STA_abbrev' => $state->abbrev(),
937
-                        ],
938
-                        GEN_SET_ADMIN_URL
939
-                    );
940
-
941
-                    $this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
942
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
943
-                }
944
-            }
945
-        } else {
946
-            $this->_template_args['states'] = false;
947
-        }
948
-
949
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
950
-            ['action' => 'add_new_state'],
951
-            GEN_SET_ADMIN_URL
952
-        );
953
-
954
-        $state_details_settings = EEH_Template::display_template(
955
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
956
-            $this->_template_args,
957
-            true
958
-        );
959
-
960
-        if (defined('DOING_AJAX')) {
961
-            $notices = EE_Error::get_notices(false, false, false);
962
-            echo wp_json_encode(
963
-                [
964
-                    'return_data' => $state_details_settings,
965
-                    'success'     => $notices['success'],
966
-                    'errors'      => $notices['errors'],
967
-                ]
968
-            );
969
-            die();
970
-        }
971
-        return $state_details_settings;
972
-    }
973
-
974
-
975
-    /**
976
-     * @return void
977
-     * @throws EE_Error
978
-     * @throws InvalidArgumentException
979
-     * @throws InvalidDataTypeException
980
-     * @throws InvalidInterfaceException
981
-     * @throws ReflectionException
982
-     */
983
-    public function add_new_state()
984
-    {
985
-        $success = true;
986
-        $CNT_ISO = $this->getCountryISO('');
987
-        if (! $CNT_ISO) {
988
-            EE_Error::add_error(
989
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
990
-                __FILE__,
991
-                __FUNCTION__,
992
-                __LINE__
993
-            );
994
-            $success = false;
995
-        }
996
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
997
-        if (! $STA_abbrev) {
998
-            EE_Error::add_error(
999
-                esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1000
-                __FILE__,
1001
-                __FUNCTION__,
1002
-                __LINE__
1003
-            );
1004
-            $success = false;
1005
-        }
1006
-        $STA_name = $this->request->getRequestParam('STA_name');
1007
-        if (! $STA_name) {
1008
-            EE_Error::add_error(
1009
-                esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1010
-                __FILE__,
1011
-                __FUNCTION__,
1012
-                __LINE__
1013
-            );
1014
-            $success = false;
1015
-        }
1016
-
1017
-        if ($success) {
1018
-            $cols_n_values = [
1019
-                'CNT_ISO'    => $CNT_ISO,
1020
-                'STA_abbrev' => $STA_abbrev,
1021
-                'STA_name'   => $STA_name,
1022
-                'STA_active' => true,
1023
-            ];
1024
-            $success       = EEM_State::instance()->insert($cols_n_values);
1025
-            EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1026
-        }
1027
-
1028
-        if (defined('DOING_AJAX')) {
1029
-            $notices = EE_Error::get_notices(false, false, false);
1030
-            echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1031
-            die();
1032
-        }
1033
-        $this->_redirect_after_action(
1034
-            $success,
1035
-            esc_html__('State', 'event_espresso'),
1036
-            'added',
1037
-            ['action' => 'country_settings']
1038
-        );
1039
-    }
1040
-
1041
-
1042
-    /**
1043
-     * @return void
1044
-     * @throws EE_Error
1045
-     * @throws InvalidArgumentException
1046
-     * @throws InvalidDataTypeException
1047
-     * @throws InvalidInterfaceException
1048
-     * @throws ReflectionException
1049
-     */
1050
-    public function delete_state()
1051
-    {
1052
-        $CNT_ISO    = $this->getCountryISO();
1053
-        $STA_ID     = $this->request->getRequestParam('STA_ID');
1054
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1055
-
1056
-        if (! $STA_ID) {
1057
-            EE_Error::add_error(
1058
-                esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1059
-                __FILE__,
1060
-                __FUNCTION__,
1061
-                __LINE__
1062
-            );
1063
-            return;
1064
-        }
1065
-
1066
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1067
-        if ($success !== false) {
1068
-            do_action(
1069
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1070
-                $CNT_ISO,
1071
-                $STA_ID,
1072
-                ['STA_abbrev' => $STA_abbrev]
1073
-            );
1074
-            EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1075
-        }
1076
-        if (defined('DOING_AJAX')) {
1077
-            $notices                = EE_Error::get_notices(false);
1078
-            $notices['return_data'] = true;
1079
-            echo wp_json_encode($notices);
1080
-            die();
1081
-        }
1082
-        $this->_redirect_after_action(
1083
-            $success,
1084
-            esc_html__('State', 'event_espresso'),
1085
-            'deleted',
1086
-            ['action' => 'country_settings']
1087
-        );
1088
-    }
1089
-
1090
-
1091
-    /**
1092
-     * @return void
1093
-     * @throws EE_Error
1094
-     * @throws InvalidArgumentException
1095
-     * @throws InvalidDataTypeException
1096
-     * @throws InvalidInterfaceException
1097
-     * @throws ReflectionException
1098
-     */
1099
-    protected function _update_country_settings()
1100
-    {
1101
-        $CNT_ISO = $this->getCountryISO();
1102
-        if (! $CNT_ISO) {
1103
-            EE_Error::add_error(
1104
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1105
-                __FILE__,
1106
-                __FUNCTION__,
1107
-                __LINE__
1108
-            );
1109
-            return;
1110
-        }
1111
-
1112
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1113
-
1114
-        $cols_n_values                    = [];
1115
-        $cols_n_values['CNT_ISO3']        = strtoupper(
1116
-            $this->request->getRequestParam('cntry', '', $country->ISO3())
1117
-        );
1118
-        $cols_n_values['CNT_name']        = $this->request->getRequestParam(
1119
-            "cntry[$CNT_ISO][CNT_name]",
1120
-            $country->name()
1121
-        );
1122
-        $cols_n_values['CNT_cur_code']    = strtoupper(
1123
-            $this->request->getRequestParam(
1124
-                "cntry[$CNT_ISO][CNT_cur_code]",
1125
-                $country->currency_code()
1126
-            )
1127
-        );
1128
-        $cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1129
-            "cntry[$CNT_ISO][CNT_cur_single]",
1130
-            $country->currency_name_single()
1131
-        );
1132
-        $cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1133
-            "cntry[$CNT_ISO][CNT_cur_plural]",
1134
-            $country->currency_name_plural()
1135
-        );
1136
-        $cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1137
-            "cntry[$CNT_ISO][CNT_cur_sign]",
1138
-            $country->currency_sign()
1139
-        );
1140
-        $cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1141
-            "cntry[$CNT_ISO][CNT_cur_sign_b4]",
1142
-            $country->currency_sign_before(),
1143
-            DataType::BOOL
1144
-        );
1145
-        $cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1146
-            "cntry[$CNT_ISO][CNT_cur_dec_plc]",
1147
-            $country->currency_decimal_places()
1148
-        );
1149
-        $cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1150
-            "cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1151
-            $country->currency_decimal_mark()
1152
-        );
1153
-        $cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1154
-            "cntry[$CNT_ISO][CNT_cur_thsnds]",
1155
-            $country->currency_thousands_separator()
1156
-        );
1157
-        $cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1158
-            "cntry[$CNT_ISO][CNT_tel_code]",
1159
-            $country->telephoneCode()
1160
-        );
1161
-        $cols_n_values['CNT_active']      = $this->request->getRequestParam(
1162
-            "cntry[$CNT_ISO][CNT_active]",
1163
-            $country->isActive(),
1164
-            DataType::BOOL
1165
-        );
1166
-
1167
-        // allow filtering of country data
1168
-        $cols_n_values = apply_filters(
1169
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1170
-            $cols_n_values
1171
-        );
1172
-
1173
-        // where values
1174
-        $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1175
-        // run the update
1176
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1177
-
1178
-        // allow filtering of states data
1179
-        $states = apply_filters(
1180
-            'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1181
-            $this->request->getRequestParam('states', [], DataType::STRING, true)
1182
-        );
1183
-
1184
-        if (! empty($states) && $success !== false) {
1185
-            // loop thru state data ( looks like : states[75][STA_name] )
1186
-            foreach ($states as $STA_ID => $state) {
1187
-                $cols_n_values = [
1188
-                    'CNT_ISO'    => $CNT_ISO,
1189
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1190
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1191
-                    'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1192
-                ];
1193
-                // where values
1194
-                $where_cols_n_values = [['STA_ID' => $STA_ID]];
1195
-                // run the update
1196
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1197
-                if ($success !== false) {
1198
-                    do_action(
1199
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1200
-                        $CNT_ISO,
1201
-                        $STA_ID,
1202
-                        $cols_n_values
1203
-                    );
1204
-                }
1205
-            }
1206
-        }
1207
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1208
-        if (
1209
-            isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1210
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1211
-        ) {
1212
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1213
-            EE_Registry::instance()->CFG->update_espresso_config();
1214
-        }
1215
-
1216
-        if ($success !== false) {
1217
-            EE_Error::add_success(
1218
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1219
-            );
1220
-        }
1221
-        $this->_redirect_after_action(
1222
-            $success,
1223
-            '',
1224
-            '',
1225
-            ['action' => 'country_settings', 'country' => $CNT_ISO],
1226
-            true
1227
-        );
1228
-    }
1229
-
1230
-
1231
-    /**
1232
-     * form_form_field_label_wrap
1233
-     *
1234
-     * @param string $label
1235
-     * @return string
1236
-     */
1237
-    public function country_form_field_label_wrap(string $label): string
1238
-    {
1239
-        return '
22
+	/**
23
+	 * @var EE_Core_Config
24
+	 */
25
+	public $core_config;
26
+
27
+
28
+	/**
29
+	 * Initialize basic properties.
30
+	 */
31
+	protected function _init_page_props()
32
+	{
33
+		$this->page_slug        = GEN_SET_PG_SLUG;
34
+		$this->page_label       = GEN_SET_LABEL;
35
+		$this->_admin_base_url  = GEN_SET_ADMIN_URL;
36
+		$this->_admin_base_path = GEN_SET_ADMIN;
37
+	}
38
+
39
+
40
+	/**
41
+	 * Set ajax hooks
42
+	 */
43
+	protected function _ajax_hooks()
44
+	{
45
+		add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
46
+		add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
47
+		add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
48
+		add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
49
+	}
50
+
51
+
52
+	/**
53
+	 * More page properties initialization.
54
+	 */
55
+	protected function _define_page_props()
56
+	{
57
+		$this->_admin_page_title = GEN_SET_LABEL;
58
+		$this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
59
+	}
60
+
61
+
62
+	/**
63
+	 * Set page routes property.
64
+	 */
65
+	protected function _set_page_routes()
66
+	{
67
+		$this->_page_routes = [
68
+			'critical_pages'                => [
69
+				'func'       => '_espresso_page_settings',
70
+				'capability' => 'manage_options',
71
+			],
72
+			'update_espresso_page_settings' => [
73
+				'func'       => '_update_espresso_page_settings',
74
+				'capability' => 'manage_options',
75
+				'noheader'   => true,
76
+			],
77
+			'default'                       => [
78
+				'func'       => '_your_organization_settings',
79
+				'capability' => 'manage_options',
80
+			],
81
+
82
+			'update_your_organization_settings' => [
83
+				'func'       => '_update_your_organization_settings',
84
+				'capability' => 'manage_options',
85
+				'noheader'   => true,
86
+			],
87
+
88
+			'admin_option_settings' => [
89
+				'func'       => '_admin_option_settings',
90
+				'capability' => 'manage_options',
91
+			],
92
+
93
+			'update_admin_option_settings' => [
94
+				'func'       => '_update_admin_option_settings',
95
+				'capability' => 'manage_options',
96
+				'noheader'   => true,
97
+			],
98
+
99
+			'country_settings' => [
100
+				'func'       => '_country_settings',
101
+				'capability' => 'manage_options',
102
+			],
103
+
104
+			'update_country_settings' => [
105
+				'func'       => '_update_country_settings',
106
+				'capability' => 'manage_options',
107
+				'noheader'   => true,
108
+			],
109
+
110
+			'display_country_settings' => [
111
+				'func'       => 'display_country_settings',
112
+				'capability' => 'manage_options',
113
+				'noheader'   => true,
114
+			],
115
+
116
+			'add_new_state' => [
117
+				'func'       => 'add_new_state',
118
+				'capability' => 'manage_options',
119
+				'noheader'   => true,
120
+			],
121
+
122
+			'delete_state'            => [
123
+				'func'       => 'delete_state',
124
+				'capability' => 'manage_options',
125
+				'noheader'   => true,
126
+			],
127
+			'privacy_settings'        => [
128
+				'func'       => 'privacySettings',
129
+				'capability' => 'manage_options',
130
+			],
131
+			'update_privacy_settings' => [
132
+				'func'               => 'updatePrivacySettings',
133
+				'capability'         => 'manage_options',
134
+				'noheader'           => true,
135
+				'headers_sent_route' => 'privacy_settings',
136
+			],
137
+		];
138
+	}
139
+
140
+
141
+	/**
142
+	 * Set page configuration property
143
+	 */
144
+	protected function _set_page_config()
145
+	{
146
+		$this->_page_config = [
147
+			'critical_pages'        => [
148
+				'nav'           => [
149
+					'label' => esc_html__('Critical Pages', 'event_espresso'),
150
+					'order' => 50,
151
+				],
152
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
153
+				'help_tabs'     => [
154
+					'general_settings_critical_pages_help_tab' => [
155
+						'title'    => esc_html__('Critical Pages', 'event_espresso'),
156
+						'filename' => 'general_settings_critical_pages',
157
+					],
158
+				],
159
+				'require_nonce' => false,
160
+			],
161
+			'default'               => [
162
+				'nav'           => [
163
+					'label' => esc_html__('Your Organization', 'event_espresso'),
164
+					'order' => 20,
165
+				],
166
+				'help_tabs'     => [
167
+					'general_settings_your_organization_help_tab' => [
168
+						'title'    => esc_html__('Your Organization', 'event_espresso'),
169
+						'filename' => 'general_settings_your_organization',
170
+					],
171
+				],
172
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
173
+				'require_nonce' => false,
174
+			],
175
+			'admin_option_settings' => [
176
+				'nav'           => [
177
+					'label' => esc_html__('Admin Options', 'event_espresso'),
178
+					'order' => 60,
179
+				],
180
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
181
+				'help_tabs'     => [
182
+					'general_settings_admin_options_help_tab' => [
183
+						'title'    => esc_html__('Admin Options', 'event_espresso'),
184
+						'filename' => 'general_settings_admin_options',
185
+					],
186
+				],
187
+				'require_nonce' => false,
188
+			],
189
+			'country_settings'      => [
190
+				'nav'           => [
191
+					'label' => esc_html__('Countries', 'event_espresso'),
192
+					'order' => 70,
193
+				],
194
+				'help_tabs'     => [
195
+					'general_settings_countries_help_tab' => [
196
+						'title'    => esc_html__('Countries', 'event_espresso'),
197
+						'filename' => 'general_settings_countries',
198
+					],
199
+				],
200
+				'require_nonce' => false,
201
+			],
202
+			'privacy_settings'      => [
203
+				'nav'           => [
204
+					'label' => esc_html__('Privacy', 'event_espresso'),
205
+					'order' => 80,
206
+				],
207
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
208
+				'require_nonce' => false,
209
+			],
210
+		];
211
+	}
212
+
213
+
214
+	protected function _add_screen_options()
215
+	{
216
+	}
217
+
218
+
219
+	protected function _add_feature_pointers()
220
+	{
221
+	}
222
+
223
+
224
+	/**
225
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
226
+	 */
227
+	public function load_scripts_styles()
228
+	{
229
+		// styles
230
+		wp_enqueue_style('espresso-ui-theme');
231
+		// scripts
232
+		wp_enqueue_script('ee_admin_js');
233
+	}
234
+
235
+
236
+	/**
237
+	 * Execute logic running on `admin_init`
238
+	 */
239
+	public function admin_init()
240
+	{
241
+		$this->core_config = EE_Registry::instance()->CFG->core;
242
+
243
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
244
+			esc_html__(
245
+				'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
246
+				'event_espresso'
247
+			)
248
+		);
249
+		EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
250
+			esc_html__(
251
+				'An error occurred! Please refresh the page and try again.',
252
+				'event_espresso'
253
+			)
254
+		);
255
+		EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
256
+			esc_html__(
257
+				'Are you sure you want to delete this State / Province?',
258
+				'event_espresso'
259
+			)
260
+		);
261
+		EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
262
+			'admin-ajax.php?page=espresso_general_settings',
263
+			is_ssl() ? 'https://' : 'http://'
264
+		);
265
+	}
266
+
267
+
268
+	public function admin_notices()
269
+	{
270
+	}
271
+
272
+
273
+	public function admin_footer_scripts()
274
+	{
275
+	}
276
+
277
+
278
+	/**
279
+	 * Enqueue scripts and styles for the default route.
280
+	 */
281
+	public function load_scripts_styles_default()
282
+	{
283
+		// styles
284
+		wp_enqueue_style('thickbox');
285
+		// scripts
286
+		wp_enqueue_script('media-upload');
287
+		wp_enqueue_script('thickbox');
288
+		wp_register_script(
289
+			'organization_settings',
290
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
291
+			['jquery', 'media-upload', 'thickbox'],
292
+			EVENT_ESPRESSO_VERSION,
293
+			true
294
+		);
295
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
296
+		wp_enqueue_script('organization_settings');
297
+		wp_enqueue_style('organization-css');
298
+		$confirm_image_delete = [
299
+			'text' => wp_strip_all_tags(
300
+				esc_html__(
301
+					'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
302
+					'event_espresso'
303
+				)
304
+			),
305
+		];
306
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
307
+	}
308
+
309
+
310
+	/**
311
+	 * Enqueue scripts and styles for the country settings route.
312
+	 */
313
+	public function load_scripts_styles_country_settings()
314
+	{
315
+		// scripts
316
+		wp_register_script(
317
+			'gen_settings_countries',
318
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
319
+			['ee_admin_js'],
320
+			EVENT_ESPRESSO_VERSION,
321
+			true
322
+		);
323
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
324
+		wp_enqueue_script('gen_settings_countries');
325
+		wp_enqueue_style('organization-css');
326
+	}
327
+
328
+
329
+	/*************        Espresso Pages        *************/
330
+	/**
331
+	 * _espresso_page_settings
332
+	 *
333
+	 * @throws EE_Error
334
+	 * @throws DomainException
335
+	 * @throws DomainException
336
+	 * @throws InvalidDataTypeException
337
+	 * @throws InvalidArgumentException
338
+	 */
339
+	protected function _espresso_page_settings()
340
+	{
341
+		// Check to make sure all of the main pages are set up properly,
342
+		// if not create the default pages and display an admin notice
343
+		EEH_Activation::verify_default_pages_exist();
344
+		$this->_transient_garbage_collection();
345
+
346
+		$this->_template_args['values'] = $this->_yes_no_values;
347
+
348
+		$this->_template_args['reg_page_id']  = $this->core_config->reg_page_id ?? null;
349
+		$this->_template_args['reg_page_obj'] = isset($this->core_config->reg_page_id)
350
+			? get_post($this->core_config->reg_page_id)
351
+			: false;
352
+
353
+		$this->_template_args['txn_page_id']  = $this->core_config->txn_page_id ?? null;
354
+		$this->_template_args['txn_page_obj'] = isset($this->core_config->txn_page_id)
355
+			? get_post($this->core_config->txn_page_id)
356
+			: false;
357
+
358
+		$this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
359
+		$this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
360
+			? get_post($this->core_config->thank_you_page_id)
361
+			: false;
362
+
363
+		$this->_template_args['cancel_page_id']  = $this->core_config->cancel_page_id ?? null;
364
+		$this->_template_args['cancel_page_obj'] = isset($this->core_config->cancel_page_id)
365
+			? get_post($this->core_config->cancel_page_id)
366
+			: false;
367
+
368
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
369
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
370
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
371
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
372
+			$this->_template_args,
373
+			true
374
+		);
375
+		$this->display_admin_page_with_sidebar();
376
+	}
377
+
378
+
379
+	/**
380
+	 * Handler for updating espresso page settings.
381
+	 *
382
+	 * @throws EE_Error
383
+	 */
384
+	protected function _update_espresso_page_settings()
385
+	{
386
+		$this->core_config = EE_Registry::instance()->CFG->core;
387
+		// capture incoming request data && set page IDs
388
+		$this->core_config->reg_page_id       = $this->request->getRequestParam(
389
+			'reg_page_id',
390
+			$this->core_config->reg_page_id,
391
+			DataType::INT
392
+		);
393
+		$this->core_config->txn_page_id       = $this->request->getRequestParam(
394
+			'txn_page_id',
395
+			$this->core_config->txn_page_id,
396
+			DataType::INT
397
+		);
398
+		$this->core_config->thank_you_page_id = $this->request->getRequestParam(
399
+			'thank_you_page_id',
400
+			$this->core_config->thank_you_page_id,
401
+			DataType::INT
402
+		);
403
+		$this->core_config->cancel_page_id    = $this->request->getRequestParam(
404
+			'cancel_page_id',
405
+			$this->core_config->cancel_page_id,
406
+			DataType::INT
407
+		);
408
+
409
+		$this->core_config = apply_filters(
410
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
411
+			$this->core_config,
412
+			$this->request->requestParams()
413
+		);
414
+
415
+		$what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
416
+		$this->_redirect_after_action(
417
+			$this->_update_espresso_configuration(
418
+				$what,
419
+				$this->core_config,
420
+				__FILE__,
421
+				__FUNCTION__,
422
+				__LINE__
423
+			),
424
+			$what,
425
+			'',
426
+			[
427
+				'action' => 'critical_pages',
428
+			],
429
+			true
430
+		);
431
+	}
432
+
433
+
434
+	/*************        Your Organization        *************/
435
+
436
+
437
+	/**
438
+	 * @throws DomainException
439
+	 * @throws EE_Error
440
+	 * @throws InvalidArgumentException
441
+	 * @throws InvalidDataTypeException
442
+	 * @throws InvalidInterfaceException
443
+	 */
444
+	protected function _your_organization_settings()
445
+	{
446
+		$this->_template_args['admin_page_content'] = '';
447
+		try {
448
+			/** @var OrganizationSettings $organization_settings_form */
449
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
450
+
451
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
452
+				$organization_settings_form->display(),
453
+				'',
454
+				'padding'
455
+			);
456
+		} catch (Exception $e) {
457
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
458
+		}
459
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
460
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
461
+		$this->display_admin_page_with_sidebar();
462
+	}
463
+
464
+
465
+	/**
466
+	 * Handler for updating organization settings.
467
+	 *
468
+	 * @throws EE_Error
469
+	 */
470
+	protected function _update_your_organization_settings()
471
+	{
472
+		try {
473
+			/** @var OrganizationSettings $organization_settings_form */
474
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
475
+
476
+			$success = $organization_settings_form->process($this->request->requestParams());
477
+
478
+			EE_Registry::instance()->CFG = apply_filters(
479
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
480
+				EE_Registry::instance()->CFG
481
+			);
482
+		} catch (Exception $e) {
483
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
484
+			$success = false;
485
+		}
486
+
487
+		if ($success) {
488
+			$success = $this->_update_espresso_configuration(
489
+				esc_html__('Your Organization Settings', 'event_espresso'),
490
+				EE_Registry::instance()->CFG,
491
+				__FILE__,
492
+				__FUNCTION__,
493
+				__LINE__
494
+			);
495
+		}
496
+
497
+		$this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
498
+	}
499
+
500
+
501
+
502
+	/*************        Admin Options        *************/
503
+
504
+
505
+	/**
506
+	 * _admin_option_settings
507
+	 *
508
+	 * @throws EE_Error
509
+	 * @throws LogicException
510
+	 */
511
+	protected function _admin_option_settings()
512
+	{
513
+		$this->_template_args['admin_page_content'] = '';
514
+		try {
515
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
516
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
517
+			$this->_template_args['values'] = $this->_yes_no_values;
518
+			// also need to account for the do_action that was in the old template
519
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
520
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
521
+				$admin_options_settings_form->display(),
522
+				'',
523
+				'padding'
524
+			);
525
+		} catch (Exception $e) {
526
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
527
+		}
528
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
529
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
530
+		$this->display_admin_page_with_sidebar();
531
+	}
532
+
533
+
534
+	/**
535
+	 * _update_admin_option_settings
536
+	 *
537
+	 * @throws EE_Error
538
+	 * @throws InvalidDataTypeException
539
+	 * @throws InvalidFormSubmissionException
540
+	 * @throws InvalidArgumentException
541
+	 * @throws LogicException
542
+	 */
543
+	protected function _update_admin_option_settings()
544
+	{
545
+		try {
546
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
547
+			$admin_options_settings_form->process(
548
+				$this->request->getRequestParam(
549
+					$admin_options_settings_form->slug(),
550
+					[],
551
+					DataType::STRING,
552
+					true
553
+				)
554
+			);
555
+			EE_Registry::instance()->CFG->admin = apply_filters(
556
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
557
+				EE_Registry::instance()->CFG->admin
558
+			);
559
+		} catch (Exception $e) {
560
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
561
+		}
562
+		$this->_redirect_after_action(
563
+			apply_filters(
564
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
565
+				$this->_update_espresso_configuration(
566
+					esc_html__('Admin Options', 'event_espresso'),
567
+					EE_Registry::instance()->CFG->admin,
568
+					__FILE__,
569
+					__FUNCTION__,
570
+					__LINE__
571
+				)
572
+			),
573
+			esc_html__('Admin Options', 'event_espresso'),
574
+			'updated',
575
+			['action' => 'admin_option_settings']
576
+		);
577
+	}
578
+
579
+
580
+	/*************        Countries        *************/
581
+
582
+
583
+	/**
584
+	 * @param string|null $default
585
+	 * @return string
586
+	 */
587
+	protected function getCountryISO(?string $default = null): string
588
+	{
589
+		$default = $default ?? $this->getCountryIsoForSite();
590
+		$CNT_ISO = $this->request->getRequestParam('country', $default);
591
+		$CNT_ISO = $this->request->getRequestParam('CNT_ISO', $CNT_ISO);
592
+		return strtoupper($CNT_ISO);
593
+	}
594
+
595
+
596
+	/**
597
+	 * @return string
598
+	 */
599
+	protected function getCountryIsoForSite(): string
600
+	{
601
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
602
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
603
+			: 'US';
604
+	}
605
+
606
+
607
+	/**
608
+	 * @param string          $CNT_ISO
609
+	 * @param EE_Country|null $country
610
+	 * @return EE_Base_Class|EE_Country
611
+	 * @throws EE_Error
612
+	 * @throws InvalidArgumentException
613
+	 * @throws InvalidDataTypeException
614
+	 * @throws InvalidInterfaceException
615
+	 * @throws ReflectionException
616
+	 */
617
+	protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
618
+	{
619
+		/** @var EE_Country $country */
620
+		return $country instanceof EE_Country && $country->ID() === $CNT_ISO
621
+			? $country
622
+			: EEM_Country::instance()->get_one_by_ID($CNT_ISO);
623
+	}
624
+
625
+
626
+	/**
627
+	 * Output Country Settings view.
628
+	 *
629
+	 * @throws DomainException
630
+	 * @throws EE_Error
631
+	 * @throws InvalidArgumentException
632
+	 * @throws InvalidDataTypeException
633
+	 * @throws InvalidInterfaceException
634
+	 * @throws ReflectionException
635
+	 */
636
+	protected function _country_settings()
637
+	{
638
+		$CNT_ISO = $this->getCountryISO();
639
+
640
+		$this->_template_args['values']    = $this->_yes_no_values;
641
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
642
+			EE_Question::new_instance(
643
+				[
644
+				  'QST_ID'           => 0,
645
+				  'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
646
+				  'QST_system'       => 'admin-country',
647
+				]
648
+			),
649
+			EE_Answer::new_instance(
650
+				[
651
+					'ANS_ID'    => 0,
652
+					'ANS_value' => $CNT_ISO,
653
+				]
654
+			),
655
+			[
656
+				'input_id'       => 'country',
657
+				'input_name'     => 'country',
658
+				'input_prefix'   => '',
659
+				'append_qstn_id' => false,
660
+			]
661
+		);
662
+
663
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
664
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
665
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
666
+		$this->_template_args['country_details_settings'] = $this->display_country_settings(
667
+			$country->ID(),
668
+			$country
669
+		);
670
+		$this->_template_args['country_states_settings']  = $this->display_country_states(
671
+			$country->ID(),
672
+			$country
673
+		);
674
+		$this->_template_args['CNT_name_for_site']        = $country->name();
675
+
676
+		$this->_set_add_edit_form_tags('update_country_settings');
677
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
678
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
679
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
680
+			$this->_template_args,
681
+			true
682
+		);
683
+		$this->display_admin_page_with_no_sidebar();
684
+	}
685
+
686
+
687
+	/**
688
+	 * @param string          $CNT_ISO
689
+	 * @param EE_Country|null $country
690
+	 * @return string
691
+	 * @throws DomainException
692
+	 * @throws EE_Error
693
+	 * @throws InvalidArgumentException
694
+	 * @throws InvalidDataTypeException
695
+	 * @throws InvalidInterfaceException
696
+	 * @throws ReflectionException
697
+	 */
698
+	public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
699
+	{
700
+		$CNT_ISO          = $this->getCountryISO($CNT_ISO);
701
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
702
+
703
+		if (! $CNT_ISO) {
704
+			return '';
705
+		}
706
+
707
+		// for ajax
708
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
709
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
710
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
711
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
712
+		$country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
713
+		$CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
714
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
715
+
716
+		$country_input_types            = [
717
+			'CNT_active'      => [
718
+				'type'             => 'RADIO_BTN',
719
+				'input_name'       => "cntry[$CNT_ISO]",
720
+				'class'            => '',
721
+				'options'          => $this->_yes_no_values,
722
+				'use_desc_4_label' => true,
723
+			],
724
+			'CNT_ISO'         => [
725
+				'type'       => 'TEXT',
726
+				'input_name' => "cntry[$CNT_ISO]",
727
+				'class'      => 'ee-input-width--small',
728
+			],
729
+			'CNT_ISO3'        => [
730
+				'type'       => 'TEXT',
731
+				'input_name' => "cntry[$CNT_ISO]",
732
+				'class'      => 'ee-input-width--small',
733
+			],
734
+			// 'RGN_ID'          => [
735
+			//     'type'       => 'TEXT',
736
+			//     'input_name' => "cntry[$CNT_ISO]",
737
+			//     'class'      => 'ee-input-width--small',
738
+			// ],
739
+			'CNT_name'        => [
740
+				'type'       => 'TEXT',
741
+				'input_name' => "cntry[$CNT_ISO]",
742
+				'class'      => 'ee-input-width--big',
743
+			],
744
+			'CNT_cur_code'    => [
745
+				'type'       => 'TEXT',
746
+				'input_name' => "cntry[$CNT_ISO]",
747
+				'class'      => 'ee-input-width--small',
748
+				'disabled'   => $CNT_cur_disabled,
749
+			],
750
+			'CNT_cur_single'  => [
751
+				'type'       => 'TEXT',
752
+				'input_name' => "cntry[$CNT_ISO]",
753
+				'class'      => 'ee-input-width--reg',
754
+				'disabled'   => $CNT_cur_disabled,
755
+			],
756
+			'CNT_cur_plural'  => [
757
+				'type'       => 'TEXT',
758
+				'input_name' => "cntry[$CNT_ISO]",
759
+				'class'      => 'ee-input-width--reg',
760
+				'disabled'   => $CNT_cur_disabled,
761
+			],
762
+			'CNT_cur_sign'    => [
763
+				'type'         => 'TEXT',
764
+				'input_name'   => "cntry[$CNT_ISO]",
765
+				'class'        => 'ee-input-width--small',
766
+				'htmlentities' => false,
767
+				'disabled'     => $CNT_cur_disabled,
768
+			],
769
+			'CNT_cur_sign_b4' => [
770
+				'type'             => 'RADIO_BTN',
771
+				'input_name'       => "cntry[$CNT_ISO]",
772
+				'class'            => '',
773
+				'options'          => $this->_yes_no_values,
774
+				'use_desc_4_label' => true,
775
+				'disabled'         => $CNT_cur_disabled,
776
+			],
777
+			'CNT_cur_dec_plc' => [
778
+				'type'       => 'RADIO_BTN',
779
+				'input_name' => "cntry[$CNT_ISO]",
780
+				'class'      => '',
781
+				'options'    => [
782
+					['id' => 0, 'text' => ''],
783
+					['id' => 1, 'text' => ''],
784
+					['id' => 2, 'text' => ''],
785
+					['id' => 3, 'text' => ''],
786
+				],
787
+				'disabled'   => $CNT_cur_disabled,
788
+			],
789
+			'CNT_cur_dec_mrk' => [
790
+				'type'             => 'RADIO_BTN',
791
+				'input_name'       => "cntry[$CNT_ISO]",
792
+				'class'            => '',
793
+				'options'          => [
794
+					[
795
+						'id'   => ',',
796
+						'text' => esc_html__(', (comma)', 'event_espresso'),
797
+					],
798
+					['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
799
+				],
800
+				'use_desc_4_label' => true,
801
+				'disabled'         => $CNT_cur_disabled,
802
+			],
803
+			'CNT_cur_thsnds'  => [
804
+				'type'             => 'RADIO_BTN',
805
+				'input_name'       => "cntry[$CNT_ISO]",
806
+				'class'            => '',
807
+				'options'          => [
808
+					[
809
+						'id'   => ',',
810
+						'text' => esc_html__(', (comma)', 'event_espresso'),
811
+					],
812
+					[
813
+						'id'   => '.',
814
+						'text' => esc_html__('. (decimal)', 'event_espresso'),
815
+					],
816
+					[
817
+						'id'   => '&nbsp;',
818
+						'text' => esc_html__('(space)', 'event_espresso'),
819
+					],
820
+				],
821
+				'use_desc_4_label' => true,
822
+				'disabled'         => $CNT_cur_disabled,
823
+			],
824
+			'CNT_tel_code'    => [
825
+				'type'       => 'TEXT',
826
+				'input_name' => "cntry[$CNT_ISO]",
827
+				'class'      => 'ee-input-width--small',
828
+			],
829
+			'CNT_is_EU'       => [
830
+				'type'             => 'RADIO_BTN',
831
+				'input_name'       => "cntry[$CNT_ISO]",
832
+				'class'            => '',
833
+				'options'          => $this->_yes_no_values,
834
+				'use_desc_4_label' => true,
835
+			],
836
+		];
837
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
838
+			$country,
839
+			$country_input_types
840
+		);
841
+		$country_details_settings       = EEH_Template::display_template(
842
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
843
+			$this->_template_args,
844
+			true
845
+		);
846
+
847
+		if (defined('DOING_AJAX')) {
848
+			$notices = EE_Error::get_notices(false, false, false);
849
+			echo wp_json_encode(
850
+				[
851
+					'return_data' => $country_details_settings,
852
+					'success'     => $notices['success'],
853
+					'errors'      => $notices['errors'],
854
+				]
855
+			);
856
+			die();
857
+		}
858
+		return $country_details_settings;
859
+	}
860
+
861
+
862
+	/**
863
+	 * @param string          $CNT_ISO
864
+	 * @param EE_Country|null $country
865
+	 * @return string
866
+	 * @throws DomainException
867
+	 * @throws EE_Error
868
+	 * @throws InvalidArgumentException
869
+	 * @throws InvalidDataTypeException
870
+	 * @throws InvalidInterfaceException
871
+	 * @throws ReflectionException
872
+	 */
873
+	public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
874
+	{
875
+		$CNT_ISO = $this->getCountryISO($CNT_ISO);
876
+		if (! $CNT_ISO) {
877
+			return '';
878
+		}
879
+		// for ajax
880
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
881
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
882
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
883
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
884
+		$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
885
+		if (empty($states)) {
886
+			/** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
887
+			$countrySubRegionDao = $this->loader->getShared(
888
+				'EventEspresso\core\services\address\CountrySubRegionDao'
889
+			);
890
+			if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
891
+				$country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
892
+				if ($countrySubRegionDao->saveCountrySubRegions($country)) {
893
+					$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
894
+				}
895
+			}
896
+		}
897
+		if (is_array($states)) {
898
+			foreach ($states as $STA_ID => $state) {
899
+				if ($state instanceof EE_State) {
900
+					$inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
901
+						$state,
902
+						[
903
+							'STA_abbrev' => [
904
+								'type'             => 'TEXT',
905
+								'label'            => esc_html__('Code', 'event_espresso'),
906
+								'input_name'       => "states[$STA_ID]",
907
+								'class'            => 'ee-input-width--tiny',
908
+								'add_mobile_label' => true,
909
+							],
910
+							'STA_name'   => [
911
+								'type'             => 'TEXT',
912
+								'label'            => esc_html__('Name', 'event_espresso'),
913
+								'input_name'       => "states[$STA_ID]",
914
+								'class'            => 'ee-input-width--big',
915
+								'add_mobile_label' => true,
916
+							],
917
+							'STA_active' => [
918
+								'type'             => 'RADIO_BTN',
919
+								'label'            => esc_html__(
920
+									'State Appears in Dropdown Select Lists',
921
+									'event_espresso'
922
+								),
923
+								'input_name'       => "states[$STA_ID]",
924
+								'options'          => $this->_yes_no_values,
925
+								'use_desc_4_label' => true,
926
+								'add_mobile_label' => true,
927
+							],
928
+						]
929
+					);
930
+
931
+					$delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
932
+						[
933
+							'action'     => 'delete_state',
934
+							'STA_ID'     => $STA_ID,
935
+							'CNT_ISO'    => $CNT_ISO,
936
+							'STA_abbrev' => $state->abbrev(),
937
+						],
938
+						GEN_SET_ADMIN_URL
939
+					);
940
+
941
+					$this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
942
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
943
+				}
944
+			}
945
+		} else {
946
+			$this->_template_args['states'] = false;
947
+		}
948
+
949
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
950
+			['action' => 'add_new_state'],
951
+			GEN_SET_ADMIN_URL
952
+		);
953
+
954
+		$state_details_settings = EEH_Template::display_template(
955
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
956
+			$this->_template_args,
957
+			true
958
+		);
959
+
960
+		if (defined('DOING_AJAX')) {
961
+			$notices = EE_Error::get_notices(false, false, false);
962
+			echo wp_json_encode(
963
+				[
964
+					'return_data' => $state_details_settings,
965
+					'success'     => $notices['success'],
966
+					'errors'      => $notices['errors'],
967
+				]
968
+			);
969
+			die();
970
+		}
971
+		return $state_details_settings;
972
+	}
973
+
974
+
975
+	/**
976
+	 * @return void
977
+	 * @throws EE_Error
978
+	 * @throws InvalidArgumentException
979
+	 * @throws InvalidDataTypeException
980
+	 * @throws InvalidInterfaceException
981
+	 * @throws ReflectionException
982
+	 */
983
+	public function add_new_state()
984
+	{
985
+		$success = true;
986
+		$CNT_ISO = $this->getCountryISO('');
987
+		if (! $CNT_ISO) {
988
+			EE_Error::add_error(
989
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
990
+				__FILE__,
991
+				__FUNCTION__,
992
+				__LINE__
993
+			);
994
+			$success = false;
995
+		}
996
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
997
+		if (! $STA_abbrev) {
998
+			EE_Error::add_error(
999
+				esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1000
+				__FILE__,
1001
+				__FUNCTION__,
1002
+				__LINE__
1003
+			);
1004
+			$success = false;
1005
+		}
1006
+		$STA_name = $this->request->getRequestParam('STA_name');
1007
+		if (! $STA_name) {
1008
+			EE_Error::add_error(
1009
+				esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1010
+				__FILE__,
1011
+				__FUNCTION__,
1012
+				__LINE__
1013
+			);
1014
+			$success = false;
1015
+		}
1016
+
1017
+		if ($success) {
1018
+			$cols_n_values = [
1019
+				'CNT_ISO'    => $CNT_ISO,
1020
+				'STA_abbrev' => $STA_abbrev,
1021
+				'STA_name'   => $STA_name,
1022
+				'STA_active' => true,
1023
+			];
1024
+			$success       = EEM_State::instance()->insert($cols_n_values);
1025
+			EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1026
+		}
1027
+
1028
+		if (defined('DOING_AJAX')) {
1029
+			$notices = EE_Error::get_notices(false, false, false);
1030
+			echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1031
+			die();
1032
+		}
1033
+		$this->_redirect_after_action(
1034
+			$success,
1035
+			esc_html__('State', 'event_espresso'),
1036
+			'added',
1037
+			['action' => 'country_settings']
1038
+		);
1039
+	}
1040
+
1041
+
1042
+	/**
1043
+	 * @return void
1044
+	 * @throws EE_Error
1045
+	 * @throws InvalidArgumentException
1046
+	 * @throws InvalidDataTypeException
1047
+	 * @throws InvalidInterfaceException
1048
+	 * @throws ReflectionException
1049
+	 */
1050
+	public function delete_state()
1051
+	{
1052
+		$CNT_ISO    = $this->getCountryISO();
1053
+		$STA_ID     = $this->request->getRequestParam('STA_ID');
1054
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1055
+
1056
+		if (! $STA_ID) {
1057
+			EE_Error::add_error(
1058
+				esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1059
+				__FILE__,
1060
+				__FUNCTION__,
1061
+				__LINE__
1062
+			);
1063
+			return;
1064
+		}
1065
+
1066
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1067
+		if ($success !== false) {
1068
+			do_action(
1069
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1070
+				$CNT_ISO,
1071
+				$STA_ID,
1072
+				['STA_abbrev' => $STA_abbrev]
1073
+			);
1074
+			EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1075
+		}
1076
+		if (defined('DOING_AJAX')) {
1077
+			$notices                = EE_Error::get_notices(false);
1078
+			$notices['return_data'] = true;
1079
+			echo wp_json_encode($notices);
1080
+			die();
1081
+		}
1082
+		$this->_redirect_after_action(
1083
+			$success,
1084
+			esc_html__('State', 'event_espresso'),
1085
+			'deleted',
1086
+			['action' => 'country_settings']
1087
+		);
1088
+	}
1089
+
1090
+
1091
+	/**
1092
+	 * @return void
1093
+	 * @throws EE_Error
1094
+	 * @throws InvalidArgumentException
1095
+	 * @throws InvalidDataTypeException
1096
+	 * @throws InvalidInterfaceException
1097
+	 * @throws ReflectionException
1098
+	 */
1099
+	protected function _update_country_settings()
1100
+	{
1101
+		$CNT_ISO = $this->getCountryISO();
1102
+		if (! $CNT_ISO) {
1103
+			EE_Error::add_error(
1104
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1105
+				__FILE__,
1106
+				__FUNCTION__,
1107
+				__LINE__
1108
+			);
1109
+			return;
1110
+		}
1111
+
1112
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1113
+
1114
+		$cols_n_values                    = [];
1115
+		$cols_n_values['CNT_ISO3']        = strtoupper(
1116
+			$this->request->getRequestParam('cntry', '', $country->ISO3())
1117
+		);
1118
+		$cols_n_values['CNT_name']        = $this->request->getRequestParam(
1119
+			"cntry[$CNT_ISO][CNT_name]",
1120
+			$country->name()
1121
+		);
1122
+		$cols_n_values['CNT_cur_code']    = strtoupper(
1123
+			$this->request->getRequestParam(
1124
+				"cntry[$CNT_ISO][CNT_cur_code]",
1125
+				$country->currency_code()
1126
+			)
1127
+		);
1128
+		$cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1129
+			"cntry[$CNT_ISO][CNT_cur_single]",
1130
+			$country->currency_name_single()
1131
+		);
1132
+		$cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1133
+			"cntry[$CNT_ISO][CNT_cur_plural]",
1134
+			$country->currency_name_plural()
1135
+		);
1136
+		$cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1137
+			"cntry[$CNT_ISO][CNT_cur_sign]",
1138
+			$country->currency_sign()
1139
+		);
1140
+		$cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1141
+			"cntry[$CNT_ISO][CNT_cur_sign_b4]",
1142
+			$country->currency_sign_before(),
1143
+			DataType::BOOL
1144
+		);
1145
+		$cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1146
+			"cntry[$CNT_ISO][CNT_cur_dec_plc]",
1147
+			$country->currency_decimal_places()
1148
+		);
1149
+		$cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1150
+			"cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1151
+			$country->currency_decimal_mark()
1152
+		);
1153
+		$cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1154
+			"cntry[$CNT_ISO][CNT_cur_thsnds]",
1155
+			$country->currency_thousands_separator()
1156
+		);
1157
+		$cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1158
+			"cntry[$CNT_ISO][CNT_tel_code]",
1159
+			$country->telephoneCode()
1160
+		);
1161
+		$cols_n_values['CNT_active']      = $this->request->getRequestParam(
1162
+			"cntry[$CNT_ISO][CNT_active]",
1163
+			$country->isActive(),
1164
+			DataType::BOOL
1165
+		);
1166
+
1167
+		// allow filtering of country data
1168
+		$cols_n_values = apply_filters(
1169
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1170
+			$cols_n_values
1171
+		);
1172
+
1173
+		// where values
1174
+		$where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1175
+		// run the update
1176
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1177
+
1178
+		// allow filtering of states data
1179
+		$states = apply_filters(
1180
+			'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1181
+			$this->request->getRequestParam('states', [], DataType::STRING, true)
1182
+		);
1183
+
1184
+		if (! empty($states) && $success !== false) {
1185
+			// loop thru state data ( looks like : states[75][STA_name] )
1186
+			foreach ($states as $STA_ID => $state) {
1187
+				$cols_n_values = [
1188
+					'CNT_ISO'    => $CNT_ISO,
1189
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1190
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1191
+					'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1192
+				];
1193
+				// where values
1194
+				$where_cols_n_values = [['STA_ID' => $STA_ID]];
1195
+				// run the update
1196
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1197
+				if ($success !== false) {
1198
+					do_action(
1199
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1200
+						$CNT_ISO,
1201
+						$STA_ID,
1202
+						$cols_n_values
1203
+					);
1204
+				}
1205
+			}
1206
+		}
1207
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1208
+		if (
1209
+			isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1210
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1211
+		) {
1212
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1213
+			EE_Registry::instance()->CFG->update_espresso_config();
1214
+		}
1215
+
1216
+		if ($success !== false) {
1217
+			EE_Error::add_success(
1218
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1219
+			);
1220
+		}
1221
+		$this->_redirect_after_action(
1222
+			$success,
1223
+			'',
1224
+			'',
1225
+			['action' => 'country_settings', 'country' => $CNT_ISO],
1226
+			true
1227
+		);
1228
+	}
1229
+
1230
+
1231
+	/**
1232
+	 * form_form_field_label_wrap
1233
+	 *
1234
+	 * @param string $label
1235
+	 * @return string
1236
+	 */
1237
+	public function country_form_field_label_wrap(string $label): string
1238
+	{
1239
+		return '
1240 1240
 			<tr>
1241 1241
 				<th>
1242 1242
 					' . $label . '
1243 1243
 				</th>';
1244
-    }
1245
-
1246
-
1247
-    /**
1248
-     * form_form_field_input__wrap
1249
-     *
1250
-     * @param string $input
1251
-     * @return string
1252
-     */
1253
-    public function country_form_field_input__wrap(string $input): string
1254
-    {
1255
-        return '
1244
+	}
1245
+
1246
+
1247
+	/**
1248
+	 * form_form_field_input__wrap
1249
+	 *
1250
+	 * @param string $input
1251
+	 * @return string
1252
+	 */
1253
+	public function country_form_field_input__wrap(string $input): string
1254
+	{
1255
+		return '
1256 1256
 				<td class="general-settings-country-input-td">
1257 1257
 					' . $input . '
1258 1258
 				</td>
1259 1259
 			</tr>';
1260
-    }
1261
-
1262
-
1263
-    /**
1264
-     * form_form_field_label_wrap
1265
-     *
1266
-     * @param string $label
1267
-     * @param string $required_text
1268
-     * @return string
1269
-     */
1270
-    public function state_form_field_label_wrap(string $label, string $required_text): string
1271
-    {
1272
-        return $required_text;
1273
-    }
1274
-
1275
-
1276
-    /**
1277
-     * form_form_field_input__wrap
1278
-     *
1279
-     * @param string $input
1280
-     * @return string
1281
-     */
1282
-    public function state_form_field_input__wrap(string $input): string
1283
-    {
1284
-        return '
1260
+	}
1261
+
1262
+
1263
+	/**
1264
+	 * form_form_field_label_wrap
1265
+	 *
1266
+	 * @param string $label
1267
+	 * @param string $required_text
1268
+	 * @return string
1269
+	 */
1270
+	public function state_form_field_label_wrap(string $label, string $required_text): string
1271
+	{
1272
+		return $required_text;
1273
+	}
1274
+
1275
+
1276
+	/**
1277
+	 * form_form_field_input__wrap
1278
+	 *
1279
+	 * @param string $input
1280
+	 * @return string
1281
+	 */
1282
+	public function state_form_field_input__wrap(string $input): string
1283
+	{
1284
+		return '
1285 1285
 				<td class="general-settings-country-state-input-td">
1286 1286
 					' . $input . '
1287 1287
 				</td>';
1288
-    }
1289
-
1290
-
1291
-    /***********/
1292
-
1293
-
1294
-    /**
1295
-     * displays edit and view links for critical EE pages
1296
-     *
1297
-     * @param int $ee_page_id
1298
-     * @return string
1299
-     */
1300
-    public static function edit_view_links(int $ee_page_id): string
1301
-    {
1302
-        $edit_url = add_query_arg(
1303
-            ['post' => $ee_page_id, 'action' => 'edit'],
1304
-            admin_url('post.php')
1305
-        );
1306
-        $links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1307
-        $links    .= ' &nbsp;|&nbsp; ';
1308
-        $links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1309
-
1310
-        return $links;
1311
-    }
1312
-
1313
-
1314
-    /**
1315
-     * displays page and shortcode status for critical EE pages
1316
-     *
1317
-     * @param WP_Post $ee_page
1318
-     * @param string  $shortcode
1319
-     * @return string
1320
-     */
1321
-    public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1322
-    {
1323
-        // page status
1324
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1325
-            $pg_class  = 'ee-status-bg--success';
1326
-            $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1327
-        } else {
1328
-            $pg_class  = 'ee-status-bg--error';
1329
-            $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1330
-        }
1331
-
1332
-        // shortcode status
1333
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1334
-            $sc_class  = 'ee-status-bg--success';
1335
-            $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1336
-        } else {
1337
-            $sc_class  = 'ee-status-bg--error';
1338
-            $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1339
-        }
1340
-
1341
-        return '
1288
+	}
1289
+
1290
+
1291
+	/***********/
1292
+
1293
+
1294
+	/**
1295
+	 * displays edit and view links for critical EE pages
1296
+	 *
1297
+	 * @param int $ee_page_id
1298
+	 * @return string
1299
+	 */
1300
+	public static function edit_view_links(int $ee_page_id): string
1301
+	{
1302
+		$edit_url = add_query_arg(
1303
+			['post' => $ee_page_id, 'action' => 'edit'],
1304
+			admin_url('post.php')
1305
+		);
1306
+		$links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1307
+		$links    .= ' &nbsp;|&nbsp; ';
1308
+		$links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1309
+
1310
+		return $links;
1311
+	}
1312
+
1313
+
1314
+	/**
1315
+	 * displays page and shortcode status for critical EE pages
1316
+	 *
1317
+	 * @param WP_Post $ee_page
1318
+	 * @param string  $shortcode
1319
+	 * @return string
1320
+	 */
1321
+	public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1322
+	{
1323
+		// page status
1324
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1325
+			$pg_class  = 'ee-status-bg--success';
1326
+			$pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1327
+		} else {
1328
+			$pg_class  = 'ee-status-bg--error';
1329
+			$pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1330
+		}
1331
+
1332
+		// shortcode status
1333
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1334
+			$sc_class  = 'ee-status-bg--success';
1335
+			$sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1336
+		} else {
1337
+			$sc_class  = 'ee-status-bg--error';
1338
+			$sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1339
+		}
1340
+
1341
+		return '
1342 1342
         <span class="ee-page-status ' . $pg_class . '"><strong>' . $pg_status . '</strong></span>
1343 1343
         <span class="ee-page-status ' . $sc_class . '"><strong>' . $sc_status . '</strong></span>';
1344
-    }
1345
-
1346
-
1347
-    /**
1348
-     * generates a dropdown of all parent pages - copied from WP core
1349
-     *
1350
-     * @param int  $default
1351
-     * @param int  $parent
1352
-     * @param int  $level
1353
-     * @param bool $echo
1354
-     * @return string;
1355
-     */
1356
-    public static function page_settings_dropdown(
1357
-        int $default = 0,
1358
-        int $parent = 0,
1359
-        int $level = 0,
1360
-        bool $echo = true
1361
-    ): string {
1362
-        global $wpdb;
1363
-        $items  = $wpdb->get_results(
1364
-            $wpdb->prepare(
1365
-                "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1366
-                $parent
1367
-            )
1368
-        );
1369
-        $output = '';
1370
-
1371
-        if ($items) {
1372
-            $level = absint($level);
1373
-            foreach ($items as $item) {
1374
-                $ID         = absint($item->ID);
1375
-                $post_title = wp_strip_all_tags($item->post_title);
1376
-                $pad        = str_repeat('&nbsp;', $level * 3);
1377
-                $option     = "\n\t";
1378
-                $option     .= '<option class="level-' . $level . '" ';
1379
-                $option     .= 'value="' . $ID . '" ';
1380
-                $option     .= $ID === absint($default) ? ' selected' : '';
1381
-                $option     .= '>';
1382
-                $option     .= "$pad {$post_title}";
1383
-                $option     .= '</option>';
1384
-                $output     .= $option;
1385
-                ob_start();
1386
-                parent_dropdown($default, $item->ID, $level + 1);
1387
-                $output .= ob_get_clean();
1388
-            }
1389
-        }
1390
-        if ($echo) {
1391
-            echo wp_kses($output, AllowedTags::getWithFormTags());
1392
-            return '';
1393
-        }
1394
-        return $output;
1395
-    }
1396
-
1397
-
1398
-    /**
1399
-     * Loads the scripts for the privacy settings form
1400
-     */
1401
-    public function load_scripts_styles_privacy_settings()
1402
-    {
1403
-        $form_handler = $this->loader->getShared(
1404
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1405
-        );
1406
-        $form_handler->enqueueStylesAndScripts();
1407
-    }
1408
-
1409
-
1410
-    /**
1411
-     * display the privacy settings form
1412
-     *
1413
-     * @throws EE_Error
1414
-     */
1415
-    public function privacySettings()
1416
-    {
1417
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1418
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1419
-        $form_handler                               = $this->loader->getShared(
1420
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1421
-        );
1422
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
1423
-            $form_handler->display(),
1424
-            '',
1425
-            'padding'
1426
-        );
1427
-        $this->display_admin_page_with_sidebar();
1428
-    }
1429
-
1430
-
1431
-    /**
1432
-     * Update the privacy settings from form data
1433
-     *
1434
-     * @throws EE_Error
1435
-     */
1436
-    public function updatePrivacySettings()
1437
-    {
1438
-        $form_handler = $this->loader->getShared(
1439
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1440
-        );
1441
-        $success      = $form_handler->process($this->get_request_data());
1442
-        $this->_redirect_after_action(
1443
-            $success,
1444
-            esc_html__('Registration Form Options', 'event_espresso'),
1445
-            'updated',
1446
-            ['action' => 'privacy_settings']
1447
-        );
1448
-    }
1344
+	}
1345
+
1346
+
1347
+	/**
1348
+	 * generates a dropdown of all parent pages - copied from WP core
1349
+	 *
1350
+	 * @param int  $default
1351
+	 * @param int  $parent
1352
+	 * @param int  $level
1353
+	 * @param bool $echo
1354
+	 * @return string;
1355
+	 */
1356
+	public static function page_settings_dropdown(
1357
+		int $default = 0,
1358
+		int $parent = 0,
1359
+		int $level = 0,
1360
+		bool $echo = true
1361
+	): string {
1362
+		global $wpdb;
1363
+		$items  = $wpdb->get_results(
1364
+			$wpdb->prepare(
1365
+				"SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1366
+				$parent
1367
+			)
1368
+		);
1369
+		$output = '';
1370
+
1371
+		if ($items) {
1372
+			$level = absint($level);
1373
+			foreach ($items as $item) {
1374
+				$ID         = absint($item->ID);
1375
+				$post_title = wp_strip_all_tags($item->post_title);
1376
+				$pad        = str_repeat('&nbsp;', $level * 3);
1377
+				$option     = "\n\t";
1378
+				$option     .= '<option class="level-' . $level . '" ';
1379
+				$option     .= 'value="' . $ID . '" ';
1380
+				$option     .= $ID === absint($default) ? ' selected' : '';
1381
+				$option     .= '>';
1382
+				$option     .= "$pad {$post_title}";
1383
+				$option     .= '</option>';
1384
+				$output     .= $option;
1385
+				ob_start();
1386
+				parent_dropdown($default, $item->ID, $level + 1);
1387
+				$output .= ob_get_clean();
1388
+			}
1389
+		}
1390
+		if ($echo) {
1391
+			echo wp_kses($output, AllowedTags::getWithFormTags());
1392
+			return '';
1393
+		}
1394
+		return $output;
1395
+	}
1396
+
1397
+
1398
+	/**
1399
+	 * Loads the scripts for the privacy settings form
1400
+	 */
1401
+	public function load_scripts_styles_privacy_settings()
1402
+	{
1403
+		$form_handler = $this->loader->getShared(
1404
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1405
+		);
1406
+		$form_handler->enqueueStylesAndScripts();
1407
+	}
1408
+
1409
+
1410
+	/**
1411
+	 * display the privacy settings form
1412
+	 *
1413
+	 * @throws EE_Error
1414
+	 */
1415
+	public function privacySettings()
1416
+	{
1417
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1418
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1419
+		$form_handler                               = $this->loader->getShared(
1420
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1421
+		);
1422
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
1423
+			$form_handler->display(),
1424
+			'',
1425
+			'padding'
1426
+		);
1427
+		$this->display_admin_page_with_sidebar();
1428
+	}
1429
+
1430
+
1431
+	/**
1432
+	 * Update the privacy settings from form data
1433
+	 *
1434
+	 * @throws EE_Error
1435
+	 */
1436
+	public function updatePrivacySettings()
1437
+	{
1438
+		$form_handler = $this->loader->getShared(
1439
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1440
+		);
1441
+		$success      = $form_handler->process($this->get_request_data());
1442
+		$this->_redirect_after_action(
1443
+			$success,
1444
+			esc_html__('Registration Form Options', 'event_espresso'),
1445
+			'updated',
1446
+			['action' => 'privacy_settings']
1447
+		);
1448
+	}
1449 1449
 }
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -246,19 +246,19 @@  discard block
 block discarded – undo
246 246
                 'event_espresso'
247 247
             )
248 248
         );
249
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
249
+        EE_Registry::$i18n_js_strings['error_occurred'] = wp_strip_all_tags(
250 250
             esc_html__(
251 251
                 'An error occurred! Please refresh the page and try again.',
252 252
                 'event_espresso'
253 253
             )
254 254
         );
255
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
255
+        EE_Registry::$i18n_js_strings['confirm_delete_state'] = wp_strip_all_tags(
256 256
             esc_html__(
257 257
                 'Are you sure you want to delete this State / Province?',
258 258
                 'event_espresso'
259 259
             )
260 260
         );
261
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
261
+        EE_Registry::$i18n_js_strings['ajax_url'] = admin_url(
262 262
             'admin-ajax.php?page=espresso_general_settings',
263 263
             is_ssl() ? 'https://' : 'http://'
264 264
         );
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
         wp_enqueue_script('thickbox');
288 288
         wp_register_script(
289 289
             'organization_settings',
290
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
290
+            GEN_SET_ASSETS_URL.'your_organization_settings.js',
291 291
             ['jquery', 'media-upload', 'thickbox'],
292 292
             EVENT_ESPRESSO_VERSION,
293 293
             true
294 294
         );
295
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
295
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', [], EVENT_ESPRESSO_VERSION);
296 296
         wp_enqueue_script('organization_settings');
297 297
         wp_enqueue_style('organization-css');
298 298
         $confirm_image_delete = [
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
         // scripts
316 316
         wp_register_script(
317 317
             'gen_settings_countries',
318
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
318
+            GEN_SET_ASSETS_URL.'gen_settings_countries.js',
319 319
             ['ee_admin_js'],
320 320
             EVENT_ESPRESSO_VERSION,
321 321
             true
322 322
         );
323
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
323
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', [], EVENT_ESPRESSO_VERSION);
324 324
         wp_enqueue_script('gen_settings_countries');
325 325
         wp_enqueue_style('organization-css');
326 326
     }
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
         $this->_set_add_edit_form_tags('update_espresso_page_settings');
369 369
         $this->_set_publish_post_box_vars(null, false, false, null, false);
370 370
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
371
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
371
+            GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php',
372 372
             $this->_template_args,
373 373
             true
374 374
         );
@@ -385,12 +385,12 @@  discard block
 block discarded – undo
385 385
     {
386 386
         $this->core_config = EE_Registry::instance()->CFG->core;
387 387
         // capture incoming request data && set page IDs
388
-        $this->core_config->reg_page_id       = $this->request->getRequestParam(
388
+        $this->core_config->reg_page_id = $this->request->getRequestParam(
389 389
             'reg_page_id',
390 390
             $this->core_config->reg_page_id,
391 391
             DataType::INT
392 392
         );
393
-        $this->core_config->txn_page_id       = $this->request->getRequestParam(
393
+        $this->core_config->txn_page_id = $this->request->getRequestParam(
394 394
             'txn_page_id',
395 395
             $this->core_config->txn_page_id,
396 396
             DataType::INT
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
             $this->core_config->thank_you_page_id,
401 401
             DataType::INT
402 402
         );
403
-        $this->core_config->cancel_page_id    = $this->request->getRequestParam(
403
+        $this->core_config->cancel_page_id = $this->request->getRequestParam(
404 404
             'cancel_page_id',
405 405
             $this->core_config->cancel_page_id,
406 406
             DataType::INT
@@ -667,16 +667,16 @@  discard block
 block discarded – undo
667 667
             $country->ID(),
668 668
             $country
669 669
         );
670
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
670
+        $this->_template_args['country_states_settings'] = $this->display_country_states(
671 671
             $country->ID(),
672 672
             $country
673 673
         );
674
-        $this->_template_args['CNT_name_for_site']        = $country->name();
674
+        $this->_template_args['CNT_name_for_site'] = $country->name();
675 675
 
676 676
         $this->_set_add_edit_form_tags('update_country_settings');
677 677
         $this->_set_publish_post_box_vars(null, false, false, null, false);
678 678
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
679
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
679
+            GEN_SET_TEMPLATE_PATH.'countries_settings.template.php',
680 680
             $this->_template_args,
681 681
             true
682 682
         );
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
         $CNT_ISO          = $this->getCountryISO($CNT_ISO);
701 701
         $CNT_ISO_for_site = $this->getCountryIsoForSite();
702 702
 
703
-        if (! $CNT_ISO) {
703
+        if ( ! $CNT_ISO) {
704 704
             return '';
705 705
         }
706 706
 
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
         $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
714 714
         $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
715 715
 
716
-        $country_input_types            = [
716
+        $country_input_types = [
717 717
             'CNT_active'      => [
718 718
                 'type'             => 'RADIO_BTN',
719 719
                 'input_name'       => "cntry[$CNT_ISO]",
@@ -838,8 +838,8 @@  discard block
 block discarded – undo
838 838
             $country,
839 839
             $country_input_types
840 840
         );
841
-        $country_details_settings       = EEH_Template::display_template(
842
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
841
+        $country_details_settings = EEH_Template::display_template(
842
+            GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php',
843 843
             $this->_template_args,
844 844
             true
845 845
         );
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
     public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
874 874
     {
875 875
         $CNT_ISO = $this->getCountryISO($CNT_ISO);
876
-        if (! $CNT_ISO) {
876
+        if ( ! $CNT_ISO) {
877 877
             return '';
878 878
         }
879 879
         // for ajax
@@ -938,8 +938,8 @@  discard block
 block discarded – undo
938 938
                         GEN_SET_ADMIN_URL
939 939
                     );
940 940
 
941
-                    $this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
942
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
941
+                    $this->_template_args['states'][$STA_ID]['inputs']           = $inputs;
942
+                    $this->_template_args['states'][$STA_ID]['delete_state_url'] = $delete_state_url;
943 943
                 }
944 944
             }
945 945
         } else {
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
         );
953 953
 
954 954
         $state_details_settings = EEH_Template::display_template(
955
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
955
+            GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php',
956 956
             $this->_template_args,
957 957
             true
958 958
         );
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
     {
985 985
         $success = true;
986 986
         $CNT_ISO = $this->getCountryISO('');
987
-        if (! $CNT_ISO) {
987
+        if ( ! $CNT_ISO) {
988 988
             EE_Error::add_error(
989 989
                 esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
990 990
                 __FILE__,
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
             $success = false;
995 995
         }
996 996
         $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
997
-        if (! $STA_abbrev) {
997
+        if ( ! $STA_abbrev) {
998 998
             EE_Error::add_error(
999 999
                 esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1000 1000
                 __FILE__,
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
             $success = false;
1005 1005
         }
1006 1006
         $STA_name = $this->request->getRequestParam('STA_name');
1007
-        if (! $STA_name) {
1007
+        if ( ! $STA_name) {
1008 1008
             EE_Error::add_error(
1009 1009
                 esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1010 1010
                 __FILE__,
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
                 'STA_name'   => $STA_name,
1022 1022
                 'STA_active' => true,
1023 1023
             ];
1024
-            $success       = EEM_State::instance()->insert($cols_n_values);
1024
+            $success = EEM_State::instance()->insert($cols_n_values);
1025 1025
             EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1026 1026
         }
1027 1027
 
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
         $STA_ID     = $this->request->getRequestParam('STA_ID');
1054 1054
         $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1055 1055
 
1056
-        if (! $STA_ID) {
1056
+        if ( ! $STA_ID) {
1057 1057
             EE_Error::add_error(
1058 1058
                 esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1059 1059
                 __FILE__,
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
     protected function _update_country_settings()
1100 1100
     {
1101 1101
         $CNT_ISO = $this->getCountryISO();
1102
-        if (! $CNT_ISO) {
1102
+        if ( ! $CNT_ISO) {
1103 1103
             EE_Error::add_error(
1104 1104
                 esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1105 1105
                 __FILE__,
@@ -1119,21 +1119,21 @@  discard block
 block discarded – undo
1119 1119
             "cntry[$CNT_ISO][CNT_name]",
1120 1120
             $country->name()
1121 1121
         );
1122
-        $cols_n_values['CNT_cur_code']    = strtoupper(
1122
+        $cols_n_values['CNT_cur_code'] = strtoupper(
1123 1123
             $this->request->getRequestParam(
1124 1124
                 "cntry[$CNT_ISO][CNT_cur_code]",
1125 1125
                 $country->currency_code()
1126 1126
             )
1127 1127
         );
1128
-        $cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1128
+        $cols_n_values['CNT_cur_single'] = $this->request->getRequestParam(
1129 1129
             "cntry[$CNT_ISO][CNT_cur_single]",
1130 1130
             $country->currency_name_single()
1131 1131
         );
1132
-        $cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1132
+        $cols_n_values['CNT_cur_plural'] = $this->request->getRequestParam(
1133 1133
             "cntry[$CNT_ISO][CNT_cur_plural]",
1134 1134
             $country->currency_name_plural()
1135 1135
         );
1136
-        $cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1136
+        $cols_n_values['CNT_cur_sign'] = $this->request->getRequestParam(
1137 1137
             "cntry[$CNT_ISO][CNT_cur_sign]",
1138 1138
             $country->currency_sign()
1139 1139
         );
@@ -1150,15 +1150,15 @@  discard block
 block discarded – undo
1150 1150
             "cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1151 1151
             $country->currency_decimal_mark()
1152 1152
         );
1153
-        $cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1153
+        $cols_n_values['CNT_cur_thsnds'] = $this->request->getRequestParam(
1154 1154
             "cntry[$CNT_ISO][CNT_cur_thsnds]",
1155 1155
             $country->currency_thousands_separator()
1156 1156
         );
1157
-        $cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1157
+        $cols_n_values['CNT_tel_code'] = $this->request->getRequestParam(
1158 1158
             "cntry[$CNT_ISO][CNT_tel_code]",
1159 1159
             $country->telephoneCode()
1160 1160
         );
1161
-        $cols_n_values['CNT_active']      = $this->request->getRequestParam(
1161
+        $cols_n_values['CNT_active'] = $this->request->getRequestParam(
1162 1162
             "cntry[$CNT_ISO][CNT_active]",
1163 1163
             $country->isActive(),
1164 1164
             DataType::BOOL
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
             $this->request->getRequestParam('states', [], DataType::STRING, true)
1182 1182
         );
1183 1183
 
1184
-        if (! empty($states) && $success !== false) {
1184
+        if ( ! empty($states) && $success !== false) {
1185 1185
             // loop thru state data ( looks like : states[75][STA_name] )
1186 1186
             foreach ($states as $STA_ID => $state) {
1187 1187
                 $cols_n_values = [
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
         return '
1240 1240
 			<tr>
1241 1241
 				<th>
1242
-					' . $label . '
1242
+					' . $label.'
1243 1243
 				</th>';
1244 1244
     }
1245 1245
 
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
     {
1255 1255
         return '
1256 1256
 				<td class="general-settings-country-input-td">
1257
-					' . $input . '
1257
+					' . $input.'
1258 1258
 				</td>
1259 1259
 			</tr>';
1260 1260
     }
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
     {
1284 1284
         return '
1285 1285
 				<td class="general-settings-country-state-input-td">
1286
-					' . $input . '
1286
+					' . $input.'
1287 1287
 				</td>';
1288 1288
     }
1289 1289
 
@@ -1303,9 +1303,9 @@  discard block
 block discarded – undo
1303 1303
             ['post' => $ee_page_id, 'action' => 'edit'],
1304 1304
             admin_url('post.php')
1305 1305
         );
1306
-        $links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1306
+        $links = '<a href="'.esc_url_raw($edit_url).'" >'.esc_html__('Edit', 'event_espresso').'</a>';
1307 1307
         $links    .= ' &nbsp;|&nbsp; ';
1308
-        $links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1308
+        $links    .= '<a href="'.get_permalink($ee_page_id).'" >'.esc_html__('View', 'event_espresso').'</a>';
1309 1309
 
1310 1310
         return $links;
1311 1311
     }
@@ -1339,8 +1339,8 @@  discard block
 block discarded – undo
1339 1339
         }
1340 1340
 
1341 1341
         return '
1342
-        <span class="ee-page-status ' . $pg_class . '"><strong>' . $pg_status . '</strong></span>
1343
-        <span class="ee-page-status ' . $sc_class . '"><strong>' . $sc_status . '</strong></span>';
1342
+        <span class="ee-page-status ' . $pg_class.'"><strong>'.$pg_status.'</strong></span>
1343
+        <span class="ee-page-status ' . $sc_class.'"><strong>'.$sc_status.'</strong></span>';
1344 1344
     }
1345 1345
 
1346 1346
 
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
         bool $echo = true
1361 1361
     ): string {
1362 1362
         global $wpdb;
1363
-        $items  = $wpdb->get_results(
1363
+        $items = $wpdb->get_results(
1364 1364
             $wpdb->prepare(
1365 1365
                 "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1366 1366
                 $parent
@@ -1375,8 +1375,8 @@  discard block
 block discarded – undo
1375 1375
                 $post_title = wp_strip_all_tags($item->post_title);
1376 1376
                 $pad        = str_repeat('&nbsp;', $level * 3);
1377 1377
                 $option     = "\n\t";
1378
-                $option     .= '<option class="level-' . $level . '" ';
1379
-                $option     .= 'value="' . $ID . '" ';
1378
+                $option     .= '<option class="level-'.$level.'" ';
1379
+                $option     .= 'value="'.$ID.'" ';
1380 1380
                 $option     .= $ID === absint($default) ? ' selected' : '';
1381 1381
                 $option     .= '>';
1382 1382
                 $option     .= "$pad {$post_title}";
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Registrations_List_Table.class.php 2 patches
Indentation   +1026 added lines, -1026 removed lines patch added patch discarded remove patch
@@ -14,595 +14,595 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class EE_Registrations_List_Table extends EE_Admin_List_Table
16 16
 {
17
-    /**
18
-     * @var Registrations_Admin_Page
19
-     */
20
-    protected $_admin_page;
21
-
22
-    /**
23
-     * @var RegistrationsListTableUserCapabilities
24
-     */
25
-    protected $caps_handler;
26
-
27
-    /**
28
-     * @var array
29
-     */
30
-    private $_status;
31
-
32
-    /**
33
-     * An array of transaction details for the related transaction to the registration being processed.
34
-     * This is set via the _set_related_details method.
35
-     *
36
-     * @var array
37
-     */
38
-    protected $_transaction_details = [];
39
-
40
-    /**
41
-     * An array of event details for the related event to the registration being processed.
42
-     * This is set via the _set_related_details method.
43
-     *
44
-     * @var array
45
-     */
46
-    protected $_event_details = [];
47
-
48
-
49
-    /**
50
-     * @param Registrations_Admin_Page $admin_page
51
-     */
52
-    public function __construct(Registrations_Admin_Page $admin_page)
53
-    {
54
-        $this->caps_handler = new RegistrationsListTableUserCapabilities(EE_Registry::instance()->CAP);
55
-        $req_data = $admin_page->get_request_data();
56
-        if (! empty($req_data['event_id'])) {
57
-            $extra_query_args = [];
58
-            foreach ($admin_page->get_views() as $view_details) {
59
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
60
-            }
61
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62
-        }
63
-        parent::__construct($admin_page);
64
-        $this->_status = $this->_admin_page->get_registration_status_array();
65
-    }
66
-
67
-
68
-    /**
69
-     * @return void
70
-     * @throws EE_Error
71
-     */
72
-    protected function _setup_data()
73
-    {
74
-        $this->_data           = $this->_admin_page->get_registrations($this->_per_page);
75
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
76
-    }
77
-
78
-
79
-    /**
80
-     * @return void
81
-     */
82
-    protected function _set_properties()
83
-    {
84
-        $return_url          = $this->getReturnUrl();
85
-        $this->_wp_list_args = [
86
-            'singular' => esc_html__('registration', 'event_espresso'),
87
-            'plural'   => esc_html__('registrations', 'event_espresso'),
88
-            'ajax'     => true,
89
-            'screen'   => $this->_admin_page->get_current_screen()->id,
90
-        ];
91
-        $req_data            = $this->_admin_page->get_request_data();
92
-        if (isset($req_data['event_id'])) {
93
-            $this->_columns        = [
94
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
95
-                'id'               => esc_html__('ID', 'event_espresso'),
96
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
97
-                'ATT_email'        => esc_html__('Email', 'event_espresso'),
98
-                '_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
99
-                'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
100
-                '_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
101
-                'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
102
-                'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
103
-                'actions'          => $this->actionsColumnHeader(),
104
-            ];
105
-            $this->_bottom_buttons = [
106
-                'report' => [
107
-                    'route'         => 'registrations_report',
108
-                    'extra_request' => [
109
-                        'EVT_ID'     => $this->_req_data['event_id'] ?? null,
110
-                        'return_url' => $return_url,
111
-                    ],
112
-                ],
113
-            ];
114
-        } else {
115
-            $this->_columns        = [
116
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
117
-                'id'               => esc_html__('ID', 'event_espresso'),
118
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
119
-                '_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
120
-                'event_name'       => esc_html__('Event', 'event_espresso'),
121
-                'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
122
-                '_REG_final_price' => esc_html__('Price', 'event_espresso'),
123
-                '_REG_paid'        => esc_html__('Paid', 'event_espresso'),
124
-                'actions'          => $this->actionsColumnHeader(),
125
-            ];
126
-            $this->_bottom_buttons = [
127
-                'report_all' => [
128
-                    'route'         => 'registrations_report',
129
-                    'extra_request' => [
130
-                        'return_url' => $return_url,
131
-                    ],
132
-                ],
133
-            ];
134
-        }
135
-        $this->_bottom_buttons['report_filtered'] = [
136
-            'route'         => 'registrations_report',
137
-            'extra_request' => [
138
-                'use_filters' => true,
139
-                'return_url'  => $return_url,
140
-            ],
141
-        ];
142
-        $filters                                  = array_diff_key(
143
-            $this->_req_data,
144
-            array_flip(
145
-                [
146
-                    'page',
147
-                    'action',
148
-                    'default_nonce',
149
-                ]
150
-            )
151
-        );
152
-        if (! empty($filters)) {
153
-            $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
154
-        }
155
-        $this->_primary_column   = 'id';
156
-        $this->_sortable_columns = [
157
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
158
-            /**
159
-             * Allows users to change the default sort if they wish.
160
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
161
-             * name.
162
-             */
163
-            'ATT_fname'     => [
164
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
165
-                true,
166
-                $this,
167
-            ]
168
-                ? ['ATT_lname' => false]
169
-                : ['ATT_fname' => false],
170
-            'event_name'    => ['event_name' => false],
171
-            'DTT_EVT_start' => ['DTT_EVT_start' => false],
172
-            'id'            => ['REG_ID' => false],
173
-        ];
174
-        $this->_hidden_columns   = [];
175
-    }
176
-
177
-
178
-    /**
179
-     * This simply sets up the row class for the table rows.
180
-     * Allows for easier overriding of child methods for setting up sorting.
181
-     *
182
-     * @param EE_Registration $item the current item
183
-     * @return string
184
-     */
185
-    protected function _get_row_class($item): string
186
-    {
187
-        $class = parent::_get_row_class($item);
188
-        if ($this->_has_checkbox_column) {
189
-            $class .= ' has-checkbox-column';
190
-        }
191
-        return $class;
192
-    }
193
-
194
-
195
-    /**
196
-     * Set the $_transaction_details property if not set yet.
197
-     *
198
-     * @param EE_Registration $registration
199
-     * @throws EE_Error
200
-     * @throws InvalidArgumentException
201
-     * @throws ReflectionException
202
-     * @throws InvalidDataTypeException
203
-     * @throws InvalidInterfaceException
204
-     */
205
-    protected function _set_related_details(EE_Registration $registration)
206
-    {
207
-        $transaction                = $registration->get_first_related('Transaction');
208
-        $status                     = $transaction instanceof EE_Transaction
209
-            ? $transaction->status_ID()
210
-            : EEM_Transaction::failed_status_code;
211
-        $this->_transaction_details = [
212
-            'transaction' => $transaction,
213
-            'status'      => $status,
214
-            'id'          => $transaction instanceof EE_Transaction
215
-                ? $transaction->ID()
216
-                : 0,
217
-            'title_attr'  => sprintf(
218
-                esc_html__('View Transaction Details (%s)', 'event_espresso'),
219
-                EEH_Template::pretty_status($status, false, 'sentence')
220
-            ),
221
-        ];
222
-        try {
223
-            $event = $registration->event();
224
-        } catch (EntityNotFoundException $e) {
225
-            $event = null;
226
-        }
227
-        $status               = $event instanceof EE_Event
228
-            ? $event->get_active_status()
229
-            : EE_Datetime::inactive;
230
-        $this->_event_details = [
231
-            'event'      => $event,
232
-            'status'     => $status,
233
-            'id'         => $event instanceof EE_Event
234
-                ? $event->ID()
235
-                : 0,
236
-            'title_attr' => sprintf(
237
-                esc_html__('Edit Event (%s)', 'event_espresso'),
238
-                EEH_Template::pretty_status($status, false, 'sentence')
239
-            ),
240
-        ];
241
-    }
242
-
243
-
244
-    /**
245
-     * @return array
246
-     * @throws EE_Error
247
-     * @throws ReflectionException
248
-     */
249
-    protected function _get_table_filters(): array
250
-    {
251
-        $filters = [];
252
-        // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
253
-        // methods.
254
-        $cur_date     = $this->_req_data['month_range'] ?? '';
255
-        $cur_category = $this->_req_data['EVT_CAT'] ?? -1;
256
-        $reg_status   = $this->_req_data['_reg_status'] ?? '';
257
-        $filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
258
-        $filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
259
-        $status       = [];
260
-        $status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
261
-        foreach ($this->_status as $key => $value) {
262
-            $status[] = ['id' => $key, 'text' => $value];
263
-        }
264
-        if ($this->_view !== 'incomplete') {
265
-            $filters[] = EEH_Form_Fields::select_input(
266
-                '_reg_status',
267
-                $status,
268
-                isset($this->_req_data['_reg_status'])
269
-                    ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
270
-                    : ''
271
-            );
272
-        }
273
-        if (isset($this->_req_data['event_id'])) {
274
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
275
-        }
276
-        return $filters;
277
-    }
278
-
279
-
280
-    /**
281
-     * @return void
282
-     * @throws EE_Error
283
-     * @throws InvalidArgumentException
284
-     * @throws InvalidDataTypeException
285
-     * @throws InvalidInterfaceException
286
-     * @throws ReflectionException
287
-     */
288
-    protected function _add_view_counts()
289
-    {
290
-        $this->_views['all']['count']   = $this->_total_registrations();
291
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
292
-        $this->_views['today']['count'] = $this->_total_registrations_today();
293
-        if ($this->caps_handler->userCanTrashRegistrations()) {
294
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
295
-            $this->_views['trash']['count']      = $this->_total_registrations('trash');
296
-        }
297
-    }
298
-
299
-
300
-    /**
301
-     * @param string $view
302
-     * @return int
303
-     * @throws EE_Error
304
-     * @throws ReflectionException
305
-     */
306
-    protected function _total_registrations(string $view = ''): int
307
-    {
308
-        $_where = [];
309
-        $EVT_ID = isset($this->_req_data['event_id'])
310
-            ? absint($this->_req_data['event_id'])
311
-            : false;
312
-        if ($EVT_ID) {
313
-            $_where['EVT_ID'] = $EVT_ID;
314
-        }
315
-        switch ($view) {
316
-            case 'trash':
317
-                return EEM_Registration::instance()->count_deleted([$_where]);
318
-            case 'incomplete':
319
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
320
-                break;
321
-            default:
322
-                $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
323
-        }
324
-        return EEM_Registration::instance()->count([$_where]);
325
-    }
326
-
327
-
328
-    /**
329
-     * @return int
330
-     * @throws EE_Error
331
-     * @throws ReflectionException
332
-     */
333
-    protected function _total_registrations_this_month(): int
334
-    {
335
-        $EVT_ID          = isset($this->_req_data['event_id'])
336
-            ? absint($this->_req_data['event_id'])
337
-            : false;
338
-        $_where          = $EVT_ID
339
-            ? ['EVT_ID' => $EVT_ID]
340
-            : [];
341
-        $this_year_r     = date('Y', current_time('timestamp'));
342
-        $time_start      = ' 00:00:00';
343
-        $time_end        = ' 23:59:59';
344
-        $this_month_r    = date('m', current_time('timestamp'));
345
-        $days_this_month = date('t', current_time('timestamp'));
346
-        // setup date query.
347
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
348
-            'REG_date',
349
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
350
-            'Y-m-d H:i:s'
351
-        );
352
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
353
-            'REG_date',
354
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
355
-            'Y-m-d H:i:s'
356
-        );
357
-        $_where['REG_date'] = [
358
-            'BETWEEN',
359
-            [
360
-                $beginning_string,
361
-                $end_string,
362
-            ],
363
-        ];
364
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
365
-        return EEM_Registration::instance()->count([$_where]);
366
-    }
367
-
368
-
369
-    /**
370
-     * @return int
371
-     * @throws EE_Error
372
-     * @throws ReflectionException
373
-     */
374
-    protected function _total_registrations_today(): int
375
-    {
376
-        $EVT_ID             = isset($this->_req_data['event_id'])
377
-            ? absint($this->_req_data['event_id'])
378
-            : false;
379
-        $_where             = $EVT_ID
380
-            ? ['EVT_ID' => $EVT_ID]
381
-            : [];
382
-        $current_date       = date('Y-m-d', current_time('timestamp'));
383
-        $time_start         = ' 00:00:00';
384
-        $time_end           = ' 23:59:59';
385
-        $_where['REG_date'] = [
386
-            'BETWEEN',
387
-            [
388
-                EEM_Registration::instance()->convert_datetime_for_query(
389
-                    'REG_date',
390
-                    $current_date . $time_start,
391
-                    'Y-m-d H:i:s'
392
-                ),
393
-                EEM_Registration::instance()->convert_datetime_for_query(
394
-                    'REG_date',
395
-                    $current_date . $time_end,
396
-                    'Y-m-d H:i:s'
397
-                ),
398
-            ],
399
-        ];
400
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
401
-        return EEM_Registration::instance()->count([$_where]);
402
-    }
403
-
404
-
405
-    /**
406
-     * @param EE_Registration $item
407
-     * @return string
408
-     * @throws EE_Error
409
-     * @throws InvalidArgumentException
410
-     * @throws InvalidDataTypeException
411
-     * @throws InvalidInterfaceException
412
-     * @throws ReflectionException
413
-     */
414
-    public function column_cb($item): string
415
-    {
416
-        /** checkbox/lock **/
417
-        $REG_ID        = $item->ID();
418
-        $transaction   = $item->get_first_related('Transaction');
419
-        $payment_count = $transaction instanceof EE_Transaction
420
-            ? $transaction->count_related('Payment')
421
-            : 0;
422
-
423
-        $content = '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />';
424
-        $content .= $payment_count > 0 || ! $this->caps_handler->userCanEditRegistration($item)
425
-            ? '<span class="ee-locked-entity dashicons dashicons-lock ee-aria-tooltip ee-aria-tooltip--big-box"
17
+	/**
18
+	 * @var Registrations_Admin_Page
19
+	 */
20
+	protected $_admin_page;
21
+
22
+	/**
23
+	 * @var RegistrationsListTableUserCapabilities
24
+	 */
25
+	protected $caps_handler;
26
+
27
+	/**
28
+	 * @var array
29
+	 */
30
+	private $_status;
31
+
32
+	/**
33
+	 * An array of transaction details for the related transaction to the registration being processed.
34
+	 * This is set via the _set_related_details method.
35
+	 *
36
+	 * @var array
37
+	 */
38
+	protected $_transaction_details = [];
39
+
40
+	/**
41
+	 * An array of event details for the related event to the registration being processed.
42
+	 * This is set via the _set_related_details method.
43
+	 *
44
+	 * @var array
45
+	 */
46
+	protected $_event_details = [];
47
+
48
+
49
+	/**
50
+	 * @param Registrations_Admin_Page $admin_page
51
+	 */
52
+	public function __construct(Registrations_Admin_Page $admin_page)
53
+	{
54
+		$this->caps_handler = new RegistrationsListTableUserCapabilities(EE_Registry::instance()->CAP);
55
+		$req_data = $admin_page->get_request_data();
56
+		if (! empty($req_data['event_id'])) {
57
+			$extra_query_args = [];
58
+			foreach ($admin_page->get_views() as $view_details) {
59
+				$extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
60
+			}
61
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62
+		}
63
+		parent::__construct($admin_page);
64
+		$this->_status = $this->_admin_page->get_registration_status_array();
65
+	}
66
+
67
+
68
+	/**
69
+	 * @return void
70
+	 * @throws EE_Error
71
+	 */
72
+	protected function _setup_data()
73
+	{
74
+		$this->_data           = $this->_admin_page->get_registrations($this->_per_page);
75
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
76
+	}
77
+
78
+
79
+	/**
80
+	 * @return void
81
+	 */
82
+	protected function _set_properties()
83
+	{
84
+		$return_url          = $this->getReturnUrl();
85
+		$this->_wp_list_args = [
86
+			'singular' => esc_html__('registration', 'event_espresso'),
87
+			'plural'   => esc_html__('registrations', 'event_espresso'),
88
+			'ajax'     => true,
89
+			'screen'   => $this->_admin_page->get_current_screen()->id,
90
+		];
91
+		$req_data            = $this->_admin_page->get_request_data();
92
+		if (isset($req_data['event_id'])) {
93
+			$this->_columns        = [
94
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
95
+				'id'               => esc_html__('ID', 'event_espresso'),
96
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
97
+				'ATT_email'        => esc_html__('Email', 'event_espresso'),
98
+				'_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
99
+				'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
100
+				'_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
101
+				'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
102
+				'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
103
+				'actions'          => $this->actionsColumnHeader(),
104
+			];
105
+			$this->_bottom_buttons = [
106
+				'report' => [
107
+					'route'         => 'registrations_report',
108
+					'extra_request' => [
109
+						'EVT_ID'     => $this->_req_data['event_id'] ?? null,
110
+						'return_url' => $return_url,
111
+					],
112
+				],
113
+			];
114
+		} else {
115
+			$this->_columns        = [
116
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
117
+				'id'               => esc_html__('ID', 'event_espresso'),
118
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
119
+				'_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
120
+				'event_name'       => esc_html__('Event', 'event_espresso'),
121
+				'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
122
+				'_REG_final_price' => esc_html__('Price', 'event_espresso'),
123
+				'_REG_paid'        => esc_html__('Paid', 'event_espresso'),
124
+				'actions'          => $this->actionsColumnHeader(),
125
+			];
126
+			$this->_bottom_buttons = [
127
+				'report_all' => [
128
+					'route'         => 'registrations_report',
129
+					'extra_request' => [
130
+						'return_url' => $return_url,
131
+					],
132
+				],
133
+			];
134
+		}
135
+		$this->_bottom_buttons['report_filtered'] = [
136
+			'route'         => 'registrations_report',
137
+			'extra_request' => [
138
+				'use_filters' => true,
139
+				'return_url'  => $return_url,
140
+			],
141
+		];
142
+		$filters                                  = array_diff_key(
143
+			$this->_req_data,
144
+			array_flip(
145
+				[
146
+					'page',
147
+					'action',
148
+					'default_nonce',
149
+				]
150
+			)
151
+		);
152
+		if (! empty($filters)) {
153
+			$this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
154
+		}
155
+		$this->_primary_column   = 'id';
156
+		$this->_sortable_columns = [
157
+			'_REG_date'     => ['_REG_date' => true],   // true means its already sorted
158
+			/**
159
+			 * Allows users to change the default sort if they wish.
160
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
161
+			 * name.
162
+			 */
163
+			'ATT_fname'     => [
164
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
165
+				true,
166
+				$this,
167
+			]
168
+				? ['ATT_lname' => false]
169
+				: ['ATT_fname' => false],
170
+			'event_name'    => ['event_name' => false],
171
+			'DTT_EVT_start' => ['DTT_EVT_start' => false],
172
+			'id'            => ['REG_ID' => false],
173
+		];
174
+		$this->_hidden_columns   = [];
175
+	}
176
+
177
+
178
+	/**
179
+	 * This simply sets up the row class for the table rows.
180
+	 * Allows for easier overriding of child methods for setting up sorting.
181
+	 *
182
+	 * @param EE_Registration $item the current item
183
+	 * @return string
184
+	 */
185
+	protected function _get_row_class($item): string
186
+	{
187
+		$class = parent::_get_row_class($item);
188
+		if ($this->_has_checkbox_column) {
189
+			$class .= ' has-checkbox-column';
190
+		}
191
+		return $class;
192
+	}
193
+
194
+
195
+	/**
196
+	 * Set the $_transaction_details property if not set yet.
197
+	 *
198
+	 * @param EE_Registration $registration
199
+	 * @throws EE_Error
200
+	 * @throws InvalidArgumentException
201
+	 * @throws ReflectionException
202
+	 * @throws InvalidDataTypeException
203
+	 * @throws InvalidInterfaceException
204
+	 */
205
+	protected function _set_related_details(EE_Registration $registration)
206
+	{
207
+		$transaction                = $registration->get_first_related('Transaction');
208
+		$status                     = $transaction instanceof EE_Transaction
209
+			? $transaction->status_ID()
210
+			: EEM_Transaction::failed_status_code;
211
+		$this->_transaction_details = [
212
+			'transaction' => $transaction,
213
+			'status'      => $status,
214
+			'id'          => $transaction instanceof EE_Transaction
215
+				? $transaction->ID()
216
+				: 0,
217
+			'title_attr'  => sprintf(
218
+				esc_html__('View Transaction Details (%s)', 'event_espresso'),
219
+				EEH_Template::pretty_status($status, false, 'sentence')
220
+			),
221
+		];
222
+		try {
223
+			$event = $registration->event();
224
+		} catch (EntityNotFoundException $e) {
225
+			$event = null;
226
+		}
227
+		$status               = $event instanceof EE_Event
228
+			? $event->get_active_status()
229
+			: EE_Datetime::inactive;
230
+		$this->_event_details = [
231
+			'event'      => $event,
232
+			'status'     => $status,
233
+			'id'         => $event instanceof EE_Event
234
+				? $event->ID()
235
+				: 0,
236
+			'title_attr' => sprintf(
237
+				esc_html__('Edit Event (%s)', 'event_espresso'),
238
+				EEH_Template::pretty_status($status, false, 'sentence')
239
+			),
240
+		];
241
+	}
242
+
243
+
244
+	/**
245
+	 * @return array
246
+	 * @throws EE_Error
247
+	 * @throws ReflectionException
248
+	 */
249
+	protected function _get_table_filters(): array
250
+	{
251
+		$filters = [];
252
+		// todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
253
+		// methods.
254
+		$cur_date     = $this->_req_data['month_range'] ?? '';
255
+		$cur_category = $this->_req_data['EVT_CAT'] ?? -1;
256
+		$reg_status   = $this->_req_data['_reg_status'] ?? '';
257
+		$filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
258
+		$filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
259
+		$status       = [];
260
+		$status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
261
+		foreach ($this->_status as $key => $value) {
262
+			$status[] = ['id' => $key, 'text' => $value];
263
+		}
264
+		if ($this->_view !== 'incomplete') {
265
+			$filters[] = EEH_Form_Fields::select_input(
266
+				'_reg_status',
267
+				$status,
268
+				isset($this->_req_data['_reg_status'])
269
+					? strtoupper(sanitize_key($this->_req_data['_reg_status']))
270
+					: ''
271
+			);
272
+		}
273
+		if (isset($this->_req_data['event_id'])) {
274
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
275
+		}
276
+		return $filters;
277
+	}
278
+
279
+
280
+	/**
281
+	 * @return void
282
+	 * @throws EE_Error
283
+	 * @throws InvalidArgumentException
284
+	 * @throws InvalidDataTypeException
285
+	 * @throws InvalidInterfaceException
286
+	 * @throws ReflectionException
287
+	 */
288
+	protected function _add_view_counts()
289
+	{
290
+		$this->_views['all']['count']   = $this->_total_registrations();
291
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
292
+		$this->_views['today']['count'] = $this->_total_registrations_today();
293
+		if ($this->caps_handler->userCanTrashRegistrations()) {
294
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
295
+			$this->_views['trash']['count']      = $this->_total_registrations('trash');
296
+		}
297
+	}
298
+
299
+
300
+	/**
301
+	 * @param string $view
302
+	 * @return int
303
+	 * @throws EE_Error
304
+	 * @throws ReflectionException
305
+	 */
306
+	protected function _total_registrations(string $view = ''): int
307
+	{
308
+		$_where = [];
309
+		$EVT_ID = isset($this->_req_data['event_id'])
310
+			? absint($this->_req_data['event_id'])
311
+			: false;
312
+		if ($EVT_ID) {
313
+			$_where['EVT_ID'] = $EVT_ID;
314
+		}
315
+		switch ($view) {
316
+			case 'trash':
317
+				return EEM_Registration::instance()->count_deleted([$_where]);
318
+			case 'incomplete':
319
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
320
+				break;
321
+			default:
322
+				$_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
323
+		}
324
+		return EEM_Registration::instance()->count([$_where]);
325
+	}
326
+
327
+
328
+	/**
329
+	 * @return int
330
+	 * @throws EE_Error
331
+	 * @throws ReflectionException
332
+	 */
333
+	protected function _total_registrations_this_month(): int
334
+	{
335
+		$EVT_ID          = isset($this->_req_data['event_id'])
336
+			? absint($this->_req_data['event_id'])
337
+			: false;
338
+		$_where          = $EVT_ID
339
+			? ['EVT_ID' => $EVT_ID]
340
+			: [];
341
+		$this_year_r     = date('Y', current_time('timestamp'));
342
+		$time_start      = ' 00:00:00';
343
+		$time_end        = ' 23:59:59';
344
+		$this_month_r    = date('m', current_time('timestamp'));
345
+		$days_this_month = date('t', current_time('timestamp'));
346
+		// setup date query.
347
+		$beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
348
+			'REG_date',
349
+			$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
350
+			'Y-m-d H:i:s'
351
+		);
352
+		$end_string         = EEM_Registration::instance()->convert_datetime_for_query(
353
+			'REG_date',
354
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
355
+			'Y-m-d H:i:s'
356
+		);
357
+		$_where['REG_date'] = [
358
+			'BETWEEN',
359
+			[
360
+				$beginning_string,
361
+				$end_string,
362
+			],
363
+		];
364
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
365
+		return EEM_Registration::instance()->count([$_where]);
366
+	}
367
+
368
+
369
+	/**
370
+	 * @return int
371
+	 * @throws EE_Error
372
+	 * @throws ReflectionException
373
+	 */
374
+	protected function _total_registrations_today(): int
375
+	{
376
+		$EVT_ID             = isset($this->_req_data['event_id'])
377
+			? absint($this->_req_data['event_id'])
378
+			: false;
379
+		$_where             = $EVT_ID
380
+			? ['EVT_ID' => $EVT_ID]
381
+			: [];
382
+		$current_date       = date('Y-m-d', current_time('timestamp'));
383
+		$time_start         = ' 00:00:00';
384
+		$time_end           = ' 23:59:59';
385
+		$_where['REG_date'] = [
386
+			'BETWEEN',
387
+			[
388
+				EEM_Registration::instance()->convert_datetime_for_query(
389
+					'REG_date',
390
+					$current_date . $time_start,
391
+					'Y-m-d H:i:s'
392
+				),
393
+				EEM_Registration::instance()->convert_datetime_for_query(
394
+					'REG_date',
395
+					$current_date . $time_end,
396
+					'Y-m-d H:i:s'
397
+				),
398
+			],
399
+		];
400
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
401
+		return EEM_Registration::instance()->count([$_where]);
402
+	}
403
+
404
+
405
+	/**
406
+	 * @param EE_Registration $item
407
+	 * @return string
408
+	 * @throws EE_Error
409
+	 * @throws InvalidArgumentException
410
+	 * @throws InvalidDataTypeException
411
+	 * @throws InvalidInterfaceException
412
+	 * @throws ReflectionException
413
+	 */
414
+	public function column_cb($item): string
415
+	{
416
+		/** checkbox/lock **/
417
+		$REG_ID        = $item->ID();
418
+		$transaction   = $item->get_first_related('Transaction');
419
+		$payment_count = $transaction instanceof EE_Transaction
420
+			? $transaction->count_related('Payment')
421
+			: 0;
422
+
423
+		$content = '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />';
424
+		$content .= $payment_count > 0 || ! $this->caps_handler->userCanEditRegistration($item)
425
+			? '<span class="ee-locked-entity dashicons dashicons-lock ee-aria-tooltip ee-aria-tooltip--big-box"
426 426
                     aria-label="' . $this->lockedRegMessage() . '"></span>'
427
-            : '';
428
-        return $this->columnContent('cb', $content, 'center');
429
-    }
430
-
431
-
432
-    private function lockedRegMessage(): string
433
-    {
434
-        return esc_html__(
435
-            'This lock-icon means that this registration cannot be trashed.  Registrations that belong to a transaction that has payments cannot be trashed.  If you wish to trash this registration then you must delete all payments attached to the related transaction first.',
436
-            'event_espresso'
437
-        );
438
-    }
439
-
440
-
441
-    /**
442
-     * @param EE_Registration $registration
443
-     * @return string
444
-     * @throws EE_Error
445
-     * @throws InvalidArgumentException
446
-     * @throws InvalidDataTypeException
447
-     * @throws InvalidInterfaceException
448
-     * @throws ReflectionException
449
-     */
450
-    public function column_id(EE_Registration $registration): string
451
-    {
452
-        $content = '<span class="ee-entity-id">' . $registration->ID() . '</span>';
453
-        $content .= '<span class="show-on-mobile-view-only">';
454
-        $content .= $this->column_ATT_fname($registration, false);
455
-        $content .= '</span>';
456
-
457
-        return $this->columnContent('id', $content, 'end');
458
-    }
459
-
460
-
461
-    /**
462
-     * @param EE_Registration $registration
463
-     * @param bool            $prep_content
464
-     * @return string
465
-     * @throws EE_Error
466
-     * @throws ReflectionException
467
-     */
468
-    public function column_ATT_fname(EE_Registration $registration, bool $prep_content = true): string
469
-    {
470
-
471
-        $status         = esc_attr($registration->status_ID());
472
-        $pretty_status  = EEH_Template::pretty_status($status, false, 'sentence');
473
-        $prime_reg_star = $registration->count() === 1
474
-            ? '<sup><span class="dashicons dashicons-star-filled gold-icon"></span></sup>'
475
-            : '';
476
-
477
-        $group_count = '
427
+			: '';
428
+		return $this->columnContent('cb', $content, 'center');
429
+	}
430
+
431
+
432
+	private function lockedRegMessage(): string
433
+	{
434
+		return esc_html__(
435
+			'This lock-icon means that this registration cannot be trashed.  Registrations that belong to a transaction that has payments cannot be trashed.  If you wish to trash this registration then you must delete all payments attached to the related transaction first.',
436
+			'event_espresso'
437
+		);
438
+	}
439
+
440
+
441
+	/**
442
+	 * @param EE_Registration $registration
443
+	 * @return string
444
+	 * @throws EE_Error
445
+	 * @throws InvalidArgumentException
446
+	 * @throws InvalidDataTypeException
447
+	 * @throws InvalidInterfaceException
448
+	 * @throws ReflectionException
449
+	 */
450
+	public function column_id(EE_Registration $registration): string
451
+	{
452
+		$content = '<span class="ee-entity-id">' . $registration->ID() . '</span>';
453
+		$content .= '<span class="show-on-mobile-view-only">';
454
+		$content .= $this->column_ATT_fname($registration, false);
455
+		$content .= '</span>';
456
+
457
+		return $this->columnContent('id', $content, 'end');
458
+	}
459
+
460
+
461
+	/**
462
+	 * @param EE_Registration $registration
463
+	 * @param bool            $prep_content
464
+	 * @return string
465
+	 * @throws EE_Error
466
+	 * @throws ReflectionException
467
+	 */
468
+	public function column_ATT_fname(EE_Registration $registration, bool $prep_content = true): string
469
+	{
470
+
471
+		$status         = esc_attr($registration->status_ID());
472
+		$pretty_status  = EEH_Template::pretty_status($status, false, 'sentence');
473
+		$prime_reg_star = $registration->count() === 1
474
+			? '<sup><span class="dashicons dashicons-star-filled gold-icon"></span></sup>'
475
+			: '';
476
+
477
+		$group_count = '
478 478
             <span class="reg-count-group-size" >
479 479
                 ' . sprintf(
480
-            esc_html__('(%1$s / %2$s)', 'event_espresso'),
481
-            $registration->count(),
482
-            $registration->group_size()
483
-        ) . '
480
+			esc_html__('(%1$s / %2$s)', 'event_espresso'),
481
+			$registration->count(),
482
+			$registration->group_size()
483
+		) . '
484 484
             </span >';
485 485
 
486
-        $content = '
486
+		$content = '
487 487
         <div class="ee-layout-row">
488 488
             <span aria-label="' . $pretty_status . '"
489 489
                   class="ee-status-dot ee-status-bg--' . $status . ' ee-aria-tooltip"
490 490
             ></span>
491 491
             ' . $this->viewRegistrationLink($registration, $status)
492
-                   . $prime_reg_star
493
-                   . $group_count . '
492
+				   . $prime_reg_star
493
+				   . $group_count . '
494 494
             <span class="spacer"></span>
495 495
             <span>
496 496
                 ' . sprintf(
497
-                       esc_html__('Reg Code: %s', 'event_espresso'),
498
-                       $registration->get('REG_code')
499
-                   ) . '
497
+					   esc_html__('Reg Code: %s', 'event_espresso'),
498
+					   $registration->get('REG_code')
499
+				   ) . '
500 500
             </span>
501 501
         </div>';
502 502
 
503
-        $url_params = ['_REG_ID' => $registration->ID()];
504
-        if (isset($this->_req_data['event_id'])) {
505
-            $url_params['event_id'] = $registration->event_ID();
506
-        }
507
-        // trash/restore/delete actions
508
-        $actions = $this->trashRegistrationLink($registration, $url_params);
509
-        $actions = $this->restoreRegistrationLink($registration, $url_params, $actions);
510
-        $actions = $this->deleteRegistrationLink($registration, $url_params, $actions);
511
-
512
-        $content = sprintf('%1$s %2$s', $content, $this->row_actions($actions));
513
-
514
-        return $prep_content ? $this->columnContent('ATT_fname', $content) : $content;
515
-    }
516
-
517
-
518
-    /**
519
-     * @param EE_Registration $registration
520
-     * @param bool            $prep_content
521
-     * @return string
522
-     * @throws EE_Error
523
-     * @throws ReflectionException
524
-     */
525
-    public function column__REG_date(EE_Registration $registration, bool $prep_content = true): string
526
-    {
527
-        $this->_set_related_details($registration);
528
-        // Build row actions
529
-        $content = $this->caps_handler->userCanViewTransaction()
530
-            ? '<a class="ee-aria-tooltip ee-status-color--' . $this->_transaction_details['status'] . '" href="'
531
-              . $this->viewTransactionUrl()
532
-              . '" aria-label="'
533
-              . esc_attr($this->_transaction_details['title_attr'])
534
-              . '">'
535
-              . $registration->get_i18n_datetime('REG_date', 'M jS Y g:i a')
536
-              . '</a>'
537
-            : $registration->get_i18n_datetime('REG_date');
538
-
539
-        return $prep_content ? $this->columnContent('_REG_date', $content) : $content;
540
-    }
541
-
542
-
543
-    /**
544
-     * @param EE_Registration $registration
545
-     * @return string
546
-     * @throws EE_Error
547
-     * @throws InvalidArgumentException
548
-     * @throws InvalidDataTypeException
549
-     * @throws InvalidInterfaceException
550
-     * @throws ReflectionException
551
-     */
552
-    public function column_event_name(EE_Registration $registration): string
553
-    {
554
-        $this->_set_related_details($registration);
555
-        $EVT_ID     = $registration->event_ID();
556
-        $event_name = $registration->event_name();
557
-        $event_name = $event_name ?: esc_html__("No Associated Event", 'event_espresso');
558
-        $event_name = wp_trim_words($event_name, 30, '...');
559
-        $edit_event = $this->editEventLink($EVT_ID, $event_name);
560
-        $actions['event_filter'] = $this->eventFilterLink($EVT_ID, $event_name);
561
-        $content = sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
562
-
563
-        return $this->columnContent('event_name', $content);
564
-    }
565
-
566
-
567
-    /**
568
-     * @param EE_Registration $registration
569
-     * @return string
570
-     * @throws EE_Error
571
-     * @throws InvalidArgumentException
572
-     * @throws InvalidDataTypeException
573
-     * @throws InvalidInterfaceException
574
-     * @throws ReflectionException
575
-     */
576
-    public function column_DTT_EVT_start(EE_Registration $registration): string
577
-    {
578
-        $datetime_strings = [];
579
-        $ticket           = $registration->ticket();
580
-        if ($ticket instanceof EE_Ticket) {
581
-            $remove_defaults = ['default_where_conditions' => 'none'];
582
-            $datetimes       = $ticket->datetimes($remove_defaults);
583
-            foreach ($datetimes as $datetime) {
584
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a');
585
-            }
586
-            $content = $this->generateDisplayForDatetimes($datetime_strings);
587
-        } else {
588
-            $content = esc_html__('There is no ticket on this registration', 'event_espresso');
589
-        }
590
-        return $this->columnContent('DTT_EVT_start', $content);
591
-    }
592
-
593
-
594
-    /**
595
-     * Receives an array of datetime strings to display and converts them to the html container for the column.
596
-     *
597
-     * @param array $datetime_strings
598
-     * @return string
599
-     */
600
-    public function generateDisplayForDatetimes(array $datetime_strings): string
601
-    {
602
-        // get first item for initial visibility
603
-        $content = (string) array_shift($datetime_strings);
604
-        if (! empty($datetime_strings)) {
605
-            $content .= '
503
+		$url_params = ['_REG_ID' => $registration->ID()];
504
+		if (isset($this->_req_data['event_id'])) {
505
+			$url_params['event_id'] = $registration->event_ID();
506
+		}
507
+		// trash/restore/delete actions
508
+		$actions = $this->trashRegistrationLink($registration, $url_params);
509
+		$actions = $this->restoreRegistrationLink($registration, $url_params, $actions);
510
+		$actions = $this->deleteRegistrationLink($registration, $url_params, $actions);
511
+
512
+		$content = sprintf('%1$s %2$s', $content, $this->row_actions($actions));
513
+
514
+		return $prep_content ? $this->columnContent('ATT_fname', $content) : $content;
515
+	}
516
+
517
+
518
+	/**
519
+	 * @param EE_Registration $registration
520
+	 * @param bool            $prep_content
521
+	 * @return string
522
+	 * @throws EE_Error
523
+	 * @throws ReflectionException
524
+	 */
525
+	public function column__REG_date(EE_Registration $registration, bool $prep_content = true): string
526
+	{
527
+		$this->_set_related_details($registration);
528
+		// Build row actions
529
+		$content = $this->caps_handler->userCanViewTransaction()
530
+			? '<a class="ee-aria-tooltip ee-status-color--' . $this->_transaction_details['status'] . '" href="'
531
+			  . $this->viewTransactionUrl()
532
+			  . '" aria-label="'
533
+			  . esc_attr($this->_transaction_details['title_attr'])
534
+			  . '">'
535
+			  . $registration->get_i18n_datetime('REG_date', 'M jS Y g:i a')
536
+			  . '</a>'
537
+			: $registration->get_i18n_datetime('REG_date');
538
+
539
+		return $prep_content ? $this->columnContent('_REG_date', $content) : $content;
540
+	}
541
+
542
+
543
+	/**
544
+	 * @param EE_Registration $registration
545
+	 * @return string
546
+	 * @throws EE_Error
547
+	 * @throws InvalidArgumentException
548
+	 * @throws InvalidDataTypeException
549
+	 * @throws InvalidInterfaceException
550
+	 * @throws ReflectionException
551
+	 */
552
+	public function column_event_name(EE_Registration $registration): string
553
+	{
554
+		$this->_set_related_details($registration);
555
+		$EVT_ID     = $registration->event_ID();
556
+		$event_name = $registration->event_name();
557
+		$event_name = $event_name ?: esc_html__("No Associated Event", 'event_espresso');
558
+		$event_name = wp_trim_words($event_name, 30, '...');
559
+		$edit_event = $this->editEventLink($EVT_ID, $event_name);
560
+		$actions['event_filter'] = $this->eventFilterLink($EVT_ID, $event_name);
561
+		$content = sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
562
+
563
+		return $this->columnContent('event_name', $content);
564
+	}
565
+
566
+
567
+	/**
568
+	 * @param EE_Registration $registration
569
+	 * @return string
570
+	 * @throws EE_Error
571
+	 * @throws InvalidArgumentException
572
+	 * @throws InvalidDataTypeException
573
+	 * @throws InvalidInterfaceException
574
+	 * @throws ReflectionException
575
+	 */
576
+	public function column_DTT_EVT_start(EE_Registration $registration): string
577
+	{
578
+		$datetime_strings = [];
579
+		$ticket           = $registration->ticket();
580
+		if ($ticket instanceof EE_Ticket) {
581
+			$remove_defaults = ['default_where_conditions' => 'none'];
582
+			$datetimes       = $ticket->datetimes($remove_defaults);
583
+			foreach ($datetimes as $datetime) {
584
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start', 'M jS Y g:i a');
585
+			}
586
+			$content = $this->generateDisplayForDatetimes($datetime_strings);
587
+		} else {
588
+			$content = esc_html__('There is no ticket on this registration', 'event_espresso');
589
+		}
590
+		return $this->columnContent('DTT_EVT_start', $content);
591
+	}
592
+
593
+
594
+	/**
595
+	 * Receives an array of datetime strings to display and converts them to the html container for the column.
596
+	 *
597
+	 * @param array $datetime_strings
598
+	 * @return string
599
+	 */
600
+	public function generateDisplayForDatetimes(array $datetime_strings): string
601
+	{
602
+		// get first item for initial visibility
603
+		$content = (string) array_shift($datetime_strings);
604
+		if (! empty($datetime_strings)) {
605
+			$content .= '
606 606
                 <div class="ee-registration-event-datetimes-container-wrap">
607 607
                     <button aria-label="' . esc_attr__('Click to view all dates', 'event_espresso') . '"
608 608
                           class="ee-aria-tooltip button button--secondary button--tiny button--icon-only ee-js ee-more-datetimes-toggle"
@@ -613,539 +613,539 @@  discard block
 block discarded – undo
613 613
                         ' . implode("", $datetime_strings) . '
614 614
                     </div>
615 615
                 </div>';
616
-        }
617
-        return $content;
618
-    }
619
-
620
-
621
-    /**
622
-     * @param EE_Registration $registration
623
-     * @return string
624
-     * @throws EE_Error
625
-     * @throws InvalidArgumentException
626
-     * @throws InvalidDataTypeException
627
-     * @throws InvalidInterfaceException
628
-     * @throws ReflectionException
629
-     */
630
-    public function column_ATT_email(EE_Registration $registration): string
631
-    {
632
-        $attendee = $registration->get_first_related('Attendee');
633
-        $content  = ! $attendee instanceof EE_Attendee
634
-            ? esc_html__('No attached contact record.', 'event_espresso')
635
-            : $attendee->email();
636
-        return $this->columnContent('ATT_email', $content);
637
-    }
638
-
639
-
640
-    /**
641
-     * @param EE_Registration $registration
642
-     * @return string
643
-     */
644
-    public function column__REG_count(EE_Registration $registration): string
645
-    {
646
-        $content =
647
-            sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $registration->count(), $registration->group_size());
648
-        return $this->columnContent('_REG_count', $content);
649
-    }
650
-
651
-
652
-    /**
653
-     * @param EE_Registration $registration
654
-     * @return string
655
-     * @throws EE_Error
656
-     * @throws ReflectionException
657
-     */
658
-    public function column_PRC_amount(EE_Registration $registration): string
659
-    {
660
-        $ticket   = $registration->ticket();
661
-        $req_data = $this->_admin_page->get_request_data();
662
-
663
-        $content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
664
-            ? '<div class="TKT_name">' . $ticket->name() . '</div>'
665
-            : '';
666
-
667
-        $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
668
-        $content        .= $registration->final_price() > 0
669
-            ? '<span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
616
+		}
617
+		return $content;
618
+	}
619
+
620
+
621
+	/**
622
+	 * @param EE_Registration $registration
623
+	 * @return string
624
+	 * @throws EE_Error
625
+	 * @throws InvalidArgumentException
626
+	 * @throws InvalidDataTypeException
627
+	 * @throws InvalidInterfaceException
628
+	 * @throws ReflectionException
629
+	 */
630
+	public function column_ATT_email(EE_Registration $registration): string
631
+	{
632
+		$attendee = $registration->get_first_related('Attendee');
633
+		$content  = ! $attendee instanceof EE_Attendee
634
+			? esc_html__('No attached contact record.', 'event_espresso')
635
+			: $attendee->email();
636
+		return $this->columnContent('ATT_email', $content);
637
+	}
638
+
639
+
640
+	/**
641
+	 * @param EE_Registration $registration
642
+	 * @return string
643
+	 */
644
+	public function column__REG_count(EE_Registration $registration): string
645
+	{
646
+		$content =
647
+			sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $registration->count(), $registration->group_size());
648
+		return $this->columnContent('_REG_count', $content);
649
+	}
650
+
651
+
652
+	/**
653
+	 * @param EE_Registration $registration
654
+	 * @return string
655
+	 * @throws EE_Error
656
+	 * @throws ReflectionException
657
+	 */
658
+	public function column_PRC_amount(EE_Registration $registration): string
659
+	{
660
+		$ticket   = $registration->ticket();
661
+		$req_data = $this->_admin_page->get_request_data();
662
+
663
+		$content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
664
+			? '<div class="TKT_name">' . $ticket->name() . '</div>'
665
+			: '';
666
+
667
+		$payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
668
+		$content        .= $registration->final_price() > 0
669
+			? '<span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
670 670
                 ' . $registration->pretty_final_price() . '
671 671
                </span>'
672
-            // free event
673
-            : '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
674
-
675
-        return $this->columnContent('PRC_amount', $content, 'end');
676
-    }
677
-
678
-
679
-    /**
680
-     * @param EE_Registration $registration
681
-     * @return string
682
-     * @throws EE_Error
683
-     * @throws ReflectionException
684
-     */
685
-    public function column__REG_final_price(EE_Registration $registration): string
686
-    {
687
-        $ticket   = $registration->ticket();
688
-        $req_data = $this->_admin_page->get_request_data();
689
-        $content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
690
-            ? ''
691
-            : '<span class="TKT_name ee-status-color--'
692
-              . $ticket->ticket_status()
693
-              . '">'
694
-              . $ticket->name()
695
-              . '</span> ';
696
-
697
-        $content .= '
672
+			// free event
673
+			: '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
674
+
675
+		return $this->columnContent('PRC_amount', $content, 'end');
676
+	}
677
+
678
+
679
+	/**
680
+	 * @param EE_Registration $registration
681
+	 * @return string
682
+	 * @throws EE_Error
683
+	 * @throws ReflectionException
684
+	 */
685
+	public function column__REG_final_price(EE_Registration $registration): string
686
+	{
687
+		$ticket   = $registration->ticket();
688
+		$req_data = $this->_admin_page->get_request_data();
689
+		$content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
690
+			? ''
691
+			: '<span class="TKT_name ee-status-color--'
692
+			  . $ticket->ticket_status()
693
+			  . '">'
694
+			  . $ticket->name()
695
+			  . '</span> ';
696
+
697
+		$content .= '
698 698
             <span class="reg-overview-paid-event-spn">
699 699
                 ' . $registration->pretty_final_price() . '
700 700
             </span>';
701
-        return $this->columnContent('_REG_final_price', $content, 'end');
702
-    }
703
-
704
-
705
-    /**
706
-     * @param EE_Registration $registration
707
-     * @return string
708
-     * @throws EE_Error
709
-     */
710
-    public function column__REG_paid(EE_Registration $registration): string
711
-    {
712
-        $payment_method      = $registration->payment_method();
713
-        $payment_method_name = $payment_method instanceof EE_Payment_Method
714
-            ? $payment_method->admin_name()
715
-            : esc_html__('Unknown', 'event_espresso');
716
-
717
-        $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
718
-        $content        = '
701
+		return $this->columnContent('_REG_final_price', $content, 'end');
702
+	}
703
+
704
+
705
+	/**
706
+	 * @param EE_Registration $registration
707
+	 * @return string
708
+	 * @throws EE_Error
709
+	 */
710
+	public function column__REG_paid(EE_Registration $registration): string
711
+	{
712
+		$payment_method      = $registration->payment_method();
713
+		$payment_method_name = $payment_method instanceof EE_Payment_Method
714
+			? $payment_method->admin_name()
715
+			: esc_html__('Unknown', 'event_espresso');
716
+
717
+		$payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
718
+		$content        = '
719 719
             <span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
720 720
                 ' . $registration->pretty_paid() . '
721 721
             </span>';
722
-        if ($registration->paid() > 0) {
723
-            $content .= '<span class="ee-status-text-small">'
724
-                        . sprintf(
725
-                            esc_html__('...via %s', 'event_espresso'),
726
-                            $payment_method_name
727
-                        )
728
-                        . '</span>';
729
-        }
730
-        return $this->columnContent('_REG_paid', $content, 'end');
731
-    }
732
-
733
-
734
-    /**
735
-     * @param EE_Registration $registration
736
-     * @return string
737
-     * @throws EE_Error
738
-     * @throws EntityNotFoundException
739
-     * @throws InvalidArgumentException
740
-     * @throws InvalidDataTypeException
741
-     * @throws InvalidInterfaceException
742
-     * @throws ReflectionException
743
-     */
744
-    public function column_TXN_total(EE_Registration $registration): string
745
-    {
746
-        if ($registration->transaction()) {
747
-            $content = $this->caps_handler->userCanViewTransaction()
748
-                ? '
722
+		if ($registration->paid() > 0) {
723
+			$content .= '<span class="ee-status-text-small">'
724
+						. sprintf(
725
+							esc_html__('...via %s', 'event_espresso'),
726
+							$payment_method_name
727
+						)
728
+						. '</span>';
729
+		}
730
+		return $this->columnContent('_REG_paid', $content, 'end');
731
+	}
732
+
733
+
734
+	/**
735
+	 * @param EE_Registration $registration
736
+	 * @return string
737
+	 * @throws EE_Error
738
+	 * @throws EntityNotFoundException
739
+	 * @throws InvalidArgumentException
740
+	 * @throws InvalidDataTypeException
741
+	 * @throws InvalidInterfaceException
742
+	 * @throws ReflectionException
743
+	 */
744
+	public function column_TXN_total(EE_Registration $registration): string
745
+	{
746
+		if ($registration->transaction()) {
747
+			$content = $this->caps_handler->userCanViewTransaction()
748
+				? '
749 749
                     <a class="ee-aria-tooltip ee-status-color--' . $registration->transaction()->status_ID() . '"
750 750
                         href="' . $this->viewTransactionUrl() . '"
751 751
                         aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
752 752
                     >
753 753
                         ' . $registration->transaction()->pretty_total() . '
754 754
                     </a>'
755
-                : $registration->transaction()->pretty_total();
756
-        } else {
757
-            $content = esc_html__("None", "event_espresso");
758
-        }
759
-        return $this->columnContent('TXN_total', $content, 'end');
760
-    }
761
-
762
-
763
-    /**
764
-     * @param EE_Registration $registration
765
-     * @return string
766
-     * @throws EE_Error
767
-     * @throws EntityNotFoundException
768
-     * @throws InvalidArgumentException
769
-     * @throws InvalidDataTypeException
770
-     * @throws InvalidInterfaceException
771
-     * @throws ReflectionException
772
-     */
773
-    public function column_TXN_paid(EE_Registration $registration): string
774
-    {
775
-        $content = '&nbsp;';
776
-        $align   = 'end';
777
-        if ($registration->count() === 1) {
778
-            $transaction = $registration->transaction()
779
-                ? $registration->transaction()
780
-                : EE_Transaction::new_instance();
781
-            if ($transaction->paid() >= $transaction->total()) {
782
-                $align   = 'center';
783
-                $content = '<span class="dashicons dashicons-yes green-icon"></span>';
784
-            } else {
785
-                $content = $this->caps_handler->userCanViewTransaction()
786
-                    ? '
755
+				: $registration->transaction()->pretty_total();
756
+		} else {
757
+			$content = esc_html__("None", "event_espresso");
758
+		}
759
+		return $this->columnContent('TXN_total', $content, 'end');
760
+	}
761
+
762
+
763
+	/**
764
+	 * @param EE_Registration $registration
765
+	 * @return string
766
+	 * @throws EE_Error
767
+	 * @throws EntityNotFoundException
768
+	 * @throws InvalidArgumentException
769
+	 * @throws InvalidDataTypeException
770
+	 * @throws InvalidInterfaceException
771
+	 * @throws ReflectionException
772
+	 */
773
+	public function column_TXN_paid(EE_Registration $registration): string
774
+	{
775
+		$content = '&nbsp;';
776
+		$align   = 'end';
777
+		if ($registration->count() === 1) {
778
+			$transaction = $registration->transaction()
779
+				? $registration->transaction()
780
+				: EE_Transaction::new_instance();
781
+			if ($transaction->paid() >= $transaction->total()) {
782
+				$align   = 'center';
783
+				$content = '<span class="dashicons dashicons-yes green-icon"></span>';
784
+			} else {
785
+				$content = $this->caps_handler->userCanViewTransaction()
786
+					? '
787 787
                     <a class="ee-aria-tooltip ee-status-color--' . $transaction->status_ID() . '"
788 788
                         href="' . $this->viewTransactionUrl() . '"
789 789
                         aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
790 790
                     >
791 791
                         ' . $registration->transaction()->pretty_paid() . '
792 792
                     </a>'
793
-                    : $registration->transaction()->pretty_paid();
794
-            }
795
-        }
796
-        return $this->columnContent('TXN_paid', $content, $align);
797
-    }
798
-
799
-
800
-    /**
801
-     * @param EE_Registration $registration
802
-     * @return string
803
-     * @throws EE_Error
804
-     * @throws InvalidArgumentException
805
-     * @throws InvalidDataTypeException
806
-     * @throws InvalidInterfaceException
807
-     * @throws ReflectionException
808
-     */
809
-    public function column_actions(EE_Registration $registration): string
810
-    {
811
-        $attendee = $registration->attendee();
812
-        $this->_set_related_details($registration);
813
-
814
-        // Build and filter row actions
815
-        $actions = apply_filters(
816
-            'FHEE__EE_Registrations_List_Table__column_actions__actions',
817
-            [
818
-                'view_lnk'               => $this->viewRegistrationAction($registration),
819
-                'edit_lnk'               => $this->editContactAction($registration, $attendee),
820
-                'resend_reg_lnk'         => $this->resendRegistrationMessageAction($registration, $attendee),
821
-                'view_txn_lnk'           => $this->viewTransactionAction(),
822
-                'dl_invoice_lnk'         => $this->viewTransactionInvoiceAction($registration, $attendee),
823
-                'filtered_messages_link' => $this->viewNotificationsAction($registration),
824
-            ],
825
-            $registration,
826
-            $this
827
-        );
828
-
829
-        $content = $this->_action_string(
830
-            implode('', $actions),
831
-            $registration,
832
-            'div',
833
-            'reg-overview-actions ee-list-table-actions'
834
-        );
835
-
836
-        return $this->columnContent('actions', $this->actionsModalMenu($content));
837
-    }
838
-
839
-
840
-    /**
841
-     * @throws EE_Error
842
-     * @throws ReflectionException
843
-     */
844
-    private function viewRegistrationUrl(EE_Registration $registration): string
845
-    {
846
-        return EE_Admin_Page::add_query_args_and_nonce(
847
-            [
848
-                'action'  => 'view_registration',
849
-                '_REG_ID' => $registration->ID(),
850
-            ],
851
-            REG_ADMIN_URL
852
-        );
853
-    }
854
-
855
-
856
-    /**
857
-     * @throws EE_Error
858
-     * @throws ReflectionException
859
-     */
860
-    private function viewRegistrationLink(
861
-        EE_Registration $registration,
862
-        string $status
863
-    ): string {
864
-        $attendee      = $registration->attendee();
865
-        $attendee_name = $attendee instanceof EE_Attendee
866
-            ? $attendee->full_name()
867
-            : '';
868
-        return $this->caps_handler->userCanReadRegistration($registration)
869
-            ? '
793
+					: $registration->transaction()->pretty_paid();
794
+			}
795
+		}
796
+		return $this->columnContent('TXN_paid', $content, $align);
797
+	}
798
+
799
+
800
+	/**
801
+	 * @param EE_Registration $registration
802
+	 * @return string
803
+	 * @throws EE_Error
804
+	 * @throws InvalidArgumentException
805
+	 * @throws InvalidDataTypeException
806
+	 * @throws InvalidInterfaceException
807
+	 * @throws ReflectionException
808
+	 */
809
+	public function column_actions(EE_Registration $registration): string
810
+	{
811
+		$attendee = $registration->attendee();
812
+		$this->_set_related_details($registration);
813
+
814
+		// Build and filter row actions
815
+		$actions = apply_filters(
816
+			'FHEE__EE_Registrations_List_Table__column_actions__actions',
817
+			[
818
+				'view_lnk'               => $this->viewRegistrationAction($registration),
819
+				'edit_lnk'               => $this->editContactAction($registration, $attendee),
820
+				'resend_reg_lnk'         => $this->resendRegistrationMessageAction($registration, $attendee),
821
+				'view_txn_lnk'           => $this->viewTransactionAction(),
822
+				'dl_invoice_lnk'         => $this->viewTransactionInvoiceAction($registration, $attendee),
823
+				'filtered_messages_link' => $this->viewNotificationsAction($registration),
824
+			],
825
+			$registration,
826
+			$this
827
+		);
828
+
829
+		$content = $this->_action_string(
830
+			implode('', $actions),
831
+			$registration,
832
+			'div',
833
+			'reg-overview-actions ee-list-table-actions'
834
+		);
835
+
836
+		return $this->columnContent('actions', $this->actionsModalMenu($content));
837
+	}
838
+
839
+
840
+	/**
841
+	 * @throws EE_Error
842
+	 * @throws ReflectionException
843
+	 */
844
+	private function viewRegistrationUrl(EE_Registration $registration): string
845
+	{
846
+		return EE_Admin_Page::add_query_args_and_nonce(
847
+			[
848
+				'action'  => 'view_registration',
849
+				'_REG_ID' => $registration->ID(),
850
+			],
851
+			REG_ADMIN_URL
852
+		);
853
+	}
854
+
855
+
856
+	/**
857
+	 * @throws EE_Error
858
+	 * @throws ReflectionException
859
+	 */
860
+	private function viewRegistrationLink(
861
+		EE_Registration $registration,
862
+		string $status
863
+	): string {
864
+		$attendee      = $registration->attendee();
865
+		$attendee_name = $attendee instanceof EE_Attendee
866
+			? $attendee->full_name()
867
+			: '';
868
+		return $this->caps_handler->userCanReadRegistration($registration)
869
+			? '
870 870
             <a  href="' . $this->viewRegistrationUrl($registration) . '"
871 871
                 class="row-title ee-status-color--' . $status . ' ee-aria-tooltip"
872 872
                 aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
873 873
             >
874 874
                 ' . $attendee_name . '
875 875
             </a>'
876
-            : $attendee_name;
877
-    }
878
-
879
-
880
-    /**
881
-     * @throws EE_Error
882
-     * @throws ReflectionException
883
-     */
884
-    private function viewRegistrationAction(EE_Registration $registration): string
885
-    {
886
-        return $this->caps_handler->userCanReadRegistration($registration)
887
-            ? '
876
+			: $attendee_name;
877
+	}
878
+
879
+
880
+	/**
881
+	 * @throws EE_Error
882
+	 * @throws ReflectionException
883
+	 */
884
+	private function viewRegistrationAction(EE_Registration $registration): string
885
+	{
886
+		return $this->caps_handler->userCanReadRegistration($registration)
887
+			? '
888 888
             <a  href="' . $this->viewRegistrationUrl($registration) . '"
889 889
                 class="ee-aria-tooltip button button--icon-only"
890 890
                 aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
891 891
             >
892 892
                 <span class="dashicons dashicons-clipboard"></span>
893 893
             </a>'
894
-            : '';
895
-    }
896
-
897
-
898
-    private function editContactAction(EE_Registration $registration, ?EE_Attendee $attendee = null): string
899
-    {
900
-
901
-        if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanEditContacts()) {
902
-            $edit_link_url = EE_Admin_Page::add_query_args_and_nonce(
903
-                [
904
-                    'action' => 'edit_attendee',
905
-                    'post'   => $registration->attendee_ID(),
906
-                ],
907
-                REG_ADMIN_URL
908
-            );
909
-            return '
894
+			: '';
895
+	}
896
+
897
+
898
+	private function editContactAction(EE_Registration $registration, ?EE_Attendee $attendee = null): string
899
+	{
900
+
901
+		if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanEditContacts()) {
902
+			$edit_link_url = EE_Admin_Page::add_query_args_and_nonce(
903
+				[
904
+					'action' => 'edit_attendee',
905
+					'post'   => $registration->attendee_ID(),
906
+				],
907
+				REG_ADMIN_URL
908
+			);
909
+			return '
910 910
                 <a href="' . $edit_link_url . '"
911 911
                    aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso') . '"
912 912
                    class="ee-aria-tooltip button button--secondary button--icon-only"
913 913
                 >
914 914
                     <span class="dashicons dashicons-admin-users"></span>
915 915
                 </a>';
916
-        }
917
-        return '';
918
-    }
919
-
920
-
921
-    /**
922
-     * @throws EE_Error
923
-     * @throws ReflectionException
924
-     */
925
-    private function resendRegistrationMessageAction(
926
-        EE_Registration $registration,
927
-        ?EE_Attendee $attendee = null
928
-    ): string {
929
-        if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanResendMessage($registration)) {
930
-            $resend_reg_link_url = EE_Admin_Page::add_query_args_and_nonce(
931
-                [
932
-                    'action'  => 'resend_registration',
933
-                    '_REG_ID' => $registration->ID(),
934
-                ],
935
-                REG_ADMIN_URL,
936
-                true
937
-            );
938
-            return '
916
+		}
917
+		return '';
918
+	}
919
+
920
+
921
+	/**
922
+	 * @throws EE_Error
923
+	 * @throws ReflectionException
924
+	 */
925
+	private function resendRegistrationMessageAction(
926
+		EE_Registration $registration,
927
+		?EE_Attendee $attendee = null
928
+	): string {
929
+		if ($attendee instanceof EE_Attendee && $this->caps_handler->userCanResendMessage($registration)) {
930
+			$resend_reg_link_url = EE_Admin_Page::add_query_args_and_nonce(
931
+				[
932
+					'action'  => 'resend_registration',
933
+					'_REG_ID' => $registration->ID(),
934
+				],
935
+				REG_ADMIN_URL,
936
+				true
937
+			);
938
+			return '
939 939
 			    <a href="' . $resend_reg_link_url . '" aria-label="'
940
-                                         . esc_attr__('Resend Registration Details', 'event_espresso')
941
-                                         . '" class="ee-aria-tooltip button button--icon-only">
940
+										 . esc_attr__('Resend Registration Details', 'event_espresso')
941
+										 . '" class="ee-aria-tooltip button button--icon-only">
942 942
 			        <span class="dashicons dashicons-email-alt"></span>
943 943
 			    </a>';
944
-        }
945
-        return '';
946
-    }
947
-
948
-
949
-    private function viewTransactionUrl(): string
950
-    {
951
-        return EE_Admin_Page::add_query_args_and_nonce(
952
-            [
953
-                    'action' => 'view_transaction',
954
-                    'TXN_ID' => $this->_transaction_details['id'],
955
-                ],
956
-            TXN_ADMIN_URL
957
-        );
958
-    }
959
-
960
-
961
-    private function viewTransactionAction(): string
962
-    {
963
-        if ($this->caps_handler->userCanViewTransaction()) {
964
-            return '
944
+		}
945
+		return '';
946
+	}
947
+
948
+
949
+	private function viewTransactionUrl(): string
950
+	{
951
+		return EE_Admin_Page::add_query_args_and_nonce(
952
+			[
953
+					'action' => 'view_transaction',
954
+					'TXN_ID' => $this->_transaction_details['id'],
955
+				],
956
+			TXN_ADMIN_URL
957
+		);
958
+	}
959
+
960
+
961
+	private function viewTransactionAction(): string
962
+	{
963
+		if ($this->caps_handler->userCanViewTransaction()) {
964
+			return '
965 965
                 <a class="ee-aria-tooltip button button--icon-only"
966 966
                    href="' . $this->viewTransactionUrl() . '"
967 967
                    aria-label="' . $this->_transaction_details['title_attr'] . '"
968 968
                 >
969 969
                     <span class="dashicons dashicons-cart"></span>
970 970
                 </a>';
971
-        }
972
-        return '';
973
-    }
974
-
975
-
976
-    /**
977
-     * @throws EE_Error
978
-     * @throws ReflectionException
979
-     */
980
-    private function viewTransactionInvoiceAction(
981
-        EE_Registration $registration,
982
-        ?EE_Attendee $attendee = null
983
-    ): string {
984
-        // only show invoice link if message type is active.
985
-        if (
986
-            $attendee instanceof EE_Attendee
987
-            && $registration->is_primary_registrant()
988
-            && EEH_MSG_Template::is_mt_active('invoice')
989
-        ) {
990
-            return '
971
+		}
972
+		return '';
973
+	}
974
+
975
+
976
+	/**
977
+	 * @throws EE_Error
978
+	 * @throws ReflectionException
979
+	 */
980
+	private function viewTransactionInvoiceAction(
981
+		EE_Registration $registration,
982
+		?EE_Attendee $attendee = null
983
+	): string {
984
+		// only show invoice link if message type is active.
985
+		if (
986
+			$attendee instanceof EE_Attendee
987
+			&& $registration->is_primary_registrant()
988
+			&& EEH_MSG_Template::is_mt_active('invoice')
989
+		) {
990
+			return '
991 991
                 <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso')
992
-                                         . '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--icon-only">
992
+										 . '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--icon-only">
993 993
                     <span class="dashicons dashicons-media-spreadsheet"></span>
994 994
                 </a>';
995
-        }
996
-        return '';
997
-    }
998
-
999
-
1000
-    /**
1001
-     * @throws ReflectionException
1002
-     * @throws EE_Error
1003
-     */
1004
-    private function viewNotificationsAction(EE_Registration $registration): string
1005
-    {
1006
-        // message list table link (filtered by REG_ID
1007
-        return $this->caps_handler->userCanReadGlobalMessages()
1008
-            ? EEH_MSG_Template::get_message_action_link(
1009
-                'see_notifications_for',
1010
-                null,
1011
-                ['_REG_ID' => $registration->ID()]
1012
-            )
1013
-            : '';
1014
-    }
1015
-
1016
-
1017
-    /**
1018
-     * @throws EE_Error
1019
-     * @throws ReflectionException
1020
-     */
1021
-    private function trashRegistrationLink(
1022
-        EE_Registration $registration,
1023
-        array $url_params
1024
-    ): array {
1025
-        $actions = [];
1026
-        // can't trash what's already trashed
1027
-        if ($this->_view === 'trash') {
1028
-            return $actions;
1029
-        }
1030
-
1031
-        // check caps
1032
-        if (! $this->caps_handler->userCanTrashRegistration($registration)) {
1033
-            return $actions;
1034
-        }
1035
-
1036
-        // don't delete registrations that have payments applied
1037
-        $transaction   = $registration->get_first_related('Transaction');
1038
-        $payment_count = $transaction instanceof EE_Transaction
1039
-            ? $transaction->count_related('Payment')
1040
-            : 0;
1041
-
1042
-        if ($payment_count > 0) {
1043
-            return $actions;
1044
-        }
1045
-
1046
-        $url_params['action'] = 'trash_registrations';
1047
-        $trash_link_url       = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1048
-        $actions['trash']     = '
995
+		}
996
+		return '';
997
+	}
998
+
999
+
1000
+	/**
1001
+	 * @throws ReflectionException
1002
+	 * @throws EE_Error
1003
+	 */
1004
+	private function viewNotificationsAction(EE_Registration $registration): string
1005
+	{
1006
+		// message list table link (filtered by REG_ID
1007
+		return $this->caps_handler->userCanReadGlobalMessages()
1008
+			? EEH_MSG_Template::get_message_action_link(
1009
+				'see_notifications_for',
1010
+				null,
1011
+				['_REG_ID' => $registration->ID()]
1012
+			)
1013
+			: '';
1014
+	}
1015
+
1016
+
1017
+	/**
1018
+	 * @throws EE_Error
1019
+	 * @throws ReflectionException
1020
+	 */
1021
+	private function trashRegistrationLink(
1022
+		EE_Registration $registration,
1023
+		array $url_params
1024
+	): array {
1025
+		$actions = [];
1026
+		// can't trash what's already trashed
1027
+		if ($this->_view === 'trash') {
1028
+			return $actions;
1029
+		}
1030
+
1031
+		// check caps
1032
+		if (! $this->caps_handler->userCanTrashRegistration($registration)) {
1033
+			return $actions;
1034
+		}
1035
+
1036
+		// don't delete registrations that have payments applied
1037
+		$transaction   = $registration->get_first_related('Transaction');
1038
+		$payment_count = $transaction instanceof EE_Transaction
1039
+			? $transaction->count_related('Payment')
1040
+			: 0;
1041
+
1042
+		if ($payment_count > 0) {
1043
+			return $actions;
1044
+		}
1045
+
1046
+		$url_params['action'] = 'trash_registrations';
1047
+		$trash_link_url       = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1048
+		$actions['trash']     = '
1049 1049
             <a class="ee-aria-tooltip"
1050 1050
                 href="' . $trash_link_url . '"
1051 1051
                 aria-label="' . esc_attr__('Trash Registration', 'event_espresso') . '"
1052 1052
             >
1053 1053
                 ' . esc_html__('Trash', 'event_espresso') . '
1054 1054
             </a>';
1055
-        return $actions;
1056
-    }
1057
-
1058
-
1059
-    /**
1060
-     * @throws EE_Error
1061
-     * @throws ReflectionException
1062
-     */
1063
-    private function restoreRegistrationLink(
1064
-        EE_Registration $registration,
1065
-        array $url_params,
1066
-        array $actions
1067
-    ): array {
1068
-        // can't restore what's not trashed
1069
-        if ($this->_view !== 'trash') {
1070
-            return $actions;
1071
-        }
1072
-
1073
-        // restore registration link
1074
-        if ($this->caps_handler->userCanRestoreRegistration($registration)) {
1075
-            $url_params['action'] = 'restore_registrations';
1076
-            $restore_link_url     = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1077
-            $actions['restore']   = '
1055
+		return $actions;
1056
+	}
1057
+
1058
+
1059
+	/**
1060
+	 * @throws EE_Error
1061
+	 * @throws ReflectionException
1062
+	 */
1063
+	private function restoreRegistrationLink(
1064
+		EE_Registration $registration,
1065
+		array $url_params,
1066
+		array $actions
1067
+	): array {
1068
+		// can't restore what's not trashed
1069
+		if ($this->_view !== 'trash') {
1070
+			return $actions;
1071
+		}
1072
+
1073
+		// restore registration link
1074
+		if ($this->caps_handler->userCanRestoreRegistration($registration)) {
1075
+			$url_params['action'] = 'restore_registrations';
1076
+			$restore_link_url     = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1077
+			$actions['restore']   = '
1078 1078
                 <a class="ee-aria-tooltip"
1079 1079
                     href="' . $restore_link_url . '"
1080 1080
                     aria-label="' . esc_attr__('Restore Registration', 'event_espresso') . '"
1081 1081
                 >
1082 1082
                     ' . esc_html__('Restore', 'event_espresso') . '
1083 1083
                 </a>';
1084
-        }
1085
-
1086
-        return $actions;
1087
-    }
1088
-
1089
-
1090
-    /**
1091
-     * @throws EE_Error
1092
-     * @throws ReflectionException
1093
-     */
1094
-    private function deleteRegistrationLink(
1095
-        EE_Registration $registration,
1096
-        array $url_params,
1097
-        array $actions
1098
-    ): array {
1099
-        if ($this->_view === 'trash' && $this->caps_handler->userCanDeleteRegistration($registration)) {
1100
-            $url_params['action'] = 'delete_registrations';
1101
-            $delete_link_url      = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1102
-            $actions['delete']    = '
1084
+		}
1085
+
1086
+		return $actions;
1087
+	}
1088
+
1089
+
1090
+	/**
1091
+	 * @throws EE_Error
1092
+	 * @throws ReflectionException
1093
+	 */
1094
+	private function deleteRegistrationLink(
1095
+		EE_Registration $registration,
1096
+		array $url_params,
1097
+		array $actions
1098
+	): array {
1099
+		if ($this->_view === 'trash' && $this->caps_handler->userCanDeleteRegistration($registration)) {
1100
+			$url_params['action'] = 'delete_registrations';
1101
+			$delete_link_url      = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1102
+			$actions['delete']    = '
1103 1103
                 <a class="ee-aria-tooltip"
1104 1104
                     href="' . $delete_link_url . '"
1105 1105
                     aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso') . '"
1106 1106
                 >
1107 1107
                     ' . esc_html__('Delete', 'event_espresso') . '
1108 1108
                 </a>';
1109
-        }
1110
-        return $actions;
1111
-    }
1112
-
1113
-
1114
-    private function editEventLink(int $EVT_ID, string $event_name): string
1115
-    {
1116
-        if (! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) {
1117
-            return $event_name;
1118
-        }
1119
-        $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
1120
-            ['action' => 'edit', 'post' => $EVT_ID],
1121
-            EVENTS_ADMIN_URL
1122
-        );
1123
-        return '
1109
+		}
1110
+		return $actions;
1111
+	}
1112
+
1113
+
1114
+	private function editEventLink(int $EVT_ID, string $event_name): string
1115
+	{
1116
+		if (! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) {
1117
+			return $event_name;
1118
+		}
1119
+		$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
1120
+			['action' => 'edit', 'post' => $EVT_ID],
1121
+			EVENTS_ADMIN_URL
1122
+		);
1123
+		return '
1124 1124
             <a class="ee-aria-tooltip ee-status-color--' . $this->_event_details['status'] . '"
1125 1125
                 href="' . $edit_event_url . '"
1126 1126
                 aria-label="' . esc_attr($this->_event_details['title_attr']) . '"
1127 1127
             >
1128 1128
                 ' . $event_name . '
1129 1129
             </a>';
1130
-    }
1130
+	}
1131 1131
 
1132 1132
 
1133
-    private function eventFilterLink(int $EVT_ID, string $event_name): string
1134
-    {
1135
-        if (!$EVT_ID) {
1136
-            return '';
1137
-        }
1138
-        $event_filter_url = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
1139
-        return '
1133
+	private function eventFilterLink(int $EVT_ID, string $event_name): string
1134
+	{
1135
+		if (!$EVT_ID) {
1136
+			return '';
1137
+		}
1138
+		$event_filter_url = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
1139
+		return '
1140 1140
             <a  class="ee-aria-tooltip ee-event-filter-link"
1141 1141
                 href="' . $event_filter_url . '"
1142 1142
                 aria-label="' . sprintf(
1143
-                    esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
1144
-                    $event_name
1145
-                ) . '"
1143
+					esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
1144
+					$event_name
1145
+				) . '"
1146 1146
             >
1147 1147
                 <span class="dashicons dashicons-groups dashicons--small"></span>'
1148
-                . esc_html__('View Registrations', 'event_espresso') . '
1148
+				. esc_html__('View Registrations', 'event_espresso') . '
1149 1149
             </a>';
1150
-    }
1150
+	}
1151 1151
 }
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
     {
54 54
         $this->caps_handler = new RegistrationsListTableUserCapabilities(EE_Registry::instance()->CAP);
55 55
         $req_data = $admin_page->get_request_data();
56
-        if (! empty($req_data['event_id'])) {
56
+        if ( ! empty($req_data['event_id'])) {
57 57
             $extra_query_args = [];
58 58
             foreach ($admin_page->get_views() as $view_details) {
59
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
59
+                $extra_query_args[$view_details['slug']] = ['event_id' => $req_data['event_id']];
60 60
             }
61 61
             $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
62 62
         }
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
             'ajax'     => true,
89 89
             'screen'   => $this->_admin_page->get_current_screen()->id,
90 90
         ];
91
-        $req_data            = $this->_admin_page->get_request_data();
91
+        $req_data = $this->_admin_page->get_request_data();
92 92
         if (isset($req_data['event_id'])) {
93
-            $this->_columns        = [
93
+            $this->_columns = [
94 94
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
95 95
                 'id'               => esc_html__('ID', 'event_espresso'),
96 96
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                 ],
113 113
             ];
114 114
         } else {
115
-            $this->_columns        = [
115
+            $this->_columns = [
116 116
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
117 117
                 'id'               => esc_html__('ID', 'event_espresso'),
118 118
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                 'return_url'  => $return_url,
140 140
             ],
141 141
         ];
142
-        $filters                                  = array_diff_key(
142
+        $filters = array_diff_key(
143 143
             $this->_req_data,
144 144
             array_flip(
145 145
                 [
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
                 ]
150 150
             )
151 151
         );
152
-        if (! empty($filters)) {
152
+        if ( ! empty($filters)) {
153 153
             $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
154 154
         }
155 155
         $this->_primary_column   = 'id';
156 156
         $this->_sortable_columns = [
157
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
157
+            '_REG_date'     => ['_REG_date' => true], // true means its already sorted
158 158
             /**
159 159
              * Allows users to change the default sort if they wish.
160 160
              * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
             'DTT_EVT_start' => ['DTT_EVT_start' => false],
172 172
             'id'            => ['REG_ID' => false],
173 173
         ];
174
-        $this->_hidden_columns   = [];
174
+        $this->_hidden_columns = [];
175 175
     }
176 176
 
177 177
 
@@ -344,14 +344,14 @@  discard block
 block discarded – undo
344 344
         $this_month_r    = date('m', current_time('timestamp'));
345 345
         $days_this_month = date('t', current_time('timestamp'));
346 346
         // setup date query.
347
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
347
+        $beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
348 348
             'REG_date',
349
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
349
+            $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start,
350 350
             'Y-m-d H:i:s'
351 351
         );
352
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
352
+        $end_string = EEM_Registration::instance()->convert_datetime_for_query(
353 353
             'REG_date',
354
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
354
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
355 355
             'Y-m-d H:i:s'
356 356
         );
357 357
         $_where['REG_date'] = [
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
                 $end_string,
362 362
             ],
363 363
         ];
364
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
364
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
365 365
         return EEM_Registration::instance()->count([$_where]);
366 366
     }
367 367
 
@@ -387,17 +387,17 @@  discard block
 block discarded – undo
387 387
             [
388 388
                 EEM_Registration::instance()->convert_datetime_for_query(
389 389
                     'REG_date',
390
-                    $current_date . $time_start,
390
+                    $current_date.$time_start,
391 391
                     'Y-m-d H:i:s'
392 392
                 ),
393 393
                 EEM_Registration::instance()->convert_datetime_for_query(
394 394
                     'REG_date',
395
-                    $current_date . $time_end,
395
+                    $current_date.$time_end,
396 396
                     'Y-m-d H:i:s'
397 397
                 ),
398 398
             ],
399 399
         ];
400
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
400
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
401 401
         return EEM_Registration::instance()->count([$_where]);
402 402
     }
403 403
 
@@ -420,10 +420,10 @@  discard block
 block discarded – undo
420 420
             ? $transaction->count_related('Payment')
421 421
             : 0;
422 422
 
423
-        $content = '<input type="checkbox" name="_REG_ID[]" value="' . $REG_ID . '" />';
423
+        $content = '<input type="checkbox" name="_REG_ID[]" value="'.$REG_ID.'" />';
424 424
         $content .= $payment_count > 0 || ! $this->caps_handler->userCanEditRegistration($item)
425 425
             ? '<span class="ee-locked-entity dashicons dashicons-lock ee-aria-tooltip ee-aria-tooltip--big-box"
426
-                    aria-label="' . $this->lockedRegMessage() . '"></span>'
426
+                    aria-label="' . $this->lockedRegMessage().'"></span>'
427 427
             : '';
428 428
         return $this->columnContent('cb', $content, 'center');
429 429
     }
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
      */
450 450
     public function column_id(EE_Registration $registration): string
451 451
     {
452
-        $content = '<span class="ee-entity-id">' . $registration->ID() . '</span>';
452
+        $content = '<span class="ee-entity-id">'.$registration->ID().'</span>';
453 453
         $content .= '<span class="show-on-mobile-view-only">';
454 454
         $content .= $this->column_ATT_fname($registration, false);
455 455
         $content .= '</span>';
@@ -480,23 +480,23 @@  discard block
 block discarded – undo
480 480
             esc_html__('(%1$s / %2$s)', 'event_espresso'),
481 481
             $registration->count(),
482 482
             $registration->group_size()
483
-        ) . '
483
+        ).'
484 484
             </span >';
485 485
 
486 486
         $content = '
487 487
         <div class="ee-layout-row">
488
-            <span aria-label="' . $pretty_status . '"
489
-                  class="ee-status-dot ee-status-bg--' . $status . ' ee-aria-tooltip"
488
+            <span aria-label="' . $pretty_status.'"
489
+                  class="ee-status-dot ee-status-bg--' . $status.' ee-aria-tooltip"
490 490
             ></span>
491 491
             ' . $this->viewRegistrationLink($registration, $status)
492 492
                    . $prime_reg_star
493
-                   . $group_count . '
493
+                   . $group_count.'
494 494
             <span class="spacer"></span>
495 495
             <span>
496 496
                 ' . sprintf(
497 497
                        esc_html__('Reg Code: %s', 'event_espresso'),
498 498
                        $registration->get('REG_code')
499
-                   ) . '
499
+                   ).'
500 500
             </span>
501 501
         </div>';
502 502
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         $this->_set_related_details($registration);
528 528
         // Build row actions
529 529
         $content = $this->caps_handler->userCanViewTransaction()
530
-            ? '<a class="ee-aria-tooltip ee-status-color--' . $this->_transaction_details['status'] . '" href="'
530
+            ? '<a class="ee-aria-tooltip ee-status-color--'.$this->_transaction_details['status'].'" href="'
531 531
               . $this->viewTransactionUrl()
532 532
               . '" aria-label="'
533 533
               . esc_attr($this->_transaction_details['title_attr'])
@@ -601,16 +601,16 @@  discard block
 block discarded – undo
601 601
     {
602 602
         // get first item for initial visibility
603 603
         $content = (string) array_shift($datetime_strings);
604
-        if (! empty($datetime_strings)) {
604
+        if ( ! empty($datetime_strings)) {
605 605
             $content .= '
606 606
                 <div class="ee-registration-event-datetimes-container-wrap">
607
-                    <button aria-label="' . esc_attr__('Click to view all dates', 'event_espresso') . '"
607
+                    <button aria-label="' . esc_attr__('Click to view all dates', 'event_espresso').'"
608 608
                           class="ee-aria-tooltip button button--secondary button--tiny button--icon-only ee-js ee-more-datetimes-toggle"
609 609
                     >
610 610
                         <span class="dashicons dashicons-admin-collapse"></span>
611 611
                     </button>
612 612
                     <div class="ee-registration-event-datetimes-container more-items hidden">
613
-                        ' . implode("", $datetime_strings) . '
613
+                        ' . implode("", $datetime_strings).'
614 614
                     </div>
615 615
                 </div>';
616 616
         }
@@ -661,16 +661,16 @@  discard block
 block discarded – undo
661 661
         $req_data = $this->_admin_page->get_request_data();
662 662
 
663 663
         $content = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
664
-            ? '<div class="TKT_name">' . $ticket->name() . '</div>'
664
+            ? '<div class="TKT_name">'.$ticket->name().'</div>'
665 665
             : '';
666 666
 
667 667
         $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
668
-        $content        .= $registration->final_price() > 0
669
-            ? '<span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
670
-                ' . $registration->pretty_final_price() . '
668
+        $content .= $registration->final_price() > 0
669
+            ? '<span class="reg-overview-paid-event-spn ee-status-color--'.$payment_status.'">
670
+                ' . $registration->pretty_final_price().'
671 671
                </span>'
672 672
             // free event
673
-            : '<span class="reg-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
673
+            : '<span class="reg-overview-free-event-spn">'.esc_html__('free', 'event_espresso').'</span>';
674 674
 
675 675
         return $this->columnContent('PRC_amount', $content, 'end');
676 676
     }
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 
697 697
         $content .= '
698 698
             <span class="reg-overview-paid-event-spn">
699
-                ' . $registration->pretty_final_price() . '
699
+                ' . $registration->pretty_final_price().'
700 700
             </span>';
701 701
         return $this->columnContent('_REG_final_price', $content, 'end');
702 702
     }
@@ -716,8 +716,8 @@  discard block
 block discarded – undo
716 716
 
717 717
         $payment_status = $registration->owes_monies_and_can_pay() ? 'TFL' : 'TCM';
718 718
         $content        = '
719
-            <span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status . '">
720
-                ' . $registration->pretty_paid() . '
719
+            <span class="reg-overview-paid-event-spn ee-status-color--' . $payment_status.'">
720
+                ' . $registration->pretty_paid().'
721 721
             </span>';
722 722
         if ($registration->paid() > 0) {
723 723
             $content .= '<span class="ee-status-text-small">'
@@ -746,11 +746,11 @@  discard block
 block discarded – undo
746 746
         if ($registration->transaction()) {
747 747
             $content = $this->caps_handler->userCanViewTransaction()
748 748
                 ? '
749
-                    <a class="ee-aria-tooltip ee-status-color--' . $registration->transaction()->status_ID() . '"
750
-                        href="' . $this->viewTransactionUrl() . '"
751
-                        aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
749
+                    <a class="ee-aria-tooltip ee-status-color--' . $registration->transaction()->status_ID().'"
750
+                        href="' . $this->viewTransactionUrl().'"
751
+                        aria-label="' . esc_attr__('View Transaction', 'event_espresso').'"
752 752
                     >
753
-                        ' . $registration->transaction()->pretty_total() . '
753
+                        ' . $registration->transaction()->pretty_total().'
754 754
                     </a>'
755 755
                 : $registration->transaction()->pretty_total();
756 756
         } else {
@@ -784,11 +784,11 @@  discard block
 block discarded – undo
784 784
             } else {
785 785
                 $content = $this->caps_handler->userCanViewTransaction()
786 786
                     ? '
787
-                    <a class="ee-aria-tooltip ee-status-color--' . $transaction->status_ID() . '"
788
-                        href="' . $this->viewTransactionUrl() . '"
789
-                        aria-label="' . esc_attr__('View Transaction', 'event_espresso') . '"
787
+                    <a class="ee-aria-tooltip ee-status-color--' . $transaction->status_ID().'"
788
+                        href="' . $this->viewTransactionUrl().'"
789
+                        aria-label="' . esc_attr__('View Transaction', 'event_espresso').'"
790 790
                     >
791
-                        ' . $registration->transaction()->pretty_paid() . '
791
+                        ' . $registration->transaction()->pretty_paid().'
792 792
                     </a>'
793 793
                     : $registration->transaction()->pretty_paid();
794 794
             }
@@ -867,11 +867,11 @@  discard block
 block discarded – undo
867 867
             : '';
868 868
         return $this->caps_handler->userCanReadRegistration($registration)
869 869
             ? '
870
-            <a  href="' . $this->viewRegistrationUrl($registration) . '"
871
-                class="row-title ee-status-color--' . $status . ' ee-aria-tooltip"
872
-                aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
870
+            <a  href="' . $this->viewRegistrationUrl($registration).'"
871
+                class="row-title ee-status-color--' . $status.' ee-aria-tooltip"
872
+                aria-label="' . esc_attr__('View Registration Details', 'event_espresso').'"
873 873
             >
874
-                ' . $attendee_name . '
874
+                ' . $attendee_name.'
875 875
             </a>'
876 876
             : $attendee_name;
877 877
     }
@@ -885,9 +885,9 @@  discard block
 block discarded – undo
885 885
     {
886 886
         return $this->caps_handler->userCanReadRegistration($registration)
887 887
             ? '
888
-            <a  href="' . $this->viewRegistrationUrl($registration) . '"
888
+            <a  href="' . $this->viewRegistrationUrl($registration).'"
889 889
                 class="ee-aria-tooltip button button--icon-only"
890
-                aria-label="' . esc_attr__('View Registration Details', 'event_espresso') . '"
890
+                aria-label="' . esc_attr__('View Registration Details', 'event_espresso').'"
891 891
             >
892 892
                 <span class="dashicons dashicons-clipboard"></span>
893 893
             </a>'
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
                 REG_ADMIN_URL
908 908
             );
909 909
             return '
910
-                <a href="' . $edit_link_url . '"
911
-                   aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso') . '"
910
+                <a href="' . $edit_link_url.'"
911
+                   aria-label="' . esc_attr__('Edit Contact Details', 'event_espresso').'"
912 912
                    class="ee-aria-tooltip button button--secondary button--icon-only"
913 913
                 >
914 914
                     <span class="dashicons dashicons-admin-users"></span>
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
                 true
937 937
             );
938 938
             return '
939
-			    <a href="' . $resend_reg_link_url . '" aria-label="'
939
+			    <a href="' . $resend_reg_link_url.'" aria-label="'
940 940
                                          . esc_attr__('Resend Registration Details', 'event_espresso')
941 941
                                          . '" class="ee-aria-tooltip button button--icon-only">
942 942
 			        <span class="dashicons dashicons-email-alt"></span>
@@ -963,8 +963,8 @@  discard block
 block discarded – undo
963 963
         if ($this->caps_handler->userCanViewTransaction()) {
964 964
             return '
965 965
                 <a class="ee-aria-tooltip button button--icon-only"
966
-                   href="' . $this->viewTransactionUrl() . '"
967
-                   aria-label="' . $this->_transaction_details['title_attr'] . '"
966
+                   href="' . $this->viewTransactionUrl().'"
967
+                   aria-label="' . $this->_transaction_details['title_attr'].'"
968 968
                 >
969 969
                     <span class="dashicons dashicons-cart"></span>
970 970
                 </a>';
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
         ) {
990 990
             return '
991 991
                 <a aria-label="' . esc_attr__('View Transaction Invoice', 'event_espresso')
992
-                                         . '" target="_blank" href="' . $registration->invoice_url() . '" class="ee-aria-tooltip button button--icon-only">
992
+                                         . '" target="_blank" href="'.$registration->invoice_url().'" class="ee-aria-tooltip button button--icon-only">
993 993
                     <span class="dashicons dashicons-media-spreadsheet"></span>
994 994
                 </a>';
995 995
         }
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
         }
1030 1030
 
1031 1031
         // check caps
1032
-        if (! $this->caps_handler->userCanTrashRegistration($registration)) {
1032
+        if ( ! $this->caps_handler->userCanTrashRegistration($registration)) {
1033 1033
             return $actions;
1034 1034
         }
1035 1035
 
@@ -1047,10 +1047,10 @@  discard block
 block discarded – undo
1047 1047
         $trash_link_url       = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1048 1048
         $actions['trash']     = '
1049 1049
             <a class="ee-aria-tooltip"
1050
-                href="' . $trash_link_url . '"
1051
-                aria-label="' . esc_attr__('Trash Registration', 'event_espresso') . '"
1050
+                href="' . $trash_link_url.'"
1051
+                aria-label="' . esc_attr__('Trash Registration', 'event_espresso').'"
1052 1052
             >
1053
-                ' . esc_html__('Trash', 'event_espresso') . '
1053
+                ' . esc_html__('Trash', 'event_espresso').'
1054 1054
             </a>';
1055 1055
         return $actions;
1056 1056
     }
@@ -1076,10 +1076,10 @@  discard block
 block discarded – undo
1076 1076
             $restore_link_url     = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1077 1077
             $actions['restore']   = '
1078 1078
                 <a class="ee-aria-tooltip"
1079
-                    href="' . $restore_link_url . '"
1080
-                    aria-label="' . esc_attr__('Restore Registration', 'event_espresso') . '"
1079
+                    href="' . $restore_link_url.'"
1080
+                    aria-label="' . esc_attr__('Restore Registration', 'event_espresso').'"
1081 1081
                 >
1082
-                    ' . esc_html__('Restore', 'event_espresso') . '
1082
+                    ' . esc_html__('Restore', 'event_espresso').'
1083 1083
                 </a>';
1084 1084
         }
1085 1085
 
@@ -1101,10 +1101,10 @@  discard block
 block discarded – undo
1101 1101
             $delete_link_url      = EE_Admin_Page::add_query_args_and_nonce($url_params, REG_ADMIN_URL);
1102 1102
             $actions['delete']    = '
1103 1103
                 <a class="ee-aria-tooltip"
1104
-                    href="' . $delete_link_url . '"
1105
-                    aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso') . '"
1104
+                    href="' . $delete_link_url.'"
1105
+                    aria-label="' . esc_attr__('Delete Registration Permanently', 'event_espresso').'"
1106 1106
                 >
1107
-                    ' . esc_html__('Delete', 'event_espresso') . '
1107
+                    ' . esc_html__('Delete', 'event_espresso').'
1108 1108
                 </a>';
1109 1109
         }
1110 1110
         return $actions;
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 
1114 1114
     private function editEventLink(int $EVT_ID, string $event_name): string
1115 1115
     {
1116
-        if (! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) {
1116
+        if ( ! $EVT_ID || ! $this->caps_handler->userCanEditEvent($EVT_ID)) {
1117 1117
             return $event_name;
1118 1118
         }
1119 1119
         $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
@@ -1121,31 +1121,31 @@  discard block
 block discarded – undo
1121 1121
             EVENTS_ADMIN_URL
1122 1122
         );
1123 1123
         return '
1124
-            <a class="ee-aria-tooltip ee-status-color--' . $this->_event_details['status'] . '"
1125
-                href="' . $edit_event_url . '"
1126
-                aria-label="' . esc_attr($this->_event_details['title_attr']) . '"
1124
+            <a class="ee-aria-tooltip ee-status-color--' . $this->_event_details['status'].'"
1125
+                href="' . $edit_event_url.'"
1126
+                aria-label="' . esc_attr($this->_event_details['title_attr']).'"
1127 1127
             >
1128
-                ' . $event_name . '
1128
+                ' . $event_name.'
1129 1129
             </a>';
1130 1130
     }
1131 1131
 
1132 1132
 
1133 1133
     private function eventFilterLink(int $EVT_ID, string $event_name): string
1134 1134
     {
1135
-        if (!$EVT_ID) {
1135
+        if ( ! $EVT_ID) {
1136 1136
             return '';
1137 1137
         }
1138 1138
         $event_filter_url = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
1139 1139
         return '
1140 1140
             <a  class="ee-aria-tooltip ee-event-filter-link"
1141
-                href="' . $event_filter_url . '"
1141
+                href="' . $event_filter_url.'"
1142 1142
                 aria-label="' . sprintf(
1143 1143
                     esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
1144 1144
                     $event_name
1145
-                ) . '"
1145
+                ).'"
1146 1146
             >
1147 1147
                 <span class="dashicons dashicons-groups dashicons--small"></span>'
1148
-                . esc_html__('View Registrations', 'event_espresso') . '
1148
+                . esc_html__('View Registrations', 'event_espresso').'
1149 1149
             </a>';
1150 1150
     }
1151 1151
 }
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 1 patch
Indentation   +3651 added lines, -3651 removed lines patch added patch discarded remove patch
@@ -19,2203 +19,2203 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
21 21
 {
22
-    /**
23
-     * @var EE_Registration
24
-     */
25
-    private $_registration;
26
-
27
-    /**
28
-     * @var EE_Event
29
-     */
30
-    private $_reg_event;
31
-
32
-    /**
33
-     * @var EE_Session
34
-     */
35
-    private $_session;
36
-
37
-    /**
38
-     * @var array
39
-     */
40
-    private static $_reg_status;
41
-
42
-    /**
43
-     * Form for displaying the custom questions for this registration.
44
-     * This gets used a few times throughout the request so its best to cache it
45
-     *
46
-     * @var EE_Registration_Custom_Questions_Form
47
-     */
48
-    protected $_reg_custom_questions_form;
49
-
50
-    /**
51
-     * @var EEM_Registration $registration_model
52
-     */
53
-    private $registration_model;
54
-
55
-    /**
56
-     * @var EEM_Attendee $attendee_model
57
-     */
58
-    private $attendee_model;
59
-
60
-    /**
61
-     * @var EEM_Event $event_model
62
-     */
63
-    private $event_model;
64
-
65
-    /**
66
-     * @var EEM_Status $status_model
67
-     */
68
-    private $status_model;
69
-
70
-
71
-    /**
72
-     * @param bool $routing
73
-     * @throws EE_Error
74
-     * @throws InvalidArgumentException
75
-     * @throws InvalidDataTypeException
76
-     * @throws InvalidInterfaceException
77
-     * @throws ReflectionException
78
-     */
79
-    public function __construct($routing = true)
80
-    {
81
-        parent::__construct($routing);
82
-        add_action('wp_loaded', [$this, 'wp_loaded']);
83
-    }
84
-
85
-
86
-    /**
87
-     * @return EEM_Registration
88
-     * @throws InvalidArgumentException
89
-     * @throws InvalidDataTypeException
90
-     * @throws InvalidInterfaceException
91
-     * @since 4.10.2.p
92
-     */
93
-    protected function getRegistrationModel()
94
-    {
95
-        if (! $this->registration_model instanceof EEM_Registration) {
96
-            $this->registration_model = $this->loader->getShared('EEM_Registration');
97
-        }
98
-        return $this->registration_model;
99
-    }
100
-
101
-
102
-    /**
103
-     * @return EEM_Attendee
104
-     * @throws InvalidArgumentException
105
-     * @throws InvalidDataTypeException
106
-     * @throws InvalidInterfaceException
107
-     * @since 4.10.2.p
108
-     */
109
-    protected function getAttendeeModel()
110
-    {
111
-        if (! $this->attendee_model instanceof EEM_Attendee) {
112
-            $this->attendee_model = $this->loader->getShared('EEM_Attendee');
113
-        }
114
-        return $this->attendee_model;
115
-    }
116
-
117
-
118
-    /**
119
-     * @return EEM_Event
120
-     * @throws InvalidArgumentException
121
-     * @throws InvalidDataTypeException
122
-     * @throws InvalidInterfaceException
123
-     * @since 4.10.2.p
124
-     */
125
-    protected function getEventModel()
126
-    {
127
-        if (! $this->event_model instanceof EEM_Event) {
128
-            $this->event_model = $this->loader->getShared('EEM_Event');
129
-        }
130
-        return $this->event_model;
131
-    }
132
-
133
-
134
-    /**
135
-     * @return EEM_Status
136
-     * @throws InvalidArgumentException
137
-     * @throws InvalidDataTypeException
138
-     * @throws InvalidInterfaceException
139
-     * @since 4.10.2.p
140
-     */
141
-    protected function getStatusModel()
142
-    {
143
-        if (! $this->status_model instanceof EEM_Status) {
144
-            $this->status_model = $this->loader->getShared('EEM_Status');
145
-        }
146
-        return $this->status_model;
147
-    }
148
-
149
-
150
-    public function wp_loaded()
151
-    {
152
-        // when adding a new registration...
153
-        $action = $this->request->getRequestParam('action');
154
-        if ($action === 'new_registration') {
155
-            EE_System::do_not_cache();
156
-            if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
157
-                // and it's NOT the attendee information reg step
158
-                // force cookie expiration by setting time to last week
159
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
160
-                // and update the global
161
-                $_COOKIE['ee_registration_added'] = 0;
162
-            }
163
-        }
164
-    }
165
-
166
-
167
-    protected function _init_page_props()
168
-    {
169
-        $this->page_slug        = REG_PG_SLUG;
170
-        $this->_admin_base_url  = REG_ADMIN_URL;
171
-        $this->_admin_base_path = REG_ADMIN;
172
-        $this->page_label       = esc_html__('Registrations', 'event_espresso');
173
-        $this->_cpt_routes      = [
174
-            'add_new_attendee' => 'espresso_attendees',
175
-            'edit_attendee'    => 'espresso_attendees',
176
-            'insert_attendee'  => 'espresso_attendees',
177
-            'update_attendee'  => 'espresso_attendees',
178
-        ];
179
-        $this->_cpt_model_names = [
180
-            'add_new_attendee' => 'EEM_Attendee',
181
-            'edit_attendee'    => 'EEM_Attendee',
182
-        ];
183
-        $this->_cpt_edit_routes = [
184
-            'espresso_attendees' => 'edit_attendee',
185
-        ];
186
-        $this->_pagenow_map     = [
187
-            'add_new_attendee' => 'post-new.php',
188
-            'edit_attendee'    => 'post.php',
189
-            'trash'            => 'post.php',
190
-        ];
191
-        add_action('edit_form_after_title', [$this, 'after_title_form_fields'], 10);
192
-        // add filters so that the comment urls don't take users to a confusing 404 page
193
-        add_filter('get_comment_link', [$this, 'clear_comment_link'], 10, 2);
194
-    }
195
-
196
-
197
-    /**
198
-     * @param string     $link    The comment permalink with '#comment-$id' appended.
199
-     * @param WP_Comment $comment The current comment object.
200
-     * @return string
201
-     */
202
-    public function clear_comment_link($link, WP_Comment $comment)
203
-    {
204
-        // gotta make sure this only happens on this route
205
-        $post_type = get_post_type($comment->comment_post_ID);
206
-        if ($post_type === 'espresso_attendees') {
207
-            return '#commentsdiv';
208
-        }
209
-        return $link;
210
-    }
211
-
212
-
213
-    protected function _ajax_hooks()
214
-    {
215
-        // todo: all hooks for registrations ajax goes in here
216
-        add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']);
217
-    }
218
-
219
-
220
-    protected function _define_page_props()
221
-    {
222
-        $this->_admin_page_title = $this->page_label;
223
-        $this->_labels           = [
224
-            'buttons'                      => [
225
-                'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
226
-                'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
227
-                'edit'                => esc_html__('Edit Contact', 'event_espresso'),
228
-                'report'              => esc_html__('Event Registrations CSV Report', 'event_espresso'),
229
-                'report_datetime'     => esc_html__('Datetime Registrations CSV Report', 'event_espresso'),
230
-                'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
231
-                'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
232
-                'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
233
-                'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
234
-            ],
235
-            'publishbox'                   => [
236
-                'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
237
-                'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
238
-            ],
239
-            'hide_add_button_on_cpt_route' => [
240
-                'edit_attendee' => true,
241
-            ],
242
-        ];
243
-    }
244
-
245
-
246
-    /**
247
-     * grab url requests and route them
248
-     *
249
-     * @return void
250
-     * @throws EE_Error
251
-     */
252
-    public function _set_page_routes()
253
-    {
254
-        $this->_get_registration_status_array();
255
-        $REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
256
-        $REG_ID             = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
257
-        $ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
258
-        $ATT_ID             = $this->request->getRequestParam('post', $ATT_ID, 'int');
259
-        $this->_page_routes = [
260
-            'default'                             => [
261
-                'func'       => '_registrations_overview_list_table',
262
-                'capability' => 'ee_read_registrations',
263
-            ],
264
-            'view_registration'                   => [
265
-                'func'       => '_registration_details',
266
-                'capability' => 'ee_read_registration',
267
-                'obj_id'     => $REG_ID,
268
-            ],
269
-            'edit_registration'                   => [
270
-                'func'               => '_update_attendee_registration_form',
271
-                'noheader'           => true,
272
-                'headers_sent_route' => 'view_registration',
273
-                'capability'         => 'ee_edit_registration',
274
-                'obj_id'             => $REG_ID,
275
-                '_REG_ID'            => $REG_ID,
276
-            ],
277
-            'trash_registrations'                 => [
278
-                'func'       => '_trash_or_restore_registrations',
279
-                'args'       => ['trash' => true],
280
-                'noheader'   => true,
281
-                'capability' => 'ee_delete_registrations',
282
-            ],
283
-            'restore_registrations'               => [
284
-                'func'       => '_trash_or_restore_registrations',
285
-                'args'       => ['trash' => false],
286
-                'noheader'   => true,
287
-                'capability' => 'ee_delete_registrations',
288
-            ],
289
-            'delete_registrations'                => [
290
-                'func'       => '_delete_registrations',
291
-                'noheader'   => true,
292
-                'capability' => 'ee_delete_registrations',
293
-            ],
294
-            'new_registration'                    => [
295
-                'func'       => 'new_registration',
296
-                'capability' => 'ee_edit_registrations',
297
-            ],
298
-            'process_reg_step'                    => [
299
-                'func'       => 'process_reg_step',
300
-                'noheader'   => true,
301
-                'capability' => 'ee_edit_registrations',
302
-            ],
303
-            'redirect_to_txn'                     => [
304
-                'func'       => 'redirect_to_txn',
305
-                'noheader'   => true,
306
-                'capability' => 'ee_edit_registrations',
307
-            ],
308
-            'change_reg_status'                   => [
309
-                'func'       => '_change_reg_status',
310
-                'noheader'   => true,
311
-                'capability' => 'ee_edit_registration',
312
-                'obj_id'     => $REG_ID,
313
-            ],
314
-            'approve_registration'                => [
315
-                'func'       => 'approve_registration',
316
-                'noheader'   => true,
317
-                'capability' => 'ee_edit_registration',
318
-                'obj_id'     => $REG_ID,
319
-            ],
320
-            'approve_and_notify_registration'     => [
321
-                'func'       => 'approve_registration',
322
-                'noheader'   => true,
323
-                'args'       => [true],
324
-                'capability' => 'ee_edit_registration',
325
-                'obj_id'     => $REG_ID,
326
-            ],
327
-            'approve_registrations'               => [
328
-                'func'       => 'bulk_action_on_registrations',
329
-                'noheader'   => true,
330
-                'capability' => 'ee_edit_registrations',
331
-                'args'       => ['approve'],
332
-            ],
333
-            'approve_and_notify_registrations'    => [
334
-                'func'       => 'bulk_action_on_registrations',
335
-                'noheader'   => true,
336
-                'capability' => 'ee_edit_registrations',
337
-                'args'       => ['approve', true],
338
-            ],
339
-            'decline_registration'                => [
340
-                'func'       => 'decline_registration',
341
-                'noheader'   => true,
342
-                'capability' => 'ee_edit_registration',
343
-                'obj_id'     => $REG_ID,
344
-            ],
345
-            'decline_and_notify_registration'     => [
346
-                'func'       => 'decline_registration',
347
-                'noheader'   => true,
348
-                'args'       => [true],
349
-                'capability' => 'ee_edit_registration',
350
-                'obj_id'     => $REG_ID,
351
-            ],
352
-            'decline_registrations'               => [
353
-                'func'       => 'bulk_action_on_registrations',
354
-                'noheader'   => true,
355
-                'capability' => 'ee_edit_registrations',
356
-                'args'       => ['decline'],
357
-            ],
358
-            'decline_and_notify_registrations'    => [
359
-                'func'       => 'bulk_action_on_registrations',
360
-                'noheader'   => true,
361
-                'capability' => 'ee_edit_registrations',
362
-                'args'       => ['decline', true],
363
-            ],
364
-            'pending_registration'                => [
365
-                'func'       => 'pending_registration',
366
-                'noheader'   => true,
367
-                'capability' => 'ee_edit_registration',
368
-                'obj_id'     => $REG_ID,
369
-            ],
370
-            'pending_and_notify_registration'     => [
371
-                'func'       => 'pending_registration',
372
-                'noheader'   => true,
373
-                'args'       => [true],
374
-                'capability' => 'ee_edit_registration',
375
-                'obj_id'     => $REG_ID,
376
-            ],
377
-            'pending_registrations'               => [
378
-                'func'       => 'bulk_action_on_registrations',
379
-                'noheader'   => true,
380
-                'capability' => 'ee_edit_registrations',
381
-                'args'       => ['pending'],
382
-            ],
383
-            'pending_and_notify_registrations'    => [
384
-                'func'       => 'bulk_action_on_registrations',
385
-                'noheader'   => true,
386
-                'capability' => 'ee_edit_registrations',
387
-                'args'       => ['pending', true],
388
-            ],
389
-            'no_approve_registration'             => [
390
-                'func'       => 'not_approve_registration',
391
-                'noheader'   => true,
392
-                'capability' => 'ee_edit_registration',
393
-                'obj_id'     => $REG_ID,
394
-            ],
395
-            'no_approve_and_notify_registration'  => [
396
-                'func'       => 'not_approve_registration',
397
-                'noheader'   => true,
398
-                'args'       => [true],
399
-                'capability' => 'ee_edit_registration',
400
-                'obj_id'     => $REG_ID,
401
-            ],
402
-            'no_approve_registrations'            => [
403
-                'func'       => 'bulk_action_on_registrations',
404
-                'noheader'   => true,
405
-                'capability' => 'ee_edit_registrations',
406
-                'args'       => ['not_approve'],
407
-            ],
408
-            'no_approve_and_notify_registrations' => [
409
-                'func'       => 'bulk_action_on_registrations',
410
-                'noheader'   => true,
411
-                'capability' => 'ee_edit_registrations',
412
-                'args'       => ['not_approve', true],
413
-            ],
414
-            'cancel_registration'                 => [
415
-                'func'       => 'cancel_registration',
416
-                'noheader'   => true,
417
-                'capability' => 'ee_edit_registration',
418
-                'obj_id'     => $REG_ID,
419
-            ],
420
-            'cancel_and_notify_registration'      => [
421
-                'func'       => 'cancel_registration',
422
-                'noheader'   => true,
423
-                'args'       => [true],
424
-                'capability' => 'ee_edit_registration',
425
-                'obj_id'     => $REG_ID,
426
-            ],
427
-            'cancel_registrations'                => [
428
-                'func'       => 'bulk_action_on_registrations',
429
-                'noheader'   => true,
430
-                'capability' => 'ee_edit_registrations',
431
-                'args'       => ['cancel'],
432
-            ],
433
-            'cancel_and_notify_registrations'     => [
434
-                'func'       => 'bulk_action_on_registrations',
435
-                'noheader'   => true,
436
-                'capability' => 'ee_edit_registrations',
437
-                'args'       => ['cancel', true],
438
-            ],
439
-            'wait_list_registration'              => [
440
-                'func'       => 'wait_list_registration',
441
-                'noheader'   => true,
442
-                'capability' => 'ee_edit_registration',
443
-                'obj_id'     => $REG_ID,
444
-            ],
445
-            'wait_list_and_notify_registration'   => [
446
-                'func'       => 'wait_list_registration',
447
-                'noheader'   => true,
448
-                'args'       => [true],
449
-                'capability' => 'ee_edit_registration',
450
-                'obj_id'     => $REG_ID,
451
-            ],
452
-            'contact_list'                        => [
453
-                'func'       => '_attendee_contact_list_table',
454
-                'capability' => 'ee_read_contacts',
455
-            ],
456
-            'add_new_attendee'                    => [
457
-                'func' => '_create_new_cpt_item',
458
-                'args' => [
459
-                    'new_attendee' => true,
460
-                    'capability'   => 'ee_edit_contacts',
461
-                ],
462
-            ],
463
-            'edit_attendee'                       => [
464
-                'func'       => '_edit_cpt_item',
465
-                'capability' => 'ee_edit_contacts',
466
-                'obj_id'     => $ATT_ID,
467
-            ],
468
-            'duplicate_attendee'                  => [
469
-                'func'       => '_duplicate_attendee',
470
-                'noheader'   => true,
471
-                'capability' => 'ee_edit_contacts',
472
-                'obj_id'     => $ATT_ID,
473
-            ],
474
-            'insert_attendee'                     => [
475
-                'func'       => '_insert_or_update_attendee',
476
-                'args'       => [
477
-                    'new_attendee' => true,
478
-                ],
479
-                'noheader'   => true,
480
-                'capability' => 'ee_edit_contacts',
481
-            ],
482
-            'update_attendee'                     => [
483
-                'func'       => '_insert_or_update_attendee',
484
-                'args'       => [
485
-                    'new_attendee' => false,
486
-                ],
487
-                'noheader'   => true,
488
-                'capability' => 'ee_edit_contacts',
489
-                'obj_id'     => $ATT_ID,
490
-            ],
491
-            'trash_attendees'                     => [
492
-                'func'       => '_trash_or_restore_attendees',
493
-                'args'       => [
494
-                    'trash' => 'true',
495
-                ],
496
-                'noheader'   => true,
497
-                'capability' => 'ee_delete_contacts',
498
-            ],
499
-            'trash_attendee'                      => [
500
-                'func'       => '_trash_or_restore_attendees',
501
-                'args'       => [
502
-                    'trash' => true,
503
-                ],
504
-                'noheader'   => true,
505
-                'capability' => 'ee_delete_contacts',
506
-                'obj_id'     => $ATT_ID,
507
-            ],
508
-            'restore_attendees'                   => [
509
-                'func'       => '_trash_or_restore_attendees',
510
-                'args'       => [
511
-                    'trash' => false,
512
-                ],
513
-                'noheader'   => true,
514
-                'capability' => 'ee_delete_contacts',
515
-                'obj_id'     => $ATT_ID,
516
-            ],
517
-            'resend_registration'                 => [
518
-                'func'       => '_resend_registration',
519
-                'noheader'   => true,
520
-                'capability' => 'ee_send_message',
521
-            ],
522
-            'registrations_report'                => [
523
-                'func'       => '_registrations_report',
524
-                'noheader'   => true,
525
-                'capability' => 'ee_read_registrations',
526
-            ],
527
-            'contact_list_export'                 => [
528
-                'func'       => '_contact_list_export',
529
-                'noheader'   => true,
530
-                'capability' => 'export',
531
-            ],
532
-            'contact_list_report'                 => [
533
-                'func'       => '_contact_list_report',
534
-                'noheader'   => true,
535
-                'capability' => 'ee_read_contacts',
536
-            ],
537
-        ];
538
-    }
539
-
540
-
541
-    protected function _set_page_config()
542
-    {
543
-        $REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
544
-        $ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
545
-        $this->_page_config = [
546
-            'default'           => [
547
-                'nav'           => [
548
-                    'label' => esc_html__('Overview', 'event_espresso'),
549
-                    'order' => 5,
550
-                ],
551
-                'help_tabs'     => [
552
-                    'registrations_overview_help_tab'                       => [
553
-                        'title'    => esc_html__('Registrations Overview', 'event_espresso'),
554
-                        'filename' => 'registrations_overview',
555
-                    ],
556
-                    'registrations_overview_table_column_headings_help_tab' => [
557
-                        'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
558
-                        'filename' => 'registrations_overview_table_column_headings',
559
-                    ],
560
-                    'registrations_overview_filters_help_tab'               => [
561
-                        'title'    => esc_html__('Registration Filters', 'event_espresso'),
562
-                        'filename' => 'registrations_overview_filters',
563
-                    ],
564
-                    'registrations_overview_views_help_tab'                 => [
565
-                        'title'    => esc_html__('Registration Views', 'event_espresso'),
566
-                        'filename' => 'registrations_overview_views',
567
-                    ],
568
-                    'registrations_regoverview_other_help_tab'              => [
569
-                        'title'    => esc_html__('Registrations Other', 'event_espresso'),
570
-                        'filename' => 'registrations_overview_other',
571
-                    ],
572
-                ],
573
-                'list_table'    => 'EE_Registrations_List_Table',
574
-                'require_nonce' => false,
575
-            ],
576
-            'view_registration' => [
577
-                'nav'           => [
578
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
579
-                    'order'      => 15,
580
-                    'url'        => $REG_ID
581
-                        ? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
582
-                        : $this->_admin_base_url,
583
-                    'persistent' => false,
584
-                ],
585
-                'help_tabs'     => [
586
-                    'registrations_details_help_tab'                    => [
587
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
588
-                        'filename' => 'registrations_details',
589
-                    ],
590
-                    'registrations_details_table_help_tab'              => [
591
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
592
-                        'filename' => 'registrations_details_table',
593
-                    ],
594
-                    'registrations_details_form_answers_help_tab'       => [
595
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
596
-                        'filename' => 'registrations_details_form_answers',
597
-                    ],
598
-                    'registrations_details_registrant_details_help_tab' => [
599
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
600
-                        'filename' => 'registrations_details_registrant_details',
601
-                    ],
602
-                ],
603
-                'metaboxes'     => array_merge(
604
-                    $this->_default_espresso_metaboxes,
605
-                    ['_registration_details_metaboxes']
606
-                ),
607
-                'require_nonce' => false,
608
-            ],
609
-            'new_registration'  => [
610
-                'nav'           => [
611
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
612
-                    'url'        => '#',
613
-                    'order'      => 15,
614
-                    'persistent' => false,
615
-                ],
616
-                'metaboxes'     => $this->_default_espresso_metaboxes,
617
-                'labels'        => [
618
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
619
-                ],
620
-                'require_nonce' => false,
621
-            ],
622
-            'add_new_attendee'  => [
623
-                'nav'           => [
624
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
625
-                    'order'      => 15,
626
-                    'persistent' => false,
627
-                ],
628
-                'metaboxes'     => array_merge(
629
-                    $this->_default_espresso_metaboxes,
630
-                    ['_publish_post_box', 'attendee_editor_metaboxes']
631
-                ),
632
-                'require_nonce' => false,
633
-            ],
634
-            'edit_attendee'     => [
635
-                'nav'           => [
636
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
637
-                    'order'      => 15,
638
-                    'persistent' => false,
639
-                    'url'        => $ATT_ID
640
-                        ? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
641
-                        : $this->_admin_base_url,
642
-                ],
643
-                'metaboxes'     => array_merge(
644
-                    $this->_default_espresso_metaboxes,
645
-                    ['attendee_editor_metaboxes']
646
-                ),
647
-                'require_nonce' => false,
648
-            ],
649
-            'contact_list'      => [
650
-                'nav'           => [
651
-                    'label' => esc_html__('Contact List', 'event_espresso'),
652
-                    'order' => 20,
653
-                ],
654
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
655
-                'help_tabs'     => [
656
-                    'registrations_contact_list_help_tab'                       => [
657
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
658
-                        'filename' => 'registrations_contact_list',
659
-                    ],
660
-                    'registrations_contact-list_table_column_headings_help_tab' => [
661
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
662
-                        'filename' => 'registrations_contact_list_table_column_headings',
663
-                    ],
664
-                    'registrations_contact_list_views_help_tab'                 => [
665
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
666
-                        'filename' => 'registrations_contact_list_views',
667
-                    ],
668
-                    'registrations_contact_list_other_help_tab'                 => [
669
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
670
-                        'filename' => 'registrations_contact_list_other',
671
-                    ],
672
-                ],
673
-                'metaboxes'     => [],
674
-                'require_nonce' => false,
675
-            ],
676
-            // override default cpt routes
677
-            'create_new'        => '',
678
-            'edit'              => '',
679
-        ];
680
-    }
681
-
682
-
683
-    /**
684
-     * The below methods aren't used by this class currently
685
-     */
686
-    protected function _add_screen_options()
687
-    {
688
-    }
689
-
690
-
691
-    protected function _add_feature_pointers()
692
-    {
693
-    }
694
-
695
-
696
-    public function admin_init()
697
-    {
698
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
699
-            'click "Update Registration Questions" to save your changes',
700
-            'event_espresso'
701
-        );
702
-    }
703
-
704
-
705
-    public function admin_notices()
706
-    {
707
-    }
708
-
709
-
710
-    public function admin_footer_scripts()
711
-    {
712
-    }
713
-
714
-
715
-    /**
716
-     * get list of registration statuses
717
-     *
718
-     * @return void
719
-     * @throws EE_Error
720
-     */
721
-    private function _get_registration_status_array()
722
-    {
723
-        self::$_reg_status = EEM_Registration::reg_status_array([], true);
724
-    }
725
-
726
-
727
-    /**
728
-     * @throws InvalidArgumentException
729
-     * @throws InvalidDataTypeException
730
-     * @throws InvalidInterfaceException
731
-     * @since 4.10.2.p
732
-     */
733
-    protected function _add_screen_options_default()
734
-    {
735
-        $this->_per_page_screen_option();
736
-    }
737
-
738
-
739
-    /**
740
-     * @throws InvalidArgumentException
741
-     * @throws InvalidDataTypeException
742
-     * @throws InvalidInterfaceException
743
-     * @since 4.10.2.p
744
-     */
745
-    protected function _add_screen_options_contact_list()
746
-    {
747
-        $page_title              = $this->_admin_page_title;
748
-        $this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
749
-        $this->_per_page_screen_option();
750
-        $this->_admin_page_title = $page_title;
751
-    }
752
-
753
-
754
-    public function load_scripts_styles()
755
-    {
756
-        // style
757
-        wp_register_style(
758
-            'espresso_reg',
759
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
760
-            ['ee-admin-css'],
761
-            EVENT_ESPRESSO_VERSION
762
-        );
763
-        wp_enqueue_style('espresso_reg');
764
-        // script
765
-        wp_register_script(
766
-            'espresso_reg',
767
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
768
-            ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
769
-            EVENT_ESPRESSO_VERSION,
770
-            true
771
-        );
772
-        wp_enqueue_script('espresso_reg');
773
-    }
774
-
775
-
776
-    /**
777
-     * @throws EE_Error
778
-     * @throws InvalidArgumentException
779
-     * @throws InvalidDataTypeException
780
-     * @throws InvalidInterfaceException
781
-     * @throws ReflectionException
782
-     * @since 4.10.2.p
783
-     */
784
-    public function load_scripts_styles_edit_attendee()
785
-    {
786
-        // stuff to only show up on our attendee edit details page.
787
-        $attendee_details_translations = [
788
-            'att_publish_text' => sprintf(
789
-            /* translators: The date and time */
790
-                wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
791
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
792
-            ),
793
-        ];
794
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
795
-        wp_enqueue_script('jquery-validate');
796
-    }
797
-
798
-
799
-    /**
800
-     * @throws EE_Error
801
-     * @throws InvalidArgumentException
802
-     * @throws InvalidDataTypeException
803
-     * @throws InvalidInterfaceException
804
-     * @throws ReflectionException
805
-     * @since 4.10.2.p
806
-     */
807
-    public function load_scripts_styles_view_registration()
808
-    {
809
-        // styles
810
-        wp_enqueue_style('espresso-ui-theme');
811
-        // scripts
812
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
813
-        $this->_reg_custom_questions_form->wp_enqueue_scripts();
814
-    }
815
-
816
-
817
-    public function load_scripts_styles_contact_list()
818
-    {
819
-        wp_dequeue_style('espresso_reg');
820
-        wp_register_style(
821
-            'espresso_att',
822
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
823
-            ['ee-admin-css'],
824
-            EVENT_ESPRESSO_VERSION
825
-        );
826
-        wp_enqueue_style('espresso_att');
827
-    }
828
-
829
-
830
-    public function load_scripts_styles_new_registration()
831
-    {
832
-        wp_register_script(
833
-            'ee-spco-for-admin',
834
-            REG_ASSETS_URL . 'spco_for_admin.js',
835
-            ['underscore', 'jquery'],
836
-            EVENT_ESPRESSO_VERSION,
837
-            true
838
-        );
839
-        wp_enqueue_script('ee-spco-for-admin');
840
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
841
-        EE_Form_Section_Proper::wp_enqueue_scripts();
842
-        EED_Ticket_Selector::load_tckt_slctr_assets();
843
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
844
-    }
845
-
846
-
847
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
848
-    {
849
-        add_filter('FHEE_load_EE_messages', '__return_true');
850
-    }
851
-
852
-
853
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
854
-    {
855
-        add_filter('FHEE_load_EE_messages', '__return_true');
856
-    }
857
-
858
-
859
-    /**
860
-     * @throws EE_Error
861
-     * @throws InvalidArgumentException
862
-     * @throws InvalidDataTypeException
863
-     * @throws InvalidInterfaceException
864
-     * @throws ReflectionException
865
-     * @since 4.10.2.p
866
-     */
867
-    protected function _set_list_table_views_default()
868
-    {
869
-        // for notification related bulk actions we need to make sure only active messengers have an option.
870
-        EED_Messages::set_autoloaders();
871
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
872
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
873
-        $active_mts               = $message_resource_manager->list_of_active_message_types();
874
-        // key= bulk_action_slug, value= message type.
875
-        $match_array = [
876
-            'approve_registrations'    => 'registration',
877
-            'decline_registrations'    => 'declined_registration',
878
-            'pending_registrations'    => 'pending_approval',
879
-            'no_approve_registrations' => 'not_approved_registration',
880
-            'cancel_registrations'     => 'cancelled_registration',
881
-        ];
882
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
883
-            'ee_send_message',
884
-            'batch_send_messages'
885
-        );
886
-        /** setup reg status bulk actions **/
887
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
888
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
889
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
890
-                'Approve and Notify Registrations',
891
-                'event_espresso'
892
-            );
893
-        }
894
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
895
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
896
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
897
-                'Decline and Notify Registrations',
898
-                'event_espresso'
899
-            );
900
-        }
901
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
902
-            'Set Registrations to Pending Payment',
903
-            'event_espresso'
904
-        );
905
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
906
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
907
-                'Set Registrations to Pending Payment and Notify',
908
-                'event_espresso'
909
-            );
910
-        }
911
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
912
-            'Set Registrations to Not Approved',
913
-            'event_espresso'
914
-        );
915
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
916
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
917
-                'Set Registrations to Not Approved and Notify',
918
-                'event_espresso'
919
-            );
920
-        }
921
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
922
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
923
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
924
-                'Cancel Registrations and Notify',
925
-                'event_espresso'
926
-            );
927
-        }
928
-        $def_reg_status_actions = apply_filters(
929
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
930
-            $def_reg_status_actions,
931
-            $active_mts,
932
-            $can_send
933
-        );
934
-
935
-        $this->_views = [
936
-            'all'   => [
937
-                'slug'        => 'all',
938
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
939
-                'count'       => 0,
940
-                'bulk_action' => array_merge(
941
-                    $def_reg_status_actions,
942
-                    [
943
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
944
-                    ]
945
-                ),
946
-            ],
947
-            'month' => [
948
-                'slug'        => 'month',
949
-                'label'       => esc_html__('This Month', 'event_espresso'),
950
-                'count'       => 0,
951
-                'bulk_action' => array_merge(
952
-                    $def_reg_status_actions,
953
-                    [
954
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
955
-                    ]
956
-                ),
957
-            ],
958
-            'today' => [
959
-                'slug'        => 'today',
960
-                'label'       => sprintf(
961
-                    esc_html__('Today - %s', 'event_espresso'),
962
-                    date('M d, Y', current_time('timestamp'))
963
-                ),
964
-                'count'       => 0,
965
-                'bulk_action' => array_merge(
966
-                    $def_reg_status_actions,
967
-                    [
968
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
969
-                    ]
970
-                ),
971
-            ],
972
-        ];
973
-        if (
974
-            EE_Registry::instance()->CAP->current_user_can(
975
-                'ee_delete_registrations',
976
-                'espresso_registrations_delete_registration'
977
-            )
978
-        ) {
979
-            $this->_views['incomplete'] = [
980
-                'slug'        => 'incomplete',
981
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
982
-                'count'       => 0,
983
-                'bulk_action' => [
984
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
985
-                ],
986
-            ];
987
-            $this->_views['trash']      = [
988
-                'slug'        => 'trash',
989
-                'label'       => esc_html__('Trash', 'event_espresso'),
990
-                'count'       => 0,
991
-                'bulk_action' => [
992
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
993
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
994
-                ],
995
-            ];
996
-        }
997
-    }
998
-
999
-
1000
-    protected function _set_list_table_views_contact_list()
1001
-    {
1002
-        $this->_views = [
1003
-            'in_use' => [
1004
-                'slug'        => 'in_use',
1005
-                'label'       => esc_html__('In Use', 'event_espresso'),
1006
-                'count'       => 0,
1007
-                'bulk_action' => [
1008
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1009
-                ],
1010
-            ],
1011
-        ];
1012
-        if (
1013
-            EE_Registry::instance()->CAP->current_user_can(
1014
-                'ee_delete_contacts',
1015
-                'espresso_registrations_trash_attendees'
1016
-            )
1017
-        ) {
1018
-            $this->_views['trash'] = [
1019
-                'slug'        => 'trash',
1020
-                'label'       => esc_html__('Trash', 'event_espresso'),
1021
-                'count'       => 0,
1022
-                'bulk_action' => [
1023
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1024
-                ],
1025
-            ];
1026
-        }
1027
-    }
1028
-
1029
-
1030
-    /**
1031
-     * @return array
1032
-     * @throws EE_Error
1033
-     */
1034
-    protected function _registration_legend_items()
1035
-    {
1036
-        $fc_items = [
1037
-            'star-icon'        => [
1038
-                'class' => 'dashicons dashicons-star-filled gold-icon',
1039
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1040
-            ],
1041
-            'view_details'     => [
1042
-                'class' => 'dashicons dashicons-clipboard',
1043
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1044
-            ],
1045
-            'edit_attendee'    => [
1046
-                'class' => 'dashicons dashicons-admin-users',
1047
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1048
-            ],
1049
-            'view_transaction' => [
1050
-                'class' => 'dashicons dashicons-cart',
1051
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1052
-            ],
1053
-            'view_invoice'     => [
1054
-                'class' => 'dashicons dashicons-media-spreadsheet',
1055
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1056
-            ],
1057
-        ];
1058
-        if (
1059
-            EE_Registry::instance()->CAP->current_user_can(
1060
-                'ee_send_message',
1061
-                'espresso_registrations_resend_registration'
1062
-            )
1063
-        ) {
1064
-            $fc_items['resend_registration'] = [
1065
-                'class' => 'dashicons dashicons-email-alt',
1066
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1067
-            ];
1068
-        } else {
1069
-            $fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1070
-        }
1071
-        if (
1072
-            EE_Registry::instance()->CAP->current_user_can(
1073
-                'ee_read_global_messages',
1074
-                'view_filtered_messages'
1075
-            )
1076
-        ) {
1077
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1078
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1079
-                $fc_items['view_related_messages'] = [
1080
-                    'class' => $related_for_icon['css_class'],
1081
-                    'desc'  => $related_for_icon['label'],
1082
-                ];
1083
-            }
1084
-        }
1085
-        $sc_items = [
1086
-            'approved_status'   => [
1087
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1088
-                'desc'  => EEH_Template::pretty_status(
1089
-                    EEM_Registration::status_id_approved,
1090
-                    false,
1091
-                    'sentence'
1092
-                ),
1093
-            ],
1094
-            'pending_status'    => [
1095
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1096
-                'desc'  => EEH_Template::pretty_status(
1097
-                    EEM_Registration::status_id_pending_payment,
1098
-                    false,
1099
-                    'sentence'
1100
-                ),
1101
-            ],
1102
-            'wait_list'         => [
1103
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1104
-                'desc'  => EEH_Template::pretty_status(
1105
-                    EEM_Registration::status_id_wait_list,
1106
-                    false,
1107
-                    'sentence'
1108
-                ),
1109
-            ],
1110
-            'incomplete_status' => [
1111
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_incomplete,
1112
-                'desc'  => EEH_Template::pretty_status(
1113
-                    EEM_Registration::status_id_incomplete,
1114
-                    false,
1115
-                    'sentence'
1116
-                ),
1117
-            ],
1118
-            'not_approved'      => [
1119
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1120
-                'desc'  => EEH_Template::pretty_status(
1121
-                    EEM_Registration::status_id_not_approved,
1122
-                    false,
1123
-                    'sentence'
1124
-                ),
1125
-            ],
1126
-            'declined_status'   => [
1127
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1128
-                'desc'  => EEH_Template::pretty_status(
1129
-                    EEM_Registration::status_id_declined,
1130
-                    false,
1131
-                    'sentence'
1132
-                ),
1133
-            ],
1134
-            'cancelled_status'  => [
1135
-                'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1136
-                'desc'  => EEH_Template::pretty_status(
1137
-                    EEM_Registration::status_id_cancelled,
1138
-                    false,
1139
-                    'sentence'
1140
-                ),
1141
-            ],
1142
-        ];
1143
-        return array_merge($fc_items, $sc_items);
1144
-    }
1145
-
1146
-
1147
-
1148
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1149
-
1150
-
1151
-    /**
1152
-     * @throws DomainException
1153
-     * @throws EE_Error
1154
-     * @throws InvalidArgumentException
1155
-     * @throws InvalidDataTypeException
1156
-     * @throws InvalidInterfaceException
1157
-     */
1158
-    protected function _registrations_overview_list_table()
1159
-    {
1160
-        $this->appendAddNewRegistrationButtonToPageTitle();
1161
-        $header_text                  = '';
1162
-        $admin_page_header_decorators = [
1163
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1164
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1165
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1166
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1167
-        ];
1168
-        foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1169
-            $filter_header_decorator = $this->loader->getNew($admin_page_header_decorator);
1170
-            $header_text = $filter_header_decorator->getHeaderText($header_text);
1171
-        }
1172
-        $this->_template_args['admin_page_header'] = $header_text;
1173
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1174
-        $this->display_admin_list_table_page_with_no_sidebar();
1175
-    }
1176
-
1177
-
1178
-    /**
1179
-     * @throws EE_Error
1180
-     * @throws InvalidArgumentException
1181
-     * @throws InvalidDataTypeException
1182
-     * @throws InvalidInterfaceException
1183
-     */
1184
-    private function appendAddNewRegistrationButtonToPageTitle()
1185
-    {
1186
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1187
-        if (
1188
-            $EVT_ID
1189
-            && EE_Registry::instance()->CAP->current_user_can(
1190
-                'ee_edit_registrations',
1191
-                'espresso_registrations_new_registration',
1192
-                $EVT_ID
1193
-            )
1194
-        ) {
1195
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1196
-                'new_registration',
1197
-                'add-registrant',
1198
-                ['event_id' => $EVT_ID],
1199
-                'add-new-h2'
1200
-            );
1201
-        }
1202
-    }
1203
-
1204
-
1205
-    /**
1206
-     * This sets the _registration property for the registration details screen
1207
-     *
1208
-     * @return void
1209
-     * @throws EE_Error
1210
-     * @throws InvalidArgumentException
1211
-     * @throws InvalidDataTypeException
1212
-     * @throws InvalidInterfaceException
1213
-     */
1214
-    private function _set_registration_object()
1215
-    {
1216
-        // get out if we've already set the object
1217
-        if ($this->_registration instanceof EE_Registration) {
1218
-            return;
1219
-        }
1220
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1221
-        if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1222
-            return;
1223
-        }
1224
-        $error_msg = sprintf(
1225
-            esc_html__(
1226
-                'An error occurred and the details for Registration ID #%s could not be retrieved.',
1227
-                'event_espresso'
1228
-            ),
1229
-            $REG_ID
1230
-        );
1231
-        EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1232
-        $this->_registration = null;
1233
-    }
1234
-
1235
-
1236
-    /**
1237
-     * Used to retrieve registrations for the list table.
1238
-     *
1239
-     * @param int  $per_page
1240
-     * @param bool $count
1241
-     * @param bool $this_month
1242
-     * @param bool $today
1243
-     * @return EE_Registration[]|int
1244
-     * @throws EE_Error
1245
-     * @throws InvalidArgumentException
1246
-     * @throws InvalidDataTypeException
1247
-     * @throws InvalidInterfaceException
1248
-     */
1249
-    public function get_registrations(
1250
-        $per_page = 10,
1251
-        $count = false,
1252
-        $this_month = false,
1253
-        $today = false
1254
-    ) {
1255
-        if ($this_month) {
1256
-            $this->request->setRequestParam('status', 'month');
1257
-        }
1258
-        if ($today) {
1259
-            $this->request->setRequestParam('status', 'today');
1260
-        }
1261
-        $query_params = $this->_get_registration_query_parameters($this->request->requestParams(), $per_page, $count);
1262
-        /**
1263
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1264
-         *
1265
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1266
-         * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1267
-         *                      or if you have the development copy of EE you can view this at the path:
1268
-         *                      /docs/G--Model-System/model-query-params.md
1269
-         */
1270
-        $query_params['group_by'] = '';
1271
-
1272
-        return $count
1273
-            ? $this->getRegistrationModel()->count($query_params)
1274
-            /** @type EE_Registration[] */
1275
-            : $this->getRegistrationModel()->get_all($query_params);
1276
-    }
1277
-
1278
-
1279
-    /**
1280
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1281
-     * Note: this listens to values on the request for some of the query parameters.
1282
-     *
1283
-     * @param array $request
1284
-     * @param int   $per_page
1285
-     * @param bool  $count
1286
-     * @return array
1287
-     * @throws EE_Error
1288
-     * @throws InvalidArgumentException
1289
-     * @throws InvalidDataTypeException
1290
-     * @throws InvalidInterfaceException
1291
-     */
1292
-    protected function _get_registration_query_parameters(
1293
-        $request = [],
1294
-        $per_page = 10,
1295
-        $count = false
1296
-    ) {
1297
-        /** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1298
-        $list_table_query_builder = $this->loader->getNew(
1299
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1300
-            [null, null, $request]
1301
-        );
1302
-        return $list_table_query_builder->getQueryParams($per_page, $count);
1303
-    }
1304
-
1305
-
1306
-    public function get_registration_status_array()
1307
-    {
1308
-        return self::$_reg_status;
1309
-    }
1310
-
1311
-
1312
-
1313
-
1314
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1315
-    /**
1316
-     * generates HTML for the View Registration Details Admin page
1317
-     *
1318
-     * @return void
1319
-     * @throws DomainException
1320
-     * @throws EE_Error
1321
-     * @throws InvalidArgumentException
1322
-     * @throws InvalidDataTypeException
1323
-     * @throws InvalidInterfaceException
1324
-     * @throws EntityNotFoundException
1325
-     * @throws ReflectionException
1326
-     */
1327
-    protected function _registration_details()
1328
-    {
1329
-        $this->_template_args = [];
1330
-        $this->_set_registration_object();
1331
-        if (is_object($this->_registration)) {
1332
-            $transaction                                   = $this->_registration->transaction()
1333
-                ? $this->_registration->transaction()
1334
-                : EE_Transaction::new_instance();
1335
-            $this->_session                                = $transaction->session_data();
1336
-            $event_id                                      = $this->_registration->event_ID();
1337
-            $this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1338
-            $this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1339
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1340
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1341
-            $this->_template_args['grand_total']           = $transaction->total();
1342
-            $this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1343
-            // link back to overview
1344
-            $this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1345
-            $this->_template_args['registration']                = $this->_registration;
1346
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1347
-                [
1348
-                    'action'   => 'default',
1349
-                    'event_id' => $event_id,
1350
-                ],
1351
-                REG_ADMIN_URL
1352
-            );
1353
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1354
-                [
1355
-                    'action' => 'default',
1356
-                    'EVT_ID' => $event_id,
1357
-                    'page'   => 'espresso_transactions',
1358
-                ],
1359
-                admin_url('admin.php')
1360
-            );
1361
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1362
-                [
1363
-                    'page'   => 'espresso_events',
1364
-                    'action' => 'edit',
1365
-                    'post'   => $event_id,
1366
-                ],
1367
-                admin_url('admin.php')
1368
-            );
1369
-            // next and previous links
1370
-            $next_reg                                      = $this->_registration->next(
1371
-                null,
1372
-                [],
1373
-                'REG_ID'
1374
-            );
1375
-            $this->_template_args['next_registration']     = $next_reg
1376
-                ? $this->_next_link(
1377
-                    EE_Admin_Page::add_query_args_and_nonce(
1378
-                        [
1379
-                            'action'  => 'view_registration',
1380
-                            '_REG_ID' => $next_reg['REG_ID'],
1381
-                        ],
1382
-                        REG_ADMIN_URL
1383
-                    ),
1384
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1385
-                )
1386
-                : '';
1387
-            $previous_reg                                  = $this->_registration->previous(
1388
-                null,
1389
-                [],
1390
-                'REG_ID'
1391
-            );
1392
-            $this->_template_args['previous_registration'] = $previous_reg
1393
-                ? $this->_previous_link(
1394
-                    EE_Admin_Page::add_query_args_and_nonce(
1395
-                        [
1396
-                            'action'  => 'view_registration',
1397
-                            '_REG_ID' => $previous_reg['REG_ID'],
1398
-                        ],
1399
-                        REG_ADMIN_URL
1400
-                    ),
1401
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1402
-                )
1403
-                : '';
1404
-            // grab header
1405
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1406
-            $this->_template_args['REG_ID']            = $this->_registration->ID();
1407
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1408
-                $template_path,
1409
-                $this->_template_args,
1410
-                true
1411
-            );
1412
-        } else {
1413
-            $this->_template_args['admin_page_header'] = '';
1414
-            $this->_display_espresso_notices();
1415
-        }
1416
-        // the details template wrapper
1417
-        $this->display_admin_page_with_sidebar();
1418
-    }
1419
-
1420
-
1421
-    /**
1422
-     * @throws EE_Error
1423
-     * @throws InvalidArgumentException
1424
-     * @throws InvalidDataTypeException
1425
-     * @throws InvalidInterfaceException
1426
-     * @throws ReflectionException
1427
-     * @since 4.10.2.p
1428
-     */
1429
-    protected function _registration_details_metaboxes()
1430
-    {
1431
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1432
-        $this->_set_registration_object();
1433
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1434
-        $this->addMetaBox(
1435
-            'edit-reg-status-mbox',
1436
-            esc_html__('Registration Status', 'event_espresso'),
1437
-            [$this, 'set_reg_status_buttons_metabox'],
1438
-            $this->_wp_page_slug
1439
-        );
1440
-        $this->addMetaBox(
1441
-            'edit-reg-details-mbox',
1442
-            '<span>' . esc_html__('Registration Details', 'event_espresso')
1443
-            . '&nbsp;<span class="dashicons dashicons-clipboard"></span></span>',
1444
-            [$this, '_reg_details_meta_box'],
1445
-            $this->_wp_page_slug
1446
-        );
1447
-        if (
1448
-            $attendee instanceof EE_Attendee
1449
-            && EE_Registry::instance()->CAP->current_user_can(
1450
-                'ee_read_registration',
1451
-                'edit-reg-questions-mbox',
1452
-                $this->_registration->ID()
1453
-            )
1454
-        ) {
1455
-            $this->addMetaBox(
1456
-                'edit-reg-questions-mbox',
1457
-                esc_html__('Registration Form Answers', 'event_espresso'),
1458
-                [$this, '_reg_questions_meta_box'],
1459
-                $this->_wp_page_slug
1460
-            );
1461
-        }
1462
-        $this->addMetaBox(
1463
-            'edit-reg-registrant-mbox',
1464
-            esc_html__('Contact Details', 'event_espresso'),
1465
-            [$this, '_reg_registrant_side_meta_box'],
1466
-            $this->_wp_page_slug,
1467
-            'side'
1468
-        );
1469
-        if ($this->_registration->group_size() > 1) {
1470
-            $this->addMetaBox(
1471
-                'edit-reg-attendees-mbox',
1472
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1473
-                [$this, '_reg_attendees_meta_box'],
1474
-                $this->_wp_page_slug
1475
-            );
1476
-        }
1477
-    }
1478
-
1479
-
1480
-    /**
1481
-     * set_reg_status_buttons_metabox
1482
-     *
1483
-     * @return void
1484
-     * @throws EE_Error
1485
-     * @throws EntityNotFoundException
1486
-     * @throws InvalidArgumentException
1487
-     * @throws InvalidDataTypeException
1488
-     * @throws InvalidInterfaceException
1489
-     * @throws ReflectionException
1490
-     */
1491
-    public function set_reg_status_buttons_metabox()
1492
-    {
1493
-        $this->_set_registration_object();
1494
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1495
-        $output                 = $change_reg_status_form->form_open(
1496
-            self::add_query_args_and_nonce(
1497
-                [
1498
-                    'action' => 'change_reg_status',
1499
-                ],
1500
-                REG_ADMIN_URL
1501
-            )
1502
-        );
1503
-        $output                 .= $change_reg_status_form->get_html();
1504
-        $output                 .= $change_reg_status_form->form_close();
1505
-        echo wp_kses($output, AllowedTags::getWithFormTags());
1506
-    }
1507
-
1508
-
1509
-    /**
1510
-     * @return EE_Form_Section_Proper
1511
-     * @throws EE_Error
1512
-     * @throws InvalidArgumentException
1513
-     * @throws InvalidDataTypeException
1514
-     * @throws InvalidInterfaceException
1515
-     * @throws EntityNotFoundException
1516
-     * @throws ReflectionException
1517
-     */
1518
-    protected function _generate_reg_status_change_form()
1519
-    {
1520
-        $reg_status_change_form_array = [
1521
-            'name'            => 'reg_status_change_form',
1522
-            'html_id'         => 'reg-status-change-form',
1523
-            'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1524
-            'subsections'     => [
1525
-                'return'         => new EE_Hidden_Input(
1526
-                    [
1527
-                        'name'    => 'return',
1528
-                        'default' => 'view_registration',
1529
-                    ]
1530
-                ),
1531
-                'REG_ID'         => new EE_Hidden_Input(
1532
-                    [
1533
-                        'name'    => 'REG_ID',
1534
-                        'default' => $this->_registration->ID(),
1535
-                    ]
1536
-                ),
1537
-            ],
1538
-        ];
1539
-        if (
1540
-            EE_Registry::instance()->CAP->current_user_can(
1541
-                'ee_edit_registration',
1542
-                'toggle_registration_status',
1543
-                $this->_registration->ID()
1544
-            )
1545
-        ) {
1546
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1547
-                $this->_get_reg_statuses(),
1548
-                [
1549
-                    'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1550
-                    'default'         => $this->_registration->status_ID(),
1551
-                ]
1552
-            );
1553
-            $reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1554
-                [
1555
-                    'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1556
-                    'default'         => false,
1557
-                    'html_help_text'  => esc_html__(
1558
-                        'If set to "Yes", then the related messages will be sent to the registrant.',
1559
-                        'event_espresso'
1560
-                    ),
1561
-                ]
1562
-            );
1563
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1564
-                [
1565
-                    'html_class'      => 'button--primary',
1566
-                    'html_label_text' => '&nbsp;',
1567
-                    'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1568
-                ]
1569
-            );
1570
-        }
1571
-        return new EE_Form_Section_Proper($reg_status_change_form_array);
1572
-    }
1573
-
1574
-
1575
-    /**
1576
-     * Returns an array of all the buttons for the various statuses and switch status actions
1577
-     *
1578
-     * @return array
1579
-     * @throws EE_Error
1580
-     * @throws InvalidArgumentException
1581
-     * @throws InvalidDataTypeException
1582
-     * @throws InvalidInterfaceException
1583
-     * @throws EntityNotFoundException
1584
-     */
1585
-    protected function _get_reg_statuses()
1586
-    {
1587
-        $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1588
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1589
-        // get current reg status
1590
-        $current_status = $this->_registration->status_ID();
1591
-        // is registration for free event? This will determine whether to display the pending payment option
1592
-        if (
1593
-            $current_status !== EEM_Registration::status_id_pending_payment
1594
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1595
-        ) {
1596
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1597
-        }
1598
-        return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1599
-    }
1600
-
1601
-
1602
-    /**
1603
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1604
-     *
1605
-     * @param bool $status REG status given for changing registrations to.
1606
-     * @param bool $notify Whether to send messages notifications or not.
1607
-     * @return array (array with reg_id(s) updated and whether update was successful.
1608
-     * @throws DomainException
1609
-     * @throws EE_Error
1610
-     * @throws EntityNotFoundException
1611
-     * @throws InvalidArgumentException
1612
-     * @throws InvalidDataTypeException
1613
-     * @throws InvalidInterfaceException
1614
-     * @throws ReflectionException
1615
-     * @throws RuntimeException
1616
-     */
1617
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1618
-    {
1619
-        $REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1620
-            ? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1621
-            : $this->request->getRequestParam('_REG_ID', [], 'int', true);
1622
-
1623
-        // sanitize $REG_IDs
1624
-        $REG_IDs = array_map('absint', $REG_IDs);
1625
-        // and remove empty entries
1626
-        $REG_IDs = array_filter($REG_IDs);
1627
-
1628
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1629
-
1630
-        /**
1631
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1632
-         * Currently this value is used downstream by the _process_resend_registration method.
1633
-         *
1634
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1635
-         * @param bool                     $status           The status registrations were changed to.
1636
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1637
-         * @param Registrations_Admin_Page $admin_page_object
1638
-         */
1639
-        $REG_ID = apply_filters(
1640
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1641
-            $result['REG_ID'],
1642
-            $status,
1643
-            $result['success'],
1644
-            $this
1645
-        );
1646
-        $this->request->setRequestParam('_REG_ID', $REG_ID);
1647
-
1648
-        // notify?
1649
-        if (
1650
-            $notify
1651
-            && $result['success']
1652
-            && ! empty($REG_ID)
1653
-            && EE_Registry::instance()->CAP->current_user_can(
1654
-                'ee_send_message',
1655
-                'espresso_registrations_resend_registration'
1656
-            )
1657
-        ) {
1658
-            $this->_process_resend_registration();
1659
-        }
1660
-        return $result;
1661
-    }
1662
-
1663
-
1664
-    /**
1665
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1666
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1667
-     *
1668
-     * @param array  $REG_IDs
1669
-     * @param string $status
1670
-     * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1671
-     *                       slug sent with setting the registration status.
1672
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1673
-     * @throws EE_Error
1674
-     * @throws InvalidArgumentException
1675
-     * @throws InvalidDataTypeException
1676
-     * @throws InvalidInterfaceException
1677
-     * @throws ReflectionException
1678
-     * @throws RuntimeException
1679
-     * @throws EntityNotFoundException
1680
-     * @throws DomainException
1681
-     */
1682
-    protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1683
-    {
1684
-        $success = false;
1685
-        // typecast $REG_IDs
1686
-        $REG_IDs = (array) $REG_IDs;
1687
-        if (! empty($REG_IDs)) {
1688
-            $success = true;
1689
-            // set default status if none is passed
1690
-            $status         = $status ?: EEM_Registration::status_id_pending_payment;
1691
-            $status_context = $notify
1692
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1693
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1694
-            // loop through REG_ID's and change status
1695
-            foreach ($REG_IDs as $REG_ID) {
1696
-                $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1697
-                if ($registration instanceof EE_Registration) {
1698
-                    $registration->set_status(
1699
-                        $status,
1700
-                        false,
1701
-                        new Context(
1702
-                            $status_context,
1703
-                            esc_html__(
1704
-                                'Manually triggered status change on a Registration Admin Page route.',
1705
-                                'event_espresso'
1706
-                            )
1707
-                        )
1708
-                    );
1709
-                    $result = $registration->save();
1710
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1711
-                    $success = $result !== false ? $success : false;
1712
-                }
1713
-            }
1714
-        }
1715
-
1716
-        // return $success and processed registrations
1717
-        return ['REG_ID' => $REG_IDs, 'success' => $success];
1718
-    }
1719
-
1720
-
1721
-    /**
1722
-     * Common logic for setting up success message and redirecting to appropriate route
1723
-     *
1724
-     * @param string $STS_ID status id for the registration changed to
1725
-     * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1726
-     * @return void
1727
-     * @throws DomainException
1728
-     * @throws EE_Error
1729
-     * @throws EntityNotFoundException
1730
-     * @throws InvalidArgumentException
1731
-     * @throws InvalidDataTypeException
1732
-     * @throws InvalidInterfaceException
1733
-     * @throws ReflectionException
1734
-     * @throws RuntimeException
1735
-     */
1736
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1737
-    {
1738
-        $result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1739
-            : ['success' => false];
1740
-        $success = isset($result['success']) && $result['success'];
1741
-        // setup success message
1742
-        if ($success) {
1743
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1744
-                $msg = sprintf(
1745
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1746
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1747
-                );
1748
-            } else {
1749
-                $msg = sprintf(
1750
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
1751
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1752
-                );
1753
-            }
1754
-            EE_Error::add_success($msg);
1755
-        } else {
1756
-            EE_Error::add_error(
1757
-                esc_html__(
1758
-                    'Something went wrong, and the status was not changed',
1759
-                    'event_espresso'
1760
-                ),
1761
-                __FILE__,
1762
-                __LINE__,
1763
-                __FUNCTION__
1764
-            );
1765
-        }
1766
-        $return = $this->request->getRequestParam('return');
1767
-        $route  = $return === 'view_registration'
1768
-            ? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1769
-            : ['action' => 'default'];
1770
-        $route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1771
-        $this->_redirect_after_action($success, '', '', $route, true);
1772
-    }
1773
-
1774
-
1775
-    /**
1776
-     * incoming reg status change from reg details page.
1777
-     *
1778
-     * @return void
1779
-     * @throws EE_Error
1780
-     * @throws EntityNotFoundException
1781
-     * @throws InvalidArgumentException
1782
-     * @throws InvalidDataTypeException
1783
-     * @throws InvalidInterfaceException
1784
-     * @throws ReflectionException
1785
-     * @throws RuntimeException
1786
-     * @throws DomainException
1787
-     */
1788
-    protected function _change_reg_status()
1789
-    {
1790
-        $this->request->setRequestParam('return', 'view_registration');
1791
-        // set notify based on whether the send notifications toggle is set or not
1792
-        $notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1793
-        $reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1794
-        $this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1795
-        switch ($reg_status) {
1796
-            case EEM_Registration::status_id_approved:
1797
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1798
-                $this->approve_registration($notify);
1799
-                break;
1800
-            case EEM_Registration::status_id_pending_payment:
1801
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1802
-                $this->pending_registration($notify);
1803
-                break;
1804
-            case EEM_Registration::status_id_not_approved:
1805
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1806
-                $this->not_approve_registration($notify);
1807
-                break;
1808
-            case EEM_Registration::status_id_declined:
1809
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1810
-                $this->decline_registration($notify);
1811
-                break;
1812
-            case EEM_Registration::status_id_cancelled:
1813
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1814
-                $this->cancel_registration($notify);
1815
-                break;
1816
-            case EEM_Registration::status_id_wait_list:
1817
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1818
-                $this->wait_list_registration($notify);
1819
-                break;
1820
-            case EEM_Registration::status_id_incomplete:
1821
-            default:
1822
-                $this->request->unSetRequestParam('return');
1823
-                $this->_reg_status_change_return('');
1824
-                break;
1825
-        }
1826
-    }
1827
-
1828
-
1829
-    /**
1830
-     * Callback for bulk action routes.
1831
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1832
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
1833
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1834
-     * when an action is happening on just a single registration).
1835
-     *
1836
-     * @param      $action
1837
-     * @param bool $notify
1838
-     */
1839
-    protected function bulk_action_on_registrations($action, $notify = false)
1840
-    {
1841
-        do_action(
1842
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1843
-            $this,
1844
-            $action,
1845
-            $notify
1846
-        );
1847
-        $method = $action . '_registration';
1848
-        if (method_exists($this, $method)) {
1849
-            $this->$method($notify);
1850
-        }
1851
-    }
1852
-
1853
-
1854
-    /**
1855
-     * approve_registration
1856
-     *
1857
-     * @param bool $notify whether or not to notify the registrant about their approval.
1858
-     * @return void
1859
-     * @throws EE_Error
1860
-     * @throws EntityNotFoundException
1861
-     * @throws InvalidArgumentException
1862
-     * @throws InvalidDataTypeException
1863
-     * @throws InvalidInterfaceException
1864
-     * @throws ReflectionException
1865
-     * @throws RuntimeException
1866
-     * @throws DomainException
1867
-     */
1868
-    protected function approve_registration($notify = false)
1869
-    {
1870
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1871
-    }
1872
-
1873
-
1874
-    /**
1875
-     * decline_registration
1876
-     *
1877
-     * @param bool $notify whether or not to notify the registrant about their status change.
1878
-     * @return void
1879
-     * @throws EE_Error
1880
-     * @throws EntityNotFoundException
1881
-     * @throws InvalidArgumentException
1882
-     * @throws InvalidDataTypeException
1883
-     * @throws InvalidInterfaceException
1884
-     * @throws ReflectionException
1885
-     * @throws RuntimeException
1886
-     * @throws DomainException
1887
-     */
1888
-    protected function decline_registration($notify = false)
1889
-    {
1890
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1891
-    }
1892
-
1893
-
1894
-    /**
1895
-     * cancel_registration
1896
-     *
1897
-     * @param bool $notify whether or not to notify the registrant about their status change.
1898
-     * @return void
1899
-     * @throws EE_Error
1900
-     * @throws EntityNotFoundException
1901
-     * @throws InvalidArgumentException
1902
-     * @throws InvalidDataTypeException
1903
-     * @throws InvalidInterfaceException
1904
-     * @throws ReflectionException
1905
-     * @throws RuntimeException
1906
-     * @throws DomainException
1907
-     */
1908
-    protected function cancel_registration($notify = false)
1909
-    {
1910
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1911
-    }
1912
-
1913
-
1914
-    /**
1915
-     * not_approve_registration
1916
-     *
1917
-     * @param bool $notify whether or not to notify the registrant about their status change.
1918
-     * @return void
1919
-     * @throws EE_Error
1920
-     * @throws EntityNotFoundException
1921
-     * @throws InvalidArgumentException
1922
-     * @throws InvalidDataTypeException
1923
-     * @throws InvalidInterfaceException
1924
-     * @throws ReflectionException
1925
-     * @throws RuntimeException
1926
-     * @throws DomainException
1927
-     */
1928
-    protected function not_approve_registration($notify = false)
1929
-    {
1930
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1931
-    }
1932
-
1933
-
1934
-    /**
1935
-     * decline_registration
1936
-     *
1937
-     * @param bool $notify whether or not to notify the registrant about their status change.
1938
-     * @return void
1939
-     * @throws EE_Error
1940
-     * @throws EntityNotFoundException
1941
-     * @throws InvalidArgumentException
1942
-     * @throws InvalidDataTypeException
1943
-     * @throws InvalidInterfaceException
1944
-     * @throws ReflectionException
1945
-     * @throws RuntimeException
1946
-     * @throws DomainException
1947
-     */
1948
-    protected function pending_registration($notify = false)
1949
-    {
1950
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1951
-    }
1952
-
1953
-
1954
-    /**
1955
-     * waitlist_registration
1956
-     *
1957
-     * @param bool $notify whether or not to notify the registrant about their status change.
1958
-     * @return void
1959
-     * @throws EE_Error
1960
-     * @throws EntityNotFoundException
1961
-     * @throws InvalidArgumentException
1962
-     * @throws InvalidDataTypeException
1963
-     * @throws InvalidInterfaceException
1964
-     * @throws ReflectionException
1965
-     * @throws RuntimeException
1966
-     * @throws DomainException
1967
-     */
1968
-    protected function wait_list_registration($notify = false)
1969
-    {
1970
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1971
-    }
1972
-
1973
-
1974
-    /**
1975
-     * generates HTML for the Registration main meta box
1976
-     *
1977
-     * @return void
1978
-     * @throws DomainException
1979
-     * @throws EE_Error
1980
-     * @throws InvalidArgumentException
1981
-     * @throws InvalidDataTypeException
1982
-     * @throws InvalidInterfaceException
1983
-     * @throws ReflectionException
1984
-     * @throws EntityNotFoundException
1985
-     */
1986
-    public function _reg_details_meta_box()
1987
-    {
1988
-        EEH_Autoloader::register_line_item_display_autoloaders();
1989
-        EEH_Autoloader::register_line_item_filter_autoloaders();
1990
-        EE_Registry::instance()->load_helper('Line_Item');
1991
-        $transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
1992
-            : EE_Transaction::new_instance();
1993
-        $this->_session = $transaction->session_data();
1994
-        $filters        = new EE_Line_Item_Filter_Collection();
1995
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
1996
-        $filters->add(new EE_Non_Zero_Line_Item_Filter());
1997
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
1998
-            $filters,
1999
-            $transaction->total_line_item()
2000
-        );
2001
-        $filtered_line_item_tree                 = $line_item_filter_processor->process();
2002
-        $line_item_display                       = new EE_Line_Item_Display(
2003
-            'reg_admin_table',
2004
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2005
-        );
2006
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2007
-            $filtered_line_item_tree,
2008
-            ['EE_Registration' => $this->_registration]
2009
-        );
2010
-        $attendee                                = $this->_registration->attendee();
2011
-        if (
2012
-            EE_Registry::instance()->CAP->current_user_can(
2013
-                'ee_read_transaction',
2014
-                'espresso_transactions_view_transaction'
2015
-            )
2016
-        ) {
2017
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2018
-                EE_Admin_Page::add_query_args_and_nonce(
2019
-                    [
2020
-                        'action' => 'view_transaction',
2021
-                        'TXN_ID' => $transaction->ID(),
2022
-                    ],
2023
-                    TXN_ADMIN_URL
2024
-                ),
2025
-                esc_html__(' View Transaction', 'event_espresso'),
2026
-                'button button--secondary right',
2027
-                'dashicons dashicons-cart'
2028
-            );
2029
-        } else {
2030
-            $this->_template_args['view_transaction_button'] = '';
2031
-        }
2032
-        if (
2033
-            $attendee instanceof EE_Attendee
2034
-            && EE_Registry::instance()->CAP->current_user_can(
2035
-                'ee_send_message',
2036
-                'espresso_registrations_resend_registration'
2037
-            )
2038
-        ) {
2039
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2040
-                EE_Admin_Page::add_query_args_and_nonce(
2041
-                    [
2042
-                        'action'      => 'resend_registration',
2043
-                        '_REG_ID'     => $this->_registration->ID(),
2044
-                        'redirect_to' => 'view_registration',
2045
-                    ],
2046
-                    REG_ADMIN_URL
2047
-                ),
2048
-                esc_html__(' Resend Registration', 'event_espresso'),
2049
-                'button button--secondary right',
2050
-                'dashicons dashicons-email-alt'
2051
-            );
2052
-        } else {
2053
-            $this->_template_args['resend_registration_button'] = '';
2054
-        }
2055
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2056
-        $payment                               = $transaction->get_first_related('Payment');
2057
-        $payment                               = ! $payment instanceof EE_Payment
2058
-            ? EE_Payment::new_instance()
2059
-            : $payment;
2060
-        $payment_method                        = $payment->get_first_related('Payment_Method');
2061
-        $payment_method                        = ! $payment_method instanceof EE_Payment_Method
2062
-            ? EE_Payment_Method::new_instance()
2063
-            : $payment_method;
2064
-        $reg_details                           = [
2065
-            'payment_method'       => $payment_method->name(),
2066
-            'response_msg'         => $payment->gateway_response(),
2067
-            'registration_id'      => $this->_registration->get('REG_code'),
2068
-            'registration_session' => $this->_registration->session_ID(),
2069
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2070
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2071
-        ];
2072
-        if (isset($reg_details['registration_id'])) {
2073
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2074
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2075
-                'Registration ID',
2076
-                'event_espresso'
2077
-            );
2078
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2079
-        }
2080
-        if (isset($reg_details['payment_method'])) {
2081
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2082
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2083
-                'Most Recent Payment Method',
2084
-                'event_espresso'
2085
-            );
2086
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2087
-            $this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2088
-            $this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2089
-                'Payment method response',
2090
-                'event_espresso'
2091
-            );
2092
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2093
-        }
2094
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2095
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2096
-            'Registration Session',
2097
-            'event_espresso'
2098
-        );
2099
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2100
-        $this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2101
-        $this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2102
-            'Registration placed from IP',
2103
-            'event_espresso'
2104
-        );
2105
-        $this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2106
-        $this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2107
-        $this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2108
-            'Registrant User Agent',
2109
-            'event_espresso'
2110
-        );
2111
-        $this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2112
-        $this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2113
-            [
2114
-                'action'   => 'default',
2115
-                'event_id' => $this->_registration->event_ID(),
2116
-            ],
2117
-            REG_ADMIN_URL
2118
-        );
2119
-
2120
-        $this->_template_args['REG_ID'] = $this->_registration->ID();
2121
-        $this->_template_args['event_id'] = $this->_registration->event_ID();
2122
-
2123
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2124
-        EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2125
-    }
2126
-
2127
-
2128
-    /**
2129
-     * generates HTML for the Registration Questions meta box.
2130
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2131
-     * otherwise uses new forms system
2132
-     *
2133
-     * @return void
2134
-     * @throws DomainException
2135
-     * @throws EE_Error
2136
-     * @throws InvalidArgumentException
2137
-     * @throws InvalidDataTypeException
2138
-     * @throws InvalidInterfaceException
2139
-     * @throws ReflectionException
2140
-     */
2141
-    public function _reg_questions_meta_box()
2142
-    {
2143
-        // allow someone to override this method entirely
2144
-        if (
2145
-            apply_filters(
2146
-                'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2147
-                true,
2148
-                $this,
2149
-                $this->_registration
2150
-            )
2151
-        ) {
2152
-            $form = $this->_get_reg_custom_questions_form(
2153
-                $this->_registration->ID()
2154
-            );
2155
-
2156
-            $this->_template_args['att_questions'] = count($form->subforms()) > 0
2157
-                ? $form->get_html_and_js()
2158
-                : '';
2159
-
2160
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2161
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
2162
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2163
-            EEH_Template::display_template($template_path, $this->_template_args);
2164
-        }
2165
-    }
2166
-
2167
-
2168
-    /**
2169
-     * form_before_question_group
2170
-     *
2171
-     * @param string $output
2172
-     * @return        string
2173
-     * @deprecated    as of 4.8.32.rc.000
2174
-     */
2175
-    public function form_before_question_group($output)
2176
-    {
2177
-        EE_Error::doing_it_wrong(
2178
-            __CLASS__ . '::' . __FUNCTION__,
2179
-            esc_html__(
2180
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2181
-                'event_espresso'
2182
-            ),
2183
-            '4.8.32.rc.000'
2184
-        );
2185
-        return '
22
+	/**
23
+	 * @var EE_Registration
24
+	 */
25
+	private $_registration;
26
+
27
+	/**
28
+	 * @var EE_Event
29
+	 */
30
+	private $_reg_event;
31
+
32
+	/**
33
+	 * @var EE_Session
34
+	 */
35
+	private $_session;
36
+
37
+	/**
38
+	 * @var array
39
+	 */
40
+	private static $_reg_status;
41
+
42
+	/**
43
+	 * Form for displaying the custom questions for this registration.
44
+	 * This gets used a few times throughout the request so its best to cache it
45
+	 *
46
+	 * @var EE_Registration_Custom_Questions_Form
47
+	 */
48
+	protected $_reg_custom_questions_form;
49
+
50
+	/**
51
+	 * @var EEM_Registration $registration_model
52
+	 */
53
+	private $registration_model;
54
+
55
+	/**
56
+	 * @var EEM_Attendee $attendee_model
57
+	 */
58
+	private $attendee_model;
59
+
60
+	/**
61
+	 * @var EEM_Event $event_model
62
+	 */
63
+	private $event_model;
64
+
65
+	/**
66
+	 * @var EEM_Status $status_model
67
+	 */
68
+	private $status_model;
69
+
70
+
71
+	/**
72
+	 * @param bool $routing
73
+	 * @throws EE_Error
74
+	 * @throws InvalidArgumentException
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws InvalidInterfaceException
77
+	 * @throws ReflectionException
78
+	 */
79
+	public function __construct($routing = true)
80
+	{
81
+		parent::__construct($routing);
82
+		add_action('wp_loaded', [$this, 'wp_loaded']);
83
+	}
84
+
85
+
86
+	/**
87
+	 * @return EEM_Registration
88
+	 * @throws InvalidArgumentException
89
+	 * @throws InvalidDataTypeException
90
+	 * @throws InvalidInterfaceException
91
+	 * @since 4.10.2.p
92
+	 */
93
+	protected function getRegistrationModel()
94
+	{
95
+		if (! $this->registration_model instanceof EEM_Registration) {
96
+			$this->registration_model = $this->loader->getShared('EEM_Registration');
97
+		}
98
+		return $this->registration_model;
99
+	}
100
+
101
+
102
+	/**
103
+	 * @return EEM_Attendee
104
+	 * @throws InvalidArgumentException
105
+	 * @throws InvalidDataTypeException
106
+	 * @throws InvalidInterfaceException
107
+	 * @since 4.10.2.p
108
+	 */
109
+	protected function getAttendeeModel()
110
+	{
111
+		if (! $this->attendee_model instanceof EEM_Attendee) {
112
+			$this->attendee_model = $this->loader->getShared('EEM_Attendee');
113
+		}
114
+		return $this->attendee_model;
115
+	}
116
+
117
+
118
+	/**
119
+	 * @return EEM_Event
120
+	 * @throws InvalidArgumentException
121
+	 * @throws InvalidDataTypeException
122
+	 * @throws InvalidInterfaceException
123
+	 * @since 4.10.2.p
124
+	 */
125
+	protected function getEventModel()
126
+	{
127
+		if (! $this->event_model instanceof EEM_Event) {
128
+			$this->event_model = $this->loader->getShared('EEM_Event');
129
+		}
130
+		return $this->event_model;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @return EEM_Status
136
+	 * @throws InvalidArgumentException
137
+	 * @throws InvalidDataTypeException
138
+	 * @throws InvalidInterfaceException
139
+	 * @since 4.10.2.p
140
+	 */
141
+	protected function getStatusModel()
142
+	{
143
+		if (! $this->status_model instanceof EEM_Status) {
144
+			$this->status_model = $this->loader->getShared('EEM_Status');
145
+		}
146
+		return $this->status_model;
147
+	}
148
+
149
+
150
+	public function wp_loaded()
151
+	{
152
+		// when adding a new registration...
153
+		$action = $this->request->getRequestParam('action');
154
+		if ($action === 'new_registration') {
155
+			EE_System::do_not_cache();
156
+			if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
157
+				// and it's NOT the attendee information reg step
158
+				// force cookie expiration by setting time to last week
159
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
160
+				// and update the global
161
+				$_COOKIE['ee_registration_added'] = 0;
162
+			}
163
+		}
164
+	}
165
+
166
+
167
+	protected function _init_page_props()
168
+	{
169
+		$this->page_slug        = REG_PG_SLUG;
170
+		$this->_admin_base_url  = REG_ADMIN_URL;
171
+		$this->_admin_base_path = REG_ADMIN;
172
+		$this->page_label       = esc_html__('Registrations', 'event_espresso');
173
+		$this->_cpt_routes      = [
174
+			'add_new_attendee' => 'espresso_attendees',
175
+			'edit_attendee'    => 'espresso_attendees',
176
+			'insert_attendee'  => 'espresso_attendees',
177
+			'update_attendee'  => 'espresso_attendees',
178
+		];
179
+		$this->_cpt_model_names = [
180
+			'add_new_attendee' => 'EEM_Attendee',
181
+			'edit_attendee'    => 'EEM_Attendee',
182
+		];
183
+		$this->_cpt_edit_routes = [
184
+			'espresso_attendees' => 'edit_attendee',
185
+		];
186
+		$this->_pagenow_map     = [
187
+			'add_new_attendee' => 'post-new.php',
188
+			'edit_attendee'    => 'post.php',
189
+			'trash'            => 'post.php',
190
+		];
191
+		add_action('edit_form_after_title', [$this, 'after_title_form_fields'], 10);
192
+		// add filters so that the comment urls don't take users to a confusing 404 page
193
+		add_filter('get_comment_link', [$this, 'clear_comment_link'], 10, 2);
194
+	}
195
+
196
+
197
+	/**
198
+	 * @param string     $link    The comment permalink with '#comment-$id' appended.
199
+	 * @param WP_Comment $comment The current comment object.
200
+	 * @return string
201
+	 */
202
+	public function clear_comment_link($link, WP_Comment $comment)
203
+	{
204
+		// gotta make sure this only happens on this route
205
+		$post_type = get_post_type($comment->comment_post_ID);
206
+		if ($post_type === 'espresso_attendees') {
207
+			return '#commentsdiv';
208
+		}
209
+		return $link;
210
+	}
211
+
212
+
213
+	protected function _ajax_hooks()
214
+	{
215
+		// todo: all hooks for registrations ajax goes in here
216
+		add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']);
217
+	}
218
+
219
+
220
+	protected function _define_page_props()
221
+	{
222
+		$this->_admin_page_title = $this->page_label;
223
+		$this->_labels           = [
224
+			'buttons'                      => [
225
+				'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
226
+				'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
227
+				'edit'                => esc_html__('Edit Contact', 'event_espresso'),
228
+				'report'              => esc_html__('Event Registrations CSV Report', 'event_espresso'),
229
+				'report_datetime'     => esc_html__('Datetime Registrations CSV Report', 'event_espresso'),
230
+				'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
231
+				'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
232
+				'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
233
+				'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
234
+			],
235
+			'publishbox'                   => [
236
+				'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
237
+				'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
238
+			],
239
+			'hide_add_button_on_cpt_route' => [
240
+				'edit_attendee' => true,
241
+			],
242
+		];
243
+	}
244
+
245
+
246
+	/**
247
+	 * grab url requests and route them
248
+	 *
249
+	 * @return void
250
+	 * @throws EE_Error
251
+	 */
252
+	public function _set_page_routes()
253
+	{
254
+		$this->_get_registration_status_array();
255
+		$REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
256
+		$REG_ID             = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
257
+		$ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
258
+		$ATT_ID             = $this->request->getRequestParam('post', $ATT_ID, 'int');
259
+		$this->_page_routes = [
260
+			'default'                             => [
261
+				'func'       => '_registrations_overview_list_table',
262
+				'capability' => 'ee_read_registrations',
263
+			],
264
+			'view_registration'                   => [
265
+				'func'       => '_registration_details',
266
+				'capability' => 'ee_read_registration',
267
+				'obj_id'     => $REG_ID,
268
+			],
269
+			'edit_registration'                   => [
270
+				'func'               => '_update_attendee_registration_form',
271
+				'noheader'           => true,
272
+				'headers_sent_route' => 'view_registration',
273
+				'capability'         => 'ee_edit_registration',
274
+				'obj_id'             => $REG_ID,
275
+				'_REG_ID'            => $REG_ID,
276
+			],
277
+			'trash_registrations'                 => [
278
+				'func'       => '_trash_or_restore_registrations',
279
+				'args'       => ['trash' => true],
280
+				'noheader'   => true,
281
+				'capability' => 'ee_delete_registrations',
282
+			],
283
+			'restore_registrations'               => [
284
+				'func'       => '_trash_or_restore_registrations',
285
+				'args'       => ['trash' => false],
286
+				'noheader'   => true,
287
+				'capability' => 'ee_delete_registrations',
288
+			],
289
+			'delete_registrations'                => [
290
+				'func'       => '_delete_registrations',
291
+				'noheader'   => true,
292
+				'capability' => 'ee_delete_registrations',
293
+			],
294
+			'new_registration'                    => [
295
+				'func'       => 'new_registration',
296
+				'capability' => 'ee_edit_registrations',
297
+			],
298
+			'process_reg_step'                    => [
299
+				'func'       => 'process_reg_step',
300
+				'noheader'   => true,
301
+				'capability' => 'ee_edit_registrations',
302
+			],
303
+			'redirect_to_txn'                     => [
304
+				'func'       => 'redirect_to_txn',
305
+				'noheader'   => true,
306
+				'capability' => 'ee_edit_registrations',
307
+			],
308
+			'change_reg_status'                   => [
309
+				'func'       => '_change_reg_status',
310
+				'noheader'   => true,
311
+				'capability' => 'ee_edit_registration',
312
+				'obj_id'     => $REG_ID,
313
+			],
314
+			'approve_registration'                => [
315
+				'func'       => 'approve_registration',
316
+				'noheader'   => true,
317
+				'capability' => 'ee_edit_registration',
318
+				'obj_id'     => $REG_ID,
319
+			],
320
+			'approve_and_notify_registration'     => [
321
+				'func'       => 'approve_registration',
322
+				'noheader'   => true,
323
+				'args'       => [true],
324
+				'capability' => 'ee_edit_registration',
325
+				'obj_id'     => $REG_ID,
326
+			],
327
+			'approve_registrations'               => [
328
+				'func'       => 'bulk_action_on_registrations',
329
+				'noheader'   => true,
330
+				'capability' => 'ee_edit_registrations',
331
+				'args'       => ['approve'],
332
+			],
333
+			'approve_and_notify_registrations'    => [
334
+				'func'       => 'bulk_action_on_registrations',
335
+				'noheader'   => true,
336
+				'capability' => 'ee_edit_registrations',
337
+				'args'       => ['approve', true],
338
+			],
339
+			'decline_registration'                => [
340
+				'func'       => 'decline_registration',
341
+				'noheader'   => true,
342
+				'capability' => 'ee_edit_registration',
343
+				'obj_id'     => $REG_ID,
344
+			],
345
+			'decline_and_notify_registration'     => [
346
+				'func'       => 'decline_registration',
347
+				'noheader'   => true,
348
+				'args'       => [true],
349
+				'capability' => 'ee_edit_registration',
350
+				'obj_id'     => $REG_ID,
351
+			],
352
+			'decline_registrations'               => [
353
+				'func'       => 'bulk_action_on_registrations',
354
+				'noheader'   => true,
355
+				'capability' => 'ee_edit_registrations',
356
+				'args'       => ['decline'],
357
+			],
358
+			'decline_and_notify_registrations'    => [
359
+				'func'       => 'bulk_action_on_registrations',
360
+				'noheader'   => true,
361
+				'capability' => 'ee_edit_registrations',
362
+				'args'       => ['decline', true],
363
+			],
364
+			'pending_registration'                => [
365
+				'func'       => 'pending_registration',
366
+				'noheader'   => true,
367
+				'capability' => 'ee_edit_registration',
368
+				'obj_id'     => $REG_ID,
369
+			],
370
+			'pending_and_notify_registration'     => [
371
+				'func'       => 'pending_registration',
372
+				'noheader'   => true,
373
+				'args'       => [true],
374
+				'capability' => 'ee_edit_registration',
375
+				'obj_id'     => $REG_ID,
376
+			],
377
+			'pending_registrations'               => [
378
+				'func'       => 'bulk_action_on_registrations',
379
+				'noheader'   => true,
380
+				'capability' => 'ee_edit_registrations',
381
+				'args'       => ['pending'],
382
+			],
383
+			'pending_and_notify_registrations'    => [
384
+				'func'       => 'bulk_action_on_registrations',
385
+				'noheader'   => true,
386
+				'capability' => 'ee_edit_registrations',
387
+				'args'       => ['pending', true],
388
+			],
389
+			'no_approve_registration'             => [
390
+				'func'       => 'not_approve_registration',
391
+				'noheader'   => true,
392
+				'capability' => 'ee_edit_registration',
393
+				'obj_id'     => $REG_ID,
394
+			],
395
+			'no_approve_and_notify_registration'  => [
396
+				'func'       => 'not_approve_registration',
397
+				'noheader'   => true,
398
+				'args'       => [true],
399
+				'capability' => 'ee_edit_registration',
400
+				'obj_id'     => $REG_ID,
401
+			],
402
+			'no_approve_registrations'            => [
403
+				'func'       => 'bulk_action_on_registrations',
404
+				'noheader'   => true,
405
+				'capability' => 'ee_edit_registrations',
406
+				'args'       => ['not_approve'],
407
+			],
408
+			'no_approve_and_notify_registrations' => [
409
+				'func'       => 'bulk_action_on_registrations',
410
+				'noheader'   => true,
411
+				'capability' => 'ee_edit_registrations',
412
+				'args'       => ['not_approve', true],
413
+			],
414
+			'cancel_registration'                 => [
415
+				'func'       => 'cancel_registration',
416
+				'noheader'   => true,
417
+				'capability' => 'ee_edit_registration',
418
+				'obj_id'     => $REG_ID,
419
+			],
420
+			'cancel_and_notify_registration'      => [
421
+				'func'       => 'cancel_registration',
422
+				'noheader'   => true,
423
+				'args'       => [true],
424
+				'capability' => 'ee_edit_registration',
425
+				'obj_id'     => $REG_ID,
426
+			],
427
+			'cancel_registrations'                => [
428
+				'func'       => 'bulk_action_on_registrations',
429
+				'noheader'   => true,
430
+				'capability' => 'ee_edit_registrations',
431
+				'args'       => ['cancel'],
432
+			],
433
+			'cancel_and_notify_registrations'     => [
434
+				'func'       => 'bulk_action_on_registrations',
435
+				'noheader'   => true,
436
+				'capability' => 'ee_edit_registrations',
437
+				'args'       => ['cancel', true],
438
+			],
439
+			'wait_list_registration'              => [
440
+				'func'       => 'wait_list_registration',
441
+				'noheader'   => true,
442
+				'capability' => 'ee_edit_registration',
443
+				'obj_id'     => $REG_ID,
444
+			],
445
+			'wait_list_and_notify_registration'   => [
446
+				'func'       => 'wait_list_registration',
447
+				'noheader'   => true,
448
+				'args'       => [true],
449
+				'capability' => 'ee_edit_registration',
450
+				'obj_id'     => $REG_ID,
451
+			],
452
+			'contact_list'                        => [
453
+				'func'       => '_attendee_contact_list_table',
454
+				'capability' => 'ee_read_contacts',
455
+			],
456
+			'add_new_attendee'                    => [
457
+				'func' => '_create_new_cpt_item',
458
+				'args' => [
459
+					'new_attendee' => true,
460
+					'capability'   => 'ee_edit_contacts',
461
+				],
462
+			],
463
+			'edit_attendee'                       => [
464
+				'func'       => '_edit_cpt_item',
465
+				'capability' => 'ee_edit_contacts',
466
+				'obj_id'     => $ATT_ID,
467
+			],
468
+			'duplicate_attendee'                  => [
469
+				'func'       => '_duplicate_attendee',
470
+				'noheader'   => true,
471
+				'capability' => 'ee_edit_contacts',
472
+				'obj_id'     => $ATT_ID,
473
+			],
474
+			'insert_attendee'                     => [
475
+				'func'       => '_insert_or_update_attendee',
476
+				'args'       => [
477
+					'new_attendee' => true,
478
+				],
479
+				'noheader'   => true,
480
+				'capability' => 'ee_edit_contacts',
481
+			],
482
+			'update_attendee'                     => [
483
+				'func'       => '_insert_or_update_attendee',
484
+				'args'       => [
485
+					'new_attendee' => false,
486
+				],
487
+				'noheader'   => true,
488
+				'capability' => 'ee_edit_contacts',
489
+				'obj_id'     => $ATT_ID,
490
+			],
491
+			'trash_attendees'                     => [
492
+				'func'       => '_trash_or_restore_attendees',
493
+				'args'       => [
494
+					'trash' => 'true',
495
+				],
496
+				'noheader'   => true,
497
+				'capability' => 'ee_delete_contacts',
498
+			],
499
+			'trash_attendee'                      => [
500
+				'func'       => '_trash_or_restore_attendees',
501
+				'args'       => [
502
+					'trash' => true,
503
+				],
504
+				'noheader'   => true,
505
+				'capability' => 'ee_delete_contacts',
506
+				'obj_id'     => $ATT_ID,
507
+			],
508
+			'restore_attendees'                   => [
509
+				'func'       => '_trash_or_restore_attendees',
510
+				'args'       => [
511
+					'trash' => false,
512
+				],
513
+				'noheader'   => true,
514
+				'capability' => 'ee_delete_contacts',
515
+				'obj_id'     => $ATT_ID,
516
+			],
517
+			'resend_registration'                 => [
518
+				'func'       => '_resend_registration',
519
+				'noheader'   => true,
520
+				'capability' => 'ee_send_message',
521
+			],
522
+			'registrations_report'                => [
523
+				'func'       => '_registrations_report',
524
+				'noheader'   => true,
525
+				'capability' => 'ee_read_registrations',
526
+			],
527
+			'contact_list_export'                 => [
528
+				'func'       => '_contact_list_export',
529
+				'noheader'   => true,
530
+				'capability' => 'export',
531
+			],
532
+			'contact_list_report'                 => [
533
+				'func'       => '_contact_list_report',
534
+				'noheader'   => true,
535
+				'capability' => 'ee_read_contacts',
536
+			],
537
+		];
538
+	}
539
+
540
+
541
+	protected function _set_page_config()
542
+	{
543
+		$REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
544
+		$ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
545
+		$this->_page_config = [
546
+			'default'           => [
547
+				'nav'           => [
548
+					'label' => esc_html__('Overview', 'event_espresso'),
549
+					'order' => 5,
550
+				],
551
+				'help_tabs'     => [
552
+					'registrations_overview_help_tab'                       => [
553
+						'title'    => esc_html__('Registrations Overview', 'event_espresso'),
554
+						'filename' => 'registrations_overview',
555
+					],
556
+					'registrations_overview_table_column_headings_help_tab' => [
557
+						'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
558
+						'filename' => 'registrations_overview_table_column_headings',
559
+					],
560
+					'registrations_overview_filters_help_tab'               => [
561
+						'title'    => esc_html__('Registration Filters', 'event_espresso'),
562
+						'filename' => 'registrations_overview_filters',
563
+					],
564
+					'registrations_overview_views_help_tab'                 => [
565
+						'title'    => esc_html__('Registration Views', 'event_espresso'),
566
+						'filename' => 'registrations_overview_views',
567
+					],
568
+					'registrations_regoverview_other_help_tab'              => [
569
+						'title'    => esc_html__('Registrations Other', 'event_espresso'),
570
+						'filename' => 'registrations_overview_other',
571
+					],
572
+				],
573
+				'list_table'    => 'EE_Registrations_List_Table',
574
+				'require_nonce' => false,
575
+			],
576
+			'view_registration' => [
577
+				'nav'           => [
578
+					'label'      => esc_html__('REG Details', 'event_espresso'),
579
+					'order'      => 15,
580
+					'url'        => $REG_ID
581
+						? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
582
+						: $this->_admin_base_url,
583
+					'persistent' => false,
584
+				],
585
+				'help_tabs'     => [
586
+					'registrations_details_help_tab'                    => [
587
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
588
+						'filename' => 'registrations_details',
589
+					],
590
+					'registrations_details_table_help_tab'              => [
591
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
592
+						'filename' => 'registrations_details_table',
593
+					],
594
+					'registrations_details_form_answers_help_tab'       => [
595
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
596
+						'filename' => 'registrations_details_form_answers',
597
+					],
598
+					'registrations_details_registrant_details_help_tab' => [
599
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
600
+						'filename' => 'registrations_details_registrant_details',
601
+					],
602
+				],
603
+				'metaboxes'     => array_merge(
604
+					$this->_default_espresso_metaboxes,
605
+					['_registration_details_metaboxes']
606
+				),
607
+				'require_nonce' => false,
608
+			],
609
+			'new_registration'  => [
610
+				'nav'           => [
611
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
612
+					'url'        => '#',
613
+					'order'      => 15,
614
+					'persistent' => false,
615
+				],
616
+				'metaboxes'     => $this->_default_espresso_metaboxes,
617
+				'labels'        => [
618
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
619
+				],
620
+				'require_nonce' => false,
621
+			],
622
+			'add_new_attendee'  => [
623
+				'nav'           => [
624
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
625
+					'order'      => 15,
626
+					'persistent' => false,
627
+				],
628
+				'metaboxes'     => array_merge(
629
+					$this->_default_espresso_metaboxes,
630
+					['_publish_post_box', 'attendee_editor_metaboxes']
631
+				),
632
+				'require_nonce' => false,
633
+			],
634
+			'edit_attendee'     => [
635
+				'nav'           => [
636
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
637
+					'order'      => 15,
638
+					'persistent' => false,
639
+					'url'        => $ATT_ID
640
+						? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
641
+						: $this->_admin_base_url,
642
+				],
643
+				'metaboxes'     => array_merge(
644
+					$this->_default_espresso_metaboxes,
645
+					['attendee_editor_metaboxes']
646
+				),
647
+				'require_nonce' => false,
648
+			],
649
+			'contact_list'      => [
650
+				'nav'           => [
651
+					'label' => esc_html__('Contact List', 'event_espresso'),
652
+					'order' => 20,
653
+				],
654
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
655
+				'help_tabs'     => [
656
+					'registrations_contact_list_help_tab'                       => [
657
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
658
+						'filename' => 'registrations_contact_list',
659
+					],
660
+					'registrations_contact-list_table_column_headings_help_tab' => [
661
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
662
+						'filename' => 'registrations_contact_list_table_column_headings',
663
+					],
664
+					'registrations_contact_list_views_help_tab'                 => [
665
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
666
+						'filename' => 'registrations_contact_list_views',
667
+					],
668
+					'registrations_contact_list_other_help_tab'                 => [
669
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
670
+						'filename' => 'registrations_contact_list_other',
671
+					],
672
+				],
673
+				'metaboxes'     => [],
674
+				'require_nonce' => false,
675
+			],
676
+			// override default cpt routes
677
+			'create_new'        => '',
678
+			'edit'              => '',
679
+		];
680
+	}
681
+
682
+
683
+	/**
684
+	 * The below methods aren't used by this class currently
685
+	 */
686
+	protected function _add_screen_options()
687
+	{
688
+	}
689
+
690
+
691
+	protected function _add_feature_pointers()
692
+	{
693
+	}
694
+
695
+
696
+	public function admin_init()
697
+	{
698
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
699
+			'click "Update Registration Questions" to save your changes',
700
+			'event_espresso'
701
+		);
702
+	}
703
+
704
+
705
+	public function admin_notices()
706
+	{
707
+	}
708
+
709
+
710
+	public function admin_footer_scripts()
711
+	{
712
+	}
713
+
714
+
715
+	/**
716
+	 * get list of registration statuses
717
+	 *
718
+	 * @return void
719
+	 * @throws EE_Error
720
+	 */
721
+	private function _get_registration_status_array()
722
+	{
723
+		self::$_reg_status = EEM_Registration::reg_status_array([], true);
724
+	}
725
+
726
+
727
+	/**
728
+	 * @throws InvalidArgumentException
729
+	 * @throws InvalidDataTypeException
730
+	 * @throws InvalidInterfaceException
731
+	 * @since 4.10.2.p
732
+	 */
733
+	protected function _add_screen_options_default()
734
+	{
735
+		$this->_per_page_screen_option();
736
+	}
737
+
738
+
739
+	/**
740
+	 * @throws InvalidArgumentException
741
+	 * @throws InvalidDataTypeException
742
+	 * @throws InvalidInterfaceException
743
+	 * @since 4.10.2.p
744
+	 */
745
+	protected function _add_screen_options_contact_list()
746
+	{
747
+		$page_title              = $this->_admin_page_title;
748
+		$this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
749
+		$this->_per_page_screen_option();
750
+		$this->_admin_page_title = $page_title;
751
+	}
752
+
753
+
754
+	public function load_scripts_styles()
755
+	{
756
+		// style
757
+		wp_register_style(
758
+			'espresso_reg',
759
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
760
+			['ee-admin-css'],
761
+			EVENT_ESPRESSO_VERSION
762
+		);
763
+		wp_enqueue_style('espresso_reg');
764
+		// script
765
+		wp_register_script(
766
+			'espresso_reg',
767
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
768
+			['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
769
+			EVENT_ESPRESSO_VERSION,
770
+			true
771
+		);
772
+		wp_enqueue_script('espresso_reg');
773
+	}
774
+
775
+
776
+	/**
777
+	 * @throws EE_Error
778
+	 * @throws InvalidArgumentException
779
+	 * @throws InvalidDataTypeException
780
+	 * @throws InvalidInterfaceException
781
+	 * @throws ReflectionException
782
+	 * @since 4.10.2.p
783
+	 */
784
+	public function load_scripts_styles_edit_attendee()
785
+	{
786
+		// stuff to only show up on our attendee edit details page.
787
+		$attendee_details_translations = [
788
+			'att_publish_text' => sprintf(
789
+			/* translators: The date and time */
790
+				wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
791
+				'<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
792
+			),
793
+		];
794
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
795
+		wp_enqueue_script('jquery-validate');
796
+	}
797
+
798
+
799
+	/**
800
+	 * @throws EE_Error
801
+	 * @throws InvalidArgumentException
802
+	 * @throws InvalidDataTypeException
803
+	 * @throws InvalidInterfaceException
804
+	 * @throws ReflectionException
805
+	 * @since 4.10.2.p
806
+	 */
807
+	public function load_scripts_styles_view_registration()
808
+	{
809
+		// styles
810
+		wp_enqueue_style('espresso-ui-theme');
811
+		// scripts
812
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
813
+		$this->_reg_custom_questions_form->wp_enqueue_scripts();
814
+	}
815
+
816
+
817
+	public function load_scripts_styles_contact_list()
818
+	{
819
+		wp_dequeue_style('espresso_reg');
820
+		wp_register_style(
821
+			'espresso_att',
822
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
823
+			['ee-admin-css'],
824
+			EVENT_ESPRESSO_VERSION
825
+		);
826
+		wp_enqueue_style('espresso_att');
827
+	}
828
+
829
+
830
+	public function load_scripts_styles_new_registration()
831
+	{
832
+		wp_register_script(
833
+			'ee-spco-for-admin',
834
+			REG_ASSETS_URL . 'spco_for_admin.js',
835
+			['underscore', 'jquery'],
836
+			EVENT_ESPRESSO_VERSION,
837
+			true
838
+		);
839
+		wp_enqueue_script('ee-spco-for-admin');
840
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
841
+		EE_Form_Section_Proper::wp_enqueue_scripts();
842
+		EED_Ticket_Selector::load_tckt_slctr_assets();
843
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
844
+	}
845
+
846
+
847
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
848
+	{
849
+		add_filter('FHEE_load_EE_messages', '__return_true');
850
+	}
851
+
852
+
853
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
854
+	{
855
+		add_filter('FHEE_load_EE_messages', '__return_true');
856
+	}
857
+
858
+
859
+	/**
860
+	 * @throws EE_Error
861
+	 * @throws InvalidArgumentException
862
+	 * @throws InvalidDataTypeException
863
+	 * @throws InvalidInterfaceException
864
+	 * @throws ReflectionException
865
+	 * @since 4.10.2.p
866
+	 */
867
+	protected function _set_list_table_views_default()
868
+	{
869
+		// for notification related bulk actions we need to make sure only active messengers have an option.
870
+		EED_Messages::set_autoloaders();
871
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
872
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
873
+		$active_mts               = $message_resource_manager->list_of_active_message_types();
874
+		// key= bulk_action_slug, value= message type.
875
+		$match_array = [
876
+			'approve_registrations'    => 'registration',
877
+			'decline_registrations'    => 'declined_registration',
878
+			'pending_registrations'    => 'pending_approval',
879
+			'no_approve_registrations' => 'not_approved_registration',
880
+			'cancel_registrations'     => 'cancelled_registration',
881
+		];
882
+		$can_send    = EE_Registry::instance()->CAP->current_user_can(
883
+			'ee_send_message',
884
+			'batch_send_messages'
885
+		);
886
+		/** setup reg status bulk actions **/
887
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
888
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
889
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
890
+				'Approve and Notify Registrations',
891
+				'event_espresso'
892
+			);
893
+		}
894
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
895
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
896
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
897
+				'Decline and Notify Registrations',
898
+				'event_espresso'
899
+			);
900
+		}
901
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
902
+			'Set Registrations to Pending Payment',
903
+			'event_espresso'
904
+		);
905
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
906
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
907
+				'Set Registrations to Pending Payment and Notify',
908
+				'event_espresso'
909
+			);
910
+		}
911
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
912
+			'Set Registrations to Not Approved',
913
+			'event_espresso'
914
+		);
915
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
916
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
917
+				'Set Registrations to Not Approved and Notify',
918
+				'event_espresso'
919
+			);
920
+		}
921
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
922
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
923
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
924
+				'Cancel Registrations and Notify',
925
+				'event_espresso'
926
+			);
927
+		}
928
+		$def_reg_status_actions = apply_filters(
929
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
930
+			$def_reg_status_actions,
931
+			$active_mts,
932
+			$can_send
933
+		);
934
+
935
+		$this->_views = [
936
+			'all'   => [
937
+				'slug'        => 'all',
938
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
939
+				'count'       => 0,
940
+				'bulk_action' => array_merge(
941
+					$def_reg_status_actions,
942
+					[
943
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
944
+					]
945
+				),
946
+			],
947
+			'month' => [
948
+				'slug'        => 'month',
949
+				'label'       => esc_html__('This Month', 'event_espresso'),
950
+				'count'       => 0,
951
+				'bulk_action' => array_merge(
952
+					$def_reg_status_actions,
953
+					[
954
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
955
+					]
956
+				),
957
+			],
958
+			'today' => [
959
+				'slug'        => 'today',
960
+				'label'       => sprintf(
961
+					esc_html__('Today - %s', 'event_espresso'),
962
+					date('M d, Y', current_time('timestamp'))
963
+				),
964
+				'count'       => 0,
965
+				'bulk_action' => array_merge(
966
+					$def_reg_status_actions,
967
+					[
968
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
969
+					]
970
+				),
971
+			],
972
+		];
973
+		if (
974
+			EE_Registry::instance()->CAP->current_user_can(
975
+				'ee_delete_registrations',
976
+				'espresso_registrations_delete_registration'
977
+			)
978
+		) {
979
+			$this->_views['incomplete'] = [
980
+				'slug'        => 'incomplete',
981
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
982
+				'count'       => 0,
983
+				'bulk_action' => [
984
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
985
+				],
986
+			];
987
+			$this->_views['trash']      = [
988
+				'slug'        => 'trash',
989
+				'label'       => esc_html__('Trash', 'event_espresso'),
990
+				'count'       => 0,
991
+				'bulk_action' => [
992
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
993
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
994
+				],
995
+			];
996
+		}
997
+	}
998
+
999
+
1000
+	protected function _set_list_table_views_contact_list()
1001
+	{
1002
+		$this->_views = [
1003
+			'in_use' => [
1004
+				'slug'        => 'in_use',
1005
+				'label'       => esc_html__('In Use', 'event_espresso'),
1006
+				'count'       => 0,
1007
+				'bulk_action' => [
1008
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1009
+				],
1010
+			],
1011
+		];
1012
+		if (
1013
+			EE_Registry::instance()->CAP->current_user_can(
1014
+				'ee_delete_contacts',
1015
+				'espresso_registrations_trash_attendees'
1016
+			)
1017
+		) {
1018
+			$this->_views['trash'] = [
1019
+				'slug'        => 'trash',
1020
+				'label'       => esc_html__('Trash', 'event_espresso'),
1021
+				'count'       => 0,
1022
+				'bulk_action' => [
1023
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1024
+				],
1025
+			];
1026
+		}
1027
+	}
1028
+
1029
+
1030
+	/**
1031
+	 * @return array
1032
+	 * @throws EE_Error
1033
+	 */
1034
+	protected function _registration_legend_items()
1035
+	{
1036
+		$fc_items = [
1037
+			'star-icon'        => [
1038
+				'class' => 'dashicons dashicons-star-filled gold-icon',
1039
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1040
+			],
1041
+			'view_details'     => [
1042
+				'class' => 'dashicons dashicons-clipboard',
1043
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1044
+			],
1045
+			'edit_attendee'    => [
1046
+				'class' => 'dashicons dashicons-admin-users',
1047
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1048
+			],
1049
+			'view_transaction' => [
1050
+				'class' => 'dashicons dashicons-cart',
1051
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1052
+			],
1053
+			'view_invoice'     => [
1054
+				'class' => 'dashicons dashicons-media-spreadsheet',
1055
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1056
+			],
1057
+		];
1058
+		if (
1059
+			EE_Registry::instance()->CAP->current_user_can(
1060
+				'ee_send_message',
1061
+				'espresso_registrations_resend_registration'
1062
+			)
1063
+		) {
1064
+			$fc_items['resend_registration'] = [
1065
+				'class' => 'dashicons dashicons-email-alt',
1066
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1067
+			];
1068
+		} else {
1069
+			$fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1070
+		}
1071
+		if (
1072
+			EE_Registry::instance()->CAP->current_user_can(
1073
+				'ee_read_global_messages',
1074
+				'view_filtered_messages'
1075
+			)
1076
+		) {
1077
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1078
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1079
+				$fc_items['view_related_messages'] = [
1080
+					'class' => $related_for_icon['css_class'],
1081
+					'desc'  => $related_for_icon['label'],
1082
+				];
1083
+			}
1084
+		}
1085
+		$sc_items = [
1086
+			'approved_status'   => [
1087
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_approved,
1088
+				'desc'  => EEH_Template::pretty_status(
1089
+					EEM_Registration::status_id_approved,
1090
+					false,
1091
+					'sentence'
1092
+				),
1093
+			],
1094
+			'pending_status'    => [
1095
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_pending_payment,
1096
+				'desc'  => EEH_Template::pretty_status(
1097
+					EEM_Registration::status_id_pending_payment,
1098
+					false,
1099
+					'sentence'
1100
+				),
1101
+			],
1102
+			'wait_list'         => [
1103
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_wait_list,
1104
+				'desc'  => EEH_Template::pretty_status(
1105
+					EEM_Registration::status_id_wait_list,
1106
+					false,
1107
+					'sentence'
1108
+				),
1109
+			],
1110
+			'incomplete_status' => [
1111
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_incomplete,
1112
+				'desc'  => EEH_Template::pretty_status(
1113
+					EEM_Registration::status_id_incomplete,
1114
+					false,
1115
+					'sentence'
1116
+				),
1117
+			],
1118
+			'not_approved'      => [
1119
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_not_approved,
1120
+				'desc'  => EEH_Template::pretty_status(
1121
+					EEM_Registration::status_id_not_approved,
1122
+					false,
1123
+					'sentence'
1124
+				),
1125
+			],
1126
+			'declined_status'   => [
1127
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_declined,
1128
+				'desc'  => EEH_Template::pretty_status(
1129
+					EEM_Registration::status_id_declined,
1130
+					false,
1131
+					'sentence'
1132
+				),
1133
+			],
1134
+			'cancelled_status'  => [
1135
+				'class' => 'ee-status-legend ee-status-bg--' . EEM_Registration::status_id_cancelled,
1136
+				'desc'  => EEH_Template::pretty_status(
1137
+					EEM_Registration::status_id_cancelled,
1138
+					false,
1139
+					'sentence'
1140
+				),
1141
+			],
1142
+		];
1143
+		return array_merge($fc_items, $sc_items);
1144
+	}
1145
+
1146
+
1147
+
1148
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1149
+
1150
+
1151
+	/**
1152
+	 * @throws DomainException
1153
+	 * @throws EE_Error
1154
+	 * @throws InvalidArgumentException
1155
+	 * @throws InvalidDataTypeException
1156
+	 * @throws InvalidInterfaceException
1157
+	 */
1158
+	protected function _registrations_overview_list_table()
1159
+	{
1160
+		$this->appendAddNewRegistrationButtonToPageTitle();
1161
+		$header_text                  = '';
1162
+		$admin_page_header_decorators = [
1163
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1164
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1165
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1166
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1167
+		];
1168
+		foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1169
+			$filter_header_decorator = $this->loader->getNew($admin_page_header_decorator);
1170
+			$header_text = $filter_header_decorator->getHeaderText($header_text);
1171
+		}
1172
+		$this->_template_args['admin_page_header'] = $header_text;
1173
+		$this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1174
+		$this->display_admin_list_table_page_with_no_sidebar();
1175
+	}
1176
+
1177
+
1178
+	/**
1179
+	 * @throws EE_Error
1180
+	 * @throws InvalidArgumentException
1181
+	 * @throws InvalidDataTypeException
1182
+	 * @throws InvalidInterfaceException
1183
+	 */
1184
+	private function appendAddNewRegistrationButtonToPageTitle()
1185
+	{
1186
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1187
+		if (
1188
+			$EVT_ID
1189
+			&& EE_Registry::instance()->CAP->current_user_can(
1190
+				'ee_edit_registrations',
1191
+				'espresso_registrations_new_registration',
1192
+				$EVT_ID
1193
+			)
1194
+		) {
1195
+			$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1196
+				'new_registration',
1197
+				'add-registrant',
1198
+				['event_id' => $EVT_ID],
1199
+				'add-new-h2'
1200
+			);
1201
+		}
1202
+	}
1203
+
1204
+
1205
+	/**
1206
+	 * This sets the _registration property for the registration details screen
1207
+	 *
1208
+	 * @return void
1209
+	 * @throws EE_Error
1210
+	 * @throws InvalidArgumentException
1211
+	 * @throws InvalidDataTypeException
1212
+	 * @throws InvalidInterfaceException
1213
+	 */
1214
+	private function _set_registration_object()
1215
+	{
1216
+		// get out if we've already set the object
1217
+		if ($this->_registration instanceof EE_Registration) {
1218
+			return;
1219
+		}
1220
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1221
+		if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1222
+			return;
1223
+		}
1224
+		$error_msg = sprintf(
1225
+			esc_html__(
1226
+				'An error occurred and the details for Registration ID #%s could not be retrieved.',
1227
+				'event_espresso'
1228
+			),
1229
+			$REG_ID
1230
+		);
1231
+		EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1232
+		$this->_registration = null;
1233
+	}
1234
+
1235
+
1236
+	/**
1237
+	 * Used to retrieve registrations for the list table.
1238
+	 *
1239
+	 * @param int  $per_page
1240
+	 * @param bool $count
1241
+	 * @param bool $this_month
1242
+	 * @param bool $today
1243
+	 * @return EE_Registration[]|int
1244
+	 * @throws EE_Error
1245
+	 * @throws InvalidArgumentException
1246
+	 * @throws InvalidDataTypeException
1247
+	 * @throws InvalidInterfaceException
1248
+	 */
1249
+	public function get_registrations(
1250
+		$per_page = 10,
1251
+		$count = false,
1252
+		$this_month = false,
1253
+		$today = false
1254
+	) {
1255
+		if ($this_month) {
1256
+			$this->request->setRequestParam('status', 'month');
1257
+		}
1258
+		if ($today) {
1259
+			$this->request->setRequestParam('status', 'today');
1260
+		}
1261
+		$query_params = $this->_get_registration_query_parameters($this->request->requestParams(), $per_page, $count);
1262
+		/**
1263
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1264
+		 *
1265
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1266
+		 * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1267
+		 *                      or if you have the development copy of EE you can view this at the path:
1268
+		 *                      /docs/G--Model-System/model-query-params.md
1269
+		 */
1270
+		$query_params['group_by'] = '';
1271
+
1272
+		return $count
1273
+			? $this->getRegistrationModel()->count($query_params)
1274
+			/** @type EE_Registration[] */
1275
+			: $this->getRegistrationModel()->get_all($query_params);
1276
+	}
1277
+
1278
+
1279
+	/**
1280
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1281
+	 * Note: this listens to values on the request for some of the query parameters.
1282
+	 *
1283
+	 * @param array $request
1284
+	 * @param int   $per_page
1285
+	 * @param bool  $count
1286
+	 * @return array
1287
+	 * @throws EE_Error
1288
+	 * @throws InvalidArgumentException
1289
+	 * @throws InvalidDataTypeException
1290
+	 * @throws InvalidInterfaceException
1291
+	 */
1292
+	protected function _get_registration_query_parameters(
1293
+		$request = [],
1294
+		$per_page = 10,
1295
+		$count = false
1296
+	) {
1297
+		/** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1298
+		$list_table_query_builder = $this->loader->getNew(
1299
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1300
+			[null, null, $request]
1301
+		);
1302
+		return $list_table_query_builder->getQueryParams($per_page, $count);
1303
+	}
1304
+
1305
+
1306
+	public function get_registration_status_array()
1307
+	{
1308
+		return self::$_reg_status;
1309
+	}
1310
+
1311
+
1312
+
1313
+
1314
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1315
+	/**
1316
+	 * generates HTML for the View Registration Details Admin page
1317
+	 *
1318
+	 * @return void
1319
+	 * @throws DomainException
1320
+	 * @throws EE_Error
1321
+	 * @throws InvalidArgumentException
1322
+	 * @throws InvalidDataTypeException
1323
+	 * @throws InvalidInterfaceException
1324
+	 * @throws EntityNotFoundException
1325
+	 * @throws ReflectionException
1326
+	 */
1327
+	protected function _registration_details()
1328
+	{
1329
+		$this->_template_args = [];
1330
+		$this->_set_registration_object();
1331
+		if (is_object($this->_registration)) {
1332
+			$transaction                                   = $this->_registration->transaction()
1333
+				? $this->_registration->transaction()
1334
+				: EE_Transaction::new_instance();
1335
+			$this->_session                                = $transaction->session_data();
1336
+			$event_id                                      = $this->_registration->event_ID();
1337
+			$this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1338
+			$this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1339
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1340
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1341
+			$this->_template_args['grand_total']           = $transaction->total();
1342
+			$this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1343
+			// link back to overview
1344
+			$this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1345
+			$this->_template_args['registration']                = $this->_registration;
1346
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1347
+				[
1348
+					'action'   => 'default',
1349
+					'event_id' => $event_id,
1350
+				],
1351
+				REG_ADMIN_URL
1352
+			);
1353
+			$this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1354
+				[
1355
+					'action' => 'default',
1356
+					'EVT_ID' => $event_id,
1357
+					'page'   => 'espresso_transactions',
1358
+				],
1359
+				admin_url('admin.php')
1360
+			);
1361
+			$this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1362
+				[
1363
+					'page'   => 'espresso_events',
1364
+					'action' => 'edit',
1365
+					'post'   => $event_id,
1366
+				],
1367
+				admin_url('admin.php')
1368
+			);
1369
+			// next and previous links
1370
+			$next_reg                                      = $this->_registration->next(
1371
+				null,
1372
+				[],
1373
+				'REG_ID'
1374
+			);
1375
+			$this->_template_args['next_registration']     = $next_reg
1376
+				? $this->_next_link(
1377
+					EE_Admin_Page::add_query_args_and_nonce(
1378
+						[
1379
+							'action'  => 'view_registration',
1380
+							'_REG_ID' => $next_reg['REG_ID'],
1381
+						],
1382
+						REG_ADMIN_URL
1383
+					),
1384
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1385
+				)
1386
+				: '';
1387
+			$previous_reg                                  = $this->_registration->previous(
1388
+				null,
1389
+				[],
1390
+				'REG_ID'
1391
+			);
1392
+			$this->_template_args['previous_registration'] = $previous_reg
1393
+				? $this->_previous_link(
1394
+					EE_Admin_Page::add_query_args_and_nonce(
1395
+						[
1396
+							'action'  => 'view_registration',
1397
+							'_REG_ID' => $previous_reg['REG_ID'],
1398
+						],
1399
+						REG_ADMIN_URL
1400
+					),
1401
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1402
+				)
1403
+				: '';
1404
+			// grab header
1405
+			$template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1406
+			$this->_template_args['REG_ID']            = $this->_registration->ID();
1407
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1408
+				$template_path,
1409
+				$this->_template_args,
1410
+				true
1411
+			);
1412
+		} else {
1413
+			$this->_template_args['admin_page_header'] = '';
1414
+			$this->_display_espresso_notices();
1415
+		}
1416
+		// the details template wrapper
1417
+		$this->display_admin_page_with_sidebar();
1418
+	}
1419
+
1420
+
1421
+	/**
1422
+	 * @throws EE_Error
1423
+	 * @throws InvalidArgumentException
1424
+	 * @throws InvalidDataTypeException
1425
+	 * @throws InvalidInterfaceException
1426
+	 * @throws ReflectionException
1427
+	 * @since 4.10.2.p
1428
+	 */
1429
+	protected function _registration_details_metaboxes()
1430
+	{
1431
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1432
+		$this->_set_registration_object();
1433
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1434
+		$this->addMetaBox(
1435
+			'edit-reg-status-mbox',
1436
+			esc_html__('Registration Status', 'event_espresso'),
1437
+			[$this, 'set_reg_status_buttons_metabox'],
1438
+			$this->_wp_page_slug
1439
+		);
1440
+		$this->addMetaBox(
1441
+			'edit-reg-details-mbox',
1442
+			'<span>' . esc_html__('Registration Details', 'event_espresso')
1443
+			. '&nbsp;<span class="dashicons dashicons-clipboard"></span></span>',
1444
+			[$this, '_reg_details_meta_box'],
1445
+			$this->_wp_page_slug
1446
+		);
1447
+		if (
1448
+			$attendee instanceof EE_Attendee
1449
+			&& EE_Registry::instance()->CAP->current_user_can(
1450
+				'ee_read_registration',
1451
+				'edit-reg-questions-mbox',
1452
+				$this->_registration->ID()
1453
+			)
1454
+		) {
1455
+			$this->addMetaBox(
1456
+				'edit-reg-questions-mbox',
1457
+				esc_html__('Registration Form Answers', 'event_espresso'),
1458
+				[$this, '_reg_questions_meta_box'],
1459
+				$this->_wp_page_slug
1460
+			);
1461
+		}
1462
+		$this->addMetaBox(
1463
+			'edit-reg-registrant-mbox',
1464
+			esc_html__('Contact Details', 'event_espresso'),
1465
+			[$this, '_reg_registrant_side_meta_box'],
1466
+			$this->_wp_page_slug,
1467
+			'side'
1468
+		);
1469
+		if ($this->_registration->group_size() > 1) {
1470
+			$this->addMetaBox(
1471
+				'edit-reg-attendees-mbox',
1472
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1473
+				[$this, '_reg_attendees_meta_box'],
1474
+				$this->_wp_page_slug
1475
+			);
1476
+		}
1477
+	}
1478
+
1479
+
1480
+	/**
1481
+	 * set_reg_status_buttons_metabox
1482
+	 *
1483
+	 * @return void
1484
+	 * @throws EE_Error
1485
+	 * @throws EntityNotFoundException
1486
+	 * @throws InvalidArgumentException
1487
+	 * @throws InvalidDataTypeException
1488
+	 * @throws InvalidInterfaceException
1489
+	 * @throws ReflectionException
1490
+	 */
1491
+	public function set_reg_status_buttons_metabox()
1492
+	{
1493
+		$this->_set_registration_object();
1494
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1495
+		$output                 = $change_reg_status_form->form_open(
1496
+			self::add_query_args_and_nonce(
1497
+				[
1498
+					'action' => 'change_reg_status',
1499
+				],
1500
+				REG_ADMIN_URL
1501
+			)
1502
+		);
1503
+		$output                 .= $change_reg_status_form->get_html();
1504
+		$output                 .= $change_reg_status_form->form_close();
1505
+		echo wp_kses($output, AllowedTags::getWithFormTags());
1506
+	}
1507
+
1508
+
1509
+	/**
1510
+	 * @return EE_Form_Section_Proper
1511
+	 * @throws EE_Error
1512
+	 * @throws InvalidArgumentException
1513
+	 * @throws InvalidDataTypeException
1514
+	 * @throws InvalidInterfaceException
1515
+	 * @throws EntityNotFoundException
1516
+	 * @throws ReflectionException
1517
+	 */
1518
+	protected function _generate_reg_status_change_form()
1519
+	{
1520
+		$reg_status_change_form_array = [
1521
+			'name'            => 'reg_status_change_form',
1522
+			'html_id'         => 'reg-status-change-form',
1523
+			'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1524
+			'subsections'     => [
1525
+				'return'         => new EE_Hidden_Input(
1526
+					[
1527
+						'name'    => 'return',
1528
+						'default' => 'view_registration',
1529
+					]
1530
+				),
1531
+				'REG_ID'         => new EE_Hidden_Input(
1532
+					[
1533
+						'name'    => 'REG_ID',
1534
+						'default' => $this->_registration->ID(),
1535
+					]
1536
+				),
1537
+			],
1538
+		];
1539
+		if (
1540
+			EE_Registry::instance()->CAP->current_user_can(
1541
+				'ee_edit_registration',
1542
+				'toggle_registration_status',
1543
+				$this->_registration->ID()
1544
+			)
1545
+		) {
1546
+			$reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1547
+				$this->_get_reg_statuses(),
1548
+				[
1549
+					'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1550
+					'default'         => $this->_registration->status_ID(),
1551
+				]
1552
+			);
1553
+			$reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1554
+				[
1555
+					'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1556
+					'default'         => false,
1557
+					'html_help_text'  => esc_html__(
1558
+						'If set to "Yes", then the related messages will be sent to the registrant.',
1559
+						'event_espresso'
1560
+					),
1561
+				]
1562
+			);
1563
+			$reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1564
+				[
1565
+					'html_class'      => 'button--primary',
1566
+					'html_label_text' => '&nbsp;',
1567
+					'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1568
+				]
1569
+			);
1570
+		}
1571
+		return new EE_Form_Section_Proper($reg_status_change_form_array);
1572
+	}
1573
+
1574
+
1575
+	/**
1576
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1577
+	 *
1578
+	 * @return array
1579
+	 * @throws EE_Error
1580
+	 * @throws InvalidArgumentException
1581
+	 * @throws InvalidDataTypeException
1582
+	 * @throws InvalidInterfaceException
1583
+	 * @throws EntityNotFoundException
1584
+	 */
1585
+	protected function _get_reg_statuses()
1586
+	{
1587
+		$reg_status_array = $this->getRegistrationModel()->reg_status_array();
1588
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1589
+		// get current reg status
1590
+		$current_status = $this->_registration->status_ID();
1591
+		// is registration for free event? This will determine whether to display the pending payment option
1592
+		if (
1593
+			$current_status !== EEM_Registration::status_id_pending_payment
1594
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1595
+		) {
1596
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1597
+		}
1598
+		return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1599
+	}
1600
+
1601
+
1602
+	/**
1603
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1604
+	 *
1605
+	 * @param bool $status REG status given for changing registrations to.
1606
+	 * @param bool $notify Whether to send messages notifications or not.
1607
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1608
+	 * @throws DomainException
1609
+	 * @throws EE_Error
1610
+	 * @throws EntityNotFoundException
1611
+	 * @throws InvalidArgumentException
1612
+	 * @throws InvalidDataTypeException
1613
+	 * @throws InvalidInterfaceException
1614
+	 * @throws ReflectionException
1615
+	 * @throws RuntimeException
1616
+	 */
1617
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1618
+	{
1619
+		$REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1620
+			? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1621
+			: $this->request->getRequestParam('_REG_ID', [], 'int', true);
1622
+
1623
+		// sanitize $REG_IDs
1624
+		$REG_IDs = array_map('absint', $REG_IDs);
1625
+		// and remove empty entries
1626
+		$REG_IDs = array_filter($REG_IDs);
1627
+
1628
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1629
+
1630
+		/**
1631
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1632
+		 * Currently this value is used downstream by the _process_resend_registration method.
1633
+		 *
1634
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1635
+		 * @param bool                     $status           The status registrations were changed to.
1636
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1637
+		 * @param Registrations_Admin_Page $admin_page_object
1638
+		 */
1639
+		$REG_ID = apply_filters(
1640
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1641
+			$result['REG_ID'],
1642
+			$status,
1643
+			$result['success'],
1644
+			$this
1645
+		);
1646
+		$this->request->setRequestParam('_REG_ID', $REG_ID);
1647
+
1648
+		// notify?
1649
+		if (
1650
+			$notify
1651
+			&& $result['success']
1652
+			&& ! empty($REG_ID)
1653
+			&& EE_Registry::instance()->CAP->current_user_can(
1654
+				'ee_send_message',
1655
+				'espresso_registrations_resend_registration'
1656
+			)
1657
+		) {
1658
+			$this->_process_resend_registration();
1659
+		}
1660
+		return $result;
1661
+	}
1662
+
1663
+
1664
+	/**
1665
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1666
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1667
+	 *
1668
+	 * @param array  $REG_IDs
1669
+	 * @param string $status
1670
+	 * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1671
+	 *                       slug sent with setting the registration status.
1672
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1673
+	 * @throws EE_Error
1674
+	 * @throws InvalidArgumentException
1675
+	 * @throws InvalidDataTypeException
1676
+	 * @throws InvalidInterfaceException
1677
+	 * @throws ReflectionException
1678
+	 * @throws RuntimeException
1679
+	 * @throws EntityNotFoundException
1680
+	 * @throws DomainException
1681
+	 */
1682
+	protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1683
+	{
1684
+		$success = false;
1685
+		// typecast $REG_IDs
1686
+		$REG_IDs = (array) $REG_IDs;
1687
+		if (! empty($REG_IDs)) {
1688
+			$success = true;
1689
+			// set default status if none is passed
1690
+			$status         = $status ?: EEM_Registration::status_id_pending_payment;
1691
+			$status_context = $notify
1692
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1693
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1694
+			// loop through REG_ID's and change status
1695
+			foreach ($REG_IDs as $REG_ID) {
1696
+				$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1697
+				if ($registration instanceof EE_Registration) {
1698
+					$registration->set_status(
1699
+						$status,
1700
+						false,
1701
+						new Context(
1702
+							$status_context,
1703
+							esc_html__(
1704
+								'Manually triggered status change on a Registration Admin Page route.',
1705
+								'event_espresso'
1706
+							)
1707
+						)
1708
+					);
1709
+					$result = $registration->save();
1710
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1711
+					$success = $result !== false ? $success : false;
1712
+				}
1713
+			}
1714
+		}
1715
+
1716
+		// return $success and processed registrations
1717
+		return ['REG_ID' => $REG_IDs, 'success' => $success];
1718
+	}
1719
+
1720
+
1721
+	/**
1722
+	 * Common logic for setting up success message and redirecting to appropriate route
1723
+	 *
1724
+	 * @param string $STS_ID status id for the registration changed to
1725
+	 * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1726
+	 * @return void
1727
+	 * @throws DomainException
1728
+	 * @throws EE_Error
1729
+	 * @throws EntityNotFoundException
1730
+	 * @throws InvalidArgumentException
1731
+	 * @throws InvalidDataTypeException
1732
+	 * @throws InvalidInterfaceException
1733
+	 * @throws ReflectionException
1734
+	 * @throws RuntimeException
1735
+	 */
1736
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1737
+	{
1738
+		$result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1739
+			: ['success' => false];
1740
+		$success = isset($result['success']) && $result['success'];
1741
+		// setup success message
1742
+		if ($success) {
1743
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1744
+				$msg = sprintf(
1745
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1746
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1747
+				);
1748
+			} else {
1749
+				$msg = sprintf(
1750
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
1751
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1752
+				);
1753
+			}
1754
+			EE_Error::add_success($msg);
1755
+		} else {
1756
+			EE_Error::add_error(
1757
+				esc_html__(
1758
+					'Something went wrong, and the status was not changed',
1759
+					'event_espresso'
1760
+				),
1761
+				__FILE__,
1762
+				__LINE__,
1763
+				__FUNCTION__
1764
+			);
1765
+		}
1766
+		$return = $this->request->getRequestParam('return');
1767
+		$route  = $return === 'view_registration'
1768
+			? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1769
+			: ['action' => 'default'];
1770
+		$route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1771
+		$this->_redirect_after_action($success, '', '', $route, true);
1772
+	}
1773
+
1774
+
1775
+	/**
1776
+	 * incoming reg status change from reg details page.
1777
+	 *
1778
+	 * @return void
1779
+	 * @throws EE_Error
1780
+	 * @throws EntityNotFoundException
1781
+	 * @throws InvalidArgumentException
1782
+	 * @throws InvalidDataTypeException
1783
+	 * @throws InvalidInterfaceException
1784
+	 * @throws ReflectionException
1785
+	 * @throws RuntimeException
1786
+	 * @throws DomainException
1787
+	 */
1788
+	protected function _change_reg_status()
1789
+	{
1790
+		$this->request->setRequestParam('return', 'view_registration');
1791
+		// set notify based on whether the send notifications toggle is set or not
1792
+		$notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1793
+		$reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1794
+		$this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1795
+		switch ($reg_status) {
1796
+			case EEM_Registration::status_id_approved:
1797
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1798
+				$this->approve_registration($notify);
1799
+				break;
1800
+			case EEM_Registration::status_id_pending_payment:
1801
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1802
+				$this->pending_registration($notify);
1803
+				break;
1804
+			case EEM_Registration::status_id_not_approved:
1805
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1806
+				$this->not_approve_registration($notify);
1807
+				break;
1808
+			case EEM_Registration::status_id_declined:
1809
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1810
+				$this->decline_registration($notify);
1811
+				break;
1812
+			case EEM_Registration::status_id_cancelled:
1813
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1814
+				$this->cancel_registration($notify);
1815
+				break;
1816
+			case EEM_Registration::status_id_wait_list:
1817
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1818
+				$this->wait_list_registration($notify);
1819
+				break;
1820
+			case EEM_Registration::status_id_incomplete:
1821
+			default:
1822
+				$this->request->unSetRequestParam('return');
1823
+				$this->_reg_status_change_return('');
1824
+				break;
1825
+		}
1826
+	}
1827
+
1828
+
1829
+	/**
1830
+	 * Callback for bulk action routes.
1831
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1832
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
1833
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1834
+	 * when an action is happening on just a single registration).
1835
+	 *
1836
+	 * @param      $action
1837
+	 * @param bool $notify
1838
+	 */
1839
+	protected function bulk_action_on_registrations($action, $notify = false)
1840
+	{
1841
+		do_action(
1842
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1843
+			$this,
1844
+			$action,
1845
+			$notify
1846
+		);
1847
+		$method = $action . '_registration';
1848
+		if (method_exists($this, $method)) {
1849
+			$this->$method($notify);
1850
+		}
1851
+	}
1852
+
1853
+
1854
+	/**
1855
+	 * approve_registration
1856
+	 *
1857
+	 * @param bool $notify whether or not to notify the registrant about their approval.
1858
+	 * @return void
1859
+	 * @throws EE_Error
1860
+	 * @throws EntityNotFoundException
1861
+	 * @throws InvalidArgumentException
1862
+	 * @throws InvalidDataTypeException
1863
+	 * @throws InvalidInterfaceException
1864
+	 * @throws ReflectionException
1865
+	 * @throws RuntimeException
1866
+	 * @throws DomainException
1867
+	 */
1868
+	protected function approve_registration($notify = false)
1869
+	{
1870
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1871
+	}
1872
+
1873
+
1874
+	/**
1875
+	 * decline_registration
1876
+	 *
1877
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1878
+	 * @return void
1879
+	 * @throws EE_Error
1880
+	 * @throws EntityNotFoundException
1881
+	 * @throws InvalidArgumentException
1882
+	 * @throws InvalidDataTypeException
1883
+	 * @throws InvalidInterfaceException
1884
+	 * @throws ReflectionException
1885
+	 * @throws RuntimeException
1886
+	 * @throws DomainException
1887
+	 */
1888
+	protected function decline_registration($notify = false)
1889
+	{
1890
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1891
+	}
1892
+
1893
+
1894
+	/**
1895
+	 * cancel_registration
1896
+	 *
1897
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1898
+	 * @return void
1899
+	 * @throws EE_Error
1900
+	 * @throws EntityNotFoundException
1901
+	 * @throws InvalidArgumentException
1902
+	 * @throws InvalidDataTypeException
1903
+	 * @throws InvalidInterfaceException
1904
+	 * @throws ReflectionException
1905
+	 * @throws RuntimeException
1906
+	 * @throws DomainException
1907
+	 */
1908
+	protected function cancel_registration($notify = false)
1909
+	{
1910
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1911
+	}
1912
+
1913
+
1914
+	/**
1915
+	 * not_approve_registration
1916
+	 *
1917
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1918
+	 * @return void
1919
+	 * @throws EE_Error
1920
+	 * @throws EntityNotFoundException
1921
+	 * @throws InvalidArgumentException
1922
+	 * @throws InvalidDataTypeException
1923
+	 * @throws InvalidInterfaceException
1924
+	 * @throws ReflectionException
1925
+	 * @throws RuntimeException
1926
+	 * @throws DomainException
1927
+	 */
1928
+	protected function not_approve_registration($notify = false)
1929
+	{
1930
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1931
+	}
1932
+
1933
+
1934
+	/**
1935
+	 * decline_registration
1936
+	 *
1937
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1938
+	 * @return void
1939
+	 * @throws EE_Error
1940
+	 * @throws EntityNotFoundException
1941
+	 * @throws InvalidArgumentException
1942
+	 * @throws InvalidDataTypeException
1943
+	 * @throws InvalidInterfaceException
1944
+	 * @throws ReflectionException
1945
+	 * @throws RuntimeException
1946
+	 * @throws DomainException
1947
+	 */
1948
+	protected function pending_registration($notify = false)
1949
+	{
1950
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1951
+	}
1952
+
1953
+
1954
+	/**
1955
+	 * waitlist_registration
1956
+	 *
1957
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1958
+	 * @return void
1959
+	 * @throws EE_Error
1960
+	 * @throws EntityNotFoundException
1961
+	 * @throws InvalidArgumentException
1962
+	 * @throws InvalidDataTypeException
1963
+	 * @throws InvalidInterfaceException
1964
+	 * @throws ReflectionException
1965
+	 * @throws RuntimeException
1966
+	 * @throws DomainException
1967
+	 */
1968
+	protected function wait_list_registration($notify = false)
1969
+	{
1970
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1971
+	}
1972
+
1973
+
1974
+	/**
1975
+	 * generates HTML for the Registration main meta box
1976
+	 *
1977
+	 * @return void
1978
+	 * @throws DomainException
1979
+	 * @throws EE_Error
1980
+	 * @throws InvalidArgumentException
1981
+	 * @throws InvalidDataTypeException
1982
+	 * @throws InvalidInterfaceException
1983
+	 * @throws ReflectionException
1984
+	 * @throws EntityNotFoundException
1985
+	 */
1986
+	public function _reg_details_meta_box()
1987
+	{
1988
+		EEH_Autoloader::register_line_item_display_autoloaders();
1989
+		EEH_Autoloader::register_line_item_filter_autoloaders();
1990
+		EE_Registry::instance()->load_helper('Line_Item');
1991
+		$transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
1992
+			: EE_Transaction::new_instance();
1993
+		$this->_session = $transaction->session_data();
1994
+		$filters        = new EE_Line_Item_Filter_Collection();
1995
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
1996
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
1997
+		$line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
1998
+			$filters,
1999
+			$transaction->total_line_item()
2000
+		);
2001
+		$filtered_line_item_tree                 = $line_item_filter_processor->process();
2002
+		$line_item_display                       = new EE_Line_Item_Display(
2003
+			'reg_admin_table',
2004
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2005
+		);
2006
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2007
+			$filtered_line_item_tree,
2008
+			['EE_Registration' => $this->_registration]
2009
+		);
2010
+		$attendee                                = $this->_registration->attendee();
2011
+		if (
2012
+			EE_Registry::instance()->CAP->current_user_can(
2013
+				'ee_read_transaction',
2014
+				'espresso_transactions_view_transaction'
2015
+			)
2016
+		) {
2017
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2018
+				EE_Admin_Page::add_query_args_and_nonce(
2019
+					[
2020
+						'action' => 'view_transaction',
2021
+						'TXN_ID' => $transaction->ID(),
2022
+					],
2023
+					TXN_ADMIN_URL
2024
+				),
2025
+				esc_html__(' View Transaction', 'event_espresso'),
2026
+				'button button--secondary right',
2027
+				'dashicons dashicons-cart'
2028
+			);
2029
+		} else {
2030
+			$this->_template_args['view_transaction_button'] = '';
2031
+		}
2032
+		if (
2033
+			$attendee instanceof EE_Attendee
2034
+			&& EE_Registry::instance()->CAP->current_user_can(
2035
+				'ee_send_message',
2036
+				'espresso_registrations_resend_registration'
2037
+			)
2038
+		) {
2039
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2040
+				EE_Admin_Page::add_query_args_and_nonce(
2041
+					[
2042
+						'action'      => 'resend_registration',
2043
+						'_REG_ID'     => $this->_registration->ID(),
2044
+						'redirect_to' => 'view_registration',
2045
+					],
2046
+					REG_ADMIN_URL
2047
+				),
2048
+				esc_html__(' Resend Registration', 'event_espresso'),
2049
+				'button button--secondary right',
2050
+				'dashicons dashicons-email-alt'
2051
+			);
2052
+		} else {
2053
+			$this->_template_args['resend_registration_button'] = '';
2054
+		}
2055
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2056
+		$payment                               = $transaction->get_first_related('Payment');
2057
+		$payment                               = ! $payment instanceof EE_Payment
2058
+			? EE_Payment::new_instance()
2059
+			: $payment;
2060
+		$payment_method                        = $payment->get_first_related('Payment_Method');
2061
+		$payment_method                        = ! $payment_method instanceof EE_Payment_Method
2062
+			? EE_Payment_Method::new_instance()
2063
+			: $payment_method;
2064
+		$reg_details                           = [
2065
+			'payment_method'       => $payment_method->name(),
2066
+			'response_msg'         => $payment->gateway_response(),
2067
+			'registration_id'      => $this->_registration->get('REG_code'),
2068
+			'registration_session' => $this->_registration->session_ID(),
2069
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2070
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2071
+		];
2072
+		if (isset($reg_details['registration_id'])) {
2073
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2074
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2075
+				'Registration ID',
2076
+				'event_espresso'
2077
+			);
2078
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2079
+		}
2080
+		if (isset($reg_details['payment_method'])) {
2081
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2082
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2083
+				'Most Recent Payment Method',
2084
+				'event_espresso'
2085
+			);
2086
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2087
+			$this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2088
+			$this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2089
+				'Payment method response',
2090
+				'event_espresso'
2091
+			);
2092
+			$this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2093
+		}
2094
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2095
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2096
+			'Registration Session',
2097
+			'event_espresso'
2098
+		);
2099
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2100
+		$this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2101
+		$this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2102
+			'Registration placed from IP',
2103
+			'event_espresso'
2104
+		);
2105
+		$this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2106
+		$this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2107
+		$this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2108
+			'Registrant User Agent',
2109
+			'event_espresso'
2110
+		);
2111
+		$this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2112
+		$this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2113
+			[
2114
+				'action'   => 'default',
2115
+				'event_id' => $this->_registration->event_ID(),
2116
+			],
2117
+			REG_ADMIN_URL
2118
+		);
2119
+
2120
+		$this->_template_args['REG_ID'] = $this->_registration->ID();
2121
+		$this->_template_args['event_id'] = $this->_registration->event_ID();
2122
+
2123
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2124
+		EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2125
+	}
2126
+
2127
+
2128
+	/**
2129
+	 * generates HTML for the Registration Questions meta box.
2130
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2131
+	 * otherwise uses new forms system
2132
+	 *
2133
+	 * @return void
2134
+	 * @throws DomainException
2135
+	 * @throws EE_Error
2136
+	 * @throws InvalidArgumentException
2137
+	 * @throws InvalidDataTypeException
2138
+	 * @throws InvalidInterfaceException
2139
+	 * @throws ReflectionException
2140
+	 */
2141
+	public function _reg_questions_meta_box()
2142
+	{
2143
+		// allow someone to override this method entirely
2144
+		if (
2145
+			apply_filters(
2146
+				'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2147
+				true,
2148
+				$this,
2149
+				$this->_registration
2150
+			)
2151
+		) {
2152
+			$form = $this->_get_reg_custom_questions_form(
2153
+				$this->_registration->ID()
2154
+			);
2155
+
2156
+			$this->_template_args['att_questions'] = count($form->subforms()) > 0
2157
+				? $form->get_html_and_js()
2158
+				: '';
2159
+
2160
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2161
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
2162
+			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2163
+			EEH_Template::display_template($template_path, $this->_template_args);
2164
+		}
2165
+	}
2166
+
2167
+
2168
+	/**
2169
+	 * form_before_question_group
2170
+	 *
2171
+	 * @param string $output
2172
+	 * @return        string
2173
+	 * @deprecated    as of 4.8.32.rc.000
2174
+	 */
2175
+	public function form_before_question_group($output)
2176
+	{
2177
+		EE_Error::doing_it_wrong(
2178
+			__CLASS__ . '::' . __FUNCTION__,
2179
+			esc_html__(
2180
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2181
+				'event_espresso'
2182
+			),
2183
+			'4.8.32.rc.000'
2184
+		);
2185
+		return '
2186 2186
 	<table class="form-table ee-width-100">
2187 2187
 		<tbody>
2188 2188
 			';
2189
-    }
2190
-
2191
-
2192
-    /**
2193
-     * form_after_question_group
2194
-     *
2195
-     * @param string $output
2196
-     * @return        string
2197
-     * @deprecated    as of 4.8.32.rc.000
2198
-     */
2199
-    public function form_after_question_group($output)
2200
-    {
2201
-        EE_Error::doing_it_wrong(
2202
-            __CLASS__ . '::' . __FUNCTION__,
2203
-            esc_html__(
2204
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2205
-                'event_espresso'
2206
-            ),
2207
-            '4.8.32.rc.000'
2208
-        );
2209
-        return '
2189
+	}
2190
+
2191
+
2192
+	/**
2193
+	 * form_after_question_group
2194
+	 *
2195
+	 * @param string $output
2196
+	 * @return        string
2197
+	 * @deprecated    as of 4.8.32.rc.000
2198
+	 */
2199
+	public function form_after_question_group($output)
2200
+	{
2201
+		EE_Error::doing_it_wrong(
2202
+			__CLASS__ . '::' . __FUNCTION__,
2203
+			esc_html__(
2204
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2205
+				'event_espresso'
2206
+			),
2207
+			'4.8.32.rc.000'
2208
+		);
2209
+		return '
2210 2210
 			<tr class="hide-if-no-js">
2211 2211
 				<th> </th>
2212 2212
 				<td class="reg-admin-edit-attendee-question-td">
2213 2213
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2214
-               . esc_attr__('click to edit question', 'event_espresso')
2215
-               . '">
2214
+			   . esc_attr__('click to edit question', 'event_espresso')
2215
+			   . '">
2216 2216
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2217
-               . esc_html__('edit the above question group', 'event_espresso')
2218
-               . '</span>
2217
+			   . esc_html__('edit the above question group', 'event_espresso')
2218
+			   . '</span>
2219 2219
 						<div class="dashicons dashicons-edit"></div>
2220 2220
 					</a>
2221 2221
 				</td>
@@ -2223,636 +2223,636 @@  discard block
 block discarded – undo
2223 2223
 		</tbody>
2224 2224
 	</table>
2225 2225
 ';
2226
-    }
2227
-
2228
-
2229
-    /**
2230
-     * form_form_field_label_wrap
2231
-     *
2232
-     * @param string $label
2233
-     * @return        string
2234
-     * @deprecated    as of 4.8.32.rc.000
2235
-     */
2236
-    public function form_form_field_label_wrap($label)
2237
-    {
2238
-        EE_Error::doing_it_wrong(
2239
-            __CLASS__ . '::' . __FUNCTION__,
2240
-            esc_html__(
2241
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2242
-                'event_espresso'
2243
-            ),
2244
-            '4.8.32.rc.000'
2245
-        );
2246
-        return '
2226
+	}
2227
+
2228
+
2229
+	/**
2230
+	 * form_form_field_label_wrap
2231
+	 *
2232
+	 * @param string $label
2233
+	 * @return        string
2234
+	 * @deprecated    as of 4.8.32.rc.000
2235
+	 */
2236
+	public function form_form_field_label_wrap($label)
2237
+	{
2238
+		EE_Error::doing_it_wrong(
2239
+			__CLASS__ . '::' . __FUNCTION__,
2240
+			esc_html__(
2241
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2242
+				'event_espresso'
2243
+			),
2244
+			'4.8.32.rc.000'
2245
+		);
2246
+		return '
2247 2247
 			<tr>
2248 2248
 				<th>
2249 2249
 					' . $label . '
2250 2250
 				</th>';
2251
-    }
2252
-
2253
-
2254
-    /**
2255
-     * form_form_field_input__wrap
2256
-     *
2257
-     * @param string $input
2258
-     * @return        string
2259
-     * @deprecated    as of 4.8.32.rc.000
2260
-     */
2261
-    public function form_form_field_input__wrap($input)
2262
-    {
2263
-        EE_Error::doing_it_wrong(
2264
-            __CLASS__ . '::' . __FUNCTION__,
2265
-            esc_html__(
2266
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2267
-                'event_espresso'
2268
-            ),
2269
-            '4.8.32.rc.000'
2270
-        );
2271
-        return '
2251
+	}
2252
+
2253
+
2254
+	/**
2255
+	 * form_form_field_input__wrap
2256
+	 *
2257
+	 * @param string $input
2258
+	 * @return        string
2259
+	 * @deprecated    as of 4.8.32.rc.000
2260
+	 */
2261
+	public function form_form_field_input__wrap($input)
2262
+	{
2263
+		EE_Error::doing_it_wrong(
2264
+			__CLASS__ . '::' . __FUNCTION__,
2265
+			esc_html__(
2266
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2267
+				'event_espresso'
2268
+			),
2269
+			'4.8.32.rc.000'
2270
+		);
2271
+		return '
2272 2272
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2273 2273
 					' . $input . '
2274 2274
 				</td>
2275 2275
 			</tr>';
2276
-    }
2277
-
2278
-
2279
-    /**
2280
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2281
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2282
-     * to display the page
2283
-     *
2284
-     * @return void
2285
-     * @throws EE_Error
2286
-     * @throws InvalidArgumentException
2287
-     * @throws InvalidDataTypeException
2288
-     * @throws InvalidInterfaceException
2289
-     * @throws ReflectionException
2290
-     */
2291
-    protected function _update_attendee_registration_form()
2292
-    {
2293
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2294
-        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2295
-            $REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2296
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2297
-            if ($success) {
2298
-                $what  = esc_html__('Registration Form', 'event_espresso');
2299
-                $route = $REG_ID
2300
-                    ? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2301
-                    : ['action' => 'default'];
2302
-                $this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2303
-            }
2304
-        }
2305
-    }
2306
-
2307
-
2308
-    /**
2309
-     * Gets the form for saving registrations custom questions (if done
2310
-     * previously retrieves the cached form object, which may have validation errors in it)
2311
-     *
2312
-     * @param int $REG_ID
2313
-     * @return EE_Registration_Custom_Questions_Form
2314
-     * @throws EE_Error
2315
-     * @throws InvalidArgumentException
2316
-     * @throws InvalidDataTypeException
2317
-     * @throws InvalidInterfaceException
2318
-     * @throws ReflectionException
2319
-     */
2320
-    protected function _get_reg_custom_questions_form($REG_ID)
2321
-    {
2322
-        if (! $this->_reg_custom_questions_form) {
2323
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2324
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2325
-                $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2326
-            );
2327
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2328
-        }
2329
-        return $this->_reg_custom_questions_form;
2330
-    }
2331
-
2332
-
2333
-    /**
2334
-     * Saves
2335
-     *
2336
-     * @param bool $REG_ID
2337
-     * @return bool
2338
-     * @throws EE_Error
2339
-     * @throws InvalidArgumentException
2340
-     * @throws InvalidDataTypeException
2341
-     * @throws InvalidInterfaceException
2342
-     * @throws ReflectionException
2343
-     */
2344
-    private function _save_reg_custom_questions_form($REG_ID = 0)
2345
-    {
2346
-        if (! $REG_ID) {
2347
-            EE_Error::add_error(
2348
-                esc_html__(
2349
-                    'An error occurred. No registration ID was received.',
2350
-                    'event_espresso'
2351
-                ),
2352
-                __FILE__,
2353
-                __FUNCTION__,
2354
-                __LINE__
2355
-            );
2356
-        }
2357
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2358
-        $form->receive_form_submission($this->request->requestParams());
2359
-        $success = false;
2360
-        if ($form->is_valid()) {
2361
-            foreach ($form->subforms() as $question_group_form) {
2362
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2363
-                    $where_conditions    = [
2364
-                        'QST_ID' => $question_id,
2365
-                        'REG_ID' => $REG_ID,
2366
-                    ];
2367
-                    $possibly_new_values = [
2368
-                        'ANS_value' => $input->normalized_value(),
2369
-                    ];
2370
-                    $answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2371
-                    if ($answer instanceof EE_Answer) {
2372
-                        $success = $answer->save($possibly_new_values);
2373
-                    } else {
2374
-                        // insert it then
2375
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2376
-                        $answer      = EE_Answer::new_instance($cols_n_vals);
2377
-                        $success     = $answer->save();
2378
-                    }
2379
-                }
2380
-            }
2381
-        } else {
2382
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2383
-        }
2384
-        return $success;
2385
-    }
2386
-
2387
-
2388
-    /**
2389
-     * generates HTML for the Registration main meta box
2390
-     *
2391
-     * @return void
2392
-     * @throws DomainException
2393
-     * @throws EE_Error
2394
-     * @throws InvalidArgumentException
2395
-     * @throws InvalidDataTypeException
2396
-     * @throws InvalidInterfaceException
2397
-     * @throws ReflectionException
2398
-     */
2399
-    public function _reg_attendees_meta_box()
2400
-    {
2401
-        $REG = $this->getRegistrationModel();
2402
-        // get all other registrations on this transaction, and cache
2403
-        // the attendees for them so we don't have to run another query using force_join
2404
-        $registrations                           = $REG->get_all(
2405
-            [
2406
-                [
2407
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2408
-                    'REG_ID' => ['!=', $this->_registration->ID()],
2409
-                ],
2410
-                'force_join'               => ['Attendee'],
2411
-                'default_where_conditions' => 'other_models_only',
2412
-            ]
2413
-        );
2414
-        $this->_template_args['attendees']       = [];
2415
-        $this->_template_args['attendee_notice'] = '';
2416
-        if (
2417
-            empty($registrations)
2418
-            || (is_array($registrations)
2419
-                && ! EEH_Array::get_one_item_from_array($registrations))
2420
-        ) {
2421
-            EE_Error::add_error(
2422
-                esc_html__(
2423
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2424
-                    'event_espresso'
2425
-                ),
2426
-                __FILE__,
2427
-                __FUNCTION__,
2428
-                __LINE__
2429
-            );
2430
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2431
-        } else {
2432
-            $att_nmbr = 1;
2433
-            foreach ($registrations as $registration) {
2434
-                /* @var $registration EE_Registration */
2435
-                $attendee                                                      = $registration->attendee()
2436
-                    ? $registration->attendee()
2437
-                    : $this->getAttendeeModel()->create_default_object();
2438
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2439
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2440
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2441
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2442
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2443
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2444
-                    ', ',
2445
-                    $attendee->full_address_as_array()
2446
-                );
2447
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2448
-                    [
2449
-                        'action' => 'edit_attendee',
2450
-                        'post'   => $attendee->ID(),
2451
-                    ],
2452
-                    REG_ADMIN_URL
2453
-                );
2454
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2455
-                    $registration->event_obj() instanceof EE_Event
2456
-                        ? $registration->event_obj()->name()
2457
-                        : '';
2458
-                $att_nmbr++;
2459
-            }
2460
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2461
-        }
2462
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2463
-        EEH_Template::display_template($template_path, $this->_template_args);
2464
-    }
2465
-
2466
-
2467
-    /**
2468
-     * generates HTML for the Edit Registration side meta box
2469
-     *
2470
-     * @return void
2471
-     * @throws DomainException
2472
-     * @throws EE_Error
2473
-     * @throws InvalidArgumentException
2474
-     * @throws InvalidDataTypeException
2475
-     * @throws InvalidInterfaceException
2476
-     * @throws ReflectionException
2477
-     */
2478
-    public function _reg_registrant_side_meta_box()
2479
-    {
2480
-        /*@var $attendee EE_Attendee */
2481
-        $att_check = $this->_registration->attendee();
2482
-        $attendee  = $att_check instanceof EE_Attendee
2483
-            ? $att_check
2484
-            : $this->getAttendeeModel()->create_default_object();
2485
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2486
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2487
-        // primary registration object (that way we know if we need to show create button or not)
2488
-        if (! $this->_registration->is_primary_registrant()) {
2489
-            $primary_registration = $this->_registration->get_primary_registration();
2490
-            $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2491
-                : null;
2492
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2493
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2494
-                // custom attendee object so let's not worry about the primary reg.
2495
-                $primary_registration = null;
2496
-            }
2497
-        } else {
2498
-            $primary_registration = null;
2499
-        }
2500
-        $this->_template_args['ATT_ID']            = $attendee->ID();
2501
-        $this->_template_args['fname']             = $attendee->fname();
2502
-        $this->_template_args['lname']             = $attendee->lname();
2503
-        $this->_template_args['email']             = $attendee->email();
2504
-        $this->_template_args['phone']             = $attendee->phone();
2505
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2506
-        // edit link
2507
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2508
-            [
2509
-                'action' => 'edit_attendee',
2510
-                'post'   => $attendee->ID(),
2511
-            ],
2512
-            REG_ADMIN_URL
2513
-        );
2514
-        $this->_template_args['att_edit_title'] = esc_html__('View details for this contact.', 'event_espresso');
2515
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2516
-        // create link
2517
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2518
-            ? EE_Admin_Page::add_query_args_and_nonce(
2519
-                [
2520
-                    'action'  => 'duplicate_attendee',
2521
-                    '_REG_ID' => $this->_registration->ID(),
2522
-                ],
2523
-                REG_ADMIN_URL
2524
-            ) : '';
2525
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2526
-        $this->_template_args['att_check'] = $att_check;
2527
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2528
-        EEH_Template::display_template($template_path, $this->_template_args);
2529
-    }
2530
-
2531
-
2532
-    /**
2533
-     * trash or restore registrations
2534
-     *
2535
-     * @param boolean $trash whether to archive or restore
2536
-     * @return void
2537
-     * @throws EE_Error
2538
-     * @throws InvalidArgumentException
2539
-     * @throws InvalidDataTypeException
2540
-     * @throws InvalidInterfaceException
2541
-     * @throws RuntimeException
2542
-     */
2543
-    protected function _trash_or_restore_registrations($trash = true)
2544
-    {
2545
-        // if empty _REG_ID then get out because there's nothing to do
2546
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2547
-        if (empty($REG_IDs)) {
2548
-            EE_Error::add_error(
2549
-                sprintf(
2550
-                    esc_html__(
2551
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2552
-                        'event_espresso'
2553
-                    ),
2554
-                    $trash ? 'trash' : 'restore'
2555
-                ),
2556
-                __FILE__,
2557
-                __LINE__,
2558
-                __FUNCTION__
2559
-            );
2560
-            $this->_redirect_after_action(false, '', '', [], true);
2561
-        }
2562
-        $success        = 0;
2563
-        $overwrite_msgs = false;
2564
-        // Checkboxes
2565
-        $reg_count = count($REG_IDs);
2566
-        // cycle thru checkboxes
2567
-        foreach ($REG_IDs as $REG_ID) {
2568
-            /** @var EE_Registration $REG */
2569
-            $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2570
-            $payments = $REG->registration_payments();
2571
-            if (! empty($payments)) {
2572
-                $name           = $REG->attendee() instanceof EE_Attendee
2573
-                    ? $REG->attendee()->full_name()
2574
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2575
-                $overwrite_msgs = true;
2576
-                EE_Error::add_error(
2577
-                    sprintf(
2578
-                        esc_html__(
2579
-                            'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2580
-                            'event_espresso'
2581
-                        ),
2582
-                        $name
2583
-                    ),
2584
-                    __FILE__,
2585
-                    __FUNCTION__,
2586
-                    __LINE__
2587
-                );
2588
-                // can't trash this registration because it has payments.
2589
-                continue;
2590
-            }
2591
-            $updated = $trash ? $REG->delete() : $REG->restore();
2592
-            if ($updated) {
2593
-                $success++;
2594
-            }
2595
-        }
2596
-        $this->_redirect_after_action(
2597
-            $success === $reg_count, // were ALL registrations affected?
2598
-            $success > 1
2599
-                ? esc_html__('Registrations', 'event_espresso')
2600
-                : esc_html__('Registration', 'event_espresso'),
2601
-            $trash
2602
-                ? esc_html__('moved to the trash', 'event_espresso')
2603
-                : esc_html__('restored', 'event_espresso'),
2604
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2605
-            $overwrite_msgs
2606
-        );
2607
-    }
2608
-
2609
-
2610
-    /**
2611
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2612
-     * registration but also.
2613
-     * 1. Removing relations to EE_Attendee
2614
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2615
-     * ALSO trashed.
2616
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2617
-     * 4. Removing relationships between all tickets and the related registrations
2618
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2619
-     * 6. Deleting permanently any related Checkins.
2620
-     *
2621
-     * @return void
2622
-     * @throws EE_Error
2623
-     * @throws InvalidArgumentException
2624
-     * @throws InvalidDataTypeException
2625
-     * @throws InvalidInterfaceException
2626
-     * @throws ReflectionException
2627
-     */
2628
-    protected function _delete_registrations()
2629
-    {
2630
-        $REG_MDL = $this->getRegistrationModel();
2631
-        $success = 0;
2632
-        // Checkboxes
2633
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2634
-
2635
-        if (! empty($REG_IDs)) {
2636
-            // if array has more than one element than success message should be plural
2637
-            $success = count($REG_IDs) > 1 ? 2 : 1;
2638
-            // cycle thru checkboxes
2639
-            foreach ($REG_IDs as $REG_ID) {
2640
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2641
-                if (! $REG instanceof EE_Registration) {
2642
-                    continue;
2643
-                }
2644
-                $deleted = $this->_delete_registration($REG);
2645
-                if (! $deleted) {
2646
-                    $success = 0;
2647
-                }
2648
-            }
2649
-        }
2650
-
2651
-        $what        = $success > 1
2652
-            ? esc_html__('Registrations', 'event_espresso')
2653
-            : esc_html__('Registration', 'event_espresso');
2654
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2655
-        $this->_redirect_after_action(
2656
-            $success,
2657
-            $what,
2658
-            $action_desc,
2659
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2660
-            true
2661
-        );
2662
-    }
2663
-
2664
-
2665
-    /**
2666
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2667
-     * models get affected.
2668
-     *
2669
-     * @param EE_Registration $REG registration to be deleted permanently
2670
-     * @return bool true = successful deletion, false = fail.
2671
-     * @throws EE_Error
2672
-     * @throws InvalidArgumentException
2673
-     * @throws InvalidDataTypeException
2674
-     * @throws InvalidInterfaceException
2675
-     * @throws ReflectionException
2676
-     */
2677
-    protected function _delete_registration(EE_Registration $REG)
2678
-    {
2679
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2680
-        // registrations on the transaction that are NOT trashed.
2681
-        $TXN = $REG->get_first_related('Transaction');
2682
-        if (! $TXN instanceof EE_Transaction) {
2683
-            EE_Error::add_error(
2684
-                sprintf(
2685
-                    esc_html__(
2686
-                        'Unable to permanently delete registration %d because its related transaction has already been deleted. If you can restore the related transaction to the database then this registration can be deleted.',
2687
-                        'event_espresso'
2688
-                    ),
2689
-                    $REG->id()
2690
-                ),
2691
-                __FILE__,
2692
-                __FUNCTION__,
2693
-                __LINE__
2694
-            );
2695
-            return false;
2696
-        }
2697
-        $REGS        = $TXN->get_many_related('Registration');
2698
-        $all_trashed = true;
2699
-        foreach ($REGS as $registration) {
2700
-            if (! $registration->get('REG_deleted')) {
2701
-                $all_trashed = false;
2702
-            }
2703
-        }
2704
-        if (! $all_trashed) {
2705
-            EE_Error::add_error(
2706
-                esc_html__(
2707
-                    'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2708
-                    'event_espresso'
2709
-                ),
2710
-                __FILE__,
2711
-                __FUNCTION__,
2712
-                __LINE__
2713
-            );
2714
-            return false;
2715
-        }
2716
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2717
-        // separately from THIS one).
2718
-        foreach ($REGS as $registration) {
2719
-            // delete related answers
2720
-            $registration->delete_related_permanently('Answer');
2721
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2722
-            $attendee = $registration->get_first_related('Attendee');
2723
-            if ($attendee instanceof EE_Attendee) {
2724
-                $registration->_remove_relation_to($attendee, 'Attendee');
2725
-            }
2726
-            // now remove relationships to tickets on this registration.
2727
-            $registration->_remove_relations('Ticket');
2728
-            // now delete permanently the checkins related to this registration.
2729
-            $registration->delete_related_permanently('Checkin');
2730
-            if ($registration->ID() === $REG->ID()) {
2731
-                continue;
2732
-            } //we don't want to delete permanently the existing registration just yet.
2733
-            // remove relation to transaction for these registrations if NOT the existing registrations
2734
-            $registration->_remove_relations('Transaction');
2735
-            // delete permanently any related messages.
2736
-            $registration->delete_related_permanently('Message');
2737
-            // now delete this registration permanently
2738
-            $registration->delete_permanently();
2739
-        }
2740
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2741
-        // (the transaction and line items should be all that's left).
2742
-        // delete the line items related to the transaction for this registration.
2743
-        $TXN->delete_related_permanently('Line_Item');
2744
-        // we need to remove all the relationships on the transaction
2745
-        $TXN->delete_related_permanently('Payment');
2746
-        $TXN->delete_related_permanently('Extra_Meta');
2747
-        $TXN->delete_related_permanently('Message');
2748
-        // now we can delete this REG permanently (and the transaction of course)
2749
-        $REG->delete_related_permanently('Transaction');
2750
-        return $REG->delete_permanently();
2751
-    }
2752
-
2753
-
2754
-    /**
2755
-     *    generates HTML for the Register New Attendee Admin page
2756
-     *
2757
-     * @throws DomainException
2758
-     * @throws EE_Error
2759
-     * @throws InvalidArgumentException
2760
-     * @throws InvalidDataTypeException
2761
-     * @throws InvalidInterfaceException
2762
-     * @throws ReflectionException
2763
-     */
2764
-    public function new_registration()
2765
-    {
2766
-        if (! $this->_set_reg_event()) {
2767
-            throw new EE_Error(
2768
-                esc_html__(
2769
-                    'Unable to continue with registering because there is no Event ID in the request',
2770
-                    'event_espresso'
2771
-                )
2772
-            );
2773
-        }
2774
-        /** @var CurrentPage $current_page */
2775
-        $current_page = $this->loader->getShared(CurrentPage::class);
2776
-        $current_page->setEspressoPage(true);
2777
-        // gotta start with a clean slate if we're not coming here via ajax
2778
-        if (
2779
-            ! $this->request->isAjax()
2780
-            && (
2781
-                ! $this->request->requestParamIsSet('processing_registration')
2782
-                || $this->request->requestParamIsSet('step_error')
2783
-            )
2784
-        ) {
2785
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2786
-        }
2787
-        $this->_template_args['event_name'] = '';
2788
-        // event name
2789
-        if ($this->_reg_event) {
2790
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2791
-            $edit_event_url                     = self::add_query_args_and_nonce(
2792
-                [
2793
-                    'action' => 'edit',
2794
-                    'post'   => $this->_reg_event->ID(),
2795
-                ],
2796
-                EVENTS_ADMIN_URL
2797
-            );
2798
-            $edit_event_lnk                     = '<a href="'
2799
-                                                  . $edit_event_url
2800
-                                                  . '" title="'
2801
-                                                  . esc_attr__('Edit ', 'event_espresso')
2802
-                                                  . $this->_reg_event->name()
2803
-                                                  . '">'
2804
-                                                  . esc_html__('Edit Event', 'event_espresso')
2805
-                                                  . '</a>';
2806
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2807
-                                                   . $edit_event_lnk
2808
-                                                   . '</span>';
2809
-        }
2810
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2811
-        if ($this->request->isAjax()) {
2812
-            $this->_return_json();
2813
-        }
2814
-        // grab header
2815
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2816
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2817
-            $template_path,
2818
-            $this->_template_args,
2819
-            true
2820
-        );
2821
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2822
-        // the details template wrapper
2823
-        $this->display_admin_page_with_sidebar();
2824
-    }
2825
-
2826
-
2827
-    /**
2828
-     * This returns the content for a registration step
2829
-     *
2830
-     * @return string html
2831
-     * @throws DomainException
2832
-     * @throws EE_Error
2833
-     * @throws InvalidArgumentException
2834
-     * @throws InvalidDataTypeException
2835
-     * @throws InvalidInterfaceException
2836
-     * @throws ReflectionException
2837
-     */
2838
-    protected function _get_registration_step_content()
2839
-    {
2840
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2841
-            $warning_msg = sprintf(
2842
-                esc_html__(
2843
-                    '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2844
-                    'event_espresso'
2845
-                ),
2846
-                '<br />',
2847
-                '<h3 class="important-notice">',
2848
-                '</h3>',
2849
-                '<div class="float-right">',
2850
-                '<span id="redirect_timer" class="important-notice">30</span>',
2851
-                '</div>',
2852
-                '<b>',
2853
-                '</b>'
2854
-            );
2855
-            return '
2276
+	}
2277
+
2278
+
2279
+	/**
2280
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2281
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2282
+	 * to display the page
2283
+	 *
2284
+	 * @return void
2285
+	 * @throws EE_Error
2286
+	 * @throws InvalidArgumentException
2287
+	 * @throws InvalidDataTypeException
2288
+	 * @throws InvalidInterfaceException
2289
+	 * @throws ReflectionException
2290
+	 */
2291
+	protected function _update_attendee_registration_form()
2292
+	{
2293
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2294
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2295
+			$REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2296
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2297
+			if ($success) {
2298
+				$what  = esc_html__('Registration Form', 'event_espresso');
2299
+				$route = $REG_ID
2300
+					? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2301
+					: ['action' => 'default'];
2302
+				$this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2303
+			}
2304
+		}
2305
+	}
2306
+
2307
+
2308
+	/**
2309
+	 * Gets the form for saving registrations custom questions (if done
2310
+	 * previously retrieves the cached form object, which may have validation errors in it)
2311
+	 *
2312
+	 * @param int $REG_ID
2313
+	 * @return EE_Registration_Custom_Questions_Form
2314
+	 * @throws EE_Error
2315
+	 * @throws InvalidArgumentException
2316
+	 * @throws InvalidDataTypeException
2317
+	 * @throws InvalidInterfaceException
2318
+	 * @throws ReflectionException
2319
+	 */
2320
+	protected function _get_reg_custom_questions_form($REG_ID)
2321
+	{
2322
+		if (! $this->_reg_custom_questions_form) {
2323
+			require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2324
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2325
+				$this->getRegistrationModel()->get_one_by_ID($REG_ID)
2326
+			);
2327
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2328
+		}
2329
+		return $this->_reg_custom_questions_form;
2330
+	}
2331
+
2332
+
2333
+	/**
2334
+	 * Saves
2335
+	 *
2336
+	 * @param bool $REG_ID
2337
+	 * @return bool
2338
+	 * @throws EE_Error
2339
+	 * @throws InvalidArgumentException
2340
+	 * @throws InvalidDataTypeException
2341
+	 * @throws InvalidInterfaceException
2342
+	 * @throws ReflectionException
2343
+	 */
2344
+	private function _save_reg_custom_questions_form($REG_ID = 0)
2345
+	{
2346
+		if (! $REG_ID) {
2347
+			EE_Error::add_error(
2348
+				esc_html__(
2349
+					'An error occurred. No registration ID was received.',
2350
+					'event_espresso'
2351
+				),
2352
+				__FILE__,
2353
+				__FUNCTION__,
2354
+				__LINE__
2355
+			);
2356
+		}
2357
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2358
+		$form->receive_form_submission($this->request->requestParams());
2359
+		$success = false;
2360
+		if ($form->is_valid()) {
2361
+			foreach ($form->subforms() as $question_group_form) {
2362
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2363
+					$where_conditions    = [
2364
+						'QST_ID' => $question_id,
2365
+						'REG_ID' => $REG_ID,
2366
+					];
2367
+					$possibly_new_values = [
2368
+						'ANS_value' => $input->normalized_value(),
2369
+					];
2370
+					$answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2371
+					if ($answer instanceof EE_Answer) {
2372
+						$success = $answer->save($possibly_new_values);
2373
+					} else {
2374
+						// insert it then
2375
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2376
+						$answer      = EE_Answer::new_instance($cols_n_vals);
2377
+						$success     = $answer->save();
2378
+					}
2379
+				}
2380
+			}
2381
+		} else {
2382
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2383
+		}
2384
+		return $success;
2385
+	}
2386
+
2387
+
2388
+	/**
2389
+	 * generates HTML for the Registration main meta box
2390
+	 *
2391
+	 * @return void
2392
+	 * @throws DomainException
2393
+	 * @throws EE_Error
2394
+	 * @throws InvalidArgumentException
2395
+	 * @throws InvalidDataTypeException
2396
+	 * @throws InvalidInterfaceException
2397
+	 * @throws ReflectionException
2398
+	 */
2399
+	public function _reg_attendees_meta_box()
2400
+	{
2401
+		$REG = $this->getRegistrationModel();
2402
+		// get all other registrations on this transaction, and cache
2403
+		// the attendees for them so we don't have to run another query using force_join
2404
+		$registrations                           = $REG->get_all(
2405
+			[
2406
+				[
2407
+					'TXN_ID' => $this->_registration->transaction_ID(),
2408
+					'REG_ID' => ['!=', $this->_registration->ID()],
2409
+				],
2410
+				'force_join'               => ['Attendee'],
2411
+				'default_where_conditions' => 'other_models_only',
2412
+			]
2413
+		);
2414
+		$this->_template_args['attendees']       = [];
2415
+		$this->_template_args['attendee_notice'] = '';
2416
+		if (
2417
+			empty($registrations)
2418
+			|| (is_array($registrations)
2419
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2420
+		) {
2421
+			EE_Error::add_error(
2422
+				esc_html__(
2423
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2424
+					'event_espresso'
2425
+				),
2426
+				__FILE__,
2427
+				__FUNCTION__,
2428
+				__LINE__
2429
+			);
2430
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2431
+		} else {
2432
+			$att_nmbr = 1;
2433
+			foreach ($registrations as $registration) {
2434
+				/* @var $registration EE_Registration */
2435
+				$attendee                                                      = $registration->attendee()
2436
+					? $registration->attendee()
2437
+					: $this->getAttendeeModel()->create_default_object();
2438
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2439
+				$this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2440
+				$this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2441
+				$this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2442
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2443
+				$this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2444
+					', ',
2445
+					$attendee->full_address_as_array()
2446
+				);
2447
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2448
+					[
2449
+						'action' => 'edit_attendee',
2450
+						'post'   => $attendee->ID(),
2451
+					],
2452
+					REG_ADMIN_URL
2453
+				);
2454
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2455
+					$registration->event_obj() instanceof EE_Event
2456
+						? $registration->event_obj()->name()
2457
+						: '';
2458
+				$att_nmbr++;
2459
+			}
2460
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2461
+		}
2462
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2463
+		EEH_Template::display_template($template_path, $this->_template_args);
2464
+	}
2465
+
2466
+
2467
+	/**
2468
+	 * generates HTML for the Edit Registration side meta box
2469
+	 *
2470
+	 * @return void
2471
+	 * @throws DomainException
2472
+	 * @throws EE_Error
2473
+	 * @throws InvalidArgumentException
2474
+	 * @throws InvalidDataTypeException
2475
+	 * @throws InvalidInterfaceException
2476
+	 * @throws ReflectionException
2477
+	 */
2478
+	public function _reg_registrant_side_meta_box()
2479
+	{
2480
+		/*@var $attendee EE_Attendee */
2481
+		$att_check = $this->_registration->attendee();
2482
+		$attendee  = $att_check instanceof EE_Attendee
2483
+			? $att_check
2484
+			: $this->getAttendeeModel()->create_default_object();
2485
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2486
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2487
+		// primary registration object (that way we know if we need to show create button or not)
2488
+		if (! $this->_registration->is_primary_registrant()) {
2489
+			$primary_registration = $this->_registration->get_primary_registration();
2490
+			$primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2491
+				: null;
2492
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2493
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2494
+				// custom attendee object so let's not worry about the primary reg.
2495
+				$primary_registration = null;
2496
+			}
2497
+		} else {
2498
+			$primary_registration = null;
2499
+		}
2500
+		$this->_template_args['ATT_ID']            = $attendee->ID();
2501
+		$this->_template_args['fname']             = $attendee->fname();
2502
+		$this->_template_args['lname']             = $attendee->lname();
2503
+		$this->_template_args['email']             = $attendee->email();
2504
+		$this->_template_args['phone']             = $attendee->phone();
2505
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2506
+		// edit link
2507
+		$this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2508
+			[
2509
+				'action' => 'edit_attendee',
2510
+				'post'   => $attendee->ID(),
2511
+			],
2512
+			REG_ADMIN_URL
2513
+		);
2514
+		$this->_template_args['att_edit_title'] = esc_html__('View details for this contact.', 'event_espresso');
2515
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2516
+		// create link
2517
+		$this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2518
+			? EE_Admin_Page::add_query_args_and_nonce(
2519
+				[
2520
+					'action'  => 'duplicate_attendee',
2521
+					'_REG_ID' => $this->_registration->ID(),
2522
+				],
2523
+				REG_ADMIN_URL
2524
+			) : '';
2525
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2526
+		$this->_template_args['att_check'] = $att_check;
2527
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2528
+		EEH_Template::display_template($template_path, $this->_template_args);
2529
+	}
2530
+
2531
+
2532
+	/**
2533
+	 * trash or restore registrations
2534
+	 *
2535
+	 * @param boolean $trash whether to archive or restore
2536
+	 * @return void
2537
+	 * @throws EE_Error
2538
+	 * @throws InvalidArgumentException
2539
+	 * @throws InvalidDataTypeException
2540
+	 * @throws InvalidInterfaceException
2541
+	 * @throws RuntimeException
2542
+	 */
2543
+	protected function _trash_or_restore_registrations($trash = true)
2544
+	{
2545
+		// if empty _REG_ID then get out because there's nothing to do
2546
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2547
+		if (empty($REG_IDs)) {
2548
+			EE_Error::add_error(
2549
+				sprintf(
2550
+					esc_html__(
2551
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2552
+						'event_espresso'
2553
+					),
2554
+					$trash ? 'trash' : 'restore'
2555
+				),
2556
+				__FILE__,
2557
+				__LINE__,
2558
+				__FUNCTION__
2559
+			);
2560
+			$this->_redirect_after_action(false, '', '', [], true);
2561
+		}
2562
+		$success        = 0;
2563
+		$overwrite_msgs = false;
2564
+		// Checkboxes
2565
+		$reg_count = count($REG_IDs);
2566
+		// cycle thru checkboxes
2567
+		foreach ($REG_IDs as $REG_ID) {
2568
+			/** @var EE_Registration $REG */
2569
+			$REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2570
+			$payments = $REG->registration_payments();
2571
+			if (! empty($payments)) {
2572
+				$name           = $REG->attendee() instanceof EE_Attendee
2573
+					? $REG->attendee()->full_name()
2574
+					: esc_html__('Unknown Attendee', 'event_espresso');
2575
+				$overwrite_msgs = true;
2576
+				EE_Error::add_error(
2577
+					sprintf(
2578
+						esc_html__(
2579
+							'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2580
+							'event_espresso'
2581
+						),
2582
+						$name
2583
+					),
2584
+					__FILE__,
2585
+					__FUNCTION__,
2586
+					__LINE__
2587
+				);
2588
+				// can't trash this registration because it has payments.
2589
+				continue;
2590
+			}
2591
+			$updated = $trash ? $REG->delete() : $REG->restore();
2592
+			if ($updated) {
2593
+				$success++;
2594
+			}
2595
+		}
2596
+		$this->_redirect_after_action(
2597
+			$success === $reg_count, // were ALL registrations affected?
2598
+			$success > 1
2599
+				? esc_html__('Registrations', 'event_espresso')
2600
+				: esc_html__('Registration', 'event_espresso'),
2601
+			$trash
2602
+				? esc_html__('moved to the trash', 'event_espresso')
2603
+				: esc_html__('restored', 'event_espresso'),
2604
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2605
+			$overwrite_msgs
2606
+		);
2607
+	}
2608
+
2609
+
2610
+	/**
2611
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2612
+	 * registration but also.
2613
+	 * 1. Removing relations to EE_Attendee
2614
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2615
+	 * ALSO trashed.
2616
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2617
+	 * 4. Removing relationships between all tickets and the related registrations
2618
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2619
+	 * 6. Deleting permanently any related Checkins.
2620
+	 *
2621
+	 * @return void
2622
+	 * @throws EE_Error
2623
+	 * @throws InvalidArgumentException
2624
+	 * @throws InvalidDataTypeException
2625
+	 * @throws InvalidInterfaceException
2626
+	 * @throws ReflectionException
2627
+	 */
2628
+	protected function _delete_registrations()
2629
+	{
2630
+		$REG_MDL = $this->getRegistrationModel();
2631
+		$success = 0;
2632
+		// Checkboxes
2633
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2634
+
2635
+		if (! empty($REG_IDs)) {
2636
+			// if array has more than one element than success message should be plural
2637
+			$success = count($REG_IDs) > 1 ? 2 : 1;
2638
+			// cycle thru checkboxes
2639
+			foreach ($REG_IDs as $REG_ID) {
2640
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2641
+				if (! $REG instanceof EE_Registration) {
2642
+					continue;
2643
+				}
2644
+				$deleted = $this->_delete_registration($REG);
2645
+				if (! $deleted) {
2646
+					$success = 0;
2647
+				}
2648
+			}
2649
+		}
2650
+
2651
+		$what        = $success > 1
2652
+			? esc_html__('Registrations', 'event_espresso')
2653
+			: esc_html__('Registration', 'event_espresso');
2654
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2655
+		$this->_redirect_after_action(
2656
+			$success,
2657
+			$what,
2658
+			$action_desc,
2659
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2660
+			true
2661
+		);
2662
+	}
2663
+
2664
+
2665
+	/**
2666
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2667
+	 * models get affected.
2668
+	 *
2669
+	 * @param EE_Registration $REG registration to be deleted permanently
2670
+	 * @return bool true = successful deletion, false = fail.
2671
+	 * @throws EE_Error
2672
+	 * @throws InvalidArgumentException
2673
+	 * @throws InvalidDataTypeException
2674
+	 * @throws InvalidInterfaceException
2675
+	 * @throws ReflectionException
2676
+	 */
2677
+	protected function _delete_registration(EE_Registration $REG)
2678
+	{
2679
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2680
+		// registrations on the transaction that are NOT trashed.
2681
+		$TXN = $REG->get_first_related('Transaction');
2682
+		if (! $TXN instanceof EE_Transaction) {
2683
+			EE_Error::add_error(
2684
+				sprintf(
2685
+					esc_html__(
2686
+						'Unable to permanently delete registration %d because its related transaction has already been deleted. If you can restore the related transaction to the database then this registration can be deleted.',
2687
+						'event_espresso'
2688
+					),
2689
+					$REG->id()
2690
+				),
2691
+				__FILE__,
2692
+				__FUNCTION__,
2693
+				__LINE__
2694
+			);
2695
+			return false;
2696
+		}
2697
+		$REGS        = $TXN->get_many_related('Registration');
2698
+		$all_trashed = true;
2699
+		foreach ($REGS as $registration) {
2700
+			if (! $registration->get('REG_deleted')) {
2701
+				$all_trashed = false;
2702
+			}
2703
+		}
2704
+		if (! $all_trashed) {
2705
+			EE_Error::add_error(
2706
+				esc_html__(
2707
+					'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2708
+					'event_espresso'
2709
+				),
2710
+				__FILE__,
2711
+				__FUNCTION__,
2712
+				__LINE__
2713
+			);
2714
+			return false;
2715
+		}
2716
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2717
+		// separately from THIS one).
2718
+		foreach ($REGS as $registration) {
2719
+			// delete related answers
2720
+			$registration->delete_related_permanently('Answer');
2721
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2722
+			$attendee = $registration->get_first_related('Attendee');
2723
+			if ($attendee instanceof EE_Attendee) {
2724
+				$registration->_remove_relation_to($attendee, 'Attendee');
2725
+			}
2726
+			// now remove relationships to tickets on this registration.
2727
+			$registration->_remove_relations('Ticket');
2728
+			// now delete permanently the checkins related to this registration.
2729
+			$registration->delete_related_permanently('Checkin');
2730
+			if ($registration->ID() === $REG->ID()) {
2731
+				continue;
2732
+			} //we don't want to delete permanently the existing registration just yet.
2733
+			// remove relation to transaction for these registrations if NOT the existing registrations
2734
+			$registration->_remove_relations('Transaction');
2735
+			// delete permanently any related messages.
2736
+			$registration->delete_related_permanently('Message');
2737
+			// now delete this registration permanently
2738
+			$registration->delete_permanently();
2739
+		}
2740
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2741
+		// (the transaction and line items should be all that's left).
2742
+		// delete the line items related to the transaction for this registration.
2743
+		$TXN->delete_related_permanently('Line_Item');
2744
+		// we need to remove all the relationships on the transaction
2745
+		$TXN->delete_related_permanently('Payment');
2746
+		$TXN->delete_related_permanently('Extra_Meta');
2747
+		$TXN->delete_related_permanently('Message');
2748
+		// now we can delete this REG permanently (and the transaction of course)
2749
+		$REG->delete_related_permanently('Transaction');
2750
+		return $REG->delete_permanently();
2751
+	}
2752
+
2753
+
2754
+	/**
2755
+	 *    generates HTML for the Register New Attendee Admin page
2756
+	 *
2757
+	 * @throws DomainException
2758
+	 * @throws EE_Error
2759
+	 * @throws InvalidArgumentException
2760
+	 * @throws InvalidDataTypeException
2761
+	 * @throws InvalidInterfaceException
2762
+	 * @throws ReflectionException
2763
+	 */
2764
+	public function new_registration()
2765
+	{
2766
+		if (! $this->_set_reg_event()) {
2767
+			throw new EE_Error(
2768
+				esc_html__(
2769
+					'Unable to continue with registering because there is no Event ID in the request',
2770
+					'event_espresso'
2771
+				)
2772
+			);
2773
+		}
2774
+		/** @var CurrentPage $current_page */
2775
+		$current_page = $this->loader->getShared(CurrentPage::class);
2776
+		$current_page->setEspressoPage(true);
2777
+		// gotta start with a clean slate if we're not coming here via ajax
2778
+		if (
2779
+			! $this->request->isAjax()
2780
+			&& (
2781
+				! $this->request->requestParamIsSet('processing_registration')
2782
+				|| $this->request->requestParamIsSet('step_error')
2783
+			)
2784
+		) {
2785
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2786
+		}
2787
+		$this->_template_args['event_name'] = '';
2788
+		// event name
2789
+		if ($this->_reg_event) {
2790
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2791
+			$edit_event_url                     = self::add_query_args_and_nonce(
2792
+				[
2793
+					'action' => 'edit',
2794
+					'post'   => $this->_reg_event->ID(),
2795
+				],
2796
+				EVENTS_ADMIN_URL
2797
+			);
2798
+			$edit_event_lnk                     = '<a href="'
2799
+												  . $edit_event_url
2800
+												  . '" title="'
2801
+												  . esc_attr__('Edit ', 'event_espresso')
2802
+												  . $this->_reg_event->name()
2803
+												  . '">'
2804
+												  . esc_html__('Edit Event', 'event_espresso')
2805
+												  . '</a>';
2806
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2807
+												   . $edit_event_lnk
2808
+												   . '</span>';
2809
+		}
2810
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2811
+		if ($this->request->isAjax()) {
2812
+			$this->_return_json();
2813
+		}
2814
+		// grab header
2815
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2816
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2817
+			$template_path,
2818
+			$this->_template_args,
2819
+			true
2820
+		);
2821
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2822
+		// the details template wrapper
2823
+		$this->display_admin_page_with_sidebar();
2824
+	}
2825
+
2826
+
2827
+	/**
2828
+	 * This returns the content for a registration step
2829
+	 *
2830
+	 * @return string html
2831
+	 * @throws DomainException
2832
+	 * @throws EE_Error
2833
+	 * @throws InvalidArgumentException
2834
+	 * @throws InvalidDataTypeException
2835
+	 * @throws InvalidInterfaceException
2836
+	 * @throws ReflectionException
2837
+	 */
2838
+	protected function _get_registration_step_content()
2839
+	{
2840
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2841
+			$warning_msg = sprintf(
2842
+				esc_html__(
2843
+					'%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
2844
+					'event_espresso'
2845
+				),
2846
+				'<br />',
2847
+				'<h3 class="important-notice">',
2848
+				'</h3>',
2849
+				'<div class="float-right">',
2850
+				'<span id="redirect_timer" class="important-notice">30</span>',
2851
+				'</div>',
2852
+				'<b>',
2853
+				'</b>'
2854
+			);
2855
+			return '
2856 2856
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2857 2857
 	<script >
2858 2858
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -2865,844 +2865,844 @@  discard block
 block discarded – undo
2865 2865
 	        }
2866 2866
 	    }, 800 );
2867 2867
 	</script >';
2868
-        }
2869
-        $template_args = [
2870
-            'title'                    => '',
2871
-            'content'                  => '',
2872
-            'step_button_text'         => '',
2873
-            'show_notification_toggle' => false,
2874
-        ];
2875
-        // to indicate we're processing a new registration
2876
-        $hidden_fields = [
2877
-            'processing_registration' => [
2878
-                'type'  => 'hidden',
2879
-                'value' => 0,
2880
-            ],
2881
-            'event_id'                => [
2882
-                'type'  => 'hidden',
2883
-                'value' => $this->_reg_event->ID(),
2884
-            ],
2885
-        ];
2886
-        // if the cart is empty then we know we're at step one, so we'll display the ticket selector
2887
-        $cart = EE_Registry::instance()->SSN->cart();
2888
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2889
-        switch ($step) {
2890
-            case 'ticket':
2891
-                $hidden_fields['processing_registration']['value'] = 1;
2892
-                $template_args['title']                            = esc_html__(
2893
-                    'Step One: Select the Ticket for this registration',
2894
-                    'event_espresso'
2895
-                );
2896
-                $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2897
-                $template_args['content'] .= '</div>';
2898
-                $template_args['step_button_text'] = esc_html__(
2899
-                    'Add Tickets and Continue to Registrant Details',
2900
-                    'event_espresso'
2901
-                );
2902
-                $template_args['show_notification_toggle']         = false;
2903
-                break;
2904
-            case 'questions':
2905
-                $hidden_fields['processing_registration']['value'] = 2;
2906
-                $template_args['title']                            = esc_html__(
2907
-                    'Step Two: Add Registrant Details for this Registration',
2908
-                    'event_espresso'
2909
-                );
2910
-                // in theory, we should be able to run EED_SPCO at this point
2911
-                // because the cart should have been set up properly by the first process_reg_step run.
2912
-                $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin();
2913
-                $template_args['step_button_text'] = esc_html__(
2914
-                    'Save Registration and Continue to Details',
2915
-                    'event_espresso'
2916
-                );
2917
-                $template_args['show_notification_toggle'] = true;
2918
-                break;
2919
-        }
2920
-        // we come back to the process_registration_step route.
2921
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2922
-        return EEH_Template::display_template(
2923
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2924
-            $template_args,
2925
-            true
2926
-        );
2927
-    }
2928
-
2929
-
2930
-    /**
2931
-     * set_reg_event
2932
-     *
2933
-     * @return bool
2934
-     * @throws EE_Error
2935
-     * @throws InvalidArgumentException
2936
-     * @throws InvalidDataTypeException
2937
-     * @throws InvalidInterfaceException
2938
-     */
2939
-    private function _set_reg_event()
2940
-    {
2941
-        if (is_object($this->_reg_event)) {
2942
-            return true;
2943
-        }
2944
-
2945
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2946
-        if (! $EVT_ID) {
2947
-            return false;
2948
-        }
2949
-        $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2950
-        return true;
2951
-    }
2952
-
2953
-
2954
-    /**
2955
-     * process_reg_step
2956
-     *
2957
-     * @return void
2958
-     * @throws DomainException
2959
-     * @throws EE_Error
2960
-     * @throws InvalidArgumentException
2961
-     * @throws InvalidDataTypeException
2962
-     * @throws InvalidInterfaceException
2963
-     * @throws ReflectionException
2964
-     * @throws RuntimeException
2965
-     */
2966
-    public function process_reg_step()
2967
-    {
2968
-        EE_System::do_not_cache();
2969
-        $this->_set_reg_event();
2970
-        /** @var CurrentPage $current_page */
2971
-        $current_page = $this->loader->getShared(CurrentPage::class);
2972
-        $current_page->setEspressoPage(true);
2973
-        $this->request->setRequestParam('uts', time());
2974
-        // what step are we on?
2975
-        $cart = EE_Registry::instance()->SSN->cart();
2976
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2977
-        // if doing ajax then we need to verify the nonce
2978
-        if ($this->request->isAjax()) {
2979
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
2980
-            $this->_verify_nonce($nonce, $this->_req_nonce);
2981
-        }
2982
-        switch ($step) {
2983
-            case 'ticket':
2984
-                // process ticket selection
2985
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
2986
-                if ($success) {
2987
-                    EE_Error::add_success(
2988
-                        esc_html__(
2989
-                            'Tickets Selected. Now complete the registration.',
2990
-                            'event_espresso'
2991
-                        )
2992
-                    );
2993
-                } else {
2994
-                    $this->request->setRequestParam('step_error', true);
2995
-                    $query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
2996
-                }
2997
-                if ($this->request->isAjax()) {
2998
-                    $this->new_registration(); // display next step
2999
-                } else {
3000
-                    $query_args = [
3001
-                        'action'                  => 'new_registration',
3002
-                        'processing_registration' => 1,
3003
-                        'event_id'                => $this->_reg_event->ID(),
3004
-                        'uts'                     => time(),
3005
-                    ];
3006
-                    $this->_redirect_after_action(
3007
-                        false,
3008
-                        '',
3009
-                        '',
3010
-                        $query_args,
3011
-                        true
3012
-                    );
3013
-                }
3014
-                break;
3015
-            case 'questions':
3016
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3017
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3018
-                }
3019
-                // process registration
3020
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3021
-                if ($cart instanceof EE_Cart) {
3022
-                    $grand_total = $cart->get_grand_total();
3023
-                    if ($grand_total instanceof EE_Line_Item) {
3024
-                        $grand_total->save_this_and_descendants_to_txn();
3025
-                    }
3026
-                }
3027
-                if (! $transaction instanceof EE_Transaction) {
3028
-                    $query_args = [
3029
-                        'action'                  => 'new_registration',
3030
-                        'processing_registration' => 2,
3031
-                        'event_id'                => $this->_reg_event->ID(),
3032
-                        'uts'                     => time(),
3033
-                    ];
3034
-                    if ($this->request->isAjax()) {
3035
-                        // display registration form again because there are errors (maybe validation?)
3036
-                        $this->new_registration();
3037
-                        return;
3038
-                    }
3039
-                    $this->_redirect_after_action(
3040
-                        false,
3041
-                        '',
3042
-                        '',
3043
-                        $query_args,
3044
-                        true
3045
-                    );
3046
-                    return;
3047
-                }
3048
-                // maybe update status, and make sure to save transaction if not done already
3049
-                if (! $transaction->update_status_based_on_total_paid()) {
3050
-                    $transaction->save();
3051
-                }
3052
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3053
-                $query_args = [
3054
-                    'action'        => 'redirect_to_txn',
3055
-                    'TXN_ID'        => $transaction->ID(),
3056
-                    'EVT_ID'        => $this->_reg_event->ID(),
3057
-                    'event_name'    => urlencode($this->_reg_event->name()),
3058
-                    'redirect_from' => 'new_registration',
3059
-                ];
3060
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3061
-                break;
3062
-        }
3063
-        // what are you looking here for?  Should be nothing to do at this point.
3064
-    }
3065
-
3066
-
3067
-    /**
3068
-     * redirect_to_txn
3069
-     *
3070
-     * @return void
3071
-     * @throws EE_Error
3072
-     * @throws InvalidArgumentException
3073
-     * @throws InvalidDataTypeException
3074
-     * @throws InvalidInterfaceException
3075
-     * @throws ReflectionException
3076
-     */
3077
-    public function redirect_to_txn()
3078
-    {
3079
-        EE_System::do_not_cache();
3080
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3081
-        $query_args = [
3082
-            'action' => 'view_transaction',
3083
-            'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3084
-            'page'   => 'espresso_transactions',
3085
-        ];
3086
-        if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3087
-            $query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3088
-            $query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3089
-            $query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3090
-        }
3091
-        EE_Error::add_success(
3092
-            esc_html__(
3093
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3094
-                'event_espresso'
3095
-            )
3096
-        );
3097
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3098
-    }
3099
-
3100
-
3101
-    /**
3102
-     * generates HTML for the Attendee Contact List
3103
-     *
3104
-     * @return void
3105
-     * @throws DomainException
3106
-     * @throws EE_Error
3107
-     */
3108
-    protected function _attendee_contact_list_table()
3109
-    {
3110
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3111
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3112
-        $this->display_admin_list_table_page_with_no_sidebar();
3113
-    }
3114
-
3115
-
3116
-    /**
3117
-     * get_attendees
3118
-     *
3119
-     * @param      $per_page
3120
-     * @param bool $count whether to return count or data.
3121
-     * @param bool $trash
3122
-     * @return array|int
3123
-     * @throws EE_Error
3124
-     * @throws InvalidArgumentException
3125
-     * @throws InvalidDataTypeException
3126
-     * @throws InvalidInterfaceException
3127
-     */
3128
-    public function get_attendees($per_page, $count = false, $trash = false)
3129
-    {
3130
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3131
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3132
-        $orderby = $this->request->getRequestParam('orderby');
3133
-        switch ($orderby) {
3134
-            case 'ATT_ID':
3135
-            case 'ATT_fname':
3136
-            case 'ATT_email':
3137
-            case 'ATT_city':
3138
-            case 'STA_ID':
3139
-            case 'CNT_ID':
3140
-                break;
3141
-            case 'Registration_Count':
3142
-                $orderby = 'Registration_Count';
3143
-                break;
3144
-            default:
3145
-                $orderby = 'ATT_lname';
3146
-        }
3147
-        $sort         = $this->request->getRequestParam('order', 'ASC');
3148
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
3149
-        $per_page     = absint($per_page) ? $per_page : 10;
3150
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3151
-        $_where       = [];
3152
-        $search_term  = $this->request->getRequestParam('s');
3153
-        if ($search_term) {
3154
-            $search_term  = '%' . $search_term . '%';
3155
-            $_where['OR'] = [
3156
-                'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3157
-                'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3158
-                'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3159
-                'ATT_fname'                         => ['LIKE', $search_term],
3160
-                'ATT_lname'                         => ['LIKE', $search_term],
3161
-                'ATT_short_bio'                     => ['LIKE', $search_term],
3162
-                'ATT_email'                         => ['LIKE', $search_term],
3163
-                'ATT_address'                       => ['LIKE', $search_term],
3164
-                'ATT_address2'                      => ['LIKE', $search_term],
3165
-                'ATT_city'                          => ['LIKE', $search_term],
3166
-                'Country.CNT_name'                  => ['LIKE', $search_term],
3167
-                'State.STA_name'                    => ['LIKE', $search_term],
3168
-                'ATT_phone'                         => ['LIKE', $search_term],
3169
-                'Registration.REG_final_price'      => ['LIKE', $search_term],
3170
-                'Registration.REG_code'             => ['LIKE', $search_term],
3171
-                'Registration.REG_group_size'       => ['LIKE', $search_term],
3172
-            ];
3173
-        }
3174
-        $offset     = ($current_page - 1) * $per_page;
3175
-        $limit      = $count ? null : [$offset, $per_page];
3176
-        $query_args = [
3177
-            $_where,
3178
-            'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3179
-            'limit'         => $limit,
3180
-        ];
3181
-        if (! $count) {
3182
-            $query_args['order_by'] = [$orderby => $sort];
3183
-        }
3184
-        $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3185
-        return $count
3186
-            ? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3187
-            : $this->getAttendeeModel()->get_all($query_args);
3188
-    }
3189
-
3190
-
3191
-    /**
3192
-     * This is just taking care of resending the registration confirmation
3193
-     *
3194
-     * @return void
3195
-     * @throws EE_Error
3196
-     * @throws InvalidArgumentException
3197
-     * @throws InvalidDataTypeException
3198
-     * @throws InvalidInterfaceException
3199
-     * @throws ReflectionException
3200
-     */
3201
-    protected function _resend_registration()
3202
-    {
3203
-        $this->_process_resend_registration();
3204
-        $REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3205
-        $redirect_to = $this->request->getRequestParam('redirect_to');
3206
-        $query_args  = $redirect_to
3207
-            ? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3208
-            : ['action' => 'default'];
3209
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3210
-    }
3211
-
3212
-
3213
-    /**
3214
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3215
-     * to use when selecting registrations
3216
-     *
3217
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3218
-     *                                                     the query parameters from the request
3219
-     * @return void ends the request with a redirect or download
3220
-     */
3221
-    public function _registrations_report_base($method_name_for_getting_query_params)
3222
-    {
3223
-        $EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3224
-            ? $this->request->getRequestParam('EVT_ID', 0, 'int')
3225
-            : null;
3226
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3227
-            $request_params = $this->request->requestParams();
3228
-            wp_redirect(
3229
-                EE_Admin_Page::add_query_args_and_nonce(
3230
-                    [
3231
-                        'page'        => 'espresso_batch',
3232
-                        'batch'       => 'file',
3233
-                        'EVT_ID'      => $EVT_ID,
3234
-                        'filters'     => urlencode(
3235
-                            serialize(
3236
-                                $this->$method_name_for_getting_query_params(
3237
-                                    EEH_Array::is_set($request_params, 'filters', [])
3238
-                                )
3239
-                            )
3240
-                        ),
3241
-                        'use_filters' => EEH_Array::is_set($request_params, 'use_filters', false),
3242
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3243
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3244
-                    ]
3245
-                )
3246
-            );
3247
-        } else {
3248
-            // Pull the current request params
3249
-            $request_args = $this->request->requestParams();
3250
-            // Set the required request_args to be passed to the export
3251
-            $required_request_args = [
3252
-                'export' => 'report',
3253
-                'action' => 'registrations_report_for_event',
3254
-                'EVT_ID' => $EVT_ID,
3255
-            ];
3256
-            // Merge required request args, overriding any currently set
3257
-            $request_args = array_merge($request_args, $required_request_args);
3258
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3259
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3260
-                $EE_Export = EE_Export::instance($request_args);
3261
-                $EE_Export->export();
3262
-            }
3263
-        }
3264
-    }
3265
-
3266
-
3267
-    /**
3268
-     * Creates a registration report using only query parameters in the request
3269
-     *
3270
-     * @return void
3271
-     */
3272
-    public function _registrations_report()
3273
-    {
3274
-        $this->_registrations_report_base('_get_registration_query_parameters');
3275
-    }
3276
-
3277
-
3278
-    public function _contact_list_export()
3279
-    {
3280
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3281
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3282
-            $EE_Export = EE_Export::instance($this->request->requestParams());
3283
-            $EE_Export->export_attendees();
3284
-        }
3285
-    }
3286
-
3287
-
3288
-    public function _contact_list_report()
3289
-    {
3290
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3291
-            wp_redirect(
3292
-                EE_Admin_Page::add_query_args_and_nonce(
3293
-                    [
3294
-                        'page'        => 'espresso_batch',
3295
-                        'batch'       => 'file',
3296
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3297
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3298
-                    ]
3299
-                )
3300
-            );
3301
-        } else {
3302
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3303
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3304
-                $EE_Export = EE_Export::instance($this->request->requestParams());
3305
-                $EE_Export->report_attendees();
3306
-            }
3307
-        }
3308
-    }
3309
-
3310
-
3311
-
3312
-
3313
-
3314
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3315
-    /**
3316
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3317
-     *
3318
-     * @return void
3319
-     * @throws EE_Error
3320
-     * @throws InvalidArgumentException
3321
-     * @throws InvalidDataTypeException
3322
-     * @throws InvalidInterfaceException
3323
-     * @throws ReflectionException
3324
-     */
3325
-    protected function _duplicate_attendee()
3326
-    {
3327
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3328
-        $action = $this->request->getRequestParam('return', 'default');
3329
-        // verify we have necessary info
3330
-        if (! $REG_ID) {
3331
-            EE_Error::add_error(
3332
-                esc_html__(
3333
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3334
-                    'event_espresso'
3335
-                ),
3336
-                __FILE__,
3337
-                __LINE__,
3338
-                __FUNCTION__
3339
-            );
3340
-            $query_args = ['action' => $action];
3341
-            $this->_redirect_after_action('', '', '', $query_args, true);
3342
-        }
3343
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3344
-        $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3345
-        if (! $registration instanceof EE_Registration) {
3346
-            throw new RuntimeException(
3347
-                sprintf(
3348
-                    esc_html__(
3349
-                        'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3350
-                        'event_espresso'
3351
-                    ),
3352
-                    $REG_ID
3353
-                )
3354
-            );
3355
-        }
3356
-        $attendee = $registration->attendee();
3357
-        // remove relation of existing attendee on registration
3358
-        $registration->_remove_relation_to($attendee, 'Attendee');
3359
-        // new attendee
3360
-        $new_attendee = clone $attendee;
3361
-        $new_attendee->set('ATT_ID', 0);
3362
-        $new_attendee->save();
3363
-        // add new attendee to reg
3364
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3365
-        EE_Error::add_success(
3366
-            esc_html__(
3367
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3368
-                'event_espresso'
3369
-            )
3370
-        );
3371
-        // redirect to edit page for attendee
3372
-        $query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3373
-        $this->_redirect_after_action('', '', '', $query_args, true);
3374
-    }
3375
-
3376
-
3377
-    /**
3378
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3379
-     *
3380
-     * @param int     $post_id
3381
-     * @param WP_Post $post
3382
-     * @throws DomainException
3383
-     * @throws EE_Error
3384
-     * @throws InvalidArgumentException
3385
-     * @throws InvalidDataTypeException
3386
-     * @throws InvalidInterfaceException
3387
-     * @throws LogicException
3388
-     * @throws InvalidFormSubmissionException
3389
-     * @throws ReflectionException
3390
-     */
3391
-    protected function _insert_update_cpt_item($post_id, $post)
3392
-    {
3393
-        $success  = true;
3394
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3395
-            ? $this->getAttendeeModel()->get_one_by_ID($post_id)
3396
-            : null;
3397
-        // for attendee updates
3398
-        if ($attendee instanceof EE_Attendee) {
3399
-            // note we should only be UPDATING attendees at this point.
3400
-            $fname          = $this->request->getRequestParam('ATT_fname', '');
3401
-            $lname          = $this->request->getRequestParam('ATT_lname', '');
3402
-            $updated_fields = [
3403
-                'ATT_fname'     => $fname,
3404
-                'ATT_lname'     => $lname,
3405
-                'ATT_full_name' => "{$fname} {$lname}",
3406
-                'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3407
-                'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3408
-                'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3409
-                'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3410
-                'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3411
-                'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3412
-            ];
3413
-            foreach ($updated_fields as $field => $value) {
3414
-                $attendee->set($field, $value);
3415
-            }
3416
-
3417
-            // process contact details metabox form handler (which will also save the attendee)
3418
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3419
-            $success              = $contact_details_form->process($this->request->requestParams());
3420
-
3421
-            $attendee_update_callbacks = apply_filters(
3422
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3423
-                []
3424
-            );
3425
-            foreach ($attendee_update_callbacks as $a_callback) {
3426
-                if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3427
-                    throw new EE_Error(
3428
-                        sprintf(
3429
-                            esc_html__(
3430
-                                'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3431
-                                'event_espresso'
3432
-                            ),
3433
-                            $a_callback
3434
-                        )
3435
-                    );
3436
-                }
3437
-            }
3438
-        }
3439
-
3440
-        if ($success === false) {
3441
-            EE_Error::add_error(
3442
-                esc_html__(
3443
-                    'Something went wrong with updating the meta table data for the registration.',
3444
-                    'event_espresso'
3445
-                ),
3446
-                __FILE__,
3447
-                __FUNCTION__,
3448
-                __LINE__
3449
-            );
3450
-        }
3451
-    }
3452
-
3453
-
3454
-    public function trash_cpt_item($post_id)
3455
-    {
3456
-    }
3457
-
3458
-
3459
-    public function delete_cpt_item($post_id)
3460
-    {
3461
-    }
3462
-
3463
-
3464
-    public function restore_cpt_item($post_id)
3465
-    {
3466
-    }
3467
-
3468
-
3469
-    protected function _restore_cpt_item($post_id, $revision_id)
3470
-    {
3471
-    }
3472
-
3473
-
3474
-    /**
3475
-     * @throws EE_Error
3476
-     * @throws ReflectionException
3477
-     * @since 4.10.2.p
3478
-     */
3479
-    public function attendee_editor_metaboxes()
3480
-    {
3481
-        $this->verify_cpt_object();
3482
-        remove_meta_box(
3483
-            'postexcerpt',
3484
-            $this->_cpt_routes[ $this->_req_action ],
3485
-            'normal'
3486
-        );
3487
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3488
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3489
-            $this->addMetaBox(
3490
-                'postexcerpt',
3491
-                esc_html__('Short Biography', 'event_espresso'),
3492
-                'post_excerpt_meta_box',
3493
-                $this->_cpt_routes[ $this->_req_action ]
3494
-            );
3495
-        }
3496
-        if (post_type_supports('espresso_attendees', 'comments')) {
3497
-            $this->addMetaBox(
3498
-                'commentsdiv',
3499
-                esc_html__('Notes on the Contact', 'event_espresso'),
3500
-                'post_comment_meta_box',
3501
-                $this->_cpt_routes[ $this->_req_action ],
3502
-                'normal',
3503
-                'core'
3504
-            );
3505
-        }
3506
-        $this->addMetaBox(
3507
-            'attendee_contact_info',
3508
-            esc_html__('Contact Info', 'event_espresso'),
3509
-            [$this, 'attendee_contact_info'],
3510
-            $this->_cpt_routes[ $this->_req_action ],
3511
-            'side',
3512
-            'core'
3513
-        );
3514
-        $this->addMetaBox(
3515
-            'attendee_details_address',
3516
-            esc_html__('Address Details', 'event_espresso'),
3517
-            [$this, 'attendee_address_details'],
3518
-            $this->_cpt_routes[ $this->_req_action ],
3519
-            'normal',
3520
-            'core'
3521
-        );
3522
-        $this->addMetaBox(
3523
-            'attendee_registrations',
3524
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3525
-            [$this, 'attendee_registrations_meta_box'],
3526
-            $this->_cpt_routes[ $this->_req_action ]
3527
-        );
3528
-    }
3529
-
3530
-
3531
-    /**
3532
-     * Metabox for attendee contact info
3533
-     *
3534
-     * @param WP_Post $post wp post object
3535
-     * @return void attendee contact info ( and form )
3536
-     * @throws EE_Error
3537
-     * @throws InvalidArgumentException
3538
-     * @throws InvalidDataTypeException
3539
-     * @throws InvalidInterfaceException
3540
-     * @throws LogicException
3541
-     * @throws DomainException
3542
-     */
3543
-    public function attendee_contact_info($post)
3544
-    {
3545
-        // get attendee object ( should already have it )
3546
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3547
-        $form->enqueueStylesAndScripts();
3548
-        echo wp_kses($form->display(), AllowedTags::getWithFormTags());
3549
-    }
3550
-
3551
-
3552
-    /**
3553
-     * Return form handler for the contact details metabox
3554
-     *
3555
-     * @param EE_Attendee $attendee
3556
-     * @return AttendeeContactDetailsMetaboxFormHandler
3557
-     * @throws DomainException
3558
-     * @throws InvalidArgumentException
3559
-     * @throws InvalidDataTypeException
3560
-     * @throws InvalidInterfaceException
3561
-     */
3562
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3563
-    {
3564
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3565
-    }
3566
-
3567
-
3568
-    /**
3569
-     * Metabox for attendee details
3570
-     *
3571
-     * @param WP_Post $post wp post object
3572
-     * @throws EE_Error
3573
-     * @throws ReflectionException
3574
-     */
3575
-    public function attendee_address_details($post)
3576
-    {
3577
-        // get attendee object (should already have it)
3578
-        $this->_template_args['attendee']     = $this->_cpt_model_obj;
3579
-        $this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3580
-            new EE_Question_Form_Input(
3581
-                EE_Question::new_instance(
3582
-                    [
3583
-                        'QST_ID'           => 0,
3584
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3585
-                        'QST_system'       => 'admin-state',
3586
-                    ]
3587
-                ),
3588
-                EE_Answer::new_instance(
3589
-                    [
3590
-                        'ANS_ID'    => 0,
3591
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3592
-                    ]
3593
-                ),
3594
-                [
3595
-                    'input_id'       => 'STA_ID',
3596
-                    'input_name'     => 'STA_ID',
3597
-                    'input_prefix'   => '',
3598
-                    'append_qstn_id' => false,
3599
-                ]
3600
-            )
3601
-        );
3602
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3603
-            new EE_Question_Form_Input(
3604
-                EE_Question::new_instance(
3605
-                    [
3606
-                        'QST_ID'           => 0,
3607
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3608
-                        'QST_system'       => 'admin-country',
3609
-                    ]
3610
-                ),
3611
-                EE_Answer::new_instance(
3612
-                    [
3613
-                        'ANS_ID'    => 0,
3614
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3615
-                    ]
3616
-                ),
3617
-                [
3618
-                    'input_id'       => 'CNT_ISO',
3619
-                    'input_name'     => 'CNT_ISO',
3620
-                    'input_prefix'   => '',
3621
-                    'append_qstn_id' => false,
3622
-                ]
3623
-            )
3624
-        );
3625
-        $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3626
-        EEH_Template::display_template($template, $this->_template_args);
3627
-    }
3628
-
3629
-
3630
-    /**
3631
-     * _attendee_details
3632
-     *
3633
-     * @param $post
3634
-     * @return void
3635
-     * @throws DomainException
3636
-     * @throws EE_Error
3637
-     * @throws InvalidArgumentException
3638
-     * @throws InvalidDataTypeException
3639
-     * @throws InvalidInterfaceException
3640
-     * @throws ReflectionException
3641
-     */
3642
-    public function attendee_registrations_meta_box($post)
3643
-    {
3644
-        $this->_template_args['attendee']      = $this->_cpt_model_obj;
3645
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3646
-        $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3647
-        EEH_Template::display_template($template, $this->_template_args);
3648
-    }
3649
-
3650
-
3651
-    /**
3652
-     * add in the form fields for the attendee edit
3653
-     *
3654
-     * @param WP_Post $post wp post object
3655
-     * @return void echos html for new form.
3656
-     * @throws DomainException
3657
-     */
3658
-    public function after_title_form_fields($post)
3659
-    {
3660
-        if ($post->post_type === 'espresso_attendees') {
3661
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3662
-            $template_args['attendee'] = $this->_cpt_model_obj;
3663
-            EEH_Template::display_template($template, $template_args);
3664
-        }
3665
-    }
3666
-
3667
-
3668
-    /**
3669
-     * _trash_or_restore_attendee
3670
-     *
3671
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3672
-     * @return void
3673
-     * @throws EE_Error
3674
-     * @throws InvalidArgumentException
3675
-     * @throws InvalidDataTypeException
3676
-     * @throws InvalidInterfaceException
3677
-     */
3678
-    protected function _trash_or_restore_attendees($trash = true)
3679
-    {
3680
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3681
-        $status = $trash ? 'trash' : 'publish';
3682
-        // Checkboxes
3683
-        if ($this->request->requestParamIsSet('checkbox')) {
3684
-            $ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3685
-            // if array has more than one element than success message should be plural
3686
-            $success = count($ATT_IDs) > 1 ? 2 : 1;
3687
-            // cycle thru checkboxes
3688
-            foreach ($ATT_IDs as $ATT_ID) {
3689
-                $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3690
-                if (! $updated) {
3691
-                    $success = 0;
3692
-                }
3693
-            }
3694
-        } else {
3695
-            // grab single id and delete
3696
-            $ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3697
-            // update attendee
3698
-            $success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3699
-        }
3700
-        $what        = $success > 1
3701
-            ? esc_html__('Contacts', 'event_espresso')
3702
-            : esc_html__('Contact', 'event_espresso');
3703
-        $action_desc = $trash
3704
-            ? esc_html__('moved to the trash', 'event_espresso')
3705
-            : esc_html__('restored', 'event_espresso');
3706
-        $this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3707
-    }
2868
+		}
2869
+		$template_args = [
2870
+			'title'                    => '',
2871
+			'content'                  => '',
2872
+			'step_button_text'         => '',
2873
+			'show_notification_toggle' => false,
2874
+		];
2875
+		// to indicate we're processing a new registration
2876
+		$hidden_fields = [
2877
+			'processing_registration' => [
2878
+				'type'  => 'hidden',
2879
+				'value' => 0,
2880
+			],
2881
+			'event_id'                => [
2882
+				'type'  => 'hidden',
2883
+				'value' => $this->_reg_event->ID(),
2884
+			],
2885
+		];
2886
+		// if the cart is empty then we know we're at step one, so we'll display the ticket selector
2887
+		$cart = EE_Registry::instance()->SSN->cart();
2888
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2889
+		switch ($step) {
2890
+			case 'ticket':
2891
+				$hidden_fields['processing_registration']['value'] = 1;
2892
+				$template_args['title']                            = esc_html__(
2893
+					'Step One: Select the Ticket for this registration',
2894
+					'event_espresso'
2895
+				);
2896
+				$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2897
+				$template_args['content'] .= '</div>';
2898
+				$template_args['step_button_text'] = esc_html__(
2899
+					'Add Tickets and Continue to Registrant Details',
2900
+					'event_espresso'
2901
+				);
2902
+				$template_args['show_notification_toggle']         = false;
2903
+				break;
2904
+			case 'questions':
2905
+				$hidden_fields['processing_registration']['value'] = 2;
2906
+				$template_args['title']                            = esc_html__(
2907
+					'Step Two: Add Registrant Details for this Registration',
2908
+					'event_espresso'
2909
+				);
2910
+				// in theory, we should be able to run EED_SPCO at this point
2911
+				// because the cart should have been set up properly by the first process_reg_step run.
2912
+				$template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin();
2913
+				$template_args['step_button_text'] = esc_html__(
2914
+					'Save Registration and Continue to Details',
2915
+					'event_espresso'
2916
+				);
2917
+				$template_args['show_notification_toggle'] = true;
2918
+				break;
2919
+		}
2920
+		// we come back to the process_registration_step route.
2921
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2922
+		return EEH_Template::display_template(
2923
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2924
+			$template_args,
2925
+			true
2926
+		);
2927
+	}
2928
+
2929
+
2930
+	/**
2931
+	 * set_reg_event
2932
+	 *
2933
+	 * @return bool
2934
+	 * @throws EE_Error
2935
+	 * @throws InvalidArgumentException
2936
+	 * @throws InvalidDataTypeException
2937
+	 * @throws InvalidInterfaceException
2938
+	 */
2939
+	private function _set_reg_event()
2940
+	{
2941
+		if (is_object($this->_reg_event)) {
2942
+			return true;
2943
+		}
2944
+
2945
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2946
+		if (! $EVT_ID) {
2947
+			return false;
2948
+		}
2949
+		$this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2950
+		return true;
2951
+	}
2952
+
2953
+
2954
+	/**
2955
+	 * process_reg_step
2956
+	 *
2957
+	 * @return void
2958
+	 * @throws DomainException
2959
+	 * @throws EE_Error
2960
+	 * @throws InvalidArgumentException
2961
+	 * @throws InvalidDataTypeException
2962
+	 * @throws InvalidInterfaceException
2963
+	 * @throws ReflectionException
2964
+	 * @throws RuntimeException
2965
+	 */
2966
+	public function process_reg_step()
2967
+	{
2968
+		EE_System::do_not_cache();
2969
+		$this->_set_reg_event();
2970
+		/** @var CurrentPage $current_page */
2971
+		$current_page = $this->loader->getShared(CurrentPage::class);
2972
+		$current_page->setEspressoPage(true);
2973
+		$this->request->setRequestParam('uts', time());
2974
+		// what step are we on?
2975
+		$cart = EE_Registry::instance()->SSN->cart();
2976
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2977
+		// if doing ajax then we need to verify the nonce
2978
+		if ($this->request->isAjax()) {
2979
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
2980
+			$this->_verify_nonce($nonce, $this->_req_nonce);
2981
+		}
2982
+		switch ($step) {
2983
+			case 'ticket':
2984
+				// process ticket selection
2985
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
2986
+				if ($success) {
2987
+					EE_Error::add_success(
2988
+						esc_html__(
2989
+							'Tickets Selected. Now complete the registration.',
2990
+							'event_espresso'
2991
+						)
2992
+					);
2993
+				} else {
2994
+					$this->request->setRequestParam('step_error', true);
2995
+					$query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
2996
+				}
2997
+				if ($this->request->isAjax()) {
2998
+					$this->new_registration(); // display next step
2999
+				} else {
3000
+					$query_args = [
3001
+						'action'                  => 'new_registration',
3002
+						'processing_registration' => 1,
3003
+						'event_id'                => $this->_reg_event->ID(),
3004
+						'uts'                     => time(),
3005
+					];
3006
+					$this->_redirect_after_action(
3007
+						false,
3008
+						'',
3009
+						'',
3010
+						$query_args,
3011
+						true
3012
+					);
3013
+				}
3014
+				break;
3015
+			case 'questions':
3016
+				if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3017
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3018
+				}
3019
+				// process registration
3020
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3021
+				if ($cart instanceof EE_Cart) {
3022
+					$grand_total = $cart->get_grand_total();
3023
+					if ($grand_total instanceof EE_Line_Item) {
3024
+						$grand_total->save_this_and_descendants_to_txn();
3025
+					}
3026
+				}
3027
+				if (! $transaction instanceof EE_Transaction) {
3028
+					$query_args = [
3029
+						'action'                  => 'new_registration',
3030
+						'processing_registration' => 2,
3031
+						'event_id'                => $this->_reg_event->ID(),
3032
+						'uts'                     => time(),
3033
+					];
3034
+					if ($this->request->isAjax()) {
3035
+						// display registration form again because there are errors (maybe validation?)
3036
+						$this->new_registration();
3037
+						return;
3038
+					}
3039
+					$this->_redirect_after_action(
3040
+						false,
3041
+						'',
3042
+						'',
3043
+						$query_args,
3044
+						true
3045
+					);
3046
+					return;
3047
+				}
3048
+				// maybe update status, and make sure to save transaction if not done already
3049
+				if (! $transaction->update_status_based_on_total_paid()) {
3050
+					$transaction->save();
3051
+				}
3052
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3053
+				$query_args = [
3054
+					'action'        => 'redirect_to_txn',
3055
+					'TXN_ID'        => $transaction->ID(),
3056
+					'EVT_ID'        => $this->_reg_event->ID(),
3057
+					'event_name'    => urlencode($this->_reg_event->name()),
3058
+					'redirect_from' => 'new_registration',
3059
+				];
3060
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3061
+				break;
3062
+		}
3063
+		// what are you looking here for?  Should be nothing to do at this point.
3064
+	}
3065
+
3066
+
3067
+	/**
3068
+	 * redirect_to_txn
3069
+	 *
3070
+	 * @return void
3071
+	 * @throws EE_Error
3072
+	 * @throws InvalidArgumentException
3073
+	 * @throws InvalidDataTypeException
3074
+	 * @throws InvalidInterfaceException
3075
+	 * @throws ReflectionException
3076
+	 */
3077
+	public function redirect_to_txn()
3078
+	{
3079
+		EE_System::do_not_cache();
3080
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3081
+		$query_args = [
3082
+			'action' => 'view_transaction',
3083
+			'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3084
+			'page'   => 'espresso_transactions',
3085
+		];
3086
+		if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3087
+			$query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3088
+			$query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3089
+			$query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3090
+		}
3091
+		EE_Error::add_success(
3092
+			esc_html__(
3093
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3094
+				'event_espresso'
3095
+			)
3096
+		);
3097
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3098
+	}
3099
+
3100
+
3101
+	/**
3102
+	 * generates HTML for the Attendee Contact List
3103
+	 *
3104
+	 * @return void
3105
+	 * @throws DomainException
3106
+	 * @throws EE_Error
3107
+	 */
3108
+	protected function _attendee_contact_list_table()
3109
+	{
3110
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3111
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3112
+		$this->display_admin_list_table_page_with_no_sidebar();
3113
+	}
3114
+
3115
+
3116
+	/**
3117
+	 * get_attendees
3118
+	 *
3119
+	 * @param      $per_page
3120
+	 * @param bool $count whether to return count or data.
3121
+	 * @param bool $trash
3122
+	 * @return array|int
3123
+	 * @throws EE_Error
3124
+	 * @throws InvalidArgumentException
3125
+	 * @throws InvalidDataTypeException
3126
+	 * @throws InvalidInterfaceException
3127
+	 */
3128
+	public function get_attendees($per_page, $count = false, $trash = false)
3129
+	{
3130
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3131
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3132
+		$orderby = $this->request->getRequestParam('orderby');
3133
+		switch ($orderby) {
3134
+			case 'ATT_ID':
3135
+			case 'ATT_fname':
3136
+			case 'ATT_email':
3137
+			case 'ATT_city':
3138
+			case 'STA_ID':
3139
+			case 'CNT_ID':
3140
+				break;
3141
+			case 'Registration_Count':
3142
+				$orderby = 'Registration_Count';
3143
+				break;
3144
+			default:
3145
+				$orderby = 'ATT_lname';
3146
+		}
3147
+		$sort         = $this->request->getRequestParam('order', 'ASC');
3148
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
3149
+		$per_page     = absint($per_page) ? $per_page : 10;
3150
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3151
+		$_where       = [];
3152
+		$search_term  = $this->request->getRequestParam('s');
3153
+		if ($search_term) {
3154
+			$search_term  = '%' . $search_term . '%';
3155
+			$_where['OR'] = [
3156
+				'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3157
+				'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3158
+				'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3159
+				'ATT_fname'                         => ['LIKE', $search_term],
3160
+				'ATT_lname'                         => ['LIKE', $search_term],
3161
+				'ATT_short_bio'                     => ['LIKE', $search_term],
3162
+				'ATT_email'                         => ['LIKE', $search_term],
3163
+				'ATT_address'                       => ['LIKE', $search_term],
3164
+				'ATT_address2'                      => ['LIKE', $search_term],
3165
+				'ATT_city'                          => ['LIKE', $search_term],
3166
+				'Country.CNT_name'                  => ['LIKE', $search_term],
3167
+				'State.STA_name'                    => ['LIKE', $search_term],
3168
+				'ATT_phone'                         => ['LIKE', $search_term],
3169
+				'Registration.REG_final_price'      => ['LIKE', $search_term],
3170
+				'Registration.REG_code'             => ['LIKE', $search_term],
3171
+				'Registration.REG_group_size'       => ['LIKE', $search_term],
3172
+			];
3173
+		}
3174
+		$offset     = ($current_page - 1) * $per_page;
3175
+		$limit      = $count ? null : [$offset, $per_page];
3176
+		$query_args = [
3177
+			$_where,
3178
+			'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3179
+			'limit'         => $limit,
3180
+		];
3181
+		if (! $count) {
3182
+			$query_args['order_by'] = [$orderby => $sort];
3183
+		}
3184
+		$query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3185
+		return $count
3186
+			? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3187
+			: $this->getAttendeeModel()->get_all($query_args);
3188
+	}
3189
+
3190
+
3191
+	/**
3192
+	 * This is just taking care of resending the registration confirmation
3193
+	 *
3194
+	 * @return void
3195
+	 * @throws EE_Error
3196
+	 * @throws InvalidArgumentException
3197
+	 * @throws InvalidDataTypeException
3198
+	 * @throws InvalidInterfaceException
3199
+	 * @throws ReflectionException
3200
+	 */
3201
+	protected function _resend_registration()
3202
+	{
3203
+		$this->_process_resend_registration();
3204
+		$REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3205
+		$redirect_to = $this->request->getRequestParam('redirect_to');
3206
+		$query_args  = $redirect_to
3207
+			? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3208
+			: ['action' => 'default'];
3209
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3210
+	}
3211
+
3212
+
3213
+	/**
3214
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3215
+	 * to use when selecting registrations
3216
+	 *
3217
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3218
+	 *                                                     the query parameters from the request
3219
+	 * @return void ends the request with a redirect or download
3220
+	 */
3221
+	public function _registrations_report_base($method_name_for_getting_query_params)
3222
+	{
3223
+		$EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3224
+			? $this->request->getRequestParam('EVT_ID', 0, 'int')
3225
+			: null;
3226
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3227
+			$request_params = $this->request->requestParams();
3228
+			wp_redirect(
3229
+				EE_Admin_Page::add_query_args_and_nonce(
3230
+					[
3231
+						'page'        => 'espresso_batch',
3232
+						'batch'       => 'file',
3233
+						'EVT_ID'      => $EVT_ID,
3234
+						'filters'     => urlencode(
3235
+							serialize(
3236
+								$this->$method_name_for_getting_query_params(
3237
+									EEH_Array::is_set($request_params, 'filters', [])
3238
+								)
3239
+							)
3240
+						),
3241
+						'use_filters' => EEH_Array::is_set($request_params, 'use_filters', false),
3242
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3243
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3244
+					]
3245
+				)
3246
+			);
3247
+		} else {
3248
+			// Pull the current request params
3249
+			$request_args = $this->request->requestParams();
3250
+			// Set the required request_args to be passed to the export
3251
+			$required_request_args = [
3252
+				'export' => 'report',
3253
+				'action' => 'registrations_report_for_event',
3254
+				'EVT_ID' => $EVT_ID,
3255
+			];
3256
+			// Merge required request args, overriding any currently set
3257
+			$request_args = array_merge($request_args, $required_request_args);
3258
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3259
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3260
+				$EE_Export = EE_Export::instance($request_args);
3261
+				$EE_Export->export();
3262
+			}
3263
+		}
3264
+	}
3265
+
3266
+
3267
+	/**
3268
+	 * Creates a registration report using only query parameters in the request
3269
+	 *
3270
+	 * @return void
3271
+	 */
3272
+	public function _registrations_report()
3273
+	{
3274
+		$this->_registrations_report_base('_get_registration_query_parameters');
3275
+	}
3276
+
3277
+
3278
+	public function _contact_list_export()
3279
+	{
3280
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3281
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3282
+			$EE_Export = EE_Export::instance($this->request->requestParams());
3283
+			$EE_Export->export_attendees();
3284
+		}
3285
+	}
3286
+
3287
+
3288
+	public function _contact_list_report()
3289
+	{
3290
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3291
+			wp_redirect(
3292
+				EE_Admin_Page::add_query_args_and_nonce(
3293
+					[
3294
+						'page'        => 'espresso_batch',
3295
+						'batch'       => 'file',
3296
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3297
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3298
+					]
3299
+				)
3300
+			);
3301
+		} else {
3302
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3303
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3304
+				$EE_Export = EE_Export::instance($this->request->requestParams());
3305
+				$EE_Export->report_attendees();
3306
+			}
3307
+		}
3308
+	}
3309
+
3310
+
3311
+
3312
+
3313
+
3314
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3315
+	/**
3316
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3317
+	 *
3318
+	 * @return void
3319
+	 * @throws EE_Error
3320
+	 * @throws InvalidArgumentException
3321
+	 * @throws InvalidDataTypeException
3322
+	 * @throws InvalidInterfaceException
3323
+	 * @throws ReflectionException
3324
+	 */
3325
+	protected function _duplicate_attendee()
3326
+	{
3327
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3328
+		$action = $this->request->getRequestParam('return', 'default');
3329
+		// verify we have necessary info
3330
+		if (! $REG_ID) {
3331
+			EE_Error::add_error(
3332
+				esc_html__(
3333
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3334
+					'event_espresso'
3335
+				),
3336
+				__FILE__,
3337
+				__LINE__,
3338
+				__FUNCTION__
3339
+			);
3340
+			$query_args = ['action' => $action];
3341
+			$this->_redirect_after_action('', '', '', $query_args, true);
3342
+		}
3343
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3344
+		$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3345
+		if (! $registration instanceof EE_Registration) {
3346
+			throw new RuntimeException(
3347
+				sprintf(
3348
+					esc_html__(
3349
+						'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3350
+						'event_espresso'
3351
+					),
3352
+					$REG_ID
3353
+				)
3354
+			);
3355
+		}
3356
+		$attendee = $registration->attendee();
3357
+		// remove relation of existing attendee on registration
3358
+		$registration->_remove_relation_to($attendee, 'Attendee');
3359
+		// new attendee
3360
+		$new_attendee = clone $attendee;
3361
+		$new_attendee->set('ATT_ID', 0);
3362
+		$new_attendee->save();
3363
+		// add new attendee to reg
3364
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3365
+		EE_Error::add_success(
3366
+			esc_html__(
3367
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3368
+				'event_espresso'
3369
+			)
3370
+		);
3371
+		// redirect to edit page for attendee
3372
+		$query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3373
+		$this->_redirect_after_action('', '', '', $query_args, true);
3374
+	}
3375
+
3376
+
3377
+	/**
3378
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3379
+	 *
3380
+	 * @param int     $post_id
3381
+	 * @param WP_Post $post
3382
+	 * @throws DomainException
3383
+	 * @throws EE_Error
3384
+	 * @throws InvalidArgumentException
3385
+	 * @throws InvalidDataTypeException
3386
+	 * @throws InvalidInterfaceException
3387
+	 * @throws LogicException
3388
+	 * @throws InvalidFormSubmissionException
3389
+	 * @throws ReflectionException
3390
+	 */
3391
+	protected function _insert_update_cpt_item($post_id, $post)
3392
+	{
3393
+		$success  = true;
3394
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3395
+			? $this->getAttendeeModel()->get_one_by_ID($post_id)
3396
+			: null;
3397
+		// for attendee updates
3398
+		if ($attendee instanceof EE_Attendee) {
3399
+			// note we should only be UPDATING attendees at this point.
3400
+			$fname          = $this->request->getRequestParam('ATT_fname', '');
3401
+			$lname          = $this->request->getRequestParam('ATT_lname', '');
3402
+			$updated_fields = [
3403
+				'ATT_fname'     => $fname,
3404
+				'ATT_lname'     => $lname,
3405
+				'ATT_full_name' => "{$fname} {$lname}",
3406
+				'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3407
+				'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3408
+				'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3409
+				'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3410
+				'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3411
+				'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3412
+			];
3413
+			foreach ($updated_fields as $field => $value) {
3414
+				$attendee->set($field, $value);
3415
+			}
3416
+
3417
+			// process contact details metabox form handler (which will also save the attendee)
3418
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3419
+			$success              = $contact_details_form->process($this->request->requestParams());
3420
+
3421
+			$attendee_update_callbacks = apply_filters(
3422
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3423
+				[]
3424
+			);
3425
+			foreach ($attendee_update_callbacks as $a_callback) {
3426
+				if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3427
+					throw new EE_Error(
3428
+						sprintf(
3429
+							esc_html__(
3430
+								'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3431
+								'event_espresso'
3432
+							),
3433
+							$a_callback
3434
+						)
3435
+					);
3436
+				}
3437
+			}
3438
+		}
3439
+
3440
+		if ($success === false) {
3441
+			EE_Error::add_error(
3442
+				esc_html__(
3443
+					'Something went wrong with updating the meta table data for the registration.',
3444
+					'event_espresso'
3445
+				),
3446
+				__FILE__,
3447
+				__FUNCTION__,
3448
+				__LINE__
3449
+			);
3450
+		}
3451
+	}
3452
+
3453
+
3454
+	public function trash_cpt_item($post_id)
3455
+	{
3456
+	}
3457
+
3458
+
3459
+	public function delete_cpt_item($post_id)
3460
+	{
3461
+	}
3462
+
3463
+
3464
+	public function restore_cpt_item($post_id)
3465
+	{
3466
+	}
3467
+
3468
+
3469
+	protected function _restore_cpt_item($post_id, $revision_id)
3470
+	{
3471
+	}
3472
+
3473
+
3474
+	/**
3475
+	 * @throws EE_Error
3476
+	 * @throws ReflectionException
3477
+	 * @since 4.10.2.p
3478
+	 */
3479
+	public function attendee_editor_metaboxes()
3480
+	{
3481
+		$this->verify_cpt_object();
3482
+		remove_meta_box(
3483
+			'postexcerpt',
3484
+			$this->_cpt_routes[ $this->_req_action ],
3485
+			'normal'
3486
+		);
3487
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3488
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3489
+			$this->addMetaBox(
3490
+				'postexcerpt',
3491
+				esc_html__('Short Biography', 'event_espresso'),
3492
+				'post_excerpt_meta_box',
3493
+				$this->_cpt_routes[ $this->_req_action ]
3494
+			);
3495
+		}
3496
+		if (post_type_supports('espresso_attendees', 'comments')) {
3497
+			$this->addMetaBox(
3498
+				'commentsdiv',
3499
+				esc_html__('Notes on the Contact', 'event_espresso'),
3500
+				'post_comment_meta_box',
3501
+				$this->_cpt_routes[ $this->_req_action ],
3502
+				'normal',
3503
+				'core'
3504
+			);
3505
+		}
3506
+		$this->addMetaBox(
3507
+			'attendee_contact_info',
3508
+			esc_html__('Contact Info', 'event_espresso'),
3509
+			[$this, 'attendee_contact_info'],
3510
+			$this->_cpt_routes[ $this->_req_action ],
3511
+			'side',
3512
+			'core'
3513
+		);
3514
+		$this->addMetaBox(
3515
+			'attendee_details_address',
3516
+			esc_html__('Address Details', 'event_espresso'),
3517
+			[$this, 'attendee_address_details'],
3518
+			$this->_cpt_routes[ $this->_req_action ],
3519
+			'normal',
3520
+			'core'
3521
+		);
3522
+		$this->addMetaBox(
3523
+			'attendee_registrations',
3524
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3525
+			[$this, 'attendee_registrations_meta_box'],
3526
+			$this->_cpt_routes[ $this->_req_action ]
3527
+		);
3528
+	}
3529
+
3530
+
3531
+	/**
3532
+	 * Metabox for attendee contact info
3533
+	 *
3534
+	 * @param WP_Post $post wp post object
3535
+	 * @return void attendee contact info ( and form )
3536
+	 * @throws EE_Error
3537
+	 * @throws InvalidArgumentException
3538
+	 * @throws InvalidDataTypeException
3539
+	 * @throws InvalidInterfaceException
3540
+	 * @throws LogicException
3541
+	 * @throws DomainException
3542
+	 */
3543
+	public function attendee_contact_info($post)
3544
+	{
3545
+		// get attendee object ( should already have it )
3546
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3547
+		$form->enqueueStylesAndScripts();
3548
+		echo wp_kses($form->display(), AllowedTags::getWithFormTags());
3549
+	}
3550
+
3551
+
3552
+	/**
3553
+	 * Return form handler for the contact details metabox
3554
+	 *
3555
+	 * @param EE_Attendee $attendee
3556
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3557
+	 * @throws DomainException
3558
+	 * @throws InvalidArgumentException
3559
+	 * @throws InvalidDataTypeException
3560
+	 * @throws InvalidInterfaceException
3561
+	 */
3562
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3563
+	{
3564
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3565
+	}
3566
+
3567
+
3568
+	/**
3569
+	 * Metabox for attendee details
3570
+	 *
3571
+	 * @param WP_Post $post wp post object
3572
+	 * @throws EE_Error
3573
+	 * @throws ReflectionException
3574
+	 */
3575
+	public function attendee_address_details($post)
3576
+	{
3577
+		// get attendee object (should already have it)
3578
+		$this->_template_args['attendee']     = $this->_cpt_model_obj;
3579
+		$this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3580
+			new EE_Question_Form_Input(
3581
+				EE_Question::new_instance(
3582
+					[
3583
+						'QST_ID'           => 0,
3584
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3585
+						'QST_system'       => 'admin-state',
3586
+					]
3587
+				),
3588
+				EE_Answer::new_instance(
3589
+					[
3590
+						'ANS_ID'    => 0,
3591
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3592
+					]
3593
+				),
3594
+				[
3595
+					'input_id'       => 'STA_ID',
3596
+					'input_name'     => 'STA_ID',
3597
+					'input_prefix'   => '',
3598
+					'append_qstn_id' => false,
3599
+				]
3600
+			)
3601
+		);
3602
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3603
+			new EE_Question_Form_Input(
3604
+				EE_Question::new_instance(
3605
+					[
3606
+						'QST_ID'           => 0,
3607
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3608
+						'QST_system'       => 'admin-country',
3609
+					]
3610
+				),
3611
+				EE_Answer::new_instance(
3612
+					[
3613
+						'ANS_ID'    => 0,
3614
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3615
+					]
3616
+				),
3617
+				[
3618
+					'input_id'       => 'CNT_ISO',
3619
+					'input_name'     => 'CNT_ISO',
3620
+					'input_prefix'   => '',
3621
+					'append_qstn_id' => false,
3622
+				]
3623
+			)
3624
+		);
3625
+		$template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3626
+		EEH_Template::display_template($template, $this->_template_args);
3627
+	}
3628
+
3629
+
3630
+	/**
3631
+	 * _attendee_details
3632
+	 *
3633
+	 * @param $post
3634
+	 * @return void
3635
+	 * @throws DomainException
3636
+	 * @throws EE_Error
3637
+	 * @throws InvalidArgumentException
3638
+	 * @throws InvalidDataTypeException
3639
+	 * @throws InvalidInterfaceException
3640
+	 * @throws ReflectionException
3641
+	 */
3642
+	public function attendee_registrations_meta_box($post)
3643
+	{
3644
+		$this->_template_args['attendee']      = $this->_cpt_model_obj;
3645
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3646
+		$template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3647
+		EEH_Template::display_template($template, $this->_template_args);
3648
+	}
3649
+
3650
+
3651
+	/**
3652
+	 * add in the form fields for the attendee edit
3653
+	 *
3654
+	 * @param WP_Post $post wp post object
3655
+	 * @return void echos html for new form.
3656
+	 * @throws DomainException
3657
+	 */
3658
+	public function after_title_form_fields($post)
3659
+	{
3660
+		if ($post->post_type === 'espresso_attendees') {
3661
+			$template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3662
+			$template_args['attendee'] = $this->_cpt_model_obj;
3663
+			EEH_Template::display_template($template, $template_args);
3664
+		}
3665
+	}
3666
+
3667
+
3668
+	/**
3669
+	 * _trash_or_restore_attendee
3670
+	 *
3671
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3672
+	 * @return void
3673
+	 * @throws EE_Error
3674
+	 * @throws InvalidArgumentException
3675
+	 * @throws InvalidDataTypeException
3676
+	 * @throws InvalidInterfaceException
3677
+	 */
3678
+	protected function _trash_or_restore_attendees($trash = true)
3679
+	{
3680
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3681
+		$status = $trash ? 'trash' : 'publish';
3682
+		// Checkboxes
3683
+		if ($this->request->requestParamIsSet('checkbox')) {
3684
+			$ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3685
+			// if array has more than one element than success message should be plural
3686
+			$success = count($ATT_IDs) > 1 ? 2 : 1;
3687
+			// cycle thru checkboxes
3688
+			foreach ($ATT_IDs as $ATT_ID) {
3689
+				$updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3690
+				if (! $updated) {
3691
+					$success = 0;
3692
+				}
3693
+			}
3694
+		} else {
3695
+			// grab single id and delete
3696
+			$ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3697
+			// update attendee
3698
+			$success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3699
+		}
3700
+		$what        = $success > 1
3701
+			? esc_html__('Contacts', 'event_espresso')
3702
+			: esc_html__('Contact', 'event_espresso');
3703
+		$action_desc = $trash
3704
+			? esc_html__('moved to the trash', 'event_espresso')
3705
+			: esc_html__('restored', 'event_espresso');
3706
+		$this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3707
+	}
3708 3708
 }
Please login to merge, or discard this patch.