Completed
Branch BUG/send-test-email-not-requir... (ff675f)
by
unknown
02:14 queued 29s
created
core/services/request/RequestParams.php 1 patch
Indentation   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -14,327 +14,327 @@
 block discarded – undo
14 14
 class RequestParams
15 15
 {
16 16
 
17
-    /**
18
-     * $_GET parameters
19
-     *
20
-     * @var array
21
-     */
22
-    protected $get;
23
-
24
-    /**
25
-     * $_POST parameters
26
-     *
27
-     * @var array
28
-     */
29
-    protected $post;
30
-
31
-    /**
32
-     * $_REQUEST parameters
33
-     *
34
-     * @var array
35
-     */
36
-    protected $request;
37
-
38
-    /**
39
-     * @var RequestSanitizer
40
-     */
41
-    protected $sanitizer;
42
-
43
-
44
-    /**
45
-     * RequestParams constructor.
46
-     *
47
-     * @param RequestSanitizer $sanitizer
48
-     * @param array            $get
49
-     * @param array            $post
50
-     */
51
-    public function __construct(RequestSanitizer $sanitizer, array $get = [], array $post = [])
52
-    {
53
-        $this->sanitizer = $sanitizer;
54
-        $this->get       = ! empty($get) ? $get : $_GET;
55
-        $this->post      = ! empty($post) ? $post : $_POST;
56
-        $this->request   = array_merge($this->get, $this->post);
57
-    }
58
-
59
-
60
-    /**
61
-     * @return array
62
-     */
63
-    public function getParams()
64
-    {
65
-        return $this->get;
66
-    }
67
-
68
-
69
-    /**
70
-     * @return array
71
-     */
72
-    public function postParams()
73
-    {
74
-        return $this->post;
75
-    }
76
-
77
-
78
-    /**
79
-     * returns contents of $_REQUEST
80
-     *
81
-     * @return array
82
-     */
83
-    public function requestParams()
84
-    {
85
-        return $this->request;
86
-    }
87
-
88
-
89
-    /**
90
-     * @param string     $key
91
-     * @param mixed|null $value
92
-     * @param bool       $override_ee
93
-     * @return    void
94
-     */
95
-    public function setRequestParam($key, $value, $override_ee = false)
96
-    {
97
-        // don't allow "ee" to be overwritten unless explicitly instructed to do so
98
-        if ($override_ee || $key !== 'ee' || empty($this->request['ee'])) {
99
-            $this->request[ $key ] = $value;
100
-        }
101
-    }
102
-
103
-
104
-    /**
105
-     * merges the incoming array of parameters into the existing request parameters
106
-     *
107
-     * @param array $request_params
108
-     * @return void
109
-     * @since   $VID:$
110
-     */
111
-    public function mergeRequestParams(array $request_params)
112
-    {
113
-        $this->request = array_merge_recursive($this->request, $request_params);
114
-    }
115
-
116
-
117
-    /**
118
-     * returns   the value for a request param if the given key exists
119
-     *
120
-     * @param string     $key
121
-     * @param mixed|null $default
122
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
123
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
124
-     * @param string     $delimiter for CSV type strings that should be returned as an array
125
-     * @return array|bool|float|int|string
126
-     */
127
-    public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '')
128
-    {
129
-        return $this->sanitizer->clean(
130
-            $this->parameterDrillDown($key, $default, 'get'),
131
-            $type,
132
-            $is_array,
133
-            $delimiter
134
-        );
135
-    }
136
-
137
-
138
-    /**
139
-     * check if param exists
140
-     *
141
-     * @param string $key
142
-     * @return bool
143
-     */
144
-    public function requestParamIsSet($key)
145
-    {
146
-        return (bool) $this->parameterDrillDown($key);
147
-    }
148
-
149
-
150
-    /**
151
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
152
-     * and return the value for the first match found
153
-     * wildcards can be either of the following:
154
-     *      ? to represent a single character of any type
155
-     *      * to represent one or more characters of any type
156
-     *
157
-     * @param string     $pattern
158
-     * @param mixed|null $default
159
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
160
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
161
-     * @param string     $delimiter for CSV type strings that should be returned as an array
162
-     * @return array|bool|float|int|string
163
-     */
164
-    public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '')
165
-    {
166
-        return $this->sanitizer->clean(
167
-            $this->parameterDrillDown($pattern, $default, 'match'),
168
-            $type,
169
-            $is_array,
170
-            $delimiter
171
-        );
172
-    }
173
-
174
-
175
-    /**
176
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
177
-     * wildcards can be either of the following:
178
-     *      ? to represent a single character of any type
179
-     *      * to represent one or more characters of any type
180
-     * returns true if a match is found or false if not
181
-     *
182
-     * @param string $pattern
183
-     * @return bool
184
-     */
185
-    public function matches($pattern)
186
-    {
187
-        return (bool) $this->parameterDrillDown($pattern, false, 'match', 'bool');
188
-    }
189
-
190
-
191
-    /**
192
-     * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
193
-     * @param string $pattern               A string including wildcards to be converted to a regex pattern
194
-     *                                      and used to search through the current request's parameter keys
195
-     * @param array  $request_params        The array of request parameters to search through
196
-     * @param mixed  $default               [optional] The value to be returned if no match is found.
197
-     *                                      Default is null
198
-     * @param string $return                [optional] Controls what kind of value is returned.
199
-     *                                      Options are:
200
-     *                                      'bool' will return true or false if match is found or not
201
-     *                                      'key' will return the first key found that matches the supplied pattern
202
-     *                                      'value' will return the value for the first request parameter
203
-     *                                      whose key matches the supplied pattern
204
-     *                                      Default is 'value'
205
-     * @return boolean|string
206
-     */
207
-    private function match($pattern, array $request_params, $default = null, $return = 'value')
208
-    {
209
-        $return = in_array($return, ['bool', 'key', 'value'], true)
210
-            ? $return
211
-            : 'is_set';
212
-        // replace wildcard chars with regex chars
213
-        $pattern = str_replace(
214
-            ['\*', '\?'],
215
-            ['.*', '.'],
216
-            preg_quote($pattern, '/')
217
-        );
218
-        foreach ($request_params as $key => $request_param) {
219
-            if (preg_match('/^' . $pattern . '$/is', $key)) {
220
-                // return value for request param
221
-                if ($return === 'value') {
222
-                    return $request_param;
223
-                }
224
-                // or actual key or true just to indicate it was found
225
-                return $return === 'key' ? $key : true;
226
-            }
227
-        }
228
-        // match not found so return default value or false
229
-        return $return === 'value' ? $default : false;
230
-    }
231
-
232
-
233
-    /**
234
-     * the supplied key can be a simple string to represent a "top-level" request parameter
235
-     * or represent a key for a request parameter that is nested deeper within the request parameter array,
236
-     * by using square brackets to surround keys for deeper array elements.
237
-     * For example :
238
-     * if the supplied $key was: "first[second][third]"
239
-     * then this will attempt to drill down into the request parameter array to find a value.
240
-     * Given the following request parameters:
241
-     *  array(
242
-     *      'first' => array(
243
-     *          'second' => array(
244
-     *              'third' => 'has a value'
245
-     *          )
246
-     *      )
247
-     *  )
248
-     * would return true if default parameters were set
249
-     *
250
-     * @param string $callback
251
-     * @param        $key
252
-     * @param null   $default
253
-     * @param string $return
254
-     * @param mixed  $request_params
255
-     * @return bool|mixed|null
256
-     */
257
-    private function parameterDrillDown(
258
-        $key,
259
-        $default = null,
260
-        $callback = 'is_set',
261
-        $return = 'value',
262
-        $request_params = []
263
-    ) {
264
-        $callback       = in_array($callback, ['is_set', 'get', 'match'], true)
265
-            ? $callback
266
-            : 'is_set';
267
-        $request_params = ! empty($request_params)
268
-            ? $request_params
269
-            : $this->request;
270
-        // does incoming key represent an array like 'first[second][third]'  ?
271
-        if (strpos($key, '[') !== false) {
272
-            // turn it into an actual array
273
-            $key  = str_replace(']', '', $key);
274
-            $keys = explode('[', $key);
275
-            $key  = array_shift($keys);
276
-            if ($callback === 'match') {
277
-                $real_key = $this->match($key, $request_params, $default, 'key');
278
-                $key      = $real_key ?: $key;
279
-            }
280
-            // check if top level key exists
281
-            if (isset($request_params[ $key ])) {
282
-                // build a new key to pass along like: 'second[third]'
283
-                // or just 'second' depending on depth of keys
284
-                $key_string = array_shift($keys);
285
-                if (! empty($keys)) {
286
-                    $key_string .= '[' . implode('][', $keys) . ']';
287
-                }
288
-                return $this->parameterDrillDown(
289
-                    $key_string,
290
-                    $default,
291
-                    $callback,
292
-                    $return,
293
-                    $request_params[ $key ]
294
-                );
295
-            }
296
-        }
297
-        if ($callback === 'is_set') {
298
-            return isset($request_params[ $key ]);
299
-        }
300
-        if ($callback === 'match') {
301
-            return $this->match($key, $request_params, $default, $return);
302
-        }
303
-        return isset($request_params[ $key ])
304
-            ? $request_params[ $key ]
305
-            : $default;
306
-    }
307
-
308
-
309
-    /**
310
-     * remove param
311
-     *
312
-     * @param      $key
313
-     * @param bool $unset_from_global_too
314
-     */
315
-    public function unSetRequestParam($key, $unset_from_global_too = false)
316
-    {
317
-        // because unset may not actually remove var
318
-        $this->get[ $key ]     = null;
319
-        $this->post[ $key ]    = null;
320
-        $this->request[ $key ] = null;
321
-        unset($this->get[ $key ], $this->post[ $key ], $this->request[ $key ]);
322
-        if ($unset_from_global_too) {
323
-            unset($_GET[ $key ], $_POST[ $key ], $_REQUEST[ $key ]);
324
-        }
325
-    }
326
-
327
-
328
-    /**
329
-     * remove params
330
-     *
331
-     * @param array $keys
332
-     * @param bool  $unset_from_global_too
333
-     */
334
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false)
335
-    {
336
-        foreach ($keys as $key) {
337
-            $this->unSetRequestParam($key, $unset_from_global_too);
338
-        }
339
-    }
17
+	/**
18
+	 * $_GET parameters
19
+	 *
20
+	 * @var array
21
+	 */
22
+	protected $get;
23
+
24
+	/**
25
+	 * $_POST parameters
26
+	 *
27
+	 * @var array
28
+	 */
29
+	protected $post;
30
+
31
+	/**
32
+	 * $_REQUEST parameters
33
+	 *
34
+	 * @var array
35
+	 */
36
+	protected $request;
37
+
38
+	/**
39
+	 * @var RequestSanitizer
40
+	 */
41
+	protected $sanitizer;
42
+
43
+
44
+	/**
45
+	 * RequestParams constructor.
46
+	 *
47
+	 * @param RequestSanitizer $sanitizer
48
+	 * @param array            $get
49
+	 * @param array            $post
50
+	 */
51
+	public function __construct(RequestSanitizer $sanitizer, array $get = [], array $post = [])
52
+	{
53
+		$this->sanitizer = $sanitizer;
54
+		$this->get       = ! empty($get) ? $get : $_GET;
55
+		$this->post      = ! empty($post) ? $post : $_POST;
56
+		$this->request   = array_merge($this->get, $this->post);
57
+	}
58
+
59
+
60
+	/**
61
+	 * @return array
62
+	 */
63
+	public function getParams()
64
+	{
65
+		return $this->get;
66
+	}
67
+
68
+
69
+	/**
70
+	 * @return array
71
+	 */
72
+	public function postParams()
73
+	{
74
+		return $this->post;
75
+	}
76
+
77
+
78
+	/**
79
+	 * returns contents of $_REQUEST
80
+	 *
81
+	 * @return array
82
+	 */
83
+	public function requestParams()
84
+	{
85
+		return $this->request;
86
+	}
87
+
88
+
89
+	/**
90
+	 * @param string     $key
91
+	 * @param mixed|null $value
92
+	 * @param bool       $override_ee
93
+	 * @return    void
94
+	 */
95
+	public function setRequestParam($key, $value, $override_ee = false)
96
+	{
97
+		// don't allow "ee" to be overwritten unless explicitly instructed to do so
98
+		if ($override_ee || $key !== 'ee' || empty($this->request['ee'])) {
99
+			$this->request[ $key ] = $value;
100
+		}
101
+	}
102
+
103
+
104
+	/**
105
+	 * merges the incoming array of parameters into the existing request parameters
106
+	 *
107
+	 * @param array $request_params
108
+	 * @return void
109
+	 * @since   $VID:$
110
+	 */
111
+	public function mergeRequestParams(array $request_params)
112
+	{
113
+		$this->request = array_merge_recursive($this->request, $request_params);
114
+	}
115
+
116
+
117
+	/**
118
+	 * returns   the value for a request param if the given key exists
119
+	 *
120
+	 * @param string     $key
121
+	 * @param mixed|null $default
122
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
123
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
124
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
125
+	 * @return array|bool|float|int|string
126
+	 */
127
+	public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '')
128
+	{
129
+		return $this->sanitizer->clean(
130
+			$this->parameterDrillDown($key, $default, 'get'),
131
+			$type,
132
+			$is_array,
133
+			$delimiter
134
+		);
135
+	}
136
+
137
+
138
+	/**
139
+	 * check if param exists
140
+	 *
141
+	 * @param string $key
142
+	 * @return bool
143
+	 */
144
+	public function requestParamIsSet($key)
145
+	{
146
+		return (bool) $this->parameterDrillDown($key);
147
+	}
148
+
149
+
150
+	/**
151
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
152
+	 * and return the value for the first match found
153
+	 * wildcards can be either of the following:
154
+	 *      ? to represent a single character of any type
155
+	 *      * to represent one or more characters of any type
156
+	 *
157
+	 * @param string     $pattern
158
+	 * @param mixed|null $default
159
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
160
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
161
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
162
+	 * @return array|bool|float|int|string
163
+	 */
164
+	public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '')
165
+	{
166
+		return $this->sanitizer->clean(
167
+			$this->parameterDrillDown($pattern, $default, 'match'),
168
+			$type,
169
+			$is_array,
170
+			$delimiter
171
+		);
172
+	}
173
+
174
+
175
+	/**
176
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
177
+	 * wildcards can be either of the following:
178
+	 *      ? to represent a single character of any type
179
+	 *      * to represent one or more characters of any type
180
+	 * returns true if a match is found or false if not
181
+	 *
182
+	 * @param string $pattern
183
+	 * @return bool
184
+	 */
185
+	public function matches($pattern)
186
+	{
187
+		return (bool) $this->parameterDrillDown($pattern, false, 'match', 'bool');
188
+	}
189
+
190
+
191
+	/**
192
+	 * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
193
+	 * @param string $pattern               A string including wildcards to be converted to a regex pattern
194
+	 *                                      and used to search through the current request's parameter keys
195
+	 * @param array  $request_params        The array of request parameters to search through
196
+	 * @param mixed  $default               [optional] The value to be returned if no match is found.
197
+	 *                                      Default is null
198
+	 * @param string $return                [optional] Controls what kind of value is returned.
199
+	 *                                      Options are:
200
+	 *                                      'bool' will return true or false if match is found or not
201
+	 *                                      'key' will return the first key found that matches the supplied pattern
202
+	 *                                      'value' will return the value for the first request parameter
203
+	 *                                      whose key matches the supplied pattern
204
+	 *                                      Default is 'value'
205
+	 * @return boolean|string
206
+	 */
207
+	private function match($pattern, array $request_params, $default = null, $return = 'value')
208
+	{
209
+		$return = in_array($return, ['bool', 'key', 'value'], true)
210
+			? $return
211
+			: 'is_set';
212
+		// replace wildcard chars with regex chars
213
+		$pattern = str_replace(
214
+			['\*', '\?'],
215
+			['.*', '.'],
216
+			preg_quote($pattern, '/')
217
+		);
218
+		foreach ($request_params as $key => $request_param) {
219
+			if (preg_match('/^' . $pattern . '$/is', $key)) {
220
+				// return value for request param
221
+				if ($return === 'value') {
222
+					return $request_param;
223
+				}
224
+				// or actual key or true just to indicate it was found
225
+				return $return === 'key' ? $key : true;
226
+			}
227
+		}
228
+		// match not found so return default value or false
229
+		return $return === 'value' ? $default : false;
230
+	}
231
+
232
+
233
+	/**
234
+	 * the supplied key can be a simple string to represent a "top-level" request parameter
235
+	 * or represent a key for a request parameter that is nested deeper within the request parameter array,
236
+	 * by using square brackets to surround keys for deeper array elements.
237
+	 * For example :
238
+	 * if the supplied $key was: "first[second][third]"
239
+	 * then this will attempt to drill down into the request parameter array to find a value.
240
+	 * Given the following request parameters:
241
+	 *  array(
242
+	 *      'first' => array(
243
+	 *          'second' => array(
244
+	 *              'third' => 'has a value'
245
+	 *          )
246
+	 *      )
247
+	 *  )
248
+	 * would return true if default parameters were set
249
+	 *
250
+	 * @param string $callback
251
+	 * @param        $key
252
+	 * @param null   $default
253
+	 * @param string $return
254
+	 * @param mixed  $request_params
255
+	 * @return bool|mixed|null
256
+	 */
257
+	private function parameterDrillDown(
258
+		$key,
259
+		$default = null,
260
+		$callback = 'is_set',
261
+		$return = 'value',
262
+		$request_params = []
263
+	) {
264
+		$callback       = in_array($callback, ['is_set', 'get', 'match'], true)
265
+			? $callback
266
+			: 'is_set';
267
+		$request_params = ! empty($request_params)
268
+			? $request_params
269
+			: $this->request;
270
+		// does incoming key represent an array like 'first[second][third]'  ?
271
+		if (strpos($key, '[') !== false) {
272
+			// turn it into an actual array
273
+			$key  = str_replace(']', '', $key);
274
+			$keys = explode('[', $key);
275
+			$key  = array_shift($keys);
276
+			if ($callback === 'match') {
277
+				$real_key = $this->match($key, $request_params, $default, 'key');
278
+				$key      = $real_key ?: $key;
279
+			}
280
+			// check if top level key exists
281
+			if (isset($request_params[ $key ])) {
282
+				// build a new key to pass along like: 'second[third]'
283
+				// or just 'second' depending on depth of keys
284
+				$key_string = array_shift($keys);
285
+				if (! empty($keys)) {
286
+					$key_string .= '[' . implode('][', $keys) . ']';
287
+				}
288
+				return $this->parameterDrillDown(
289
+					$key_string,
290
+					$default,
291
+					$callback,
292
+					$return,
293
+					$request_params[ $key ]
294
+				);
295
+			}
296
+		}
297
+		if ($callback === 'is_set') {
298
+			return isset($request_params[ $key ]);
299
+		}
300
+		if ($callback === 'match') {
301
+			return $this->match($key, $request_params, $default, $return);
302
+		}
303
+		return isset($request_params[ $key ])
304
+			? $request_params[ $key ]
305
+			: $default;
306
+	}
307
+
308
+
309
+	/**
310
+	 * remove param
311
+	 *
312
+	 * @param      $key
313
+	 * @param bool $unset_from_global_too
314
+	 */
315
+	public function unSetRequestParam($key, $unset_from_global_too = false)
316
+	{
317
+		// because unset may not actually remove var
318
+		$this->get[ $key ]     = null;
319
+		$this->post[ $key ]    = null;
320
+		$this->request[ $key ] = null;
321
+		unset($this->get[ $key ], $this->post[ $key ], $this->request[ $key ]);
322
+		if ($unset_from_global_too) {
323
+			unset($_GET[ $key ], $_POST[ $key ], $_REQUEST[ $key ]);
324
+		}
325
+	}
326
+
327
+
328
+	/**
329
+	 * remove params
330
+	 *
331
+	 * @param array $keys
332
+	 * @param bool  $unset_from_global_too
333
+	 */
334
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false)
335
+	{
336
+		foreach ($keys as $key) {
337
+			$this->unSetRequestParam($key, $unset_from_global_too);
338
+		}
339
+	}
340 340
 }
Please login to merge, or discard this patch.
core/services/request/Request.php 1 patch
Indentation   +491 added lines, -491 removed lines patch added patch discarded remove patch
@@ -17,495 +17,495 @@
 block discarded – undo
17 17
 class Request implements InterminableInterface, RequestInterface, ReservedInstanceInterface
18 18
 {
19 19
 
20
-    /**
21
-     * $_COOKIE parameters
22
-     *
23
-     * @var array
24
-     */
25
-    protected $cookies;
26
-
27
-    /**
28
-     * $_FILES parameters
29
-     *
30
-     * @var array
31
-     */
32
-    protected $files;
33
-
34
-    /**
35
-     * true if current user appears to be some kind of bot
36
-     *
37
-     * @var bool
38
-     */
39
-    protected $is_bot;
40
-
41
-    /**
42
-     * @var RequestParams
43
-     */
44
-    protected $request_params;
45
-
46
-    /**
47
-     * @var RequestTypeContextCheckerInterface
48
-     */
49
-    protected $request_type;
50
-
51
-    /**
52
-     * @var ServerParams
53
-     */
54
-    protected $server_params;
55
-
56
-
57
-    public function __construct(
58
-        RequestParams $request_params,
59
-        ServerParams $server_params,
60
-        array $cookies = [],
61
-        array $files = []
62
-    ) {
63
-        $this->cookies = ! empty($cookies)
64
-            ? $cookies
65
-            : filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_STRING);
66
-        $this->files          = ! empty($files) ? $files : $_FILES;
67
-        $this->request_params = $request_params;
68
-        $this->server_params  = $server_params;
69
-    }
70
-
71
-
72
-    /**
73
-     * @param RequestTypeContextCheckerInterface $type
74
-     */
75
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
76
-    {
77
-        $this->request_type = $type;
78
-    }
79
-
80
-
81
-    /**
82
-     * @return array
83
-     */
84
-    public function getParams()
85
-    {
86
-        return $this->request_params->getParams();
87
-    }
88
-
89
-
90
-    /**
91
-     * @return array
92
-     */
93
-    public function postParams()
94
-    {
95
-        return $this->request_params->postParams();
96
-    }
97
-
98
-
99
-    /**
100
-     * @return array
101
-     */
102
-    public function cookieParams()
103
-    {
104
-        return $this->cookies;
105
-    }
106
-
107
-
108
-    /**
109
-     * @return array
110
-     */
111
-    public function serverParams()
112
-    {
113
-        return $this->server_params->getAllServerParams();
114
-    }
115
-
116
-
117
-    /**
118
-     * @param string $key
119
-     * @param mixed|null $default
120
-     * @return array|int|float|string
121
-     */
122
-    public function getServerParam($key, $default = null)
123
-    {
124
-        return $this->server_params->getServerParam($key, $default);
125
-    }
126
-
127
-
128
-    /**
129
-     * @param string                 $key
130
-     * @param array|int|float|string $value
131
-     * @return void
132
-     */
133
-    public function setServerParam($key, $value)
134
-    {
135
-        $this->server_params->setServerParam($key, $value);
136
-    }
137
-
138
-
139
-    /**
140
-     * @param string $key
141
-     * @return bool
142
-     */
143
-    public function serverParamIsSet($key)
144
-    {
145
-        return $this->server_params->serverParamIsSet($key);
146
-    }
147
-
148
-
149
-    /**
150
-     * @return array
151
-     */
152
-    public function filesParams()
153
-    {
154
-        return $this->files;
155
-    }
156
-
157
-
158
-    /**
159
-     * returns sanitized contents of $_REQUEST
160
-     *
161
-     * @return array
162
-     */
163
-    public function requestParams()
164
-    {
165
-        return $this->request_params->requestParams();
166
-    }
167
-
168
-
169
-    /**
170
-     * @param string     $key
171
-     * @param mixed|null $value
172
-     * @param bool       $override_ee
173
-     * @return void
174
-     */
175
-    public function setRequestParam($key, $value, $override_ee = false)
176
-    {
177
-        $this->request_params->setRequestParam($key, $value, $override_ee);
178
-    }
179
-
180
-
181
-    /**
182
-     * merges the incoming array of parameters into the existing request parameters
183
-     *
184
-     * @param array $request_params
185
-     * @return void
186
-     * @since   $VID:$
187
-     */
188
-    public function mergeRequestParams(array $request_params)
189
-    {
190
-        $this->request_params->mergeRequestParams($request_params);
191
-    }
192
-
193
-
194
-    /**
195
-     * returns sanitized value for a request param if the given key exists
196
-     *
197
-     * @param string     $key
198
-     * @param mixed|null $default
199
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
200
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
201
-     * @param string     $delimiter for CSV type strings that should be returned as an array
202
-     * @return array|bool|float|int|string
203
-     */
204
-    public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '')
205
-    {
206
-        return $this->request_params->getRequestParam($key, $default, $type, $is_array, $delimiter);
207
-    }
208
-
209
-
210
-    /**
211
-     * check if param exists
212
-     *
213
-     * @param string $key
214
-     * @return bool
215
-     */
216
-    public function requestParamIsSet($key)
217
-    {
218
-        return $this->request_params->requestParamIsSet($key);
219
-    }
220
-
221
-
222
-    /**
223
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
224
-     * and return the sanitized value for the first match found
225
-     * wildcards can be either of the following:
226
-     *      ? to represent a single character of any type
227
-     *      * to represent one or more characters of any type
228
-     *
229
-     * @param string     $pattern
230
-     * @param mixed|null $default
231
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
232
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
233
-     * @param string     $delimiter for CSV type strings that should be returned as an array
234
-     * @return array|bool|float|int|string
235
-     */
236
-    public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '')
237
-    {
238
-        return $this->request_params->getMatch($pattern, $default, $type, $is_array, $delimiter);
239
-    }
240
-
241
-
242
-    /**
243
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
244
-     * wildcards can be either of the following:
245
-     *      ? to represent a single character of any type
246
-     *      * to represent one or more characters of any type
247
-     * returns true if a match is found or false if not
248
-     *
249
-     * @param string $pattern
250
-     * @return bool
251
-     */
252
-    public function matches($pattern)
253
-    {
254
-        return $this->request_params->matches($pattern);
255
-    }
256
-
257
-
258
-    /**
259
-     * remove param
260
-     *
261
-     * @param      $key
262
-     * @param bool $unset_from_global_too
263
-     */
264
-    public function unSetRequestParam($key, $unset_from_global_too = false)
265
-    {
266
-        $this->request_params->unSetRequestParam($key, $unset_from_global_too);
267
-    }
268
-
269
-
270
-    /**
271
-     * remove params
272
-     *
273
-     * @param array $keys
274
-     * @param bool  $unset_from_global_too
275
-     */
276
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false)
277
-    {
278
-        $this->request_params->unSetRequestParams($keys, $unset_from_global_too);
279
-    }
280
-
281
-
282
-    /**
283
-     * @return string
284
-     */
285
-    public function ipAddress()
286
-    {
287
-        return $this->server_params->ipAddress();
288
-    }
289
-
290
-
291
-    /**
292
-     * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
293
-     *
294
-     * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
295
-     *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
296
-     *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
297
-     * @return string
298
-     */
299
-    public function requestUri($relativeToWpRoot = false)
300
-    {
301
-        return $this->server_params->requestUri();
302
-    }
303
-
304
-
305
-    /**
306
-     * @return string
307
-     */
308
-    public function userAgent()
309
-    {
310
-        return $this->server_params->userAgent();
311
-    }
312
-
313
-
314
-    /**
315
-     * @param string $user_agent
316
-     */
317
-    public function setUserAgent($user_agent = '')
318
-    {
319
-        $this->server_params->setUserAgent($user_agent);
320
-    }
321
-
322
-
323
-    /**
324
-     * @return bool
325
-     */
326
-    public function isBot()
327
-    {
328
-        return $this->is_bot;
329
-    }
330
-
331
-
332
-    /**
333
-     * @param bool $is_bot
334
-     */
335
-    public function setIsBot($is_bot)
336
-    {
337
-        $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
338
-    }
339
-
340
-
341
-    /**
342
-     * @return bool
343
-     */
344
-    public function isActivation()
345
-    {
346
-        return $this->request_type->isActivation();
347
-    }
348
-
349
-
350
-    /**
351
-     * @param $is_activation
352
-     * @return bool
353
-     */
354
-    public function setIsActivation($is_activation)
355
-    {
356
-        return $this->request_type->setIsActivation($is_activation);
357
-    }
358
-
359
-
360
-    /**
361
-     * @return bool
362
-     */
363
-    public function isAdmin()
364
-    {
365
-        return $this->request_type->isAdmin();
366
-    }
367
-
368
-
369
-    /**
370
-     * @return bool
371
-     */
372
-    public function isAdminAjax()
373
-    {
374
-        return $this->request_type->isAdminAjax();
375
-    }
376
-
377
-
378
-    /**
379
-     * @return bool
380
-     */
381
-    public function isAjax()
382
-    {
383
-        return $this->request_type->isAjax();
384
-    }
385
-
386
-
387
-    /**
388
-     * @return bool
389
-     */
390
-    public function isEeAjax()
391
-    {
392
-        return $this->request_type->isEeAjax();
393
-    }
394
-
395
-
396
-    /**
397
-     * @return bool
398
-     */
399
-    public function isOtherAjax()
400
-    {
401
-        return $this->request_type->isOtherAjax();
402
-    }
403
-
404
-
405
-    /**
406
-     * @return bool
407
-     */
408
-    public function isApi()
409
-    {
410
-        return $this->request_type->isApi();
411
-    }
412
-
413
-
414
-    /**
415
-     * @return bool
416
-     */
417
-    public function isCli()
418
-    {
419
-        return $this->request_type->isCli();
420
-    }
421
-
422
-
423
-    /**
424
-     * @return bool
425
-     */
426
-    public function isCron()
427
-    {
428
-        return $this->request_type->isCron();
429
-    }
430
-
431
-
432
-    /**
433
-     * @return bool
434
-     */
435
-    public function isFeed()
436
-    {
437
-        return $this->request_type->isFeed();
438
-    }
439
-
440
-
441
-    /**
442
-     * @return bool
443
-     */
444
-    public function isFrontend()
445
-    {
446
-        return $this->request_type->isFrontend();
447
-    }
448
-
449
-
450
-    /**
451
-     * @return bool
452
-     */
453
-    public function isFrontAjax()
454
-    {
455
-        return $this->request_type->isFrontAjax();
456
-    }
457
-
458
-
459
-    /**
460
-     * @return bool
461
-     */
462
-    public function isIframe()
463
-    {
464
-        return $this->request_type->isIframe();
465
-    }
466
-
467
-
468
-    /**
469
-     * @return bool
470
-     */
471
-    public function isWordPressApi()
472
-    {
473
-        return $this->request_type->isWordPressApi();
474
-    }
475
-
476
-
477
-    /**
478
-     * @return bool
479
-     */
480
-    public function isWordPressHeartbeat()
481
-    {
482
-        return $this->request_type->isWordPressHeartbeat();
483
-    }
484
-
485
-
486
-    /**
487
-     * @return bool
488
-     */
489
-    public function isWordPressScrape()
490
-    {
491
-        return $this->request_type->isWordPressScrape();
492
-    }
493
-
494
-
495
-    /**
496
-     * @return string
497
-     */
498
-    public function slug()
499
-    {
500
-        return $this->request_type->slug();
501
-    }
502
-
503
-
504
-    /**
505
-     * @return RequestTypeContextCheckerInterface
506
-     */
507
-    public function getRequestType()
508
-    {
509
-        return $this->request_type;
510
-    }
20
+	/**
21
+	 * $_COOKIE parameters
22
+	 *
23
+	 * @var array
24
+	 */
25
+	protected $cookies;
26
+
27
+	/**
28
+	 * $_FILES parameters
29
+	 *
30
+	 * @var array
31
+	 */
32
+	protected $files;
33
+
34
+	/**
35
+	 * true if current user appears to be some kind of bot
36
+	 *
37
+	 * @var bool
38
+	 */
39
+	protected $is_bot;
40
+
41
+	/**
42
+	 * @var RequestParams
43
+	 */
44
+	protected $request_params;
45
+
46
+	/**
47
+	 * @var RequestTypeContextCheckerInterface
48
+	 */
49
+	protected $request_type;
50
+
51
+	/**
52
+	 * @var ServerParams
53
+	 */
54
+	protected $server_params;
55
+
56
+
57
+	public function __construct(
58
+		RequestParams $request_params,
59
+		ServerParams $server_params,
60
+		array $cookies = [],
61
+		array $files = []
62
+	) {
63
+		$this->cookies = ! empty($cookies)
64
+			? $cookies
65
+			: filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_STRING);
66
+		$this->files          = ! empty($files) ? $files : $_FILES;
67
+		$this->request_params = $request_params;
68
+		$this->server_params  = $server_params;
69
+	}
70
+
71
+
72
+	/**
73
+	 * @param RequestTypeContextCheckerInterface $type
74
+	 */
75
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
76
+	{
77
+		$this->request_type = $type;
78
+	}
79
+
80
+
81
+	/**
82
+	 * @return array
83
+	 */
84
+	public function getParams()
85
+	{
86
+		return $this->request_params->getParams();
87
+	}
88
+
89
+
90
+	/**
91
+	 * @return array
92
+	 */
93
+	public function postParams()
94
+	{
95
+		return $this->request_params->postParams();
96
+	}
97
+
98
+
99
+	/**
100
+	 * @return array
101
+	 */
102
+	public function cookieParams()
103
+	{
104
+		return $this->cookies;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @return array
110
+	 */
111
+	public function serverParams()
112
+	{
113
+		return $this->server_params->getAllServerParams();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @param string $key
119
+	 * @param mixed|null $default
120
+	 * @return array|int|float|string
121
+	 */
122
+	public function getServerParam($key, $default = null)
123
+	{
124
+		return $this->server_params->getServerParam($key, $default);
125
+	}
126
+
127
+
128
+	/**
129
+	 * @param string                 $key
130
+	 * @param array|int|float|string $value
131
+	 * @return void
132
+	 */
133
+	public function setServerParam($key, $value)
134
+	{
135
+		$this->server_params->setServerParam($key, $value);
136
+	}
137
+
138
+
139
+	/**
140
+	 * @param string $key
141
+	 * @return bool
142
+	 */
143
+	public function serverParamIsSet($key)
144
+	{
145
+		return $this->server_params->serverParamIsSet($key);
146
+	}
147
+
148
+
149
+	/**
150
+	 * @return array
151
+	 */
152
+	public function filesParams()
153
+	{
154
+		return $this->files;
155
+	}
156
+
157
+
158
+	/**
159
+	 * returns sanitized contents of $_REQUEST
160
+	 *
161
+	 * @return array
162
+	 */
163
+	public function requestParams()
164
+	{
165
+		return $this->request_params->requestParams();
166
+	}
167
+
168
+
169
+	/**
170
+	 * @param string     $key
171
+	 * @param mixed|null $value
172
+	 * @param bool       $override_ee
173
+	 * @return void
174
+	 */
175
+	public function setRequestParam($key, $value, $override_ee = false)
176
+	{
177
+		$this->request_params->setRequestParam($key, $value, $override_ee);
178
+	}
179
+
180
+
181
+	/**
182
+	 * merges the incoming array of parameters into the existing request parameters
183
+	 *
184
+	 * @param array $request_params
185
+	 * @return void
186
+	 * @since   $VID:$
187
+	 */
188
+	public function mergeRequestParams(array $request_params)
189
+	{
190
+		$this->request_params->mergeRequestParams($request_params);
191
+	}
192
+
193
+
194
+	/**
195
+	 * returns sanitized value for a request param if the given key exists
196
+	 *
197
+	 * @param string     $key
198
+	 * @param mixed|null $default
199
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
200
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
201
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
202
+	 * @return array|bool|float|int|string
203
+	 */
204
+	public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '')
205
+	{
206
+		return $this->request_params->getRequestParam($key, $default, $type, $is_array, $delimiter);
207
+	}
208
+
209
+
210
+	/**
211
+	 * check if param exists
212
+	 *
213
+	 * @param string $key
214
+	 * @return bool
215
+	 */
216
+	public function requestParamIsSet($key)
217
+	{
218
+		return $this->request_params->requestParamIsSet($key);
219
+	}
220
+
221
+
222
+	/**
223
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
224
+	 * and return the sanitized value for the first match found
225
+	 * wildcards can be either of the following:
226
+	 *      ? to represent a single character of any type
227
+	 *      * to represent one or more characters of any type
228
+	 *
229
+	 * @param string     $pattern
230
+	 * @param mixed|null $default
231
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
232
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
233
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
234
+	 * @return array|bool|float|int|string
235
+	 */
236
+	public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '')
237
+	{
238
+		return $this->request_params->getMatch($pattern, $default, $type, $is_array, $delimiter);
239
+	}
240
+
241
+
242
+	/**
243
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
244
+	 * wildcards can be either of the following:
245
+	 *      ? to represent a single character of any type
246
+	 *      * to represent one or more characters of any type
247
+	 * returns true if a match is found or false if not
248
+	 *
249
+	 * @param string $pattern
250
+	 * @return bool
251
+	 */
252
+	public function matches($pattern)
253
+	{
254
+		return $this->request_params->matches($pattern);
255
+	}
256
+
257
+
258
+	/**
259
+	 * remove param
260
+	 *
261
+	 * @param      $key
262
+	 * @param bool $unset_from_global_too
263
+	 */
264
+	public function unSetRequestParam($key, $unset_from_global_too = false)
265
+	{
266
+		$this->request_params->unSetRequestParam($key, $unset_from_global_too);
267
+	}
268
+
269
+
270
+	/**
271
+	 * remove params
272
+	 *
273
+	 * @param array $keys
274
+	 * @param bool  $unset_from_global_too
275
+	 */
276
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false)
277
+	{
278
+		$this->request_params->unSetRequestParams($keys, $unset_from_global_too);
279
+	}
280
+
281
+
282
+	/**
283
+	 * @return string
284
+	 */
285
+	public function ipAddress()
286
+	{
287
+		return $this->server_params->ipAddress();
288
+	}
289
+
290
+
291
+	/**
292
+	 * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
293
+	 *
294
+	 * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
295
+	 *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
296
+	 *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
297
+	 * @return string
298
+	 */
299
+	public function requestUri($relativeToWpRoot = false)
300
+	{
301
+		return $this->server_params->requestUri();
302
+	}
303
+
304
+
305
+	/**
306
+	 * @return string
307
+	 */
308
+	public function userAgent()
309
+	{
310
+		return $this->server_params->userAgent();
311
+	}
312
+
313
+
314
+	/**
315
+	 * @param string $user_agent
316
+	 */
317
+	public function setUserAgent($user_agent = '')
318
+	{
319
+		$this->server_params->setUserAgent($user_agent);
320
+	}
321
+
322
+
323
+	/**
324
+	 * @return bool
325
+	 */
326
+	public function isBot()
327
+	{
328
+		return $this->is_bot;
329
+	}
330
+
331
+
332
+	/**
333
+	 * @param bool $is_bot
334
+	 */
335
+	public function setIsBot($is_bot)
336
+	{
337
+		$this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
338
+	}
339
+
340
+
341
+	/**
342
+	 * @return bool
343
+	 */
344
+	public function isActivation()
345
+	{
346
+		return $this->request_type->isActivation();
347
+	}
348
+
349
+
350
+	/**
351
+	 * @param $is_activation
352
+	 * @return bool
353
+	 */
354
+	public function setIsActivation($is_activation)
355
+	{
356
+		return $this->request_type->setIsActivation($is_activation);
357
+	}
358
+
359
+
360
+	/**
361
+	 * @return bool
362
+	 */
363
+	public function isAdmin()
364
+	{
365
+		return $this->request_type->isAdmin();
366
+	}
367
+
368
+
369
+	/**
370
+	 * @return bool
371
+	 */
372
+	public function isAdminAjax()
373
+	{
374
+		return $this->request_type->isAdminAjax();
375
+	}
376
+
377
+
378
+	/**
379
+	 * @return bool
380
+	 */
381
+	public function isAjax()
382
+	{
383
+		return $this->request_type->isAjax();
384
+	}
385
+
386
+
387
+	/**
388
+	 * @return bool
389
+	 */
390
+	public function isEeAjax()
391
+	{
392
+		return $this->request_type->isEeAjax();
393
+	}
394
+
395
+
396
+	/**
397
+	 * @return bool
398
+	 */
399
+	public function isOtherAjax()
400
+	{
401
+		return $this->request_type->isOtherAjax();
402
+	}
403
+
404
+
405
+	/**
406
+	 * @return bool
407
+	 */
408
+	public function isApi()
409
+	{
410
+		return $this->request_type->isApi();
411
+	}
412
+
413
+
414
+	/**
415
+	 * @return bool
416
+	 */
417
+	public function isCli()
418
+	{
419
+		return $this->request_type->isCli();
420
+	}
421
+
422
+
423
+	/**
424
+	 * @return bool
425
+	 */
426
+	public function isCron()
427
+	{
428
+		return $this->request_type->isCron();
429
+	}
430
+
431
+
432
+	/**
433
+	 * @return bool
434
+	 */
435
+	public function isFeed()
436
+	{
437
+		return $this->request_type->isFeed();
438
+	}
439
+
440
+
441
+	/**
442
+	 * @return bool
443
+	 */
444
+	public function isFrontend()
445
+	{
446
+		return $this->request_type->isFrontend();
447
+	}
448
+
449
+
450
+	/**
451
+	 * @return bool
452
+	 */
453
+	public function isFrontAjax()
454
+	{
455
+		return $this->request_type->isFrontAjax();
456
+	}
457
+
458
+
459
+	/**
460
+	 * @return bool
461
+	 */
462
+	public function isIframe()
463
+	{
464
+		return $this->request_type->isIframe();
465
+	}
466
+
467
+
468
+	/**
469
+	 * @return bool
470
+	 */
471
+	public function isWordPressApi()
472
+	{
473
+		return $this->request_type->isWordPressApi();
474
+	}
475
+
476
+
477
+	/**
478
+	 * @return bool
479
+	 */
480
+	public function isWordPressHeartbeat()
481
+	{
482
+		return $this->request_type->isWordPressHeartbeat();
483
+	}
484
+
485
+
486
+	/**
487
+	 * @return bool
488
+	 */
489
+	public function isWordPressScrape()
490
+	{
491
+		return $this->request_type->isWordPressScrape();
492
+	}
493
+
494
+
495
+	/**
496
+	 * @return string
497
+	 */
498
+	public function slug()
499
+	{
500
+		return $this->request_type->slug();
501
+	}
502
+
503
+
504
+	/**
505
+	 * @return RequestTypeContextCheckerInterface
506
+	 */
507
+	public function getRequestType()
508
+	{
509
+		return $this->request_type;
510
+	}
511 511
 }
Please login to merge, or discard this patch.
core/services/request/RequestInterface.php 1 patch
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -16,195 +16,195 @@
 block discarded – undo
16 16
 interface RequestInterface extends RequestTypeContextCheckerInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @param RequestTypeContextCheckerInterface $type
21
-     */
22
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
19
+	/**
20
+	 * @param RequestTypeContextCheckerInterface $type
21
+	 */
22
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
23 23
 
24 24
 
25
-    /**
26
-     * @return array
27
-     */
28
-    public function getParams();
29
-
30
-
31
-    /**
32
-     * @return array
33
-     */
34
-    public function postParams();
35
-
36
-
37
-    /**
38
-     * @return array
39
-     */
40
-    public function cookieParams();
41
-
42
-
43
-    /**
44
-     * @return array
45
-     */
46
-    public function serverParams();
47
-
48
-
49
-    /**
50
-     * @param string $key
51
-     * @param mixed|null $default
52
-     * @return array|int|float|string
53
-     */
54
-    public function getServerParam($key, $default = null);
55
-
56
-
57
-    /**
58
-     * @param string                 $key
59
-     * @param array|int|float|string $value
60
-     * @return void
61
-     */
62
-    public function setServerParam($key, $value);
63
-
64
-
65
-    /**
66
-     * @param string $key
67
-     * @return bool
68
-     */
69
-    public function serverParamIsSet($key);
70
-
71
-
72
-    /**
73
-     * @return array
74
-     */
75
-    public function filesParams();
76
-
77
-
78
-    /**
79
-     * returns sanitized contents of $_REQUEST
80
-     *
81
-     * @return array
82
-     */
83
-    public function requestParams();
84
-
85
-
86
-    /**
87
-     * @param string $key
88
-     * @param string $value
89
-     * @param bool   $override_ee
90
-     * @return void
91
-     */
92
-    public function setRequestParam($key, $value, $override_ee = false);
93
-
94
-
95
-    /**
96
-     * returns   the value for a request param if the given key exists
97
-     *
98
-     * @param string     $key
99
-     * @param mixed|null $default
100
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
101
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
102
-     * @param string     $delimiter for CSV type strings that should be returned as an array
103
-     * @return array|bool|float|int|string
104
-     */
105
-    public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '');
106
-
107
-
108
-    /**
109
-     * check if param exists
110
-     *
111
-     * @param string $key
112
-     * @return bool
113
-     */
114
-    public function requestParamIsSet($key);
115
-
116
-
117
-    /**
118
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
119
-     * and return the value for the first match found
120
-     * wildcards can be either of the following:
121
-     *      ? to represent a single character of any type
122
-     *      * to represent one or more characters of any type
123
-     *
124
-     * @param string     $pattern
125
-     * @param mixed|null $default
126
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
127
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
128
-     * @param string     $delimiter for CSV type strings that should be returned as an array
129
-     * @return array|bool|float|int|string
130
-     */
131
-    public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '');
132
-
133
-
134
-    /**
135
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
136
-     * wildcards can be either of the following:
137
-     *      ? to represent a single character of any type
138
-     *      * to represent one or more characters of any type
139
-     * returns true if a match is found or false if not
140
-     *
141
-     * @param string $pattern
142
-     * @return false|int
143
-     */
144
-    public function matches($pattern);
145
-
146
-
147
-    /**
148
-     * remove param
149
-     *
150
-     * @param string $key
151
-     * @param bool   $unset_from_global_too
152
-     */
153
-    public function unSetRequestParam($key, $unset_from_global_too = false);
154
-
155
-
156
-    /**
157
-     * remove params
158
-     *
159
-     * @param array $keys
160
-     * @param bool  $unset_from_global_too
161
-     */
162
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false);
163
-
164
-
165
-    /**
166
-     * @return string
167
-     */
168
-    public function ipAddress();
169
-
170
-
171
-    /**
172
-     * @param boolean $relativeToWpRoot whether to return the uri relative to WordPress' home URL, or not.
173
-     * @return string
174
-     */
175
-    public function requestUri($relativeToWpRoot = false);
176
-
177
-
178
-    /**
179
-     * @return string
180
-     */
181
-    public function userAgent();
182
-
183
-
184
-    /**
185
-     * @param string $user_agent
186
-     */
187
-    public function setUserAgent($user_agent = '');
188
-
189
-
190
-    /**
191
-     * @return bool
192
-     */
193
-    public function isBot();
194
-
195
-
196
-    /**
197
-     * @param bool $is_bot
198
-     */
199
-    public function setIsBot($is_bot);
200
-
201
-
202
-    /**
203
-     * merges the incoming array of parameters into the existing request parameters
204
-     *
205
-     * @param array $request_params
206
-     * @return mixed
207
-     * @since   $VID:$
208
-     */
209
-    public function mergeRequestParams(array $request_params);
25
+	/**
26
+	 * @return array
27
+	 */
28
+	public function getParams();
29
+
30
+
31
+	/**
32
+	 * @return array
33
+	 */
34
+	public function postParams();
35
+
36
+
37
+	/**
38
+	 * @return array
39
+	 */
40
+	public function cookieParams();
41
+
42
+
43
+	/**
44
+	 * @return array
45
+	 */
46
+	public function serverParams();
47
+
48
+
49
+	/**
50
+	 * @param string $key
51
+	 * @param mixed|null $default
52
+	 * @return array|int|float|string
53
+	 */
54
+	public function getServerParam($key, $default = null);
55
+
56
+
57
+	/**
58
+	 * @param string                 $key
59
+	 * @param array|int|float|string $value
60
+	 * @return void
61
+	 */
62
+	public function setServerParam($key, $value);
63
+
64
+
65
+	/**
66
+	 * @param string $key
67
+	 * @return bool
68
+	 */
69
+	public function serverParamIsSet($key);
70
+
71
+
72
+	/**
73
+	 * @return array
74
+	 */
75
+	public function filesParams();
76
+
77
+
78
+	/**
79
+	 * returns sanitized contents of $_REQUEST
80
+	 *
81
+	 * @return array
82
+	 */
83
+	public function requestParams();
84
+
85
+
86
+	/**
87
+	 * @param string $key
88
+	 * @param string $value
89
+	 * @param bool   $override_ee
90
+	 * @return void
91
+	 */
92
+	public function setRequestParam($key, $value, $override_ee = false);
93
+
94
+
95
+	/**
96
+	 * returns   the value for a request param if the given key exists
97
+	 *
98
+	 * @param string     $key
99
+	 * @param mixed|null $default
100
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
101
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
102
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
103
+	 * @return array|bool|float|int|string
104
+	 */
105
+	public function getRequestParam($key, $default = null, $type = 'string', $is_array = false, $delimiter = '');
106
+
107
+
108
+	/**
109
+	 * check if param exists
110
+	 *
111
+	 * @param string $key
112
+	 * @return bool
113
+	 */
114
+	public function requestParamIsSet($key);
115
+
116
+
117
+	/**
118
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
119
+	 * and return the value for the first match found
120
+	 * wildcards can be either of the following:
121
+	 *      ? to represent a single character of any type
122
+	 *      * to represent one or more characters of any type
123
+	 *
124
+	 * @param string     $pattern
125
+	 * @param mixed|null $default
126
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
127
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
128
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
129
+	 * @return array|bool|float|int|string
130
+	 */
131
+	public function getMatch($pattern, $default = null, $type = 'string', $is_array = false, $delimiter = '');
132
+
133
+
134
+	/**
135
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
136
+	 * wildcards can be either of the following:
137
+	 *      ? to represent a single character of any type
138
+	 *      * to represent one or more characters of any type
139
+	 * returns true if a match is found or false if not
140
+	 *
141
+	 * @param string $pattern
142
+	 * @return false|int
143
+	 */
144
+	public function matches($pattern);
145
+
146
+
147
+	/**
148
+	 * remove param
149
+	 *
150
+	 * @param string $key
151
+	 * @param bool   $unset_from_global_too
152
+	 */
153
+	public function unSetRequestParam($key, $unset_from_global_too = false);
154
+
155
+
156
+	/**
157
+	 * remove params
158
+	 *
159
+	 * @param array $keys
160
+	 * @param bool  $unset_from_global_too
161
+	 */
162
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false);
163
+
164
+
165
+	/**
166
+	 * @return string
167
+	 */
168
+	public function ipAddress();
169
+
170
+
171
+	/**
172
+	 * @param boolean $relativeToWpRoot whether to return the uri relative to WordPress' home URL, or not.
173
+	 * @return string
174
+	 */
175
+	public function requestUri($relativeToWpRoot = false);
176
+
177
+
178
+	/**
179
+	 * @return string
180
+	 */
181
+	public function userAgent();
182
+
183
+
184
+	/**
185
+	 * @param string $user_agent
186
+	 */
187
+	public function setUserAgent($user_agent = '');
188
+
189
+
190
+	/**
191
+	 * @return bool
192
+	 */
193
+	public function isBot();
194
+
195
+
196
+	/**
197
+	 * @param bool $is_bot
198
+	 */
199
+	public function setIsBot($is_bot);
200
+
201
+
202
+	/**
203
+	 * merges the incoming array of parameters into the existing request parameters
204
+	 *
205
+	 * @param array $request_params
206
+	 * @return mixed
207
+	 * @since   $VID:$
208
+	 */
209
+	public function mergeRequestParams(array $request_params);
210 210
 }
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 2 patches
Indentation   +3685 added lines, -3685 removed lines patch added patch discarded remove patch
@@ -19,2233 +19,2233 @@  discard block
 block discarded – undo
19 19
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
20 20
 {
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 = null;
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->getLoader()->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->getLoader()->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->getLoader()->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->getLoader()->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_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
230
-                'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
231
-                'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
232
-                'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
233
-            ],
234
-            'publishbox'                   => [
235
-                'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
236
-                'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
237
-            ],
238
-            'hide_add_button_on_cpt_route' => [
239
-                'edit_attendee' => true,
240
-            ],
241
-        ];
242
-    }
243
-
244
-
245
-    /**
246
-     * grab url requests and route them
247
-     *
248
-     * @return void
249
-     * @throws EE_Error
250
-     */
251
-    public function _set_page_routes()
252
-    {
253
-        $this->_get_registration_status_array();
254
-        $REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
255
-        $REG_ID             = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
256
-        $ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
257
-        $ATT_ID             = $this->request->getRequestParam('post', $ATT_ID, 'int');
258
-        $this->_page_routes = [
259
-            'default'                             => [
260
-                'func'       => '_registrations_overview_list_table',
261
-                'capability' => 'ee_read_registrations',
262
-            ],
263
-            'view_registration'                   => [
264
-                'func'       => '_registration_details',
265
-                'capability' => 'ee_read_registration',
266
-                'obj_id'     => $REG_ID,
267
-            ],
268
-            'edit_registration'                   => [
269
-                'func'               => '_update_attendee_registration_form',
270
-                'noheader'           => true,
271
-                'headers_sent_route' => 'view_registration',
272
-                'capability'         => 'ee_edit_registration',
273
-                'obj_id'             => $REG_ID,
274
-                '_REG_ID'            => $REG_ID,
275
-            ],
276
-            'trash_registrations'                 => [
277
-                'func'       => '_trash_or_restore_registrations',
278
-                'args'       => ['trash' => true],
279
-                'noheader'   => true,
280
-                'capability' => 'ee_delete_registrations',
281
-            ],
282
-            'restore_registrations'               => [
283
-                'func'       => '_trash_or_restore_registrations',
284
-                'args'       => ['trash' => false],
285
-                'noheader'   => true,
286
-                'capability' => 'ee_delete_registrations',
287
-            ],
288
-            'delete_registrations'                => [
289
-                'func'       => '_delete_registrations',
290
-                'noheader'   => true,
291
-                'capability' => 'ee_delete_registrations',
292
-            ],
293
-            'new_registration'                    => [
294
-                'func'       => 'new_registration',
295
-                'capability' => 'ee_edit_registrations',
296
-            ],
297
-            'process_reg_step'                    => [
298
-                'func'       => 'process_reg_step',
299
-                'noheader'   => true,
300
-                'capability' => 'ee_edit_registrations',
301
-            ],
302
-            'redirect_to_txn'                     => [
303
-                'func'       => 'redirect_to_txn',
304
-                'noheader'   => true,
305
-                'capability' => 'ee_edit_registrations',
306
-            ],
307
-            'change_reg_status'                   => [
308
-                'func'       => '_change_reg_status',
309
-                'noheader'   => true,
310
-                'capability' => 'ee_edit_registration',
311
-                'obj_id'     => $REG_ID,
312
-            ],
313
-            'approve_registration'                => [
314
-                'func'       => 'approve_registration',
315
-                'noheader'   => true,
316
-                'capability' => 'ee_edit_registration',
317
-                'obj_id'     => $REG_ID,
318
-            ],
319
-            'approve_and_notify_registration'     => [
320
-                'func'       => 'approve_registration',
321
-                'noheader'   => true,
322
-                'args'       => [true],
323
-                'capability' => 'ee_edit_registration',
324
-                'obj_id'     => $REG_ID,
325
-            ],
326
-            'approve_registrations'               => [
327
-                'func'       => 'bulk_action_on_registrations',
328
-                'noheader'   => true,
329
-                'capability' => 'ee_edit_registrations',
330
-                'args'       => ['approve'],
331
-            ],
332
-            'approve_and_notify_registrations'    => [
333
-                'func'       => 'bulk_action_on_registrations',
334
-                'noheader'   => true,
335
-                'capability' => 'ee_edit_registrations',
336
-                'args'       => ['approve', true],
337
-            ],
338
-            'decline_registration'                => [
339
-                'func'       => 'decline_registration',
340
-                'noheader'   => true,
341
-                'capability' => 'ee_edit_registration',
342
-                'obj_id'     => $REG_ID,
343
-            ],
344
-            'decline_and_notify_registration'     => [
345
-                'func'       => 'decline_registration',
346
-                'noheader'   => true,
347
-                'args'       => [true],
348
-                'capability' => 'ee_edit_registration',
349
-                'obj_id'     => $REG_ID,
350
-            ],
351
-            'decline_registrations'               => [
352
-                'func'       => 'bulk_action_on_registrations',
353
-                'noheader'   => true,
354
-                'capability' => 'ee_edit_registrations',
355
-                'args'       => ['decline'],
356
-            ],
357
-            'decline_and_notify_registrations'    => [
358
-                'func'       => 'bulk_action_on_registrations',
359
-                'noheader'   => true,
360
-                'capability' => 'ee_edit_registrations',
361
-                'args'       => ['decline', true],
362
-            ],
363
-            'pending_registration'                => [
364
-                'func'       => 'pending_registration',
365
-                'noheader'   => true,
366
-                'capability' => 'ee_edit_registration',
367
-                'obj_id'     => $REG_ID,
368
-            ],
369
-            'pending_and_notify_registration'     => [
370
-                'func'       => 'pending_registration',
371
-                'noheader'   => true,
372
-                'args'       => [true],
373
-                'capability' => 'ee_edit_registration',
374
-                'obj_id'     => $REG_ID,
375
-            ],
376
-            'pending_registrations'               => [
377
-                'func'       => 'bulk_action_on_registrations',
378
-                'noheader'   => true,
379
-                'capability' => 'ee_edit_registrations',
380
-                'args'       => ['pending'],
381
-            ],
382
-            'pending_and_notify_registrations'    => [
383
-                'func'       => 'bulk_action_on_registrations',
384
-                'noheader'   => true,
385
-                'capability' => 'ee_edit_registrations',
386
-                'args'       => ['pending', true],
387
-            ],
388
-            'no_approve_registration'             => [
389
-                'func'       => 'not_approve_registration',
390
-                'noheader'   => true,
391
-                'capability' => 'ee_edit_registration',
392
-                'obj_id'     => $REG_ID,
393
-            ],
394
-            'no_approve_and_notify_registration'  => [
395
-                'func'       => 'not_approve_registration',
396
-                'noheader'   => true,
397
-                'args'       => [true],
398
-                'capability' => 'ee_edit_registration',
399
-                'obj_id'     => $REG_ID,
400
-            ],
401
-            'no_approve_registrations'            => [
402
-                'func'       => 'bulk_action_on_registrations',
403
-                'noheader'   => true,
404
-                'capability' => 'ee_edit_registrations',
405
-                'args'       => ['not_approve'],
406
-            ],
407
-            'no_approve_and_notify_registrations' => [
408
-                'func'       => 'bulk_action_on_registrations',
409
-                'noheader'   => true,
410
-                'capability' => 'ee_edit_registrations',
411
-                'args'       => ['not_approve', true],
412
-            ],
413
-            'cancel_registration'                 => [
414
-                'func'       => 'cancel_registration',
415
-                'noheader'   => true,
416
-                'capability' => 'ee_edit_registration',
417
-                'obj_id'     => $REG_ID,
418
-            ],
419
-            'cancel_and_notify_registration'      => [
420
-                'func'       => 'cancel_registration',
421
-                'noheader'   => true,
422
-                'args'       => [true],
423
-                'capability' => 'ee_edit_registration',
424
-                'obj_id'     => $REG_ID,
425
-            ],
426
-            'cancel_registrations'                => [
427
-                'func'       => 'bulk_action_on_registrations',
428
-                'noheader'   => true,
429
-                'capability' => 'ee_edit_registrations',
430
-                'args'       => ['cancel'],
431
-            ],
432
-            'cancel_and_notify_registrations'     => [
433
-                'func'       => 'bulk_action_on_registrations',
434
-                'noheader'   => true,
435
-                'capability' => 'ee_edit_registrations',
436
-                'args'       => ['cancel', true],
437
-            ],
438
-            'wait_list_registration'              => [
439
-                'func'       => 'wait_list_registration',
440
-                'noheader'   => true,
441
-                'capability' => 'ee_edit_registration',
442
-                'obj_id'     => $REG_ID,
443
-            ],
444
-            'wait_list_and_notify_registration'   => [
445
-                'func'       => 'wait_list_registration',
446
-                'noheader'   => true,
447
-                'args'       => [true],
448
-                'capability' => 'ee_edit_registration',
449
-                'obj_id'     => $REG_ID,
450
-            ],
451
-            'contact_list'                        => [
452
-                'func'       => '_attendee_contact_list_table',
453
-                'capability' => 'ee_read_contacts',
454
-            ],
455
-            'add_new_attendee'                    => [
456
-                'func' => '_create_new_cpt_item',
457
-                'args' => [
458
-                    'new_attendee' => true,
459
-                    'capability'   => 'ee_edit_contacts',
460
-                ],
461
-            ],
462
-            'edit_attendee'                       => [
463
-                'func'       => '_edit_cpt_item',
464
-                'capability' => 'ee_edit_contacts',
465
-                'obj_id'     => $ATT_ID,
466
-            ],
467
-            'duplicate_attendee'                  => [
468
-                'func'       => '_duplicate_attendee',
469
-                'noheader'   => true,
470
-                'capability' => 'ee_edit_contacts',
471
-                'obj_id'     => $ATT_ID,
472
-            ],
473
-            'insert_attendee'                     => [
474
-                'func'       => '_insert_or_update_attendee',
475
-                'args'       => [
476
-                    'new_attendee' => true,
477
-                ],
478
-                'noheader'   => true,
479
-                'capability' => 'ee_edit_contacts',
480
-            ],
481
-            'update_attendee'                     => [
482
-                'func'       => '_insert_or_update_attendee',
483
-                'args'       => [
484
-                    'new_attendee' => false,
485
-                ],
486
-                'noheader'   => true,
487
-                'capability' => 'ee_edit_contacts',
488
-                'obj_id'     => $ATT_ID,
489
-            ],
490
-            'trash_attendees'                     => [
491
-                'func'       => '_trash_or_restore_attendees',
492
-                'args'       => [
493
-                    'trash' => 'true',
494
-                ],
495
-                'noheader'   => true,
496
-                'capability' => 'ee_delete_contacts',
497
-            ],
498
-            'trash_attendee'                      => [
499
-                'func'       => '_trash_or_restore_attendees',
500
-                'args'       => [
501
-                    'trash' => true,
502
-                ],
503
-                'noheader'   => true,
504
-                'capability' => 'ee_delete_contacts',
505
-                'obj_id'     => $ATT_ID,
506
-            ],
507
-            'restore_attendees'                   => [
508
-                'func'       => '_trash_or_restore_attendees',
509
-                'args'       => [
510
-                    'trash' => false,
511
-                ],
512
-                'noheader'   => true,
513
-                'capability' => 'ee_delete_contacts',
514
-                'obj_id'     => $ATT_ID,
515
-            ],
516
-            'resend_registration'                 => [
517
-                'func'       => '_resend_registration',
518
-                'noheader'   => true,
519
-                'capability' => 'ee_send_message',
520
-            ],
521
-            'registrations_report'                => [
522
-                'func'       => '_registrations_report',
523
-                'noheader'   => true,
524
-                'capability' => 'ee_read_registrations',
525
-            ],
526
-            'contact_list_export'                 => [
527
-                'func'       => '_contact_list_export',
528
-                'noheader'   => true,
529
-                'capability' => 'export',
530
-            ],
531
-            'contact_list_report'                 => [
532
-                'func'       => '_contact_list_report',
533
-                'noheader'   => true,
534
-                'capability' => 'ee_read_contacts',
535
-            ],
536
-        ];
537
-    }
538
-
539
-
540
-    protected function _set_page_config()
541
-    {
542
-        $REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
543
-        $ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
544
-        $this->_page_config = [
545
-            'default'           => [
546
-                'nav'           => [
547
-                    'label' => esc_html__('Overview', 'event_espresso'),
548
-                    'order' => 5,
549
-                ],
550
-                'help_tabs'     => [
551
-                    'registrations_overview_help_tab'                       => [
552
-                        'title'    => esc_html__('Registrations Overview', 'event_espresso'),
553
-                        'filename' => 'registrations_overview',
554
-                    ],
555
-                    'registrations_overview_table_column_headings_help_tab' => [
556
-                        'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
557
-                        'filename' => 'registrations_overview_table_column_headings',
558
-                    ],
559
-                    'registrations_overview_filters_help_tab'               => [
560
-                        'title'    => esc_html__('Registration Filters', 'event_espresso'),
561
-                        'filename' => 'registrations_overview_filters',
562
-                    ],
563
-                    'registrations_overview_views_help_tab'                 => [
564
-                        'title'    => esc_html__('Registration Views', 'event_espresso'),
565
-                        'filename' => 'registrations_overview_views',
566
-                    ],
567
-                    'registrations_regoverview_other_help_tab'              => [
568
-                        'title'    => esc_html__('Registrations Other', 'event_espresso'),
569
-                        'filename' => 'registrations_overview_other',
570
-                    ],
571
-                ],
572
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
573
-                // 'help_tour'     => array('Registration_Overview_Help_Tour'),
574
-                'qtips'         => ['Registration_List_Table_Tips'],
575
-                'list_table'    => 'EE_Registrations_List_Table',
576
-                'require_nonce' => false,
577
-            ],
578
-            'view_registration' => [
579
-                'nav'           => [
580
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
581
-                    'order'      => 15,
582
-                    'url'        => $REG_ID
583
-                        ? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
584
-                        : $this->_admin_base_url,
585
-                    'persistent' => false,
586
-                ],
587
-                'help_tabs'     => [
588
-                    'registrations_details_help_tab'                    => [
589
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
590
-                        'filename' => 'registrations_details',
591
-                    ],
592
-                    'registrations_details_table_help_tab'              => [
593
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
594
-                        'filename' => 'registrations_details_table',
595
-                    ],
596
-                    'registrations_details_form_answers_help_tab'       => [
597
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
598
-                        'filename' => 'registrations_details_form_answers',
599
-                    ],
600
-                    'registrations_details_registrant_details_help_tab' => [
601
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
602
-                        'filename' => 'registrations_details_registrant_details',
603
-                    ],
604
-                ],
605
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
606
-                // 'help_tour'     => array('Registration_Details_Help_Tour'),
607
-                'metaboxes'     => array_merge(
608
-                    $this->_default_espresso_metaboxes,
609
-                    ['_registration_details_metaboxes']
610
-                ),
611
-                'require_nonce' => false,
612
-            ],
613
-            'new_registration'  => [
614
-                'nav'           => [
615
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
616
-                    'url'        => '#',
617
-                    'order'      => 15,
618
-                    'persistent' => false,
619
-                ],
620
-                'metaboxes'     => $this->_default_espresso_metaboxes,
621
-                'labels'        => [
622
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
623
-                ],
624
-                'require_nonce' => false,
625
-            ],
626
-            'add_new_attendee'  => [
627
-                'nav'           => [
628
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
629
-                    'order'      => 15,
630
-                    'persistent' => false,
631
-                ],
632
-                'metaboxes'     => array_merge(
633
-                    $this->_default_espresso_metaboxes,
634
-                    ['_publish_post_box', 'attendee_editor_metaboxes']
635
-                ),
636
-                'require_nonce' => false,
637
-            ],
638
-            'edit_attendee'     => [
639
-                'nav'           => [
640
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
641
-                    'order'      => 15,
642
-                    'persistent' => false,
643
-                    'url'        => $ATT_ID
644
-                        ? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
645
-                        : $this->_admin_base_url,
646
-                ],
647
-                'metaboxes'     => ['attendee_editor_metaboxes'],
648
-                'require_nonce' => false,
649
-            ],
650
-            'contact_list'      => [
651
-                'nav'           => [
652
-                    'label' => esc_html__('Contact List', 'event_espresso'),
653
-                    'order' => 20,
654
-                ],
655
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
656
-                'help_tabs'     => [
657
-                    'registrations_contact_list_help_tab'                       => [
658
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
659
-                        'filename' => 'registrations_contact_list',
660
-                    ],
661
-                    'registrations_contact-list_table_column_headings_help_tab' => [
662
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
663
-                        'filename' => 'registrations_contact_list_table_column_headings',
664
-                    ],
665
-                    'registrations_contact_list_views_help_tab'                 => [
666
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
667
-                        'filename' => 'registrations_contact_list_views',
668
-                    ],
669
-                    'registrations_contact_list_other_help_tab'                 => [
670
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
671
-                        'filename' => 'registrations_contact_list_other',
672
-                    ],
673
-                ],
674
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
675
-                // 'help_tour'     => array('Contact_List_Help_Tour'),
676
-                'metaboxes'     => [],
677
-                'require_nonce' => false,
678
-            ],
679
-            // override default cpt routes
680
-            'create_new'        => '',
681
-            'edit'              => '',
682
-        ];
683
-    }
684
-
685
-
686
-    /**
687
-     * The below methods aren't used by this class currently
688
-     */
689
-    protected function _add_screen_options()
690
-    {
691
-    }
692
-
693
-
694
-    protected function _add_feature_pointers()
695
-    {
696
-    }
697
-
698
-
699
-    public function admin_init()
700
-    {
701
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
702
-            'click "Update Registration Questions" to save your changes',
703
-            'event_espresso'
704
-        );
705
-    }
706
-
707
-
708
-    public function admin_notices()
709
-    {
710
-    }
711
-
712
-
713
-    public function admin_footer_scripts()
714
-    {
715
-    }
716
-
717
-
718
-    /**
719
-     * get list of registration statuses
720
-     *
721
-     * @return void
722
-     * @throws EE_Error
723
-     */
724
-    private function _get_registration_status_array()
725
-    {
726
-        self::$_reg_status = EEM_Registration::reg_status_array([], true);
727
-    }
728
-
729
-
730
-    /**
731
-     * @throws InvalidArgumentException
732
-     * @throws InvalidDataTypeException
733
-     * @throws InvalidInterfaceException
734
-     * @since 4.10.2.p
735
-     */
736
-    protected function _add_screen_options_default()
737
-    {
738
-        $this->_per_page_screen_option();
739
-    }
740
-
741
-
742
-    /**
743
-     * @throws InvalidArgumentException
744
-     * @throws InvalidDataTypeException
745
-     * @throws InvalidInterfaceException
746
-     * @since 4.10.2.p
747
-     */
748
-    protected function _add_screen_options_contact_list()
749
-    {
750
-        $page_title              = $this->_admin_page_title;
751
-        $this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
752
-        $this->_per_page_screen_option();
753
-        $this->_admin_page_title = $page_title;
754
-    }
755
-
756
-
757
-    public function load_scripts_styles()
758
-    {
759
-        // style
760
-        wp_register_style(
761
-            'espresso_reg',
762
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
763
-            ['ee-admin-css'],
764
-            EVENT_ESPRESSO_VERSION
765
-        );
766
-        wp_enqueue_style('espresso_reg');
767
-        // script
768
-        wp_register_script(
769
-            'espresso_reg',
770
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
771
-            ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
772
-            EVENT_ESPRESSO_VERSION,
773
-            true
774
-        );
775
-        wp_enqueue_script('espresso_reg');
776
-    }
777
-
778
-
779
-    /**
780
-     * @throws EE_Error
781
-     * @throws InvalidArgumentException
782
-     * @throws InvalidDataTypeException
783
-     * @throws InvalidInterfaceException
784
-     * @throws ReflectionException
785
-     * @since 4.10.2.p
786
-     */
787
-    public function load_scripts_styles_edit_attendee()
788
-    {
789
-        // stuff to only show up on our attendee edit details page.
790
-        $attendee_details_translations = [
791
-            'att_publish_text' => sprintf(
792
-            /* translators: The date and time */
793
-                wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
794
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
795
-            ),
796
-        ];
797
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
798
-        wp_enqueue_script('jquery-validate');
799
-    }
800
-
801
-
802
-    /**
803
-     * @throws EE_Error
804
-     * @throws InvalidArgumentException
805
-     * @throws InvalidDataTypeException
806
-     * @throws InvalidInterfaceException
807
-     * @throws ReflectionException
808
-     * @since 4.10.2.p
809
-     */
810
-    public function load_scripts_styles_view_registration()
811
-    {
812
-        // styles
813
-        wp_enqueue_style('espresso-ui-theme');
814
-        // scripts
815
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
816
-        $this->_reg_custom_questions_form->wp_enqueue_scripts();
817
-    }
818
-
819
-
820
-    public function load_scripts_styles_contact_list()
821
-    {
822
-        wp_dequeue_style('espresso_reg');
823
-        wp_register_style(
824
-            'espresso_att',
825
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
826
-            ['ee-admin-css'],
827
-            EVENT_ESPRESSO_VERSION
828
-        );
829
-        wp_enqueue_style('espresso_att');
830
-    }
831
-
832
-
833
-    public function load_scripts_styles_new_registration()
834
-    {
835
-        wp_register_script(
836
-            'ee-spco-for-admin',
837
-            REG_ASSETS_URL . 'spco_for_admin.js',
838
-            ['underscore', 'jquery'],
839
-            EVENT_ESPRESSO_VERSION,
840
-            true
841
-        );
842
-        wp_enqueue_script('ee-spco-for-admin');
843
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
844
-        EE_Form_Section_Proper::wp_enqueue_scripts();
845
-        EED_Ticket_Selector::load_tckt_slctr_assets();
846
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
847
-    }
848
-
849
-
850
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
851
-    {
852
-        add_filter('FHEE_load_EE_messages', '__return_true');
853
-    }
854
-
855
-
856
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
857
-    {
858
-        add_filter('FHEE_load_EE_messages', '__return_true');
859
-    }
860
-
861
-
862
-    /**
863
-     * @throws EE_Error
864
-     * @throws InvalidArgumentException
865
-     * @throws InvalidDataTypeException
866
-     * @throws InvalidInterfaceException
867
-     * @throws ReflectionException
868
-     * @since 4.10.2.p
869
-     */
870
-    protected function _set_list_table_views_default()
871
-    {
872
-        // for notification related bulk actions we need to make sure only active messengers have an option.
873
-        EED_Messages::set_autoloaders();
874
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
875
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
876
-        $active_mts               = $message_resource_manager->list_of_active_message_types();
877
-        // key= bulk_action_slug, value= message type.
878
-        $match_array = [
879
-            'approve_registrations'    => 'registration',
880
-            'decline_registrations'    => 'declined_registration',
881
-            'pending_registrations'    => 'pending_approval',
882
-            'no_approve_registrations' => 'not_approved_registration',
883
-            'cancel_registrations'     => 'cancelled_registration',
884
-        ];
885
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
886
-            'ee_send_message',
887
-            'batch_send_messages'
888
-        );
889
-        /** setup reg status bulk actions **/
890
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
891
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
892
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
893
-                'Approve and Notify Registrations',
894
-                'event_espresso'
895
-            );
896
-        }
897
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
898
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
899
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
900
-                'Decline and Notify Registrations',
901
-                'event_espresso'
902
-            );
903
-        }
904
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
905
-            'Set Registrations to Pending Payment',
906
-            'event_espresso'
907
-        );
908
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
909
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
910
-                'Set Registrations to Pending Payment and Notify',
911
-                'event_espresso'
912
-            );
913
-        }
914
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
915
-            'Set Registrations to Not Approved',
916
-            'event_espresso'
917
-        );
918
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
919
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
920
-                'Set Registrations to Not Approved and Notify',
921
-                'event_espresso'
922
-            );
923
-        }
924
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
925
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
926
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
927
-                'Cancel Registrations and Notify',
928
-                'event_espresso'
929
-            );
930
-        }
931
-        $def_reg_status_actions = apply_filters(
932
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
933
-            $def_reg_status_actions,
934
-            $active_mts,
935
-            $can_send
936
-        );
937
-
938
-        $this->_views = [
939
-            'all'   => [
940
-                'slug'        => 'all',
941
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
942
-                'count'       => 0,
943
-                'bulk_action' => array_merge(
944
-                    $def_reg_status_actions,
945
-                    [
946
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
947
-                    ]
948
-                ),
949
-            ],
950
-            'month' => [
951
-                'slug'        => 'month',
952
-                'label'       => esc_html__('This Month', 'event_espresso'),
953
-                'count'       => 0,
954
-                'bulk_action' => array_merge(
955
-                    $def_reg_status_actions,
956
-                    [
957
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
958
-                    ]
959
-                ),
960
-            ],
961
-            'today' => [
962
-                'slug'        => 'today',
963
-                'label'       => sprintf(
964
-                    esc_html__('Today - %s', 'event_espresso'),
965
-                    date('M d, Y', current_time('timestamp'))
966
-                ),
967
-                'count'       => 0,
968
-                'bulk_action' => array_merge(
969
-                    $def_reg_status_actions,
970
-                    [
971
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
972
-                    ]
973
-                ),
974
-            ],
975
-        ];
976
-        if (
977
-            EE_Registry::instance()->CAP->current_user_can(
978
-                'ee_delete_registrations',
979
-                'espresso_registrations_delete_registration'
980
-            )
981
-        ) {
982
-            $this->_views['incomplete'] = [
983
-                'slug'        => 'incomplete',
984
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
985
-                'count'       => 0,
986
-                'bulk_action' => [
987
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
988
-                ],
989
-            ];
990
-            $this->_views['trash']      = [
991
-                'slug'        => 'trash',
992
-                'label'       => esc_html__('Trash', 'event_espresso'),
993
-                'count'       => 0,
994
-                'bulk_action' => [
995
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
996
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
997
-                ],
998
-            ];
999
-        }
1000
-    }
1001
-
1002
-
1003
-    protected function _set_list_table_views_contact_list()
1004
-    {
1005
-        $this->_views = [
1006
-            'in_use' => [
1007
-                'slug'        => 'in_use',
1008
-                'label'       => esc_html__('In Use', 'event_espresso'),
1009
-                'count'       => 0,
1010
-                'bulk_action' => [
1011
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1012
-                ],
1013
-            ],
1014
-        ];
1015
-        if (
1016
-            EE_Registry::instance()->CAP->current_user_can(
1017
-                'ee_delete_contacts',
1018
-                'espresso_registrations_trash_attendees'
1019
-            )
1020
-        ) {
1021
-            $this->_views['trash'] = [
1022
-                'slug'        => 'trash',
1023
-                'label'       => esc_html__('Trash', 'event_espresso'),
1024
-                'count'       => 0,
1025
-                'bulk_action' => [
1026
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1027
-                ],
1028
-            ];
1029
-        }
1030
-    }
1031
-
1032
-
1033
-    /**
1034
-     * @return array
1035
-     * @throws EE_Error
1036
-     */
1037
-    protected function _registration_legend_items()
1038
-    {
1039
-        $fc_items = [
1040
-            'star-icon'        => [
1041
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1042
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1043
-            ],
1044
-            'view_details'     => [
1045
-                'class' => 'dashicons dashicons-clipboard',
1046
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1047
-            ],
1048
-            'edit_attendee'    => [
1049
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1050
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1051
-            ],
1052
-            'view_transaction' => [
1053
-                'class' => 'dashicons dashicons-cart',
1054
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1055
-            ],
1056
-            'view_invoice'     => [
1057
-                'class' => 'dashicons dashicons-media-spreadsheet',
1058
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1059
-            ],
1060
-        ];
1061
-        if (
1062
-            EE_Registry::instance()->CAP->current_user_can(
1063
-                'ee_send_message',
1064
-                'espresso_registrations_resend_registration'
1065
-            )
1066
-        ) {
1067
-            $fc_items['resend_registration'] = [
1068
-                'class' => 'dashicons dashicons-email-alt',
1069
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1070
-            ];
1071
-        } else {
1072
-            $fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1073
-        }
1074
-        if (
1075
-            EE_Registry::instance()->CAP->current_user_can(
1076
-                'ee_read_global_messages',
1077
-                'view_filtered_messages'
1078
-            )
1079
-        ) {
1080
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1081
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1082
-                $fc_items['view_related_messages'] = [
1083
-                    'class' => $related_for_icon['css_class'],
1084
-                    'desc'  => $related_for_icon['label'],
1085
-                ];
1086
-            }
1087
-        }
1088
-        $sc_items = [
1089
-            'approved_status'   => [
1090
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1091
-                'desc'  => EEH_Template::pretty_status(
1092
-                    EEM_Registration::status_id_approved,
1093
-                    false,
1094
-                    'sentence'
1095
-                ),
1096
-            ],
1097
-            'pending_status'    => [
1098
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1099
-                'desc'  => EEH_Template::pretty_status(
1100
-                    EEM_Registration::status_id_pending_payment,
1101
-                    false,
1102
-                    'sentence'
1103
-                ),
1104
-            ],
1105
-            'wait_list'         => [
1106
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1107
-                'desc'  => EEH_Template::pretty_status(
1108
-                    EEM_Registration::status_id_wait_list,
1109
-                    false,
1110
-                    'sentence'
1111
-                ),
1112
-            ],
1113
-            'incomplete_status' => [
1114
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1115
-                'desc'  => EEH_Template::pretty_status(
1116
-                    EEM_Registration::status_id_incomplete,
1117
-                    false,
1118
-                    'sentence'
1119
-                ),
1120
-            ],
1121
-            'not_approved'      => [
1122
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1123
-                'desc'  => EEH_Template::pretty_status(
1124
-                    EEM_Registration::status_id_not_approved,
1125
-                    false,
1126
-                    'sentence'
1127
-                ),
1128
-            ],
1129
-            'declined_status'   => [
1130
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1131
-                'desc'  => EEH_Template::pretty_status(
1132
-                    EEM_Registration::status_id_declined,
1133
-                    false,
1134
-                    'sentence'
1135
-                ),
1136
-            ],
1137
-            'cancelled_status'  => [
1138
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1139
-                'desc'  => EEH_Template::pretty_status(
1140
-                    EEM_Registration::status_id_cancelled,
1141
-                    false,
1142
-                    'sentence'
1143
-                ),
1144
-            ],
1145
-        ];
1146
-        return array_merge($fc_items, $sc_items);
1147
-    }
1148
-
1149
-
1150
-
1151
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1152
-
1153
-
1154
-    /**
1155
-     * @throws DomainException
1156
-     * @throws EE_Error
1157
-     * @throws InvalidArgumentException
1158
-     * @throws InvalidDataTypeException
1159
-     * @throws InvalidInterfaceException
1160
-     */
1161
-    protected function _registrations_overview_list_table()
1162
-    {
1163
-        $this->appendAddNewRegistrationButtonToPageTitle();
1164
-        $header_text                  = '';
1165
-        $admin_page_header_decorators = [
1166
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1167
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1168
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1169
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1170
-        ];
1171
-        foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1172
-            $filter_header_decorator = $this->getLoader()->getNew($admin_page_header_decorator);
1173
-            $header_text             = $filter_header_decorator->getHeaderText($header_text);
1174
-        }
1175
-        $this->_template_args['admin_page_header'] = $header_text;
1176
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1177
-        $this->display_admin_list_table_page_with_no_sidebar();
1178
-    }
1179
-
1180
-
1181
-    /**
1182
-     * @throws EE_Error
1183
-     * @throws InvalidArgumentException
1184
-     * @throws InvalidDataTypeException
1185
-     * @throws InvalidInterfaceException
1186
-     */
1187
-    private function appendAddNewRegistrationButtonToPageTitle()
1188
-    {
1189
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1190
-        if (
1191
-            $EVT_ID
1192
-            && EE_Registry::instance()->CAP->current_user_can(
1193
-                'ee_edit_registrations',
1194
-                'espresso_registrations_new_registration',
1195
-                $EVT_ID
1196
-            )
1197
-        ) {
1198
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1199
-                'new_registration',
1200
-                'add-registrant',
1201
-                ['event_id' => $EVT_ID],
1202
-                'add-new-h2'
1203
-            );
1204
-        }
1205
-    }
1206
-
1207
-
1208
-    /**
1209
-     * This sets the _registration property for the registration details screen
1210
-     *
1211
-     * @return void
1212
-     * @throws EE_Error
1213
-     * @throws InvalidArgumentException
1214
-     * @throws InvalidDataTypeException
1215
-     * @throws InvalidInterfaceException
1216
-     */
1217
-    private function _set_registration_object()
1218
-    {
1219
-        // get out if we've already set the object
1220
-        if ($this->_registration instanceof EE_Registration) {
1221
-            return;
1222
-        }
1223
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1224
-        if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1225
-            return;
1226
-        }
1227
-        $error_msg = sprintf(
1228
-            esc_html__(
1229
-                'An error occurred and the details for Registration ID #%s could not be retrieved.',
1230
-                'event_espresso'
1231
-            ),
1232
-            $REG_ID
1233
-        );
1234
-        EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1235
-        $this->_registration = null;
1236
-    }
1237
-
1238
-
1239
-    /**
1240
-     * Used to retrieve registrations for the list table.
1241
-     *
1242
-     * @param int  $per_page
1243
-     * @param bool $count
1244
-     * @param bool $this_month
1245
-     * @param bool $today
1246
-     * @return EE_Registration[]|int
1247
-     * @throws EE_Error
1248
-     * @throws InvalidArgumentException
1249
-     * @throws InvalidDataTypeException
1250
-     * @throws InvalidInterfaceException
1251
-     */
1252
-    public function get_registrations(
1253
-        $per_page = 10,
1254
-        $count = false,
1255
-        $this_month = false,
1256
-        $today = false
1257
-    ) {
1258
-        if ($this_month) {
1259
-            $this->request->setRequestParam('status', 'month');
1260
-        }
1261
-        if ($today) {
1262
-            $this->request->setRequestParam('status', 'today');
1263
-        }
1264
-        $query_params = $this->_get_registration_query_parameters($this->request->requestParams(), $per_page, $count);
1265
-        /**
1266
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1267
-         *
1268
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1269
-         * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1270
-         *                      or if you have the development copy of EE you can view this at the path:
1271
-         *                      /docs/G--Model-System/model-query-params.md
1272
-         */
1273
-        $query_params['group_by'] = '';
1274
-
1275
-        return $count
1276
-            ? $this->getRegistrationModel()->count($query_params)
1277
-            /** @type EE_Registration[] */
1278
-            : $this->getRegistrationModel()->get_all($query_params);
1279
-    }
1280
-
1281
-
1282
-    /**
1283
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1284
-     * Note: this listens to values on the request for some of the query parameters.
1285
-     *
1286
-     * @param array $request
1287
-     * @param int   $per_page
1288
-     * @param bool  $count
1289
-     * @return array
1290
-     * @throws EE_Error
1291
-     * @throws InvalidArgumentException
1292
-     * @throws InvalidDataTypeException
1293
-     * @throws InvalidInterfaceException
1294
-     */
1295
-    protected function _get_registration_query_parameters(
1296
-        $request = [],
1297
-        $per_page = 10,
1298
-        $count = false
1299
-    ) {
1300
-        /** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1301
-        $list_table_query_builder = $this->getLoader()->getNew(
1302
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1303
-            [null, null, $request]
1304
-        );
1305
-        return $list_table_query_builder->getQueryParams($per_page, $count);
1306
-    }
1307
-
1308
-
1309
-    public function get_registration_status_array()
1310
-    {
1311
-        return self::$_reg_status;
1312
-    }
1313
-
1314
-
1315
-
1316
-
1317
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1318
-    /**
1319
-     * generates HTML for the View Registration Details Admin page
1320
-     *
1321
-     * @return void
1322
-     * @throws DomainException
1323
-     * @throws EE_Error
1324
-     * @throws InvalidArgumentException
1325
-     * @throws InvalidDataTypeException
1326
-     * @throws InvalidInterfaceException
1327
-     * @throws EntityNotFoundException
1328
-     * @throws ReflectionException
1329
-     */
1330
-    protected function _registration_details()
1331
-    {
1332
-        $this->_template_args = [];
1333
-        $this->_set_registration_object();
1334
-        if (is_object($this->_registration)) {
1335
-            $transaction                                   = $this->_registration->transaction()
1336
-                ? $this->_registration->transaction()
1337
-                : EE_Transaction::new_instance();
1338
-            $this->_session                                = $transaction->session_data();
1339
-            $event_id                                      = $this->_registration->event_ID();
1340
-            $this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1341
-            $this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1342
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1343
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1344
-            $this->_template_args['grand_total']           = $transaction->total();
1345
-            $this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1346
-            // link back to overview
1347
-            $this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1348
-            $this->_template_args['registration']                = $this->_registration;
1349
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1350
-                [
1351
-                    'action'   => 'default',
1352
-                    'event_id' => $event_id,
1353
-                ],
1354
-                REG_ADMIN_URL
1355
-            );
1356
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1357
-                [
1358
-                    'action' => 'default',
1359
-                    'EVT_ID' => $event_id,
1360
-                    'page'   => 'espresso_transactions',
1361
-                ],
1362
-                admin_url('admin.php')
1363
-            );
1364
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1365
-                [
1366
-                    'page'   => 'espresso_events',
1367
-                    'action' => 'edit',
1368
-                    'post'   => $event_id,
1369
-                ],
1370
-                admin_url('admin.php')
1371
-            );
1372
-            // next and previous links
1373
-            $next_reg                                      = $this->_registration->next(
1374
-                null,
1375
-                [],
1376
-                'REG_ID'
1377
-            );
1378
-            $this->_template_args['next_registration']     = $next_reg
1379
-                ? $this->_next_link(
1380
-                    EE_Admin_Page::add_query_args_and_nonce(
1381
-                        [
1382
-                            'action'  => 'view_registration',
1383
-                            '_REG_ID' => $next_reg['REG_ID'],
1384
-                        ],
1385
-                        REG_ADMIN_URL
1386
-                    ),
1387
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1388
-                )
1389
-                : '';
1390
-            $previous_reg                                  = $this->_registration->previous(
1391
-                null,
1392
-                [],
1393
-                'REG_ID'
1394
-            );
1395
-            $this->_template_args['previous_registration'] = $previous_reg
1396
-                ? $this->_previous_link(
1397
-                    EE_Admin_Page::add_query_args_and_nonce(
1398
-                        [
1399
-                            'action'  => 'view_registration',
1400
-                            '_REG_ID' => $previous_reg['REG_ID'],
1401
-                        ],
1402
-                        REG_ADMIN_URL
1403
-                    ),
1404
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1405
-                )
1406
-                : '';
1407
-            // grab header
1408
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1409
-            $this->_template_args['REG_ID']            = $this->_registration->ID();
1410
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1411
-                $template_path,
1412
-                $this->_template_args,
1413
-                true
1414
-            );
1415
-        } else {
1416
-            $this->_template_args['admin_page_header'] = '';
1417
-            $this->_display_espresso_notices();
1418
-        }
1419
-        // the details template wrapper
1420
-        $this->display_admin_page_with_sidebar();
1421
-    }
1422
-
1423
-
1424
-    /**
1425
-     * @throws EE_Error
1426
-     * @throws InvalidArgumentException
1427
-     * @throws InvalidDataTypeException
1428
-     * @throws InvalidInterfaceException
1429
-     * @throws ReflectionException
1430
-     * @since 4.10.2.p
1431
-     */
1432
-    protected function _registration_details_metaboxes()
1433
-    {
1434
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1435
-        $this->_set_registration_object();
1436
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1437
-        add_meta_box(
1438
-            'edit-reg-status-mbox',
1439
-            esc_html__('Registration Status', 'event_espresso'),
1440
-            [$this, 'set_reg_status_buttons_metabox'],
1441
-            $this->_wp_page_slug,
1442
-            'normal',
1443
-            'high'
1444
-        );
1445
-        add_meta_box(
1446
-            'edit-reg-details-mbox',
1447
-            esc_html__('Registration Details', 'event_espresso'),
1448
-            [$this, '_reg_details_meta_box'],
1449
-            $this->_wp_page_slug,
1450
-            'normal',
1451
-            'high'
1452
-        );
1453
-        if (
1454
-            $attendee instanceof EE_Attendee
1455
-            && EE_Registry::instance()->CAP->current_user_can(
1456
-                'ee_read_registration',
1457
-                'edit-reg-questions-mbox',
1458
-                $this->_registration->ID()
1459
-            )
1460
-        ) {
1461
-            add_meta_box(
1462
-                'edit-reg-questions-mbox',
1463
-                esc_html__('Registration Form Answers', 'event_espresso'),
1464
-                [$this, '_reg_questions_meta_box'],
1465
-                $this->_wp_page_slug,
1466
-                'normal',
1467
-                'high'
1468
-            );
1469
-        }
1470
-        add_meta_box(
1471
-            'edit-reg-registrant-mbox',
1472
-            esc_html__('Contact Details', 'event_espresso'),
1473
-            [$this, '_reg_registrant_side_meta_box'],
1474
-            $this->_wp_page_slug,
1475
-            'side',
1476
-            'high'
1477
-        );
1478
-        if ($this->_registration->group_size() > 1) {
1479
-            add_meta_box(
1480
-                'edit-reg-attendees-mbox',
1481
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1482
-                [$this, '_reg_attendees_meta_box'],
1483
-                $this->_wp_page_slug,
1484
-                'normal',
1485
-                'high'
1486
-            );
1487
-        }
1488
-    }
1489
-
1490
-
1491
-    /**
1492
-     * set_reg_status_buttons_metabox
1493
-     *
1494
-     * @return void
1495
-     * @throws EE_Error
1496
-     * @throws EntityNotFoundException
1497
-     * @throws InvalidArgumentException
1498
-     * @throws InvalidDataTypeException
1499
-     * @throws InvalidInterfaceException
1500
-     * @throws ReflectionException
1501
-     */
1502
-    public function set_reg_status_buttons_metabox()
1503
-    {
1504
-        $this->_set_registration_object();
1505
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1506
-        $output                 = $change_reg_status_form->form_open(
1507
-            self::add_query_args_and_nonce(
1508
-                [
1509
-                    'action' => 'change_reg_status',
1510
-                ],
1511
-                REG_ADMIN_URL
1512
-            )
1513
-        );
1514
-        $output                 .= $change_reg_status_form->get_html();
1515
-        $output                 .= $change_reg_status_form->form_close();
1516
-        echo $output; // already escaped
1517
-    }
1518
-
1519
-
1520
-    /**
1521
-     * @return EE_Form_Section_Proper
1522
-     * @throws EE_Error
1523
-     * @throws InvalidArgumentException
1524
-     * @throws InvalidDataTypeException
1525
-     * @throws InvalidInterfaceException
1526
-     * @throws EntityNotFoundException
1527
-     * @throws ReflectionException
1528
-     */
1529
-    protected function _generate_reg_status_change_form()
1530
-    {
1531
-        $reg_status_change_form_array = [
1532
-            'name'            => 'reg_status_change_form',
1533
-            'html_id'         => 'reg-status-change-form',
1534
-            'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1535
-            'subsections'     => [
1536
-                'return'         => new EE_Hidden_Input(
1537
-                    [
1538
-                        'name'    => 'return',
1539
-                        'default' => 'view_registration',
1540
-                    ]
1541
-                ),
1542
-                'REG_ID'         => new EE_Hidden_Input(
1543
-                    [
1544
-                        'name'    => 'REG_ID',
1545
-                        'default' => $this->_registration->ID(),
1546
-                    ]
1547
-                ),
1548
-                'current_status' => new EE_Form_Section_HTML(
1549
-                    EEH_HTML::table(
1550
-                        EEH_HTML::tr(
1551
-                            EEH_HTML::th(
1552
-                                EEH_HTML::label(
1553
-                                    EEH_HTML::strong(
1554
-                                        esc_html__('Current Registration Status', 'event_espresso')
1555
-                                    )
1556
-                                )
1557
-                            )
1558
-                            . EEH_HTML::td(
1559
-                                EEH_HTML::strong(
1560
-                                    $this->_registration->pretty_status(),
1561
-                                    '',
1562
-                                    'status-' . $this->_registration->status_ID(),
1563
-                                    'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1564
-                                )
1565
-                            )
1566
-                        )
1567
-                    )
1568
-                ),
1569
-            ],
1570
-        ];
1571
-        if (
1572
-            EE_Registry::instance()->CAP->current_user_can(
1573
-                'ee_edit_registration',
1574
-                'toggle_registration_status',
1575
-                $this->_registration->ID()
1576
-            )
1577
-        ) {
1578
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1579
-                $this->_get_reg_statuses(),
1580
-                [
1581
-                    'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1582
-                    'default'         => $this->_registration->status_ID(),
1583
-                ]
1584
-            );
1585
-            $reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1586
-                [
1587
-                    'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1588
-                    'default'         => false,
1589
-                    'html_help_text'  => esc_html__(
1590
-                        'If set to "Yes", then the related messages will be sent to the registrant.',
1591
-                        'event_espresso'
1592
-                    ),
1593
-                ]
1594
-            );
1595
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1596
-                [
1597
-                    'html_class'      => 'button-primary',
1598
-                    'html_label_text' => '&nbsp;',
1599
-                    'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1600
-                ]
1601
-            );
1602
-        }
1603
-        return new EE_Form_Section_Proper($reg_status_change_form_array);
1604
-    }
1605
-
1606
-
1607
-    /**
1608
-     * Returns an array of all the buttons for the various statuses and switch status actions
1609
-     *
1610
-     * @return array
1611
-     * @throws EE_Error
1612
-     * @throws InvalidArgumentException
1613
-     * @throws InvalidDataTypeException
1614
-     * @throws InvalidInterfaceException
1615
-     * @throws EntityNotFoundException
1616
-     */
1617
-    protected function _get_reg_statuses()
1618
-    {
1619
-        $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1620
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1621
-        // get current reg status
1622
-        $current_status = $this->_registration->status_ID();
1623
-        // is registration for free event? This will determine whether to display the pending payment option
1624
-        if (
1625
-            $current_status !== EEM_Registration::status_id_pending_payment
1626
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1627
-        ) {
1628
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1629
-        }
1630
-        return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1631
-    }
1632
-
1633
-
1634
-    /**
1635
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1636
-     *
1637
-     * @param bool $status REG status given for changing registrations to.
1638
-     * @param bool $notify Whether to send messages notifications or not.
1639
-     * @return array (array with reg_id(s) updated and whether update was successful.
1640
-     * @throws DomainException
1641
-     * @throws EE_Error
1642
-     * @throws EntityNotFoundException
1643
-     * @throws InvalidArgumentException
1644
-     * @throws InvalidDataTypeException
1645
-     * @throws InvalidInterfaceException
1646
-     * @throws ReflectionException
1647
-     * @throws RuntimeException
1648
-     */
1649
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1650
-    {
1651
-        $REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1652
-            ? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1653
-            : $this->request->getRequestParam('_REG_ID', [], 'int', true);
1654
-
1655
-        // sanitize $REG_IDs
1656
-        $REG_IDs = array_map('absint', $REG_IDs);
1657
-        // and remove empty entries
1658
-        $REG_IDs = array_filter($REG_IDs);
1659
-
1660
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1661
-
1662
-        /**
1663
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1664
-         * Currently this value is used downstream by the _process_resend_registration method.
1665
-         *
1666
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1667
-         * @param bool                     $status           The status registrations were changed to.
1668
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1669
-         * @param Registrations_Admin_Page $admin_page_object
1670
-         */
1671
-        $REG_ID = apply_filters(
1672
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1673
-            $result['REG_ID'],
1674
-            $status,
1675
-            $result['success'],
1676
-            $this
1677
-        );
1678
-        $this->request->setRequestParam('_REG_ID', $REG_ID);
1679
-
1680
-        // notify?
1681
-        if (
1682
-            $notify
1683
-            && $result['success']
1684
-            && ! empty($REG_ID)
1685
-            && EE_Registry::instance()->CAP->current_user_can(
1686
-                'ee_send_message',
1687
-                'espresso_registrations_resend_registration'
1688
-            )
1689
-        ) {
1690
-            $this->_process_resend_registration();
1691
-        }
1692
-        return $result;
1693
-    }
1694
-
1695
-
1696
-    /**
1697
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1698
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1699
-     *
1700
-     * @param array  $REG_IDs
1701
-     * @param string $status
1702
-     * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1703
-     *                       slug sent with setting the registration status.
1704
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1705
-     * @throws EE_Error
1706
-     * @throws InvalidArgumentException
1707
-     * @throws InvalidDataTypeException
1708
-     * @throws InvalidInterfaceException
1709
-     * @throws ReflectionException
1710
-     * @throws RuntimeException
1711
-     * @throws EntityNotFoundException
1712
-     * @throws DomainException
1713
-     */
1714
-    protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1715
-    {
1716
-        $success = false;
1717
-        // typecast $REG_IDs
1718
-        $REG_IDs = (array) $REG_IDs;
1719
-        if (! empty($REG_IDs)) {
1720
-            $success = true;
1721
-            // set default status if none is passed
1722
-            $status         = $status ?: EEM_Registration::status_id_pending_payment;
1723
-            $status_context = $notify
1724
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1725
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1726
-            // loop through REG_ID's and change status
1727
-            foreach ($REG_IDs as $REG_ID) {
1728
-                $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1729
-                if ($registration instanceof EE_Registration) {
1730
-                    $registration->set_status(
1731
-                        $status,
1732
-                        false,
1733
-                        new Context(
1734
-                            $status_context,
1735
-                            esc_html__(
1736
-                                'Manually triggered status change on a Registration Admin Page route.',
1737
-                                'event_espresso'
1738
-                            )
1739
-                        )
1740
-                    );
1741
-                    $result = $registration->save();
1742
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1743
-                    $success = $result !== false ? $success : false;
1744
-                }
1745
-            }
1746
-        }
1747
-
1748
-        // return $success and processed registrations
1749
-        return ['REG_ID' => $REG_IDs, 'success' => $success];
1750
-    }
1751
-
1752
-
1753
-    /**
1754
-     * Common logic for setting up success message and redirecting to appropriate route
1755
-     *
1756
-     * @param string $STS_ID status id for the registration changed to
1757
-     * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1758
-     * @return void
1759
-     * @throws DomainException
1760
-     * @throws EE_Error
1761
-     * @throws EntityNotFoundException
1762
-     * @throws InvalidArgumentException
1763
-     * @throws InvalidDataTypeException
1764
-     * @throws InvalidInterfaceException
1765
-     * @throws ReflectionException
1766
-     * @throws RuntimeException
1767
-     */
1768
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1769
-    {
1770
-        $result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1771
-            : ['success' => false];
1772
-        $success = isset($result['success']) && $result['success'];
1773
-        // setup success message
1774
-        if ($success) {
1775
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1776
-                $msg = sprintf(
1777
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1778
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1779
-                );
1780
-            } else {
1781
-                $msg = sprintf(
1782
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
1783
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1784
-                );
1785
-            }
1786
-            EE_Error::add_success($msg);
1787
-        } else {
1788
-            EE_Error::add_error(
1789
-                esc_html__(
1790
-                    'Something went wrong, and the status was not changed',
1791
-                    'event_espresso'
1792
-                ),
1793
-                __FILE__,
1794
-                __LINE__,
1795
-                __FUNCTION__
1796
-            );
1797
-        }
1798
-        $return = $this->request->getRequestParam('return');
1799
-        $route  = $return === 'view_registration'
1800
-            ? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1801
-            : ['action' => 'default'];
1802
-        $route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1803
-        $this->_redirect_after_action($success, '', '', $route, true);
1804
-    }
1805
-
1806
-
1807
-    /**
1808
-     * incoming reg status change from reg details page.
1809
-     *
1810
-     * @return void
1811
-     * @throws EE_Error
1812
-     * @throws EntityNotFoundException
1813
-     * @throws InvalidArgumentException
1814
-     * @throws InvalidDataTypeException
1815
-     * @throws InvalidInterfaceException
1816
-     * @throws ReflectionException
1817
-     * @throws RuntimeException
1818
-     * @throws DomainException
1819
-     */
1820
-    protected function _change_reg_status()
1821
-    {
1822
-        $this->request->setRequestParam('return', 'view_registration');
1823
-        // set notify based on whether the send notifications toggle is set or not
1824
-        $notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1825
-        $reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1826
-        $this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1827
-        switch ($reg_status) {
1828
-            case EEM_Registration::status_id_approved:
1829
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1830
-                $this->approve_registration($notify);
1831
-                break;
1832
-            case EEM_Registration::status_id_pending_payment:
1833
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1834
-                $this->pending_registration($notify);
1835
-                break;
1836
-            case EEM_Registration::status_id_not_approved:
1837
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1838
-                $this->not_approve_registration($notify);
1839
-                break;
1840
-            case EEM_Registration::status_id_declined:
1841
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1842
-                $this->decline_registration($notify);
1843
-                break;
1844
-            case EEM_Registration::status_id_cancelled:
1845
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1846
-                $this->cancel_registration($notify);
1847
-                break;
1848
-            case EEM_Registration::status_id_wait_list:
1849
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1850
-                $this->wait_list_registration($notify);
1851
-                break;
1852
-            case EEM_Registration::status_id_incomplete:
1853
-            default:
1854
-                $this->request->unSetRequestParam('return');
1855
-                $this->_reg_status_change_return('');
1856
-                break;
1857
-        }
1858
-    }
1859
-
1860
-
1861
-    /**
1862
-     * Callback for bulk action routes.
1863
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1864
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
1865
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1866
-     * when an action is happening on just a single registration).
1867
-     *
1868
-     * @param      $action
1869
-     * @param bool $notify
1870
-     */
1871
-    protected function bulk_action_on_registrations($action, $notify = false)
1872
-    {
1873
-        do_action(
1874
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1875
-            $this,
1876
-            $action,
1877
-            $notify
1878
-        );
1879
-        $method = $action . '_registration';
1880
-        if (method_exists($this, $method)) {
1881
-            $this->$method($notify);
1882
-        }
1883
-    }
1884
-
1885
-
1886
-    /**
1887
-     * approve_registration
1888
-     *
1889
-     * @param bool $notify whether or not to notify the registrant about their approval.
1890
-     * @return void
1891
-     * @throws EE_Error
1892
-     * @throws EntityNotFoundException
1893
-     * @throws InvalidArgumentException
1894
-     * @throws InvalidDataTypeException
1895
-     * @throws InvalidInterfaceException
1896
-     * @throws ReflectionException
1897
-     * @throws RuntimeException
1898
-     * @throws DomainException
1899
-     */
1900
-    protected function approve_registration($notify = false)
1901
-    {
1902
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1903
-    }
1904
-
1905
-
1906
-    /**
1907
-     * decline_registration
1908
-     *
1909
-     * @param bool $notify whether or not to notify the registrant about their status change.
1910
-     * @return void
1911
-     * @throws EE_Error
1912
-     * @throws EntityNotFoundException
1913
-     * @throws InvalidArgumentException
1914
-     * @throws InvalidDataTypeException
1915
-     * @throws InvalidInterfaceException
1916
-     * @throws ReflectionException
1917
-     * @throws RuntimeException
1918
-     * @throws DomainException
1919
-     */
1920
-    protected function decline_registration($notify = false)
1921
-    {
1922
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1923
-    }
1924
-
1925
-
1926
-    /**
1927
-     * cancel_registration
1928
-     *
1929
-     * @param bool $notify whether or not to notify the registrant about their status change.
1930
-     * @return void
1931
-     * @throws EE_Error
1932
-     * @throws EntityNotFoundException
1933
-     * @throws InvalidArgumentException
1934
-     * @throws InvalidDataTypeException
1935
-     * @throws InvalidInterfaceException
1936
-     * @throws ReflectionException
1937
-     * @throws RuntimeException
1938
-     * @throws DomainException
1939
-     */
1940
-    protected function cancel_registration($notify = false)
1941
-    {
1942
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1943
-    }
1944
-
1945
-
1946
-    /**
1947
-     * not_approve_registration
1948
-     *
1949
-     * @param bool $notify whether or not to notify the registrant about their status change.
1950
-     * @return void
1951
-     * @throws EE_Error
1952
-     * @throws EntityNotFoundException
1953
-     * @throws InvalidArgumentException
1954
-     * @throws InvalidDataTypeException
1955
-     * @throws InvalidInterfaceException
1956
-     * @throws ReflectionException
1957
-     * @throws RuntimeException
1958
-     * @throws DomainException
1959
-     */
1960
-    protected function not_approve_registration($notify = false)
1961
-    {
1962
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1963
-    }
1964
-
1965
-
1966
-    /**
1967
-     * decline_registration
1968
-     *
1969
-     * @param bool $notify whether or not to notify the registrant about their status change.
1970
-     * @return void
1971
-     * @throws EE_Error
1972
-     * @throws EntityNotFoundException
1973
-     * @throws InvalidArgumentException
1974
-     * @throws InvalidDataTypeException
1975
-     * @throws InvalidInterfaceException
1976
-     * @throws ReflectionException
1977
-     * @throws RuntimeException
1978
-     * @throws DomainException
1979
-     */
1980
-    protected function pending_registration($notify = false)
1981
-    {
1982
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1983
-    }
1984
-
1985
-
1986
-    /**
1987
-     * waitlist_registration
1988
-     *
1989
-     * @param bool $notify whether or not to notify the registrant about their status change.
1990
-     * @return void
1991
-     * @throws EE_Error
1992
-     * @throws EntityNotFoundException
1993
-     * @throws InvalidArgumentException
1994
-     * @throws InvalidDataTypeException
1995
-     * @throws InvalidInterfaceException
1996
-     * @throws ReflectionException
1997
-     * @throws RuntimeException
1998
-     * @throws DomainException
1999
-     */
2000
-    protected function wait_list_registration($notify = false)
2001
-    {
2002
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2003
-    }
2004
-
2005
-
2006
-    /**
2007
-     * generates HTML for the Registration main meta box
2008
-     *
2009
-     * @return void
2010
-     * @throws DomainException
2011
-     * @throws EE_Error
2012
-     * @throws InvalidArgumentException
2013
-     * @throws InvalidDataTypeException
2014
-     * @throws InvalidInterfaceException
2015
-     * @throws ReflectionException
2016
-     * @throws EntityNotFoundException
2017
-     */
2018
-    public function _reg_details_meta_box()
2019
-    {
2020
-        EEH_Autoloader::register_line_item_display_autoloaders();
2021
-        EEH_Autoloader::register_line_item_filter_autoloaders();
2022
-        EE_Registry::instance()->load_helper('Line_Item');
2023
-        $transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
2024
-            : EE_Transaction::new_instance();
2025
-        $this->_session = $transaction->session_data();
2026
-        $filters        = new EE_Line_Item_Filter_Collection();
2027
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2028
-        $filters->add(new EE_Non_Zero_Line_Item_Filter());
2029
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2030
-            $filters,
2031
-            $transaction->total_line_item()
2032
-        );
2033
-        $filtered_line_item_tree                 = $line_item_filter_processor->process();
2034
-        $line_item_display                       = new EE_Line_Item_Display(
2035
-            'reg_admin_table',
2036
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2037
-        );
2038
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2039
-            $filtered_line_item_tree,
2040
-            ['EE_Registration' => $this->_registration]
2041
-        );
2042
-        $attendee                                = $this->_registration->attendee();
2043
-        if (
2044
-            EE_Registry::instance()->CAP->current_user_can(
2045
-                'ee_read_transaction',
2046
-                'espresso_transactions_view_transaction'
2047
-            )
2048
-        ) {
2049
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2050
-                EE_Admin_Page::add_query_args_and_nonce(
2051
-                    [
2052
-                        'action' => 'view_transaction',
2053
-                        'TXN_ID' => $transaction->ID(),
2054
-                    ],
2055
-                    TXN_ADMIN_URL
2056
-                ),
2057
-                esc_html__(' View Transaction', 'event_espresso'),
2058
-                'button secondary-button right',
2059
-                'dashicons dashicons-cart'
2060
-            );
2061
-        } else {
2062
-            $this->_template_args['view_transaction_button'] = '';
2063
-        }
2064
-        if (
2065
-            $attendee instanceof EE_Attendee
2066
-            && EE_Registry::instance()->CAP->current_user_can(
2067
-                'ee_send_message',
2068
-                'espresso_registrations_resend_registration'
2069
-            )
2070
-        ) {
2071
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2072
-                EE_Admin_Page::add_query_args_and_nonce(
2073
-                    [
2074
-                        'action'      => 'resend_registration',
2075
-                        '_REG_ID'     => $this->_registration->ID(),
2076
-                        'redirect_to' => 'view_registration',
2077
-                    ],
2078
-                    REG_ADMIN_URL
2079
-                ),
2080
-                esc_html__(' Resend Registration', 'event_espresso'),
2081
-                'button secondary-button right',
2082
-                'dashicons dashicons-email-alt'
2083
-            );
2084
-        } else {
2085
-            $this->_template_args['resend_registration_button'] = '';
2086
-        }
2087
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2088
-        $payment                               = $transaction->get_first_related('Payment');
2089
-        $payment                               = ! $payment instanceof EE_Payment
2090
-            ? EE_Payment::new_instance()
2091
-            : $payment;
2092
-        $payment_method                        = $payment->get_first_related('Payment_Method');
2093
-        $payment_method                        = ! $payment_method instanceof EE_Payment_Method
2094
-            ? EE_Payment_Method::new_instance()
2095
-            : $payment_method;
2096
-        $reg_details                           = [
2097
-            'payment_method'       => $payment_method->name(),
2098
-            'response_msg'         => $payment->gateway_response(),
2099
-            'registration_id'      => $this->_registration->get('REG_code'),
2100
-            'registration_session' => $this->_registration->session_ID(),
2101
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2102
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2103
-        ];
2104
-        if (isset($reg_details['registration_id'])) {
2105
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2106
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2107
-                'Registration ID',
2108
-                'event_espresso'
2109
-            );
2110
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2111
-        }
2112
-        if (isset($reg_details['payment_method'])) {
2113
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2114
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2115
-                'Most Recent Payment Method',
2116
-                'event_espresso'
2117
-            );
2118
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2119
-            $this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2120
-            $this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2121
-                'Payment method response',
2122
-                'event_espresso'
2123
-            );
2124
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2125
-        }
2126
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2127
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2128
-            'Registration Session',
2129
-            'event_espresso'
2130
-        );
2131
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2132
-        $this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2133
-        $this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2134
-            'Registration placed from IP',
2135
-            'event_espresso'
2136
-        );
2137
-        $this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2138
-        $this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2139
-        $this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2140
-            'Registrant User Agent',
2141
-            'event_espresso'
2142
-        );
2143
-        $this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2144
-        $this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2145
-            [
2146
-                'action'   => 'default',
2147
-                'event_id' => $this->_registration->event_ID(),
2148
-            ],
2149
-            REG_ADMIN_URL
2150
-        );
2151
-        $this->_template_args['REG_ID']                                       = $this->_registration->ID();
2152
-        $this->_template_args['event_id']                                     = $this->_registration->event_ID();
2153
-        $template_path                                                        =
2154
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2155
-        EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2156
-    }
2157
-
2158
-
2159
-    /**
2160
-     * generates HTML for the Registration Questions meta box.
2161
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2162
-     * otherwise uses new forms system
2163
-     *
2164
-     * @return void
2165
-     * @throws DomainException
2166
-     * @throws EE_Error
2167
-     * @throws InvalidArgumentException
2168
-     * @throws InvalidDataTypeException
2169
-     * @throws InvalidInterfaceException
2170
-     * @throws ReflectionException
2171
-     */
2172
-    public function _reg_questions_meta_box()
2173
-    {
2174
-        // allow someone to override this method entirely
2175
-        if (
2176
-            apply_filters(
2177
-                'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2178
-                true,
2179
-                $this,
2180
-                $this->_registration
2181
-            )
2182
-        ) {
2183
-            $form                                              = $this->_get_reg_custom_questions_form(
2184
-                $this->_registration->ID()
2185
-            );
2186
-            $this->_template_args['att_questions']             = count($form->subforms()) > 0
2187
-                ? $form->get_html_and_js()
2188
-                : '';
2189
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2190
-            $this->_template_args['REG_ID']                    = $this->_registration->ID();
2191
-            $template_path                                     =
2192
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2193
-            EEH_Template::display_template($template_path, $this->_template_args);
2194
-        }
2195
-    }
2196
-
2197
-
2198
-    /**
2199
-     * form_before_question_group
2200
-     *
2201
-     * @param string $output
2202
-     * @return        string
2203
-     * @deprecated    as of 4.8.32.rc.000
2204
-     */
2205
-    public function form_before_question_group($output)
2206
-    {
2207
-        EE_Error::doing_it_wrong(
2208
-            __CLASS__ . '::' . __FUNCTION__,
2209
-            esc_html__(
2210
-                '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.',
2211
-                'event_espresso'
2212
-            ),
2213
-            '4.8.32.rc.000'
2214
-        );
2215
-        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 = null;
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->getLoader()->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->getLoader()->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->getLoader()->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->getLoader()->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_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
230
+				'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
231
+				'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
232
+				'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
233
+			],
234
+			'publishbox'                   => [
235
+				'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
236
+				'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
237
+			],
238
+			'hide_add_button_on_cpt_route' => [
239
+				'edit_attendee' => true,
240
+			],
241
+		];
242
+	}
243
+
244
+
245
+	/**
246
+	 * grab url requests and route them
247
+	 *
248
+	 * @return void
249
+	 * @throws EE_Error
250
+	 */
251
+	public function _set_page_routes()
252
+	{
253
+		$this->_get_registration_status_array();
254
+		$REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
255
+		$REG_ID             = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
256
+		$ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
257
+		$ATT_ID             = $this->request->getRequestParam('post', $ATT_ID, 'int');
258
+		$this->_page_routes = [
259
+			'default'                             => [
260
+				'func'       => '_registrations_overview_list_table',
261
+				'capability' => 'ee_read_registrations',
262
+			],
263
+			'view_registration'                   => [
264
+				'func'       => '_registration_details',
265
+				'capability' => 'ee_read_registration',
266
+				'obj_id'     => $REG_ID,
267
+			],
268
+			'edit_registration'                   => [
269
+				'func'               => '_update_attendee_registration_form',
270
+				'noheader'           => true,
271
+				'headers_sent_route' => 'view_registration',
272
+				'capability'         => 'ee_edit_registration',
273
+				'obj_id'             => $REG_ID,
274
+				'_REG_ID'            => $REG_ID,
275
+			],
276
+			'trash_registrations'                 => [
277
+				'func'       => '_trash_or_restore_registrations',
278
+				'args'       => ['trash' => true],
279
+				'noheader'   => true,
280
+				'capability' => 'ee_delete_registrations',
281
+			],
282
+			'restore_registrations'               => [
283
+				'func'       => '_trash_or_restore_registrations',
284
+				'args'       => ['trash' => false],
285
+				'noheader'   => true,
286
+				'capability' => 'ee_delete_registrations',
287
+			],
288
+			'delete_registrations'                => [
289
+				'func'       => '_delete_registrations',
290
+				'noheader'   => true,
291
+				'capability' => 'ee_delete_registrations',
292
+			],
293
+			'new_registration'                    => [
294
+				'func'       => 'new_registration',
295
+				'capability' => 'ee_edit_registrations',
296
+			],
297
+			'process_reg_step'                    => [
298
+				'func'       => 'process_reg_step',
299
+				'noheader'   => true,
300
+				'capability' => 'ee_edit_registrations',
301
+			],
302
+			'redirect_to_txn'                     => [
303
+				'func'       => 'redirect_to_txn',
304
+				'noheader'   => true,
305
+				'capability' => 'ee_edit_registrations',
306
+			],
307
+			'change_reg_status'                   => [
308
+				'func'       => '_change_reg_status',
309
+				'noheader'   => true,
310
+				'capability' => 'ee_edit_registration',
311
+				'obj_id'     => $REG_ID,
312
+			],
313
+			'approve_registration'                => [
314
+				'func'       => 'approve_registration',
315
+				'noheader'   => true,
316
+				'capability' => 'ee_edit_registration',
317
+				'obj_id'     => $REG_ID,
318
+			],
319
+			'approve_and_notify_registration'     => [
320
+				'func'       => 'approve_registration',
321
+				'noheader'   => true,
322
+				'args'       => [true],
323
+				'capability' => 'ee_edit_registration',
324
+				'obj_id'     => $REG_ID,
325
+			],
326
+			'approve_registrations'               => [
327
+				'func'       => 'bulk_action_on_registrations',
328
+				'noheader'   => true,
329
+				'capability' => 'ee_edit_registrations',
330
+				'args'       => ['approve'],
331
+			],
332
+			'approve_and_notify_registrations'    => [
333
+				'func'       => 'bulk_action_on_registrations',
334
+				'noheader'   => true,
335
+				'capability' => 'ee_edit_registrations',
336
+				'args'       => ['approve', true],
337
+			],
338
+			'decline_registration'                => [
339
+				'func'       => 'decline_registration',
340
+				'noheader'   => true,
341
+				'capability' => 'ee_edit_registration',
342
+				'obj_id'     => $REG_ID,
343
+			],
344
+			'decline_and_notify_registration'     => [
345
+				'func'       => 'decline_registration',
346
+				'noheader'   => true,
347
+				'args'       => [true],
348
+				'capability' => 'ee_edit_registration',
349
+				'obj_id'     => $REG_ID,
350
+			],
351
+			'decline_registrations'               => [
352
+				'func'       => 'bulk_action_on_registrations',
353
+				'noheader'   => true,
354
+				'capability' => 'ee_edit_registrations',
355
+				'args'       => ['decline'],
356
+			],
357
+			'decline_and_notify_registrations'    => [
358
+				'func'       => 'bulk_action_on_registrations',
359
+				'noheader'   => true,
360
+				'capability' => 'ee_edit_registrations',
361
+				'args'       => ['decline', true],
362
+			],
363
+			'pending_registration'                => [
364
+				'func'       => 'pending_registration',
365
+				'noheader'   => true,
366
+				'capability' => 'ee_edit_registration',
367
+				'obj_id'     => $REG_ID,
368
+			],
369
+			'pending_and_notify_registration'     => [
370
+				'func'       => 'pending_registration',
371
+				'noheader'   => true,
372
+				'args'       => [true],
373
+				'capability' => 'ee_edit_registration',
374
+				'obj_id'     => $REG_ID,
375
+			],
376
+			'pending_registrations'               => [
377
+				'func'       => 'bulk_action_on_registrations',
378
+				'noheader'   => true,
379
+				'capability' => 'ee_edit_registrations',
380
+				'args'       => ['pending'],
381
+			],
382
+			'pending_and_notify_registrations'    => [
383
+				'func'       => 'bulk_action_on_registrations',
384
+				'noheader'   => true,
385
+				'capability' => 'ee_edit_registrations',
386
+				'args'       => ['pending', true],
387
+			],
388
+			'no_approve_registration'             => [
389
+				'func'       => 'not_approve_registration',
390
+				'noheader'   => true,
391
+				'capability' => 'ee_edit_registration',
392
+				'obj_id'     => $REG_ID,
393
+			],
394
+			'no_approve_and_notify_registration'  => [
395
+				'func'       => 'not_approve_registration',
396
+				'noheader'   => true,
397
+				'args'       => [true],
398
+				'capability' => 'ee_edit_registration',
399
+				'obj_id'     => $REG_ID,
400
+			],
401
+			'no_approve_registrations'            => [
402
+				'func'       => 'bulk_action_on_registrations',
403
+				'noheader'   => true,
404
+				'capability' => 'ee_edit_registrations',
405
+				'args'       => ['not_approve'],
406
+			],
407
+			'no_approve_and_notify_registrations' => [
408
+				'func'       => 'bulk_action_on_registrations',
409
+				'noheader'   => true,
410
+				'capability' => 'ee_edit_registrations',
411
+				'args'       => ['not_approve', true],
412
+			],
413
+			'cancel_registration'                 => [
414
+				'func'       => 'cancel_registration',
415
+				'noheader'   => true,
416
+				'capability' => 'ee_edit_registration',
417
+				'obj_id'     => $REG_ID,
418
+			],
419
+			'cancel_and_notify_registration'      => [
420
+				'func'       => 'cancel_registration',
421
+				'noheader'   => true,
422
+				'args'       => [true],
423
+				'capability' => 'ee_edit_registration',
424
+				'obj_id'     => $REG_ID,
425
+			],
426
+			'cancel_registrations'                => [
427
+				'func'       => 'bulk_action_on_registrations',
428
+				'noheader'   => true,
429
+				'capability' => 'ee_edit_registrations',
430
+				'args'       => ['cancel'],
431
+			],
432
+			'cancel_and_notify_registrations'     => [
433
+				'func'       => 'bulk_action_on_registrations',
434
+				'noheader'   => true,
435
+				'capability' => 'ee_edit_registrations',
436
+				'args'       => ['cancel', true],
437
+			],
438
+			'wait_list_registration'              => [
439
+				'func'       => 'wait_list_registration',
440
+				'noheader'   => true,
441
+				'capability' => 'ee_edit_registration',
442
+				'obj_id'     => $REG_ID,
443
+			],
444
+			'wait_list_and_notify_registration'   => [
445
+				'func'       => 'wait_list_registration',
446
+				'noheader'   => true,
447
+				'args'       => [true],
448
+				'capability' => 'ee_edit_registration',
449
+				'obj_id'     => $REG_ID,
450
+			],
451
+			'contact_list'                        => [
452
+				'func'       => '_attendee_contact_list_table',
453
+				'capability' => 'ee_read_contacts',
454
+			],
455
+			'add_new_attendee'                    => [
456
+				'func' => '_create_new_cpt_item',
457
+				'args' => [
458
+					'new_attendee' => true,
459
+					'capability'   => 'ee_edit_contacts',
460
+				],
461
+			],
462
+			'edit_attendee'                       => [
463
+				'func'       => '_edit_cpt_item',
464
+				'capability' => 'ee_edit_contacts',
465
+				'obj_id'     => $ATT_ID,
466
+			],
467
+			'duplicate_attendee'                  => [
468
+				'func'       => '_duplicate_attendee',
469
+				'noheader'   => true,
470
+				'capability' => 'ee_edit_contacts',
471
+				'obj_id'     => $ATT_ID,
472
+			],
473
+			'insert_attendee'                     => [
474
+				'func'       => '_insert_or_update_attendee',
475
+				'args'       => [
476
+					'new_attendee' => true,
477
+				],
478
+				'noheader'   => true,
479
+				'capability' => 'ee_edit_contacts',
480
+			],
481
+			'update_attendee'                     => [
482
+				'func'       => '_insert_or_update_attendee',
483
+				'args'       => [
484
+					'new_attendee' => false,
485
+				],
486
+				'noheader'   => true,
487
+				'capability' => 'ee_edit_contacts',
488
+				'obj_id'     => $ATT_ID,
489
+			],
490
+			'trash_attendees'                     => [
491
+				'func'       => '_trash_or_restore_attendees',
492
+				'args'       => [
493
+					'trash' => 'true',
494
+				],
495
+				'noheader'   => true,
496
+				'capability' => 'ee_delete_contacts',
497
+			],
498
+			'trash_attendee'                      => [
499
+				'func'       => '_trash_or_restore_attendees',
500
+				'args'       => [
501
+					'trash' => true,
502
+				],
503
+				'noheader'   => true,
504
+				'capability' => 'ee_delete_contacts',
505
+				'obj_id'     => $ATT_ID,
506
+			],
507
+			'restore_attendees'                   => [
508
+				'func'       => '_trash_or_restore_attendees',
509
+				'args'       => [
510
+					'trash' => false,
511
+				],
512
+				'noheader'   => true,
513
+				'capability' => 'ee_delete_contacts',
514
+				'obj_id'     => $ATT_ID,
515
+			],
516
+			'resend_registration'                 => [
517
+				'func'       => '_resend_registration',
518
+				'noheader'   => true,
519
+				'capability' => 'ee_send_message',
520
+			],
521
+			'registrations_report'                => [
522
+				'func'       => '_registrations_report',
523
+				'noheader'   => true,
524
+				'capability' => 'ee_read_registrations',
525
+			],
526
+			'contact_list_export'                 => [
527
+				'func'       => '_contact_list_export',
528
+				'noheader'   => true,
529
+				'capability' => 'export',
530
+			],
531
+			'contact_list_report'                 => [
532
+				'func'       => '_contact_list_report',
533
+				'noheader'   => true,
534
+				'capability' => 'ee_read_contacts',
535
+			],
536
+		];
537
+	}
538
+
539
+
540
+	protected function _set_page_config()
541
+	{
542
+		$REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
543
+		$ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
544
+		$this->_page_config = [
545
+			'default'           => [
546
+				'nav'           => [
547
+					'label' => esc_html__('Overview', 'event_espresso'),
548
+					'order' => 5,
549
+				],
550
+				'help_tabs'     => [
551
+					'registrations_overview_help_tab'                       => [
552
+						'title'    => esc_html__('Registrations Overview', 'event_espresso'),
553
+						'filename' => 'registrations_overview',
554
+					],
555
+					'registrations_overview_table_column_headings_help_tab' => [
556
+						'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
557
+						'filename' => 'registrations_overview_table_column_headings',
558
+					],
559
+					'registrations_overview_filters_help_tab'               => [
560
+						'title'    => esc_html__('Registration Filters', 'event_espresso'),
561
+						'filename' => 'registrations_overview_filters',
562
+					],
563
+					'registrations_overview_views_help_tab'                 => [
564
+						'title'    => esc_html__('Registration Views', 'event_espresso'),
565
+						'filename' => 'registrations_overview_views',
566
+					],
567
+					'registrations_regoverview_other_help_tab'              => [
568
+						'title'    => esc_html__('Registrations Other', 'event_espresso'),
569
+						'filename' => 'registrations_overview_other',
570
+					],
571
+				],
572
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
573
+				// 'help_tour'     => array('Registration_Overview_Help_Tour'),
574
+				'qtips'         => ['Registration_List_Table_Tips'],
575
+				'list_table'    => 'EE_Registrations_List_Table',
576
+				'require_nonce' => false,
577
+			],
578
+			'view_registration' => [
579
+				'nav'           => [
580
+					'label'      => esc_html__('REG Details', 'event_espresso'),
581
+					'order'      => 15,
582
+					'url'        => $REG_ID
583
+						? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
584
+						: $this->_admin_base_url,
585
+					'persistent' => false,
586
+				],
587
+				'help_tabs'     => [
588
+					'registrations_details_help_tab'                    => [
589
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
590
+						'filename' => 'registrations_details',
591
+					],
592
+					'registrations_details_table_help_tab'              => [
593
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
594
+						'filename' => 'registrations_details_table',
595
+					],
596
+					'registrations_details_form_answers_help_tab'       => [
597
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
598
+						'filename' => 'registrations_details_form_answers',
599
+					],
600
+					'registrations_details_registrant_details_help_tab' => [
601
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
602
+						'filename' => 'registrations_details_registrant_details',
603
+					],
604
+				],
605
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
606
+				// 'help_tour'     => array('Registration_Details_Help_Tour'),
607
+				'metaboxes'     => array_merge(
608
+					$this->_default_espresso_metaboxes,
609
+					['_registration_details_metaboxes']
610
+				),
611
+				'require_nonce' => false,
612
+			],
613
+			'new_registration'  => [
614
+				'nav'           => [
615
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
616
+					'url'        => '#',
617
+					'order'      => 15,
618
+					'persistent' => false,
619
+				],
620
+				'metaboxes'     => $this->_default_espresso_metaboxes,
621
+				'labels'        => [
622
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
623
+				],
624
+				'require_nonce' => false,
625
+			],
626
+			'add_new_attendee'  => [
627
+				'nav'           => [
628
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
629
+					'order'      => 15,
630
+					'persistent' => false,
631
+				],
632
+				'metaboxes'     => array_merge(
633
+					$this->_default_espresso_metaboxes,
634
+					['_publish_post_box', 'attendee_editor_metaboxes']
635
+				),
636
+				'require_nonce' => false,
637
+			],
638
+			'edit_attendee'     => [
639
+				'nav'           => [
640
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
641
+					'order'      => 15,
642
+					'persistent' => false,
643
+					'url'        => $ATT_ID
644
+						? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
645
+						: $this->_admin_base_url,
646
+				],
647
+				'metaboxes'     => ['attendee_editor_metaboxes'],
648
+				'require_nonce' => false,
649
+			],
650
+			'contact_list'      => [
651
+				'nav'           => [
652
+					'label' => esc_html__('Contact List', 'event_espresso'),
653
+					'order' => 20,
654
+				],
655
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
656
+				'help_tabs'     => [
657
+					'registrations_contact_list_help_tab'                       => [
658
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
659
+						'filename' => 'registrations_contact_list',
660
+					],
661
+					'registrations_contact-list_table_column_headings_help_tab' => [
662
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
663
+						'filename' => 'registrations_contact_list_table_column_headings',
664
+					],
665
+					'registrations_contact_list_views_help_tab'                 => [
666
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
667
+						'filename' => 'registrations_contact_list_views',
668
+					],
669
+					'registrations_contact_list_other_help_tab'                 => [
670
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
671
+						'filename' => 'registrations_contact_list_other',
672
+					],
673
+				],
674
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
675
+				// 'help_tour'     => array('Contact_List_Help_Tour'),
676
+				'metaboxes'     => [],
677
+				'require_nonce' => false,
678
+			],
679
+			// override default cpt routes
680
+			'create_new'        => '',
681
+			'edit'              => '',
682
+		];
683
+	}
684
+
685
+
686
+	/**
687
+	 * The below methods aren't used by this class currently
688
+	 */
689
+	protected function _add_screen_options()
690
+	{
691
+	}
692
+
693
+
694
+	protected function _add_feature_pointers()
695
+	{
696
+	}
697
+
698
+
699
+	public function admin_init()
700
+	{
701
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
702
+			'click "Update Registration Questions" to save your changes',
703
+			'event_espresso'
704
+		);
705
+	}
706
+
707
+
708
+	public function admin_notices()
709
+	{
710
+	}
711
+
712
+
713
+	public function admin_footer_scripts()
714
+	{
715
+	}
716
+
717
+
718
+	/**
719
+	 * get list of registration statuses
720
+	 *
721
+	 * @return void
722
+	 * @throws EE_Error
723
+	 */
724
+	private function _get_registration_status_array()
725
+	{
726
+		self::$_reg_status = EEM_Registration::reg_status_array([], true);
727
+	}
728
+
729
+
730
+	/**
731
+	 * @throws InvalidArgumentException
732
+	 * @throws InvalidDataTypeException
733
+	 * @throws InvalidInterfaceException
734
+	 * @since 4.10.2.p
735
+	 */
736
+	protected function _add_screen_options_default()
737
+	{
738
+		$this->_per_page_screen_option();
739
+	}
740
+
741
+
742
+	/**
743
+	 * @throws InvalidArgumentException
744
+	 * @throws InvalidDataTypeException
745
+	 * @throws InvalidInterfaceException
746
+	 * @since 4.10.2.p
747
+	 */
748
+	protected function _add_screen_options_contact_list()
749
+	{
750
+		$page_title              = $this->_admin_page_title;
751
+		$this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
752
+		$this->_per_page_screen_option();
753
+		$this->_admin_page_title = $page_title;
754
+	}
755
+
756
+
757
+	public function load_scripts_styles()
758
+	{
759
+		// style
760
+		wp_register_style(
761
+			'espresso_reg',
762
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
763
+			['ee-admin-css'],
764
+			EVENT_ESPRESSO_VERSION
765
+		);
766
+		wp_enqueue_style('espresso_reg');
767
+		// script
768
+		wp_register_script(
769
+			'espresso_reg',
770
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
771
+			['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
772
+			EVENT_ESPRESSO_VERSION,
773
+			true
774
+		);
775
+		wp_enqueue_script('espresso_reg');
776
+	}
777
+
778
+
779
+	/**
780
+	 * @throws EE_Error
781
+	 * @throws InvalidArgumentException
782
+	 * @throws InvalidDataTypeException
783
+	 * @throws InvalidInterfaceException
784
+	 * @throws ReflectionException
785
+	 * @since 4.10.2.p
786
+	 */
787
+	public function load_scripts_styles_edit_attendee()
788
+	{
789
+		// stuff to only show up on our attendee edit details page.
790
+		$attendee_details_translations = [
791
+			'att_publish_text' => sprintf(
792
+			/* translators: The date and time */
793
+				wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
794
+				'<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
795
+			),
796
+		];
797
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
798
+		wp_enqueue_script('jquery-validate');
799
+	}
800
+
801
+
802
+	/**
803
+	 * @throws EE_Error
804
+	 * @throws InvalidArgumentException
805
+	 * @throws InvalidDataTypeException
806
+	 * @throws InvalidInterfaceException
807
+	 * @throws ReflectionException
808
+	 * @since 4.10.2.p
809
+	 */
810
+	public function load_scripts_styles_view_registration()
811
+	{
812
+		// styles
813
+		wp_enqueue_style('espresso-ui-theme');
814
+		// scripts
815
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
816
+		$this->_reg_custom_questions_form->wp_enqueue_scripts();
817
+	}
818
+
819
+
820
+	public function load_scripts_styles_contact_list()
821
+	{
822
+		wp_dequeue_style('espresso_reg');
823
+		wp_register_style(
824
+			'espresso_att',
825
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
826
+			['ee-admin-css'],
827
+			EVENT_ESPRESSO_VERSION
828
+		);
829
+		wp_enqueue_style('espresso_att');
830
+	}
831
+
832
+
833
+	public function load_scripts_styles_new_registration()
834
+	{
835
+		wp_register_script(
836
+			'ee-spco-for-admin',
837
+			REG_ASSETS_URL . 'spco_for_admin.js',
838
+			['underscore', 'jquery'],
839
+			EVENT_ESPRESSO_VERSION,
840
+			true
841
+		);
842
+		wp_enqueue_script('ee-spco-for-admin');
843
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
844
+		EE_Form_Section_Proper::wp_enqueue_scripts();
845
+		EED_Ticket_Selector::load_tckt_slctr_assets();
846
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
847
+	}
848
+
849
+
850
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
851
+	{
852
+		add_filter('FHEE_load_EE_messages', '__return_true');
853
+	}
854
+
855
+
856
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
857
+	{
858
+		add_filter('FHEE_load_EE_messages', '__return_true');
859
+	}
860
+
861
+
862
+	/**
863
+	 * @throws EE_Error
864
+	 * @throws InvalidArgumentException
865
+	 * @throws InvalidDataTypeException
866
+	 * @throws InvalidInterfaceException
867
+	 * @throws ReflectionException
868
+	 * @since 4.10.2.p
869
+	 */
870
+	protected function _set_list_table_views_default()
871
+	{
872
+		// for notification related bulk actions we need to make sure only active messengers have an option.
873
+		EED_Messages::set_autoloaders();
874
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
875
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
876
+		$active_mts               = $message_resource_manager->list_of_active_message_types();
877
+		// key= bulk_action_slug, value= message type.
878
+		$match_array = [
879
+			'approve_registrations'    => 'registration',
880
+			'decline_registrations'    => 'declined_registration',
881
+			'pending_registrations'    => 'pending_approval',
882
+			'no_approve_registrations' => 'not_approved_registration',
883
+			'cancel_registrations'     => 'cancelled_registration',
884
+		];
885
+		$can_send    = EE_Registry::instance()->CAP->current_user_can(
886
+			'ee_send_message',
887
+			'batch_send_messages'
888
+		);
889
+		/** setup reg status bulk actions **/
890
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
891
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
892
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
893
+				'Approve and Notify Registrations',
894
+				'event_espresso'
895
+			);
896
+		}
897
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
898
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
899
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
900
+				'Decline and Notify Registrations',
901
+				'event_espresso'
902
+			);
903
+		}
904
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
905
+			'Set Registrations to Pending Payment',
906
+			'event_espresso'
907
+		);
908
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
909
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
910
+				'Set Registrations to Pending Payment and Notify',
911
+				'event_espresso'
912
+			);
913
+		}
914
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
915
+			'Set Registrations to Not Approved',
916
+			'event_espresso'
917
+		);
918
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
919
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
920
+				'Set Registrations to Not Approved and Notify',
921
+				'event_espresso'
922
+			);
923
+		}
924
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
925
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
926
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
927
+				'Cancel Registrations and Notify',
928
+				'event_espresso'
929
+			);
930
+		}
931
+		$def_reg_status_actions = apply_filters(
932
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
933
+			$def_reg_status_actions,
934
+			$active_mts,
935
+			$can_send
936
+		);
937
+
938
+		$this->_views = [
939
+			'all'   => [
940
+				'slug'        => 'all',
941
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
942
+				'count'       => 0,
943
+				'bulk_action' => array_merge(
944
+					$def_reg_status_actions,
945
+					[
946
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
947
+					]
948
+				),
949
+			],
950
+			'month' => [
951
+				'slug'        => 'month',
952
+				'label'       => esc_html__('This Month', 'event_espresso'),
953
+				'count'       => 0,
954
+				'bulk_action' => array_merge(
955
+					$def_reg_status_actions,
956
+					[
957
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
958
+					]
959
+				),
960
+			],
961
+			'today' => [
962
+				'slug'        => 'today',
963
+				'label'       => sprintf(
964
+					esc_html__('Today - %s', 'event_espresso'),
965
+					date('M d, Y', current_time('timestamp'))
966
+				),
967
+				'count'       => 0,
968
+				'bulk_action' => array_merge(
969
+					$def_reg_status_actions,
970
+					[
971
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
972
+					]
973
+				),
974
+			],
975
+		];
976
+		if (
977
+			EE_Registry::instance()->CAP->current_user_can(
978
+				'ee_delete_registrations',
979
+				'espresso_registrations_delete_registration'
980
+			)
981
+		) {
982
+			$this->_views['incomplete'] = [
983
+				'slug'        => 'incomplete',
984
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
985
+				'count'       => 0,
986
+				'bulk_action' => [
987
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
988
+				],
989
+			];
990
+			$this->_views['trash']      = [
991
+				'slug'        => 'trash',
992
+				'label'       => esc_html__('Trash', 'event_espresso'),
993
+				'count'       => 0,
994
+				'bulk_action' => [
995
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
996
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
997
+				],
998
+			];
999
+		}
1000
+	}
1001
+
1002
+
1003
+	protected function _set_list_table_views_contact_list()
1004
+	{
1005
+		$this->_views = [
1006
+			'in_use' => [
1007
+				'slug'        => 'in_use',
1008
+				'label'       => esc_html__('In Use', 'event_espresso'),
1009
+				'count'       => 0,
1010
+				'bulk_action' => [
1011
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1012
+				],
1013
+			],
1014
+		];
1015
+		if (
1016
+			EE_Registry::instance()->CAP->current_user_can(
1017
+				'ee_delete_contacts',
1018
+				'espresso_registrations_trash_attendees'
1019
+			)
1020
+		) {
1021
+			$this->_views['trash'] = [
1022
+				'slug'        => 'trash',
1023
+				'label'       => esc_html__('Trash', 'event_espresso'),
1024
+				'count'       => 0,
1025
+				'bulk_action' => [
1026
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1027
+				],
1028
+			];
1029
+		}
1030
+	}
1031
+
1032
+
1033
+	/**
1034
+	 * @return array
1035
+	 * @throws EE_Error
1036
+	 */
1037
+	protected function _registration_legend_items()
1038
+	{
1039
+		$fc_items = [
1040
+			'star-icon'        => [
1041
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1042
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1043
+			],
1044
+			'view_details'     => [
1045
+				'class' => 'dashicons dashicons-clipboard',
1046
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1047
+			],
1048
+			'edit_attendee'    => [
1049
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1050
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1051
+			],
1052
+			'view_transaction' => [
1053
+				'class' => 'dashicons dashicons-cart',
1054
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1055
+			],
1056
+			'view_invoice'     => [
1057
+				'class' => 'dashicons dashicons-media-spreadsheet',
1058
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1059
+			],
1060
+		];
1061
+		if (
1062
+			EE_Registry::instance()->CAP->current_user_can(
1063
+				'ee_send_message',
1064
+				'espresso_registrations_resend_registration'
1065
+			)
1066
+		) {
1067
+			$fc_items['resend_registration'] = [
1068
+				'class' => 'dashicons dashicons-email-alt',
1069
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1070
+			];
1071
+		} else {
1072
+			$fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1073
+		}
1074
+		if (
1075
+			EE_Registry::instance()->CAP->current_user_can(
1076
+				'ee_read_global_messages',
1077
+				'view_filtered_messages'
1078
+			)
1079
+		) {
1080
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1081
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1082
+				$fc_items['view_related_messages'] = [
1083
+					'class' => $related_for_icon['css_class'],
1084
+					'desc'  => $related_for_icon['label'],
1085
+				];
1086
+			}
1087
+		}
1088
+		$sc_items = [
1089
+			'approved_status'   => [
1090
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1091
+				'desc'  => EEH_Template::pretty_status(
1092
+					EEM_Registration::status_id_approved,
1093
+					false,
1094
+					'sentence'
1095
+				),
1096
+			],
1097
+			'pending_status'    => [
1098
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1099
+				'desc'  => EEH_Template::pretty_status(
1100
+					EEM_Registration::status_id_pending_payment,
1101
+					false,
1102
+					'sentence'
1103
+				),
1104
+			],
1105
+			'wait_list'         => [
1106
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1107
+				'desc'  => EEH_Template::pretty_status(
1108
+					EEM_Registration::status_id_wait_list,
1109
+					false,
1110
+					'sentence'
1111
+				),
1112
+			],
1113
+			'incomplete_status' => [
1114
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1115
+				'desc'  => EEH_Template::pretty_status(
1116
+					EEM_Registration::status_id_incomplete,
1117
+					false,
1118
+					'sentence'
1119
+				),
1120
+			],
1121
+			'not_approved'      => [
1122
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1123
+				'desc'  => EEH_Template::pretty_status(
1124
+					EEM_Registration::status_id_not_approved,
1125
+					false,
1126
+					'sentence'
1127
+				),
1128
+			],
1129
+			'declined_status'   => [
1130
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1131
+				'desc'  => EEH_Template::pretty_status(
1132
+					EEM_Registration::status_id_declined,
1133
+					false,
1134
+					'sentence'
1135
+				),
1136
+			],
1137
+			'cancelled_status'  => [
1138
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1139
+				'desc'  => EEH_Template::pretty_status(
1140
+					EEM_Registration::status_id_cancelled,
1141
+					false,
1142
+					'sentence'
1143
+				),
1144
+			],
1145
+		];
1146
+		return array_merge($fc_items, $sc_items);
1147
+	}
1148
+
1149
+
1150
+
1151
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1152
+
1153
+
1154
+	/**
1155
+	 * @throws DomainException
1156
+	 * @throws EE_Error
1157
+	 * @throws InvalidArgumentException
1158
+	 * @throws InvalidDataTypeException
1159
+	 * @throws InvalidInterfaceException
1160
+	 */
1161
+	protected function _registrations_overview_list_table()
1162
+	{
1163
+		$this->appendAddNewRegistrationButtonToPageTitle();
1164
+		$header_text                  = '';
1165
+		$admin_page_header_decorators = [
1166
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1167
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1168
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1169
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1170
+		];
1171
+		foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1172
+			$filter_header_decorator = $this->getLoader()->getNew($admin_page_header_decorator);
1173
+			$header_text             = $filter_header_decorator->getHeaderText($header_text);
1174
+		}
1175
+		$this->_template_args['admin_page_header'] = $header_text;
1176
+		$this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1177
+		$this->display_admin_list_table_page_with_no_sidebar();
1178
+	}
1179
+
1180
+
1181
+	/**
1182
+	 * @throws EE_Error
1183
+	 * @throws InvalidArgumentException
1184
+	 * @throws InvalidDataTypeException
1185
+	 * @throws InvalidInterfaceException
1186
+	 */
1187
+	private function appendAddNewRegistrationButtonToPageTitle()
1188
+	{
1189
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1190
+		if (
1191
+			$EVT_ID
1192
+			&& EE_Registry::instance()->CAP->current_user_can(
1193
+				'ee_edit_registrations',
1194
+				'espresso_registrations_new_registration',
1195
+				$EVT_ID
1196
+			)
1197
+		) {
1198
+			$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1199
+				'new_registration',
1200
+				'add-registrant',
1201
+				['event_id' => $EVT_ID],
1202
+				'add-new-h2'
1203
+			);
1204
+		}
1205
+	}
1206
+
1207
+
1208
+	/**
1209
+	 * This sets the _registration property for the registration details screen
1210
+	 *
1211
+	 * @return void
1212
+	 * @throws EE_Error
1213
+	 * @throws InvalidArgumentException
1214
+	 * @throws InvalidDataTypeException
1215
+	 * @throws InvalidInterfaceException
1216
+	 */
1217
+	private function _set_registration_object()
1218
+	{
1219
+		// get out if we've already set the object
1220
+		if ($this->_registration instanceof EE_Registration) {
1221
+			return;
1222
+		}
1223
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1224
+		if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1225
+			return;
1226
+		}
1227
+		$error_msg = sprintf(
1228
+			esc_html__(
1229
+				'An error occurred and the details for Registration ID #%s could not be retrieved.',
1230
+				'event_espresso'
1231
+			),
1232
+			$REG_ID
1233
+		);
1234
+		EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1235
+		$this->_registration = null;
1236
+	}
1237
+
1238
+
1239
+	/**
1240
+	 * Used to retrieve registrations for the list table.
1241
+	 *
1242
+	 * @param int  $per_page
1243
+	 * @param bool $count
1244
+	 * @param bool $this_month
1245
+	 * @param bool $today
1246
+	 * @return EE_Registration[]|int
1247
+	 * @throws EE_Error
1248
+	 * @throws InvalidArgumentException
1249
+	 * @throws InvalidDataTypeException
1250
+	 * @throws InvalidInterfaceException
1251
+	 */
1252
+	public function get_registrations(
1253
+		$per_page = 10,
1254
+		$count = false,
1255
+		$this_month = false,
1256
+		$today = false
1257
+	) {
1258
+		if ($this_month) {
1259
+			$this->request->setRequestParam('status', 'month');
1260
+		}
1261
+		if ($today) {
1262
+			$this->request->setRequestParam('status', 'today');
1263
+		}
1264
+		$query_params = $this->_get_registration_query_parameters($this->request->requestParams(), $per_page, $count);
1265
+		/**
1266
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1267
+		 *
1268
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1269
+		 * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1270
+		 *                      or if you have the development copy of EE you can view this at the path:
1271
+		 *                      /docs/G--Model-System/model-query-params.md
1272
+		 */
1273
+		$query_params['group_by'] = '';
1274
+
1275
+		return $count
1276
+			? $this->getRegistrationModel()->count($query_params)
1277
+			/** @type EE_Registration[] */
1278
+			: $this->getRegistrationModel()->get_all($query_params);
1279
+	}
1280
+
1281
+
1282
+	/**
1283
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1284
+	 * Note: this listens to values on the request for some of the query parameters.
1285
+	 *
1286
+	 * @param array $request
1287
+	 * @param int   $per_page
1288
+	 * @param bool  $count
1289
+	 * @return array
1290
+	 * @throws EE_Error
1291
+	 * @throws InvalidArgumentException
1292
+	 * @throws InvalidDataTypeException
1293
+	 * @throws InvalidInterfaceException
1294
+	 */
1295
+	protected function _get_registration_query_parameters(
1296
+		$request = [],
1297
+		$per_page = 10,
1298
+		$count = false
1299
+	) {
1300
+		/** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1301
+		$list_table_query_builder = $this->getLoader()->getNew(
1302
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1303
+			[null, null, $request]
1304
+		);
1305
+		return $list_table_query_builder->getQueryParams($per_page, $count);
1306
+	}
1307
+
1308
+
1309
+	public function get_registration_status_array()
1310
+	{
1311
+		return self::$_reg_status;
1312
+	}
1313
+
1314
+
1315
+
1316
+
1317
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1318
+	/**
1319
+	 * generates HTML for the View Registration Details Admin page
1320
+	 *
1321
+	 * @return void
1322
+	 * @throws DomainException
1323
+	 * @throws EE_Error
1324
+	 * @throws InvalidArgumentException
1325
+	 * @throws InvalidDataTypeException
1326
+	 * @throws InvalidInterfaceException
1327
+	 * @throws EntityNotFoundException
1328
+	 * @throws ReflectionException
1329
+	 */
1330
+	protected function _registration_details()
1331
+	{
1332
+		$this->_template_args = [];
1333
+		$this->_set_registration_object();
1334
+		if (is_object($this->_registration)) {
1335
+			$transaction                                   = $this->_registration->transaction()
1336
+				? $this->_registration->transaction()
1337
+				: EE_Transaction::new_instance();
1338
+			$this->_session                                = $transaction->session_data();
1339
+			$event_id                                      = $this->_registration->event_ID();
1340
+			$this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1341
+			$this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1342
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1343
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1344
+			$this->_template_args['grand_total']           = $transaction->total();
1345
+			$this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1346
+			// link back to overview
1347
+			$this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1348
+			$this->_template_args['registration']                = $this->_registration;
1349
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1350
+				[
1351
+					'action'   => 'default',
1352
+					'event_id' => $event_id,
1353
+				],
1354
+				REG_ADMIN_URL
1355
+			);
1356
+			$this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1357
+				[
1358
+					'action' => 'default',
1359
+					'EVT_ID' => $event_id,
1360
+					'page'   => 'espresso_transactions',
1361
+				],
1362
+				admin_url('admin.php')
1363
+			);
1364
+			$this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1365
+				[
1366
+					'page'   => 'espresso_events',
1367
+					'action' => 'edit',
1368
+					'post'   => $event_id,
1369
+				],
1370
+				admin_url('admin.php')
1371
+			);
1372
+			// next and previous links
1373
+			$next_reg                                      = $this->_registration->next(
1374
+				null,
1375
+				[],
1376
+				'REG_ID'
1377
+			);
1378
+			$this->_template_args['next_registration']     = $next_reg
1379
+				? $this->_next_link(
1380
+					EE_Admin_Page::add_query_args_and_nonce(
1381
+						[
1382
+							'action'  => 'view_registration',
1383
+							'_REG_ID' => $next_reg['REG_ID'],
1384
+						],
1385
+						REG_ADMIN_URL
1386
+					),
1387
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1388
+				)
1389
+				: '';
1390
+			$previous_reg                                  = $this->_registration->previous(
1391
+				null,
1392
+				[],
1393
+				'REG_ID'
1394
+			);
1395
+			$this->_template_args['previous_registration'] = $previous_reg
1396
+				? $this->_previous_link(
1397
+					EE_Admin_Page::add_query_args_and_nonce(
1398
+						[
1399
+							'action'  => 'view_registration',
1400
+							'_REG_ID' => $previous_reg['REG_ID'],
1401
+						],
1402
+						REG_ADMIN_URL
1403
+					),
1404
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1405
+				)
1406
+				: '';
1407
+			// grab header
1408
+			$template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1409
+			$this->_template_args['REG_ID']            = $this->_registration->ID();
1410
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1411
+				$template_path,
1412
+				$this->_template_args,
1413
+				true
1414
+			);
1415
+		} else {
1416
+			$this->_template_args['admin_page_header'] = '';
1417
+			$this->_display_espresso_notices();
1418
+		}
1419
+		// the details template wrapper
1420
+		$this->display_admin_page_with_sidebar();
1421
+	}
1422
+
1423
+
1424
+	/**
1425
+	 * @throws EE_Error
1426
+	 * @throws InvalidArgumentException
1427
+	 * @throws InvalidDataTypeException
1428
+	 * @throws InvalidInterfaceException
1429
+	 * @throws ReflectionException
1430
+	 * @since 4.10.2.p
1431
+	 */
1432
+	protected function _registration_details_metaboxes()
1433
+	{
1434
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1435
+		$this->_set_registration_object();
1436
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1437
+		add_meta_box(
1438
+			'edit-reg-status-mbox',
1439
+			esc_html__('Registration Status', 'event_espresso'),
1440
+			[$this, 'set_reg_status_buttons_metabox'],
1441
+			$this->_wp_page_slug,
1442
+			'normal',
1443
+			'high'
1444
+		);
1445
+		add_meta_box(
1446
+			'edit-reg-details-mbox',
1447
+			esc_html__('Registration Details', 'event_espresso'),
1448
+			[$this, '_reg_details_meta_box'],
1449
+			$this->_wp_page_slug,
1450
+			'normal',
1451
+			'high'
1452
+		);
1453
+		if (
1454
+			$attendee instanceof EE_Attendee
1455
+			&& EE_Registry::instance()->CAP->current_user_can(
1456
+				'ee_read_registration',
1457
+				'edit-reg-questions-mbox',
1458
+				$this->_registration->ID()
1459
+			)
1460
+		) {
1461
+			add_meta_box(
1462
+				'edit-reg-questions-mbox',
1463
+				esc_html__('Registration Form Answers', 'event_espresso'),
1464
+				[$this, '_reg_questions_meta_box'],
1465
+				$this->_wp_page_slug,
1466
+				'normal',
1467
+				'high'
1468
+			);
1469
+		}
1470
+		add_meta_box(
1471
+			'edit-reg-registrant-mbox',
1472
+			esc_html__('Contact Details', 'event_espresso'),
1473
+			[$this, '_reg_registrant_side_meta_box'],
1474
+			$this->_wp_page_slug,
1475
+			'side',
1476
+			'high'
1477
+		);
1478
+		if ($this->_registration->group_size() > 1) {
1479
+			add_meta_box(
1480
+				'edit-reg-attendees-mbox',
1481
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1482
+				[$this, '_reg_attendees_meta_box'],
1483
+				$this->_wp_page_slug,
1484
+				'normal',
1485
+				'high'
1486
+			);
1487
+		}
1488
+	}
1489
+
1490
+
1491
+	/**
1492
+	 * set_reg_status_buttons_metabox
1493
+	 *
1494
+	 * @return void
1495
+	 * @throws EE_Error
1496
+	 * @throws EntityNotFoundException
1497
+	 * @throws InvalidArgumentException
1498
+	 * @throws InvalidDataTypeException
1499
+	 * @throws InvalidInterfaceException
1500
+	 * @throws ReflectionException
1501
+	 */
1502
+	public function set_reg_status_buttons_metabox()
1503
+	{
1504
+		$this->_set_registration_object();
1505
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1506
+		$output                 = $change_reg_status_form->form_open(
1507
+			self::add_query_args_and_nonce(
1508
+				[
1509
+					'action' => 'change_reg_status',
1510
+				],
1511
+				REG_ADMIN_URL
1512
+			)
1513
+		);
1514
+		$output                 .= $change_reg_status_form->get_html();
1515
+		$output                 .= $change_reg_status_form->form_close();
1516
+		echo $output; // already escaped
1517
+	}
1518
+
1519
+
1520
+	/**
1521
+	 * @return EE_Form_Section_Proper
1522
+	 * @throws EE_Error
1523
+	 * @throws InvalidArgumentException
1524
+	 * @throws InvalidDataTypeException
1525
+	 * @throws InvalidInterfaceException
1526
+	 * @throws EntityNotFoundException
1527
+	 * @throws ReflectionException
1528
+	 */
1529
+	protected function _generate_reg_status_change_form()
1530
+	{
1531
+		$reg_status_change_form_array = [
1532
+			'name'            => 'reg_status_change_form',
1533
+			'html_id'         => 'reg-status-change-form',
1534
+			'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1535
+			'subsections'     => [
1536
+				'return'         => new EE_Hidden_Input(
1537
+					[
1538
+						'name'    => 'return',
1539
+						'default' => 'view_registration',
1540
+					]
1541
+				),
1542
+				'REG_ID'         => new EE_Hidden_Input(
1543
+					[
1544
+						'name'    => 'REG_ID',
1545
+						'default' => $this->_registration->ID(),
1546
+					]
1547
+				),
1548
+				'current_status' => new EE_Form_Section_HTML(
1549
+					EEH_HTML::table(
1550
+						EEH_HTML::tr(
1551
+							EEH_HTML::th(
1552
+								EEH_HTML::label(
1553
+									EEH_HTML::strong(
1554
+										esc_html__('Current Registration Status', 'event_espresso')
1555
+									)
1556
+								)
1557
+							)
1558
+							. EEH_HTML::td(
1559
+								EEH_HTML::strong(
1560
+									$this->_registration->pretty_status(),
1561
+									'',
1562
+									'status-' . $this->_registration->status_ID(),
1563
+									'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1564
+								)
1565
+							)
1566
+						)
1567
+					)
1568
+				),
1569
+			],
1570
+		];
1571
+		if (
1572
+			EE_Registry::instance()->CAP->current_user_can(
1573
+				'ee_edit_registration',
1574
+				'toggle_registration_status',
1575
+				$this->_registration->ID()
1576
+			)
1577
+		) {
1578
+			$reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1579
+				$this->_get_reg_statuses(),
1580
+				[
1581
+					'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1582
+					'default'         => $this->_registration->status_ID(),
1583
+				]
1584
+			);
1585
+			$reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1586
+				[
1587
+					'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1588
+					'default'         => false,
1589
+					'html_help_text'  => esc_html__(
1590
+						'If set to "Yes", then the related messages will be sent to the registrant.',
1591
+						'event_espresso'
1592
+					),
1593
+				]
1594
+			);
1595
+			$reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1596
+				[
1597
+					'html_class'      => 'button-primary',
1598
+					'html_label_text' => '&nbsp;',
1599
+					'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1600
+				]
1601
+			);
1602
+		}
1603
+		return new EE_Form_Section_Proper($reg_status_change_form_array);
1604
+	}
1605
+
1606
+
1607
+	/**
1608
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1609
+	 *
1610
+	 * @return array
1611
+	 * @throws EE_Error
1612
+	 * @throws InvalidArgumentException
1613
+	 * @throws InvalidDataTypeException
1614
+	 * @throws InvalidInterfaceException
1615
+	 * @throws EntityNotFoundException
1616
+	 */
1617
+	protected function _get_reg_statuses()
1618
+	{
1619
+		$reg_status_array = $this->getRegistrationModel()->reg_status_array();
1620
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1621
+		// get current reg status
1622
+		$current_status = $this->_registration->status_ID();
1623
+		// is registration for free event? This will determine whether to display the pending payment option
1624
+		if (
1625
+			$current_status !== EEM_Registration::status_id_pending_payment
1626
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1627
+		) {
1628
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1629
+		}
1630
+		return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1631
+	}
1632
+
1633
+
1634
+	/**
1635
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1636
+	 *
1637
+	 * @param bool $status REG status given for changing registrations to.
1638
+	 * @param bool $notify Whether to send messages notifications or not.
1639
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1640
+	 * @throws DomainException
1641
+	 * @throws EE_Error
1642
+	 * @throws EntityNotFoundException
1643
+	 * @throws InvalidArgumentException
1644
+	 * @throws InvalidDataTypeException
1645
+	 * @throws InvalidInterfaceException
1646
+	 * @throws ReflectionException
1647
+	 * @throws RuntimeException
1648
+	 */
1649
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1650
+	{
1651
+		$REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1652
+			? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1653
+			: $this->request->getRequestParam('_REG_ID', [], 'int', true);
1654
+
1655
+		// sanitize $REG_IDs
1656
+		$REG_IDs = array_map('absint', $REG_IDs);
1657
+		// and remove empty entries
1658
+		$REG_IDs = array_filter($REG_IDs);
1659
+
1660
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1661
+
1662
+		/**
1663
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1664
+		 * Currently this value is used downstream by the _process_resend_registration method.
1665
+		 *
1666
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1667
+		 * @param bool                     $status           The status registrations were changed to.
1668
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1669
+		 * @param Registrations_Admin_Page $admin_page_object
1670
+		 */
1671
+		$REG_ID = apply_filters(
1672
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1673
+			$result['REG_ID'],
1674
+			$status,
1675
+			$result['success'],
1676
+			$this
1677
+		);
1678
+		$this->request->setRequestParam('_REG_ID', $REG_ID);
1679
+
1680
+		// notify?
1681
+		if (
1682
+			$notify
1683
+			&& $result['success']
1684
+			&& ! empty($REG_ID)
1685
+			&& EE_Registry::instance()->CAP->current_user_can(
1686
+				'ee_send_message',
1687
+				'espresso_registrations_resend_registration'
1688
+			)
1689
+		) {
1690
+			$this->_process_resend_registration();
1691
+		}
1692
+		return $result;
1693
+	}
1694
+
1695
+
1696
+	/**
1697
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1698
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1699
+	 *
1700
+	 * @param array  $REG_IDs
1701
+	 * @param string $status
1702
+	 * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1703
+	 *                       slug sent with setting the registration status.
1704
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1705
+	 * @throws EE_Error
1706
+	 * @throws InvalidArgumentException
1707
+	 * @throws InvalidDataTypeException
1708
+	 * @throws InvalidInterfaceException
1709
+	 * @throws ReflectionException
1710
+	 * @throws RuntimeException
1711
+	 * @throws EntityNotFoundException
1712
+	 * @throws DomainException
1713
+	 */
1714
+	protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1715
+	{
1716
+		$success = false;
1717
+		// typecast $REG_IDs
1718
+		$REG_IDs = (array) $REG_IDs;
1719
+		if (! empty($REG_IDs)) {
1720
+			$success = true;
1721
+			// set default status if none is passed
1722
+			$status         = $status ?: EEM_Registration::status_id_pending_payment;
1723
+			$status_context = $notify
1724
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1725
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1726
+			// loop through REG_ID's and change status
1727
+			foreach ($REG_IDs as $REG_ID) {
1728
+				$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1729
+				if ($registration instanceof EE_Registration) {
1730
+					$registration->set_status(
1731
+						$status,
1732
+						false,
1733
+						new Context(
1734
+							$status_context,
1735
+							esc_html__(
1736
+								'Manually triggered status change on a Registration Admin Page route.',
1737
+								'event_espresso'
1738
+							)
1739
+						)
1740
+					);
1741
+					$result = $registration->save();
1742
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1743
+					$success = $result !== false ? $success : false;
1744
+				}
1745
+			}
1746
+		}
1747
+
1748
+		// return $success and processed registrations
1749
+		return ['REG_ID' => $REG_IDs, 'success' => $success];
1750
+	}
1751
+
1752
+
1753
+	/**
1754
+	 * Common logic for setting up success message and redirecting to appropriate route
1755
+	 *
1756
+	 * @param string $STS_ID status id for the registration changed to
1757
+	 * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1758
+	 * @return void
1759
+	 * @throws DomainException
1760
+	 * @throws EE_Error
1761
+	 * @throws EntityNotFoundException
1762
+	 * @throws InvalidArgumentException
1763
+	 * @throws InvalidDataTypeException
1764
+	 * @throws InvalidInterfaceException
1765
+	 * @throws ReflectionException
1766
+	 * @throws RuntimeException
1767
+	 */
1768
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1769
+	{
1770
+		$result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1771
+			: ['success' => false];
1772
+		$success = isset($result['success']) && $result['success'];
1773
+		// setup success message
1774
+		if ($success) {
1775
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1776
+				$msg = sprintf(
1777
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1778
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1779
+				);
1780
+			} else {
1781
+				$msg = sprintf(
1782
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
1783
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1784
+				);
1785
+			}
1786
+			EE_Error::add_success($msg);
1787
+		} else {
1788
+			EE_Error::add_error(
1789
+				esc_html__(
1790
+					'Something went wrong, and the status was not changed',
1791
+					'event_espresso'
1792
+				),
1793
+				__FILE__,
1794
+				__LINE__,
1795
+				__FUNCTION__
1796
+			);
1797
+		}
1798
+		$return = $this->request->getRequestParam('return');
1799
+		$route  = $return === 'view_registration'
1800
+			? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1801
+			: ['action' => 'default'];
1802
+		$route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1803
+		$this->_redirect_after_action($success, '', '', $route, true);
1804
+	}
1805
+
1806
+
1807
+	/**
1808
+	 * incoming reg status change from reg details page.
1809
+	 *
1810
+	 * @return void
1811
+	 * @throws EE_Error
1812
+	 * @throws EntityNotFoundException
1813
+	 * @throws InvalidArgumentException
1814
+	 * @throws InvalidDataTypeException
1815
+	 * @throws InvalidInterfaceException
1816
+	 * @throws ReflectionException
1817
+	 * @throws RuntimeException
1818
+	 * @throws DomainException
1819
+	 */
1820
+	protected function _change_reg_status()
1821
+	{
1822
+		$this->request->setRequestParam('return', 'view_registration');
1823
+		// set notify based on whether the send notifications toggle is set or not
1824
+		$notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1825
+		$reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1826
+		$this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1827
+		switch ($reg_status) {
1828
+			case EEM_Registration::status_id_approved:
1829
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1830
+				$this->approve_registration($notify);
1831
+				break;
1832
+			case EEM_Registration::status_id_pending_payment:
1833
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1834
+				$this->pending_registration($notify);
1835
+				break;
1836
+			case EEM_Registration::status_id_not_approved:
1837
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1838
+				$this->not_approve_registration($notify);
1839
+				break;
1840
+			case EEM_Registration::status_id_declined:
1841
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1842
+				$this->decline_registration($notify);
1843
+				break;
1844
+			case EEM_Registration::status_id_cancelled:
1845
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1846
+				$this->cancel_registration($notify);
1847
+				break;
1848
+			case EEM_Registration::status_id_wait_list:
1849
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1850
+				$this->wait_list_registration($notify);
1851
+				break;
1852
+			case EEM_Registration::status_id_incomplete:
1853
+			default:
1854
+				$this->request->unSetRequestParam('return');
1855
+				$this->_reg_status_change_return('');
1856
+				break;
1857
+		}
1858
+	}
1859
+
1860
+
1861
+	/**
1862
+	 * Callback for bulk action routes.
1863
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1864
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
1865
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1866
+	 * when an action is happening on just a single registration).
1867
+	 *
1868
+	 * @param      $action
1869
+	 * @param bool $notify
1870
+	 */
1871
+	protected function bulk_action_on_registrations($action, $notify = false)
1872
+	{
1873
+		do_action(
1874
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1875
+			$this,
1876
+			$action,
1877
+			$notify
1878
+		);
1879
+		$method = $action . '_registration';
1880
+		if (method_exists($this, $method)) {
1881
+			$this->$method($notify);
1882
+		}
1883
+	}
1884
+
1885
+
1886
+	/**
1887
+	 * approve_registration
1888
+	 *
1889
+	 * @param bool $notify whether or not to notify the registrant about their approval.
1890
+	 * @return void
1891
+	 * @throws EE_Error
1892
+	 * @throws EntityNotFoundException
1893
+	 * @throws InvalidArgumentException
1894
+	 * @throws InvalidDataTypeException
1895
+	 * @throws InvalidInterfaceException
1896
+	 * @throws ReflectionException
1897
+	 * @throws RuntimeException
1898
+	 * @throws DomainException
1899
+	 */
1900
+	protected function approve_registration($notify = false)
1901
+	{
1902
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1903
+	}
1904
+
1905
+
1906
+	/**
1907
+	 * decline_registration
1908
+	 *
1909
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1910
+	 * @return void
1911
+	 * @throws EE_Error
1912
+	 * @throws EntityNotFoundException
1913
+	 * @throws InvalidArgumentException
1914
+	 * @throws InvalidDataTypeException
1915
+	 * @throws InvalidInterfaceException
1916
+	 * @throws ReflectionException
1917
+	 * @throws RuntimeException
1918
+	 * @throws DomainException
1919
+	 */
1920
+	protected function decline_registration($notify = false)
1921
+	{
1922
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1923
+	}
1924
+
1925
+
1926
+	/**
1927
+	 * cancel_registration
1928
+	 *
1929
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1930
+	 * @return void
1931
+	 * @throws EE_Error
1932
+	 * @throws EntityNotFoundException
1933
+	 * @throws InvalidArgumentException
1934
+	 * @throws InvalidDataTypeException
1935
+	 * @throws InvalidInterfaceException
1936
+	 * @throws ReflectionException
1937
+	 * @throws RuntimeException
1938
+	 * @throws DomainException
1939
+	 */
1940
+	protected function cancel_registration($notify = false)
1941
+	{
1942
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1943
+	}
1944
+
1945
+
1946
+	/**
1947
+	 * not_approve_registration
1948
+	 *
1949
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1950
+	 * @return void
1951
+	 * @throws EE_Error
1952
+	 * @throws EntityNotFoundException
1953
+	 * @throws InvalidArgumentException
1954
+	 * @throws InvalidDataTypeException
1955
+	 * @throws InvalidInterfaceException
1956
+	 * @throws ReflectionException
1957
+	 * @throws RuntimeException
1958
+	 * @throws DomainException
1959
+	 */
1960
+	protected function not_approve_registration($notify = false)
1961
+	{
1962
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1963
+	}
1964
+
1965
+
1966
+	/**
1967
+	 * decline_registration
1968
+	 *
1969
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1970
+	 * @return void
1971
+	 * @throws EE_Error
1972
+	 * @throws EntityNotFoundException
1973
+	 * @throws InvalidArgumentException
1974
+	 * @throws InvalidDataTypeException
1975
+	 * @throws InvalidInterfaceException
1976
+	 * @throws ReflectionException
1977
+	 * @throws RuntimeException
1978
+	 * @throws DomainException
1979
+	 */
1980
+	protected function pending_registration($notify = false)
1981
+	{
1982
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1983
+	}
1984
+
1985
+
1986
+	/**
1987
+	 * waitlist_registration
1988
+	 *
1989
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1990
+	 * @return void
1991
+	 * @throws EE_Error
1992
+	 * @throws EntityNotFoundException
1993
+	 * @throws InvalidArgumentException
1994
+	 * @throws InvalidDataTypeException
1995
+	 * @throws InvalidInterfaceException
1996
+	 * @throws ReflectionException
1997
+	 * @throws RuntimeException
1998
+	 * @throws DomainException
1999
+	 */
2000
+	protected function wait_list_registration($notify = false)
2001
+	{
2002
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2003
+	}
2004
+
2005
+
2006
+	/**
2007
+	 * generates HTML for the Registration main meta box
2008
+	 *
2009
+	 * @return void
2010
+	 * @throws DomainException
2011
+	 * @throws EE_Error
2012
+	 * @throws InvalidArgumentException
2013
+	 * @throws InvalidDataTypeException
2014
+	 * @throws InvalidInterfaceException
2015
+	 * @throws ReflectionException
2016
+	 * @throws EntityNotFoundException
2017
+	 */
2018
+	public function _reg_details_meta_box()
2019
+	{
2020
+		EEH_Autoloader::register_line_item_display_autoloaders();
2021
+		EEH_Autoloader::register_line_item_filter_autoloaders();
2022
+		EE_Registry::instance()->load_helper('Line_Item');
2023
+		$transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
2024
+			: EE_Transaction::new_instance();
2025
+		$this->_session = $transaction->session_data();
2026
+		$filters        = new EE_Line_Item_Filter_Collection();
2027
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2028
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
2029
+		$line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2030
+			$filters,
2031
+			$transaction->total_line_item()
2032
+		);
2033
+		$filtered_line_item_tree                 = $line_item_filter_processor->process();
2034
+		$line_item_display                       = new EE_Line_Item_Display(
2035
+			'reg_admin_table',
2036
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2037
+		);
2038
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2039
+			$filtered_line_item_tree,
2040
+			['EE_Registration' => $this->_registration]
2041
+		);
2042
+		$attendee                                = $this->_registration->attendee();
2043
+		if (
2044
+			EE_Registry::instance()->CAP->current_user_can(
2045
+				'ee_read_transaction',
2046
+				'espresso_transactions_view_transaction'
2047
+			)
2048
+		) {
2049
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2050
+				EE_Admin_Page::add_query_args_and_nonce(
2051
+					[
2052
+						'action' => 'view_transaction',
2053
+						'TXN_ID' => $transaction->ID(),
2054
+					],
2055
+					TXN_ADMIN_URL
2056
+				),
2057
+				esc_html__(' View Transaction', 'event_espresso'),
2058
+				'button secondary-button right',
2059
+				'dashicons dashicons-cart'
2060
+			);
2061
+		} else {
2062
+			$this->_template_args['view_transaction_button'] = '';
2063
+		}
2064
+		if (
2065
+			$attendee instanceof EE_Attendee
2066
+			&& EE_Registry::instance()->CAP->current_user_can(
2067
+				'ee_send_message',
2068
+				'espresso_registrations_resend_registration'
2069
+			)
2070
+		) {
2071
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2072
+				EE_Admin_Page::add_query_args_and_nonce(
2073
+					[
2074
+						'action'      => 'resend_registration',
2075
+						'_REG_ID'     => $this->_registration->ID(),
2076
+						'redirect_to' => 'view_registration',
2077
+					],
2078
+					REG_ADMIN_URL
2079
+				),
2080
+				esc_html__(' Resend Registration', 'event_espresso'),
2081
+				'button secondary-button right',
2082
+				'dashicons dashicons-email-alt'
2083
+			);
2084
+		} else {
2085
+			$this->_template_args['resend_registration_button'] = '';
2086
+		}
2087
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2088
+		$payment                               = $transaction->get_first_related('Payment');
2089
+		$payment                               = ! $payment instanceof EE_Payment
2090
+			? EE_Payment::new_instance()
2091
+			: $payment;
2092
+		$payment_method                        = $payment->get_first_related('Payment_Method');
2093
+		$payment_method                        = ! $payment_method instanceof EE_Payment_Method
2094
+			? EE_Payment_Method::new_instance()
2095
+			: $payment_method;
2096
+		$reg_details                           = [
2097
+			'payment_method'       => $payment_method->name(),
2098
+			'response_msg'         => $payment->gateway_response(),
2099
+			'registration_id'      => $this->_registration->get('REG_code'),
2100
+			'registration_session' => $this->_registration->session_ID(),
2101
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2102
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2103
+		];
2104
+		if (isset($reg_details['registration_id'])) {
2105
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2106
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2107
+				'Registration ID',
2108
+				'event_espresso'
2109
+			);
2110
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2111
+		}
2112
+		if (isset($reg_details['payment_method'])) {
2113
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2114
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2115
+				'Most Recent Payment Method',
2116
+				'event_espresso'
2117
+			);
2118
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2119
+			$this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2120
+			$this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2121
+				'Payment method response',
2122
+				'event_espresso'
2123
+			);
2124
+			$this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2125
+		}
2126
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2127
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2128
+			'Registration Session',
2129
+			'event_espresso'
2130
+		);
2131
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2132
+		$this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2133
+		$this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2134
+			'Registration placed from IP',
2135
+			'event_espresso'
2136
+		);
2137
+		$this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2138
+		$this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2139
+		$this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2140
+			'Registrant User Agent',
2141
+			'event_espresso'
2142
+		);
2143
+		$this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2144
+		$this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2145
+			[
2146
+				'action'   => 'default',
2147
+				'event_id' => $this->_registration->event_ID(),
2148
+			],
2149
+			REG_ADMIN_URL
2150
+		);
2151
+		$this->_template_args['REG_ID']                                       = $this->_registration->ID();
2152
+		$this->_template_args['event_id']                                     = $this->_registration->event_ID();
2153
+		$template_path                                                        =
2154
+			REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2155
+		EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2156
+	}
2157
+
2158
+
2159
+	/**
2160
+	 * generates HTML for the Registration Questions meta box.
2161
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2162
+	 * otherwise uses new forms system
2163
+	 *
2164
+	 * @return void
2165
+	 * @throws DomainException
2166
+	 * @throws EE_Error
2167
+	 * @throws InvalidArgumentException
2168
+	 * @throws InvalidDataTypeException
2169
+	 * @throws InvalidInterfaceException
2170
+	 * @throws ReflectionException
2171
+	 */
2172
+	public function _reg_questions_meta_box()
2173
+	{
2174
+		// allow someone to override this method entirely
2175
+		if (
2176
+			apply_filters(
2177
+				'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2178
+				true,
2179
+				$this,
2180
+				$this->_registration
2181
+			)
2182
+		) {
2183
+			$form                                              = $this->_get_reg_custom_questions_form(
2184
+				$this->_registration->ID()
2185
+			);
2186
+			$this->_template_args['att_questions']             = count($form->subforms()) > 0
2187
+				? $form->get_html_and_js()
2188
+				: '';
2189
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2190
+			$this->_template_args['REG_ID']                    = $this->_registration->ID();
2191
+			$template_path                                     =
2192
+				REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2193
+			EEH_Template::display_template($template_path, $this->_template_args);
2194
+		}
2195
+	}
2196
+
2197
+
2198
+	/**
2199
+	 * form_before_question_group
2200
+	 *
2201
+	 * @param string $output
2202
+	 * @return        string
2203
+	 * @deprecated    as of 4.8.32.rc.000
2204
+	 */
2205
+	public function form_before_question_group($output)
2206
+	{
2207
+		EE_Error::doing_it_wrong(
2208
+			__CLASS__ . '::' . __FUNCTION__,
2209
+			esc_html__(
2210
+				'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.',
2211
+				'event_espresso'
2212
+			),
2213
+			'4.8.32.rc.000'
2214
+		);
2215
+		return '
2216 2216
 	<table class="form-table ee-width-100">
2217 2217
 		<tbody>
2218 2218
 			';
2219
-    }
2220
-
2221
-
2222
-    /**
2223
-     * form_after_question_group
2224
-     *
2225
-     * @param string $output
2226
-     * @return        string
2227
-     * @deprecated    as of 4.8.32.rc.000
2228
-     */
2229
-    public function form_after_question_group($output)
2230
-    {
2231
-        EE_Error::doing_it_wrong(
2232
-            __CLASS__ . '::' . __FUNCTION__,
2233
-            esc_html__(
2234
-                '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.',
2235
-                'event_espresso'
2236
-            ),
2237
-            '4.8.32.rc.000'
2238
-        );
2239
-        return '
2219
+	}
2220
+
2221
+
2222
+	/**
2223
+	 * form_after_question_group
2224
+	 *
2225
+	 * @param string $output
2226
+	 * @return        string
2227
+	 * @deprecated    as of 4.8.32.rc.000
2228
+	 */
2229
+	public function form_after_question_group($output)
2230
+	{
2231
+		EE_Error::doing_it_wrong(
2232
+			__CLASS__ . '::' . __FUNCTION__,
2233
+			esc_html__(
2234
+				'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.',
2235
+				'event_espresso'
2236
+			),
2237
+			'4.8.32.rc.000'
2238
+		);
2239
+		return '
2240 2240
 			<tr class="hide-if-no-js">
2241 2241
 				<th> </th>
2242 2242
 				<td class="reg-admin-edit-attendee-question-td">
2243 2243
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2244
-               . esc_attr__('click to edit question', 'event_espresso')
2245
-               . '">
2244
+			   . esc_attr__('click to edit question', 'event_espresso')
2245
+			   . '">
2246 2246
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2247
-               . esc_html__('edit the above question group', 'event_espresso')
2248
-               . '</span>
2247
+			   . esc_html__('edit the above question group', 'event_espresso')
2248
+			   . '</span>
2249 2249
 						<div class="dashicons dashicons-edit"></div>
2250 2250
 					</a>
2251 2251
 				</td>
@@ -2253,637 +2253,637 @@  discard block
 block discarded – undo
2253 2253
 		</tbody>
2254 2254
 	</table>
2255 2255
 ';
2256
-    }
2257
-
2258
-
2259
-    /**
2260
-     * form_form_field_label_wrap
2261
-     *
2262
-     * @param string $label
2263
-     * @return        string
2264
-     * @deprecated    as of 4.8.32.rc.000
2265
-     */
2266
-    public function form_form_field_label_wrap($label)
2267
-    {
2268
-        EE_Error::doing_it_wrong(
2269
-            __CLASS__ . '::' . __FUNCTION__,
2270
-            esc_html__(
2271
-                '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.',
2272
-                'event_espresso'
2273
-            ),
2274
-            '4.8.32.rc.000'
2275
-        );
2276
-        return '
2256
+	}
2257
+
2258
+
2259
+	/**
2260
+	 * form_form_field_label_wrap
2261
+	 *
2262
+	 * @param string $label
2263
+	 * @return        string
2264
+	 * @deprecated    as of 4.8.32.rc.000
2265
+	 */
2266
+	public function form_form_field_label_wrap($label)
2267
+	{
2268
+		EE_Error::doing_it_wrong(
2269
+			__CLASS__ . '::' . __FUNCTION__,
2270
+			esc_html__(
2271
+				'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.',
2272
+				'event_espresso'
2273
+			),
2274
+			'4.8.32.rc.000'
2275
+		);
2276
+		return '
2277 2277
 			<tr>
2278 2278
 				<th>
2279 2279
 					' . $label . '
2280 2280
 				</th>';
2281
-    }
2282
-
2283
-
2284
-    /**
2285
-     * form_form_field_input__wrap
2286
-     *
2287
-     * @param string $input
2288
-     * @return        string
2289
-     * @deprecated    as of 4.8.32.rc.000
2290
-     */
2291
-    public function form_form_field_input__wrap($input)
2292
-    {
2293
-        EE_Error::doing_it_wrong(
2294
-            __CLASS__ . '::' . __FUNCTION__,
2295
-            esc_html__(
2296
-                '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.',
2297
-                'event_espresso'
2298
-            ),
2299
-            '4.8.32.rc.000'
2300
-        );
2301
-        return '
2281
+	}
2282
+
2283
+
2284
+	/**
2285
+	 * form_form_field_input__wrap
2286
+	 *
2287
+	 * @param string $input
2288
+	 * @return        string
2289
+	 * @deprecated    as of 4.8.32.rc.000
2290
+	 */
2291
+	public function form_form_field_input__wrap($input)
2292
+	{
2293
+		EE_Error::doing_it_wrong(
2294
+			__CLASS__ . '::' . __FUNCTION__,
2295
+			esc_html__(
2296
+				'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.',
2297
+				'event_espresso'
2298
+			),
2299
+			'4.8.32.rc.000'
2300
+		);
2301
+		return '
2302 2302
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2303 2303
 					' . $input . '
2304 2304
 				</td>
2305 2305
 			</tr>';
2306
-    }
2307
-
2308
-
2309
-    /**
2310
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2311
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2312
-     * to display the page
2313
-     *
2314
-     * @return void
2315
-     * @throws EE_Error
2316
-     * @throws InvalidArgumentException
2317
-     * @throws InvalidDataTypeException
2318
-     * @throws InvalidInterfaceException
2319
-     * @throws ReflectionException
2320
-     */
2321
-    protected function _update_attendee_registration_form()
2322
-    {
2323
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2324
-        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2325
-            $REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2326
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2327
-            if ($success) {
2328
-                $what  = esc_html__('Registration Form', 'event_espresso');
2329
-                $route = $REG_ID
2330
-                    ? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2331
-                    : ['action' => 'default'];
2332
-                $this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2333
-            }
2334
-        }
2335
-    }
2336
-
2337
-
2338
-    /**
2339
-     * Gets the form for saving registrations custom questions (if done
2340
-     * previously retrieves the cached form object, which may have validation errors in it)
2341
-     *
2342
-     * @param int $REG_ID
2343
-     * @return EE_Registration_Custom_Questions_Form
2344
-     * @throws EE_Error
2345
-     * @throws InvalidArgumentException
2346
-     * @throws InvalidDataTypeException
2347
-     * @throws InvalidInterfaceException
2348
-     * @throws ReflectionException
2349
-     */
2350
-    protected function _get_reg_custom_questions_form($REG_ID)
2351
-    {
2352
-        if (! $this->_reg_custom_questions_form) {
2353
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2354
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2355
-                $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2356
-            );
2357
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2358
-        }
2359
-        return $this->_reg_custom_questions_form;
2360
-    }
2361
-
2362
-
2363
-    /**
2364
-     * Saves
2365
-     *
2366
-     * @param bool $REG_ID
2367
-     * @return bool
2368
-     * @throws EE_Error
2369
-     * @throws InvalidArgumentException
2370
-     * @throws InvalidDataTypeException
2371
-     * @throws InvalidInterfaceException
2372
-     * @throws ReflectionException
2373
-     */
2374
-    private function _save_reg_custom_questions_form($REG_ID = 0)
2375
-    {
2376
-        if (! $REG_ID) {
2377
-            EE_Error::add_error(
2378
-                esc_html__(
2379
-                    'An error occurred. No registration ID was received.',
2380
-                    'event_espresso'
2381
-                ),
2382
-                __FILE__,
2383
-                __FUNCTION__,
2384
-                __LINE__
2385
-            );
2386
-        }
2387
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2388
-        $form->receive_form_submission($this->request->requestParams());
2389
-        $success = false;
2390
-        if ($form->is_valid()) {
2391
-            foreach ($form->subforms() as $question_group_form) {
2392
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2393
-                    $where_conditions    = [
2394
-                        'QST_ID' => $question_id,
2395
-                        'REG_ID' => $REG_ID,
2396
-                    ];
2397
-                    $possibly_new_values = [
2398
-                        'ANS_value' => $input->normalized_value(),
2399
-                    ];
2400
-                    $answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2401
-                    if ($answer instanceof EE_Answer) {
2402
-                        $success = $answer->save($possibly_new_values);
2403
-                    } else {
2404
-                        // insert it then
2405
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2406
-                        $answer      = EE_Answer::new_instance($cols_n_vals);
2407
-                        $success     = $answer->save();
2408
-                    }
2409
-                }
2410
-            }
2411
-        } else {
2412
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2413
-        }
2414
-        return $success;
2415
-    }
2416
-
2417
-
2418
-    /**
2419
-     * generates HTML for the Registration main meta box
2420
-     *
2421
-     * @return void
2422
-     * @throws DomainException
2423
-     * @throws EE_Error
2424
-     * @throws InvalidArgumentException
2425
-     * @throws InvalidDataTypeException
2426
-     * @throws InvalidInterfaceException
2427
-     * @throws ReflectionException
2428
-     */
2429
-    public function _reg_attendees_meta_box()
2430
-    {
2431
-        $REG = $this->getRegistrationModel();
2432
-        // get all other registrations on this transaction, and cache
2433
-        // the attendees for them so we don't have to run another query using force_join
2434
-        $registrations                           = $REG->get_all(
2435
-            [
2436
-                [
2437
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2438
-                    'REG_ID' => ['!=', $this->_registration->ID()],
2439
-                ],
2440
-                'force_join'               => ['Attendee'],
2441
-                'default_where_conditions' => 'other_models_only',
2442
-            ]
2443
-        );
2444
-        $this->_template_args['attendees']       = [];
2445
-        $this->_template_args['attendee_notice'] = '';
2446
-        if (
2447
-            empty($registrations)
2448
-            || (is_array($registrations)
2449
-                && ! EEH_Array::get_one_item_from_array($registrations))
2450
-        ) {
2451
-            EE_Error::add_error(
2452
-                esc_html__(
2453
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2454
-                    'event_espresso'
2455
-                ),
2456
-                __FILE__,
2457
-                __FUNCTION__,
2458
-                __LINE__
2459
-            );
2460
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2461
-        } else {
2462
-            $att_nmbr = 1;
2463
-            foreach ($registrations as $registration) {
2464
-                /* @var $registration EE_Registration */
2465
-                $attendee                                                      = $registration->attendee()
2466
-                    ? $registration->attendee()
2467
-                    : $this->getAttendeeModel()->create_default_object();
2468
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2469
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2470
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2471
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2472
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2473
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2474
-                    ', ',
2475
-                    $attendee->full_address_as_array()
2476
-                );
2477
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2478
-                    [
2479
-                        'action' => 'edit_attendee',
2480
-                        'post'   => $attendee->ID(),
2481
-                    ],
2482
-                    REG_ADMIN_URL
2483
-                );
2484
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2485
-                    $registration->event_obj() instanceof EE_Event
2486
-                        ? $registration->event_obj()->name()
2487
-                        : '';
2488
-                $att_nmbr++;
2489
-            }
2490
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2491
-        }
2492
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2493
-        EEH_Template::display_template($template_path, $this->_template_args);
2494
-    }
2495
-
2496
-
2497
-    /**
2498
-     * generates HTML for the Edit Registration side meta box
2499
-     *
2500
-     * @return void
2501
-     * @throws DomainException
2502
-     * @throws EE_Error
2503
-     * @throws InvalidArgumentException
2504
-     * @throws InvalidDataTypeException
2505
-     * @throws InvalidInterfaceException
2506
-     * @throws ReflectionException
2507
-     */
2508
-    public function _reg_registrant_side_meta_box()
2509
-    {
2510
-        /*@var $attendee EE_Attendee */
2511
-        $att_check = $this->_registration->attendee();
2512
-        $attendee  = $att_check instanceof EE_Attendee
2513
-            ? $att_check
2514
-            : $this->getAttendeeModel()->create_default_object();
2515
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2516
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2517
-        // primary registration object (that way we know if we need to show create button or not)
2518
-        if (! $this->_registration->is_primary_registrant()) {
2519
-            $primary_registration = $this->_registration->get_primary_registration();
2520
-            $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2521
-                : null;
2522
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2523
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2524
-                // custom attendee object so let's not worry about the primary reg.
2525
-                $primary_registration = null;
2526
-            }
2527
-        } else {
2528
-            $primary_registration = null;
2529
-        }
2530
-        $this->_template_args['ATT_ID']            = $attendee->ID();
2531
-        $this->_template_args['fname']             = $attendee->fname();
2532
-        $this->_template_args['lname']             = $attendee->lname();
2533
-        $this->_template_args['email']             = $attendee->email();
2534
-        $this->_template_args['phone']             = $attendee->phone();
2535
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2536
-        // edit link
2537
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2538
-            [
2539
-                'action' => 'edit_attendee',
2540
-                'post'   => $attendee->ID(),
2541
-            ],
2542
-            REG_ADMIN_URL
2543
-        );
2544
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2545
-        // create link
2546
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2547
-            ? EE_Admin_Page::add_query_args_and_nonce(
2548
-                [
2549
-                    'action'  => 'duplicate_attendee',
2550
-                    '_REG_ID' => $this->_registration->ID(),
2551
-                ],
2552
-                REG_ADMIN_URL
2553
-            ) : '';
2554
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2555
-        $this->_template_args['att_check']    = $att_check;
2556
-        $template_path                        =
2557
-            REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2558
-        EEH_Template::display_template($template_path, $this->_template_args);
2559
-    }
2560
-
2561
-
2562
-    /**
2563
-     * trash or restore registrations
2564
-     *
2565
-     * @param boolean $trash whether to archive or restore
2566
-     * @return void
2567
-     * @throws EE_Error
2568
-     * @throws InvalidArgumentException
2569
-     * @throws InvalidDataTypeException
2570
-     * @throws InvalidInterfaceException
2571
-     * @throws RuntimeException
2572
-     */
2573
-    protected function _trash_or_restore_registrations($trash = true)
2574
-    {
2575
-        // if empty _REG_ID then get out because there's nothing to do
2576
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2577
-        if (empty($REG_IDs)) {
2578
-            EE_Error::add_error(
2579
-                sprintf(
2580
-                    esc_html__(
2581
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2582
-                        'event_espresso'
2583
-                    ),
2584
-                    $trash ? 'trash' : 'restore'
2585
-                ),
2586
-                __FILE__,
2587
-                __LINE__,
2588
-                __FUNCTION__
2589
-            );
2590
-            $this->_redirect_after_action(false, '', '', [], true);
2591
-        }
2592
-        $success        = 0;
2593
-        $overwrite_msgs = false;
2594
-        // Checkboxes
2595
-        $reg_count = count($REG_IDs);
2596
-        // cycle thru checkboxes
2597
-        foreach ($REG_IDs as $REG_ID) {
2598
-            /** @var EE_Registration $REG */
2599
-            $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2600
-            $payments = $REG->registration_payments();
2601
-            if (! empty($payments)) {
2602
-                $name           = $REG->attendee() instanceof EE_Attendee
2603
-                    ? $REG->attendee()->full_name()
2604
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2605
-                $overwrite_msgs = true;
2606
-                EE_Error::add_error(
2607
-                    sprintf(
2608
-                        esc_html__(
2609
-                            '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.',
2610
-                            'event_espresso'
2611
-                        ),
2612
-                        $name
2613
-                    ),
2614
-                    __FILE__,
2615
-                    __FUNCTION__,
2616
-                    __LINE__
2617
-                );
2618
-                // can't trash this registration because it has payments.
2619
-                continue;
2620
-            }
2621
-            $updated = $trash ? $REG->delete() : $REG->restore();
2622
-            if ($updated) {
2623
-                $success++;
2624
-            }
2625
-        }
2626
-        $this->_redirect_after_action(
2627
-            $success === $reg_count, // were ALL registrations affected?
2628
-            $success > 1
2629
-                ? esc_html__('Registrations', 'event_espresso')
2630
-                : esc_html__('Registration', 'event_espresso'),
2631
-            $trash
2632
-                ? esc_html__('moved to the trash', 'event_espresso')
2633
-                : esc_html__('restored', 'event_espresso'),
2634
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2635
-            $overwrite_msgs
2636
-        );
2637
-    }
2638
-
2639
-
2640
-    /**
2641
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2642
-     * registration but also.
2643
-     * 1. Removing relations to EE_Attendee
2644
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2645
-     * ALSO trashed.
2646
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2647
-     * 4. Removing relationships between all tickets and the related registrations
2648
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2649
-     * 6. Deleting permanently any related Checkins.
2650
-     *
2651
-     * @return void
2652
-     * @throws EE_Error
2653
-     * @throws InvalidArgumentException
2654
-     * @throws InvalidDataTypeException
2655
-     * @throws InvalidInterfaceException
2656
-     * @throws ReflectionException
2657
-     */
2658
-    protected function _delete_registrations()
2659
-    {
2660
-        $REG_MDL = $this->getRegistrationModel();
2661
-        $success = 0;
2662
-        // Checkboxes
2663
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2664
-
2665
-        if (! empty($REG_IDs)) {
2666
-            // if array has more than one element than success message should be plural
2667
-            $success = count($REG_IDs) > 1 ? 2 : 1;
2668
-            // cycle thru checkboxes
2669
-            foreach ($REG_IDs as $REG_ID) {
2670
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2671
-                if (! $REG instanceof EE_Registration) {
2672
-                    continue;
2673
-                }
2674
-                $deleted = $this->_delete_registration($REG);
2675
-                if (! $deleted) {
2676
-                    $success = 0;
2677
-                }
2678
-            }
2679
-        }
2680
-
2681
-        $what        = $success > 1
2682
-            ? esc_html__('Registrations', 'event_espresso')
2683
-            : esc_html__('Registration', 'event_espresso');
2684
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2685
-        $this->_redirect_after_action(
2686
-            $success,
2687
-            $what,
2688
-            $action_desc,
2689
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2690
-            true
2691
-        );
2692
-    }
2693
-
2694
-
2695
-    /**
2696
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2697
-     * models get affected.
2698
-     *
2699
-     * @param EE_Registration $REG registration to be deleted permanently
2700
-     * @return bool true = successful deletion, false = fail.
2701
-     * @throws EE_Error
2702
-     * @throws InvalidArgumentException
2703
-     * @throws InvalidDataTypeException
2704
-     * @throws InvalidInterfaceException
2705
-     * @throws ReflectionException
2706
-     */
2707
-    protected function _delete_registration(EE_Registration $REG)
2708
-    {
2709
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2710
-        // registrations on the transaction that are NOT trashed.
2711
-        $TXN = $REG->get_first_related('Transaction');
2712
-        if (! $TXN instanceof EE_Transaction) {
2713
-            EE_Error::add_error(
2714
-                sprintf(
2715
-                    esc_html__(
2716
-                        '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.',
2717
-                        'event_espresso'
2718
-                    ),
2719
-                    $REG->id()
2720
-                ),
2721
-                __FILE__,
2722
-                __FUNCTION__,
2723
-                __LINE__
2724
-            );
2725
-            return false;
2726
-        }
2727
-        $REGS        = $TXN->get_many_related('Registration');
2728
-        $all_trashed = true;
2729
-        foreach ($REGS as $registration) {
2730
-            if (! $registration->get('REG_deleted')) {
2731
-                $all_trashed = false;
2732
-            }
2733
-        }
2734
-        if (! $all_trashed) {
2735
-            EE_Error::add_error(
2736
-                esc_html__(
2737
-                    '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.',
2738
-                    'event_espresso'
2739
-                ),
2740
-                __FILE__,
2741
-                __FUNCTION__,
2742
-                __LINE__
2743
-            );
2744
-            return false;
2745
-        }
2746
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2747
-        // separately from THIS one).
2748
-        foreach ($REGS as $registration) {
2749
-            // delete related answers
2750
-            $registration->delete_related_permanently('Answer');
2751
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2752
-            $attendee = $registration->get_first_related('Attendee');
2753
-            if ($attendee instanceof EE_Attendee) {
2754
-                $registration->_remove_relation_to($attendee, 'Attendee');
2755
-            }
2756
-            // now remove relationships to tickets on this registration.
2757
-            $registration->_remove_relations('Ticket');
2758
-            // now delete permanently the checkins related to this registration.
2759
-            $registration->delete_related_permanently('Checkin');
2760
-            if ($registration->ID() === $REG->ID()) {
2761
-                continue;
2762
-            } //we don't want to delete permanently the existing registration just yet.
2763
-            // remove relation to transaction for these registrations if NOT the existing registrations
2764
-            $registration->_remove_relations('Transaction');
2765
-            // delete permanently any related messages.
2766
-            $registration->delete_related_permanently('Message');
2767
-            // now delete this registration permanently
2768
-            $registration->delete_permanently();
2769
-        }
2770
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2771
-        // (the transaction and line items should be all that's left).
2772
-        // delete the line items related to the transaction for this registration.
2773
-        $TXN->delete_related_permanently('Line_Item');
2774
-        // we need to remove all the relationships on the transaction
2775
-        $TXN->delete_related_permanently('Payment');
2776
-        $TXN->delete_related_permanently('Extra_Meta');
2777
-        $TXN->delete_related_permanently('Message');
2778
-        // now we can delete this REG permanently (and the transaction of course)
2779
-        $REG->delete_related_permanently('Transaction');
2780
-        return $REG->delete_permanently();
2781
-    }
2782
-
2783
-
2784
-    /**
2785
-     *    generates HTML for the Register New Attendee Admin page
2786
-     *
2787
-     * @throws DomainException
2788
-     * @throws EE_Error
2789
-     * @throws InvalidArgumentException
2790
-     * @throws InvalidDataTypeException
2791
-     * @throws InvalidInterfaceException
2792
-     * @throws ReflectionException
2793
-     */
2794
-    public function new_registration()
2795
-    {
2796
-        if (! $this->_set_reg_event()) {
2797
-            throw new EE_Error(
2798
-                esc_html__(
2799
-                    'Unable to continue with registering because there is no Event ID in the request',
2800
-                    'event_espresso'
2801
-                )
2802
-            );
2803
-        }
2804
-        /** @var CurrentPage $current_page */
2805
-        $current_page = $this->loader->getShared(CurrentPage::class);
2806
-        $current_page->setEspressoPage(true);
2807
-        // gotta start with a clean slate if we're not coming here via ajax
2808
-        if (
2809
-            ! $this->request->isAjax()
2810
-            && (
2811
-                ! $this->request->requestParamIsSet('processing_registration')
2812
-                || $this->request->requestParamIsSet('step_error')
2813
-            )
2814
-        ) {
2815
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2816
-        }
2817
-        $this->_template_args['event_name'] = '';
2818
-        // event name
2819
-        if ($this->_reg_event) {
2820
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2821
-            $edit_event_url                     = self::add_query_args_and_nonce(
2822
-                [
2823
-                    'action' => 'edit',
2824
-                    'post'   => $this->_reg_event->ID(),
2825
-                ],
2826
-                EVENTS_ADMIN_URL
2827
-            );
2828
-            $edit_event_lnk                     = '<a href="'
2829
-                                                  . $edit_event_url
2830
-                                                  . '" title="'
2831
-                                                  . esc_attr__('Edit ', 'event_espresso')
2832
-                                                  . $this->_reg_event->name()
2833
-                                                  . '">'
2834
-                                                  . esc_html__('Edit Event', 'event_espresso')
2835
-                                                  . '</a>';
2836
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2837
-                                                   . $edit_event_lnk
2838
-                                                   . '</span>';
2839
-        }
2840
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2841
-        if ($this->request->isAjax()) {
2842
-            $this->_return_json();
2843
-        }
2844
-        // grab header
2845
-        $template_path                              =
2846
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2847
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2848
-            $template_path,
2849
-            $this->_template_args,
2850
-            true
2851
-        );
2852
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2853
-        // the details template wrapper
2854
-        $this->display_admin_page_with_sidebar();
2855
-    }
2856
-
2857
-
2858
-    /**
2859
-     * This returns the content for a registration step
2860
-     *
2861
-     * @return string html
2862
-     * @throws DomainException
2863
-     * @throws EE_Error
2864
-     * @throws InvalidArgumentException
2865
-     * @throws InvalidDataTypeException
2866
-     * @throws InvalidInterfaceException
2867
-     * @throws ReflectionException
2868
-     */
2869
-    protected function _get_registration_step_content()
2870
-    {
2871
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2872
-            $warning_msg = sprintf(
2873
-                esc_html__(
2874
-                    '%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',
2875
-                    'event_espresso'
2876
-                ),
2877
-                '<br />',
2878
-                '<h3 class="important-notice">',
2879
-                '</h3>',
2880
-                '<div class="float-right">',
2881
-                '<span id="redirect_timer" class="important-notice">30</span>',
2882
-                '</div>',
2883
-                '<b>',
2884
-                '</b>'
2885
-            );
2886
-            return '
2306
+	}
2307
+
2308
+
2309
+	/**
2310
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2311
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2312
+	 * to display the page
2313
+	 *
2314
+	 * @return void
2315
+	 * @throws EE_Error
2316
+	 * @throws InvalidArgumentException
2317
+	 * @throws InvalidDataTypeException
2318
+	 * @throws InvalidInterfaceException
2319
+	 * @throws ReflectionException
2320
+	 */
2321
+	protected function _update_attendee_registration_form()
2322
+	{
2323
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2324
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2325
+			$REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2326
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2327
+			if ($success) {
2328
+				$what  = esc_html__('Registration Form', 'event_espresso');
2329
+				$route = $REG_ID
2330
+					? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2331
+					: ['action' => 'default'];
2332
+				$this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2333
+			}
2334
+		}
2335
+	}
2336
+
2337
+
2338
+	/**
2339
+	 * Gets the form for saving registrations custom questions (if done
2340
+	 * previously retrieves the cached form object, which may have validation errors in it)
2341
+	 *
2342
+	 * @param int $REG_ID
2343
+	 * @return EE_Registration_Custom_Questions_Form
2344
+	 * @throws EE_Error
2345
+	 * @throws InvalidArgumentException
2346
+	 * @throws InvalidDataTypeException
2347
+	 * @throws InvalidInterfaceException
2348
+	 * @throws ReflectionException
2349
+	 */
2350
+	protected function _get_reg_custom_questions_form($REG_ID)
2351
+	{
2352
+		if (! $this->_reg_custom_questions_form) {
2353
+			require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2354
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2355
+				$this->getRegistrationModel()->get_one_by_ID($REG_ID)
2356
+			);
2357
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2358
+		}
2359
+		return $this->_reg_custom_questions_form;
2360
+	}
2361
+
2362
+
2363
+	/**
2364
+	 * Saves
2365
+	 *
2366
+	 * @param bool $REG_ID
2367
+	 * @return bool
2368
+	 * @throws EE_Error
2369
+	 * @throws InvalidArgumentException
2370
+	 * @throws InvalidDataTypeException
2371
+	 * @throws InvalidInterfaceException
2372
+	 * @throws ReflectionException
2373
+	 */
2374
+	private function _save_reg_custom_questions_form($REG_ID = 0)
2375
+	{
2376
+		if (! $REG_ID) {
2377
+			EE_Error::add_error(
2378
+				esc_html__(
2379
+					'An error occurred. No registration ID was received.',
2380
+					'event_espresso'
2381
+				),
2382
+				__FILE__,
2383
+				__FUNCTION__,
2384
+				__LINE__
2385
+			);
2386
+		}
2387
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2388
+		$form->receive_form_submission($this->request->requestParams());
2389
+		$success = false;
2390
+		if ($form->is_valid()) {
2391
+			foreach ($form->subforms() as $question_group_form) {
2392
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2393
+					$where_conditions    = [
2394
+						'QST_ID' => $question_id,
2395
+						'REG_ID' => $REG_ID,
2396
+					];
2397
+					$possibly_new_values = [
2398
+						'ANS_value' => $input->normalized_value(),
2399
+					];
2400
+					$answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2401
+					if ($answer instanceof EE_Answer) {
2402
+						$success = $answer->save($possibly_new_values);
2403
+					} else {
2404
+						// insert it then
2405
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2406
+						$answer      = EE_Answer::new_instance($cols_n_vals);
2407
+						$success     = $answer->save();
2408
+					}
2409
+				}
2410
+			}
2411
+		} else {
2412
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2413
+		}
2414
+		return $success;
2415
+	}
2416
+
2417
+
2418
+	/**
2419
+	 * generates HTML for the Registration main meta box
2420
+	 *
2421
+	 * @return void
2422
+	 * @throws DomainException
2423
+	 * @throws EE_Error
2424
+	 * @throws InvalidArgumentException
2425
+	 * @throws InvalidDataTypeException
2426
+	 * @throws InvalidInterfaceException
2427
+	 * @throws ReflectionException
2428
+	 */
2429
+	public function _reg_attendees_meta_box()
2430
+	{
2431
+		$REG = $this->getRegistrationModel();
2432
+		// get all other registrations on this transaction, and cache
2433
+		// the attendees for them so we don't have to run another query using force_join
2434
+		$registrations                           = $REG->get_all(
2435
+			[
2436
+				[
2437
+					'TXN_ID' => $this->_registration->transaction_ID(),
2438
+					'REG_ID' => ['!=', $this->_registration->ID()],
2439
+				],
2440
+				'force_join'               => ['Attendee'],
2441
+				'default_where_conditions' => 'other_models_only',
2442
+			]
2443
+		);
2444
+		$this->_template_args['attendees']       = [];
2445
+		$this->_template_args['attendee_notice'] = '';
2446
+		if (
2447
+			empty($registrations)
2448
+			|| (is_array($registrations)
2449
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2450
+		) {
2451
+			EE_Error::add_error(
2452
+				esc_html__(
2453
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2454
+					'event_espresso'
2455
+				),
2456
+				__FILE__,
2457
+				__FUNCTION__,
2458
+				__LINE__
2459
+			);
2460
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2461
+		} else {
2462
+			$att_nmbr = 1;
2463
+			foreach ($registrations as $registration) {
2464
+				/* @var $registration EE_Registration */
2465
+				$attendee                                                      = $registration->attendee()
2466
+					? $registration->attendee()
2467
+					: $this->getAttendeeModel()->create_default_object();
2468
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2469
+				$this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2470
+				$this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2471
+				$this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2472
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2473
+				$this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2474
+					', ',
2475
+					$attendee->full_address_as_array()
2476
+				);
2477
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2478
+					[
2479
+						'action' => 'edit_attendee',
2480
+						'post'   => $attendee->ID(),
2481
+					],
2482
+					REG_ADMIN_URL
2483
+				);
2484
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2485
+					$registration->event_obj() instanceof EE_Event
2486
+						? $registration->event_obj()->name()
2487
+						: '';
2488
+				$att_nmbr++;
2489
+			}
2490
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2491
+		}
2492
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2493
+		EEH_Template::display_template($template_path, $this->_template_args);
2494
+	}
2495
+
2496
+
2497
+	/**
2498
+	 * generates HTML for the Edit Registration side meta box
2499
+	 *
2500
+	 * @return void
2501
+	 * @throws DomainException
2502
+	 * @throws EE_Error
2503
+	 * @throws InvalidArgumentException
2504
+	 * @throws InvalidDataTypeException
2505
+	 * @throws InvalidInterfaceException
2506
+	 * @throws ReflectionException
2507
+	 */
2508
+	public function _reg_registrant_side_meta_box()
2509
+	{
2510
+		/*@var $attendee EE_Attendee */
2511
+		$att_check = $this->_registration->attendee();
2512
+		$attendee  = $att_check instanceof EE_Attendee
2513
+			? $att_check
2514
+			: $this->getAttendeeModel()->create_default_object();
2515
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2516
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2517
+		// primary registration object (that way we know if we need to show create button or not)
2518
+		if (! $this->_registration->is_primary_registrant()) {
2519
+			$primary_registration = $this->_registration->get_primary_registration();
2520
+			$primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2521
+				: null;
2522
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2523
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2524
+				// custom attendee object so let's not worry about the primary reg.
2525
+				$primary_registration = null;
2526
+			}
2527
+		} else {
2528
+			$primary_registration = null;
2529
+		}
2530
+		$this->_template_args['ATT_ID']            = $attendee->ID();
2531
+		$this->_template_args['fname']             = $attendee->fname();
2532
+		$this->_template_args['lname']             = $attendee->lname();
2533
+		$this->_template_args['email']             = $attendee->email();
2534
+		$this->_template_args['phone']             = $attendee->phone();
2535
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2536
+		// edit link
2537
+		$this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2538
+			[
2539
+				'action' => 'edit_attendee',
2540
+				'post'   => $attendee->ID(),
2541
+			],
2542
+			REG_ADMIN_URL
2543
+		);
2544
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2545
+		// create link
2546
+		$this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2547
+			? EE_Admin_Page::add_query_args_and_nonce(
2548
+				[
2549
+					'action'  => 'duplicate_attendee',
2550
+					'_REG_ID' => $this->_registration->ID(),
2551
+				],
2552
+				REG_ADMIN_URL
2553
+			) : '';
2554
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2555
+		$this->_template_args['att_check']    = $att_check;
2556
+		$template_path                        =
2557
+			REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2558
+		EEH_Template::display_template($template_path, $this->_template_args);
2559
+	}
2560
+
2561
+
2562
+	/**
2563
+	 * trash or restore registrations
2564
+	 *
2565
+	 * @param boolean $trash whether to archive or restore
2566
+	 * @return void
2567
+	 * @throws EE_Error
2568
+	 * @throws InvalidArgumentException
2569
+	 * @throws InvalidDataTypeException
2570
+	 * @throws InvalidInterfaceException
2571
+	 * @throws RuntimeException
2572
+	 */
2573
+	protected function _trash_or_restore_registrations($trash = true)
2574
+	{
2575
+		// if empty _REG_ID then get out because there's nothing to do
2576
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2577
+		if (empty($REG_IDs)) {
2578
+			EE_Error::add_error(
2579
+				sprintf(
2580
+					esc_html__(
2581
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2582
+						'event_espresso'
2583
+					),
2584
+					$trash ? 'trash' : 'restore'
2585
+				),
2586
+				__FILE__,
2587
+				__LINE__,
2588
+				__FUNCTION__
2589
+			);
2590
+			$this->_redirect_after_action(false, '', '', [], true);
2591
+		}
2592
+		$success        = 0;
2593
+		$overwrite_msgs = false;
2594
+		// Checkboxes
2595
+		$reg_count = count($REG_IDs);
2596
+		// cycle thru checkboxes
2597
+		foreach ($REG_IDs as $REG_ID) {
2598
+			/** @var EE_Registration $REG */
2599
+			$REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2600
+			$payments = $REG->registration_payments();
2601
+			if (! empty($payments)) {
2602
+				$name           = $REG->attendee() instanceof EE_Attendee
2603
+					? $REG->attendee()->full_name()
2604
+					: esc_html__('Unknown Attendee', 'event_espresso');
2605
+				$overwrite_msgs = true;
2606
+				EE_Error::add_error(
2607
+					sprintf(
2608
+						esc_html__(
2609
+							'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.',
2610
+							'event_espresso'
2611
+						),
2612
+						$name
2613
+					),
2614
+					__FILE__,
2615
+					__FUNCTION__,
2616
+					__LINE__
2617
+				);
2618
+				// can't trash this registration because it has payments.
2619
+				continue;
2620
+			}
2621
+			$updated = $trash ? $REG->delete() : $REG->restore();
2622
+			if ($updated) {
2623
+				$success++;
2624
+			}
2625
+		}
2626
+		$this->_redirect_after_action(
2627
+			$success === $reg_count, // were ALL registrations affected?
2628
+			$success > 1
2629
+				? esc_html__('Registrations', 'event_espresso')
2630
+				: esc_html__('Registration', 'event_espresso'),
2631
+			$trash
2632
+				? esc_html__('moved to the trash', 'event_espresso')
2633
+				: esc_html__('restored', 'event_espresso'),
2634
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2635
+			$overwrite_msgs
2636
+		);
2637
+	}
2638
+
2639
+
2640
+	/**
2641
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2642
+	 * registration but also.
2643
+	 * 1. Removing relations to EE_Attendee
2644
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2645
+	 * ALSO trashed.
2646
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2647
+	 * 4. Removing relationships between all tickets and the related registrations
2648
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2649
+	 * 6. Deleting permanently any related Checkins.
2650
+	 *
2651
+	 * @return void
2652
+	 * @throws EE_Error
2653
+	 * @throws InvalidArgumentException
2654
+	 * @throws InvalidDataTypeException
2655
+	 * @throws InvalidInterfaceException
2656
+	 * @throws ReflectionException
2657
+	 */
2658
+	protected function _delete_registrations()
2659
+	{
2660
+		$REG_MDL = $this->getRegistrationModel();
2661
+		$success = 0;
2662
+		// Checkboxes
2663
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2664
+
2665
+		if (! empty($REG_IDs)) {
2666
+			// if array has more than one element than success message should be plural
2667
+			$success = count($REG_IDs) > 1 ? 2 : 1;
2668
+			// cycle thru checkboxes
2669
+			foreach ($REG_IDs as $REG_ID) {
2670
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2671
+				if (! $REG instanceof EE_Registration) {
2672
+					continue;
2673
+				}
2674
+				$deleted = $this->_delete_registration($REG);
2675
+				if (! $deleted) {
2676
+					$success = 0;
2677
+				}
2678
+			}
2679
+		}
2680
+
2681
+		$what        = $success > 1
2682
+			? esc_html__('Registrations', 'event_espresso')
2683
+			: esc_html__('Registration', 'event_espresso');
2684
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2685
+		$this->_redirect_after_action(
2686
+			$success,
2687
+			$what,
2688
+			$action_desc,
2689
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2690
+			true
2691
+		);
2692
+	}
2693
+
2694
+
2695
+	/**
2696
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2697
+	 * models get affected.
2698
+	 *
2699
+	 * @param EE_Registration $REG registration to be deleted permanently
2700
+	 * @return bool true = successful deletion, false = fail.
2701
+	 * @throws EE_Error
2702
+	 * @throws InvalidArgumentException
2703
+	 * @throws InvalidDataTypeException
2704
+	 * @throws InvalidInterfaceException
2705
+	 * @throws ReflectionException
2706
+	 */
2707
+	protected function _delete_registration(EE_Registration $REG)
2708
+	{
2709
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2710
+		// registrations on the transaction that are NOT trashed.
2711
+		$TXN = $REG->get_first_related('Transaction');
2712
+		if (! $TXN instanceof EE_Transaction) {
2713
+			EE_Error::add_error(
2714
+				sprintf(
2715
+					esc_html__(
2716
+						'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.',
2717
+						'event_espresso'
2718
+					),
2719
+					$REG->id()
2720
+				),
2721
+				__FILE__,
2722
+				__FUNCTION__,
2723
+				__LINE__
2724
+			);
2725
+			return false;
2726
+		}
2727
+		$REGS        = $TXN->get_many_related('Registration');
2728
+		$all_trashed = true;
2729
+		foreach ($REGS as $registration) {
2730
+			if (! $registration->get('REG_deleted')) {
2731
+				$all_trashed = false;
2732
+			}
2733
+		}
2734
+		if (! $all_trashed) {
2735
+			EE_Error::add_error(
2736
+				esc_html__(
2737
+					'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.',
2738
+					'event_espresso'
2739
+				),
2740
+				__FILE__,
2741
+				__FUNCTION__,
2742
+				__LINE__
2743
+			);
2744
+			return false;
2745
+		}
2746
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2747
+		// separately from THIS one).
2748
+		foreach ($REGS as $registration) {
2749
+			// delete related answers
2750
+			$registration->delete_related_permanently('Answer');
2751
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2752
+			$attendee = $registration->get_first_related('Attendee');
2753
+			if ($attendee instanceof EE_Attendee) {
2754
+				$registration->_remove_relation_to($attendee, 'Attendee');
2755
+			}
2756
+			// now remove relationships to tickets on this registration.
2757
+			$registration->_remove_relations('Ticket');
2758
+			// now delete permanently the checkins related to this registration.
2759
+			$registration->delete_related_permanently('Checkin');
2760
+			if ($registration->ID() === $REG->ID()) {
2761
+				continue;
2762
+			} //we don't want to delete permanently the existing registration just yet.
2763
+			// remove relation to transaction for these registrations if NOT the existing registrations
2764
+			$registration->_remove_relations('Transaction');
2765
+			// delete permanently any related messages.
2766
+			$registration->delete_related_permanently('Message');
2767
+			// now delete this registration permanently
2768
+			$registration->delete_permanently();
2769
+		}
2770
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2771
+		// (the transaction and line items should be all that's left).
2772
+		// delete the line items related to the transaction for this registration.
2773
+		$TXN->delete_related_permanently('Line_Item');
2774
+		// we need to remove all the relationships on the transaction
2775
+		$TXN->delete_related_permanently('Payment');
2776
+		$TXN->delete_related_permanently('Extra_Meta');
2777
+		$TXN->delete_related_permanently('Message');
2778
+		// now we can delete this REG permanently (and the transaction of course)
2779
+		$REG->delete_related_permanently('Transaction');
2780
+		return $REG->delete_permanently();
2781
+	}
2782
+
2783
+
2784
+	/**
2785
+	 *    generates HTML for the Register New Attendee Admin page
2786
+	 *
2787
+	 * @throws DomainException
2788
+	 * @throws EE_Error
2789
+	 * @throws InvalidArgumentException
2790
+	 * @throws InvalidDataTypeException
2791
+	 * @throws InvalidInterfaceException
2792
+	 * @throws ReflectionException
2793
+	 */
2794
+	public function new_registration()
2795
+	{
2796
+		if (! $this->_set_reg_event()) {
2797
+			throw new EE_Error(
2798
+				esc_html__(
2799
+					'Unable to continue with registering because there is no Event ID in the request',
2800
+					'event_espresso'
2801
+				)
2802
+			);
2803
+		}
2804
+		/** @var CurrentPage $current_page */
2805
+		$current_page = $this->loader->getShared(CurrentPage::class);
2806
+		$current_page->setEspressoPage(true);
2807
+		// gotta start with a clean slate if we're not coming here via ajax
2808
+		if (
2809
+			! $this->request->isAjax()
2810
+			&& (
2811
+				! $this->request->requestParamIsSet('processing_registration')
2812
+				|| $this->request->requestParamIsSet('step_error')
2813
+			)
2814
+		) {
2815
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2816
+		}
2817
+		$this->_template_args['event_name'] = '';
2818
+		// event name
2819
+		if ($this->_reg_event) {
2820
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2821
+			$edit_event_url                     = self::add_query_args_and_nonce(
2822
+				[
2823
+					'action' => 'edit',
2824
+					'post'   => $this->_reg_event->ID(),
2825
+				],
2826
+				EVENTS_ADMIN_URL
2827
+			);
2828
+			$edit_event_lnk                     = '<a href="'
2829
+												  . $edit_event_url
2830
+												  . '" title="'
2831
+												  . esc_attr__('Edit ', 'event_espresso')
2832
+												  . $this->_reg_event->name()
2833
+												  . '">'
2834
+												  . esc_html__('Edit Event', 'event_espresso')
2835
+												  . '</a>';
2836
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2837
+												   . $edit_event_lnk
2838
+												   . '</span>';
2839
+		}
2840
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2841
+		if ($this->request->isAjax()) {
2842
+			$this->_return_json();
2843
+		}
2844
+		// grab header
2845
+		$template_path                              =
2846
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2847
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2848
+			$template_path,
2849
+			$this->_template_args,
2850
+			true
2851
+		);
2852
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2853
+		// the details template wrapper
2854
+		$this->display_admin_page_with_sidebar();
2855
+	}
2856
+
2857
+
2858
+	/**
2859
+	 * This returns the content for a registration step
2860
+	 *
2861
+	 * @return string html
2862
+	 * @throws DomainException
2863
+	 * @throws EE_Error
2864
+	 * @throws InvalidArgumentException
2865
+	 * @throws InvalidDataTypeException
2866
+	 * @throws InvalidInterfaceException
2867
+	 * @throws ReflectionException
2868
+	 */
2869
+	protected function _get_registration_step_content()
2870
+	{
2871
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2872
+			$warning_msg = sprintf(
2873
+				esc_html__(
2874
+					'%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',
2875
+					'event_espresso'
2876
+				),
2877
+				'<br />',
2878
+				'<h3 class="important-notice">',
2879
+				'</h3>',
2880
+				'<div class="float-right">',
2881
+				'<span id="redirect_timer" class="important-notice">30</span>',
2882
+				'</div>',
2883
+				'<b>',
2884
+				'</b>'
2885
+			);
2886
+			return '
2887 2887
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2888 2888
 	<script >
2889 2889
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -2896,847 +2896,847 @@  discard block
 block discarded – undo
2896 2896
 	        }
2897 2897
 	    }, 800 );
2898 2898
 	</script >';
2899
-        }
2900
-        $template_args = [
2901
-            'title'                    => '',
2902
-            'content'                  => '',
2903
-            'step_button_text'         => '',
2904
-            'show_notification_toggle' => false,
2905
-        ];
2906
-        // to indicate we're processing a new registration
2907
-        $hidden_fields = [
2908
-            'processing_registration' => [
2909
-                'type'  => 'hidden',
2910
-                'value' => 0,
2911
-            ],
2912
-            'event_id'                => [
2913
-                'type'  => 'hidden',
2914
-                'value' => $this->_reg_event->ID(),
2915
-            ],
2916
-        ];
2917
-        // if the cart is empty then we know we're at step one, so we'll display the ticket selector
2918
-        $cart = EE_Registry::instance()->SSN->cart();
2919
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2920
-        switch ($step) {
2921
-            case 'ticket':
2922
-                $hidden_fields['processing_registration']['value'] = 1;
2923
-                $template_args['title']                            = esc_html__(
2924
-                    'Step One: Select the Ticket for this registration',
2925
-                    'event_espresso'
2926
-                );
2927
-                $template_args['content']                          =
2928
-                    EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2929
-                $template_args['content']                          .= '</div>';
2930
-                $template_args['step_button_text']                 = esc_html__(
2931
-                    'Add Tickets and Continue to Registrant Details',
2932
-                    'event_espresso'
2933
-                );
2934
-                $template_args['show_notification_toggle']         = false;
2935
-                break;
2936
-            case 'questions':
2937
-                $hidden_fields['processing_registration']['value'] = 2;
2938
-                $template_args['title']                            = esc_html__(
2939
-                    'Step Two: Add Registrant Details for this Registration',
2940
-                    'event_espresso'
2941
-                );
2942
-                // in theory, we should be able to run EED_SPCO at this point
2943
-                // because the cart should have been set up properly by the first process_reg_step run.
2944
-                $template_args['content']                  =
2945
-                    EED_Single_Page_Checkout::registration_checkout_for_admin();
2946
-                $template_args['step_button_text']         = esc_html__(
2947
-                    'Save Registration and Continue to Details',
2948
-                    'event_espresso'
2949
-                );
2950
-                $template_args['show_notification_toggle'] = true;
2951
-                break;
2952
-        }
2953
-        // we come back to the process_registration_step route.
2954
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2955
-        return EEH_Template::display_template(
2956
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2957
-            $template_args,
2958
-            true
2959
-        );
2960
-    }
2961
-
2962
-
2963
-    /**
2964
-     * set_reg_event
2965
-     *
2966
-     * @return bool
2967
-     * @throws EE_Error
2968
-     * @throws InvalidArgumentException
2969
-     * @throws InvalidDataTypeException
2970
-     * @throws InvalidInterfaceException
2971
-     */
2972
-    private function _set_reg_event()
2973
-    {
2974
-        if (is_object($this->_reg_event)) {
2975
-            return true;
2976
-        }
2977
-
2978
-        $EVT_ID = $this->request->getRequestParam('event_id[reg_status]', 0, 'int');
2979
-        if (! $EVT_ID) {
2980
-            return false;
2981
-        }
2982
-        $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2983
-        return true;
2984
-    }
2985
-
2986
-
2987
-    /**
2988
-     * process_reg_step
2989
-     *
2990
-     * @return void
2991
-     * @throws DomainException
2992
-     * @throws EE_Error
2993
-     * @throws InvalidArgumentException
2994
-     * @throws InvalidDataTypeException
2995
-     * @throws InvalidInterfaceException
2996
-     * @throws ReflectionException
2997
-     * @throws RuntimeException
2998
-     */
2999
-    public function process_reg_step()
3000
-    {
3001
-        EE_System::do_not_cache();
3002
-        $this->_set_reg_event();
3003
-        /** @var CurrentPage $current_page */
3004
-        $current_page = $this->loader->getShared(CurrentPage::class);
3005
-        $current_page->setEspressoPage(true);
3006
-        $this->request->setRequestParam('uts', time());
3007
-        // what step are we on?
3008
-        $cart = EE_Registry::instance()->SSN->cart();
3009
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3010
-        // if doing ajax then we need to verify the nonce
3011
-        if ($this->request->isAjax()) {
3012
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
3013
-            $this->_verify_nonce($nonce, $this->_req_nonce);
3014
-        }
3015
-        switch ($step) {
3016
-            case 'ticket':
3017
-                // process ticket selection
3018
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
3019
-                if ($success) {
3020
-                    EE_Error::add_success(
3021
-                        esc_html__(
3022
-                            'Tickets Selected. Now complete the registration.',
3023
-                            'event_espresso'
3024
-                        )
3025
-                    );
3026
-                } else {
3027
-                    $this->request->setRequestParam('step_error', true);
3028
-                    $query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3029
-                }
3030
-                if ($this->request->isAjax()) {
3031
-                    $this->new_registration(); // display next step
3032
-                } else {
3033
-                    $query_args = [
3034
-                        'action'                  => 'new_registration',
3035
-                        'processing_registration' => 1,
3036
-                        'event_id'                => $this->_reg_event->ID(),
3037
-                        'uts'                     => time(),
3038
-                    ];
3039
-                    $this->_redirect_after_action(
3040
-                        false,
3041
-                        '',
3042
-                        '',
3043
-                        $query_args,
3044
-                        true
3045
-                    );
3046
-                }
3047
-                break;
3048
-            case 'questions':
3049
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3050
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3051
-                }
3052
-                // process registration
3053
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3054
-                if ($cart instanceof EE_Cart) {
3055
-                    $grand_total = $cart->get_grand_total();
3056
-                    if ($grand_total instanceof EE_Line_Item) {
3057
-                        $grand_total->save_this_and_descendants_to_txn();
3058
-                    }
3059
-                }
3060
-                if (! $transaction instanceof EE_Transaction) {
3061
-                    $query_args = [
3062
-                        'action'                  => 'new_registration',
3063
-                        'processing_registration' => 2,
3064
-                        'event_id'                => $this->_reg_event->ID(),
3065
-                        'uts'                     => time(),
3066
-                    ];
3067
-                    if ($this->request->isAjax()) {
3068
-                        // display registration form again because there are errors (maybe validation?)
3069
-                        $this->new_registration();
3070
-                        return;
3071
-                    }
3072
-                    $this->_redirect_after_action(
3073
-                        false,
3074
-                        '',
3075
-                        '',
3076
-                        $query_args,
3077
-                        true
3078
-                    );
3079
-                    return;
3080
-                }
3081
-                // maybe update status, and make sure to save transaction if not done already
3082
-                if (! $transaction->update_status_based_on_total_paid()) {
3083
-                    $transaction->save();
3084
-                }
3085
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3086
-                $query_args = [
3087
-                    'action'        => 'redirect_to_txn',
3088
-                    'TXN_ID'        => $transaction->ID(),
3089
-                    'EVT_ID'        => $this->_reg_event->ID(),
3090
-                    'event_name'    => urlencode($this->_reg_event->name()),
3091
-                    'redirect_from' => 'new_registration',
3092
-                ];
3093
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3094
-                break;
3095
-        }
3096
-        // what are you looking here for?  Should be nothing to do at this point.
3097
-    }
3098
-
3099
-
3100
-    /**
3101
-     * redirect_to_txn
3102
-     *
3103
-     * @return void
3104
-     * @throws EE_Error
3105
-     * @throws InvalidArgumentException
3106
-     * @throws InvalidDataTypeException
3107
-     * @throws InvalidInterfaceException
3108
-     * @throws ReflectionException
3109
-     */
3110
-    public function redirect_to_txn()
3111
-    {
3112
-        EE_System::do_not_cache();
3113
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3114
-        $query_args = [
3115
-            'action' => 'view_transaction',
3116
-            'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3117
-            'page'   => 'espresso_transactions',
3118
-        ];
3119
-        if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3120
-            $query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3121
-            $query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3122
-            $query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3123
-        }
3124
-        EE_Error::add_success(
3125
-            esc_html__(
3126
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3127
-                'event_espresso'
3128
-            )
3129
-        );
3130
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3131
-    }
3132
-
3133
-
3134
-    /**
3135
-     * generates HTML for the Attendee Contact List
3136
-     *
3137
-     * @return void
3138
-     * @throws DomainException
3139
-     * @throws EE_Error
3140
-     */
3141
-    protected function _attendee_contact_list_table()
3142
-    {
3143
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3144
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3145
-        $this->display_admin_list_table_page_with_no_sidebar();
3146
-    }
3147
-
3148
-
3149
-    /**
3150
-     * get_attendees
3151
-     *
3152
-     * @param      $per_page
3153
-     * @param bool $count whether to return count or data.
3154
-     * @param bool $trash
3155
-     * @return array|int
3156
-     * @throws EE_Error
3157
-     * @throws InvalidArgumentException
3158
-     * @throws InvalidDataTypeException
3159
-     * @throws InvalidInterfaceException
3160
-     */
3161
-    public function get_attendees($per_page, $count = false, $trash = false)
3162
-    {
3163
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3164
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3165
-        $orderby = $this->request->getRequestParam('orderby');
3166
-        switch ($orderby) {
3167
-            case 'ATT_ID':
3168
-            case 'ATT_fname':
3169
-            case 'ATT_email':
3170
-            case 'ATT_city':
3171
-            case 'STA_ID':
3172
-            case 'CNT_ID':
3173
-                break;
3174
-            case 'Registration_Count':
3175
-                $orderby = 'Registration_Count';
3176
-                break;
3177
-            default:
3178
-                $orderby = 'ATT_lname';
3179
-        }
3180
-        $sort         = $this->request->getRequestParam('order', 'ASC');
3181
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
3182
-        $per_page     = absint($per_page) ? $per_page : 10;
3183
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3184
-        $_where       = [];
3185
-        $search_term  = $this->request->getRequestParam('s');
3186
-        if ($search_term) {
3187
-            $search_term  = '%' . $search_term . '%';
3188
-            $_where['OR'] = [
3189
-                'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3190
-                'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3191
-                'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3192
-                'ATT_fname'                         => ['LIKE', $search_term],
3193
-                'ATT_lname'                         => ['LIKE', $search_term],
3194
-                'ATT_short_bio'                     => ['LIKE', $search_term],
3195
-                'ATT_email'                         => ['LIKE', $search_term],
3196
-                'ATT_address'                       => ['LIKE', $search_term],
3197
-                'ATT_address2'                      => ['LIKE', $search_term],
3198
-                'ATT_city'                          => ['LIKE', $search_term],
3199
-                'Country.CNT_name'                  => ['LIKE', $search_term],
3200
-                'State.STA_name'                    => ['LIKE', $search_term],
3201
-                'ATT_phone'                         => ['LIKE', $search_term],
3202
-                'Registration.REG_final_price'      => ['LIKE', $search_term],
3203
-                'Registration.REG_code'             => ['LIKE', $search_term],
3204
-                'Registration.REG_group_size'       => ['LIKE', $search_term],
3205
-            ];
3206
-        }
3207
-        $offset     = ($current_page - 1) * $per_page;
3208
-        $limit      = $count ? null : [$offset, $per_page];
3209
-        $query_args = [
3210
-            $_where,
3211
-            'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3212
-            'limit'         => $limit,
3213
-        ];
3214
-        if (! $count) {
3215
-            $query_args['order_by'] = [$orderby => $sort];
3216
-        }
3217
-        $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3218
-        return $count
3219
-            ? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3220
-            : $this->getAttendeeModel()->get_all($query_args);
3221
-    }
3222
-
3223
-
3224
-    /**
3225
-     * This is just taking care of resending the registration confirmation
3226
-     *
3227
-     * @return void
3228
-     * @throws EE_Error
3229
-     * @throws InvalidArgumentException
3230
-     * @throws InvalidDataTypeException
3231
-     * @throws InvalidInterfaceException
3232
-     * @throws ReflectionException
3233
-     */
3234
-    protected function _resend_registration()
3235
-    {
3236
-        $this->_process_resend_registration();
3237
-        $REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3238
-        $redirect_to = $this->request->getRequestParam('redirect_to');
3239
-        $query_args  = $redirect_to
3240
-            ? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3241
-            : ['action' => 'default'];
3242
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3243
-    }
3244
-
3245
-
3246
-    /**
3247
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3248
-     * to use when selecting registrations
3249
-     *
3250
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3251
-     *                                                     the query parameters from the request
3252
-     * @return void ends the request with a redirect or download
3253
-     */
3254
-    public function _registrations_report_base($method_name_for_getting_query_params)
3255
-    {
3256
-        $EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3257
-            ? $this->request->getRequestParam('EVT_ID', 0, 'int')
3258
-            : null;
3259
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3260
-            $request_params = $this->request->requestParams();
3261
-            wp_redirect(
3262
-                EE_Admin_Page::add_query_args_and_nonce(
3263
-                    [
3264
-                        'page'        => 'espresso_batch',
3265
-                        'batch'       => 'file',
3266
-                        'EVT_ID'      => $EVT_ID,
3267
-                        'filters'     => urlencode(
3268
-                            serialize(
3269
-                                $this->$method_name_for_getting_query_params(
3270
-                                    EEH_Array::is_set($request_params, 'filters', [])
3271
-                                )
3272
-                            )
3273
-                        ),
3274
-                        'use_filters' => EEH_Array::is_set($request_params, 'use_filters', false),
3275
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3276
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3277
-                    ]
3278
-                )
3279
-            );
3280
-        } else {
3281
-            $new_request_args = [
3282
-                'export' => 'report',
3283
-                'action' => 'registrations_report_for_event',
3284
-                'EVT_ID' => $EVT_ID,
3285
-            ];
3286
-            $this->request->mergeRequestParams($new_request_args);
3287
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3288
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3289
-                $EE_Export = EE_Export::instance($this->request->requestParams());
3290
-                $EE_Export->export();
3291
-            }
3292
-        }
3293
-    }
3294
-
3295
-
3296
-    /**
3297
-     * Creates a registration report using only query parameters in the request
3298
-     *
3299
-     * @return void
3300
-     */
3301
-    public function _registrations_report()
3302
-    {
3303
-        $this->_registrations_report_base('_get_registration_query_parameters');
3304
-    }
3305
-
3306
-
3307
-    public function _contact_list_export()
3308
-    {
3309
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3310
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3311
-            $EE_Export = EE_Export::instance($this->request->requestParams());
3312
-            $EE_Export->export_attendees();
3313
-        }
3314
-    }
3315
-
3316
-
3317
-    public function _contact_list_report()
3318
-    {
3319
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3320
-            wp_redirect(
3321
-                EE_Admin_Page::add_query_args_and_nonce(
3322
-                    [
3323
-                        'page'        => 'espresso_batch',
3324
-                        'batch'       => 'file',
3325
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3326
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3327
-                    ]
3328
-                )
3329
-            );
3330
-        } else {
3331
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3332
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3333
-                $EE_Export = EE_Export::instance($this->request->requestParams());
3334
-                $EE_Export->report_attendees();
3335
-            }
3336
-        }
3337
-    }
3338
-
3339
-
3340
-
3341
-
3342
-
3343
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3344
-    /**
3345
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3346
-     *
3347
-     * @return void
3348
-     * @throws EE_Error
3349
-     * @throws InvalidArgumentException
3350
-     * @throws InvalidDataTypeException
3351
-     * @throws InvalidInterfaceException
3352
-     * @throws ReflectionException
3353
-     */
3354
-    protected function _duplicate_attendee()
3355
-    {
3356
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3357
-        $action = $this->request->getRequestParam('return', 'default');
3358
-        // verify we have necessary info
3359
-        if (! $REG_ID) {
3360
-            EE_Error::add_error(
3361
-                esc_html__(
3362
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3363
-                    'event_espresso'
3364
-                ),
3365
-                __FILE__,
3366
-                __LINE__,
3367
-                __FUNCTION__
3368
-            );
3369
-            $query_args = ['action' => $action];
3370
-            $this->_redirect_after_action('', '', '', $query_args, true);
3371
-        }
3372
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3373
-        $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3374
-        if (! $registration instanceof EE_Registration) {
3375
-            throw new RuntimeException(
3376
-                sprintf(
3377
-                    esc_html__(
3378
-                        'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3379
-                        'event_espresso'
3380
-                    ),
3381
-                    $REG_ID
3382
-                )
3383
-            );
3384
-        }
3385
-        $attendee = $registration->attendee();
3386
-        // remove relation of existing attendee on registration
3387
-        $registration->_remove_relation_to($attendee, 'Attendee');
3388
-        // new attendee
3389
-        $new_attendee = clone $attendee;
3390
-        $new_attendee->set('ATT_ID', 0);
3391
-        $new_attendee->save();
3392
-        // add new attendee to reg
3393
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3394
-        EE_Error::add_success(
3395
-            esc_html__(
3396
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3397
-                'event_espresso'
3398
-            )
3399
-        );
3400
-        // redirect to edit page for attendee
3401
-        $query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3402
-        $this->_redirect_after_action('', '', '', $query_args, true);
3403
-    }
3404
-
3405
-
3406
-    /**
3407
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3408
-     *
3409
-     * @param int     $post_id
3410
-     * @param WP_POST $post
3411
-     * @throws DomainException
3412
-     * @throws EE_Error
3413
-     * @throws InvalidArgumentException
3414
-     * @throws InvalidDataTypeException
3415
-     * @throws InvalidInterfaceException
3416
-     * @throws LogicException
3417
-     * @throws InvalidFormSubmissionException
3418
-     * @throws ReflectionException
3419
-     */
3420
-    protected function _insert_update_cpt_item($post_id, $post)
3421
-    {
3422
-        $success  = true;
3423
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3424
-            ? $this->getAttendeeModel()->get_one_by_ID($post_id)
3425
-            : null;
3426
-        // for attendee updates
3427
-        if ($attendee instanceof EE_Attendee) {
3428
-            // note we should only be UPDATING attendees at this point.
3429
-            $fname          = $this->request->getRequestParam('ATT_fname', '');
3430
-            $lname          = $this->request->getRequestParam('ATT_lname', '');
3431
-            $updated_fields = [
3432
-                'ATT_fname'     => $fname,
3433
-                'ATT_lname'     => $lname,
3434
-                'ATT_full_name' => "{$fname} {$lname}",
3435
-                'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3436
-                'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3437
-                'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3438
-                'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3439
-                'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3440
-                'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3441
-            ];
3442
-            foreach ($updated_fields as $field => $value) {
3443
-                $attendee->set($field, $value);
3444
-            }
3445
-
3446
-            // process contact details metabox form handler (which will also save the attendee)
3447
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3448
-            $success              = $contact_details_form->process($this->request->requestParams());
3449
-
3450
-            $attendee_update_callbacks = apply_filters(
3451
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3452
-                []
3453
-            );
3454
-            foreach ($attendee_update_callbacks as $a_callback) {
3455
-                if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3456
-                    throw new EE_Error(
3457
-                        sprintf(
3458
-                            esc_html__(
3459
-                                '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.',
3460
-                                'event_espresso'
3461
-                            ),
3462
-                            $a_callback
3463
-                        )
3464
-                    );
3465
-                }
3466
-            }
3467
-        }
3468
-
3469
-        if ($success === false) {
3470
-            EE_Error::add_error(
3471
-                esc_html__(
3472
-                    'Something went wrong with updating the meta table data for the registration.',
3473
-                    'event_espresso'
3474
-                ),
3475
-                __FILE__,
3476
-                __FUNCTION__,
3477
-                __LINE__
3478
-            );
3479
-        }
3480
-    }
3481
-
3482
-
3483
-    public function trash_cpt_item($post_id)
3484
-    {
3485
-    }
3486
-
3487
-
3488
-    public function delete_cpt_item($post_id)
3489
-    {
3490
-    }
3491
-
3492
-
3493
-    public function restore_cpt_item($post_id)
3494
-    {
3495
-    }
3496
-
3497
-
3498
-    protected function _restore_cpt_item($post_id, $revision_id)
3499
-    {
3500
-    }
3501
-
3502
-
3503
-    /**
3504
-     * @throws EE_Error
3505
-     * @throws ReflectionException
3506
-     * @since 4.10.2.p
3507
-     */
3508
-    public function attendee_editor_metaboxes()
3509
-    {
3510
-        $this->verify_cpt_object();
3511
-        remove_meta_box(
3512
-            'postexcerpt',
3513
-            $this->_cpt_routes[ $this->_req_action ],
3514
-            'normal'
3515
-        );
3516
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3517
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3518
-            add_meta_box(
3519
-                'postexcerpt',
3520
-                esc_html__('Short Biography', 'event_espresso'),
3521
-                'post_excerpt_meta_box',
3522
-                $this->_cpt_routes[ $this->_req_action ],
3523
-                'normal'
3524
-            );
3525
-        }
3526
-        if (post_type_supports('espresso_attendees', 'comments')) {
3527
-            add_meta_box(
3528
-                'commentsdiv',
3529
-                esc_html__('Notes on the Contact', 'event_espresso'),
3530
-                'post_comment_meta_box',
3531
-                $this->_cpt_routes[ $this->_req_action ],
3532
-                'normal',
3533
-                'core'
3534
-            );
3535
-        }
3536
-        add_meta_box(
3537
-            'attendee_contact_info',
3538
-            esc_html__('Contact Info', 'event_espresso'),
3539
-            [$this, 'attendee_contact_info'],
3540
-            $this->_cpt_routes[ $this->_req_action ],
3541
-            'side',
3542
-            'core'
3543
-        );
3544
-        add_meta_box(
3545
-            'attendee_details_address',
3546
-            esc_html__('Address Details', 'event_espresso'),
3547
-            [$this, 'attendee_address_details'],
3548
-            $this->_cpt_routes[ $this->_req_action ],
3549
-            'normal',
3550
-            'core'
3551
-        );
3552
-        add_meta_box(
3553
-            'attendee_registrations',
3554
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3555
-            [$this, 'attendee_registrations_meta_box'],
3556
-            $this->_cpt_routes[ $this->_req_action ],
3557
-            'normal',
3558
-            'high'
3559
-        );
3560
-    }
3561
-
3562
-
3563
-    /**
3564
-     * Metabox for attendee contact info
3565
-     *
3566
-     * @param WP_Post $post wp post object
3567
-     * @return void attendee contact info ( and form )
3568
-     * @throws EE_Error
3569
-     * @throws InvalidArgumentException
3570
-     * @throws InvalidDataTypeException
3571
-     * @throws InvalidInterfaceException
3572
-     * @throws LogicException
3573
-     * @throws DomainException
3574
-     */
3575
-    public function attendee_contact_info($post)
3576
-    {
3577
-        // get attendee object ( should already have it )
3578
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3579
-        $form->enqueueStylesAndScripts();
3580
-        echo $form->display(); // already escaped
3581
-    }
3582
-
3583
-
3584
-    /**
3585
-     * Return form handler for the contact details metabox
3586
-     *
3587
-     * @param EE_Attendee $attendee
3588
-     * @return AttendeeContactDetailsMetaboxFormHandler
3589
-     * @throws DomainException
3590
-     * @throws InvalidArgumentException
3591
-     * @throws InvalidDataTypeException
3592
-     * @throws InvalidInterfaceException
3593
-     */
3594
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3595
-    {
3596
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3597
-    }
3598
-
3599
-
3600
-    /**
3601
-     * Metabox for attendee details
3602
-     *
3603
-     * @param WP_Post $post wp post object
3604
-     * @throws EE_Error
3605
-     * @throws ReflectionException
3606
-     */
3607
-    public function attendee_address_details($post)
3608
-    {
3609
-        // get attendee object (should already have it)
3610
-        $this->_template_args['attendee']     = $this->_cpt_model_obj;
3611
-        $this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3612
-            new EE_Question_Form_Input(
3613
-                EE_Question::new_instance(
3614
-                    [
3615
-                        'QST_ID'           => 0,
3616
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3617
-                        'QST_system'       => 'admin-state',
3618
-                    ]
3619
-                ),
3620
-                EE_Answer::new_instance(
3621
-                    [
3622
-                        'ANS_ID'    => 0,
3623
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3624
-                    ]
3625
-                ),
3626
-                [
3627
-                    'input_id'       => 'STA_ID',
3628
-                    'input_name'     => 'STA_ID',
3629
-                    'input_prefix'   => '',
3630
-                    'append_qstn_id' => false,
3631
-                ]
3632
-            )
3633
-        );
3634
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3635
-            new EE_Question_Form_Input(
3636
-                EE_Question::new_instance(
3637
-                    [
3638
-                        'QST_ID'           => 0,
3639
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3640
-                        'QST_system'       => 'admin-country',
3641
-                    ]
3642
-                ),
3643
-                EE_Answer::new_instance(
3644
-                    [
3645
-                        'ANS_ID'    => 0,
3646
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3647
-                    ]
3648
-                ),
3649
-                [
3650
-                    'input_id'       => 'CNT_ISO',
3651
-                    'input_name'     => 'CNT_ISO',
3652
-                    'input_prefix'   => '',
3653
-                    'append_qstn_id' => false,
3654
-                ]
3655
-            )
3656
-        );
3657
-        $template                             =
3658
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3659
-        EEH_Template::display_template($template, $this->_template_args);
3660
-    }
3661
-
3662
-
3663
-    /**
3664
-     * _attendee_details
3665
-     *
3666
-     * @param $post
3667
-     * @return void
3668
-     * @throws DomainException
3669
-     * @throws EE_Error
3670
-     * @throws InvalidArgumentException
3671
-     * @throws InvalidDataTypeException
3672
-     * @throws InvalidInterfaceException
3673
-     * @throws ReflectionException
3674
-     */
3675
-    public function attendee_registrations_meta_box($post)
3676
-    {
3677
-        $this->_template_args['attendee']      = $this->_cpt_model_obj;
3678
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3679
-        $template                              =
3680
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3681
-        EEH_Template::display_template($template, $this->_template_args);
3682
-    }
3683
-
3684
-
3685
-    /**
3686
-     * add in the form fields for the attendee edit
3687
-     *
3688
-     * @param WP_Post $post wp post object
3689
-     * @return void echos html for new form.
3690
-     * @throws DomainException
3691
-     */
3692
-    public function after_title_form_fields($post)
3693
-    {
3694
-        if ($post->post_type === 'espresso_attendees') {
3695
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3696
-            $template_args['attendee'] = $this->_cpt_model_obj;
3697
-            EEH_Template::display_template($template, $template_args);
3698
-        }
3699
-    }
3700
-
3701
-
3702
-    /**
3703
-     * _trash_or_restore_attendee
3704
-     *
3705
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3706
-     * @return void
3707
-     * @throws EE_Error
3708
-     * @throws InvalidArgumentException
3709
-     * @throws InvalidDataTypeException
3710
-     * @throws InvalidInterfaceException
3711
-     */
3712
-    protected function _trash_or_restore_attendees($trash = true)
3713
-    {
3714
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3715
-        $status = $trash ? 'trash' : 'publish';
3716
-        // Checkboxes
3717
-        if ($this->request->requestParamIsSet('checkbox')) {
3718
-            $ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3719
-            // if array has more than one element than success message should be plural
3720
-            $success = count($ATT_IDs) > 1 ? 2 : 1;
3721
-            // cycle thru checkboxes
3722
-            foreach ($ATT_IDs as $ATT_ID) {
3723
-                $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3724
-                if (! $updated) {
3725
-                    $success = 0;
3726
-                }
3727
-            }
3728
-        } else {
3729
-            // grab single id and delete
3730
-            $ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3731
-            // update attendee
3732
-            $success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3733
-        }
3734
-        $what        = $success > 1
3735
-            ? esc_html__('Contacts', 'event_espresso')
3736
-            : esc_html__('Contact', 'event_espresso');
3737
-        $action_desc = $trash
3738
-            ? esc_html__('moved to the trash', 'event_espresso')
3739
-            : esc_html__('restored', 'event_espresso');
3740
-        $this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3741
-    }
2899
+		}
2900
+		$template_args = [
2901
+			'title'                    => '',
2902
+			'content'                  => '',
2903
+			'step_button_text'         => '',
2904
+			'show_notification_toggle' => false,
2905
+		];
2906
+		// to indicate we're processing a new registration
2907
+		$hidden_fields = [
2908
+			'processing_registration' => [
2909
+				'type'  => 'hidden',
2910
+				'value' => 0,
2911
+			],
2912
+			'event_id'                => [
2913
+				'type'  => 'hidden',
2914
+				'value' => $this->_reg_event->ID(),
2915
+			],
2916
+		];
2917
+		// if the cart is empty then we know we're at step one, so we'll display the ticket selector
2918
+		$cart = EE_Registry::instance()->SSN->cart();
2919
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2920
+		switch ($step) {
2921
+			case 'ticket':
2922
+				$hidden_fields['processing_registration']['value'] = 1;
2923
+				$template_args['title']                            = esc_html__(
2924
+					'Step One: Select the Ticket for this registration',
2925
+					'event_espresso'
2926
+				);
2927
+				$template_args['content']                          =
2928
+					EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2929
+				$template_args['content']                          .= '</div>';
2930
+				$template_args['step_button_text']                 = esc_html__(
2931
+					'Add Tickets and Continue to Registrant Details',
2932
+					'event_espresso'
2933
+				);
2934
+				$template_args['show_notification_toggle']         = false;
2935
+				break;
2936
+			case 'questions':
2937
+				$hidden_fields['processing_registration']['value'] = 2;
2938
+				$template_args['title']                            = esc_html__(
2939
+					'Step Two: Add Registrant Details for this Registration',
2940
+					'event_espresso'
2941
+				);
2942
+				// in theory, we should be able to run EED_SPCO at this point
2943
+				// because the cart should have been set up properly by the first process_reg_step run.
2944
+				$template_args['content']                  =
2945
+					EED_Single_Page_Checkout::registration_checkout_for_admin();
2946
+				$template_args['step_button_text']         = esc_html__(
2947
+					'Save Registration and Continue to Details',
2948
+					'event_espresso'
2949
+				);
2950
+				$template_args['show_notification_toggle'] = true;
2951
+				break;
2952
+		}
2953
+		// we come back to the process_registration_step route.
2954
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2955
+		return EEH_Template::display_template(
2956
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2957
+			$template_args,
2958
+			true
2959
+		);
2960
+	}
2961
+
2962
+
2963
+	/**
2964
+	 * set_reg_event
2965
+	 *
2966
+	 * @return bool
2967
+	 * @throws EE_Error
2968
+	 * @throws InvalidArgumentException
2969
+	 * @throws InvalidDataTypeException
2970
+	 * @throws InvalidInterfaceException
2971
+	 */
2972
+	private function _set_reg_event()
2973
+	{
2974
+		if (is_object($this->_reg_event)) {
2975
+			return true;
2976
+		}
2977
+
2978
+		$EVT_ID = $this->request->getRequestParam('event_id[reg_status]', 0, 'int');
2979
+		if (! $EVT_ID) {
2980
+			return false;
2981
+		}
2982
+		$this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2983
+		return true;
2984
+	}
2985
+
2986
+
2987
+	/**
2988
+	 * process_reg_step
2989
+	 *
2990
+	 * @return void
2991
+	 * @throws DomainException
2992
+	 * @throws EE_Error
2993
+	 * @throws InvalidArgumentException
2994
+	 * @throws InvalidDataTypeException
2995
+	 * @throws InvalidInterfaceException
2996
+	 * @throws ReflectionException
2997
+	 * @throws RuntimeException
2998
+	 */
2999
+	public function process_reg_step()
3000
+	{
3001
+		EE_System::do_not_cache();
3002
+		$this->_set_reg_event();
3003
+		/** @var CurrentPage $current_page */
3004
+		$current_page = $this->loader->getShared(CurrentPage::class);
3005
+		$current_page->setEspressoPage(true);
3006
+		$this->request->setRequestParam('uts', time());
3007
+		// what step are we on?
3008
+		$cart = EE_Registry::instance()->SSN->cart();
3009
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3010
+		// if doing ajax then we need to verify the nonce
3011
+		if ($this->request->isAjax()) {
3012
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
3013
+			$this->_verify_nonce($nonce, $this->_req_nonce);
3014
+		}
3015
+		switch ($step) {
3016
+			case 'ticket':
3017
+				// process ticket selection
3018
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
3019
+				if ($success) {
3020
+					EE_Error::add_success(
3021
+						esc_html__(
3022
+							'Tickets Selected. Now complete the registration.',
3023
+							'event_espresso'
3024
+						)
3025
+					);
3026
+				} else {
3027
+					$this->request->setRequestParam('step_error', true);
3028
+					$query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3029
+				}
3030
+				if ($this->request->isAjax()) {
3031
+					$this->new_registration(); // display next step
3032
+				} else {
3033
+					$query_args = [
3034
+						'action'                  => 'new_registration',
3035
+						'processing_registration' => 1,
3036
+						'event_id'                => $this->_reg_event->ID(),
3037
+						'uts'                     => time(),
3038
+					];
3039
+					$this->_redirect_after_action(
3040
+						false,
3041
+						'',
3042
+						'',
3043
+						$query_args,
3044
+						true
3045
+					);
3046
+				}
3047
+				break;
3048
+			case 'questions':
3049
+				if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3050
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3051
+				}
3052
+				// process registration
3053
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3054
+				if ($cart instanceof EE_Cart) {
3055
+					$grand_total = $cart->get_grand_total();
3056
+					if ($grand_total instanceof EE_Line_Item) {
3057
+						$grand_total->save_this_and_descendants_to_txn();
3058
+					}
3059
+				}
3060
+				if (! $transaction instanceof EE_Transaction) {
3061
+					$query_args = [
3062
+						'action'                  => 'new_registration',
3063
+						'processing_registration' => 2,
3064
+						'event_id'                => $this->_reg_event->ID(),
3065
+						'uts'                     => time(),
3066
+					];
3067
+					if ($this->request->isAjax()) {
3068
+						// display registration form again because there are errors (maybe validation?)
3069
+						$this->new_registration();
3070
+						return;
3071
+					}
3072
+					$this->_redirect_after_action(
3073
+						false,
3074
+						'',
3075
+						'',
3076
+						$query_args,
3077
+						true
3078
+					);
3079
+					return;
3080
+				}
3081
+				// maybe update status, and make sure to save transaction if not done already
3082
+				if (! $transaction->update_status_based_on_total_paid()) {
3083
+					$transaction->save();
3084
+				}
3085
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3086
+				$query_args = [
3087
+					'action'        => 'redirect_to_txn',
3088
+					'TXN_ID'        => $transaction->ID(),
3089
+					'EVT_ID'        => $this->_reg_event->ID(),
3090
+					'event_name'    => urlencode($this->_reg_event->name()),
3091
+					'redirect_from' => 'new_registration',
3092
+				];
3093
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3094
+				break;
3095
+		}
3096
+		// what are you looking here for?  Should be nothing to do at this point.
3097
+	}
3098
+
3099
+
3100
+	/**
3101
+	 * redirect_to_txn
3102
+	 *
3103
+	 * @return void
3104
+	 * @throws EE_Error
3105
+	 * @throws InvalidArgumentException
3106
+	 * @throws InvalidDataTypeException
3107
+	 * @throws InvalidInterfaceException
3108
+	 * @throws ReflectionException
3109
+	 */
3110
+	public function redirect_to_txn()
3111
+	{
3112
+		EE_System::do_not_cache();
3113
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3114
+		$query_args = [
3115
+			'action' => 'view_transaction',
3116
+			'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3117
+			'page'   => 'espresso_transactions',
3118
+		];
3119
+		if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3120
+			$query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3121
+			$query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3122
+			$query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3123
+		}
3124
+		EE_Error::add_success(
3125
+			esc_html__(
3126
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3127
+				'event_espresso'
3128
+			)
3129
+		);
3130
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3131
+	}
3132
+
3133
+
3134
+	/**
3135
+	 * generates HTML for the Attendee Contact List
3136
+	 *
3137
+	 * @return void
3138
+	 * @throws DomainException
3139
+	 * @throws EE_Error
3140
+	 */
3141
+	protected function _attendee_contact_list_table()
3142
+	{
3143
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3144
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3145
+		$this->display_admin_list_table_page_with_no_sidebar();
3146
+	}
3147
+
3148
+
3149
+	/**
3150
+	 * get_attendees
3151
+	 *
3152
+	 * @param      $per_page
3153
+	 * @param bool $count whether to return count or data.
3154
+	 * @param bool $trash
3155
+	 * @return array|int
3156
+	 * @throws EE_Error
3157
+	 * @throws InvalidArgumentException
3158
+	 * @throws InvalidDataTypeException
3159
+	 * @throws InvalidInterfaceException
3160
+	 */
3161
+	public function get_attendees($per_page, $count = false, $trash = false)
3162
+	{
3163
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3164
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3165
+		$orderby = $this->request->getRequestParam('orderby');
3166
+		switch ($orderby) {
3167
+			case 'ATT_ID':
3168
+			case 'ATT_fname':
3169
+			case 'ATT_email':
3170
+			case 'ATT_city':
3171
+			case 'STA_ID':
3172
+			case 'CNT_ID':
3173
+				break;
3174
+			case 'Registration_Count':
3175
+				$orderby = 'Registration_Count';
3176
+				break;
3177
+			default:
3178
+				$orderby = 'ATT_lname';
3179
+		}
3180
+		$sort         = $this->request->getRequestParam('order', 'ASC');
3181
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
3182
+		$per_page     = absint($per_page) ? $per_page : 10;
3183
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3184
+		$_where       = [];
3185
+		$search_term  = $this->request->getRequestParam('s');
3186
+		if ($search_term) {
3187
+			$search_term  = '%' . $search_term . '%';
3188
+			$_where['OR'] = [
3189
+				'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3190
+				'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3191
+				'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3192
+				'ATT_fname'                         => ['LIKE', $search_term],
3193
+				'ATT_lname'                         => ['LIKE', $search_term],
3194
+				'ATT_short_bio'                     => ['LIKE', $search_term],
3195
+				'ATT_email'                         => ['LIKE', $search_term],
3196
+				'ATT_address'                       => ['LIKE', $search_term],
3197
+				'ATT_address2'                      => ['LIKE', $search_term],
3198
+				'ATT_city'                          => ['LIKE', $search_term],
3199
+				'Country.CNT_name'                  => ['LIKE', $search_term],
3200
+				'State.STA_name'                    => ['LIKE', $search_term],
3201
+				'ATT_phone'                         => ['LIKE', $search_term],
3202
+				'Registration.REG_final_price'      => ['LIKE', $search_term],
3203
+				'Registration.REG_code'             => ['LIKE', $search_term],
3204
+				'Registration.REG_group_size'       => ['LIKE', $search_term],
3205
+			];
3206
+		}
3207
+		$offset     = ($current_page - 1) * $per_page;
3208
+		$limit      = $count ? null : [$offset, $per_page];
3209
+		$query_args = [
3210
+			$_where,
3211
+			'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3212
+			'limit'         => $limit,
3213
+		];
3214
+		if (! $count) {
3215
+			$query_args['order_by'] = [$orderby => $sort];
3216
+		}
3217
+		$query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3218
+		return $count
3219
+			? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3220
+			: $this->getAttendeeModel()->get_all($query_args);
3221
+	}
3222
+
3223
+
3224
+	/**
3225
+	 * This is just taking care of resending the registration confirmation
3226
+	 *
3227
+	 * @return void
3228
+	 * @throws EE_Error
3229
+	 * @throws InvalidArgumentException
3230
+	 * @throws InvalidDataTypeException
3231
+	 * @throws InvalidInterfaceException
3232
+	 * @throws ReflectionException
3233
+	 */
3234
+	protected function _resend_registration()
3235
+	{
3236
+		$this->_process_resend_registration();
3237
+		$REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3238
+		$redirect_to = $this->request->getRequestParam('redirect_to');
3239
+		$query_args  = $redirect_to
3240
+			? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3241
+			: ['action' => 'default'];
3242
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3243
+	}
3244
+
3245
+
3246
+	/**
3247
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3248
+	 * to use when selecting registrations
3249
+	 *
3250
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3251
+	 *                                                     the query parameters from the request
3252
+	 * @return void ends the request with a redirect or download
3253
+	 */
3254
+	public function _registrations_report_base($method_name_for_getting_query_params)
3255
+	{
3256
+		$EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3257
+			? $this->request->getRequestParam('EVT_ID', 0, 'int')
3258
+			: null;
3259
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3260
+			$request_params = $this->request->requestParams();
3261
+			wp_redirect(
3262
+				EE_Admin_Page::add_query_args_and_nonce(
3263
+					[
3264
+						'page'        => 'espresso_batch',
3265
+						'batch'       => 'file',
3266
+						'EVT_ID'      => $EVT_ID,
3267
+						'filters'     => urlencode(
3268
+							serialize(
3269
+								$this->$method_name_for_getting_query_params(
3270
+									EEH_Array::is_set($request_params, 'filters', [])
3271
+								)
3272
+							)
3273
+						),
3274
+						'use_filters' => EEH_Array::is_set($request_params, 'use_filters', false),
3275
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3276
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3277
+					]
3278
+				)
3279
+			);
3280
+		} else {
3281
+			$new_request_args = [
3282
+				'export' => 'report',
3283
+				'action' => 'registrations_report_for_event',
3284
+				'EVT_ID' => $EVT_ID,
3285
+			];
3286
+			$this->request->mergeRequestParams($new_request_args);
3287
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3288
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3289
+				$EE_Export = EE_Export::instance($this->request->requestParams());
3290
+				$EE_Export->export();
3291
+			}
3292
+		}
3293
+	}
3294
+
3295
+
3296
+	/**
3297
+	 * Creates a registration report using only query parameters in the request
3298
+	 *
3299
+	 * @return void
3300
+	 */
3301
+	public function _registrations_report()
3302
+	{
3303
+		$this->_registrations_report_base('_get_registration_query_parameters');
3304
+	}
3305
+
3306
+
3307
+	public function _contact_list_export()
3308
+	{
3309
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3310
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3311
+			$EE_Export = EE_Export::instance($this->request->requestParams());
3312
+			$EE_Export->export_attendees();
3313
+		}
3314
+	}
3315
+
3316
+
3317
+	public function _contact_list_report()
3318
+	{
3319
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3320
+			wp_redirect(
3321
+				EE_Admin_Page::add_query_args_and_nonce(
3322
+					[
3323
+						'page'        => 'espresso_batch',
3324
+						'batch'       => 'file',
3325
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3326
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3327
+					]
3328
+				)
3329
+			);
3330
+		} else {
3331
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3332
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3333
+				$EE_Export = EE_Export::instance($this->request->requestParams());
3334
+				$EE_Export->report_attendees();
3335
+			}
3336
+		}
3337
+	}
3338
+
3339
+
3340
+
3341
+
3342
+
3343
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3344
+	/**
3345
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3346
+	 *
3347
+	 * @return void
3348
+	 * @throws EE_Error
3349
+	 * @throws InvalidArgumentException
3350
+	 * @throws InvalidDataTypeException
3351
+	 * @throws InvalidInterfaceException
3352
+	 * @throws ReflectionException
3353
+	 */
3354
+	protected function _duplicate_attendee()
3355
+	{
3356
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3357
+		$action = $this->request->getRequestParam('return', 'default');
3358
+		// verify we have necessary info
3359
+		if (! $REG_ID) {
3360
+			EE_Error::add_error(
3361
+				esc_html__(
3362
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3363
+					'event_espresso'
3364
+				),
3365
+				__FILE__,
3366
+				__LINE__,
3367
+				__FUNCTION__
3368
+			);
3369
+			$query_args = ['action' => $action];
3370
+			$this->_redirect_after_action('', '', '', $query_args, true);
3371
+		}
3372
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3373
+		$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3374
+		if (! $registration instanceof EE_Registration) {
3375
+			throw new RuntimeException(
3376
+				sprintf(
3377
+					esc_html__(
3378
+						'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3379
+						'event_espresso'
3380
+					),
3381
+					$REG_ID
3382
+				)
3383
+			);
3384
+		}
3385
+		$attendee = $registration->attendee();
3386
+		// remove relation of existing attendee on registration
3387
+		$registration->_remove_relation_to($attendee, 'Attendee');
3388
+		// new attendee
3389
+		$new_attendee = clone $attendee;
3390
+		$new_attendee->set('ATT_ID', 0);
3391
+		$new_attendee->save();
3392
+		// add new attendee to reg
3393
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3394
+		EE_Error::add_success(
3395
+			esc_html__(
3396
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3397
+				'event_espresso'
3398
+			)
3399
+		);
3400
+		// redirect to edit page for attendee
3401
+		$query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3402
+		$this->_redirect_after_action('', '', '', $query_args, true);
3403
+	}
3404
+
3405
+
3406
+	/**
3407
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3408
+	 *
3409
+	 * @param int     $post_id
3410
+	 * @param WP_POST $post
3411
+	 * @throws DomainException
3412
+	 * @throws EE_Error
3413
+	 * @throws InvalidArgumentException
3414
+	 * @throws InvalidDataTypeException
3415
+	 * @throws InvalidInterfaceException
3416
+	 * @throws LogicException
3417
+	 * @throws InvalidFormSubmissionException
3418
+	 * @throws ReflectionException
3419
+	 */
3420
+	protected function _insert_update_cpt_item($post_id, $post)
3421
+	{
3422
+		$success  = true;
3423
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3424
+			? $this->getAttendeeModel()->get_one_by_ID($post_id)
3425
+			: null;
3426
+		// for attendee updates
3427
+		if ($attendee instanceof EE_Attendee) {
3428
+			// note we should only be UPDATING attendees at this point.
3429
+			$fname          = $this->request->getRequestParam('ATT_fname', '');
3430
+			$lname          = $this->request->getRequestParam('ATT_lname', '');
3431
+			$updated_fields = [
3432
+				'ATT_fname'     => $fname,
3433
+				'ATT_lname'     => $lname,
3434
+				'ATT_full_name' => "{$fname} {$lname}",
3435
+				'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3436
+				'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3437
+				'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3438
+				'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3439
+				'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3440
+				'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3441
+			];
3442
+			foreach ($updated_fields as $field => $value) {
3443
+				$attendee->set($field, $value);
3444
+			}
3445
+
3446
+			// process contact details metabox form handler (which will also save the attendee)
3447
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3448
+			$success              = $contact_details_form->process($this->request->requestParams());
3449
+
3450
+			$attendee_update_callbacks = apply_filters(
3451
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3452
+				[]
3453
+			);
3454
+			foreach ($attendee_update_callbacks as $a_callback) {
3455
+				if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3456
+					throw new EE_Error(
3457
+						sprintf(
3458
+							esc_html__(
3459
+								'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.',
3460
+								'event_espresso'
3461
+							),
3462
+							$a_callback
3463
+						)
3464
+					);
3465
+				}
3466
+			}
3467
+		}
3468
+
3469
+		if ($success === false) {
3470
+			EE_Error::add_error(
3471
+				esc_html__(
3472
+					'Something went wrong with updating the meta table data for the registration.',
3473
+					'event_espresso'
3474
+				),
3475
+				__FILE__,
3476
+				__FUNCTION__,
3477
+				__LINE__
3478
+			);
3479
+		}
3480
+	}
3481
+
3482
+
3483
+	public function trash_cpt_item($post_id)
3484
+	{
3485
+	}
3486
+
3487
+
3488
+	public function delete_cpt_item($post_id)
3489
+	{
3490
+	}
3491
+
3492
+
3493
+	public function restore_cpt_item($post_id)
3494
+	{
3495
+	}
3496
+
3497
+
3498
+	protected function _restore_cpt_item($post_id, $revision_id)
3499
+	{
3500
+	}
3501
+
3502
+
3503
+	/**
3504
+	 * @throws EE_Error
3505
+	 * @throws ReflectionException
3506
+	 * @since 4.10.2.p
3507
+	 */
3508
+	public function attendee_editor_metaboxes()
3509
+	{
3510
+		$this->verify_cpt_object();
3511
+		remove_meta_box(
3512
+			'postexcerpt',
3513
+			$this->_cpt_routes[ $this->_req_action ],
3514
+			'normal'
3515
+		);
3516
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3517
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3518
+			add_meta_box(
3519
+				'postexcerpt',
3520
+				esc_html__('Short Biography', 'event_espresso'),
3521
+				'post_excerpt_meta_box',
3522
+				$this->_cpt_routes[ $this->_req_action ],
3523
+				'normal'
3524
+			);
3525
+		}
3526
+		if (post_type_supports('espresso_attendees', 'comments')) {
3527
+			add_meta_box(
3528
+				'commentsdiv',
3529
+				esc_html__('Notes on the Contact', 'event_espresso'),
3530
+				'post_comment_meta_box',
3531
+				$this->_cpt_routes[ $this->_req_action ],
3532
+				'normal',
3533
+				'core'
3534
+			);
3535
+		}
3536
+		add_meta_box(
3537
+			'attendee_contact_info',
3538
+			esc_html__('Contact Info', 'event_espresso'),
3539
+			[$this, 'attendee_contact_info'],
3540
+			$this->_cpt_routes[ $this->_req_action ],
3541
+			'side',
3542
+			'core'
3543
+		);
3544
+		add_meta_box(
3545
+			'attendee_details_address',
3546
+			esc_html__('Address Details', 'event_espresso'),
3547
+			[$this, 'attendee_address_details'],
3548
+			$this->_cpt_routes[ $this->_req_action ],
3549
+			'normal',
3550
+			'core'
3551
+		);
3552
+		add_meta_box(
3553
+			'attendee_registrations',
3554
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3555
+			[$this, 'attendee_registrations_meta_box'],
3556
+			$this->_cpt_routes[ $this->_req_action ],
3557
+			'normal',
3558
+			'high'
3559
+		);
3560
+	}
3561
+
3562
+
3563
+	/**
3564
+	 * Metabox for attendee contact info
3565
+	 *
3566
+	 * @param WP_Post $post wp post object
3567
+	 * @return void attendee contact info ( and form )
3568
+	 * @throws EE_Error
3569
+	 * @throws InvalidArgumentException
3570
+	 * @throws InvalidDataTypeException
3571
+	 * @throws InvalidInterfaceException
3572
+	 * @throws LogicException
3573
+	 * @throws DomainException
3574
+	 */
3575
+	public function attendee_contact_info($post)
3576
+	{
3577
+		// get attendee object ( should already have it )
3578
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3579
+		$form->enqueueStylesAndScripts();
3580
+		echo $form->display(); // already escaped
3581
+	}
3582
+
3583
+
3584
+	/**
3585
+	 * Return form handler for the contact details metabox
3586
+	 *
3587
+	 * @param EE_Attendee $attendee
3588
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3589
+	 * @throws DomainException
3590
+	 * @throws InvalidArgumentException
3591
+	 * @throws InvalidDataTypeException
3592
+	 * @throws InvalidInterfaceException
3593
+	 */
3594
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3595
+	{
3596
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3597
+	}
3598
+
3599
+
3600
+	/**
3601
+	 * Metabox for attendee details
3602
+	 *
3603
+	 * @param WP_Post $post wp post object
3604
+	 * @throws EE_Error
3605
+	 * @throws ReflectionException
3606
+	 */
3607
+	public function attendee_address_details($post)
3608
+	{
3609
+		// get attendee object (should already have it)
3610
+		$this->_template_args['attendee']     = $this->_cpt_model_obj;
3611
+		$this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3612
+			new EE_Question_Form_Input(
3613
+				EE_Question::new_instance(
3614
+					[
3615
+						'QST_ID'           => 0,
3616
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3617
+						'QST_system'       => 'admin-state',
3618
+					]
3619
+				),
3620
+				EE_Answer::new_instance(
3621
+					[
3622
+						'ANS_ID'    => 0,
3623
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3624
+					]
3625
+				),
3626
+				[
3627
+					'input_id'       => 'STA_ID',
3628
+					'input_name'     => 'STA_ID',
3629
+					'input_prefix'   => '',
3630
+					'append_qstn_id' => false,
3631
+				]
3632
+			)
3633
+		);
3634
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3635
+			new EE_Question_Form_Input(
3636
+				EE_Question::new_instance(
3637
+					[
3638
+						'QST_ID'           => 0,
3639
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3640
+						'QST_system'       => 'admin-country',
3641
+					]
3642
+				),
3643
+				EE_Answer::new_instance(
3644
+					[
3645
+						'ANS_ID'    => 0,
3646
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3647
+					]
3648
+				),
3649
+				[
3650
+					'input_id'       => 'CNT_ISO',
3651
+					'input_name'     => 'CNT_ISO',
3652
+					'input_prefix'   => '',
3653
+					'append_qstn_id' => false,
3654
+				]
3655
+			)
3656
+		);
3657
+		$template                             =
3658
+			REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3659
+		EEH_Template::display_template($template, $this->_template_args);
3660
+	}
3661
+
3662
+
3663
+	/**
3664
+	 * _attendee_details
3665
+	 *
3666
+	 * @param $post
3667
+	 * @return void
3668
+	 * @throws DomainException
3669
+	 * @throws EE_Error
3670
+	 * @throws InvalidArgumentException
3671
+	 * @throws InvalidDataTypeException
3672
+	 * @throws InvalidInterfaceException
3673
+	 * @throws ReflectionException
3674
+	 */
3675
+	public function attendee_registrations_meta_box($post)
3676
+	{
3677
+		$this->_template_args['attendee']      = $this->_cpt_model_obj;
3678
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3679
+		$template                              =
3680
+			REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3681
+		EEH_Template::display_template($template, $this->_template_args);
3682
+	}
3683
+
3684
+
3685
+	/**
3686
+	 * add in the form fields for the attendee edit
3687
+	 *
3688
+	 * @param WP_Post $post wp post object
3689
+	 * @return void echos html for new form.
3690
+	 * @throws DomainException
3691
+	 */
3692
+	public function after_title_form_fields($post)
3693
+	{
3694
+		if ($post->post_type === 'espresso_attendees') {
3695
+			$template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3696
+			$template_args['attendee'] = $this->_cpt_model_obj;
3697
+			EEH_Template::display_template($template, $template_args);
3698
+		}
3699
+	}
3700
+
3701
+
3702
+	/**
3703
+	 * _trash_or_restore_attendee
3704
+	 *
3705
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3706
+	 * @return void
3707
+	 * @throws EE_Error
3708
+	 * @throws InvalidArgumentException
3709
+	 * @throws InvalidDataTypeException
3710
+	 * @throws InvalidInterfaceException
3711
+	 */
3712
+	protected function _trash_or_restore_attendees($trash = true)
3713
+	{
3714
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3715
+		$status = $trash ? 'trash' : 'publish';
3716
+		// Checkboxes
3717
+		if ($this->request->requestParamIsSet('checkbox')) {
3718
+			$ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3719
+			// if array has more than one element than success message should be plural
3720
+			$success = count($ATT_IDs) > 1 ? 2 : 1;
3721
+			// cycle thru checkboxes
3722
+			foreach ($ATT_IDs as $ATT_ID) {
3723
+				$updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3724
+				if (! $updated) {
3725
+					$success = 0;
3726
+				}
3727
+			}
3728
+		} else {
3729
+			// grab single id and delete
3730
+			$ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3731
+			// update attendee
3732
+			$success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3733
+		}
3734
+		$what        = $success > 1
3735
+			? esc_html__('Contacts', 'event_espresso')
3736
+			: esc_html__('Contact', 'event_espresso');
3737
+		$action_desc = $trash
3738
+			? esc_html__('moved to the trash', 'event_espresso')
3739
+			: esc_html__('restored', 'event_espresso');
3740
+		$this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3741
+	}
3742 3742
 }
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     protected function getRegistrationModel()
94 94
     {
95
-        if (! $this->registration_model instanceof EEM_Registration) {
95
+        if ( ! $this->registration_model instanceof EEM_Registration) {
96 96
             $this->registration_model = $this->getLoader()->getShared('EEM_Registration');
97 97
         }
98 98
         return $this->registration_model;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      */
109 109
     protected function getAttendeeModel()
110 110
     {
111
-        if (! $this->attendee_model instanceof EEM_Attendee) {
111
+        if ( ! $this->attendee_model instanceof EEM_Attendee) {
112 112
             $this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
113 113
         }
114 114
         return $this->attendee_model;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     protected function getEventModel()
126 126
     {
127
-        if (! $this->event_model instanceof EEM_Event) {
127
+        if ( ! $this->event_model instanceof EEM_Event) {
128 128
             $this->event_model = $this->getLoader()->getShared('EEM_Event');
129 129
         }
130 130
         return $this->event_model;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      */
141 141
     protected function getStatusModel()
142 142
     {
143
-        if (! $this->status_model instanceof EEM_Status) {
143
+        if ( ! $this->status_model instanceof EEM_Status) {
144 144
             $this->status_model = $this->getLoader()->getShared('EEM_Status');
145 145
         }
146 146
         return $this->status_model;
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
         // style
760 760
         wp_register_style(
761 761
             'espresso_reg',
762
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
762
+            REG_ASSETS_URL.'espresso_registrations_admin.css',
763 763
             ['ee-admin-css'],
764 764
             EVENT_ESPRESSO_VERSION
765 765
         );
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
         // script
768 768
         wp_register_script(
769 769
             'espresso_reg',
770
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
770
+            REG_ASSETS_URL.'espresso_registrations_admin.js',
771 771
             ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
772 772
             EVENT_ESPRESSO_VERSION,
773 773
             true
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
             'att_publish_text' => sprintf(
792 792
             /* translators: The date and time */
793 793
                 wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
794
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
794
+                '<b>'.$this->_cpt_model_obj->get_datetime('ATT_created').'</b>'
795 795
             ),
796 796
         ];
797 797
         wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
         wp_dequeue_style('espresso_reg');
823 823
         wp_register_style(
824 824
             'espresso_att',
825
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
825
+            REG_ASSETS_URL.'espresso_attendees_admin.css',
826 826
             ['ee-admin-css'],
827 827
             EVENT_ESPRESSO_VERSION
828 828
         );
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
     {
835 835
         wp_register_script(
836 836
             'ee-spco-for-admin',
837
-            REG_ASSETS_URL . 'spco_for_admin.js',
837
+            REG_ASSETS_URL.'spco_for_admin.js',
838 838
             ['underscore', 'jquery'],
839 839
             EVENT_ESPRESSO_VERSION,
840 840
             true
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
             'no_approve_registrations' => 'not_approved_registration',
883 883
             'cancel_registrations'     => 'cancelled_registration',
884 884
         ];
885
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
885
+        $can_send = EE_Registry::instance()->CAP->current_user_can(
886 886
             'ee_send_message',
887 887
             'batch_send_messages'
888 888
         );
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
                     'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
988 988
                 ],
989 989
             ];
990
-            $this->_views['trash']      = [
990
+            $this->_views['trash'] = [
991 991
                 'slug'        => 'trash',
992 992
                 'label'       => esc_html__('Trash', 'event_espresso'),
993 993
                 'count'       => 0,
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
         }
1088 1088
         $sc_items = [
1089 1089
             'approved_status'   => [
1090
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1090
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
1091 1091
                 'desc'  => EEH_Template::pretty_status(
1092 1092
                     EEM_Registration::status_id_approved,
1093 1093
                     false,
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
                 ),
1096 1096
             ],
1097 1097
             'pending_status'    => [
1098
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1098
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
1099 1099
                 'desc'  => EEH_Template::pretty_status(
1100 1100
                     EEM_Registration::status_id_pending_payment,
1101 1101
                     false,
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
                 ),
1104 1104
             ],
1105 1105
             'wait_list'         => [
1106
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1106
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
1107 1107
                 'desc'  => EEH_Template::pretty_status(
1108 1108
                     EEM_Registration::status_id_wait_list,
1109 1109
                     false,
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
                 ),
1112 1112
             ],
1113 1113
             'incomplete_status' => [
1114
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1114
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete,
1115 1115
                 'desc'  => EEH_Template::pretty_status(
1116 1116
                     EEM_Registration::status_id_incomplete,
1117 1117
                     false,
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
                 ),
1120 1120
             ],
1121 1121
             'not_approved'      => [
1122
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1122
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
1123 1123
                 'desc'  => EEH_Template::pretty_status(
1124 1124
                     EEM_Registration::status_id_not_approved,
1125 1125
                     false,
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
                 ),
1128 1128
             ],
1129 1129
             'declined_status'   => [
1130
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1130
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
1131 1131
                 'desc'  => EEH_Template::pretty_status(
1132 1132
                     EEM_Registration::status_id_declined,
1133 1133
                     false,
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
                 ),
1136 1136
             ],
1137 1137
             'cancelled_status'  => [
1138
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1138
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
1139 1139
                 'desc'  => EEH_Template::pretty_status(
1140 1140
                     EEM_Registration::status_id_cancelled,
1141 1141
                     false,
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
                 $EVT_ID
1196 1196
             )
1197 1197
         ) {
1198
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1198
+            $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
1199 1199
                 'new_registration',
1200 1200
                 'add-registrant',
1201 1201
                 ['event_id' => $EVT_ID],
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
                 ],
1354 1354
                 REG_ADMIN_URL
1355 1355
             );
1356
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1356
+            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1357 1357
                 [
1358 1358
                     'action' => 'default',
1359 1359
                     'EVT_ID' => $event_id,
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
                 ],
1362 1362
                 admin_url('admin.php')
1363 1363
             );
1364
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1364
+            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1365 1365
                 [
1366 1366
                     'page'   => 'espresso_events',
1367 1367
                     'action' => 'edit',
@@ -1370,12 +1370,12 @@  discard block
 block discarded – undo
1370 1370
                 admin_url('admin.php')
1371 1371
             );
1372 1372
             // next and previous links
1373
-            $next_reg                                      = $this->_registration->next(
1373
+            $next_reg = $this->_registration->next(
1374 1374
                 null,
1375 1375
                 [],
1376 1376
                 'REG_ID'
1377 1377
             );
1378
-            $this->_template_args['next_registration']     = $next_reg
1378
+            $this->_template_args['next_registration'] = $next_reg
1379 1379
                 ? $this->_next_link(
1380 1380
                     EE_Admin_Page::add_query_args_and_nonce(
1381 1381
                         [
@@ -1387,7 +1387,7 @@  discard block
 block discarded – undo
1387 1387
                     'dashicons dashicons-arrow-right ee-icon-size-22'
1388 1388
                 )
1389 1389
                 : '';
1390
-            $previous_reg                                  = $this->_registration->previous(
1390
+            $previous_reg = $this->_registration->previous(
1391 1391
                 null,
1392 1392
                 [],
1393 1393
                 'REG_ID'
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
                 )
1406 1406
                 : '';
1407 1407
             // grab header
1408
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1408
+            $template_path                             = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1409 1409
             $this->_template_args['REG_ID']            = $this->_registration->ID();
1410 1410
             $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1411 1411
                 $template_path,
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
                                 EEH_HTML::strong(
1560 1560
                                     $this->_registration->pretty_status(),
1561 1561
                                     '',
1562
-                                    'status-' . $this->_registration->status_ID(),
1562
+                                    'status-'.$this->_registration->status_ID(),
1563 1563
                                     'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1564 1564
                                 )
1565 1565
                             )
@@ -1575,7 +1575,7 @@  discard block
 block discarded – undo
1575 1575
                 $this->_registration->ID()
1576 1576
             )
1577 1577
         ) {
1578
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1578
+            $reg_status_change_form_array['subsections']['reg_status'] = new EE_Select_Input(
1579 1579
                 $this->_get_reg_statuses(),
1580 1580
                 [
1581 1581
                     'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
@@ -1592,7 +1592,7 @@  discard block
 block discarded – undo
1592 1592
                     ),
1593 1593
                 ]
1594 1594
             );
1595
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1595
+            $reg_status_change_form_array['subsections']['submit'] = new EE_Submit_Input(
1596 1596
                 [
1597 1597
                     'html_class'      => 'button-primary',
1598 1598
                     'html_label_text' => '&nbsp;',
@@ -1617,7 +1617,7 @@  discard block
 block discarded – undo
1617 1617
     protected function _get_reg_statuses()
1618 1618
     {
1619 1619
         $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1620
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1620
+        unset($reg_status_array[EEM_Registration::status_id_incomplete]);
1621 1621
         // get current reg status
1622 1622
         $current_status = $this->_registration->status_ID();
1623 1623
         // is registration for free event? This will determine whether to display the pending payment option
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
             $current_status !== EEM_Registration::status_id_pending_payment
1626 1626
             && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1627 1627
         ) {
1628
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1628
+            unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1629 1629
         }
1630 1630
         return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1631 1631
     }
@@ -1716,7 +1716,7 @@  discard block
 block discarded – undo
1716 1716
         $success = false;
1717 1717
         // typecast $REG_IDs
1718 1718
         $REG_IDs = (array) $REG_IDs;
1719
-        if (! empty($REG_IDs)) {
1719
+        if ( ! empty($REG_IDs)) {
1720 1720
             $success = true;
1721 1721
             // set default status if none is passed
1722 1722
             $status         = $status ?: EEM_Registration::status_id_pending_payment;
@@ -1876,7 +1876,7 @@  discard block
 block discarded – undo
1876 1876
             $action,
1877 1877
             $notify
1878 1878
         );
1879
-        $method = $action . '_registration';
1879
+        $method = $action.'_registration';
1880 1880
         if (method_exists($this, $method)) {
1881 1881
             $this->$method($notify);
1882 1882
         }
@@ -2026,7 +2026,7 @@  discard block
 block discarded – undo
2026 2026
         $filters        = new EE_Line_Item_Filter_Collection();
2027 2027
         $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2028 2028
         $filters->add(new EE_Non_Zero_Line_Item_Filter());
2029
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2029
+        $line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2030 2030
             $filters,
2031 2031
             $transaction->total_line_item()
2032 2032
         );
@@ -2039,7 +2039,7 @@  discard block
 block discarded – undo
2039 2039
             $filtered_line_item_tree,
2040 2040
             ['EE_Registration' => $this->_registration]
2041 2041
         );
2042
-        $attendee                                = $this->_registration->attendee();
2042
+        $attendee = $this->_registration->attendee();
2043 2043
         if (
2044 2044
             EE_Registry::instance()->CAP->current_user_can(
2045 2045
                 'ee_read_transaction',
@@ -2121,7 +2121,7 @@  discard block
 block discarded – undo
2121 2121
                 'Payment method response',
2122 2122
                 'event_espresso'
2123 2123
             );
2124
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2124
+            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2125 2125
         }
2126 2126
         $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2127 2127
         $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
@@ -2151,7 +2151,7 @@  discard block
 block discarded – undo
2151 2151
         $this->_template_args['REG_ID']                                       = $this->_registration->ID();
2152 2152
         $this->_template_args['event_id']                                     = $this->_registration->event_ID();
2153 2153
         $template_path                                                        =
2154
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2154
+            REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
2155 2155
         EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2156 2156
     }
2157 2157
 
@@ -2189,7 +2189,7 @@  discard block
 block discarded – undo
2189 2189
             $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2190 2190
             $this->_template_args['REG_ID']                    = $this->_registration->ID();
2191 2191
             $template_path                                     =
2192
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2192
+                REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
2193 2193
             EEH_Template::display_template($template_path, $this->_template_args);
2194 2194
         }
2195 2195
     }
@@ -2205,7 +2205,7 @@  discard block
 block discarded – undo
2205 2205
     public function form_before_question_group($output)
2206 2206
     {
2207 2207
         EE_Error::doing_it_wrong(
2208
-            __CLASS__ . '::' . __FUNCTION__,
2208
+            __CLASS__.'::'.__FUNCTION__,
2209 2209
             esc_html__(
2210 2210
                 '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.',
2211 2211
                 'event_espresso'
@@ -2229,7 +2229,7 @@  discard block
 block discarded – undo
2229 2229
     public function form_after_question_group($output)
2230 2230
     {
2231 2231
         EE_Error::doing_it_wrong(
2232
-            __CLASS__ . '::' . __FUNCTION__,
2232
+            __CLASS__.'::'.__FUNCTION__,
2233 2233
             esc_html__(
2234 2234
                 '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.',
2235 2235
                 'event_espresso'
@@ -2266,7 +2266,7 @@  discard block
 block discarded – undo
2266 2266
     public function form_form_field_label_wrap($label)
2267 2267
     {
2268 2268
         EE_Error::doing_it_wrong(
2269
-            __CLASS__ . '::' . __FUNCTION__,
2269
+            __CLASS__.'::'.__FUNCTION__,
2270 2270
             esc_html__(
2271 2271
                 '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.',
2272 2272
                 'event_espresso'
@@ -2276,7 +2276,7 @@  discard block
 block discarded – undo
2276 2276
         return '
2277 2277
 			<tr>
2278 2278
 				<th>
2279
-					' . $label . '
2279
+					' . $label.'
2280 2280
 				</th>';
2281 2281
     }
2282 2282
 
@@ -2291,7 +2291,7 @@  discard block
 block discarded – undo
2291 2291
     public function form_form_field_input__wrap($input)
2292 2292
     {
2293 2293
         EE_Error::doing_it_wrong(
2294
-            __CLASS__ . '::' . __FUNCTION__,
2294
+            __CLASS__.'::'.__FUNCTION__,
2295 2295
             esc_html__(
2296 2296
                 '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.',
2297 2297
                 'event_espresso'
@@ -2300,7 +2300,7 @@  discard block
 block discarded – undo
2300 2300
         );
2301 2301
         return '
2302 2302
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2303
-					' . $input . '
2303
+					' . $input.'
2304 2304
 				</td>
2305 2305
 			</tr>';
2306 2306
     }
@@ -2349,8 +2349,8 @@  discard block
 block discarded – undo
2349 2349
      */
2350 2350
     protected function _get_reg_custom_questions_form($REG_ID)
2351 2351
     {
2352
-        if (! $this->_reg_custom_questions_form) {
2353
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2352
+        if ( ! $this->_reg_custom_questions_form) {
2353
+            require_once(REG_ADMIN.'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2354 2354
             $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2355 2355
                 $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2356 2356
             );
@@ -2373,7 +2373,7 @@  discard block
 block discarded – undo
2373 2373
      */
2374 2374
     private function _save_reg_custom_questions_form($REG_ID = 0)
2375 2375
     {
2376
-        if (! $REG_ID) {
2376
+        if ( ! $REG_ID) {
2377 2377
             EE_Error::add_error(
2378 2378
                 esc_html__(
2379 2379
                     'An error occurred. No registration ID was received.',
@@ -2390,7 +2390,7 @@  discard block
 block discarded – undo
2390 2390
         if ($form->is_valid()) {
2391 2391
             foreach ($form->subforms() as $question_group_form) {
2392 2392
                 foreach ($question_group_form->inputs() as $question_id => $input) {
2393
-                    $where_conditions    = [
2393
+                    $where_conditions = [
2394 2394
                         'QST_ID' => $question_id,
2395 2395
                         'REG_ID' => $REG_ID,
2396 2396
                     ];
@@ -2431,7 +2431,7 @@  discard block
 block discarded – undo
2431 2431
         $REG = $this->getRegistrationModel();
2432 2432
         // get all other registrations on this transaction, and cache
2433 2433
         // the attendees for them so we don't have to run another query using force_join
2434
-        $registrations                           = $REG->get_all(
2434
+        $registrations = $REG->get_all(
2435 2435
             [
2436 2436
                 [
2437 2437
                     'TXN_ID' => $this->_registration->transaction_ID(),
@@ -2465,23 +2465,23 @@  discard block
 block discarded – undo
2465 2465
                 $attendee                                                      = $registration->attendee()
2466 2466
                     ? $registration->attendee()
2467 2467
                     : $this->getAttendeeModel()->create_default_object();
2468
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2469
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2470
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2471
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2472
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2473
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2468
+                $this->_template_args['attendees'][$att_nmbr]['STS_ID']      = $registration->status_ID();
2469
+                $this->_template_args['attendees'][$att_nmbr]['fname']       = $attendee->fname();
2470
+                $this->_template_args['attendees'][$att_nmbr]['lname']       = $attendee->lname();
2471
+                $this->_template_args['attendees'][$att_nmbr]['email']       = $attendee->email();
2472
+                $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();
2473
+                $this->_template_args['attendees'][$att_nmbr]['address']     = implode(
2474 2474
                     ', ',
2475 2475
                     $attendee->full_address_as_array()
2476 2476
                 );
2477
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2477
+                $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(
2478 2478
                     [
2479 2479
                         'action' => 'edit_attendee',
2480 2480
                         'post'   => $attendee->ID(),
2481 2481
                     ],
2482 2482
                     REG_ADMIN_URL
2483 2483
                 );
2484
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2484
+                $this->_template_args['attendees'][$att_nmbr]['event_name'] =
2485 2485
                     $registration->event_obj() instanceof EE_Event
2486 2486
                         ? $registration->event_obj()->name()
2487 2487
                         : '';
@@ -2489,7 +2489,7 @@  discard block
 block discarded – undo
2489 2489
             }
2490 2490
             $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2491 2491
         }
2492
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2492
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
2493 2493
         EEH_Template::display_template($template_path, $this->_template_args);
2494 2494
     }
2495 2495
 
@@ -2515,11 +2515,11 @@  discard block
 block discarded – undo
2515 2515
         // now let's determine if this is not the primary registration.  If it isn't then we set the
2516 2516
         // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2517 2517
         // primary registration object (that way we know if we need to show create button or not)
2518
-        if (! $this->_registration->is_primary_registrant()) {
2518
+        if ( ! $this->_registration->is_primary_registrant()) {
2519 2519
             $primary_registration = $this->_registration->get_primary_registration();
2520 2520
             $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2521 2521
                 : null;
2522
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2522
+            if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2523 2523
                 // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2524 2524
                 // custom attendee object so let's not worry about the primary reg.
2525 2525
                 $primary_registration = null;
@@ -2534,7 +2534,7 @@  discard block
 block discarded – undo
2534 2534
         $this->_template_args['phone']             = $attendee->phone();
2535 2535
         $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2536 2536
         // edit link
2537
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2537
+        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2538 2538
             [
2539 2539
                 'action' => 'edit_attendee',
2540 2540
                 'post'   => $attendee->ID(),
@@ -2543,7 +2543,7 @@  discard block
 block discarded – undo
2543 2543
         );
2544 2544
         $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2545 2545
         // create link
2546
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2546
+        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2547 2547
             ? EE_Admin_Page::add_query_args_and_nonce(
2548 2548
                 [
2549 2549
                     'action'  => 'duplicate_attendee',
@@ -2554,7 +2554,7 @@  discard block
 block discarded – undo
2554 2554
         $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2555 2555
         $this->_template_args['att_check']    = $att_check;
2556 2556
         $template_path                        =
2557
-            REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2557
+            REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
2558 2558
         EEH_Template::display_template($template_path, $this->_template_args);
2559 2559
     }
2560 2560
 
@@ -2598,7 +2598,7 @@  discard block
 block discarded – undo
2598 2598
             /** @var EE_Registration $REG */
2599 2599
             $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2600 2600
             $payments = $REG->registration_payments();
2601
-            if (! empty($payments)) {
2601
+            if ( ! empty($payments)) {
2602 2602
                 $name           = $REG->attendee() instanceof EE_Attendee
2603 2603
                     ? $REG->attendee()->full_name()
2604 2604
                     : esc_html__('Unknown Attendee', 'event_espresso');
@@ -2662,17 +2662,17 @@  discard block
 block discarded – undo
2662 2662
         // Checkboxes
2663 2663
         $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2664 2664
 
2665
-        if (! empty($REG_IDs)) {
2665
+        if ( ! empty($REG_IDs)) {
2666 2666
             // if array has more than one element than success message should be plural
2667 2667
             $success = count($REG_IDs) > 1 ? 2 : 1;
2668 2668
             // cycle thru checkboxes
2669 2669
             foreach ($REG_IDs as $REG_ID) {
2670 2670
                 $REG = $REG_MDL->get_one_by_ID($REG_ID);
2671
-                if (! $REG instanceof EE_Registration) {
2671
+                if ( ! $REG instanceof EE_Registration) {
2672 2672
                     continue;
2673 2673
                 }
2674 2674
                 $deleted = $this->_delete_registration($REG);
2675
-                if (! $deleted) {
2675
+                if ( ! $deleted) {
2676 2676
                     $success = 0;
2677 2677
                 }
2678 2678
             }
@@ -2709,7 +2709,7 @@  discard block
 block discarded – undo
2709 2709
         // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2710 2710
         // registrations on the transaction that are NOT trashed.
2711 2711
         $TXN = $REG->get_first_related('Transaction');
2712
-        if (! $TXN instanceof EE_Transaction) {
2712
+        if ( ! $TXN instanceof EE_Transaction) {
2713 2713
             EE_Error::add_error(
2714 2714
                 sprintf(
2715 2715
                     esc_html__(
@@ -2727,11 +2727,11 @@  discard block
 block discarded – undo
2727 2727
         $REGS        = $TXN->get_many_related('Registration');
2728 2728
         $all_trashed = true;
2729 2729
         foreach ($REGS as $registration) {
2730
-            if (! $registration->get('REG_deleted')) {
2730
+            if ( ! $registration->get('REG_deleted')) {
2731 2731
                 $all_trashed = false;
2732 2732
             }
2733 2733
         }
2734
-        if (! $all_trashed) {
2734
+        if ( ! $all_trashed) {
2735 2735
             EE_Error::add_error(
2736 2736
                 esc_html__(
2737 2737
                     '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.',
@@ -2793,7 +2793,7 @@  discard block
 block discarded – undo
2793 2793
      */
2794 2794
     public function new_registration()
2795 2795
     {
2796
-        if (! $this->_set_reg_event()) {
2796
+        if ( ! $this->_set_reg_event()) {
2797 2797
             throw new EE_Error(
2798 2798
                 esc_html__(
2799 2799
                     'Unable to continue with registering because there is no Event ID in the request',
@@ -2825,7 +2825,7 @@  discard block
 block discarded – undo
2825 2825
                 ],
2826 2826
                 EVENTS_ADMIN_URL
2827 2827
             );
2828
-            $edit_event_lnk                     = '<a href="'
2828
+            $edit_event_lnk = '<a href="'
2829 2829
                                                   . $edit_event_url
2830 2830
                                                   . '" title="'
2831 2831
                                                   . esc_attr__('Edit ', 'event_espresso')
@@ -2843,7 +2843,7 @@  discard block
 block discarded – undo
2843 2843
         }
2844 2844
         // grab header
2845 2845
         $template_path                              =
2846
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2846
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2847 2847
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2848 2848
             $template_path,
2849 2849
             $this->_template_args,
@@ -2884,7 +2884,7 @@  discard block
 block discarded – undo
2884 2884
                 '</b>'
2885 2885
             );
2886 2886
             return '
2887
-	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2887
+	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div>
2888 2888
 	<script >
2889 2889
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
2890 2890
 		// after just adding a new registration... we gotta try to put a stop to that !!!
@@ -2926,7 +2926,7 @@  discard block
 block discarded – undo
2926 2926
                 );
2927 2927
                 $template_args['content']                          =
2928 2928
                     EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2929
-                $template_args['content']                          .= '</div>';
2929
+                $template_args['content'] .= '</div>';
2930 2930
                 $template_args['step_button_text']                 = esc_html__(
2931 2931
                     'Add Tickets and Continue to Registrant Details',
2932 2932
                     'event_espresso'
@@ -2953,7 +2953,7 @@  discard block
 block discarded – undo
2953 2953
         // we come back to the process_registration_step route.
2954 2954
         $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2955 2955
         return EEH_Template::display_template(
2956
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2956
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php',
2957 2957
             $template_args,
2958 2958
             true
2959 2959
         );
@@ -2976,7 +2976,7 @@  discard block
 block discarded – undo
2976 2976
         }
2977 2977
 
2978 2978
         $EVT_ID = $this->request->getRequestParam('event_id[reg_status]', 0, 'int');
2979
-        if (! $EVT_ID) {
2979
+        if ( ! $EVT_ID) {
2980 2980
             return false;
2981 2981
         }
2982 2982
         $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
@@ -3046,7 +3046,7 @@  discard block
 block discarded – undo
3046 3046
                 }
3047 3047
                 break;
3048 3048
             case 'questions':
3049
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3049
+                if ( ! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3050 3050
                     add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3051 3051
                 }
3052 3052
                 // process registration
@@ -3057,7 +3057,7 @@  discard block
 block discarded – undo
3057 3057
                         $grand_total->save_this_and_descendants_to_txn();
3058 3058
                     }
3059 3059
                 }
3060
-                if (! $transaction instanceof EE_Transaction) {
3060
+                if ( ! $transaction instanceof EE_Transaction) {
3061 3061
                     $query_args = [
3062 3062
                         'action'                  => 'new_registration',
3063 3063
                         'processing_registration' => 2,
@@ -3079,7 +3079,7 @@  discard block
 block discarded – undo
3079 3079
                     return;
3080 3080
                 }
3081 3081
                 // maybe update status, and make sure to save transaction if not done already
3082
-                if (! $transaction->update_status_based_on_total_paid()) {
3082
+                if ( ! $transaction->update_status_based_on_total_paid()) {
3083 3083
                     $transaction->save();
3084 3084
                 }
3085 3085
                 EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
@@ -3161,7 +3161,7 @@  discard block
 block discarded – undo
3161 3161
     public function get_attendees($per_page, $count = false, $trash = false)
3162 3162
     {
3163 3163
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3164
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3164
+        require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
3165 3165
         $orderby = $this->request->getRequestParam('orderby');
3166 3166
         switch ($orderby) {
3167 3167
             case 'ATT_ID':
@@ -3184,7 +3184,7 @@  discard block
 block discarded – undo
3184 3184
         $_where       = [];
3185 3185
         $search_term  = $this->request->getRequestParam('s');
3186 3186
         if ($search_term) {
3187
-            $search_term  = '%' . $search_term . '%';
3187
+            $search_term  = '%'.$search_term.'%';
3188 3188
             $_where['OR'] = [
3189 3189
                 'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3190 3190
                 'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
@@ -3211,7 +3211,7 @@  discard block
 block discarded – undo
3211 3211
             'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3212 3212
             'limit'         => $limit,
3213 3213
         ];
3214
-        if (! $count) {
3214
+        if ( ! $count) {
3215 3215
             $query_args['order_by'] = [$orderby => $sort];
3216 3216
         }
3217 3217
         $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
@@ -3256,7 +3256,7 @@  discard block
 block discarded – undo
3256 3256
         $EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3257 3257
             ? $this->request->getRequestParam('EVT_ID', 0, 'int')
3258 3258
             : null;
3259
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3259
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3260 3260
             $request_params = $this->request->requestParams();
3261 3261
             wp_redirect(
3262 3262
                 EE_Admin_Page::add_query_args_and_nonce(
@@ -3284,8 +3284,8 @@  discard block
 block discarded – undo
3284 3284
                 'EVT_ID' => $EVT_ID,
3285 3285
             ];
3286 3286
             $this->request->mergeRequestParams($new_request_args);
3287
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3288
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3287
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3288
+                require_once(EE_CLASSES.'EE_Export.class.php');
3289 3289
                 $EE_Export = EE_Export::instance($this->request->requestParams());
3290 3290
                 $EE_Export->export();
3291 3291
             }
@@ -3306,8 +3306,8 @@  discard block
 block discarded – undo
3306 3306
 
3307 3307
     public function _contact_list_export()
3308 3308
     {
3309
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3310
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3309
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3310
+            require_once(EE_CLASSES.'EE_Export.class.php');
3311 3311
             $EE_Export = EE_Export::instance($this->request->requestParams());
3312 3312
             $EE_Export->export_attendees();
3313 3313
         }
@@ -3316,7 +3316,7 @@  discard block
 block discarded – undo
3316 3316
 
3317 3317
     public function _contact_list_report()
3318 3318
     {
3319
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3319
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3320 3320
             wp_redirect(
3321 3321
                 EE_Admin_Page::add_query_args_and_nonce(
3322 3322
                     [
@@ -3328,8 +3328,8 @@  discard block
 block discarded – undo
3328 3328
                 )
3329 3329
             );
3330 3330
         } else {
3331
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3332
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3331
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3332
+                require_once(EE_CLASSES.'EE_Export.class.php');
3333 3333
                 $EE_Export = EE_Export::instance($this->request->requestParams());
3334 3334
                 $EE_Export->report_attendees();
3335 3335
             }
@@ -3356,7 +3356,7 @@  discard block
 block discarded – undo
3356 3356
         $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3357 3357
         $action = $this->request->getRequestParam('return', 'default');
3358 3358
         // verify we have necessary info
3359
-        if (! $REG_ID) {
3359
+        if ( ! $REG_ID) {
3360 3360
             EE_Error::add_error(
3361 3361
                 esc_html__(
3362 3362
                     'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
@@ -3371,7 +3371,7 @@  discard block
 block discarded – undo
3371 3371
         }
3372 3372
         // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3373 3373
         $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3374
-        if (! $registration instanceof EE_Registration) {
3374
+        if ( ! $registration instanceof EE_Registration) {
3375 3375
             throw new RuntimeException(
3376 3376
                 sprintf(
3377 3377
                     esc_html__(
@@ -3510,16 +3510,16 @@  discard block
 block discarded – undo
3510 3510
         $this->verify_cpt_object();
3511 3511
         remove_meta_box(
3512 3512
             'postexcerpt',
3513
-            $this->_cpt_routes[ $this->_req_action ],
3513
+            $this->_cpt_routes[$this->_req_action],
3514 3514
             'normal'
3515 3515
         );
3516
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3516
+        remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal');
3517 3517
         if (post_type_supports('espresso_attendees', 'excerpt')) {
3518 3518
             add_meta_box(
3519 3519
                 'postexcerpt',
3520 3520
                 esc_html__('Short Biography', 'event_espresso'),
3521 3521
                 'post_excerpt_meta_box',
3522
-                $this->_cpt_routes[ $this->_req_action ],
3522
+                $this->_cpt_routes[$this->_req_action],
3523 3523
                 'normal'
3524 3524
             );
3525 3525
         }
@@ -3528,7 +3528,7 @@  discard block
 block discarded – undo
3528 3528
                 'commentsdiv',
3529 3529
                 esc_html__('Notes on the Contact', 'event_espresso'),
3530 3530
                 'post_comment_meta_box',
3531
-                $this->_cpt_routes[ $this->_req_action ],
3531
+                $this->_cpt_routes[$this->_req_action],
3532 3532
                 'normal',
3533 3533
                 'core'
3534 3534
             );
@@ -3537,7 +3537,7 @@  discard block
 block discarded – undo
3537 3537
             'attendee_contact_info',
3538 3538
             esc_html__('Contact Info', 'event_espresso'),
3539 3539
             [$this, 'attendee_contact_info'],
3540
-            $this->_cpt_routes[ $this->_req_action ],
3540
+            $this->_cpt_routes[$this->_req_action],
3541 3541
             'side',
3542 3542
             'core'
3543 3543
         );
@@ -3545,7 +3545,7 @@  discard block
 block discarded – undo
3545 3545
             'attendee_details_address',
3546 3546
             esc_html__('Address Details', 'event_espresso'),
3547 3547
             [$this, 'attendee_address_details'],
3548
-            $this->_cpt_routes[ $this->_req_action ],
3548
+            $this->_cpt_routes[$this->_req_action],
3549 3549
             'normal',
3550 3550
             'core'
3551 3551
         );
@@ -3553,7 +3553,7 @@  discard block
 block discarded – undo
3553 3553
             'attendee_registrations',
3554 3554
             esc_html__('Registrations for this Contact', 'event_espresso'),
3555 3555
             [$this, 'attendee_registrations_meta_box'],
3556
-            $this->_cpt_routes[ $this->_req_action ],
3556
+            $this->_cpt_routes[$this->_req_action],
3557 3557
             'normal',
3558 3558
             'high'
3559 3559
         );
@@ -3654,8 +3654,8 @@  discard block
 block discarded – undo
3654 3654
                 ]
3655 3655
             )
3656 3656
         );
3657
-        $template                             =
3658
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3657
+        $template =
3658
+            REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
3659 3659
         EEH_Template::display_template($template, $this->_template_args);
3660 3660
     }
3661 3661
 
@@ -3677,7 +3677,7 @@  discard block
 block discarded – undo
3677 3677
         $this->_template_args['attendee']      = $this->_cpt_model_obj;
3678 3678
         $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3679 3679
         $template                              =
3680
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3680
+            REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
3681 3681
         EEH_Template::display_template($template, $this->_template_args);
3682 3682
     }
3683 3683
 
@@ -3692,7 +3692,7 @@  discard block
 block discarded – undo
3692 3692
     public function after_title_form_fields($post)
3693 3693
     {
3694 3694
         if ($post->post_type === 'espresso_attendees') {
3695
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3695
+            $template                  = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
3696 3696
             $template_args['attendee'] = $this->_cpt_model_obj;
3697 3697
             EEH_Template::display_template($template, $template_args);
3698 3698
         }
@@ -3721,7 +3721,7 @@  discard block
 block discarded – undo
3721 3721
             // cycle thru checkboxes
3722 3722
             foreach ($ATT_IDs as $ATT_ID) {
3723 3723
                 $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3724
-                if (! $updated) {
3724
+                if ( ! $updated) {
3725 3725
                     $success = 0;
3726 3726
                 }
3727 3727
             }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +4111 added lines, -4111 removed lines patch added patch discarded remove patch
@@ -18,4187 +18,4187 @@
 block discarded – undo
18 18
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var LoaderInterface
23
-     */
24
-    protected $loader;
21
+	/**
22
+	 * @var LoaderInterface
23
+	 */
24
+	protected $loader;
25 25
 
26
-    /**
27
-     * @var RequestInterface
28
-     */
29
-    protected $request;
26
+	/**
27
+	 * @var RequestInterface
28
+	 */
29
+	protected $request;
30 30
 
31
-    // set in _init_page_props()
32
-    public $page_slug;
31
+	// set in _init_page_props()
32
+	public $page_slug;
33 33
 
34
-    public $page_label;
34
+	public $page_label;
35 35
 
36
-    public $page_folder;
36
+	public $page_folder;
37 37
 
38
-    // set in define_page_props()
39
-    protected $_admin_base_url;
38
+	// set in define_page_props()
39
+	protected $_admin_base_url;
40 40
 
41
-    protected $_admin_base_path;
41
+	protected $_admin_base_path;
42 42
 
43
-    protected $_admin_page_title;
43
+	protected $_admin_page_title;
44 44
 
45
-    protected $_labels;
45
+	protected $_labels;
46 46
 
47 47
 
48
-    // set early within EE_Admin_Init
49
-    protected $_wp_page_slug;
48
+	// set early within EE_Admin_Init
49
+	protected $_wp_page_slug;
50 50
 
51
-    // navtabs
52
-    protected $_nav_tabs;
51
+	// navtabs
52
+	protected $_nav_tabs;
53 53
 
54
-    protected $_default_nav_tab_name;
54
+	protected $_default_nav_tab_name;
55 55
 
56
-    /**
57
-     * @var array $_help_tour
58
-     */
59
-    protected $_help_tour = [];
56
+	/**
57
+	 * @var array $_help_tour
58
+	 */
59
+	protected $_help_tour = [];
60 60
 
61 61
 
62
-    // template variables (used by templates)
63
-    protected $_template_path;
62
+	// template variables (used by templates)
63
+	protected $_template_path;
64 64
 
65
-    protected $_column_template_path;
65
+	protected $_column_template_path;
66 66
 
67
-    /**
68
-     * @var array $_template_args
69
-     */
70
-    protected $_template_args = [];
67
+	/**
68
+	 * @var array $_template_args
69
+	 */
70
+	protected $_template_args = [];
71 71
 
72
-    /**
73
-     * this will hold the list table object for a given view.
74
-     *
75
-     * @var EE_Admin_List_Table $_list_table_object
76
-     */
77
-    protected $_list_table_object;
72
+	/**
73
+	 * this will hold the list table object for a given view.
74
+	 *
75
+	 * @var EE_Admin_List_Table $_list_table_object
76
+	 */
77
+	protected $_list_table_object;
78 78
 
79
-    // bools
80
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
79
+	// bools
80
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
81 81
 
82
-    protected $_routing;
82
+	protected $_routing;
83 83
 
84
-    // list table args
85
-    protected $_view;
84
+	// list table args
85
+	protected $_view;
86 86
 
87
-    protected $_views;
87
+	protected $_views;
88 88
 
89 89
 
90
-    // action => method pairs used for routing incoming requests
91
-    protected $_page_routes;
90
+	// action => method pairs used for routing incoming requests
91
+	protected $_page_routes;
92 92
 
93
-    /**
94
-     * @var array $_page_config
95
-     */
96
-    protected $_page_config;
93
+	/**
94
+	 * @var array $_page_config
95
+	 */
96
+	protected $_page_config;
97 97
 
98
-    /**
99
-     * the current page route and route config
100
-     *
101
-     * @var string $_route
102
-     */
103
-    protected $_route;
98
+	/**
99
+	 * the current page route and route config
100
+	 *
101
+	 * @var string $_route
102
+	 */
103
+	protected $_route;
104 104
 
105
-    /**
106
-     * @var string $_cpt_route
107
-     */
108
-    protected $_cpt_route;
105
+	/**
106
+	 * @var string $_cpt_route
107
+	 */
108
+	protected $_cpt_route;
109 109
 
110
-    /**
111
-     * @var array $_route_config
112
-     */
113
-    protected $_route_config;
110
+	/**
111
+	 * @var array $_route_config
112
+	 */
113
+	protected $_route_config;
114 114
 
115
-    /**
116
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
117
-     * actions.
118
-     *
119
-     * @since 4.6.x
120
-     * @var array.
121
-     */
122
-    protected $_default_route_query_args;
123
-
124
-    // set via request page and action args.
125
-    protected $_current_page;
126
-
127
-    protected $_current_view;
128
-
129
-    protected $_current_page_view_url;
130
-
131
-    /**
132
-     * unprocessed value for the 'action' request param (default '')
133
-     *
134
-     * @var string
135
-     */
136
-    protected $raw_req_action = '';
137
-
138
-    /**
139
-     * unprocessed value for the 'page' request param (default '')
140
-     *
141
-     * @var string
142
-     */
143
-    protected $raw_req_page = '';
144
-
145
-    /**
146
-     * sanitized request action (and nonce)
147
-     *
148
-     * @var string
149
-     */
150
-    protected $_req_action = '';
151
-
152
-    /**
153
-     * sanitized request action nonce
154
-     *
155
-     * @var string
156
-     */
157
-    protected $_req_nonce = '';
158
-
159
-    /**
160
-     * @var string
161
-     */
162
-    protected $_search_btn_label = '';
163
-
164
-    /**
165
-     * @var string
166
-     */
167
-    protected $_search_box_callback = '';
168
-
169
-    /**
170
-     * @var WP_Screen
171
-     */
172
-    protected $_current_screen;
173
-
174
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
175
-    protected $_hook_obj;
176
-
177
-    // for holding incoming request data
178
-    protected $_req_data = [];
179
-
180
-    // yes / no array for admin form fields
181
-    protected $_yes_no_values = [];
182
-
183
-    // some default things shared by all child classes
184
-    protected $_default_espresso_metaboxes;
185
-
186
-    /**
187
-     * @var EE_Registry
188
-     */
189
-    protected $EE = null;
190
-
191
-
192
-    /**
193
-     * This is just a property that flags whether the given route is a caffeinated route or not.
194
-     *
195
-     * @var boolean
196
-     */
197
-    protected $_is_caf = false;
198
-
199
-
200
-    /**
201
-     * @Constructor
202
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
203
-     * @throws EE_Error
204
-     * @throws InvalidArgumentException
205
-     * @throws ReflectionException
206
-     * @throws InvalidDataTypeException
207
-     * @throws InvalidInterfaceException
208
-     */
209
-    public function __construct($routing = true)
210
-    {
211
-        $this->loader  = LoaderFactory::getLoader();
212
-        $this->request = $this->loader->getShared(RequestInterface::class);
213
-        $this->_routing = $routing;
214
-
215
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
216
-            $this->_is_caf = true;
217
-        }
218
-        $this->_yes_no_values = [
219
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
220
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
221
-        ];
222
-        // set the _req_data property.
223
-        $this->_req_data = $this->request->requestParams();
224
-        // set initial page props (child method)
225
-        $this->_init_page_props();
226
-        // set global defaults
227
-        $this->_set_defaults();
228
-        // set early because incoming requests could be ajax related and we need to register those hooks.
229
-        $this->_global_ajax_hooks();
230
-        $this->_ajax_hooks();
231
-        // other_page_hooks have to be early too.
232
-        $this->_do_other_page_hooks();
233
-        // set up page dependencies
234
-        $this->_before_page_setup();
235
-        $this->_page_setup();
236
-        // die();
237
-    }
238
-
239
-
240
-    /**
241
-     * _init_page_props
242
-     * Child classes use to set at least the following properties:
243
-     * $page_slug.
244
-     * $page_label.
245
-     *
246
-     * @abstract
247
-     * @return void
248
-     */
249
-    abstract protected function _init_page_props();
250
-
251
-
252
-    /**
253
-     * _ajax_hooks
254
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
255
-     * Note: within the ajax callback methods.
256
-     *
257
-     * @abstract
258
-     * @return void
259
-     */
260
-    abstract protected function _ajax_hooks();
261
-
262
-
263
-    /**
264
-     * _define_page_props
265
-     * child classes define page properties in here.  Must include at least:
266
-     * $_admin_base_url = base_url for all admin pages
267
-     * $_admin_page_title = default admin_page_title for admin pages
268
-     * $_labels = array of default labels for various automatically generated elements:
269
-     *    array(
270
-     *        'buttons' => array(
271
-     *            'add' => esc_html__('label for add new button'),
272
-     *            'edit' => esc_html__('label for edit button'),
273
-     *            'delete' => esc_html__('label for delete button')
274
-     *            )
275
-     *        )
276
-     *
277
-     * @abstract
278
-     * @return void
279
-     */
280
-    abstract protected function _define_page_props();
281
-
282
-
283
-    /**
284
-     * _set_page_routes
285
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
286
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
287
-     * have a 'default' route. Here's the format
288
-     * $this->_page_routes = array(
289
-     *        'default' => array(
290
-     *            'func' => '_default_method_handling_route',
291
-     *            'args' => array('array','of','args'),
292
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
293
-     *            ajax request, backend processing)
294
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
295
-     *            headers route after.  The string you enter here should match the defined route reference for a
296
-     *            headers sent route.
297
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
298
-     *            this route.
299
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
300
-     *            checks).
301
-     *        ),
302
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
303
-     *        handling method.
304
-     *        )
305
-     * )
306
-     *
307
-     * @abstract
308
-     * @return void
309
-     */
310
-    abstract protected function _set_page_routes();
311
-
312
-
313
-    /**
314
-     * _set_page_config
315
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
316
-     * array corresponds to the page_route for the loaded page. Format:
317
-     * $this->_page_config = array(
318
-     *        'default' => array(
319
-     *            'labels' => array(
320
-     *                'buttons' => array(
321
-     *                    'add' => esc_html__('label for adding item'),
322
-     *                    'edit' => esc_html__('label for editing item'),
323
-     *                    'delete' => esc_html__('label for deleting item')
324
-     *                ),
325
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
326
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
327
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
328
-     *            _define_page_props() method
329
-     *            'nav' => array(
330
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
331
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
332
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
333
-     *                'order' => 10, //required to indicate tab position.
334
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
335
-     *                displayed then add this parameter.
336
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
337
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
338
-     *            metaboxes set for eventespresso admin pages.
339
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
340
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
341
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
342
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
343
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
344
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
345
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
346
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
347
-     *            want to display.
348
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
349
-     *                'tab_id' => array(
350
-     *                    'title' => 'tab_title',
351
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
352
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
353
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
354
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
355
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
356
-     *                    attempt to use the callback which should match the name of a method in the class
357
-     *                    ),
358
-     *                'tab2_id' => array(
359
-     *                    'title' => 'tab2 title',
360
-     *                    'filename' => 'file_name_2'
361
-     *                    'callback' => 'callback_method_for_content',
362
-     *                 ),
363
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
364
-     *            help tab area on an admin page. @return void
365
-     *
366
-     * @link
367
-     *                http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
368
-     *                'help_tour' => array(
369
-     *                'name_of_help_tour_class', //all help tours should be a child class of EE_Help_Tour and located
370
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
371
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
372
-     *                ),
373
-     *                'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default
374
-     *                is true if it isn't present).  To remove the requirement for a nonce check when this route is
375
-     *                visited just set
376
-     *                'require_nonce' to FALSE
377
-     *                )
378
-     *                )
379
-     *
380
-     * @abstract
381
-     */
382
-    abstract protected function _set_page_config();
383
-
384
-
385
-
386
-
387
-
388
-    /** end sample help_tour methods **/
389
-    /**
390
-     * _add_screen_options
391
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
392
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
393
-     * to a particular view.
394
-     *
395
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
396
-     *         see also WP_Screen object documents...
397
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
398
-     * @abstract
399
-     * @return void
400
-     */
401
-    abstract protected function _add_screen_options();
402
-
403
-
404
-    /**
405
-     * _add_feature_pointers
406
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
407
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
408
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
409
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
410
-     * extended) also see:
411
-     *
412
-     * @link   http://eamann.com/tech/wordpress-portland/
413
-     * @abstract
414
-     * @return void
415
-     */
416
-    abstract protected function _add_feature_pointers();
417
-
418
-
419
-    /**
420
-     * load_scripts_styles
421
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
422
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
423
-     * scripts/styles per view by putting them in a dynamic function in this format
424
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
425
-     *
426
-     * @abstract
427
-     * @return void
428
-     */
429
-    abstract public function load_scripts_styles();
430
-
431
-
432
-    /**
433
-     * admin_init
434
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
435
-     * all pages/views loaded by child class.
436
-     *
437
-     * @abstract
438
-     * @return void
439
-     */
440
-    abstract public function admin_init();
441
-
442
-
443
-    /**
444
-     * admin_notices
445
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
446
-     * all pages/views loaded by child class.
447
-     *
448
-     * @abstract
449
-     * @return void
450
-     */
451
-    abstract public function admin_notices();
452
-
453
-
454
-    /**
455
-     * admin_footer_scripts
456
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
457
-     * will apply to all pages/views loaded by child class.
458
-     *
459
-     * @return void
460
-     */
461
-    abstract public function admin_footer_scripts();
462
-
463
-
464
-    /**
465
-     * admin_footer
466
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
467
-     * apply to all pages/views loaded by child class.
468
-     *
469
-     * @return void
470
-     */
471
-    public function admin_footer()
472
-    {
473
-    }
474
-
475
-
476
-    /**
477
-     * _global_ajax_hooks
478
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
479
-     * Note: within the ajax callback methods.
480
-     *
481
-     * @abstract
482
-     * @return void
483
-     */
484
-    protected function _global_ajax_hooks()
485
-    {
486
-        // for lazy loading of metabox content
487
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
488
-    }
489
-
490
-
491
-    public function ajax_metabox_content()
492
-    {
493
-        $content_id  = $this->request->getRequestParam('contentid', '');
494
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
495
-        self::cached_rss_display($content_id, $content_url);
496
-        wp_die();
497
-    }
498
-
499
-
500
-    /**
501
-     * allows extending classes do something specific before the parent constructor runs _page_setup().
502
-     *
503
-     * @return void
504
-     */
505
-    protected function _before_page_setup()
506
-    {
507
-        // default is to do nothing
508
-    }
509
-
510
-
511
-    /**
512
-     * Makes sure any things that need to be loaded early get handled.
513
-     * We also escape early here if the page requested doesn't match the object.
514
-     *
515
-     * @final
516
-     * @return void
517
-     * @throws EE_Error
518
-     * @throws InvalidArgumentException
519
-     * @throws ReflectionException
520
-     * @throws InvalidDataTypeException
521
-     * @throws InvalidInterfaceException
522
-     */
523
-    final protected function _page_setup()
524
-    {
525
-        // requires?
526
-        // admin_init stuff - global - we're setting this REALLY early
527
-        // so if EE_Admin pages have to hook into other WP pages they can.
528
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
529
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
530
-        // next verify if we need to load anything...
531
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
532
-        $this->page_folder   = strtolower(
533
-            str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
534
-        );
535
-        global $ee_menu_slugs;
536
-        $ee_menu_slugs = (array) $ee_menu_slugs;
537
-        if (
538
-            ! $this->request->isAjax()
539
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
540
-        ) {
541
-            return;
542
-        }
543
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
544
-        // we need to copy the action from the second to the first
545
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
546
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
547
-        $action     = $action !== '-1' ? $action : $action2;
548
-        $req_action = $action !== '-1' ? $action : 'default';
549
-
550
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
551
-        // then let's use the route as the action.
552
-        // This covers cases where we're coming in from a list table that isn't on the default route.
553
-        $route = $this->request->getRequestParam('route');
554
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
555
-            ? $route
556
-            : $req_action;
557
-
558
-        $this->_current_view = $this->_req_action;
559
-        $this->_req_nonce    = $this->_req_action . '_nonce';
560
-        $this->_define_page_props();
561
-        $this->_current_page_view_url = add_query_arg(
562
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
563
-            $this->_admin_base_url
564
-        );
565
-        // default things
566
-        $this->_default_espresso_metaboxes = [
567
-            '_espresso_news_post_box',
568
-            '_espresso_links_post_box',
569
-            '_espresso_ratings_request',
570
-            '_espresso_sponsors_post_box',
571
-        ];
572
-        // set page configs
573
-        $this->_set_page_routes();
574
-        $this->_set_page_config();
575
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
576
-        if ($this->request->requestParamIsSet('wp_referer')) {
577
-            $wp_referer = $this->request->getRequestParam('wp_referer');
578
-            if ($wp_referer) {
579
-                $this->_default_route_query_args['wp_referer'] = $wp_referer;
580
-            }
581
-        }
582
-        // for caffeinated and other extended functionality.
583
-        //  If there is a _extend_page_config method
584
-        // then let's run that to modify the all the various page configuration arrays
585
-        if (method_exists($this, '_extend_page_config')) {
586
-            $this->_extend_page_config();
587
-        }
588
-        // for CPT and other extended functionality.
589
-        // If there is an _extend_page_config_for_cpt
590
-        // then let's run that to modify all the various page configuration arrays.
591
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
592
-            $this->_extend_page_config_for_cpt();
593
-        }
594
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
595
-        $this->_page_routes = apply_filters(
596
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
597
-            $this->_page_routes,
598
-            $this
599
-        );
600
-        $this->_page_config = apply_filters(
601
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
602
-            $this->_page_config,
603
-            $this
604
-        );
605
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
606
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
607
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
608
-            add_action(
609
-                'AHEE__EE_Admin_Page__route_admin_request',
610
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
611
-                10,
612
-                2
613
-            );
614
-        }
615
-        // next route only if routing enabled
616
-        if ($this->_routing && ! $this->request->isAjax()) {
617
-            $this->_verify_routes();
618
-            // next let's just check user_access and kill if no access
619
-            $this->check_user_access();
620
-            if ($this->_is_UI_request) {
621
-                // admin_init stuff - global, all views for this page class, specific view
622
-                add_action('admin_init', [$this, 'admin_init'], 10);
623
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
624
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
625
-                }
626
-            } else {
627
-                // hijack regular WP loading and route admin request immediately
628
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
629
-                $this->route_admin_request();
630
-            }
631
-        }
632
-    }
633
-
634
-
635
-    /**
636
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
637
-     *
638
-     * @return void
639
-     * @throws EE_Error
640
-     */
641
-    private function _do_other_page_hooks()
642
-    {
643
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
644
-        foreach ($registered_pages as $page) {
645
-            // now let's setup the file name and class that should be present
646
-            $classname = str_replace('.class.php', '', $page);
647
-            // autoloaders should take care of loading file
648
-            if (! class_exists($classname)) {
649
-                $error_msg[] = sprintf(
650
-                    esc_html__(
651
-                        'Something went wrong with loading the %s admin hooks page.',
652
-                        'event_espresso'
653
-                    ),
654
-                    $page
655
-                );
656
-                $error_msg[] = $error_msg[0]
657
-                               . "\r\n"
658
-                               . sprintf(
659
-                                   esc_html__(
660
-                                       'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
661
-                                       'event_espresso'
662
-                                   ),
663
-                                   $page,
664
-                                   '<br />',
665
-                                   '<strong>' . $classname . '</strong>'
666
-                               );
667
-                throw new EE_Error(implode('||', $error_msg));
668
-            }
669
-            // notice we are passing the instance of this class to the hook object.
670
-            $this->loader->getShared($classname, [$this]);
671
-        }
672
-    }
673
-
674
-
675
-    /**
676
-     * @throws ReflectionException
677
-     * @throws EE_Error
678
-     */
679
-    public function load_page_dependencies()
680
-    {
681
-        try {
682
-            $this->_load_page_dependencies();
683
-        } catch (EE_Error $e) {
684
-            $e->get_error();
685
-        }
686
-    }
687
-
688
-
689
-    /**
690
-     * load_page_dependencies
691
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
692
-     *
693
-     * @return void
694
-     * @throws DomainException
695
-     * @throws EE_Error
696
-     * @throws InvalidArgumentException
697
-     * @throws InvalidDataTypeException
698
-     * @throws InvalidInterfaceException
699
-     */
700
-    protected function _load_page_dependencies()
701
-    {
702
-        // let's set the current_screen and screen options to override what WP set
703
-        $this->_current_screen = get_current_screen();
704
-        // load admin_notices - global, page class, and view specific
705
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
706
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
707
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
708
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
709
-        }
710
-        // load network admin_notices - global, page class, and view specific
711
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
712
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
713
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
714
-        }
715
-        // this will save any per_page screen options if they are present
716
-        $this->_set_per_page_screen_options();
717
-        // setup list table properties
718
-        $this->_set_list_table();
719
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
720
-        // However in some cases the metaboxes will need to be added within a route handling callback.
721
-        $this->_add_registered_meta_boxes();
722
-        $this->_add_screen_columns();
723
-        // add screen options - global, page child class, and view specific
724
-        $this->_add_global_screen_options();
725
-        $this->_add_screen_options();
726
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
727
-        if (method_exists($this, $add_screen_options)) {
728
-            $this->{$add_screen_options}();
729
-        }
730
-        // add help tab(s) and tours- set via page_config and qtips.
731
-        // $this->_add_help_tour();
732
-        $this->_add_help_tabs();
733
-        $this->_add_qtips();
734
-        // add feature_pointers - global, page child class, and view specific
735
-        $this->_add_feature_pointers();
736
-        $this->_add_global_feature_pointers();
737
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
738
-        if (method_exists($this, $add_feature_pointer)) {
739
-            $this->{$add_feature_pointer}();
740
-        }
741
-        // enqueue scripts/styles - global, page class, and view specific
742
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
743
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
744
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
745
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
746
-        }
747
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
748
-        // admin_print_footer_scripts - global, page child class, and view specific.
749
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
750
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
751
-        // is a good use case. Notice the late priority we're giving these
752
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
753
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
754
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
755
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
756
-        }
757
-        // admin footer scripts
758
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
759
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
760
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
761
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
762
-        }
763
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
764
-        // targeted hook
765
-        do_action(
766
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
767
-        );
768
-    }
769
-
770
-
771
-    /**
772
-     * _set_defaults
773
-     * This sets some global defaults for class properties.
774
-     */
775
-    private function _set_defaults()
776
-    {
777
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
778
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
779
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
780
-        $this->_page_config          = $this->_default_route_query_args = [];
781
-        $this->_default_nav_tab_name = 'overview';
782
-        // init template args
783
-        $this->_template_args = [
784
-            'admin_page_header'  => '',
785
-            'admin_page_content' => '',
786
-            'post_body_content'  => '',
787
-            'before_list_table'  => '',
788
-            'after_list_table'   => '',
789
-        ];
790
-    }
791
-
792
-
793
-    /**
794
-     * route_admin_request
795
-     *
796
-     * @return void
797
-     * @throws InvalidArgumentException
798
-     * @throws InvalidInterfaceException
799
-     * @throws InvalidDataTypeException
800
-     * @throws EE_Error
801
-     * @throws ReflectionException
802
-     * @see    _route_admin_request()
803
-     */
804
-    public function route_admin_request()
805
-    {
806
-        try {
807
-            $this->_route_admin_request();
808
-        } catch (EE_Error $e) {
809
-            $e->get_error();
810
-        }
811
-    }
812
-
813
-
814
-    public function set_wp_page_slug($wp_page_slug)
815
-    {
816
-        $this->_wp_page_slug = $wp_page_slug;
817
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
818
-        if (is_network_admin()) {
819
-            $this->_wp_page_slug .= '-network';
820
-        }
821
-    }
822
-
823
-
824
-    /**
825
-     * _verify_routes
826
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
827
-     * we know if we need to drop out.
828
-     *
829
-     * @return bool
830
-     * @throws EE_Error
831
-     */
832
-    protected function _verify_routes()
833
-    {
834
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
835
-        if (! $this->_current_page && ! $this->request->isAjax()) {
836
-            return false;
837
-        }
838
-        $this->_route = false;
839
-        // check that the page_routes array is not empty
840
-        if (empty($this->_page_routes)) {
841
-            // user error msg
842
-            $error_msg = sprintf(
843
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
844
-                $this->_admin_page_title
845
-            );
846
-            // developer error msg
847
-            $error_msg .= '||' . $error_msg
848
-                          . esc_html__(
849
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
850
-                              'event_espresso'
851
-                          );
852
-            throw new EE_Error($error_msg);
853
-        }
854
-        // and that the requested page route exists
855
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
856
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
857
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
858
-                ? $this->_page_config[ $this->_req_action ]
859
-                : [];
860
-        } else {
861
-            // user error msg
862
-            $error_msg = sprintf(
863
-                esc_html__(
864
-                    'The requested page route does not exist for the %s admin page.',
865
-                    'event_espresso'
866
-                ),
867
-                $this->_admin_page_title
868
-            );
869
-            // developer error msg
870
-            $error_msg .= '||' . $error_msg
871
-                          . sprintf(
872
-                              esc_html__(
873
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
874
-                                  'event_espresso'
875
-                              ),
876
-                              $this->_req_action
877
-                          );
878
-            throw new EE_Error($error_msg);
879
-        }
880
-        // and that a default route exists
881
-        if (! array_key_exists('default', $this->_page_routes)) {
882
-            // user error msg
883
-            $error_msg = sprintf(
884
-                esc_html__(
885
-                    'A default page route has not been set for the % admin page.',
886
-                    'event_espresso'
887
-                ),
888
-                $this->_admin_page_title
889
-            );
890
-            // developer error msg
891
-            $error_msg .= '||' . $error_msg
892
-                          . esc_html__(
893
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
894
-                              'event_espresso'
895
-                          );
896
-            throw new EE_Error($error_msg);
897
-        }
898
-        // first lets' catch if the UI request has EVER been set.
899
-        if ($this->_is_UI_request === null) {
900
-            // lets set if this is a UI request or not.
901
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
902
-            // wait a minute... we might have a noheader in the route array
903
-            $this->_is_UI_request = ! (
904
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
905
-            )
906
-                ? $this->_is_UI_request
907
-                : false;
908
-        }
909
-        $this->_set_current_labels();
910
-        return true;
911
-    }
912
-
913
-
914
-    /**
915
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
916
-     *
917
-     * @param string $route the route name we're verifying
918
-     * @return bool we'll throw an exception if this isn't a valid route.
919
-     * @throws EE_Error
920
-     */
921
-    protected function _verify_route($route)
922
-    {
923
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
924
-            return true;
925
-        }
926
-        // user error msg
927
-        $error_msg = sprintf(
928
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
929
-            $this->_admin_page_title
930
-        );
931
-        // developer error msg
932
-        $error_msg .= '||' . $error_msg
933
-                      . sprintf(
934
-                          esc_html__(
935
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
936
-                              'event_espresso'
937
-                          ),
938
-                          $route
939
-                      );
940
-        throw new EE_Error($error_msg);
941
-    }
942
-
943
-
944
-    /**
945
-     * perform nonce verification
946
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
947
-     * using this method (and save retyping!)
948
-     *
949
-     * @param string $nonce     The nonce sent
950
-     * @param string $nonce_ref The nonce reference string (name0)
951
-     * @return void
952
-     * @throws EE_Error
953
-     */
954
-    protected function _verify_nonce($nonce, $nonce_ref)
955
-    {
956
-        // verify nonce against expected value
957
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
958
-            // these are not the droids you are looking for !!!
959
-            $msg = sprintf(
960
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
961
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
962
-                '</a>'
963
-            );
964
-            if (WP_DEBUG) {
965
-                $msg .= "\n  ";
966
-                $msg .= sprintf(
967
-                    esc_html__(
968
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
969
-                        'event_espresso'
970
-                    ),
971
-                    __CLASS__
972
-                );
973
-            }
974
-            if (! $this->request->isAjax()) {
975
-                wp_die($msg);
976
-            }
977
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
978
-            $this->_return_json();
979
-        }
980
-    }
981
-
982
-
983
-    /**
984
-     * _route_admin_request()
985
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
986
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
987
-     * in the page routes and then will try to load the corresponding method.
988
-     *
989
-     * @return void
990
-     * @throws EE_Error
991
-     * @throws InvalidArgumentException
992
-     * @throws InvalidDataTypeException
993
-     * @throws InvalidInterfaceException
994
-     * @throws ReflectionException
995
-     */
996
-    protected function _route_admin_request()
997
-    {
998
-        if (! $this->_is_UI_request) {
999
-            $this->_verify_routes();
1000
-        }
1001
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1002
-        if ($this->_req_action !== 'default' && $nonce_check) {
1003
-            // set nonce from post data
1004
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
1005
-            $this->_verify_nonce($nonce, $this->_req_nonce);
1006
-        }
1007
-        // set the nav_tabs array but ONLY if this is  UI_request
1008
-        if ($this->_is_UI_request) {
1009
-            $this->_set_nav_tabs();
1010
-        }
1011
-        // grab callback function
1012
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
1013
-        // check if callback has args
1014
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1015
-        $error_msg = '';
1016
-        // action right before calling route
1017
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1018
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1019
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1020
-        }
1021
-        // right before calling the route, let's clean the _wp_http_referer
1022
-        $this->request->setServerParam(
1023
-            'REQUEST_URI',
1024
-            remove_query_arg(
1025
-                '_wp_http_referer',
1026
-                wp_unslash($this->request->getServerParam('REQUEST_URI'))
1027
-            )
1028
-        );
1029
-        if (! empty($func)) {
1030
-            if (is_array($func)) {
1031
-                list($class, $method) = $func;
1032
-            } elseif (strpos($func, '::') !== false) {
1033
-                list($class, $method) = explode('::', $func);
1034
-            } else {
1035
-                $class  = $this;
1036
-                $method = $func;
1037
-            }
1038
-            if (! (is_object($class) && $class === $this)) {
1039
-                // send along this admin page object for access by addons.
1040
-                $args['admin_page_object'] = $this;
1041
-            }
1042
-            if (
115
+	/**
116
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
117
+	 * actions.
118
+	 *
119
+	 * @since 4.6.x
120
+	 * @var array.
121
+	 */
122
+	protected $_default_route_query_args;
123
+
124
+	// set via request page and action args.
125
+	protected $_current_page;
126
+
127
+	protected $_current_view;
128
+
129
+	protected $_current_page_view_url;
130
+
131
+	/**
132
+	 * unprocessed value for the 'action' request param (default '')
133
+	 *
134
+	 * @var string
135
+	 */
136
+	protected $raw_req_action = '';
137
+
138
+	/**
139
+	 * unprocessed value for the 'page' request param (default '')
140
+	 *
141
+	 * @var string
142
+	 */
143
+	protected $raw_req_page = '';
144
+
145
+	/**
146
+	 * sanitized request action (and nonce)
147
+	 *
148
+	 * @var string
149
+	 */
150
+	protected $_req_action = '';
151
+
152
+	/**
153
+	 * sanitized request action nonce
154
+	 *
155
+	 * @var string
156
+	 */
157
+	protected $_req_nonce = '';
158
+
159
+	/**
160
+	 * @var string
161
+	 */
162
+	protected $_search_btn_label = '';
163
+
164
+	/**
165
+	 * @var string
166
+	 */
167
+	protected $_search_box_callback = '';
168
+
169
+	/**
170
+	 * @var WP_Screen
171
+	 */
172
+	protected $_current_screen;
173
+
174
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
175
+	protected $_hook_obj;
176
+
177
+	// for holding incoming request data
178
+	protected $_req_data = [];
179
+
180
+	// yes / no array for admin form fields
181
+	protected $_yes_no_values = [];
182
+
183
+	// some default things shared by all child classes
184
+	protected $_default_espresso_metaboxes;
185
+
186
+	/**
187
+	 * @var EE_Registry
188
+	 */
189
+	protected $EE = null;
190
+
191
+
192
+	/**
193
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
194
+	 *
195
+	 * @var boolean
196
+	 */
197
+	protected $_is_caf = false;
198
+
199
+
200
+	/**
201
+	 * @Constructor
202
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
203
+	 * @throws EE_Error
204
+	 * @throws InvalidArgumentException
205
+	 * @throws ReflectionException
206
+	 * @throws InvalidDataTypeException
207
+	 * @throws InvalidInterfaceException
208
+	 */
209
+	public function __construct($routing = true)
210
+	{
211
+		$this->loader  = LoaderFactory::getLoader();
212
+		$this->request = $this->loader->getShared(RequestInterface::class);
213
+		$this->_routing = $routing;
214
+
215
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
216
+			$this->_is_caf = true;
217
+		}
218
+		$this->_yes_no_values = [
219
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
220
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
221
+		];
222
+		// set the _req_data property.
223
+		$this->_req_data = $this->request->requestParams();
224
+		// set initial page props (child method)
225
+		$this->_init_page_props();
226
+		// set global defaults
227
+		$this->_set_defaults();
228
+		// set early because incoming requests could be ajax related and we need to register those hooks.
229
+		$this->_global_ajax_hooks();
230
+		$this->_ajax_hooks();
231
+		// other_page_hooks have to be early too.
232
+		$this->_do_other_page_hooks();
233
+		// set up page dependencies
234
+		$this->_before_page_setup();
235
+		$this->_page_setup();
236
+		// die();
237
+	}
238
+
239
+
240
+	/**
241
+	 * _init_page_props
242
+	 * Child classes use to set at least the following properties:
243
+	 * $page_slug.
244
+	 * $page_label.
245
+	 *
246
+	 * @abstract
247
+	 * @return void
248
+	 */
249
+	abstract protected function _init_page_props();
250
+
251
+
252
+	/**
253
+	 * _ajax_hooks
254
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
255
+	 * Note: within the ajax callback methods.
256
+	 *
257
+	 * @abstract
258
+	 * @return void
259
+	 */
260
+	abstract protected function _ajax_hooks();
261
+
262
+
263
+	/**
264
+	 * _define_page_props
265
+	 * child classes define page properties in here.  Must include at least:
266
+	 * $_admin_base_url = base_url for all admin pages
267
+	 * $_admin_page_title = default admin_page_title for admin pages
268
+	 * $_labels = array of default labels for various automatically generated elements:
269
+	 *    array(
270
+	 *        'buttons' => array(
271
+	 *            'add' => esc_html__('label for add new button'),
272
+	 *            'edit' => esc_html__('label for edit button'),
273
+	 *            'delete' => esc_html__('label for delete button')
274
+	 *            )
275
+	 *        )
276
+	 *
277
+	 * @abstract
278
+	 * @return void
279
+	 */
280
+	abstract protected function _define_page_props();
281
+
282
+
283
+	/**
284
+	 * _set_page_routes
285
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
286
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
287
+	 * have a 'default' route. Here's the format
288
+	 * $this->_page_routes = array(
289
+	 *        'default' => array(
290
+	 *            'func' => '_default_method_handling_route',
291
+	 *            'args' => array('array','of','args'),
292
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
293
+	 *            ajax request, backend processing)
294
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
295
+	 *            headers route after.  The string you enter here should match the defined route reference for a
296
+	 *            headers sent route.
297
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
298
+	 *            this route.
299
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
300
+	 *            checks).
301
+	 *        ),
302
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
303
+	 *        handling method.
304
+	 *        )
305
+	 * )
306
+	 *
307
+	 * @abstract
308
+	 * @return void
309
+	 */
310
+	abstract protected function _set_page_routes();
311
+
312
+
313
+	/**
314
+	 * _set_page_config
315
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
316
+	 * array corresponds to the page_route for the loaded page. Format:
317
+	 * $this->_page_config = array(
318
+	 *        'default' => array(
319
+	 *            'labels' => array(
320
+	 *                'buttons' => array(
321
+	 *                    'add' => esc_html__('label for adding item'),
322
+	 *                    'edit' => esc_html__('label for editing item'),
323
+	 *                    'delete' => esc_html__('label for deleting item')
324
+	 *                ),
325
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
326
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
327
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
328
+	 *            _define_page_props() method
329
+	 *            'nav' => array(
330
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
331
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
332
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
333
+	 *                'order' => 10, //required to indicate tab position.
334
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
335
+	 *                displayed then add this parameter.
336
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
337
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
338
+	 *            metaboxes set for eventespresso admin pages.
339
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
340
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
341
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
342
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
343
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
344
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
345
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
346
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
347
+	 *            want to display.
348
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
349
+	 *                'tab_id' => array(
350
+	 *                    'title' => 'tab_title',
351
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
352
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
353
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
354
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
355
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
356
+	 *                    attempt to use the callback which should match the name of a method in the class
357
+	 *                    ),
358
+	 *                'tab2_id' => array(
359
+	 *                    'title' => 'tab2 title',
360
+	 *                    'filename' => 'file_name_2'
361
+	 *                    'callback' => 'callback_method_for_content',
362
+	 *                 ),
363
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
364
+	 *            help tab area on an admin page. @return void
365
+	 *
366
+	 * @link
367
+	 *                http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
368
+	 *                'help_tour' => array(
369
+	 *                'name_of_help_tour_class', //all help tours should be a child class of EE_Help_Tour and located
370
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
371
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
372
+	 *                ),
373
+	 *                'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default
374
+	 *                is true if it isn't present).  To remove the requirement for a nonce check when this route is
375
+	 *                visited just set
376
+	 *                'require_nonce' to FALSE
377
+	 *                )
378
+	 *                )
379
+	 *
380
+	 * @abstract
381
+	 */
382
+	abstract protected function _set_page_config();
383
+
384
+
385
+
386
+
387
+
388
+	/** end sample help_tour methods **/
389
+	/**
390
+	 * _add_screen_options
391
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
392
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
393
+	 * to a particular view.
394
+	 *
395
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
396
+	 *         see also WP_Screen object documents...
397
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
398
+	 * @abstract
399
+	 * @return void
400
+	 */
401
+	abstract protected function _add_screen_options();
402
+
403
+
404
+	/**
405
+	 * _add_feature_pointers
406
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
407
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
408
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
409
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
410
+	 * extended) also see:
411
+	 *
412
+	 * @link   http://eamann.com/tech/wordpress-portland/
413
+	 * @abstract
414
+	 * @return void
415
+	 */
416
+	abstract protected function _add_feature_pointers();
417
+
418
+
419
+	/**
420
+	 * load_scripts_styles
421
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
422
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
423
+	 * scripts/styles per view by putting them in a dynamic function in this format
424
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
425
+	 *
426
+	 * @abstract
427
+	 * @return void
428
+	 */
429
+	abstract public function load_scripts_styles();
430
+
431
+
432
+	/**
433
+	 * admin_init
434
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
435
+	 * all pages/views loaded by child class.
436
+	 *
437
+	 * @abstract
438
+	 * @return void
439
+	 */
440
+	abstract public function admin_init();
441
+
442
+
443
+	/**
444
+	 * admin_notices
445
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
446
+	 * all pages/views loaded by child class.
447
+	 *
448
+	 * @abstract
449
+	 * @return void
450
+	 */
451
+	abstract public function admin_notices();
452
+
453
+
454
+	/**
455
+	 * admin_footer_scripts
456
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
457
+	 * will apply to all pages/views loaded by child class.
458
+	 *
459
+	 * @return void
460
+	 */
461
+	abstract public function admin_footer_scripts();
462
+
463
+
464
+	/**
465
+	 * admin_footer
466
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
467
+	 * apply to all pages/views loaded by child class.
468
+	 *
469
+	 * @return void
470
+	 */
471
+	public function admin_footer()
472
+	{
473
+	}
474
+
475
+
476
+	/**
477
+	 * _global_ajax_hooks
478
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
479
+	 * Note: within the ajax callback methods.
480
+	 *
481
+	 * @abstract
482
+	 * @return void
483
+	 */
484
+	protected function _global_ajax_hooks()
485
+	{
486
+		// for lazy loading of metabox content
487
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
488
+	}
489
+
490
+
491
+	public function ajax_metabox_content()
492
+	{
493
+		$content_id  = $this->request->getRequestParam('contentid', '');
494
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
495
+		self::cached_rss_display($content_id, $content_url);
496
+		wp_die();
497
+	}
498
+
499
+
500
+	/**
501
+	 * allows extending classes do something specific before the parent constructor runs _page_setup().
502
+	 *
503
+	 * @return void
504
+	 */
505
+	protected function _before_page_setup()
506
+	{
507
+		// default is to do nothing
508
+	}
509
+
510
+
511
+	/**
512
+	 * Makes sure any things that need to be loaded early get handled.
513
+	 * We also escape early here if the page requested doesn't match the object.
514
+	 *
515
+	 * @final
516
+	 * @return void
517
+	 * @throws EE_Error
518
+	 * @throws InvalidArgumentException
519
+	 * @throws ReflectionException
520
+	 * @throws InvalidDataTypeException
521
+	 * @throws InvalidInterfaceException
522
+	 */
523
+	final protected function _page_setup()
524
+	{
525
+		// requires?
526
+		// admin_init stuff - global - we're setting this REALLY early
527
+		// so if EE_Admin pages have to hook into other WP pages they can.
528
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
529
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
530
+		// next verify if we need to load anything...
531
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
532
+		$this->page_folder   = strtolower(
533
+			str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
534
+		);
535
+		global $ee_menu_slugs;
536
+		$ee_menu_slugs = (array) $ee_menu_slugs;
537
+		if (
538
+			! $this->request->isAjax()
539
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
540
+		) {
541
+			return;
542
+		}
543
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
544
+		// we need to copy the action from the second to the first
545
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
546
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
547
+		$action     = $action !== '-1' ? $action : $action2;
548
+		$req_action = $action !== '-1' ? $action : 'default';
549
+
550
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
551
+		// then let's use the route as the action.
552
+		// This covers cases where we're coming in from a list table that isn't on the default route.
553
+		$route = $this->request->getRequestParam('route');
554
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
555
+			? $route
556
+			: $req_action;
557
+
558
+		$this->_current_view = $this->_req_action;
559
+		$this->_req_nonce    = $this->_req_action . '_nonce';
560
+		$this->_define_page_props();
561
+		$this->_current_page_view_url = add_query_arg(
562
+			['page' => $this->_current_page, 'action' => $this->_current_view],
563
+			$this->_admin_base_url
564
+		);
565
+		// default things
566
+		$this->_default_espresso_metaboxes = [
567
+			'_espresso_news_post_box',
568
+			'_espresso_links_post_box',
569
+			'_espresso_ratings_request',
570
+			'_espresso_sponsors_post_box',
571
+		];
572
+		// set page configs
573
+		$this->_set_page_routes();
574
+		$this->_set_page_config();
575
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
576
+		if ($this->request->requestParamIsSet('wp_referer')) {
577
+			$wp_referer = $this->request->getRequestParam('wp_referer');
578
+			if ($wp_referer) {
579
+				$this->_default_route_query_args['wp_referer'] = $wp_referer;
580
+			}
581
+		}
582
+		// for caffeinated and other extended functionality.
583
+		//  If there is a _extend_page_config method
584
+		// then let's run that to modify the all the various page configuration arrays
585
+		if (method_exists($this, '_extend_page_config')) {
586
+			$this->_extend_page_config();
587
+		}
588
+		// for CPT and other extended functionality.
589
+		// If there is an _extend_page_config_for_cpt
590
+		// then let's run that to modify all the various page configuration arrays.
591
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
592
+			$this->_extend_page_config_for_cpt();
593
+		}
594
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
595
+		$this->_page_routes = apply_filters(
596
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
597
+			$this->_page_routes,
598
+			$this
599
+		);
600
+		$this->_page_config = apply_filters(
601
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
602
+			$this->_page_config,
603
+			$this
604
+		);
605
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
606
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
607
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
608
+			add_action(
609
+				'AHEE__EE_Admin_Page__route_admin_request',
610
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
611
+				10,
612
+				2
613
+			);
614
+		}
615
+		// next route only if routing enabled
616
+		if ($this->_routing && ! $this->request->isAjax()) {
617
+			$this->_verify_routes();
618
+			// next let's just check user_access and kill if no access
619
+			$this->check_user_access();
620
+			if ($this->_is_UI_request) {
621
+				// admin_init stuff - global, all views for this page class, specific view
622
+				add_action('admin_init', [$this, 'admin_init'], 10);
623
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
624
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
625
+				}
626
+			} else {
627
+				// hijack regular WP loading and route admin request immediately
628
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
629
+				$this->route_admin_request();
630
+			}
631
+		}
632
+	}
633
+
634
+
635
+	/**
636
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
637
+	 *
638
+	 * @return void
639
+	 * @throws EE_Error
640
+	 */
641
+	private function _do_other_page_hooks()
642
+	{
643
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
644
+		foreach ($registered_pages as $page) {
645
+			// now let's setup the file name and class that should be present
646
+			$classname = str_replace('.class.php', '', $page);
647
+			// autoloaders should take care of loading file
648
+			if (! class_exists($classname)) {
649
+				$error_msg[] = sprintf(
650
+					esc_html__(
651
+						'Something went wrong with loading the %s admin hooks page.',
652
+						'event_espresso'
653
+					),
654
+					$page
655
+				);
656
+				$error_msg[] = $error_msg[0]
657
+							   . "\r\n"
658
+							   . sprintf(
659
+								   esc_html__(
660
+									   'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
661
+									   'event_espresso'
662
+								   ),
663
+								   $page,
664
+								   '<br />',
665
+								   '<strong>' . $classname . '</strong>'
666
+							   );
667
+				throw new EE_Error(implode('||', $error_msg));
668
+			}
669
+			// notice we are passing the instance of this class to the hook object.
670
+			$this->loader->getShared($classname, [$this]);
671
+		}
672
+	}
673
+
674
+
675
+	/**
676
+	 * @throws ReflectionException
677
+	 * @throws EE_Error
678
+	 */
679
+	public function load_page_dependencies()
680
+	{
681
+		try {
682
+			$this->_load_page_dependencies();
683
+		} catch (EE_Error $e) {
684
+			$e->get_error();
685
+		}
686
+	}
687
+
688
+
689
+	/**
690
+	 * load_page_dependencies
691
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
692
+	 *
693
+	 * @return void
694
+	 * @throws DomainException
695
+	 * @throws EE_Error
696
+	 * @throws InvalidArgumentException
697
+	 * @throws InvalidDataTypeException
698
+	 * @throws InvalidInterfaceException
699
+	 */
700
+	protected function _load_page_dependencies()
701
+	{
702
+		// let's set the current_screen and screen options to override what WP set
703
+		$this->_current_screen = get_current_screen();
704
+		// load admin_notices - global, page class, and view specific
705
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
706
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
707
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
708
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
709
+		}
710
+		// load network admin_notices - global, page class, and view specific
711
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
712
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
713
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
714
+		}
715
+		// this will save any per_page screen options if they are present
716
+		$this->_set_per_page_screen_options();
717
+		// setup list table properties
718
+		$this->_set_list_table();
719
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
720
+		// However in some cases the metaboxes will need to be added within a route handling callback.
721
+		$this->_add_registered_meta_boxes();
722
+		$this->_add_screen_columns();
723
+		// add screen options - global, page child class, and view specific
724
+		$this->_add_global_screen_options();
725
+		$this->_add_screen_options();
726
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
727
+		if (method_exists($this, $add_screen_options)) {
728
+			$this->{$add_screen_options}();
729
+		}
730
+		// add help tab(s) and tours- set via page_config and qtips.
731
+		// $this->_add_help_tour();
732
+		$this->_add_help_tabs();
733
+		$this->_add_qtips();
734
+		// add feature_pointers - global, page child class, and view specific
735
+		$this->_add_feature_pointers();
736
+		$this->_add_global_feature_pointers();
737
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
738
+		if (method_exists($this, $add_feature_pointer)) {
739
+			$this->{$add_feature_pointer}();
740
+		}
741
+		// enqueue scripts/styles - global, page class, and view specific
742
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
743
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
744
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
745
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
746
+		}
747
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
748
+		// admin_print_footer_scripts - global, page child class, and view specific.
749
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
750
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
751
+		// is a good use case. Notice the late priority we're giving these
752
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
753
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
754
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
755
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
756
+		}
757
+		// admin footer scripts
758
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
759
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
760
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
761
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
762
+		}
763
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
764
+		// targeted hook
765
+		do_action(
766
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
767
+		);
768
+	}
769
+
770
+
771
+	/**
772
+	 * _set_defaults
773
+	 * This sets some global defaults for class properties.
774
+	 */
775
+	private function _set_defaults()
776
+	{
777
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
778
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
779
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
780
+		$this->_page_config          = $this->_default_route_query_args = [];
781
+		$this->_default_nav_tab_name = 'overview';
782
+		// init template args
783
+		$this->_template_args = [
784
+			'admin_page_header'  => '',
785
+			'admin_page_content' => '',
786
+			'post_body_content'  => '',
787
+			'before_list_table'  => '',
788
+			'after_list_table'   => '',
789
+		];
790
+	}
791
+
792
+
793
+	/**
794
+	 * route_admin_request
795
+	 *
796
+	 * @return void
797
+	 * @throws InvalidArgumentException
798
+	 * @throws InvalidInterfaceException
799
+	 * @throws InvalidDataTypeException
800
+	 * @throws EE_Error
801
+	 * @throws ReflectionException
802
+	 * @see    _route_admin_request()
803
+	 */
804
+	public function route_admin_request()
805
+	{
806
+		try {
807
+			$this->_route_admin_request();
808
+		} catch (EE_Error $e) {
809
+			$e->get_error();
810
+		}
811
+	}
812
+
813
+
814
+	public function set_wp_page_slug($wp_page_slug)
815
+	{
816
+		$this->_wp_page_slug = $wp_page_slug;
817
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
818
+		if (is_network_admin()) {
819
+			$this->_wp_page_slug .= '-network';
820
+		}
821
+	}
822
+
823
+
824
+	/**
825
+	 * _verify_routes
826
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
827
+	 * we know if we need to drop out.
828
+	 *
829
+	 * @return bool
830
+	 * @throws EE_Error
831
+	 */
832
+	protected function _verify_routes()
833
+	{
834
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
835
+		if (! $this->_current_page && ! $this->request->isAjax()) {
836
+			return false;
837
+		}
838
+		$this->_route = false;
839
+		// check that the page_routes array is not empty
840
+		if (empty($this->_page_routes)) {
841
+			// user error msg
842
+			$error_msg = sprintf(
843
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
844
+				$this->_admin_page_title
845
+			);
846
+			// developer error msg
847
+			$error_msg .= '||' . $error_msg
848
+						  . esc_html__(
849
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
850
+							  'event_espresso'
851
+						  );
852
+			throw new EE_Error($error_msg);
853
+		}
854
+		// and that the requested page route exists
855
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
856
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
857
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
858
+				? $this->_page_config[ $this->_req_action ]
859
+				: [];
860
+		} else {
861
+			// user error msg
862
+			$error_msg = sprintf(
863
+				esc_html__(
864
+					'The requested page route does not exist for the %s admin page.',
865
+					'event_espresso'
866
+				),
867
+				$this->_admin_page_title
868
+			);
869
+			// developer error msg
870
+			$error_msg .= '||' . $error_msg
871
+						  . sprintf(
872
+							  esc_html__(
873
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
874
+								  'event_espresso'
875
+							  ),
876
+							  $this->_req_action
877
+						  );
878
+			throw new EE_Error($error_msg);
879
+		}
880
+		// and that a default route exists
881
+		if (! array_key_exists('default', $this->_page_routes)) {
882
+			// user error msg
883
+			$error_msg = sprintf(
884
+				esc_html__(
885
+					'A default page route has not been set for the % admin page.',
886
+					'event_espresso'
887
+				),
888
+				$this->_admin_page_title
889
+			);
890
+			// developer error msg
891
+			$error_msg .= '||' . $error_msg
892
+						  . esc_html__(
893
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
894
+							  'event_espresso'
895
+						  );
896
+			throw new EE_Error($error_msg);
897
+		}
898
+		// first lets' catch if the UI request has EVER been set.
899
+		if ($this->_is_UI_request === null) {
900
+			// lets set if this is a UI request or not.
901
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
902
+			// wait a minute... we might have a noheader in the route array
903
+			$this->_is_UI_request = ! (
904
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
905
+			)
906
+				? $this->_is_UI_request
907
+				: false;
908
+		}
909
+		$this->_set_current_labels();
910
+		return true;
911
+	}
912
+
913
+
914
+	/**
915
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
916
+	 *
917
+	 * @param string $route the route name we're verifying
918
+	 * @return bool we'll throw an exception if this isn't a valid route.
919
+	 * @throws EE_Error
920
+	 */
921
+	protected function _verify_route($route)
922
+	{
923
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
924
+			return true;
925
+		}
926
+		// user error msg
927
+		$error_msg = sprintf(
928
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
929
+			$this->_admin_page_title
930
+		);
931
+		// developer error msg
932
+		$error_msg .= '||' . $error_msg
933
+					  . sprintf(
934
+						  esc_html__(
935
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
936
+							  'event_espresso'
937
+						  ),
938
+						  $route
939
+					  );
940
+		throw new EE_Error($error_msg);
941
+	}
942
+
943
+
944
+	/**
945
+	 * perform nonce verification
946
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
947
+	 * using this method (and save retyping!)
948
+	 *
949
+	 * @param string $nonce     The nonce sent
950
+	 * @param string $nonce_ref The nonce reference string (name0)
951
+	 * @return void
952
+	 * @throws EE_Error
953
+	 */
954
+	protected function _verify_nonce($nonce, $nonce_ref)
955
+	{
956
+		// verify nonce against expected value
957
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
958
+			// these are not the droids you are looking for !!!
959
+			$msg = sprintf(
960
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
961
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
962
+				'</a>'
963
+			);
964
+			if (WP_DEBUG) {
965
+				$msg .= "\n  ";
966
+				$msg .= sprintf(
967
+					esc_html__(
968
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
969
+						'event_espresso'
970
+					),
971
+					__CLASS__
972
+				);
973
+			}
974
+			if (! $this->request->isAjax()) {
975
+				wp_die($msg);
976
+			}
977
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
978
+			$this->_return_json();
979
+		}
980
+	}
981
+
982
+
983
+	/**
984
+	 * _route_admin_request()
985
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
986
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
987
+	 * in the page routes and then will try to load the corresponding method.
988
+	 *
989
+	 * @return void
990
+	 * @throws EE_Error
991
+	 * @throws InvalidArgumentException
992
+	 * @throws InvalidDataTypeException
993
+	 * @throws InvalidInterfaceException
994
+	 * @throws ReflectionException
995
+	 */
996
+	protected function _route_admin_request()
997
+	{
998
+		if (! $this->_is_UI_request) {
999
+			$this->_verify_routes();
1000
+		}
1001
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1002
+		if ($this->_req_action !== 'default' && $nonce_check) {
1003
+			// set nonce from post data
1004
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
1005
+			$this->_verify_nonce($nonce, $this->_req_nonce);
1006
+		}
1007
+		// set the nav_tabs array but ONLY if this is  UI_request
1008
+		if ($this->_is_UI_request) {
1009
+			$this->_set_nav_tabs();
1010
+		}
1011
+		// grab callback function
1012
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
1013
+		// check if callback has args
1014
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1015
+		$error_msg = '';
1016
+		// action right before calling route
1017
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1018
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1019
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1020
+		}
1021
+		// right before calling the route, let's clean the _wp_http_referer
1022
+		$this->request->setServerParam(
1023
+			'REQUEST_URI',
1024
+			remove_query_arg(
1025
+				'_wp_http_referer',
1026
+				wp_unslash($this->request->getServerParam('REQUEST_URI'))
1027
+			)
1028
+		);
1029
+		if (! empty($func)) {
1030
+			if (is_array($func)) {
1031
+				list($class, $method) = $func;
1032
+			} elseif (strpos($func, '::') !== false) {
1033
+				list($class, $method) = explode('::', $func);
1034
+			} else {
1035
+				$class  = $this;
1036
+				$method = $func;
1037
+			}
1038
+			if (! (is_object($class) && $class === $this)) {
1039
+				// send along this admin page object for access by addons.
1040
+				$args['admin_page_object'] = $this;
1041
+			}
1042
+			if (
1043 1043
 // is it a method on a class that doesn't work?
1044
-                (
1045
-                    (
1046
-                        method_exists($class, $method)
1047
-                        && call_user_func_array([$class, $method], $args) === false
1048
-                    )
1049
-                    && (
1050
-                        // is it a standalone function that doesn't work?
1051
-                        function_exists($method)
1052
-                        && call_user_func_array(
1053
-                            $func,
1054
-                            array_merge(['admin_page_object' => $this], $args)
1055
-                        ) === false
1056
-                    )
1057
-                )
1058
-                || (
1059
-                    // is it neither a class method NOR a standalone function?
1060
-                    ! method_exists($class, $method)
1061
-                    && ! function_exists($method)
1062
-                )
1063
-            ) {
1064
-                // user error msg
1065
-                $error_msg = esc_html__(
1066
-                    'An error occurred. The  requested page route could not be found.',
1067
-                    'event_espresso'
1068
-                );
1069
-                // developer error msg
1070
-                $error_msg .= '||';
1071
-                $error_msg .= sprintf(
1072
-                    esc_html__(
1073
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1074
-                        'event_espresso'
1075
-                    ),
1076
-                    $method
1077
-                );
1078
-            }
1079
-            if (! empty($error_msg)) {
1080
-                throw new EE_Error($error_msg);
1081
-            }
1082
-        }
1083
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1084
-        // then we need to reset the routing properties to the new route.
1085
-        // now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1086
-        if (
1087
-            $this->_is_UI_request === false
1088
-            && is_array($this->_route)
1089
-            && ! empty($this->_route['headers_sent_route'])
1090
-        ) {
1091
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1092
-        }
1093
-    }
1094
-
1095
-
1096
-    /**
1097
-     * This method just allows the resetting of page properties in the case where a no headers
1098
-     * route redirects to a headers route in its route config.
1099
-     *
1100
-     * @param string $new_route New (non header) route to redirect to.
1101
-     * @return   void
1102
-     * @throws ReflectionException
1103
-     * @throws InvalidArgumentException
1104
-     * @throws InvalidInterfaceException
1105
-     * @throws InvalidDataTypeException
1106
-     * @throws EE_Error
1107
-     * @since   4.3.0
1108
-     */
1109
-    protected function _reset_routing_properties($new_route)
1110
-    {
1111
-        $this->_is_UI_request = true;
1112
-        // now we set the current route to whatever the headers_sent_route is set at
1113
-        $this->request->setRequestParam('action', $new_route);
1114
-        // rerun page setup
1115
-        $this->_page_setup();
1116
-    }
1117
-
1118
-
1119
-    /**
1120
-     * _add_query_arg
1121
-     * adds nonce to array of arguments then calls WP add_query_arg function
1122
-     *(internally just uses EEH_URL's function with the same name)
1123
-     *
1124
-     * @param array  $args
1125
-     * @param string $url
1126
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1127
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1128
-     *                                        Example usage: If the current page is:
1129
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1130
-     *                                        &action=default&event_id=20&month_range=March%202015
1131
-     *                                        &_wpnonce=5467821
1132
-     *                                        and you call:
1133
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1134
-     *                                        array(
1135
-     *                                        'action' => 'resend_something',
1136
-     *                                        'page=>espresso_registrations'
1137
-     *                                        ),
1138
-     *                                        $some_url,
1139
-     *                                        true
1140
-     *                                        );
1141
-     *                                        It will produce a url in this structure:
1142
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1143
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1144
-     *                                        month_range]=March%202015
1145
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1146
-     * @return string
1147
-     */
1148
-    public static function add_query_args_and_nonce(
1149
-        $args = [],
1150
-        $url = false,
1151
-        $sticky = false,
1152
-        $exclude_nonce = false
1153
-    ) {
1154
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1155
-        if ($sticky) {
1156
-            /** @var RequestInterface $request */
1157
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1158
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1159
-            foreach ($request->requestParams() as $key => $value) {
1160
-                // do not add nonces
1161
-                if (strpos($key, 'nonce') !== false) {
1162
-                    continue;
1163
-                }
1164
-                $args[ 'wp_referer[' . $key . ']' ] = htmlspecialchars($value);
1165
-            }
1166
-        }
1167
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1168
-    }
1169
-
1170
-
1171
-    /**
1172
-     * This returns a generated link that will load the related help tab.
1173
-     *
1174
-     * @param string $help_tab_id the id for the connected help tab
1175
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1176
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1177
-     * @return string              generated link
1178
-     * @uses EEH_Template::get_help_tab_link()
1179
-     */
1180
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1181
-    {
1182
-        return EEH_Template::get_help_tab_link(
1183
-            $help_tab_id,
1184
-            $this->page_slug,
1185
-            $this->_req_action,
1186
-            $icon_style,
1187
-            $help_text
1188
-        );
1189
-    }
1190
-
1191
-
1192
-    /**
1193
-     * _add_help_tabs
1194
-     * Note child classes define their help tabs within the page_config array.
1195
-     *
1196
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1197
-     * @return void
1198
-     * @throws DomainException
1199
-     * @throws EE_Error
1200
-     */
1201
-    protected function _add_help_tabs()
1202
-    {
1203
-        $tour_buttons = '';
1204
-        if (isset($this->_page_config[ $this->_req_action ])) {
1205
-            $config = $this->_page_config[ $this->_req_action ];
1206
-            // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1207
-            // is there a help tour for the current route?  if there is let's setup the tour buttons
1208
-            // if (isset($this->_help_tour[ $this->_req_action ])) {
1209
-            //     $tb = array();
1210
-            //     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1211
-            //     foreach ($this->_help_tour['tours'] as $tour) {
1212
-            //         // if this is the end tour then we don't need to setup a button
1213
-            //         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1214
-            //             continue;
1215
-            //         }
1216
-            //         $tb[] = '<button id="trigger-tour-'
1217
-            //                 . $tour->get_slug()
1218
-            //                 . '" class="button-primary trigger-ee-help-tour">'
1219
-            //                 . $tour->get_label()
1220
-            //                 . '</button>';
1221
-            //     }
1222
-            //     $tour_buttons .= implode('<br />', $tb);
1223
-            //     $tour_buttons .= '</div></div>';
1224
-            // }
1225
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1226
-            if (is_array($config) && isset($config['help_sidebar'])) {
1227
-                // check that the callback given is valid
1228
-                if (! method_exists($this, $config['help_sidebar'])) {
1229
-                    throw new EE_Error(
1230
-                        sprintf(
1231
-                            esc_html__(
1232
-                                'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1233
-                                'event_espresso'
1234
-                            ),
1235
-                            $config['help_sidebar'],
1236
-                            get_class($this)
1237
-                        )
1238
-                    );
1239
-                }
1240
-                $content = apply_filters(
1241
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1242
-                    $this->{$config['help_sidebar']}()
1243
-                );
1244
-                $content .= $tour_buttons; // add help tour buttons.
1245
-                // do we have any help tours setup?  Cause if we do we want to add the buttons
1246
-                $this->_current_screen->set_help_sidebar($content);
1247
-            }
1248
-            // if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1249
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1250
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1251
-            }
1252
-            // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1253
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1254
-                $_ht['id']      = $this->page_slug;
1255
-                $_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1256
-                $_ht['content'] = '<p>'
1257
-                                  . esc_html__(
1258
-                                      'The buttons to the right allow you to start/restart any help tours available for this page',
1259
-                                      'event_espresso'
1260
-                                  ) . '</p>';
1261
-                $this->_current_screen->add_help_tab($_ht);
1262
-            }
1263
-            if (! isset($config['help_tabs'])) {
1264
-                return;
1265
-            } //no help tabs for this route
1266
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1267
-                // we're here so there ARE help tabs!
1268
-                // make sure we've got what we need
1269
-                if (! isset($cfg['title'])) {
1270
-                    throw new EE_Error(
1271
-                        esc_html__(
1272
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1273
-                            'event_espresso'
1274
-                        )
1275
-                    );
1276
-                }
1277
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1278
-                    throw new EE_Error(
1279
-                        esc_html__(
1280
-                            'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1281
-                            'event_espresso'
1282
-                        )
1283
-                    );
1284
-                }
1285
-                // first priority goes to content.
1286
-                if (! empty($cfg['content'])) {
1287
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1288
-                    // second priority goes to filename
1289
-                } elseif (! empty($cfg['filename'])) {
1290
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1291
-                    // it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1292
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1293
-                                                             . basename($this->_get_dir())
1294
-                                                             . '/help_tabs/'
1295
-                                                             . $cfg['filename']
1296
-                                                             . '.help_tab.php' : $file_path;
1297
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1298
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1299
-                        EE_Error::add_error(
1300
-                            sprintf(
1301
-                                esc_html__(
1302
-                                    'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1303
-                                    'event_espresso'
1304
-                                ),
1305
-                                $tab_id,
1306
-                                key($config),
1307
-                                $file_path
1308
-                            ),
1309
-                            __FILE__,
1310
-                            __FUNCTION__,
1311
-                            __LINE__
1312
-                        );
1313
-                        return;
1314
-                    }
1315
-                    $template_args['admin_page_obj'] = $this;
1316
-                    $content                         = EEH_Template::display_template(
1317
-                        $file_path,
1318
-                        $template_args,
1319
-                        true
1320
-                    );
1321
-                } else {
1322
-                    $content = '';
1323
-                }
1324
-                // check if callback is valid
1325
-                if (
1326
-                    empty($content)
1327
-                    && (
1328
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1329
-                    )
1330
-                ) {
1331
-                    EE_Error::add_error(
1332
-                        sprintf(
1333
-                            esc_html__(
1334
-                                'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1335
-                                'event_espresso'
1336
-                            ),
1337
-                            $cfg['title']
1338
-                        ),
1339
-                        __FILE__,
1340
-                        __FUNCTION__,
1341
-                        __LINE__
1342
-                    );
1343
-                    return;
1344
-                }
1345
-                // setup config array for help tab method
1346
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1347
-                $_ht = [
1348
-                    'id'       => $id,
1349
-                    'title'    => $cfg['title'],
1350
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1351
-                    'content'  => $content,
1352
-                ];
1353
-                $this->_current_screen->add_help_tab($_ht);
1354
-            }
1355
-        }
1356
-    }
1357
-
1358
-
1359
-    /**
1360
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1361
-     * an array with properties for setting up usage of the joyride plugin
1362
-     *
1363
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1364
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1365
-     *         _set_page_config() comments
1366
-     * @return void
1367
-     * @throws InvalidArgumentException
1368
-     * @throws InvalidDataTypeException
1369
-     * @throws InvalidInterfaceException
1370
-     */
1371
-    protected function _add_help_tour()
1372
-    {
1373
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1374
-        // $tours = array();
1375
-        // $this->_help_tour = array();
1376
-        // // exit early if help tours are turned off globally
1377
-        // if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1378
-        //     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1379
-        // ) {
1380
-        //     return;
1381
-        // }
1382
-        // // loop through _page_config to find any help_tour defined
1383
-        // foreach ($this->_page_config as $route => $config) {
1384
-        //     // we're only going to set things up for this route
1385
-        //     if ($route !== $this->_req_action) {
1386
-        //         continue;
1387
-        //     }
1388
-        //     if (isset($config['help_tour'])) {
1389
-        //         foreach ($config['help_tour'] as $tour) {
1390
-        //             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1391
-        //             // let's see if we can get that file...
1392
-        //             // if not its possible this is a decaf route not set in caffeinated
1393
-        //             // so lets try and get the caffeinated equivalent
1394
-        //             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1395
-        //                                                      . basename($this->_get_dir())
1396
-        //                                                      . '/help_tours/'
1397
-        //                                                      . $tour
1398
-        //                                                      . '.class.php' : $file_path;
1399
-        //             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1400
-        //             if (! is_readable($file_path)) {
1401
-        //                 EE_Error::add_error(
1402
-        //                     sprintf(
1403
-        //                         esc_html__(
1404
-        //                             'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1405
-        //                             'event_espresso'
1406
-        //                         ),
1407
-        //                         $file_path,
1408
-        //                         $tour
1409
-        //                     ),
1410
-        //                     __FILE__,
1411
-        //                     __FUNCTION__,
1412
-        //                     __LINE__
1413
-        //                 );
1414
-        //                 return;
1415
-        //             }
1416
-        //             require_once $file_path;
1417
-        //             if (! class_exists($tour)) {
1418
-        //                 $error_msg[] = sprintf(
1419
-        //                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1420
-        //                     $tour
1421
-        //                 );
1422
-        //                 $error_msg[] = $error_msg[0] . "\r\n"
1423
-        //                                . sprintf(
1424
-        //                                    esc_html__(
1425
-        //                                        'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1426
-        //                                        'event_espresso'
1427
-        //                                    ),
1428
-        //                                    $tour,
1429
-        //                                    '<br />',
1430
-        //                                    $tour,
1431
-        //                                    $this->_req_action,
1432
-        //                                    get_class($this)
1433
-        //                                );
1434
-        //                 throw new EE_Error(implode('||', $error_msg));
1435
-        //             }
1436
-        //             $tour_obj = new $tour($this->_is_caf);
1437
-        //             $tours[] = $tour_obj;
1438
-        //             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1439
-        //         }
1440
-        //         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1441
-        //         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1442
-        //         $tours[] = $end_stop_tour;
1443
-        //         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1444
-        //     }
1445
-        // }
1446
-        //
1447
-        // if (! empty($tours)) {
1448
-        //     $this->_help_tour['tours'] = $tours;
1449
-        // }
1450
-        // // that's it!  Now that the $_help_tours property is set (or not)
1451
-        // // the scripts and html should be taken care of automatically.
1452
-        //
1453
-        // /**
1454
-        //  * Allow extending the help tours variable.
1455
-        //  *
1456
-        //  * @param Array $_help_tour The array containing all help tour information to be displayed.
1457
-        //  */
1458
-        // $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1459
-    }
1460
-
1461
-
1462
-    /**
1463
-     * This simply sets up any qtips that have been defined in the page config
1464
-     *
1465
-     * @return void
1466
-     */
1467
-    protected function _add_qtips()
1468
-    {
1469
-        if (isset($this->_route_config['qtips'])) {
1470
-            $qtips = (array) $this->_route_config['qtips'];
1471
-            // load qtip loader
1472
-            $path = [
1473
-                $this->_get_dir() . '/qtips/',
1474
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1475
-            ];
1476
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1477
-        }
1478
-    }
1479
-
1480
-
1481
-    /**
1482
-     * _set_nav_tabs
1483
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1484
-     * wish to add additional tabs or modify accordingly.
1485
-     *
1486
-     * @return void
1487
-     * @throws InvalidArgumentException
1488
-     * @throws InvalidInterfaceException
1489
-     * @throws InvalidDataTypeException
1490
-     */
1491
-    protected function _set_nav_tabs()
1492
-    {
1493
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1494
-        $i = 0;
1495
-        foreach ($this->_page_config as $slug => $config) {
1496
-            if (! is_array($config) || empty($config['nav'])) {
1497
-                continue;
1498
-            }
1499
-            // no nav tab for this config
1500
-            // check for persistent flag
1501
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1502
-                // nav tab is only to appear when route requested.
1503
-                continue;
1504
-            }
1505
-            if (! $this->check_user_access($slug, true)) {
1506
-                // no nav tab because current user does not have access.
1507
-                continue;
1508
-            }
1509
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1510
-            $this->_nav_tabs[ $slug ] = [
1511
-                'url'       => isset($config['nav']['url'])
1512
-                    ? $config['nav']['url']
1513
-                    : self::add_query_args_and_nonce(
1514
-                        ['action' => $slug],
1515
-                        $this->_admin_base_url
1516
-                    ),
1517
-                'link_text' => isset($config['nav']['label'])
1518
-                    ? $config['nav']['label']
1519
-                    : ucwords(
1520
-                        str_replace('_', ' ', $slug)
1521
-                    ),
1522
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1523
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1524
-            ];
1525
-            $i++;
1526
-        }
1527
-        // if $this->_nav_tabs is empty then lets set the default
1528
-        if (empty($this->_nav_tabs)) {
1529
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1530
-                'url'       => $this->_admin_base_url,
1531
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1532
-                'css_class' => 'nav-tab-active',
1533
-                'order'     => 10,
1534
-            ];
1535
-        }
1536
-        // now let's sort the tabs according to order
1537
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1538
-    }
1539
-
1540
-
1541
-    /**
1542
-     * _set_current_labels
1543
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1544
-     * property array
1545
-     *
1546
-     * @return void
1547
-     */
1548
-    private function _set_current_labels()
1549
-    {
1550
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1551
-            foreach ($this->_route_config['labels'] as $label => $text) {
1552
-                if (is_array($text)) {
1553
-                    foreach ($text as $sublabel => $subtext) {
1554
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1555
-                    }
1556
-                } else {
1557
-                    $this->_labels[ $label ] = $text;
1558
-                }
1559
-            }
1560
-        }
1561
-    }
1562
-
1563
-
1564
-    /**
1565
-     *        verifies user access for this admin page
1566
-     *
1567
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1568
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1569
-     *                               return false if verify fail.
1570
-     * @return bool
1571
-     * @throws InvalidArgumentException
1572
-     * @throws InvalidDataTypeException
1573
-     * @throws InvalidInterfaceException
1574
-     */
1575
-    public function check_user_access($route_to_check = '', $verify_only = false)
1576
-    {
1577
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1578
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1579
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1580
-                          && is_array(
1581
-                              $this->_page_routes[ $route_to_check ]
1582
-                          )
1583
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1584
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1585
-        if (empty($capability) && empty($route_to_check)) {
1586
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1587
-                : $this->_route['capability'];
1588
-        } else {
1589
-            $capability = empty($capability) ? 'manage_options' : $capability;
1590
-        }
1591
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1592
-        if (
1593
-            ! $this->request->isAjax()
1594
-            && (
1595
-                ! function_exists('is_admin')
1596
-                || ! EE_Registry::instance()->CAP->current_user_can(
1597
-                    $capability,
1598
-                    $this->page_slug
1599
-                    . '_'
1600
-                    . $route_to_check,
1601
-                    $id
1602
-                )
1603
-            )
1604
-        ) {
1605
-            if ($verify_only) {
1606
-                return false;
1607
-            }
1608
-            if (is_user_logged_in()) {
1609
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1610
-            } else {
1611
-                return false;
1612
-            }
1613
-        }
1614
-        return true;
1615
-    }
1616
-
1617
-
1618
-    /**
1619
-     * admin_init_global
1620
-     * This runs all the code that we want executed within the WP admin_init hook.
1621
-     * This method executes for ALL EE Admin pages.
1622
-     *
1623
-     * @return void
1624
-     */
1625
-    public function admin_init_global()
1626
-    {
1627
-    }
1628
-
1629
-
1630
-    /**
1631
-     * wp_loaded_global
1632
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1633
-     * EE_Admin page and will execute on every EE Admin Page load
1634
-     *
1635
-     * @return void
1636
-     */
1637
-    public function wp_loaded()
1638
-    {
1639
-    }
1640
-
1641
-
1642
-    /**
1643
-     * admin_notices
1644
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1645
-     * ALL EE_Admin pages.
1646
-     *
1647
-     * @return void
1648
-     */
1649
-    public function admin_notices_global()
1650
-    {
1651
-        $this->_display_no_javascript_warning();
1652
-        $this->_display_espresso_notices();
1653
-    }
1654
-
1655
-
1656
-    public function network_admin_notices_global()
1657
-    {
1658
-        $this->_display_no_javascript_warning();
1659
-        $this->_display_espresso_notices();
1660
-    }
1661
-
1662
-
1663
-    /**
1664
-     * admin_footer_scripts_global
1665
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1666
-     * will apply on ALL EE_Admin pages.
1667
-     *
1668
-     * @return void
1669
-     */
1670
-    public function admin_footer_scripts_global()
1671
-    {
1672
-        $this->_add_admin_page_ajax_loading_img();
1673
-        $this->_add_admin_page_overlay();
1674
-        // if metaboxes are present we need to add the nonce field
1675
-        if (
1676
-            isset($this->_route_config['metaboxes'])
1677
-            || isset($this->_route_config['list_table'])
1678
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1679
-        ) {
1680
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1681
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1682
-        }
1683
-    }
1684
-
1685
-
1686
-    /**
1687
-     * admin_footer_global
1688
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1689
-     * ALL EE_Admin Pages.
1690
-     *
1691
-     * @return void
1692
-     */
1693
-    public function admin_footer_global()
1694
-    {
1695
-        // dialog container for dialog helper
1696
-        echo '
1044
+				(
1045
+					(
1046
+						method_exists($class, $method)
1047
+						&& call_user_func_array([$class, $method], $args) === false
1048
+					)
1049
+					&& (
1050
+						// is it a standalone function that doesn't work?
1051
+						function_exists($method)
1052
+						&& call_user_func_array(
1053
+							$func,
1054
+							array_merge(['admin_page_object' => $this], $args)
1055
+						) === false
1056
+					)
1057
+				)
1058
+				|| (
1059
+					// is it neither a class method NOR a standalone function?
1060
+					! method_exists($class, $method)
1061
+					&& ! function_exists($method)
1062
+				)
1063
+			) {
1064
+				// user error msg
1065
+				$error_msg = esc_html__(
1066
+					'An error occurred. The  requested page route could not be found.',
1067
+					'event_espresso'
1068
+				);
1069
+				// developer error msg
1070
+				$error_msg .= '||';
1071
+				$error_msg .= sprintf(
1072
+					esc_html__(
1073
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1074
+						'event_espresso'
1075
+					),
1076
+					$method
1077
+				);
1078
+			}
1079
+			if (! empty($error_msg)) {
1080
+				throw new EE_Error($error_msg);
1081
+			}
1082
+		}
1083
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1084
+		// then we need to reset the routing properties to the new route.
1085
+		// now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1086
+		if (
1087
+			$this->_is_UI_request === false
1088
+			&& is_array($this->_route)
1089
+			&& ! empty($this->_route['headers_sent_route'])
1090
+		) {
1091
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1092
+		}
1093
+	}
1094
+
1095
+
1096
+	/**
1097
+	 * This method just allows the resetting of page properties in the case where a no headers
1098
+	 * route redirects to a headers route in its route config.
1099
+	 *
1100
+	 * @param string $new_route New (non header) route to redirect to.
1101
+	 * @return   void
1102
+	 * @throws ReflectionException
1103
+	 * @throws InvalidArgumentException
1104
+	 * @throws InvalidInterfaceException
1105
+	 * @throws InvalidDataTypeException
1106
+	 * @throws EE_Error
1107
+	 * @since   4.3.0
1108
+	 */
1109
+	protected function _reset_routing_properties($new_route)
1110
+	{
1111
+		$this->_is_UI_request = true;
1112
+		// now we set the current route to whatever the headers_sent_route is set at
1113
+		$this->request->setRequestParam('action', $new_route);
1114
+		// rerun page setup
1115
+		$this->_page_setup();
1116
+	}
1117
+
1118
+
1119
+	/**
1120
+	 * _add_query_arg
1121
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1122
+	 *(internally just uses EEH_URL's function with the same name)
1123
+	 *
1124
+	 * @param array  $args
1125
+	 * @param string $url
1126
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1127
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1128
+	 *                                        Example usage: If the current page is:
1129
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1130
+	 *                                        &action=default&event_id=20&month_range=March%202015
1131
+	 *                                        &_wpnonce=5467821
1132
+	 *                                        and you call:
1133
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1134
+	 *                                        array(
1135
+	 *                                        'action' => 'resend_something',
1136
+	 *                                        'page=>espresso_registrations'
1137
+	 *                                        ),
1138
+	 *                                        $some_url,
1139
+	 *                                        true
1140
+	 *                                        );
1141
+	 *                                        It will produce a url in this structure:
1142
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1143
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1144
+	 *                                        month_range]=March%202015
1145
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1146
+	 * @return string
1147
+	 */
1148
+	public static function add_query_args_and_nonce(
1149
+		$args = [],
1150
+		$url = false,
1151
+		$sticky = false,
1152
+		$exclude_nonce = false
1153
+	) {
1154
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1155
+		if ($sticky) {
1156
+			/** @var RequestInterface $request */
1157
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1158
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1159
+			foreach ($request->requestParams() as $key => $value) {
1160
+				// do not add nonces
1161
+				if (strpos($key, 'nonce') !== false) {
1162
+					continue;
1163
+				}
1164
+				$args[ 'wp_referer[' . $key . ']' ] = htmlspecialchars($value);
1165
+			}
1166
+		}
1167
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1168
+	}
1169
+
1170
+
1171
+	/**
1172
+	 * This returns a generated link that will load the related help tab.
1173
+	 *
1174
+	 * @param string $help_tab_id the id for the connected help tab
1175
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1176
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1177
+	 * @return string              generated link
1178
+	 * @uses EEH_Template::get_help_tab_link()
1179
+	 */
1180
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1181
+	{
1182
+		return EEH_Template::get_help_tab_link(
1183
+			$help_tab_id,
1184
+			$this->page_slug,
1185
+			$this->_req_action,
1186
+			$icon_style,
1187
+			$help_text
1188
+		);
1189
+	}
1190
+
1191
+
1192
+	/**
1193
+	 * _add_help_tabs
1194
+	 * Note child classes define their help tabs within the page_config array.
1195
+	 *
1196
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1197
+	 * @return void
1198
+	 * @throws DomainException
1199
+	 * @throws EE_Error
1200
+	 */
1201
+	protected function _add_help_tabs()
1202
+	{
1203
+		$tour_buttons = '';
1204
+		if (isset($this->_page_config[ $this->_req_action ])) {
1205
+			$config = $this->_page_config[ $this->_req_action ];
1206
+			// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1207
+			// is there a help tour for the current route?  if there is let's setup the tour buttons
1208
+			// if (isset($this->_help_tour[ $this->_req_action ])) {
1209
+			//     $tb = array();
1210
+			//     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1211
+			//     foreach ($this->_help_tour['tours'] as $tour) {
1212
+			//         // if this is the end tour then we don't need to setup a button
1213
+			//         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1214
+			//             continue;
1215
+			//         }
1216
+			//         $tb[] = '<button id="trigger-tour-'
1217
+			//                 . $tour->get_slug()
1218
+			//                 . '" class="button-primary trigger-ee-help-tour">'
1219
+			//                 . $tour->get_label()
1220
+			//                 . '</button>';
1221
+			//     }
1222
+			//     $tour_buttons .= implode('<br />', $tb);
1223
+			//     $tour_buttons .= '</div></div>';
1224
+			// }
1225
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1226
+			if (is_array($config) && isset($config['help_sidebar'])) {
1227
+				// check that the callback given is valid
1228
+				if (! method_exists($this, $config['help_sidebar'])) {
1229
+					throw new EE_Error(
1230
+						sprintf(
1231
+							esc_html__(
1232
+								'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1233
+								'event_espresso'
1234
+							),
1235
+							$config['help_sidebar'],
1236
+							get_class($this)
1237
+						)
1238
+					);
1239
+				}
1240
+				$content = apply_filters(
1241
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1242
+					$this->{$config['help_sidebar']}()
1243
+				);
1244
+				$content .= $tour_buttons; // add help tour buttons.
1245
+				// do we have any help tours setup?  Cause if we do we want to add the buttons
1246
+				$this->_current_screen->set_help_sidebar($content);
1247
+			}
1248
+			// if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1249
+			if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1250
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1251
+			}
1252
+			// handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1253
+			if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1254
+				$_ht['id']      = $this->page_slug;
1255
+				$_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1256
+				$_ht['content'] = '<p>'
1257
+								  . esc_html__(
1258
+									  'The buttons to the right allow you to start/restart any help tours available for this page',
1259
+									  'event_espresso'
1260
+								  ) . '</p>';
1261
+				$this->_current_screen->add_help_tab($_ht);
1262
+			}
1263
+			if (! isset($config['help_tabs'])) {
1264
+				return;
1265
+			} //no help tabs for this route
1266
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1267
+				// we're here so there ARE help tabs!
1268
+				// make sure we've got what we need
1269
+				if (! isset($cfg['title'])) {
1270
+					throw new EE_Error(
1271
+						esc_html__(
1272
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1273
+							'event_espresso'
1274
+						)
1275
+					);
1276
+				}
1277
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1278
+					throw new EE_Error(
1279
+						esc_html__(
1280
+							'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1281
+							'event_espresso'
1282
+						)
1283
+					);
1284
+				}
1285
+				// first priority goes to content.
1286
+				if (! empty($cfg['content'])) {
1287
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1288
+					// second priority goes to filename
1289
+				} elseif (! empty($cfg['filename'])) {
1290
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1291
+					// it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1292
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1293
+															 . basename($this->_get_dir())
1294
+															 . '/help_tabs/'
1295
+															 . $cfg['filename']
1296
+															 . '.help_tab.php' : $file_path;
1297
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1298
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1299
+						EE_Error::add_error(
1300
+							sprintf(
1301
+								esc_html__(
1302
+									'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1303
+									'event_espresso'
1304
+								),
1305
+								$tab_id,
1306
+								key($config),
1307
+								$file_path
1308
+							),
1309
+							__FILE__,
1310
+							__FUNCTION__,
1311
+							__LINE__
1312
+						);
1313
+						return;
1314
+					}
1315
+					$template_args['admin_page_obj'] = $this;
1316
+					$content                         = EEH_Template::display_template(
1317
+						$file_path,
1318
+						$template_args,
1319
+						true
1320
+					);
1321
+				} else {
1322
+					$content = '';
1323
+				}
1324
+				// check if callback is valid
1325
+				if (
1326
+					empty($content)
1327
+					&& (
1328
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1329
+					)
1330
+				) {
1331
+					EE_Error::add_error(
1332
+						sprintf(
1333
+							esc_html__(
1334
+								'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1335
+								'event_espresso'
1336
+							),
1337
+							$cfg['title']
1338
+						),
1339
+						__FILE__,
1340
+						__FUNCTION__,
1341
+						__LINE__
1342
+					);
1343
+					return;
1344
+				}
1345
+				// setup config array for help tab method
1346
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1347
+				$_ht = [
1348
+					'id'       => $id,
1349
+					'title'    => $cfg['title'],
1350
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1351
+					'content'  => $content,
1352
+				];
1353
+				$this->_current_screen->add_help_tab($_ht);
1354
+			}
1355
+		}
1356
+	}
1357
+
1358
+
1359
+	/**
1360
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1361
+	 * an array with properties for setting up usage of the joyride plugin
1362
+	 *
1363
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1364
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1365
+	 *         _set_page_config() comments
1366
+	 * @return void
1367
+	 * @throws InvalidArgumentException
1368
+	 * @throws InvalidDataTypeException
1369
+	 * @throws InvalidInterfaceException
1370
+	 */
1371
+	protected function _add_help_tour()
1372
+	{
1373
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1374
+		// $tours = array();
1375
+		// $this->_help_tour = array();
1376
+		// // exit early if help tours are turned off globally
1377
+		// if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1378
+		//     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1379
+		// ) {
1380
+		//     return;
1381
+		// }
1382
+		// // loop through _page_config to find any help_tour defined
1383
+		// foreach ($this->_page_config as $route => $config) {
1384
+		//     // we're only going to set things up for this route
1385
+		//     if ($route !== $this->_req_action) {
1386
+		//         continue;
1387
+		//     }
1388
+		//     if (isset($config['help_tour'])) {
1389
+		//         foreach ($config['help_tour'] as $tour) {
1390
+		//             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1391
+		//             // let's see if we can get that file...
1392
+		//             // if not its possible this is a decaf route not set in caffeinated
1393
+		//             // so lets try and get the caffeinated equivalent
1394
+		//             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1395
+		//                                                      . basename($this->_get_dir())
1396
+		//                                                      . '/help_tours/'
1397
+		//                                                      . $tour
1398
+		//                                                      . '.class.php' : $file_path;
1399
+		//             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1400
+		//             if (! is_readable($file_path)) {
1401
+		//                 EE_Error::add_error(
1402
+		//                     sprintf(
1403
+		//                         esc_html__(
1404
+		//                             'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1405
+		//                             'event_espresso'
1406
+		//                         ),
1407
+		//                         $file_path,
1408
+		//                         $tour
1409
+		//                     ),
1410
+		//                     __FILE__,
1411
+		//                     __FUNCTION__,
1412
+		//                     __LINE__
1413
+		//                 );
1414
+		//                 return;
1415
+		//             }
1416
+		//             require_once $file_path;
1417
+		//             if (! class_exists($tour)) {
1418
+		//                 $error_msg[] = sprintf(
1419
+		//                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1420
+		//                     $tour
1421
+		//                 );
1422
+		//                 $error_msg[] = $error_msg[0] . "\r\n"
1423
+		//                                . sprintf(
1424
+		//                                    esc_html__(
1425
+		//                                        'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1426
+		//                                        'event_espresso'
1427
+		//                                    ),
1428
+		//                                    $tour,
1429
+		//                                    '<br />',
1430
+		//                                    $tour,
1431
+		//                                    $this->_req_action,
1432
+		//                                    get_class($this)
1433
+		//                                );
1434
+		//                 throw new EE_Error(implode('||', $error_msg));
1435
+		//             }
1436
+		//             $tour_obj = new $tour($this->_is_caf);
1437
+		//             $tours[] = $tour_obj;
1438
+		//             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1439
+		//         }
1440
+		//         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1441
+		//         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1442
+		//         $tours[] = $end_stop_tour;
1443
+		//         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1444
+		//     }
1445
+		// }
1446
+		//
1447
+		// if (! empty($tours)) {
1448
+		//     $this->_help_tour['tours'] = $tours;
1449
+		// }
1450
+		// // that's it!  Now that the $_help_tours property is set (or not)
1451
+		// // the scripts and html should be taken care of automatically.
1452
+		//
1453
+		// /**
1454
+		//  * Allow extending the help tours variable.
1455
+		//  *
1456
+		//  * @param Array $_help_tour The array containing all help tour information to be displayed.
1457
+		//  */
1458
+		// $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1459
+	}
1460
+
1461
+
1462
+	/**
1463
+	 * This simply sets up any qtips that have been defined in the page config
1464
+	 *
1465
+	 * @return void
1466
+	 */
1467
+	protected function _add_qtips()
1468
+	{
1469
+		if (isset($this->_route_config['qtips'])) {
1470
+			$qtips = (array) $this->_route_config['qtips'];
1471
+			// load qtip loader
1472
+			$path = [
1473
+				$this->_get_dir() . '/qtips/',
1474
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1475
+			];
1476
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1477
+		}
1478
+	}
1479
+
1480
+
1481
+	/**
1482
+	 * _set_nav_tabs
1483
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1484
+	 * wish to add additional tabs or modify accordingly.
1485
+	 *
1486
+	 * @return void
1487
+	 * @throws InvalidArgumentException
1488
+	 * @throws InvalidInterfaceException
1489
+	 * @throws InvalidDataTypeException
1490
+	 */
1491
+	protected function _set_nav_tabs()
1492
+	{
1493
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1494
+		$i = 0;
1495
+		foreach ($this->_page_config as $slug => $config) {
1496
+			if (! is_array($config) || empty($config['nav'])) {
1497
+				continue;
1498
+			}
1499
+			// no nav tab for this config
1500
+			// check for persistent flag
1501
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1502
+				// nav tab is only to appear when route requested.
1503
+				continue;
1504
+			}
1505
+			if (! $this->check_user_access($slug, true)) {
1506
+				// no nav tab because current user does not have access.
1507
+				continue;
1508
+			}
1509
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1510
+			$this->_nav_tabs[ $slug ] = [
1511
+				'url'       => isset($config['nav']['url'])
1512
+					? $config['nav']['url']
1513
+					: self::add_query_args_and_nonce(
1514
+						['action' => $slug],
1515
+						$this->_admin_base_url
1516
+					),
1517
+				'link_text' => isset($config['nav']['label'])
1518
+					? $config['nav']['label']
1519
+					: ucwords(
1520
+						str_replace('_', ' ', $slug)
1521
+					),
1522
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1523
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1524
+			];
1525
+			$i++;
1526
+		}
1527
+		// if $this->_nav_tabs is empty then lets set the default
1528
+		if (empty($this->_nav_tabs)) {
1529
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1530
+				'url'       => $this->_admin_base_url,
1531
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1532
+				'css_class' => 'nav-tab-active',
1533
+				'order'     => 10,
1534
+			];
1535
+		}
1536
+		// now let's sort the tabs according to order
1537
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1538
+	}
1539
+
1540
+
1541
+	/**
1542
+	 * _set_current_labels
1543
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1544
+	 * property array
1545
+	 *
1546
+	 * @return void
1547
+	 */
1548
+	private function _set_current_labels()
1549
+	{
1550
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1551
+			foreach ($this->_route_config['labels'] as $label => $text) {
1552
+				if (is_array($text)) {
1553
+					foreach ($text as $sublabel => $subtext) {
1554
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1555
+					}
1556
+				} else {
1557
+					$this->_labels[ $label ] = $text;
1558
+				}
1559
+			}
1560
+		}
1561
+	}
1562
+
1563
+
1564
+	/**
1565
+	 *        verifies user access for this admin page
1566
+	 *
1567
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1568
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1569
+	 *                               return false if verify fail.
1570
+	 * @return bool
1571
+	 * @throws InvalidArgumentException
1572
+	 * @throws InvalidDataTypeException
1573
+	 * @throws InvalidInterfaceException
1574
+	 */
1575
+	public function check_user_access($route_to_check = '', $verify_only = false)
1576
+	{
1577
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1578
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1579
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1580
+						  && is_array(
1581
+							  $this->_page_routes[ $route_to_check ]
1582
+						  )
1583
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1584
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1585
+		if (empty($capability) && empty($route_to_check)) {
1586
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1587
+				: $this->_route['capability'];
1588
+		} else {
1589
+			$capability = empty($capability) ? 'manage_options' : $capability;
1590
+		}
1591
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1592
+		if (
1593
+			! $this->request->isAjax()
1594
+			&& (
1595
+				! function_exists('is_admin')
1596
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1597
+					$capability,
1598
+					$this->page_slug
1599
+					. '_'
1600
+					. $route_to_check,
1601
+					$id
1602
+				)
1603
+			)
1604
+		) {
1605
+			if ($verify_only) {
1606
+				return false;
1607
+			}
1608
+			if (is_user_logged_in()) {
1609
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1610
+			} else {
1611
+				return false;
1612
+			}
1613
+		}
1614
+		return true;
1615
+	}
1616
+
1617
+
1618
+	/**
1619
+	 * admin_init_global
1620
+	 * This runs all the code that we want executed within the WP admin_init hook.
1621
+	 * This method executes for ALL EE Admin pages.
1622
+	 *
1623
+	 * @return void
1624
+	 */
1625
+	public function admin_init_global()
1626
+	{
1627
+	}
1628
+
1629
+
1630
+	/**
1631
+	 * wp_loaded_global
1632
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1633
+	 * EE_Admin page and will execute on every EE Admin Page load
1634
+	 *
1635
+	 * @return void
1636
+	 */
1637
+	public function wp_loaded()
1638
+	{
1639
+	}
1640
+
1641
+
1642
+	/**
1643
+	 * admin_notices
1644
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1645
+	 * ALL EE_Admin pages.
1646
+	 *
1647
+	 * @return void
1648
+	 */
1649
+	public function admin_notices_global()
1650
+	{
1651
+		$this->_display_no_javascript_warning();
1652
+		$this->_display_espresso_notices();
1653
+	}
1654
+
1655
+
1656
+	public function network_admin_notices_global()
1657
+	{
1658
+		$this->_display_no_javascript_warning();
1659
+		$this->_display_espresso_notices();
1660
+	}
1661
+
1662
+
1663
+	/**
1664
+	 * admin_footer_scripts_global
1665
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1666
+	 * will apply on ALL EE_Admin pages.
1667
+	 *
1668
+	 * @return void
1669
+	 */
1670
+	public function admin_footer_scripts_global()
1671
+	{
1672
+		$this->_add_admin_page_ajax_loading_img();
1673
+		$this->_add_admin_page_overlay();
1674
+		// if metaboxes are present we need to add the nonce field
1675
+		if (
1676
+			isset($this->_route_config['metaboxes'])
1677
+			|| isset($this->_route_config['list_table'])
1678
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1679
+		) {
1680
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1681
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1682
+		}
1683
+	}
1684
+
1685
+
1686
+	/**
1687
+	 * admin_footer_global
1688
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1689
+	 * ALL EE_Admin Pages.
1690
+	 *
1691
+	 * @return void
1692
+	 */
1693
+	public function admin_footer_global()
1694
+	{
1695
+		// dialog container for dialog helper
1696
+		echo '
1697 1697
         <div class="ee-admin-dialog-container auto-hide hidden">
1698 1698
             <div class="ee-notices"></div>
1699 1699
             <div class="ee-admin-dialog-container-inner-content"></div>
1700 1700
         </div>
1701 1701
         ';
1702 1702
 
1703
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1704
-        // help tour stuff?
1705
-        // if (isset($this->_help_tour[ $this->_req_action ])) {
1706
-        //     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1707
-        // }
1708
-        // current set timezone for timezone js
1709
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1710
-    }
1711
-
1712
-
1713
-    /**
1714
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1715
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1716
-     * help popups then in your templates or your content you set "triggers" for the content using the
1717
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1718
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1719
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1720
-     * for the
1721
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1722
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1723
-     *    'help_trigger_id' => array(
1724
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1725
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1726
-     *    )
1727
-     * );
1728
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1729
-     *
1730
-     * @param array $help_array
1731
-     * @param bool  $display
1732
-     * @return string content
1733
-     * @throws DomainException
1734
-     * @throws EE_Error
1735
-     */
1736
-    protected function _set_help_popup_content($help_array = [], $display = false)
1737
-    {
1738
-        $content    = '';
1739
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1740
-        // loop through the array and setup content
1741
-        foreach ($help_array as $trigger => $help) {
1742
-            // make sure the array is setup properly
1743
-            if (! isset($help['title']) || ! isset($help['content'])) {
1744
-                throw new EE_Error(
1745
-                    esc_html__(
1746
-                        'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1747
-                        'event_espresso'
1748
-                    )
1749
-                );
1750
-            }
1751
-            // we're good so let'd setup the template vars and then assign parsed template content to our content.
1752
-            $template_args = [
1753
-                'help_popup_id'      => $trigger,
1754
-                'help_popup_title'   => $help['title'],
1755
-                'help_popup_content' => $help['content'],
1756
-            ];
1757
-            $content       .= EEH_Template::display_template(
1758
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1759
-                $template_args,
1760
-                true
1761
-            );
1762
-        }
1763
-        if ($display) {
1764
-            echo $content; // already escaped
1765
-            return '';
1766
-        }
1767
-        return $content;
1768
-    }
1769
-
1770
-
1771
-    /**
1772
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1773
-     *
1774
-     * @return array properly formatted array for help popup content
1775
-     * @throws EE_Error
1776
-     */
1777
-    private function _get_help_content()
1778
-    {
1779
-        // what is the method we're looking for?
1780
-        $method_name = '_help_popup_content_' . $this->_req_action;
1781
-        // if method doesn't exist let's get out.
1782
-        if (! method_exists($this, $method_name)) {
1783
-            return [];
1784
-        }
1785
-        // k we're good to go let's retrieve the help array
1786
-        $help_array = call_user_func([$this, $method_name]);
1787
-        // make sure we've got an array!
1788
-        if (! is_array($help_array)) {
1789
-            throw new EE_Error(
1790
-                esc_html__(
1791
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1792
-                    'event_espresso'
1793
-                )
1794
-            );
1795
-        }
1796
-        return $help_array;
1797
-    }
1798
-
1799
-
1800
-    /**
1801
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1802
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1803
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1804
-     *
1805
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1806
-     * @param boolean $display    if false then we return the trigger string
1807
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1808
-     * @return string
1809
-     * @throws DomainException
1810
-     * @throws EE_Error
1811
-     */
1812
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1813
-    {
1814
-        if ($this->request->isAjax()) {
1815
-            return '';
1816
-        }
1817
-        // let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1818
-        $help_array   = $this->_get_help_content();
1819
-        $help_content = '';
1820
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1821
-            $help_array[ $trigger_id ] = [
1822
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1823
-                'content' => esc_html__(
1824
-                    'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1825
-                    'event_espresso'
1826
-                ),
1827
-            ];
1828
-            $help_content              = $this->_set_help_popup_content($help_array, false);
1829
-        }
1830
-        // let's setup the trigger
1831
-        $content = '<a class="ee-dialog" href="?height='
1832
-                   . esc_attr($dimensions[0])
1833
-                   . '&width='
1834
-                   . esc_attr($dimensions[1])
1835
-                   . '&inlineId='
1836
-                   . esc_attr($trigger_id)
1837
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1838
-        $content .= $help_content;
1839
-        if ($display) {
1840
-            echo $content; // already escaped
1841
-            return '';
1842
-        }
1843
-        return $content;
1844
-    }
1845
-
1846
-
1847
-    /**
1848
-     * _add_global_screen_options
1849
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1850
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1851
-     *
1852
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1853
-     *         see also WP_Screen object documents...
1854
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1855
-     * @abstract
1856
-     * @return void
1857
-     */
1858
-    private function _add_global_screen_options()
1859
-    {
1860
-    }
1861
-
1862
-
1863
-    /**
1864
-     * _add_global_feature_pointers
1865
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1866
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1867
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1868
-     *
1869
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1870
-     *         extended) also see:
1871
-     * @link   http://eamann.com/tech/wordpress-portland/
1872
-     * @abstract
1873
-     * @return void
1874
-     */
1875
-    private function _add_global_feature_pointers()
1876
-    {
1877
-    }
1878
-
1879
-
1880
-    /**
1881
-     * load_global_scripts_styles
1882
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1883
-     *
1884
-     * @return void
1885
-     */
1886
-    public function load_global_scripts_styles()
1887
-    {
1888
-        /** STYLES **/
1889
-        // add debugging styles
1890
-        if (WP_DEBUG) {
1891
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1892
-        }
1893
-        // register all styles
1894
-        wp_register_style(
1895
-            'espresso-ui-theme',
1896
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1897
-            [],
1898
-            EVENT_ESPRESSO_VERSION
1899
-        );
1900
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1901
-        // helpers styles
1902
-        wp_register_style(
1903
-            'ee-text-links',
1904
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1905
-            [],
1906
-            EVENT_ESPRESSO_VERSION
1907
-        );
1908
-        /** SCRIPTS **/
1909
-        // register all scripts
1910
-        wp_register_script(
1911
-            'ee-dialog',
1912
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1913
-            ['jquery', 'jquery-ui-draggable'],
1914
-            EVENT_ESPRESSO_VERSION,
1915
-            true
1916
-        );
1917
-        wp_register_script(
1918
-            'ee_admin_js',
1919
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1920
-            ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1921
-            EVENT_ESPRESSO_VERSION,
1922
-            true
1923
-        );
1924
-        wp_register_script(
1925
-            'jquery-ui-timepicker-addon',
1926
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1927
-            ['jquery-ui-datepicker', 'jquery-ui-slider'],
1928
-            EVENT_ESPRESSO_VERSION,
1929
-            true
1930
-        );
1931
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1932
-        // if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1933
-        //     add_filter('FHEE_load_joyride', '__return_true');
1934
-        // }
1935
-        // script for sorting tables
1936
-        wp_register_script(
1937
-            'espresso_ajax_table_sorting',
1938
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1939
-            ['ee_admin_js', 'jquery-ui-sortable'],
1940
-            EVENT_ESPRESSO_VERSION,
1941
-            true
1942
-        );
1943
-        // script for parsing uri's
1944
-        wp_register_script(
1945
-            'ee-parse-uri',
1946
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1947
-            [],
1948
-            EVENT_ESPRESSO_VERSION,
1949
-            true
1950
-        );
1951
-        // and parsing associative serialized form elements
1952
-        wp_register_script(
1953
-            'ee-serialize-full-array',
1954
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1955
-            ['jquery'],
1956
-            EVENT_ESPRESSO_VERSION,
1957
-            true
1958
-        );
1959
-        // helpers scripts
1960
-        wp_register_script(
1961
-            'ee-text-links',
1962
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1963
-            ['jquery'],
1964
-            EVENT_ESPRESSO_VERSION,
1965
-            true
1966
-        );
1967
-        wp_register_script(
1968
-            'ee-moment-core',
1969
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1970
-            [],
1971
-            EVENT_ESPRESSO_VERSION,
1972
-            true
1973
-        );
1974
-        wp_register_script(
1975
-            'ee-moment',
1976
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1977
-            ['ee-moment-core'],
1978
-            EVENT_ESPRESSO_VERSION,
1979
-            true
1980
-        );
1981
-        wp_register_script(
1982
-            'ee-datepicker',
1983
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1984
-            ['jquery-ui-timepicker-addon', 'ee-moment'],
1985
-            EVENT_ESPRESSO_VERSION,
1986
-            true
1987
-        );
1988
-        // google charts
1989
-        wp_register_script(
1990
-            'google-charts',
1991
-            'https://www.gstatic.com/charts/loader.js',
1992
-            [],
1993
-            EVENT_ESPRESSO_VERSION,
1994
-            false
1995
-        );
1996
-        // ENQUEUE ALL BASICS BY DEFAULT
1997
-        wp_enqueue_style('ee-admin-css');
1998
-        wp_enqueue_script('ee_admin_js');
1999
-        wp_enqueue_script('ee-accounting');
2000
-        wp_enqueue_script('jquery-validate');
2001
-        // taking care of metaboxes
2002
-        if (
2003
-            empty($this->_cpt_route)
2004
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
2005
-        ) {
2006
-            wp_enqueue_script('dashboard');
2007
-        }
2008
-        // LOCALIZED DATA
2009
-        // localize script for ajax lazy loading
2010
-        $lazy_loader_container_ids = apply_filters(
2011
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2012
-            ['espresso_news_post_box_content']
2013
-        );
2014
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2015
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
2016
-        // /**
2017
-        //  * help tour stuff
2018
-        //  */
2019
-        // if (! empty($this->_help_tour)) {
2020
-        //     // register the js for kicking things off
2021
-        //     wp_enqueue_script(
2022
-        //         'ee-help-tour',
2023
-        //         EE_ADMIN_URL . 'assets/ee-help-tour.js',
2024
-        //         array('jquery-joyride'),
2025
-        //         EVENT_ESPRESSO_VERSION,
2026
-        //         true
2027
-        //     );
2028
-        //     $tours = array();
2029
-        //     // setup tours for the js tour object
2030
-        //     foreach ($this->_help_tour['tours'] as $tour) {
2031
-        //         if ($tour instanceof EE_Help_Tour) {
2032
-        //             $tours[] = array(
2033
-        //                 'id'      => $tour->get_slug(),
2034
-        //                 'options' => $tour->get_options(),
2035
-        //             );
2036
-        //         }
2037
-        //     }
2038
-        //     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2039
-        //     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2040
-        // }
2041
-
2042
-        add_filter(
2043
-            'admin_body_class',
2044
-            function ($classes) {
2045
-                if (strpos($classes, 'espresso-admin') === false) {
2046
-                    $classes .= ' espresso-admin';
2047
-                }
2048
-                return $classes;
2049
-            }
2050
-        );
2051
-    }
2052
-
2053
-
2054
-    /**
2055
-     *        admin_footer_scripts_eei18n_js_strings
2056
-     *
2057
-     * @return        void
2058
-     */
2059
-    public function admin_footer_scripts_eei18n_js_strings()
2060
-    {
2061
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2062
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
2063
-            __(
2064
-                'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2065
-                'event_espresso'
2066
-            )
2067
-        );
2068
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
2069
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
2070
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
2071
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
2072
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2073
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
2074
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
2075
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
2076
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
2077
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
2078
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
2079
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
2080
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
2081
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
2082
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
2083
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
2084
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2085
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
2086
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
2087
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
2088
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
2089
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
2090
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
2091
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
2092
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
2093
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
2094
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
2095
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
2096
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
2097
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
2098
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
2099
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
2100
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
2101
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
2102
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
2103
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
2104
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2105
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2106
-    }
2107
-
2108
-
2109
-    /**
2110
-     *        load enhanced xdebug styles for ppl with failing eyesight
2111
-     *
2112
-     * @return        void
2113
-     */
2114
-    public function add_xdebug_style()
2115
-    {
2116
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2117
-    }
2118
-
2119
-
2120
-    /************************/
2121
-    /** LIST TABLE METHODS **/
2122
-    /************************/
2123
-    /**
2124
-     * this sets up the list table if the current view requires it.
2125
-     *
2126
-     * @return void
2127
-     * @throws EE_Error
2128
-     */
2129
-    protected function _set_list_table()
2130
-    {
2131
-        // first is this a list_table view?
2132
-        if (! isset($this->_route_config['list_table'])) {
2133
-            return;
2134
-        } //not a list_table view so get out.
2135
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2136
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2137
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2138
-            // user error msg
2139
-            $error_msg = esc_html__(
2140
-                'An error occurred. The requested list table views could not be found.',
2141
-                'event_espresso'
2142
-            );
2143
-            // developer error msg
2144
-            $error_msg .= '||'
2145
-                          . sprintf(
2146
-                              esc_html__(
2147
-                                  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2148
-                                  'event_espresso'
2149
-                              ),
2150
-                              $this->_req_action,
2151
-                              $list_table_view
2152
-                          );
2153
-            throw new EE_Error($error_msg);
2154
-        }
2155
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2156
-        $this->_views = apply_filters(
2157
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2158
-            $this->_views
2159
-        );
2160
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2161
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2162
-        $this->_set_list_table_view();
2163
-        $this->_set_list_table_object();
2164
-    }
2165
-
2166
-
2167
-    /**
2168
-     * set current view for List Table
2169
-     *
2170
-     * @return void
2171
-     */
2172
-    protected function _set_list_table_view()
2173
-    {
2174
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2175
-        $status = $this->request->getRequestParam('status', null, 'key');
2176
-        $this->_view = $status && array_key_exists($status, $this->_views)
2177
-            ? $status
2178
-            : $this->_view;
2179
-    }
2180
-
2181
-
2182
-    /**
2183
-     * _set_list_table_object
2184
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2185
-     *
2186
-     * @throws InvalidInterfaceException
2187
-     * @throws InvalidArgumentException
2188
-     * @throws InvalidDataTypeException
2189
-     * @throws EE_Error
2190
-     * @throws InvalidInterfaceException
2191
-     */
2192
-    protected function _set_list_table_object()
2193
-    {
2194
-        if (isset($this->_route_config['list_table'])) {
2195
-            if (! class_exists($this->_route_config['list_table'])) {
2196
-                throw new EE_Error(
2197
-                    sprintf(
2198
-                        esc_html__(
2199
-                            'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2200
-                            'event_espresso'
2201
-                        ),
2202
-                        $this->_route_config['list_table'],
2203
-                        get_class($this)
2204
-                    )
2205
-                );
2206
-            }
2207
-            $this->_list_table_object = $this->loader->getShared(
2208
-                $this->_route_config['list_table'],
2209
-                [$this]
2210
-            );
2211
-        }
2212
-    }
2213
-
2214
-
2215
-    /**
2216
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2217
-     *
2218
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2219
-     *                                                    urls.  The array should be indexed by the view it is being
2220
-     *                                                    added to.
2221
-     * @return array
2222
-     */
2223
-    public function get_list_table_view_RLs($extra_query_args = [])
2224
-    {
2225
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2226
-        if (empty($this->_views)) {
2227
-            $this->_views = [];
2228
-        }
2229
-        // cycle thru views
2230
-        foreach ($this->_views as $key => $view) {
2231
-            $query_args = [];
2232
-            // check for current view
2233
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2234
-            $query_args['action']                        = $this->_req_action;
2235
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2236
-            $query_args['status']                        = $view['slug'];
2237
-            // merge any other arguments sent in.
2238
-            if (isset($extra_query_args[ $view['slug'] ])) {
2239
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2240
-            }
2241
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2242
-        }
2243
-        return $this->_views;
2244
-    }
2245
-
2246
-
2247
-    /**
2248
-     * _entries_per_page_dropdown
2249
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2250
-     *
2251
-     * @param int $max_entries total number of rows in the table
2252
-     * @return string
2253
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2254
-     *         WP does it.
2255
-     */
2256
-    protected function _entries_per_page_dropdown($max_entries = 0)
2257
-    {
2258
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2259
-        $values   = [10, 25, 50, 100];
2260
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2261
-        if ($max_entries) {
2262
-            $values[] = $max_entries;
2263
-            sort($values);
2264
-        }
2265
-        $entries_per_page_dropdown = '
1703
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1704
+		// help tour stuff?
1705
+		// if (isset($this->_help_tour[ $this->_req_action ])) {
1706
+		//     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1707
+		// }
1708
+		// current set timezone for timezone js
1709
+		echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1710
+	}
1711
+
1712
+
1713
+	/**
1714
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1715
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1716
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1717
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1718
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1719
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1720
+	 * for the
1721
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1722
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1723
+	 *    'help_trigger_id' => array(
1724
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1725
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1726
+	 *    )
1727
+	 * );
1728
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1729
+	 *
1730
+	 * @param array $help_array
1731
+	 * @param bool  $display
1732
+	 * @return string content
1733
+	 * @throws DomainException
1734
+	 * @throws EE_Error
1735
+	 */
1736
+	protected function _set_help_popup_content($help_array = [], $display = false)
1737
+	{
1738
+		$content    = '';
1739
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1740
+		// loop through the array and setup content
1741
+		foreach ($help_array as $trigger => $help) {
1742
+			// make sure the array is setup properly
1743
+			if (! isset($help['title']) || ! isset($help['content'])) {
1744
+				throw new EE_Error(
1745
+					esc_html__(
1746
+						'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1747
+						'event_espresso'
1748
+					)
1749
+				);
1750
+			}
1751
+			// we're good so let'd setup the template vars and then assign parsed template content to our content.
1752
+			$template_args = [
1753
+				'help_popup_id'      => $trigger,
1754
+				'help_popup_title'   => $help['title'],
1755
+				'help_popup_content' => $help['content'],
1756
+			];
1757
+			$content       .= EEH_Template::display_template(
1758
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1759
+				$template_args,
1760
+				true
1761
+			);
1762
+		}
1763
+		if ($display) {
1764
+			echo $content; // already escaped
1765
+			return '';
1766
+		}
1767
+		return $content;
1768
+	}
1769
+
1770
+
1771
+	/**
1772
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1773
+	 *
1774
+	 * @return array properly formatted array for help popup content
1775
+	 * @throws EE_Error
1776
+	 */
1777
+	private function _get_help_content()
1778
+	{
1779
+		// what is the method we're looking for?
1780
+		$method_name = '_help_popup_content_' . $this->_req_action;
1781
+		// if method doesn't exist let's get out.
1782
+		if (! method_exists($this, $method_name)) {
1783
+			return [];
1784
+		}
1785
+		// k we're good to go let's retrieve the help array
1786
+		$help_array = call_user_func([$this, $method_name]);
1787
+		// make sure we've got an array!
1788
+		if (! is_array($help_array)) {
1789
+			throw new EE_Error(
1790
+				esc_html__(
1791
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1792
+					'event_espresso'
1793
+				)
1794
+			);
1795
+		}
1796
+		return $help_array;
1797
+	}
1798
+
1799
+
1800
+	/**
1801
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1802
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1803
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1804
+	 *
1805
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1806
+	 * @param boolean $display    if false then we return the trigger string
1807
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1808
+	 * @return string
1809
+	 * @throws DomainException
1810
+	 * @throws EE_Error
1811
+	 */
1812
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1813
+	{
1814
+		if ($this->request->isAjax()) {
1815
+			return '';
1816
+		}
1817
+		// let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1818
+		$help_array   = $this->_get_help_content();
1819
+		$help_content = '';
1820
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1821
+			$help_array[ $trigger_id ] = [
1822
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1823
+				'content' => esc_html__(
1824
+					'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1825
+					'event_espresso'
1826
+				),
1827
+			];
1828
+			$help_content              = $this->_set_help_popup_content($help_array, false);
1829
+		}
1830
+		// let's setup the trigger
1831
+		$content = '<a class="ee-dialog" href="?height='
1832
+				   . esc_attr($dimensions[0])
1833
+				   . '&width='
1834
+				   . esc_attr($dimensions[1])
1835
+				   . '&inlineId='
1836
+				   . esc_attr($trigger_id)
1837
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1838
+		$content .= $help_content;
1839
+		if ($display) {
1840
+			echo $content; // already escaped
1841
+			return '';
1842
+		}
1843
+		return $content;
1844
+	}
1845
+
1846
+
1847
+	/**
1848
+	 * _add_global_screen_options
1849
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1850
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1851
+	 *
1852
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1853
+	 *         see also WP_Screen object documents...
1854
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1855
+	 * @abstract
1856
+	 * @return void
1857
+	 */
1858
+	private function _add_global_screen_options()
1859
+	{
1860
+	}
1861
+
1862
+
1863
+	/**
1864
+	 * _add_global_feature_pointers
1865
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1866
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1867
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1868
+	 *
1869
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1870
+	 *         extended) also see:
1871
+	 * @link   http://eamann.com/tech/wordpress-portland/
1872
+	 * @abstract
1873
+	 * @return void
1874
+	 */
1875
+	private function _add_global_feature_pointers()
1876
+	{
1877
+	}
1878
+
1879
+
1880
+	/**
1881
+	 * load_global_scripts_styles
1882
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1883
+	 *
1884
+	 * @return void
1885
+	 */
1886
+	public function load_global_scripts_styles()
1887
+	{
1888
+		/** STYLES **/
1889
+		// add debugging styles
1890
+		if (WP_DEBUG) {
1891
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1892
+		}
1893
+		// register all styles
1894
+		wp_register_style(
1895
+			'espresso-ui-theme',
1896
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1897
+			[],
1898
+			EVENT_ESPRESSO_VERSION
1899
+		);
1900
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1901
+		// helpers styles
1902
+		wp_register_style(
1903
+			'ee-text-links',
1904
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1905
+			[],
1906
+			EVENT_ESPRESSO_VERSION
1907
+		);
1908
+		/** SCRIPTS **/
1909
+		// register all scripts
1910
+		wp_register_script(
1911
+			'ee-dialog',
1912
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1913
+			['jquery', 'jquery-ui-draggable'],
1914
+			EVENT_ESPRESSO_VERSION,
1915
+			true
1916
+		);
1917
+		wp_register_script(
1918
+			'ee_admin_js',
1919
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1920
+			['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1921
+			EVENT_ESPRESSO_VERSION,
1922
+			true
1923
+		);
1924
+		wp_register_script(
1925
+			'jquery-ui-timepicker-addon',
1926
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1927
+			['jquery-ui-datepicker', 'jquery-ui-slider'],
1928
+			EVENT_ESPRESSO_VERSION,
1929
+			true
1930
+		);
1931
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1932
+		// if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1933
+		//     add_filter('FHEE_load_joyride', '__return_true');
1934
+		// }
1935
+		// script for sorting tables
1936
+		wp_register_script(
1937
+			'espresso_ajax_table_sorting',
1938
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1939
+			['ee_admin_js', 'jquery-ui-sortable'],
1940
+			EVENT_ESPRESSO_VERSION,
1941
+			true
1942
+		);
1943
+		// script for parsing uri's
1944
+		wp_register_script(
1945
+			'ee-parse-uri',
1946
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1947
+			[],
1948
+			EVENT_ESPRESSO_VERSION,
1949
+			true
1950
+		);
1951
+		// and parsing associative serialized form elements
1952
+		wp_register_script(
1953
+			'ee-serialize-full-array',
1954
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1955
+			['jquery'],
1956
+			EVENT_ESPRESSO_VERSION,
1957
+			true
1958
+		);
1959
+		// helpers scripts
1960
+		wp_register_script(
1961
+			'ee-text-links',
1962
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1963
+			['jquery'],
1964
+			EVENT_ESPRESSO_VERSION,
1965
+			true
1966
+		);
1967
+		wp_register_script(
1968
+			'ee-moment-core',
1969
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1970
+			[],
1971
+			EVENT_ESPRESSO_VERSION,
1972
+			true
1973
+		);
1974
+		wp_register_script(
1975
+			'ee-moment',
1976
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1977
+			['ee-moment-core'],
1978
+			EVENT_ESPRESSO_VERSION,
1979
+			true
1980
+		);
1981
+		wp_register_script(
1982
+			'ee-datepicker',
1983
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1984
+			['jquery-ui-timepicker-addon', 'ee-moment'],
1985
+			EVENT_ESPRESSO_VERSION,
1986
+			true
1987
+		);
1988
+		// google charts
1989
+		wp_register_script(
1990
+			'google-charts',
1991
+			'https://www.gstatic.com/charts/loader.js',
1992
+			[],
1993
+			EVENT_ESPRESSO_VERSION,
1994
+			false
1995
+		);
1996
+		// ENQUEUE ALL BASICS BY DEFAULT
1997
+		wp_enqueue_style('ee-admin-css');
1998
+		wp_enqueue_script('ee_admin_js');
1999
+		wp_enqueue_script('ee-accounting');
2000
+		wp_enqueue_script('jquery-validate');
2001
+		// taking care of metaboxes
2002
+		if (
2003
+			empty($this->_cpt_route)
2004
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
2005
+		) {
2006
+			wp_enqueue_script('dashboard');
2007
+		}
2008
+		// LOCALIZED DATA
2009
+		// localize script for ajax lazy loading
2010
+		$lazy_loader_container_ids = apply_filters(
2011
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2012
+			['espresso_news_post_box_content']
2013
+		);
2014
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2015
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
2016
+		// /**
2017
+		//  * help tour stuff
2018
+		//  */
2019
+		// if (! empty($this->_help_tour)) {
2020
+		//     // register the js for kicking things off
2021
+		//     wp_enqueue_script(
2022
+		//         'ee-help-tour',
2023
+		//         EE_ADMIN_URL . 'assets/ee-help-tour.js',
2024
+		//         array('jquery-joyride'),
2025
+		//         EVENT_ESPRESSO_VERSION,
2026
+		//         true
2027
+		//     );
2028
+		//     $tours = array();
2029
+		//     // setup tours for the js tour object
2030
+		//     foreach ($this->_help_tour['tours'] as $tour) {
2031
+		//         if ($tour instanceof EE_Help_Tour) {
2032
+		//             $tours[] = array(
2033
+		//                 'id'      => $tour->get_slug(),
2034
+		//                 'options' => $tour->get_options(),
2035
+		//             );
2036
+		//         }
2037
+		//     }
2038
+		//     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2039
+		//     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2040
+		// }
2041
+
2042
+		add_filter(
2043
+			'admin_body_class',
2044
+			function ($classes) {
2045
+				if (strpos($classes, 'espresso-admin') === false) {
2046
+					$classes .= ' espresso-admin';
2047
+				}
2048
+				return $classes;
2049
+			}
2050
+		);
2051
+	}
2052
+
2053
+
2054
+	/**
2055
+	 *        admin_footer_scripts_eei18n_js_strings
2056
+	 *
2057
+	 * @return        void
2058
+	 */
2059
+	public function admin_footer_scripts_eei18n_js_strings()
2060
+	{
2061
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2062
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
2063
+			__(
2064
+				'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2065
+				'event_espresso'
2066
+			)
2067
+		);
2068
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
2069
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
2070
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
2071
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
2072
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2073
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
2074
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
2075
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
2076
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
2077
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
2078
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
2079
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
2080
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
2081
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
2082
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
2083
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
2084
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2085
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
2086
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
2087
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
2088
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
2089
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
2090
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
2091
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
2092
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
2093
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
2094
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
2095
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
2096
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
2097
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
2098
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
2099
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
2100
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
2101
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
2102
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
2103
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
2104
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2105
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2106
+	}
2107
+
2108
+
2109
+	/**
2110
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2111
+	 *
2112
+	 * @return        void
2113
+	 */
2114
+	public function add_xdebug_style()
2115
+	{
2116
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2117
+	}
2118
+
2119
+
2120
+	/************************/
2121
+	/** LIST TABLE METHODS **/
2122
+	/************************/
2123
+	/**
2124
+	 * this sets up the list table if the current view requires it.
2125
+	 *
2126
+	 * @return void
2127
+	 * @throws EE_Error
2128
+	 */
2129
+	protected function _set_list_table()
2130
+	{
2131
+		// first is this a list_table view?
2132
+		if (! isset($this->_route_config['list_table'])) {
2133
+			return;
2134
+		} //not a list_table view so get out.
2135
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2136
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2137
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2138
+			// user error msg
2139
+			$error_msg = esc_html__(
2140
+				'An error occurred. The requested list table views could not be found.',
2141
+				'event_espresso'
2142
+			);
2143
+			// developer error msg
2144
+			$error_msg .= '||'
2145
+						  . sprintf(
2146
+							  esc_html__(
2147
+								  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2148
+								  'event_espresso'
2149
+							  ),
2150
+							  $this->_req_action,
2151
+							  $list_table_view
2152
+						  );
2153
+			throw new EE_Error($error_msg);
2154
+		}
2155
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2156
+		$this->_views = apply_filters(
2157
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2158
+			$this->_views
2159
+		);
2160
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2161
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2162
+		$this->_set_list_table_view();
2163
+		$this->_set_list_table_object();
2164
+	}
2165
+
2166
+
2167
+	/**
2168
+	 * set current view for List Table
2169
+	 *
2170
+	 * @return void
2171
+	 */
2172
+	protected function _set_list_table_view()
2173
+	{
2174
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2175
+		$status = $this->request->getRequestParam('status', null, 'key');
2176
+		$this->_view = $status && array_key_exists($status, $this->_views)
2177
+			? $status
2178
+			: $this->_view;
2179
+	}
2180
+
2181
+
2182
+	/**
2183
+	 * _set_list_table_object
2184
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2185
+	 *
2186
+	 * @throws InvalidInterfaceException
2187
+	 * @throws InvalidArgumentException
2188
+	 * @throws InvalidDataTypeException
2189
+	 * @throws EE_Error
2190
+	 * @throws InvalidInterfaceException
2191
+	 */
2192
+	protected function _set_list_table_object()
2193
+	{
2194
+		if (isset($this->_route_config['list_table'])) {
2195
+			if (! class_exists($this->_route_config['list_table'])) {
2196
+				throw new EE_Error(
2197
+					sprintf(
2198
+						esc_html__(
2199
+							'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2200
+							'event_espresso'
2201
+						),
2202
+						$this->_route_config['list_table'],
2203
+						get_class($this)
2204
+					)
2205
+				);
2206
+			}
2207
+			$this->_list_table_object = $this->loader->getShared(
2208
+				$this->_route_config['list_table'],
2209
+				[$this]
2210
+			);
2211
+		}
2212
+	}
2213
+
2214
+
2215
+	/**
2216
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2217
+	 *
2218
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2219
+	 *                                                    urls.  The array should be indexed by the view it is being
2220
+	 *                                                    added to.
2221
+	 * @return array
2222
+	 */
2223
+	public function get_list_table_view_RLs($extra_query_args = [])
2224
+	{
2225
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2226
+		if (empty($this->_views)) {
2227
+			$this->_views = [];
2228
+		}
2229
+		// cycle thru views
2230
+		foreach ($this->_views as $key => $view) {
2231
+			$query_args = [];
2232
+			// check for current view
2233
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2234
+			$query_args['action']                        = $this->_req_action;
2235
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2236
+			$query_args['status']                        = $view['slug'];
2237
+			// merge any other arguments sent in.
2238
+			if (isset($extra_query_args[ $view['slug'] ])) {
2239
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2240
+			}
2241
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2242
+		}
2243
+		return $this->_views;
2244
+	}
2245
+
2246
+
2247
+	/**
2248
+	 * _entries_per_page_dropdown
2249
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2250
+	 *
2251
+	 * @param int $max_entries total number of rows in the table
2252
+	 * @return string
2253
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2254
+	 *         WP does it.
2255
+	 */
2256
+	protected function _entries_per_page_dropdown($max_entries = 0)
2257
+	{
2258
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2259
+		$values   = [10, 25, 50, 100];
2260
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2261
+		if ($max_entries) {
2262
+			$values[] = $max_entries;
2263
+			sort($values);
2264
+		}
2265
+		$entries_per_page_dropdown = '
2266 2266
 			<div id="entries-per-page-dv" class="alignleft actions">
2267 2267
 				<label class="hide-if-no-js">
2268 2268
 					Show
2269 2269
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2270
-        foreach ($values as $value) {
2271
-            if ($value < $max_entries) {
2272
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2273
-                $entries_per_page_dropdown .= '
2270
+		foreach ($values as $value) {
2271
+			if ($value < $max_entries) {
2272
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2273
+				$entries_per_page_dropdown .= '
2274 2274
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2275
-            }
2276
-        }
2277
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2278
-        $entries_per_page_dropdown .= '
2275
+			}
2276
+		}
2277
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2278
+		$entries_per_page_dropdown .= '
2279 2279
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2280
-        $entries_per_page_dropdown .= '
2280
+		$entries_per_page_dropdown .= '
2281 2281
 					</select>
2282 2282
 					entries
2283 2283
 				</label>
2284 2284
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2285 2285
 			</div>
2286 2286
 		';
2287
-        return $entries_per_page_dropdown;
2288
-    }
2289
-
2290
-
2291
-    /**
2292
-     *        _set_search_attributes
2293
-     *
2294
-     * @return        void
2295
-     */
2296
-    public function _set_search_attributes()
2297
-    {
2298
-        $this->_template_args['search']['btn_label'] = sprintf(
2299
-            esc_html__('Search %s', 'event_espresso'),
2300
-            empty($this->_search_btn_label) ? $this->page_label
2301
-                : $this->_search_btn_label
2302
-        );
2303
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2304
-    }
2305
-
2306
-
2307
-
2308
-    /*** END LIST TABLE METHODS **/
2309
-
2310
-
2311
-    /**
2312
-     * _add_registered_metaboxes
2313
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2314
-     *
2315
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2316
-     * @return void
2317
-     * @throws EE_Error
2318
-     */
2319
-    private function _add_registered_meta_boxes()
2320
-    {
2321
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2322
-        // we only add meta boxes if the page_route calls for it
2323
-        if (
2324
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2325
-            && is_array(
2326
-                $this->_route_config['metaboxes']
2327
-            )
2328
-        ) {
2329
-            // this simply loops through the callbacks provided
2330
-            // and checks if there is a corresponding callback registered by the child
2331
-            // if there is then we go ahead and process the metabox loader.
2332
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2333
-                // first check for Closures
2334
-                if ($metabox_callback instanceof Closure) {
2335
-                    $result = $metabox_callback();
2336
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2337
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2338
-                } else {
2339
-                    $result = call_user_func([$this, &$metabox_callback]);
2340
-                }
2341
-                if ($result === false) {
2342
-                    // user error msg
2343
-                    $error_msg = esc_html__(
2344
-                        'An error occurred. The  requested metabox could not be found.',
2345
-                        'event_espresso'
2346
-                    );
2347
-                    // developer error msg
2348
-                    $error_msg .= '||'
2349
-                                  . sprintf(
2350
-                                      esc_html__(
2351
-                                          'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2352
-                                          'event_espresso'
2353
-                                      ),
2354
-                                      $metabox_callback
2355
-                                  );
2356
-                    throw new EE_Error($error_msg);
2357
-                }
2358
-            }
2359
-        }
2360
-    }
2361
-
2362
-
2363
-    /**
2364
-     * _add_screen_columns
2365
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2366
-     * the dynamic column template and we'll setup the column options for the page.
2367
-     *
2368
-     * @return void
2369
-     */
2370
-    private function _add_screen_columns()
2371
-    {
2372
-        if (
2373
-            is_array($this->_route_config)
2374
-            && isset($this->_route_config['columns'])
2375
-            && is_array($this->_route_config['columns'])
2376
-            && count($this->_route_config['columns']) === 2
2377
-        ) {
2378
-            add_screen_option(
2379
-                'layout_columns',
2380
-                [
2381
-                    'max'     => (int) $this->_route_config['columns'][0],
2382
-                    'default' => (int) $this->_route_config['columns'][1],
2383
-                ]
2384
-            );
2385
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2386
-            $screen_id                                           = $this->_current_screen->id;
2387
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2388
-            $total_columns                                       = ! empty($screen_columns)
2389
-                ? $screen_columns
2390
-                : $this->_route_config['columns'][1];
2391
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2392
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2393
-            $this->_template_args['screen']                      = $this->_current_screen;
2394
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2395
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2396
-            // finally if we don't have has_metaboxes set in the route config
2397
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2398
-            $this->_route_config['has_metaboxes'] = true;
2399
-        }
2400
-    }
2401
-
2402
-
2403
-
2404
-    /** GLOBALLY AVAILABLE METABOXES **/
2405
-
2406
-
2407
-    /**
2408
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2409
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2410
-     * these get loaded on.
2411
-     */
2412
-    private function _espresso_news_post_box()
2413
-    {
2414
-        $news_box_title = apply_filters(
2415
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2416
-            esc_html__('New @ Event Espresso', 'event_espresso')
2417
-        );
2418
-        add_meta_box(
2419
-            'espresso_news_post_box',
2420
-            $news_box_title,
2421
-            [
2422
-                $this,
2423
-                'espresso_news_post_box',
2424
-            ],
2425
-            $this->_wp_page_slug,
2426
-            'side'
2427
-        );
2428
-    }
2429
-
2430
-
2431
-    /**
2432
-     * Code for setting up espresso ratings request metabox.
2433
-     */
2434
-    protected function _espresso_ratings_request()
2435
-    {
2436
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2437
-            return;
2438
-        }
2439
-        $ratings_box_title = apply_filters(
2440
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2441
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2442
-        );
2443
-        add_meta_box(
2444
-            'espresso_ratings_request',
2445
-            $ratings_box_title,
2446
-            [
2447
-                $this,
2448
-                'espresso_ratings_request',
2449
-            ],
2450
-            $this->_wp_page_slug,
2451
-            'side'
2452
-        );
2453
-    }
2454
-
2455
-
2456
-    /**
2457
-     * Code for setting up espresso ratings request metabox content.
2458
-     *
2459
-     * @throws DomainException
2460
-     */
2461
-    public function espresso_ratings_request()
2462
-    {
2463
-        EEH_Template::display_template(
2464
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2465
-            []
2466
-        );
2467
-    }
2468
-
2469
-
2470
-    public static function cached_rss_display($rss_id, $url)
2471
-    {
2472
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2473
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2474
-                     . '</p><p class="hide-if-js">'
2475
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2476
-                     . '</p>';
2477
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2478
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2479
-        $post      = '</div>' . "\n";
2480
-        $cache_key = 'ee_rss_' . md5($rss_id);
2481
-        $output    = get_transient($cache_key);
2482
-        if ($output !== false) {
2483
-            echo $pre . $output . $post; // already escaped
2484
-            return true;
2485
-        }
2486
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2487
-            echo $pre . $loading . $post; // already escaped
2488
-            return false;
2489
-        }
2490
-        ob_start();
2491
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2492
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2493
-        return true;
2494
-    }
2495
-
2496
-
2497
-    public function espresso_news_post_box()
2498
-    {
2499
-        ?>
2287
+		return $entries_per_page_dropdown;
2288
+	}
2289
+
2290
+
2291
+	/**
2292
+	 *        _set_search_attributes
2293
+	 *
2294
+	 * @return        void
2295
+	 */
2296
+	public function _set_search_attributes()
2297
+	{
2298
+		$this->_template_args['search']['btn_label'] = sprintf(
2299
+			esc_html__('Search %s', 'event_espresso'),
2300
+			empty($this->_search_btn_label) ? $this->page_label
2301
+				: $this->_search_btn_label
2302
+		);
2303
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2304
+	}
2305
+
2306
+
2307
+
2308
+	/*** END LIST TABLE METHODS **/
2309
+
2310
+
2311
+	/**
2312
+	 * _add_registered_metaboxes
2313
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2314
+	 *
2315
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2316
+	 * @return void
2317
+	 * @throws EE_Error
2318
+	 */
2319
+	private function _add_registered_meta_boxes()
2320
+	{
2321
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2322
+		// we only add meta boxes if the page_route calls for it
2323
+		if (
2324
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2325
+			&& is_array(
2326
+				$this->_route_config['metaboxes']
2327
+			)
2328
+		) {
2329
+			// this simply loops through the callbacks provided
2330
+			// and checks if there is a corresponding callback registered by the child
2331
+			// if there is then we go ahead and process the metabox loader.
2332
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2333
+				// first check for Closures
2334
+				if ($metabox_callback instanceof Closure) {
2335
+					$result = $metabox_callback();
2336
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2337
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2338
+				} else {
2339
+					$result = call_user_func([$this, &$metabox_callback]);
2340
+				}
2341
+				if ($result === false) {
2342
+					// user error msg
2343
+					$error_msg = esc_html__(
2344
+						'An error occurred. The  requested metabox could not be found.',
2345
+						'event_espresso'
2346
+					);
2347
+					// developer error msg
2348
+					$error_msg .= '||'
2349
+								  . sprintf(
2350
+									  esc_html__(
2351
+										  'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2352
+										  'event_espresso'
2353
+									  ),
2354
+									  $metabox_callback
2355
+								  );
2356
+					throw new EE_Error($error_msg);
2357
+				}
2358
+			}
2359
+		}
2360
+	}
2361
+
2362
+
2363
+	/**
2364
+	 * _add_screen_columns
2365
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2366
+	 * the dynamic column template and we'll setup the column options for the page.
2367
+	 *
2368
+	 * @return void
2369
+	 */
2370
+	private function _add_screen_columns()
2371
+	{
2372
+		if (
2373
+			is_array($this->_route_config)
2374
+			&& isset($this->_route_config['columns'])
2375
+			&& is_array($this->_route_config['columns'])
2376
+			&& count($this->_route_config['columns']) === 2
2377
+		) {
2378
+			add_screen_option(
2379
+				'layout_columns',
2380
+				[
2381
+					'max'     => (int) $this->_route_config['columns'][0],
2382
+					'default' => (int) $this->_route_config['columns'][1],
2383
+				]
2384
+			);
2385
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2386
+			$screen_id                                           = $this->_current_screen->id;
2387
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2388
+			$total_columns                                       = ! empty($screen_columns)
2389
+				? $screen_columns
2390
+				: $this->_route_config['columns'][1];
2391
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2392
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2393
+			$this->_template_args['screen']                      = $this->_current_screen;
2394
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2395
+																   . 'admin_details_metabox_column_wrapper.template.php';
2396
+			// finally if we don't have has_metaboxes set in the route config
2397
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2398
+			$this->_route_config['has_metaboxes'] = true;
2399
+		}
2400
+	}
2401
+
2402
+
2403
+
2404
+	/** GLOBALLY AVAILABLE METABOXES **/
2405
+
2406
+
2407
+	/**
2408
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2409
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2410
+	 * these get loaded on.
2411
+	 */
2412
+	private function _espresso_news_post_box()
2413
+	{
2414
+		$news_box_title = apply_filters(
2415
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2416
+			esc_html__('New @ Event Espresso', 'event_espresso')
2417
+		);
2418
+		add_meta_box(
2419
+			'espresso_news_post_box',
2420
+			$news_box_title,
2421
+			[
2422
+				$this,
2423
+				'espresso_news_post_box',
2424
+			],
2425
+			$this->_wp_page_slug,
2426
+			'side'
2427
+		);
2428
+	}
2429
+
2430
+
2431
+	/**
2432
+	 * Code for setting up espresso ratings request metabox.
2433
+	 */
2434
+	protected function _espresso_ratings_request()
2435
+	{
2436
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2437
+			return;
2438
+		}
2439
+		$ratings_box_title = apply_filters(
2440
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2441
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2442
+		);
2443
+		add_meta_box(
2444
+			'espresso_ratings_request',
2445
+			$ratings_box_title,
2446
+			[
2447
+				$this,
2448
+				'espresso_ratings_request',
2449
+			],
2450
+			$this->_wp_page_slug,
2451
+			'side'
2452
+		);
2453
+	}
2454
+
2455
+
2456
+	/**
2457
+	 * Code for setting up espresso ratings request metabox content.
2458
+	 *
2459
+	 * @throws DomainException
2460
+	 */
2461
+	public function espresso_ratings_request()
2462
+	{
2463
+		EEH_Template::display_template(
2464
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2465
+			[]
2466
+		);
2467
+	}
2468
+
2469
+
2470
+	public static function cached_rss_display($rss_id, $url)
2471
+	{
2472
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2473
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2474
+					 . '</p><p class="hide-if-js">'
2475
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2476
+					 . '</p>';
2477
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2478
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2479
+		$post      = '</div>' . "\n";
2480
+		$cache_key = 'ee_rss_' . md5($rss_id);
2481
+		$output    = get_transient($cache_key);
2482
+		if ($output !== false) {
2483
+			echo $pre . $output . $post; // already escaped
2484
+			return true;
2485
+		}
2486
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2487
+			echo $pre . $loading . $post; // already escaped
2488
+			return false;
2489
+		}
2490
+		ob_start();
2491
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2492
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2493
+		return true;
2494
+	}
2495
+
2496
+
2497
+	public function espresso_news_post_box()
2498
+	{
2499
+		?>
2500 2500
         <div class="padding">
2501 2501
             <div id="espresso_news_post_box_content" class="infolinks">
2502 2502
                 <?php
2503
-                // Get RSS Feed(s)
2504
-                self::cached_rss_display(
2505
-                    'espresso_news_post_box_content',
2506
-                    esc_url_raw(
2507
-                        apply_filters(
2508
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2509
-                            'https://eventespresso.com/feed/'
2510
-                        )
2511
-                    )
2512
-                );
2513
-                ?>
2503
+				// Get RSS Feed(s)
2504
+				self::cached_rss_display(
2505
+					'espresso_news_post_box_content',
2506
+					esc_url_raw(
2507
+						apply_filters(
2508
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2509
+							'https://eventespresso.com/feed/'
2510
+						)
2511
+					)
2512
+				);
2513
+				?>
2514 2514
             </div>
2515 2515
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2516 2516
         </div>
2517 2517
         <?php
2518
-    }
2519
-
2520
-
2521
-    private function _espresso_links_post_box()
2522
-    {
2523
-        // Hiding until we actually have content to put in here...
2524
-        // add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2525
-    }
2526
-
2527
-
2528
-    public function espresso_links_post_box()
2529
-    {
2530
-        // Hiding until we actually have content to put in here...
2531
-        // EEH_Template::display_template(
2532
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2533
-        // );
2534
-    }
2535
-
2536
-
2537
-    protected function _espresso_sponsors_post_box()
2538
-    {
2539
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2540
-            add_meta_box(
2541
-                'espresso_sponsors_post_box',
2542
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2543
-                [$this, 'espresso_sponsors_post_box'],
2544
-                $this->_wp_page_slug,
2545
-                'side'
2546
-            );
2547
-        }
2548
-    }
2549
-
2550
-
2551
-    public function espresso_sponsors_post_box()
2552
-    {
2553
-        EEH_Template::display_template(
2554
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2555
-        );
2556
-    }
2557
-
2558
-
2559
-    private function _publish_post_box()
2560
-    {
2561
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2562
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2563
-        // then we'll use that for the metabox label.
2564
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2565
-        if (! empty($this->_labels['publishbox'])) {
2566
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2567
-                : $this->_labels['publishbox'];
2568
-        } else {
2569
-            $box_label = esc_html__('Publish', 'event_espresso');
2570
-        }
2571
-        $box_label = apply_filters(
2572
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2573
-            $box_label,
2574
-            $this->_req_action,
2575
-            $this
2576
-        );
2577
-        add_meta_box(
2578
-            $meta_box_ref,
2579
-            $box_label,
2580
-            [$this, 'editor_overview'],
2581
-            $this->_current_screen->id,
2582
-            'side',
2583
-            'high'
2584
-        );
2585
-    }
2586
-
2587
-
2588
-    public function editor_overview()
2589
-    {
2590
-        // if we have extra content set let's add it in if not make sure its empty
2591
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2592
-            ? $this->_template_args['publish_box_extra_content']
2593
-            : '';
2594
-        echo EEH_Template::display_template(
2595
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2596
-            $this->_template_args,
2597
-            true
2598
-        );
2599
-    }
2600
-
2601
-
2602
-    /** end of globally available metaboxes section **/
2603
-
2604
-
2605
-    /**
2606
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2607
-     * protected method.
2608
-     *
2609
-     * @param string $name
2610
-     * @param int    $id
2611
-     * @param bool   $delete
2612
-     * @param string $save_close_redirect_URL
2613
-     * @param bool   $both_btns
2614
-     * @throws EE_Error
2615
-     * @throws InvalidArgumentException
2616
-     * @throws InvalidDataTypeException
2617
-     * @throws InvalidInterfaceException
2618
-     * @see   $this->_set_publish_post_box_vars for param details
2619
-     * @since 4.6.0
2620
-     */
2621
-    public function set_publish_post_box_vars(
2622
-        $name = '',
2623
-        $id = 0,
2624
-        $delete = false,
2625
-        $save_close_redirect_URL = '',
2626
-        $both_btns = true
2627
-    ) {
2628
-        $this->_set_publish_post_box_vars(
2629
-            $name,
2630
-            $id,
2631
-            $delete,
2632
-            $save_close_redirect_URL,
2633
-            $both_btns
2634
-        );
2635
-    }
2636
-
2637
-
2638
-    /**
2639
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2640
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2641
-     * save, and save and close buttons to work properly, then you will want to include a
2642
-     * values for the name and id arguments.
2643
-     *
2644
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2645
-     * @param int     $id                         id attached to the item published
2646
-     * @param string  $delete                     page route callback for the delete action
2647
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2648
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2649
-     *                                            the Save button
2650
-     * @throws EE_Error
2651
-     * @throws InvalidArgumentException
2652
-     * @throws InvalidDataTypeException
2653
-     * @throws InvalidInterfaceException
2654
-     * @todo  Add in validation for name/id arguments.
2655
-     */
2656
-    protected function _set_publish_post_box_vars(
2657
-        $name = '',
2658
-        $id = 0,
2659
-        $delete = '',
2660
-        $save_close_redirect_URL = '',
2661
-        $both_btns = true
2662
-    ) {
2663
-        // if Save & Close, use a custom redirect URL or default to the main page?
2664
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2665
-            ? $save_close_redirect_URL
2666
-            : $this->_admin_base_url;
2667
-        // create the Save & Close and Save buttons
2668
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2669
-        // if we have extra content set let's add it in if not make sure its empty
2670
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2671
-            ? $this->_template_args['publish_box_extra_content']
2672
-            : '';
2673
-        if ($delete && ! empty($id)) {
2674
-            // make sure we have a default if just true is sent.
2675
-            $delete           = ! empty($delete) ? $delete : 'delete';
2676
-            $delete_link_args = [$name => $id];
2677
-            $delete           = $this->get_action_link_or_button(
2678
-                $delete,
2679
-                $delete,
2680
-                $delete_link_args,
2681
-                'submitdelete deletion',
2682
-                '',
2683
-                false
2684
-            );
2685
-        }
2686
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2687
-        if (! empty($name) && ! empty($id)) {
2688
-            $hidden_field_arr[ $name ] = [
2689
-                'type'  => 'hidden',
2690
-                'value' => $id,
2691
-            ];
2692
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2693
-        } else {
2694
-            $hf = '';
2695
-        }
2696
-        // add hidden field
2697
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2698
-            ? $hf[ $name ]['field']
2699
-            : $hf;
2700
-    }
2701
-
2702
-
2703
-    /**
2704
-     * displays an error message to ppl who have javascript disabled
2705
-     *
2706
-     * @return void
2707
-     */
2708
-    private function _display_no_javascript_warning()
2709
-    {
2710
-        ?>
2518
+	}
2519
+
2520
+
2521
+	private function _espresso_links_post_box()
2522
+	{
2523
+		// Hiding until we actually have content to put in here...
2524
+		// add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2525
+	}
2526
+
2527
+
2528
+	public function espresso_links_post_box()
2529
+	{
2530
+		// Hiding until we actually have content to put in here...
2531
+		// EEH_Template::display_template(
2532
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2533
+		// );
2534
+	}
2535
+
2536
+
2537
+	protected function _espresso_sponsors_post_box()
2538
+	{
2539
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2540
+			add_meta_box(
2541
+				'espresso_sponsors_post_box',
2542
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2543
+				[$this, 'espresso_sponsors_post_box'],
2544
+				$this->_wp_page_slug,
2545
+				'side'
2546
+			);
2547
+		}
2548
+	}
2549
+
2550
+
2551
+	public function espresso_sponsors_post_box()
2552
+	{
2553
+		EEH_Template::display_template(
2554
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2555
+		);
2556
+	}
2557
+
2558
+
2559
+	private function _publish_post_box()
2560
+	{
2561
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2562
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2563
+		// then we'll use that for the metabox label.
2564
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2565
+		if (! empty($this->_labels['publishbox'])) {
2566
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2567
+				: $this->_labels['publishbox'];
2568
+		} else {
2569
+			$box_label = esc_html__('Publish', 'event_espresso');
2570
+		}
2571
+		$box_label = apply_filters(
2572
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2573
+			$box_label,
2574
+			$this->_req_action,
2575
+			$this
2576
+		);
2577
+		add_meta_box(
2578
+			$meta_box_ref,
2579
+			$box_label,
2580
+			[$this, 'editor_overview'],
2581
+			$this->_current_screen->id,
2582
+			'side',
2583
+			'high'
2584
+		);
2585
+	}
2586
+
2587
+
2588
+	public function editor_overview()
2589
+	{
2590
+		// if we have extra content set let's add it in if not make sure its empty
2591
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2592
+			? $this->_template_args['publish_box_extra_content']
2593
+			: '';
2594
+		echo EEH_Template::display_template(
2595
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2596
+			$this->_template_args,
2597
+			true
2598
+		);
2599
+	}
2600
+
2601
+
2602
+	/** end of globally available metaboxes section **/
2603
+
2604
+
2605
+	/**
2606
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2607
+	 * protected method.
2608
+	 *
2609
+	 * @param string $name
2610
+	 * @param int    $id
2611
+	 * @param bool   $delete
2612
+	 * @param string $save_close_redirect_URL
2613
+	 * @param bool   $both_btns
2614
+	 * @throws EE_Error
2615
+	 * @throws InvalidArgumentException
2616
+	 * @throws InvalidDataTypeException
2617
+	 * @throws InvalidInterfaceException
2618
+	 * @see   $this->_set_publish_post_box_vars for param details
2619
+	 * @since 4.6.0
2620
+	 */
2621
+	public function set_publish_post_box_vars(
2622
+		$name = '',
2623
+		$id = 0,
2624
+		$delete = false,
2625
+		$save_close_redirect_URL = '',
2626
+		$both_btns = true
2627
+	) {
2628
+		$this->_set_publish_post_box_vars(
2629
+			$name,
2630
+			$id,
2631
+			$delete,
2632
+			$save_close_redirect_URL,
2633
+			$both_btns
2634
+		);
2635
+	}
2636
+
2637
+
2638
+	/**
2639
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2640
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2641
+	 * save, and save and close buttons to work properly, then you will want to include a
2642
+	 * values for the name and id arguments.
2643
+	 *
2644
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2645
+	 * @param int     $id                         id attached to the item published
2646
+	 * @param string  $delete                     page route callback for the delete action
2647
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2648
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2649
+	 *                                            the Save button
2650
+	 * @throws EE_Error
2651
+	 * @throws InvalidArgumentException
2652
+	 * @throws InvalidDataTypeException
2653
+	 * @throws InvalidInterfaceException
2654
+	 * @todo  Add in validation for name/id arguments.
2655
+	 */
2656
+	protected function _set_publish_post_box_vars(
2657
+		$name = '',
2658
+		$id = 0,
2659
+		$delete = '',
2660
+		$save_close_redirect_URL = '',
2661
+		$both_btns = true
2662
+	) {
2663
+		// if Save & Close, use a custom redirect URL or default to the main page?
2664
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2665
+			? $save_close_redirect_URL
2666
+			: $this->_admin_base_url;
2667
+		// create the Save & Close and Save buttons
2668
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2669
+		// if we have extra content set let's add it in if not make sure its empty
2670
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2671
+			? $this->_template_args['publish_box_extra_content']
2672
+			: '';
2673
+		if ($delete && ! empty($id)) {
2674
+			// make sure we have a default if just true is sent.
2675
+			$delete           = ! empty($delete) ? $delete : 'delete';
2676
+			$delete_link_args = [$name => $id];
2677
+			$delete           = $this->get_action_link_or_button(
2678
+				$delete,
2679
+				$delete,
2680
+				$delete_link_args,
2681
+				'submitdelete deletion',
2682
+				'',
2683
+				false
2684
+			);
2685
+		}
2686
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2687
+		if (! empty($name) && ! empty($id)) {
2688
+			$hidden_field_arr[ $name ] = [
2689
+				'type'  => 'hidden',
2690
+				'value' => $id,
2691
+			];
2692
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2693
+		} else {
2694
+			$hf = '';
2695
+		}
2696
+		// add hidden field
2697
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2698
+			? $hf[ $name ]['field']
2699
+			: $hf;
2700
+	}
2701
+
2702
+
2703
+	/**
2704
+	 * displays an error message to ppl who have javascript disabled
2705
+	 *
2706
+	 * @return void
2707
+	 */
2708
+	private function _display_no_javascript_warning()
2709
+	{
2710
+		?>
2711 2711
         <noscript>
2712 2712
             <div id="no-js-message" class="error">
2713 2713
                 <p style="font-size:1.3em;">
2714 2714
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2715 2715
                     <?php esc_html_e(
2716
-                        'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2717
-                        'event_espresso'
2718
-                    ); ?>
2716
+						'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2717
+						'event_espresso'
2718
+					); ?>
2719 2719
                 </p>
2720 2720
             </div>
2721 2721
         </noscript>
2722 2722
         <?php
2723
-    }
2724
-
2725
-
2726
-    /**
2727
-     * displays espresso success and/or error notices
2728
-     *
2729
-     * @return void
2730
-     */
2731
-    protected function _display_espresso_notices()
2732
-    {
2733
-        $notices = $this->_get_transient(true);
2734
-        echo stripslashes($notices);
2735
-    }
2736
-
2737
-
2738
-    /**
2739
-     * spinny things pacify the masses
2740
-     *
2741
-     * @return void
2742
-     */
2743
-    protected function _add_admin_page_ajax_loading_img()
2744
-    {
2745
-        ?>
2723
+	}
2724
+
2725
+
2726
+	/**
2727
+	 * displays espresso success and/or error notices
2728
+	 *
2729
+	 * @return void
2730
+	 */
2731
+	protected function _display_espresso_notices()
2732
+	{
2733
+		$notices = $this->_get_transient(true);
2734
+		echo stripslashes($notices);
2735
+	}
2736
+
2737
+
2738
+	/**
2739
+	 * spinny things pacify the masses
2740
+	 *
2741
+	 * @return void
2742
+	 */
2743
+	protected function _add_admin_page_ajax_loading_img()
2744
+	{
2745
+		?>
2746 2746
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2747 2747
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2748
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2748
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2749 2749
         </div>
2750 2750
         <?php
2751
-    }
2751
+	}
2752 2752
 
2753 2753
 
2754
-    /**
2755
-     * add admin page overlay for modal boxes
2756
-     *
2757
-     * @return void
2758
-     */
2759
-    protected function _add_admin_page_overlay()
2760
-    {
2761
-        ?>
2754
+	/**
2755
+	 * add admin page overlay for modal boxes
2756
+	 *
2757
+	 * @return void
2758
+	 */
2759
+	protected function _add_admin_page_overlay()
2760
+	{
2761
+		?>
2762 2762
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2763 2763
         <?php
2764
-    }
2765
-
2766
-
2767
-    /**
2768
-     * facade for add_meta_box
2769
-     *
2770
-     * @param string  $action        where the metabox get's displayed
2771
-     * @param string  $title         Title of Metabox (output in metabox header)
2772
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2773
-     *                               instead of the one created in here.
2774
-     * @param array   $callback_args an array of args supplied for the metabox
2775
-     * @param string  $column        what metabox column
2776
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2777
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2778
-     *                               created but just set our own callback for wp's add_meta_box.
2779
-     * @throws DomainException
2780
-     */
2781
-    public function _add_admin_page_meta_box(
2782
-        $action,
2783
-        $title,
2784
-        $callback,
2785
-        $callback_args,
2786
-        $column = 'normal',
2787
-        $priority = 'high',
2788
-        $create_func = true
2789
-    ) {
2790
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2791
-        // if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2792
-        if (empty($callback_args) && $create_func) {
2793
-            $callback_args = [
2794
-                'template_path' => $this->_template_path,
2795
-                'template_args' => $this->_template_args,
2796
-            ];
2797
-        }
2798
-        // if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2799
-        $call_back_func = $create_func
2800
-            ? function ($post, $metabox) {
2801
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2802
-                echo EEH_Template::display_template(
2803
-                    $metabox['args']['template_path'],
2804
-                    $metabox['args']['template_args'],
2805
-                    true
2806
-                );
2807
-            }
2808
-            : $callback;
2809
-        add_meta_box(
2810
-            str_replace('_', '-', $action) . '-mbox',
2811
-            $title,
2812
-            $call_back_func,
2813
-            $this->_wp_page_slug,
2814
-            $column,
2815
-            $priority,
2816
-            $callback_args
2817
-        );
2818
-    }
2819
-
2820
-
2821
-    /**
2822
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2823
-     *
2824
-     * @throws DomainException
2825
-     * @throws EE_Error
2826
-     */
2827
-    public function display_admin_page_with_metabox_columns()
2828
-    {
2829
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2830
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2831
-            $this->_column_template_path,
2832
-            $this->_template_args,
2833
-            true
2834
-        );
2835
-        // the final wrapper
2836
-        $this->admin_page_wrapper();
2837
-    }
2838
-
2839
-
2840
-    /**
2841
-     * generates  HTML wrapper for an admin details page
2842
-     *
2843
-     * @return void
2844
-     * @throws EE_Error
2845
-     * @throws DomainException
2846
-     */
2847
-    public function display_admin_page_with_sidebar()
2848
-    {
2849
-        $this->_display_admin_page(true);
2850
-    }
2851
-
2852
-
2853
-    /**
2854
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2855
-     *
2856
-     * @return void
2857
-     * @throws EE_Error
2858
-     * @throws DomainException
2859
-     */
2860
-    public function display_admin_page_with_no_sidebar()
2861
-    {
2862
-        $this->_display_admin_page();
2863
-    }
2864
-
2865
-
2866
-    /**
2867
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2868
-     *
2869
-     * @return void
2870
-     * @throws EE_Error
2871
-     * @throws DomainException
2872
-     */
2873
-    public function display_about_admin_page()
2874
-    {
2875
-        $this->_display_admin_page(false, true);
2876
-    }
2877
-
2878
-
2879
-    /**
2880
-     * display_admin_page
2881
-     * contains the code for actually displaying an admin page
2882
-     *
2883
-     * @param boolean $sidebar true with sidebar, false without
2884
-     * @param boolean $about   use the about_admin_wrapper instead of the default.
2885
-     * @return void
2886
-     * @throws DomainException
2887
-     * @throws EE_Error
2888
-     */
2889
-    private function _display_admin_page($sidebar = false, $about = false)
2890
-    {
2891
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2892
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2893
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2894
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2895
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2896
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2897
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2898
-            ? 'poststuff'
2899
-            : 'espresso-default-admin';
2900
-        $template_path                                     = $sidebar
2901
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2902
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2903
-        if ($this->request->isAjax()) {
2904
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2905
-        }
2906
-        $template_path                                     = ! empty($this->_column_template_path)
2907
-            ? $this->_column_template_path : $template_path;
2908
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2909
-            ? $this->_template_args['admin_page_content']
2910
-            : '';
2911
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2912
-            ? $this->_template_args['before_admin_page_content']
2913
-            : '';
2914
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2915
-            ? $this->_template_args['after_admin_page_content']
2916
-            : '';
2917
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2918
-            $template_path,
2919
-            $this->_template_args,
2920
-            true
2921
-        );
2922
-        // the final template wrapper
2923
-        $this->admin_page_wrapper($about);
2924
-    }
2925
-
2926
-
2927
-    /**
2928
-     * This is used to display caf preview pages.
2929
-     *
2930
-     * @param string $utm_campaign_source what is the key used for google analytics link
2931
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2932
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2933
-     * @return void
2934
-     * @throws DomainException
2935
-     * @throws EE_Error
2936
-     * @throws InvalidArgumentException
2937
-     * @throws InvalidDataTypeException
2938
-     * @throws InvalidInterfaceException
2939
-     * @since 4.3.2
2940
-     */
2941
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2942
-    {
2943
-        // let's generate a default preview action button if there isn't one already present.
2944
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2945
-            'Upgrade to Event Espresso 4 Right Now',
2946
-            'event_espresso'
2947
-        );
2948
-        $buy_now_url                                   = add_query_arg(
2949
-            [
2950
-                'ee_ver'       => 'ee4',
2951
-                'utm_source'   => 'ee4_plugin_admin',
2952
-                'utm_medium'   => 'link',
2953
-                'utm_campaign' => $utm_campaign_source,
2954
-                'utm_content'  => 'buy_now_button',
2955
-            ],
2956
-            'https://eventespresso.com/pricing/'
2957
-        );
2958
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2959
-            ? $this->get_action_link_or_button(
2960
-                '',
2961
-                'buy_now',
2962
-                [],
2963
-                'button-primary button-large',
2964
-                esc_url_raw($buy_now_url),
2965
-                true
2966
-            )
2967
-            : $this->_template_args['preview_action_button'];
2968
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2969
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2970
-            $this->_template_args,
2971
-            true
2972
-        );
2973
-        $this->_display_admin_page($display_sidebar);
2974
-    }
2975
-
2976
-
2977
-    /**
2978
-     * display_admin_list_table_page_with_sidebar
2979
-     * generates HTML wrapper for an admin_page with list_table
2980
-     *
2981
-     * @return void
2982
-     * @throws EE_Error
2983
-     * @throws DomainException
2984
-     */
2985
-    public function display_admin_list_table_page_with_sidebar()
2986
-    {
2987
-        $this->_display_admin_list_table_page(true);
2988
-    }
2989
-
2990
-
2991
-    /**
2992
-     * display_admin_list_table_page_with_no_sidebar
2993
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2994
-     *
2995
-     * @return void
2996
-     * @throws EE_Error
2997
-     * @throws DomainException
2998
-     */
2999
-    public function display_admin_list_table_page_with_no_sidebar()
3000
-    {
3001
-        $this->_display_admin_list_table_page();
3002
-    }
3003
-
3004
-
3005
-    /**
3006
-     * generates html wrapper for an admin_list_table page
3007
-     *
3008
-     * @param boolean $sidebar whether to display with sidebar or not.
3009
-     * @return void
3010
-     * @throws DomainException
3011
-     * @throws EE_Error
3012
-     */
3013
-    private function _display_admin_list_table_page($sidebar = false)
3014
-    {
3015
-        // setup search attributes
3016
-        $this->_set_search_attributes();
3017
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
3018
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3019
-        $this->_template_args['table_url']        = $this->request->isAjax()
3020
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3021
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
3022
-        $this->_template_args['list_table']       = $this->_list_table_object;
3023
-        $this->_template_args['current_route']    = $this->_req_action;
3024
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3025
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3026
-        if (! empty($ajax_sorting_callback)) {
3027
-            $sortable_list_table_form_fields = wp_nonce_field(
3028
-                $ajax_sorting_callback . '_nonce',
3029
-                $ajax_sorting_callback . '_nonce',
3030
-                false,
3031
-                false
3032
-            );
3033
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3034
-                                                . $this->page_slug
3035
-                                                . '" />';
3036
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3037
-                                                . $ajax_sorting_callback
3038
-                                                . '" />';
3039
-        } else {
3040
-            $sortable_list_table_form_fields = '';
3041
-        }
3042
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3043
-        $hidden_form_fields                                      =
3044
-            isset($this->_template_args['list_table_hidden_fields'])
3045
-                ? $this->_template_args['list_table_hidden_fields']
3046
-                : '';
3047
-        $nonce_ref                                               = $this->_req_action . '_nonce';
3048
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
3049
-                                                                    . $nonce_ref
3050
-                                                                    . '" value="'
3051
-                                                                    . wp_create_nonce($nonce_ref)
3052
-                                                                    . '">';
3053
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3054
-        // display message about search results?
3055
-        $search = $this->request->getRequestParam('s');
3056
-        $this->_template_args['before_list_table'] .= ! empty($search)
3057
-            ? '<p class="ee-search-results">' . sprintf(
3058
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3059
-                trim($search, '%')
3060
-            ) . '</p>'
3061
-            : '';
3062
-        // filter before_list_table template arg
3063
-        $this->_template_args['before_list_table'] = apply_filters(
3064
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3065
-            $this->_template_args['before_list_table'],
3066
-            $this->page_slug,
3067
-            $this->request->requestParams(),
3068
-            $this->_req_action
3069
-        );
3070
-        // convert to array and filter again
3071
-        // arrays are easier to inject new items in a specific location,
3072
-        // but would not be backwards compatible, so we have to add a new filter
3073
-        $this->_template_args['before_list_table'] = implode(
3074
-            " \n",
3075
-            (array) apply_filters(
3076
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3077
-                (array) $this->_template_args['before_list_table'],
3078
-                $this->page_slug,
3079
-                $this->request->requestParams(),
3080
-                $this->_req_action
3081
-            )
3082
-        );
3083
-        // filter after_list_table template arg
3084
-        $this->_template_args['after_list_table'] = apply_filters(
3085
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3086
-            $this->_template_args['after_list_table'],
3087
-            $this->page_slug,
3088
-            $this->request->requestParams(),
3089
-            $this->_req_action
3090
-        );
3091
-        // convert to array and filter again
3092
-        // arrays are easier to inject new items in a specific location,
3093
-        // but would not be backwards compatible, so we have to add a new filter
3094
-        $this->_template_args['after_list_table']   = implode(
3095
-            " \n",
3096
-            (array) apply_filters(
3097
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3098
-                (array) $this->_template_args['after_list_table'],
3099
-                $this->page_slug,
3100
-                $this->request->requestParams(),
3101
-                $this->_req_action
3102
-            )
3103
-        );
3104
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3105
-            $template_path,
3106
-            $this->_template_args,
3107
-            true
3108
-        );
3109
-        // the final template wrapper
3110
-        if ($sidebar) {
3111
-            $this->display_admin_page_with_sidebar();
3112
-        } else {
3113
-            $this->display_admin_page_with_no_sidebar();
3114
-        }
3115
-    }
3116
-
3117
-
3118
-    /**
3119
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3120
-     * html string for the legend.
3121
-     * $items are expected in an array in the following format:
3122
-     * $legend_items = array(
3123
-     *        'item_id' => array(
3124
-     *            'icon' => 'http://url_to_icon_being_described.png',
3125
-     *            'desc' => esc_html__('localized description of item');
3126
-     *        )
3127
-     * );
3128
-     *
3129
-     * @param array $items see above for format of array
3130
-     * @return string html string of legend
3131
-     * @throws DomainException
3132
-     */
3133
-    protected function _display_legend($items)
3134
-    {
3135
-        $this->_template_args['items'] = apply_filters(
3136
-            'FHEE__EE_Admin_Page___display_legend__items',
3137
-            (array) $items,
3138
-            $this
3139
-        );
3140
-        return EEH_Template::display_template(
3141
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3142
-            $this->_template_args,
3143
-            true
3144
-        );
3145
-    }
3146
-
3147
-
3148
-    /**
3149
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3150
-     * The returned json object is created from an array in the following format:
3151
-     * array(
3152
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3153
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3154
-     *  'notices' => '', // - contains any EE_Error formatted notices
3155
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3156
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3157
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3158
-     *  that might be included in here)
3159
-     * )
3160
-     * The json object is populated by whatever is set in the $_template_args property.
3161
-     *
3162
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3163
-     *                                 instead of displayed.
3164
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3165
-     * @return void
3166
-     * @throws EE_Error
3167
-     */
3168
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
3169
-    {
3170
-        // make sure any EE_Error notices have been handled.
3171
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3172
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3173
-        unset($this->_template_args['data']);
3174
-        $json = [
3175
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3176
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3177
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3178
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3179
-            'notices'   => EE_Error::get_notices(),
3180
-            'content'   => isset($this->_template_args['admin_page_content'])
3181
-                ? $this->_template_args['admin_page_content'] : '',
3182
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3183
-            'isEEajax'  => true
3184
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3185
-        ];
3186
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3187
-        if (null === error_get_last() || ! headers_sent()) {
3188
-            header('Content-Type: application/json; charset=UTF-8');
3189
-        }
3190
-        echo wp_json_encode($json);
3191
-        exit();
3192
-    }
3193
-
3194
-
3195
-    /**
3196
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3197
-     *
3198
-     * @return void
3199
-     * @throws EE_Error
3200
-     */
3201
-    public function return_json()
3202
-    {
3203
-        if ($this->request->isAjax()) {
3204
-            $this->_return_json();
3205
-        } else {
3206
-            throw new EE_Error(
3207
-                sprintf(
3208
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3209
-                    __FUNCTION__
3210
-                )
3211
-            );
3212
-        }
3213
-    }
3214
-
3215
-
3216
-    /**
3217
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3218
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3219
-     *
3220
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3221
-     */
3222
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3223
-    {
3224
-        $this->_hook_obj = $hook_obj;
3225
-    }
3226
-
3227
-
3228
-    /**
3229
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3230
-     *
3231
-     * @param boolean $about whether to use the special about page wrapper or default.
3232
-     * @return void
3233
-     * @throws DomainException
3234
-     * @throws EE_Error
3235
-     */
3236
-    public function admin_page_wrapper($about = false)
3237
-    {
3238
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3239
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3240
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3241
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3242
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3243
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3244
-            isset($this->_template_args['before_admin_page_content'])
3245
-                ? $this->_template_args['before_admin_page_content']
3246
-                : ''
3247
-        );
3248
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3249
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3250
-            isset($this->_template_args['after_admin_page_content'])
3251
-                ? $this->_template_args['after_admin_page_content']
3252
-                : ''
3253
-        );
3254
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3255
-        // load settings page wrapper template
3256
-        $template_path = ! $this->request->isAjax()
3257
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3258
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
3259
-        // about page?
3260
-        $template_path = $about
3261
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3262
-            : $template_path;
3263
-        if ($this->request->isAjax()) {
3264
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3265
-                $template_path,
3266
-                $this->_template_args,
3267
-                true
3268
-            );
3269
-            $this->_return_json();
3270
-        } else {
3271
-            EEH_Template::display_template($template_path, $this->_template_args);
3272
-        }
3273
-    }
3274
-
3275
-
3276
-    /**
3277
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3278
-     *
3279
-     * @return string html
3280
-     * @throws EE_Error
3281
-     */
3282
-    protected function _get_main_nav_tabs()
3283
-    {
3284
-        // let's generate the html using the EEH_Tabbed_Content helper.
3285
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3286
-        // (rather than setting in the page_routes array)
3287
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3288
-    }
3289
-
3290
-
3291
-    /**
3292
-     *        sort nav tabs
3293
-     *
3294
-     * @param $a
3295
-     * @param $b
3296
-     * @return int
3297
-     */
3298
-    private function _sort_nav_tabs($a, $b)
3299
-    {
3300
-        if ($a['order'] === $b['order']) {
3301
-            return 0;
3302
-        }
3303
-        return ($a['order'] < $b['order']) ? -1 : 1;
3304
-    }
3305
-
3306
-
3307
-    /**
3308
-     *    generates HTML for the forms used on admin pages
3309
-     *
3310
-     * @param array  $input_vars   - array of input field details
3311
-     * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3312
-     *                             use)
3313
-     * @param bool   $id
3314
-     * @return string
3315
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3316
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3317
-     */
3318
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3319
-    {
3320
-        return $generator === 'string'
3321
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3322
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3323
-    }
3324
-
3325
-
3326
-    /**
3327
-     * generates the "Save" and "Save & Close" buttons for edit forms
3328
-     *
3329
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3330
-     *                                   Close" button.
3331
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3332
-     *                                   'Save', [1] => 'save & close')
3333
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3334
-     *                                   via the "name" value in the button).  We can also use this to just dump
3335
-     *                                   default actions by submitting some other value.
3336
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3337
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3338
-     *                                   close (normal form handling).
3339
-     */
3340
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3341
-    {
3342
-        // make sure $text and $actions are in an array
3343
-        $text          = (array) $text;
3344
-        $actions       = (array) $actions;
3345
-        $referrer_url  = empty($referrer)
3346
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3347
-              . $this->request->getServerParam('REQUEST_URI')
3348
-              . '" />'
3349
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3350
-              . $referrer
3351
-              . '" />';
3352
-        $button_text   = ! empty($text)
3353
-            ? $text
3354
-            : [
3355
-                esc_html__('Save', 'event_espresso'),
3356
-                esc_html__('Save and Close', 'event_espresso'),
3357
-            ];
3358
-        $default_names = ['save', 'save_and_close'];
3359
-        // add in a hidden index for the current page (so save and close redirects properly)
3360
-        $this->_template_args['save_buttons'] = $referrer_url;
3361
-        foreach ($button_text as $key => $button) {
3362
-            $ref                                  = $default_names[ $key ];
3363
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3364
-                                                     . $ref
3365
-                                                     . '" value="'
3366
-                                                     . $button
3367
-                                                     . '" name="'
3368
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3369
-                                                     . '" id="'
3370
-                                                     . $this->_current_view . '_' . $ref
3371
-                                                     . '" />';
3372
-            if (! $both) {
3373
-                break;
3374
-            }
3375
-        }
3376
-    }
3377
-
3378
-
3379
-    /**
3380
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3381
-     *
3382
-     * @param string $route
3383
-     * @param array  $additional_hidden_fields
3384
-     * @see   $this->_set_add_edit_form_tags() for details on params
3385
-     * @since 4.6.0
3386
-     */
3387
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3388
-    {
3389
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3390
-    }
3391
-
3392
-
3393
-    /**
3394
-     * set form open and close tags on add/edit pages.
3395
-     *
3396
-     * @param string $route                    the route you want the form to direct to
3397
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3398
-     * @return void
3399
-     */
3400
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3401
-    {
3402
-        if (empty($route)) {
3403
-            $user_msg = esc_html__(
3404
-                'An error occurred. No action was set for this page\'s form.',
3405
-                'event_espresso'
3406
-            );
3407
-            $dev_msg  = $user_msg . "\n"
3408
-                        . sprintf(
3409
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3410
-                            __FUNCTION__,
3411
-                            __CLASS__
3412
-                        );
3413
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3414
-        }
3415
-        // open form
3416
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3417
-                                                             . $this->_admin_base_url
3418
-                                                             . '" id="'
3419
-                                                             . $route
3420
-                                                             . '_event_form" >';
3421
-        // add nonce
3422
-        $nonce                                             =
3423
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3424
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3425
-        // add REQUIRED form action
3426
-        $hidden_fields = [
3427
-            'action' => ['type' => 'hidden', 'value' => $route],
3428
-        ];
3429
-        // merge arrays
3430
-        $hidden_fields = is_array($additional_hidden_fields)
3431
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3432
-            : $hidden_fields;
3433
-        // generate form fields
3434
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3435
-        // add fields to form
3436
-        foreach ((array) $form_fields as $field_name => $form_field) {
3437
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3438
-        }
3439
-        // close form
3440
-        $this->_template_args['after_admin_page_content'] = '</form>';
3441
-    }
3442
-
3443
-
3444
-    /**
3445
-     * Public Wrapper for _redirect_after_action() method since its
3446
-     * discovered it would be useful for external code to have access.
3447
-     *
3448
-     * @param bool   $success
3449
-     * @param string $what
3450
-     * @param string $action_desc
3451
-     * @param array  $query_args
3452
-     * @param bool   $override_overwrite
3453
-     * @throws EE_Error
3454
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3455
-     * @since 4.5.0
3456
-     */
3457
-    public function redirect_after_action(
3458
-        $success = false,
3459
-        $what = 'item',
3460
-        $action_desc = 'processed',
3461
-        $query_args = [],
3462
-        $override_overwrite = false
3463
-    ) {
3464
-        $this->_redirect_after_action(
3465
-            $success,
3466
-            $what,
3467
-            $action_desc,
3468
-            $query_args,
3469
-            $override_overwrite
3470
-        );
3471
-    }
3472
-
3473
-
3474
-    /**
3475
-     * Helper method for merging existing request data with the returned redirect url.
3476
-     *
3477
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3478
-     * filters are still applied.
3479
-     *
3480
-     * @param array $new_route_data
3481
-     * @return array
3482
-     */
3483
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3484
-    {
3485
-        foreach ($this->request->requestParams() as $ref => $value) {
3486
-            // unset nonces
3487
-            if (strpos($ref, 'nonce') !== false) {
3488
-                $this->request->unSetRequestParam($ref);
3489
-                continue;
3490
-            }
3491
-            // urlencode values.
3492
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3493
-            $this->request->setRequestParam($ref, $value);
3494
-        }
3495
-        return array_merge($this->request->requestParams(), $new_route_data);
3496
-    }
3497
-
3498
-
3499
-    /**
3500
-     *    _redirect_after_action
3501
-     *
3502
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3503
-     * @param string $what               - what the action was performed on
3504
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3505
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3506
-     *                                   action is completed
3507
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3508
-     *                                   override this so that they show.
3509
-     * @return void
3510
-     * @throws EE_Error
3511
-     */
3512
-    protected function _redirect_after_action(
3513
-        $success = 0,
3514
-        $what = 'item',
3515
-        $action_desc = 'processed',
3516
-        $query_args = [],
3517
-        $override_overwrite = false
3518
-    ) {
3519
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3520
-        // class name for actions/filters.
3521
-        $classname = get_class($this);
3522
-        // set redirect url.
3523
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3524
-        // otherwise we go with whatever is set as the _admin_base_url
3525
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3526
-        $notices      = EE_Error::get_notices(false);
3527
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3528
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3529
-            EE_Error::overwrite_success();
3530
-        }
3531
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3532
-            // how many records affected ? more than one record ? or just one ?
3533
-            if ($success > 1) {
3534
-                // set plural msg
3535
-                EE_Error::add_success(
3536
-                    sprintf(
3537
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3538
-                        $what,
3539
-                        $action_desc
3540
-                    ),
3541
-                    __FILE__,
3542
-                    __FUNCTION__,
3543
-                    __LINE__
3544
-                );
3545
-            } elseif ($success === 1) {
3546
-                // set singular msg
3547
-                EE_Error::add_success(
3548
-                    sprintf(
3549
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3550
-                        $what,
3551
-                        $action_desc
3552
-                    ),
3553
-                    __FILE__,
3554
-                    __FUNCTION__,
3555
-                    __LINE__
3556
-                );
3557
-            }
3558
-        }
3559
-        // check that $query_args isn't something crazy
3560
-        if (! is_array($query_args)) {
3561
-            $query_args = [];
3562
-        }
3563
-        /**
3564
-         * Allow injecting actions before the query_args are modified for possible different
3565
-         * redirections on save and close actions
3566
-         *
3567
-         * @param array $query_args       The original query_args array coming into the
3568
-         *                                method.
3569
-         * @since 4.2.0
3570
-         */
3571
-        do_action(
3572
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3573
-            $query_args
3574
-        );
3575
-        // calculate where we're going (if we have a "save and close" button pushed)
3576
-
3577
-        if (
3578
-            $this->request->requestParamIsSet('save_and_close')
3579
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3580
-        ) {
3581
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3582
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3583
-            // regenerate query args array from referrer URL
3584
-            parse_str($parsed_url['query'], $query_args);
3585
-            // correct page and action will be in the query args now
3586
-            $redirect_url = admin_url('admin.php');
3587
-        }
3588
-        // merge any default query_args set in _default_route_query_args property
3589
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3590
-            $args_to_merge = [];
3591
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3592
-                // is there a wp_referer array in our _default_route_query_args property?
3593
-                if ($query_param === 'wp_referer') {
3594
-                    $query_value = (array) $query_value;
3595
-                    foreach ($query_value as $reference => $value) {
3596
-                        if (strpos($reference, 'nonce') !== false) {
3597
-                            continue;
3598
-                        }
3599
-                        // finally we will override any arguments in the referer with
3600
-                        // what might be set on the _default_route_query_args array.
3601
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3602
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3603
-                        } else {
3604
-                            $args_to_merge[ $reference ] = urlencode($value);
3605
-                        }
3606
-                    }
3607
-                    continue;
3608
-                }
3609
-                $args_to_merge[ $query_param ] = $query_value;
3610
-            }
3611
-            // now let's merge these arguments but override with what was specifically sent in to the
3612
-            // redirect.
3613
-            $query_args = array_merge($args_to_merge, $query_args);
3614
-        }
3615
-        $this->_process_notices($query_args);
3616
-        // generate redirect url
3617
-        // if redirecting to anything other than the main page, add a nonce
3618
-        if (isset($query_args['action'])) {
3619
-            // manually generate wp_nonce and merge that with the query vars
3620
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3621
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3622
-        }
3623
-        // we're adding some hooks and filters in here for processing any things just before redirects
3624
-        // (example: an admin page has done an insert or update and we want to run something after that).
3625
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3626
-        $redirect_url = apply_filters(
3627
-            'FHEE_redirect_' . $classname . $this->_req_action,
3628
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3629
-            $query_args
3630
-        );
3631
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3632
-        if ($this->request->isAjax()) {
3633
-            $default_data                    = [
3634
-                'close'        => true,
3635
-                'redirect_url' => $redirect_url,
3636
-                'where'        => 'main',
3637
-                'what'         => 'append',
3638
-            ];
3639
-            $this->_template_args['success'] = $success;
3640
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3641
-                $default_data,
3642
-                $this->_template_args['data']
3643
-            ) : $default_data;
3644
-            $this->_return_json();
3645
-        }
3646
-        wp_safe_redirect($redirect_url);
3647
-        exit();
3648
-    }
3649
-
3650
-
3651
-    /**
3652
-     * process any notices before redirecting (or returning ajax request)
3653
-     * This method sets the $this->_template_args['notices'] attribute;
3654
-     *
3655
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3656
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3657
-     *                                  page_routes haven't been defined yet.
3658
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3659
-     *                                  still save a transient for the notice.
3660
-     * @return void
3661
-     * @throws EE_Error
3662
-     */
3663
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3664
-    {
3665
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3666
-        if ($this->request->isAjax()) {
3667
-            $notices = EE_Error::get_notices(false);
3668
-            if (empty($this->_template_args['success'])) {
3669
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3670
-            }
3671
-            if (empty($this->_template_args['errors'])) {
3672
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3673
-            }
3674
-            if (empty($this->_template_args['attention'])) {
3675
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3676
-            }
3677
-        }
3678
-        $this->_template_args['notices'] = EE_Error::get_notices();
3679
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3680
-        if (! $this->request->isAjax() || $sticky_notices) {
3681
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3682
-            $this->_add_transient(
3683
-                $route,
3684
-                $this->_template_args['notices'],
3685
-                true,
3686
-                $skip_route_verify
3687
-            );
3688
-        }
3689
-    }
3690
-
3691
-
3692
-    /**
3693
-     * get_action_link_or_button
3694
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3695
-     *
3696
-     * @param string $action        use this to indicate which action the url is generated with.
3697
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3698
-     *                              property.
3699
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3700
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3701
-     * @param string $base_url      If this is not provided
3702
-     *                              the _admin_base_url will be used as the default for the button base_url.
3703
-     *                              Otherwise this value will be used.
3704
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3705
-     * @return string
3706
-     * @throws InvalidArgumentException
3707
-     * @throws InvalidInterfaceException
3708
-     * @throws InvalidDataTypeException
3709
-     * @throws EE_Error
3710
-     */
3711
-    public function get_action_link_or_button(
3712
-        $action,
3713
-        $type = 'add',
3714
-        $extra_request = [],
3715
-        $class = 'button-primary',
3716
-        $base_url = '',
3717
-        $exclude_nonce = false
3718
-    ) {
3719
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3720
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3721
-            throw new EE_Error(
3722
-                sprintf(
3723
-                    esc_html__(
3724
-                        'There is no page route for given action for the button.  This action was given: %s',
3725
-                        'event_espresso'
3726
-                    ),
3727
-                    $action
3728
-                )
3729
-            );
3730
-        }
3731
-        if (! isset($this->_labels['buttons'][ $type ])) {
3732
-            throw new EE_Error(
3733
-                sprintf(
3734
-                    esc_html__(
3735
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3736
-                        'event_espresso'
3737
-                    ),
3738
-                    $type
3739
-                )
3740
-            );
3741
-        }
3742
-        // finally check user access for this button.
3743
-        $has_access = $this->check_user_access($action, true);
3744
-        if (! $has_access) {
3745
-            return '';
3746
-        }
3747
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3748
-        $query_args = [
3749
-            'action' => $action,
3750
-        ];
3751
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3752
-        if (! empty($extra_request)) {
3753
-            $query_args = array_merge($extra_request, $query_args);
3754
-        }
3755
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3756
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3757
-    }
3758
-
3759
-
3760
-    /**
3761
-     * _per_page_screen_option
3762
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3763
-     *
3764
-     * @return void
3765
-     * @throws InvalidArgumentException
3766
-     * @throws InvalidInterfaceException
3767
-     * @throws InvalidDataTypeException
3768
-     */
3769
-    protected function _per_page_screen_option()
3770
-    {
3771
-        $option = 'per_page';
3772
-        $args   = [
3773
-            'label'   => apply_filters(
3774
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3775
-                $this->_admin_page_title,
3776
-                $this
3777
-            ),
3778
-            'default' => (int) apply_filters(
3779
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3780
-                20
3781
-            ),
3782
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3783
-        ];
3784
-        // ONLY add the screen option if the user has access to it.
3785
-        if ($this->check_user_access($this->_current_view, true)) {
3786
-            add_screen_option($option, $args);
3787
-        }
3788
-    }
3789
-
3790
-
3791
-    /**
3792
-     * set_per_page_screen_option
3793
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3794
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3795
-     * admin_menu.
3796
-     *
3797
-     * @return void
3798
-     */
3799
-    private function _set_per_page_screen_options()
3800
-    {
3801
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3802
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3803
-            if (! $user = wp_get_current_user()) {
3804
-                return;
3805
-            }
3806
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3807
-            if (! $option) {
3808
-                return;
3809
-            }
3810
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3811
-            $map_option = $option;
3812
-            $option     = str_replace('-', '_', $option);
3813
-            switch ($map_option) {
3814
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3815
-                    $max_value = apply_filters(
3816
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3817
-                        999,
3818
-                        $this->_current_page,
3819
-                        $this->_current_view
3820
-                    );
3821
-                    if ($value < 1) {
3822
-                        return;
3823
-                    }
3824
-                    $value = min($value, $max_value);
3825
-                    break;
3826
-                default:
3827
-                    $value = apply_filters(
3828
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3829
-                        false,
3830
-                        $option,
3831
-                        $value
3832
-                    );
3833
-                    if (false === $value) {
3834
-                        return;
3835
-                    }
3836
-                    break;
3837
-            }
3838
-            update_user_meta($user->ID, $option, $value);
3839
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3840
-            exit;
3841
-        }
3842
-    }
3843
-
3844
-
3845
-    /**
3846
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3847
-     *
3848
-     * @param array $data array that will be assigned to template args.
3849
-     */
3850
-    public function set_template_args($data)
3851
-    {
3852
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3853
-    }
3854
-
3855
-
3856
-    /**
3857
-     * This makes available the WP transient system for temporarily moving data between routes
3858
-     *
3859
-     * @param string $route             the route that should receive the transient
3860
-     * @param array  $data              the data that gets sent
3861
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3862
-     *                                  normal route transient.
3863
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3864
-     *                                  when we are adding a transient before page_routes have been defined.
3865
-     * @return void
3866
-     * @throws EE_Error
3867
-     */
3868
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3869
-    {
3870
-        $user_id = get_current_user_id();
3871
-        if (! $skip_route_verify) {
3872
-            $this->_verify_route($route);
3873
-        }
3874
-        // now let's set the string for what kind of transient we're setting
3875
-        $transient = $notices
3876
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3877
-            : 'rte_tx_' . $route . '_' . $user_id;
3878
-        $data      = $notices ? ['notices' => $data] : $data;
3879
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3880
-        $existing = is_multisite() && is_network_admin()
3881
-            ? get_site_transient($transient)
3882
-            : get_transient($transient);
3883
-        if ($existing) {
3884
-            $data = array_merge((array) $data, (array) $existing);
3885
-        }
3886
-        if (is_multisite() && is_network_admin()) {
3887
-            set_site_transient($transient, $data, 8);
3888
-        } else {
3889
-            set_transient($transient, $data, 8);
3890
-        }
3891
-    }
3892
-
3893
-
3894
-    /**
3895
-     * this retrieves the temporary transient that has been set for moving data between routes.
3896
-     *
3897
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3898
-     * @param string $route
3899
-     * @return mixed data
3900
-     */
3901
-    protected function _get_transient($notices = false, $route = '')
3902
-    {
3903
-        $user_id   = get_current_user_id();
3904
-        $route     = ! $route ? $this->_req_action : $route;
3905
-        $transient = $notices
3906
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3907
-            : 'rte_tx_' . $route . '_' . $user_id;
3908
-        $data      = is_multisite() && is_network_admin()
3909
-            ? get_site_transient($transient)
3910
-            : get_transient($transient);
3911
-        // delete transient after retrieval (just in case it hasn't expired);
3912
-        if (is_multisite() && is_network_admin()) {
3913
-            delete_site_transient($transient);
3914
-        } else {
3915
-            delete_transient($transient);
3916
-        }
3917
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3918
-    }
3919
-
3920
-
3921
-    /**
3922
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3923
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3924
-     * default route callback on the EE_Admin page you want it run.)
3925
-     *
3926
-     * @return void
3927
-     */
3928
-    protected function _transient_garbage_collection()
3929
-    {
3930
-        global $wpdb;
3931
-        // retrieve all existing transients
3932
-        $query =
3933
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3934
-        if ($results = $wpdb->get_results($query)) {
3935
-            foreach ($results as $result) {
3936
-                $transient = str_replace('_transient_', '', $result->option_name);
3937
-                get_transient($transient);
3938
-                if (is_multisite() && is_network_admin()) {
3939
-                    get_site_transient($transient);
3940
-                }
3941
-            }
3942
-        }
3943
-    }
3944
-
3945
-
3946
-    /**
3947
-     * get_view
3948
-     *
3949
-     * @return string content of _view property
3950
-     */
3951
-    public function get_view()
3952
-    {
3953
-        return $this->_view;
3954
-    }
3955
-
3956
-
3957
-    /**
3958
-     * getter for the protected $_views property
3959
-     *
3960
-     * @return array
3961
-     */
3962
-    public function get_views()
3963
-    {
3964
-        return $this->_views;
3965
-    }
3966
-
3967
-
3968
-    /**
3969
-     * get_current_page
3970
-     *
3971
-     * @return string _current_page property value
3972
-     */
3973
-    public function get_current_page()
3974
-    {
3975
-        return $this->_current_page;
3976
-    }
3977
-
3978
-
3979
-    /**
3980
-     * get_current_view
3981
-     *
3982
-     * @return string _current_view property value
3983
-     */
3984
-    public function get_current_view()
3985
-    {
3986
-        return $this->_current_view;
3987
-    }
3988
-
3989
-
3990
-    /**
3991
-     * get_current_screen
3992
-     *
3993
-     * @return object The current WP_Screen object
3994
-     */
3995
-    public function get_current_screen()
3996
-    {
3997
-        return $this->_current_screen;
3998
-    }
3999
-
4000
-
4001
-    /**
4002
-     * get_current_page_view_url
4003
-     *
4004
-     * @return string This returns the url for the current_page_view.
4005
-     */
4006
-    public function get_current_page_view_url()
4007
-    {
4008
-        return $this->_current_page_view_url;
4009
-    }
4010
-
4011
-
4012
-    /**
4013
-     * just returns the Request
4014
-     *
4015
-     * @return RequestInterface
4016
-     */
4017
-    public function get_request()
4018
-    {
4019
-        return $this->request;
4020
-    }
4021
-
4022
-
4023
-    /**
4024
-     * just returns the _req_data property
4025
-     *
4026
-     * @return array
4027
-     */
4028
-    public function get_request_data()
4029
-    {
4030
-        return $this->request->requestParams();
4031
-    }
4032
-
4033
-
4034
-    /**
4035
-     * returns the _req_data protected property
4036
-     *
4037
-     * @return string
4038
-     */
4039
-    public function get_req_action()
4040
-    {
4041
-        return $this->_req_action;
4042
-    }
4043
-
4044
-
4045
-    /**
4046
-     * @return bool  value of $_is_caf property
4047
-     */
4048
-    public function is_caf()
4049
-    {
4050
-        return $this->_is_caf;
4051
-    }
4052
-
4053
-
4054
-    /**
4055
-     * @return mixed
4056
-     */
4057
-    public function default_espresso_metaboxes()
4058
-    {
4059
-        return $this->_default_espresso_metaboxes;
4060
-    }
4061
-
4062
-
4063
-    /**
4064
-     * @return mixed
4065
-     */
4066
-    public function admin_base_url()
4067
-    {
4068
-        return $this->_admin_base_url;
4069
-    }
4070
-
4071
-
4072
-    /**
4073
-     * @return mixed
4074
-     */
4075
-    public function wp_page_slug()
4076
-    {
4077
-        return $this->_wp_page_slug;
4078
-    }
4079
-
4080
-
4081
-    /**
4082
-     * updates  espresso configuration settings
4083
-     *
4084
-     * @param string                   $tab
4085
-     * @param EE_Config_Base|EE_Config $config
4086
-     * @param string                   $file file where error occurred
4087
-     * @param string                   $func function  where error occurred
4088
-     * @param string                   $line line no where error occurred
4089
-     * @return boolean
4090
-     */
4091
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4092
-    {
4093
-        // remove any options that are NOT going to be saved with the config settings.
4094
-        if (isset($config->core->ee_ueip_optin)) {
4095
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4096
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4097
-            update_option('ee_ueip_has_notified', true);
4098
-        }
4099
-        // and save it (note we're also doing the network save here)
4100
-        $net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4101
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4102
-        if ($config_saved && $net_saved) {
4103
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4104
-            return true;
4105
-        }
4106
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4107
-        return false;
4108
-    }
4109
-
4110
-
4111
-    /**
4112
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4113
-     *
4114
-     * @return array
4115
-     */
4116
-    public function get_yes_no_values()
4117
-    {
4118
-        return $this->_yes_no_values;
4119
-    }
4120
-
4121
-
4122
-    protected function _get_dir()
4123
-    {
4124
-        $reflector = new ReflectionClass(get_class($this));
4125
-        return dirname($reflector->getFileName());
4126
-    }
4127
-
4128
-
4129
-    /**
4130
-     * A helper for getting a "next link".
4131
-     *
4132
-     * @param string $url   The url to link to
4133
-     * @param string $class The class to use.
4134
-     * @return string
4135
-     */
4136
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4137
-    {
4138
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4139
-    }
4140
-
4141
-
4142
-    /**
4143
-     * A helper for getting a "previous link".
4144
-     *
4145
-     * @param string $url   The url to link to
4146
-     * @param string $class The class to use.
4147
-     * @return string
4148
-     */
4149
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4150
-    {
4151
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4152
-    }
4153
-
4154
-
4155
-
4156
-
4157
-
4158
-
4159
-
4160
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4161
-
4162
-
4163
-    /**
4164
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4165
-     * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4166
-     * _req_data array.
4167
-     *
4168
-     * @return bool success/fail
4169
-     * @throws EE_Error
4170
-     * @throws InvalidArgumentException
4171
-     * @throws ReflectionException
4172
-     * @throws InvalidDataTypeException
4173
-     * @throws InvalidInterfaceException
4174
-     */
4175
-    protected function _process_resend_registration()
4176
-    {
4177
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4178
-        do_action(
4179
-            'AHEE__EE_Admin_Page___process_resend_registration',
4180
-            $this->_template_args['success'],
4181
-            $this->request->requestParams()
4182
-        );
4183
-        return $this->_template_args['success'];
4184
-    }
4185
-
4186
-
4187
-    /**
4188
-     * This automatically processes any payment message notifications when manual payment has been applied.
4189
-     *
4190
-     * @param EE_Payment $payment
4191
-     * @return bool success/fail
4192
-     */
4193
-    protected function _process_payment_notification(EE_Payment $payment)
4194
-    {
4195
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4196
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4197
-        $this->_template_args['success'] = apply_filters(
4198
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4199
-            false,
4200
-            $payment
4201
-        );
4202
-        return $this->_template_args['success'];
4203
-    }
2764
+	}
2765
+
2766
+
2767
+	/**
2768
+	 * facade for add_meta_box
2769
+	 *
2770
+	 * @param string  $action        where the metabox get's displayed
2771
+	 * @param string  $title         Title of Metabox (output in metabox header)
2772
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2773
+	 *                               instead of the one created in here.
2774
+	 * @param array   $callback_args an array of args supplied for the metabox
2775
+	 * @param string  $column        what metabox column
2776
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2777
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2778
+	 *                               created but just set our own callback for wp's add_meta_box.
2779
+	 * @throws DomainException
2780
+	 */
2781
+	public function _add_admin_page_meta_box(
2782
+		$action,
2783
+		$title,
2784
+		$callback,
2785
+		$callback_args,
2786
+		$column = 'normal',
2787
+		$priority = 'high',
2788
+		$create_func = true
2789
+	) {
2790
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2791
+		// if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2792
+		if (empty($callback_args) && $create_func) {
2793
+			$callback_args = [
2794
+				'template_path' => $this->_template_path,
2795
+				'template_args' => $this->_template_args,
2796
+			];
2797
+		}
2798
+		// if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2799
+		$call_back_func = $create_func
2800
+			? function ($post, $metabox) {
2801
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2802
+				echo EEH_Template::display_template(
2803
+					$metabox['args']['template_path'],
2804
+					$metabox['args']['template_args'],
2805
+					true
2806
+				);
2807
+			}
2808
+			: $callback;
2809
+		add_meta_box(
2810
+			str_replace('_', '-', $action) . '-mbox',
2811
+			$title,
2812
+			$call_back_func,
2813
+			$this->_wp_page_slug,
2814
+			$column,
2815
+			$priority,
2816
+			$callback_args
2817
+		);
2818
+	}
2819
+
2820
+
2821
+	/**
2822
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2823
+	 *
2824
+	 * @throws DomainException
2825
+	 * @throws EE_Error
2826
+	 */
2827
+	public function display_admin_page_with_metabox_columns()
2828
+	{
2829
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2830
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2831
+			$this->_column_template_path,
2832
+			$this->_template_args,
2833
+			true
2834
+		);
2835
+		// the final wrapper
2836
+		$this->admin_page_wrapper();
2837
+	}
2838
+
2839
+
2840
+	/**
2841
+	 * generates  HTML wrapper for an admin details page
2842
+	 *
2843
+	 * @return void
2844
+	 * @throws EE_Error
2845
+	 * @throws DomainException
2846
+	 */
2847
+	public function display_admin_page_with_sidebar()
2848
+	{
2849
+		$this->_display_admin_page(true);
2850
+	}
2851
+
2852
+
2853
+	/**
2854
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2855
+	 *
2856
+	 * @return void
2857
+	 * @throws EE_Error
2858
+	 * @throws DomainException
2859
+	 */
2860
+	public function display_admin_page_with_no_sidebar()
2861
+	{
2862
+		$this->_display_admin_page();
2863
+	}
2864
+
2865
+
2866
+	/**
2867
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2868
+	 *
2869
+	 * @return void
2870
+	 * @throws EE_Error
2871
+	 * @throws DomainException
2872
+	 */
2873
+	public function display_about_admin_page()
2874
+	{
2875
+		$this->_display_admin_page(false, true);
2876
+	}
2877
+
2878
+
2879
+	/**
2880
+	 * display_admin_page
2881
+	 * contains the code for actually displaying an admin page
2882
+	 *
2883
+	 * @param boolean $sidebar true with sidebar, false without
2884
+	 * @param boolean $about   use the about_admin_wrapper instead of the default.
2885
+	 * @return void
2886
+	 * @throws DomainException
2887
+	 * @throws EE_Error
2888
+	 */
2889
+	private function _display_admin_page($sidebar = false, $about = false)
2890
+	{
2891
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2892
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2893
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2894
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2895
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2896
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2897
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2898
+			? 'poststuff'
2899
+			: 'espresso-default-admin';
2900
+		$template_path                                     = $sidebar
2901
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2902
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2903
+		if ($this->request->isAjax()) {
2904
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2905
+		}
2906
+		$template_path                                     = ! empty($this->_column_template_path)
2907
+			? $this->_column_template_path : $template_path;
2908
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2909
+			? $this->_template_args['admin_page_content']
2910
+			: '';
2911
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2912
+			? $this->_template_args['before_admin_page_content']
2913
+			: '';
2914
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2915
+			? $this->_template_args['after_admin_page_content']
2916
+			: '';
2917
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2918
+			$template_path,
2919
+			$this->_template_args,
2920
+			true
2921
+		);
2922
+		// the final template wrapper
2923
+		$this->admin_page_wrapper($about);
2924
+	}
2925
+
2926
+
2927
+	/**
2928
+	 * This is used to display caf preview pages.
2929
+	 *
2930
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2931
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2932
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2933
+	 * @return void
2934
+	 * @throws DomainException
2935
+	 * @throws EE_Error
2936
+	 * @throws InvalidArgumentException
2937
+	 * @throws InvalidDataTypeException
2938
+	 * @throws InvalidInterfaceException
2939
+	 * @since 4.3.2
2940
+	 */
2941
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2942
+	{
2943
+		// let's generate a default preview action button if there isn't one already present.
2944
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2945
+			'Upgrade to Event Espresso 4 Right Now',
2946
+			'event_espresso'
2947
+		);
2948
+		$buy_now_url                                   = add_query_arg(
2949
+			[
2950
+				'ee_ver'       => 'ee4',
2951
+				'utm_source'   => 'ee4_plugin_admin',
2952
+				'utm_medium'   => 'link',
2953
+				'utm_campaign' => $utm_campaign_source,
2954
+				'utm_content'  => 'buy_now_button',
2955
+			],
2956
+			'https://eventespresso.com/pricing/'
2957
+		);
2958
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2959
+			? $this->get_action_link_or_button(
2960
+				'',
2961
+				'buy_now',
2962
+				[],
2963
+				'button-primary button-large',
2964
+				esc_url_raw($buy_now_url),
2965
+				true
2966
+			)
2967
+			: $this->_template_args['preview_action_button'];
2968
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2969
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2970
+			$this->_template_args,
2971
+			true
2972
+		);
2973
+		$this->_display_admin_page($display_sidebar);
2974
+	}
2975
+
2976
+
2977
+	/**
2978
+	 * display_admin_list_table_page_with_sidebar
2979
+	 * generates HTML wrapper for an admin_page with list_table
2980
+	 *
2981
+	 * @return void
2982
+	 * @throws EE_Error
2983
+	 * @throws DomainException
2984
+	 */
2985
+	public function display_admin_list_table_page_with_sidebar()
2986
+	{
2987
+		$this->_display_admin_list_table_page(true);
2988
+	}
2989
+
2990
+
2991
+	/**
2992
+	 * display_admin_list_table_page_with_no_sidebar
2993
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2994
+	 *
2995
+	 * @return void
2996
+	 * @throws EE_Error
2997
+	 * @throws DomainException
2998
+	 */
2999
+	public function display_admin_list_table_page_with_no_sidebar()
3000
+	{
3001
+		$this->_display_admin_list_table_page();
3002
+	}
3003
+
3004
+
3005
+	/**
3006
+	 * generates html wrapper for an admin_list_table page
3007
+	 *
3008
+	 * @param boolean $sidebar whether to display with sidebar or not.
3009
+	 * @return void
3010
+	 * @throws DomainException
3011
+	 * @throws EE_Error
3012
+	 */
3013
+	private function _display_admin_list_table_page($sidebar = false)
3014
+	{
3015
+		// setup search attributes
3016
+		$this->_set_search_attributes();
3017
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
3018
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3019
+		$this->_template_args['table_url']        = $this->request->isAjax()
3020
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3021
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
3022
+		$this->_template_args['list_table']       = $this->_list_table_object;
3023
+		$this->_template_args['current_route']    = $this->_req_action;
3024
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3025
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3026
+		if (! empty($ajax_sorting_callback)) {
3027
+			$sortable_list_table_form_fields = wp_nonce_field(
3028
+				$ajax_sorting_callback . '_nonce',
3029
+				$ajax_sorting_callback . '_nonce',
3030
+				false,
3031
+				false
3032
+			);
3033
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3034
+												. $this->page_slug
3035
+												. '" />';
3036
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3037
+												. $ajax_sorting_callback
3038
+												. '" />';
3039
+		} else {
3040
+			$sortable_list_table_form_fields = '';
3041
+		}
3042
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3043
+		$hidden_form_fields                                      =
3044
+			isset($this->_template_args['list_table_hidden_fields'])
3045
+				? $this->_template_args['list_table_hidden_fields']
3046
+				: '';
3047
+		$nonce_ref                                               = $this->_req_action . '_nonce';
3048
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
3049
+																	. $nonce_ref
3050
+																	. '" value="'
3051
+																	. wp_create_nonce($nonce_ref)
3052
+																	. '">';
3053
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3054
+		// display message about search results?
3055
+		$search = $this->request->getRequestParam('s');
3056
+		$this->_template_args['before_list_table'] .= ! empty($search)
3057
+			? '<p class="ee-search-results">' . sprintf(
3058
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3059
+				trim($search, '%')
3060
+			) . '</p>'
3061
+			: '';
3062
+		// filter before_list_table template arg
3063
+		$this->_template_args['before_list_table'] = apply_filters(
3064
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3065
+			$this->_template_args['before_list_table'],
3066
+			$this->page_slug,
3067
+			$this->request->requestParams(),
3068
+			$this->_req_action
3069
+		);
3070
+		// convert to array and filter again
3071
+		// arrays are easier to inject new items in a specific location,
3072
+		// but would not be backwards compatible, so we have to add a new filter
3073
+		$this->_template_args['before_list_table'] = implode(
3074
+			" \n",
3075
+			(array) apply_filters(
3076
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3077
+				(array) $this->_template_args['before_list_table'],
3078
+				$this->page_slug,
3079
+				$this->request->requestParams(),
3080
+				$this->_req_action
3081
+			)
3082
+		);
3083
+		// filter after_list_table template arg
3084
+		$this->_template_args['after_list_table'] = apply_filters(
3085
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3086
+			$this->_template_args['after_list_table'],
3087
+			$this->page_slug,
3088
+			$this->request->requestParams(),
3089
+			$this->_req_action
3090
+		);
3091
+		// convert to array and filter again
3092
+		// arrays are easier to inject new items in a specific location,
3093
+		// but would not be backwards compatible, so we have to add a new filter
3094
+		$this->_template_args['after_list_table']   = implode(
3095
+			" \n",
3096
+			(array) apply_filters(
3097
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3098
+				(array) $this->_template_args['after_list_table'],
3099
+				$this->page_slug,
3100
+				$this->request->requestParams(),
3101
+				$this->_req_action
3102
+			)
3103
+		);
3104
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3105
+			$template_path,
3106
+			$this->_template_args,
3107
+			true
3108
+		);
3109
+		// the final template wrapper
3110
+		if ($sidebar) {
3111
+			$this->display_admin_page_with_sidebar();
3112
+		} else {
3113
+			$this->display_admin_page_with_no_sidebar();
3114
+		}
3115
+	}
3116
+
3117
+
3118
+	/**
3119
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3120
+	 * html string for the legend.
3121
+	 * $items are expected in an array in the following format:
3122
+	 * $legend_items = array(
3123
+	 *        'item_id' => array(
3124
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3125
+	 *            'desc' => esc_html__('localized description of item');
3126
+	 *        )
3127
+	 * );
3128
+	 *
3129
+	 * @param array $items see above for format of array
3130
+	 * @return string html string of legend
3131
+	 * @throws DomainException
3132
+	 */
3133
+	protected function _display_legend($items)
3134
+	{
3135
+		$this->_template_args['items'] = apply_filters(
3136
+			'FHEE__EE_Admin_Page___display_legend__items',
3137
+			(array) $items,
3138
+			$this
3139
+		);
3140
+		return EEH_Template::display_template(
3141
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3142
+			$this->_template_args,
3143
+			true
3144
+		);
3145
+	}
3146
+
3147
+
3148
+	/**
3149
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3150
+	 * The returned json object is created from an array in the following format:
3151
+	 * array(
3152
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3153
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3154
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3155
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3156
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3157
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3158
+	 *  that might be included in here)
3159
+	 * )
3160
+	 * The json object is populated by whatever is set in the $_template_args property.
3161
+	 *
3162
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3163
+	 *                                 instead of displayed.
3164
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3165
+	 * @return void
3166
+	 * @throws EE_Error
3167
+	 */
3168
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
3169
+	{
3170
+		// make sure any EE_Error notices have been handled.
3171
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3172
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3173
+		unset($this->_template_args['data']);
3174
+		$json = [
3175
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3176
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3177
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3178
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3179
+			'notices'   => EE_Error::get_notices(),
3180
+			'content'   => isset($this->_template_args['admin_page_content'])
3181
+				? $this->_template_args['admin_page_content'] : '',
3182
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3183
+			'isEEajax'  => true
3184
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3185
+		];
3186
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3187
+		if (null === error_get_last() || ! headers_sent()) {
3188
+			header('Content-Type: application/json; charset=UTF-8');
3189
+		}
3190
+		echo wp_json_encode($json);
3191
+		exit();
3192
+	}
3193
+
3194
+
3195
+	/**
3196
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3197
+	 *
3198
+	 * @return void
3199
+	 * @throws EE_Error
3200
+	 */
3201
+	public function return_json()
3202
+	{
3203
+		if ($this->request->isAjax()) {
3204
+			$this->_return_json();
3205
+		} else {
3206
+			throw new EE_Error(
3207
+				sprintf(
3208
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3209
+					__FUNCTION__
3210
+				)
3211
+			);
3212
+		}
3213
+	}
3214
+
3215
+
3216
+	/**
3217
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3218
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3219
+	 *
3220
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3221
+	 */
3222
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3223
+	{
3224
+		$this->_hook_obj = $hook_obj;
3225
+	}
3226
+
3227
+
3228
+	/**
3229
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3230
+	 *
3231
+	 * @param boolean $about whether to use the special about page wrapper or default.
3232
+	 * @return void
3233
+	 * @throws DomainException
3234
+	 * @throws EE_Error
3235
+	 */
3236
+	public function admin_page_wrapper($about = false)
3237
+	{
3238
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3239
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3240
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3241
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3242
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3243
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3244
+			isset($this->_template_args['before_admin_page_content'])
3245
+				? $this->_template_args['before_admin_page_content']
3246
+				: ''
3247
+		);
3248
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3249
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3250
+			isset($this->_template_args['after_admin_page_content'])
3251
+				? $this->_template_args['after_admin_page_content']
3252
+				: ''
3253
+		);
3254
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3255
+		// load settings page wrapper template
3256
+		$template_path = ! $this->request->isAjax()
3257
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3258
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
3259
+		// about page?
3260
+		$template_path = $about
3261
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3262
+			: $template_path;
3263
+		if ($this->request->isAjax()) {
3264
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3265
+				$template_path,
3266
+				$this->_template_args,
3267
+				true
3268
+			);
3269
+			$this->_return_json();
3270
+		} else {
3271
+			EEH_Template::display_template($template_path, $this->_template_args);
3272
+		}
3273
+	}
3274
+
3275
+
3276
+	/**
3277
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3278
+	 *
3279
+	 * @return string html
3280
+	 * @throws EE_Error
3281
+	 */
3282
+	protected function _get_main_nav_tabs()
3283
+	{
3284
+		// let's generate the html using the EEH_Tabbed_Content helper.
3285
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3286
+		// (rather than setting in the page_routes array)
3287
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3288
+	}
3289
+
3290
+
3291
+	/**
3292
+	 *        sort nav tabs
3293
+	 *
3294
+	 * @param $a
3295
+	 * @param $b
3296
+	 * @return int
3297
+	 */
3298
+	private function _sort_nav_tabs($a, $b)
3299
+	{
3300
+		if ($a['order'] === $b['order']) {
3301
+			return 0;
3302
+		}
3303
+		return ($a['order'] < $b['order']) ? -1 : 1;
3304
+	}
3305
+
3306
+
3307
+	/**
3308
+	 *    generates HTML for the forms used on admin pages
3309
+	 *
3310
+	 * @param array  $input_vars   - array of input field details
3311
+	 * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3312
+	 *                             use)
3313
+	 * @param bool   $id
3314
+	 * @return string
3315
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3316
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3317
+	 */
3318
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3319
+	{
3320
+		return $generator === 'string'
3321
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3322
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3323
+	}
3324
+
3325
+
3326
+	/**
3327
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3328
+	 *
3329
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3330
+	 *                                   Close" button.
3331
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3332
+	 *                                   'Save', [1] => 'save & close')
3333
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3334
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3335
+	 *                                   default actions by submitting some other value.
3336
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3337
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3338
+	 *                                   close (normal form handling).
3339
+	 */
3340
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3341
+	{
3342
+		// make sure $text and $actions are in an array
3343
+		$text          = (array) $text;
3344
+		$actions       = (array) $actions;
3345
+		$referrer_url  = empty($referrer)
3346
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3347
+			  . $this->request->getServerParam('REQUEST_URI')
3348
+			  . '" />'
3349
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3350
+			  . $referrer
3351
+			  . '" />';
3352
+		$button_text   = ! empty($text)
3353
+			? $text
3354
+			: [
3355
+				esc_html__('Save', 'event_espresso'),
3356
+				esc_html__('Save and Close', 'event_espresso'),
3357
+			];
3358
+		$default_names = ['save', 'save_and_close'];
3359
+		// add in a hidden index for the current page (so save and close redirects properly)
3360
+		$this->_template_args['save_buttons'] = $referrer_url;
3361
+		foreach ($button_text as $key => $button) {
3362
+			$ref                                  = $default_names[ $key ];
3363
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3364
+													 . $ref
3365
+													 . '" value="'
3366
+													 . $button
3367
+													 . '" name="'
3368
+													 . (! empty($actions) ? $actions[ $key ] : $ref)
3369
+													 . '" id="'
3370
+													 . $this->_current_view . '_' . $ref
3371
+													 . '" />';
3372
+			if (! $both) {
3373
+				break;
3374
+			}
3375
+		}
3376
+	}
3377
+
3378
+
3379
+	/**
3380
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3381
+	 *
3382
+	 * @param string $route
3383
+	 * @param array  $additional_hidden_fields
3384
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3385
+	 * @since 4.6.0
3386
+	 */
3387
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3388
+	{
3389
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3390
+	}
3391
+
3392
+
3393
+	/**
3394
+	 * set form open and close tags on add/edit pages.
3395
+	 *
3396
+	 * @param string $route                    the route you want the form to direct to
3397
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3398
+	 * @return void
3399
+	 */
3400
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3401
+	{
3402
+		if (empty($route)) {
3403
+			$user_msg = esc_html__(
3404
+				'An error occurred. No action was set for this page\'s form.',
3405
+				'event_espresso'
3406
+			);
3407
+			$dev_msg  = $user_msg . "\n"
3408
+						. sprintf(
3409
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3410
+							__FUNCTION__,
3411
+							__CLASS__
3412
+						);
3413
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3414
+		}
3415
+		// open form
3416
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3417
+															 . $this->_admin_base_url
3418
+															 . '" id="'
3419
+															 . $route
3420
+															 . '_event_form" >';
3421
+		// add nonce
3422
+		$nonce                                             =
3423
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3424
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3425
+		// add REQUIRED form action
3426
+		$hidden_fields = [
3427
+			'action' => ['type' => 'hidden', 'value' => $route],
3428
+		];
3429
+		// merge arrays
3430
+		$hidden_fields = is_array($additional_hidden_fields)
3431
+			? array_merge($hidden_fields, $additional_hidden_fields)
3432
+			: $hidden_fields;
3433
+		// generate form fields
3434
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3435
+		// add fields to form
3436
+		foreach ((array) $form_fields as $field_name => $form_field) {
3437
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3438
+		}
3439
+		// close form
3440
+		$this->_template_args['after_admin_page_content'] = '</form>';
3441
+	}
3442
+
3443
+
3444
+	/**
3445
+	 * Public Wrapper for _redirect_after_action() method since its
3446
+	 * discovered it would be useful for external code to have access.
3447
+	 *
3448
+	 * @param bool   $success
3449
+	 * @param string $what
3450
+	 * @param string $action_desc
3451
+	 * @param array  $query_args
3452
+	 * @param bool   $override_overwrite
3453
+	 * @throws EE_Error
3454
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3455
+	 * @since 4.5.0
3456
+	 */
3457
+	public function redirect_after_action(
3458
+		$success = false,
3459
+		$what = 'item',
3460
+		$action_desc = 'processed',
3461
+		$query_args = [],
3462
+		$override_overwrite = false
3463
+	) {
3464
+		$this->_redirect_after_action(
3465
+			$success,
3466
+			$what,
3467
+			$action_desc,
3468
+			$query_args,
3469
+			$override_overwrite
3470
+		);
3471
+	}
3472
+
3473
+
3474
+	/**
3475
+	 * Helper method for merging existing request data with the returned redirect url.
3476
+	 *
3477
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3478
+	 * filters are still applied.
3479
+	 *
3480
+	 * @param array $new_route_data
3481
+	 * @return array
3482
+	 */
3483
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3484
+	{
3485
+		foreach ($this->request->requestParams() as $ref => $value) {
3486
+			// unset nonces
3487
+			if (strpos($ref, 'nonce') !== false) {
3488
+				$this->request->unSetRequestParam($ref);
3489
+				continue;
3490
+			}
3491
+			// urlencode values.
3492
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3493
+			$this->request->setRequestParam($ref, $value);
3494
+		}
3495
+		return array_merge($this->request->requestParams(), $new_route_data);
3496
+	}
3497
+
3498
+
3499
+	/**
3500
+	 *    _redirect_after_action
3501
+	 *
3502
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3503
+	 * @param string $what               - what the action was performed on
3504
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3505
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3506
+	 *                                   action is completed
3507
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3508
+	 *                                   override this so that they show.
3509
+	 * @return void
3510
+	 * @throws EE_Error
3511
+	 */
3512
+	protected function _redirect_after_action(
3513
+		$success = 0,
3514
+		$what = 'item',
3515
+		$action_desc = 'processed',
3516
+		$query_args = [],
3517
+		$override_overwrite = false
3518
+	) {
3519
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3520
+		// class name for actions/filters.
3521
+		$classname = get_class($this);
3522
+		// set redirect url.
3523
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3524
+		// otherwise we go with whatever is set as the _admin_base_url
3525
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3526
+		$notices      = EE_Error::get_notices(false);
3527
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3528
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3529
+			EE_Error::overwrite_success();
3530
+		}
3531
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3532
+			// how many records affected ? more than one record ? or just one ?
3533
+			if ($success > 1) {
3534
+				// set plural msg
3535
+				EE_Error::add_success(
3536
+					sprintf(
3537
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3538
+						$what,
3539
+						$action_desc
3540
+					),
3541
+					__FILE__,
3542
+					__FUNCTION__,
3543
+					__LINE__
3544
+				);
3545
+			} elseif ($success === 1) {
3546
+				// set singular msg
3547
+				EE_Error::add_success(
3548
+					sprintf(
3549
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3550
+						$what,
3551
+						$action_desc
3552
+					),
3553
+					__FILE__,
3554
+					__FUNCTION__,
3555
+					__LINE__
3556
+				);
3557
+			}
3558
+		}
3559
+		// check that $query_args isn't something crazy
3560
+		if (! is_array($query_args)) {
3561
+			$query_args = [];
3562
+		}
3563
+		/**
3564
+		 * Allow injecting actions before the query_args are modified for possible different
3565
+		 * redirections on save and close actions
3566
+		 *
3567
+		 * @param array $query_args       The original query_args array coming into the
3568
+		 *                                method.
3569
+		 * @since 4.2.0
3570
+		 */
3571
+		do_action(
3572
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3573
+			$query_args
3574
+		);
3575
+		// calculate where we're going (if we have a "save and close" button pushed)
3576
+
3577
+		if (
3578
+			$this->request->requestParamIsSet('save_and_close')
3579
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3580
+		) {
3581
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3582
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3583
+			// regenerate query args array from referrer URL
3584
+			parse_str($parsed_url['query'], $query_args);
3585
+			// correct page and action will be in the query args now
3586
+			$redirect_url = admin_url('admin.php');
3587
+		}
3588
+		// merge any default query_args set in _default_route_query_args property
3589
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3590
+			$args_to_merge = [];
3591
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3592
+				// is there a wp_referer array in our _default_route_query_args property?
3593
+				if ($query_param === 'wp_referer') {
3594
+					$query_value = (array) $query_value;
3595
+					foreach ($query_value as $reference => $value) {
3596
+						if (strpos($reference, 'nonce') !== false) {
3597
+							continue;
3598
+						}
3599
+						// finally we will override any arguments in the referer with
3600
+						// what might be set on the _default_route_query_args array.
3601
+						if (isset($this->_default_route_query_args[ $reference ])) {
3602
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3603
+						} else {
3604
+							$args_to_merge[ $reference ] = urlencode($value);
3605
+						}
3606
+					}
3607
+					continue;
3608
+				}
3609
+				$args_to_merge[ $query_param ] = $query_value;
3610
+			}
3611
+			// now let's merge these arguments but override with what was specifically sent in to the
3612
+			// redirect.
3613
+			$query_args = array_merge($args_to_merge, $query_args);
3614
+		}
3615
+		$this->_process_notices($query_args);
3616
+		// generate redirect url
3617
+		// if redirecting to anything other than the main page, add a nonce
3618
+		if (isset($query_args['action'])) {
3619
+			// manually generate wp_nonce and merge that with the query vars
3620
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3621
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3622
+		}
3623
+		// we're adding some hooks and filters in here for processing any things just before redirects
3624
+		// (example: an admin page has done an insert or update and we want to run something after that).
3625
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3626
+		$redirect_url = apply_filters(
3627
+			'FHEE_redirect_' . $classname . $this->_req_action,
3628
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3629
+			$query_args
3630
+		);
3631
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3632
+		if ($this->request->isAjax()) {
3633
+			$default_data                    = [
3634
+				'close'        => true,
3635
+				'redirect_url' => $redirect_url,
3636
+				'where'        => 'main',
3637
+				'what'         => 'append',
3638
+			];
3639
+			$this->_template_args['success'] = $success;
3640
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3641
+				$default_data,
3642
+				$this->_template_args['data']
3643
+			) : $default_data;
3644
+			$this->_return_json();
3645
+		}
3646
+		wp_safe_redirect($redirect_url);
3647
+		exit();
3648
+	}
3649
+
3650
+
3651
+	/**
3652
+	 * process any notices before redirecting (or returning ajax request)
3653
+	 * This method sets the $this->_template_args['notices'] attribute;
3654
+	 *
3655
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3656
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3657
+	 *                                  page_routes haven't been defined yet.
3658
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3659
+	 *                                  still save a transient for the notice.
3660
+	 * @return void
3661
+	 * @throws EE_Error
3662
+	 */
3663
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3664
+	{
3665
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3666
+		if ($this->request->isAjax()) {
3667
+			$notices = EE_Error::get_notices(false);
3668
+			if (empty($this->_template_args['success'])) {
3669
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3670
+			}
3671
+			if (empty($this->_template_args['errors'])) {
3672
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3673
+			}
3674
+			if (empty($this->_template_args['attention'])) {
3675
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3676
+			}
3677
+		}
3678
+		$this->_template_args['notices'] = EE_Error::get_notices();
3679
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3680
+		if (! $this->request->isAjax() || $sticky_notices) {
3681
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3682
+			$this->_add_transient(
3683
+				$route,
3684
+				$this->_template_args['notices'],
3685
+				true,
3686
+				$skip_route_verify
3687
+			);
3688
+		}
3689
+	}
3690
+
3691
+
3692
+	/**
3693
+	 * get_action_link_or_button
3694
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3695
+	 *
3696
+	 * @param string $action        use this to indicate which action the url is generated with.
3697
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3698
+	 *                              property.
3699
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3700
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3701
+	 * @param string $base_url      If this is not provided
3702
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3703
+	 *                              Otherwise this value will be used.
3704
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3705
+	 * @return string
3706
+	 * @throws InvalidArgumentException
3707
+	 * @throws InvalidInterfaceException
3708
+	 * @throws InvalidDataTypeException
3709
+	 * @throws EE_Error
3710
+	 */
3711
+	public function get_action_link_or_button(
3712
+		$action,
3713
+		$type = 'add',
3714
+		$extra_request = [],
3715
+		$class = 'button-primary',
3716
+		$base_url = '',
3717
+		$exclude_nonce = false
3718
+	) {
3719
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3720
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3721
+			throw new EE_Error(
3722
+				sprintf(
3723
+					esc_html__(
3724
+						'There is no page route for given action for the button.  This action was given: %s',
3725
+						'event_espresso'
3726
+					),
3727
+					$action
3728
+				)
3729
+			);
3730
+		}
3731
+		if (! isset($this->_labels['buttons'][ $type ])) {
3732
+			throw new EE_Error(
3733
+				sprintf(
3734
+					esc_html__(
3735
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3736
+						'event_espresso'
3737
+					),
3738
+					$type
3739
+				)
3740
+			);
3741
+		}
3742
+		// finally check user access for this button.
3743
+		$has_access = $this->check_user_access($action, true);
3744
+		if (! $has_access) {
3745
+			return '';
3746
+		}
3747
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3748
+		$query_args = [
3749
+			'action' => $action,
3750
+		];
3751
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3752
+		if (! empty($extra_request)) {
3753
+			$query_args = array_merge($extra_request, $query_args);
3754
+		}
3755
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3756
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3757
+	}
3758
+
3759
+
3760
+	/**
3761
+	 * _per_page_screen_option
3762
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3763
+	 *
3764
+	 * @return void
3765
+	 * @throws InvalidArgumentException
3766
+	 * @throws InvalidInterfaceException
3767
+	 * @throws InvalidDataTypeException
3768
+	 */
3769
+	protected function _per_page_screen_option()
3770
+	{
3771
+		$option = 'per_page';
3772
+		$args   = [
3773
+			'label'   => apply_filters(
3774
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3775
+				$this->_admin_page_title,
3776
+				$this
3777
+			),
3778
+			'default' => (int) apply_filters(
3779
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3780
+				20
3781
+			),
3782
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3783
+		];
3784
+		// ONLY add the screen option if the user has access to it.
3785
+		if ($this->check_user_access($this->_current_view, true)) {
3786
+			add_screen_option($option, $args);
3787
+		}
3788
+	}
3789
+
3790
+
3791
+	/**
3792
+	 * set_per_page_screen_option
3793
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3794
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3795
+	 * admin_menu.
3796
+	 *
3797
+	 * @return void
3798
+	 */
3799
+	private function _set_per_page_screen_options()
3800
+	{
3801
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3802
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3803
+			if (! $user = wp_get_current_user()) {
3804
+				return;
3805
+			}
3806
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3807
+			if (! $option) {
3808
+				return;
3809
+			}
3810
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3811
+			$map_option = $option;
3812
+			$option     = str_replace('-', '_', $option);
3813
+			switch ($map_option) {
3814
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3815
+					$max_value = apply_filters(
3816
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3817
+						999,
3818
+						$this->_current_page,
3819
+						$this->_current_view
3820
+					);
3821
+					if ($value < 1) {
3822
+						return;
3823
+					}
3824
+					$value = min($value, $max_value);
3825
+					break;
3826
+				default:
3827
+					$value = apply_filters(
3828
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3829
+						false,
3830
+						$option,
3831
+						$value
3832
+					);
3833
+					if (false === $value) {
3834
+						return;
3835
+					}
3836
+					break;
3837
+			}
3838
+			update_user_meta($user->ID, $option, $value);
3839
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3840
+			exit;
3841
+		}
3842
+	}
3843
+
3844
+
3845
+	/**
3846
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3847
+	 *
3848
+	 * @param array $data array that will be assigned to template args.
3849
+	 */
3850
+	public function set_template_args($data)
3851
+	{
3852
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3853
+	}
3854
+
3855
+
3856
+	/**
3857
+	 * This makes available the WP transient system for temporarily moving data between routes
3858
+	 *
3859
+	 * @param string $route             the route that should receive the transient
3860
+	 * @param array  $data              the data that gets sent
3861
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3862
+	 *                                  normal route transient.
3863
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3864
+	 *                                  when we are adding a transient before page_routes have been defined.
3865
+	 * @return void
3866
+	 * @throws EE_Error
3867
+	 */
3868
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3869
+	{
3870
+		$user_id = get_current_user_id();
3871
+		if (! $skip_route_verify) {
3872
+			$this->_verify_route($route);
3873
+		}
3874
+		// now let's set the string for what kind of transient we're setting
3875
+		$transient = $notices
3876
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3877
+			: 'rte_tx_' . $route . '_' . $user_id;
3878
+		$data      = $notices ? ['notices' => $data] : $data;
3879
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3880
+		$existing = is_multisite() && is_network_admin()
3881
+			? get_site_transient($transient)
3882
+			: get_transient($transient);
3883
+		if ($existing) {
3884
+			$data = array_merge((array) $data, (array) $existing);
3885
+		}
3886
+		if (is_multisite() && is_network_admin()) {
3887
+			set_site_transient($transient, $data, 8);
3888
+		} else {
3889
+			set_transient($transient, $data, 8);
3890
+		}
3891
+	}
3892
+
3893
+
3894
+	/**
3895
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3896
+	 *
3897
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3898
+	 * @param string $route
3899
+	 * @return mixed data
3900
+	 */
3901
+	protected function _get_transient($notices = false, $route = '')
3902
+	{
3903
+		$user_id   = get_current_user_id();
3904
+		$route     = ! $route ? $this->_req_action : $route;
3905
+		$transient = $notices
3906
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3907
+			: 'rte_tx_' . $route . '_' . $user_id;
3908
+		$data      = is_multisite() && is_network_admin()
3909
+			? get_site_transient($transient)
3910
+			: get_transient($transient);
3911
+		// delete transient after retrieval (just in case it hasn't expired);
3912
+		if (is_multisite() && is_network_admin()) {
3913
+			delete_site_transient($transient);
3914
+		} else {
3915
+			delete_transient($transient);
3916
+		}
3917
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3918
+	}
3919
+
3920
+
3921
+	/**
3922
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3923
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3924
+	 * default route callback on the EE_Admin page you want it run.)
3925
+	 *
3926
+	 * @return void
3927
+	 */
3928
+	protected function _transient_garbage_collection()
3929
+	{
3930
+		global $wpdb;
3931
+		// retrieve all existing transients
3932
+		$query =
3933
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3934
+		if ($results = $wpdb->get_results($query)) {
3935
+			foreach ($results as $result) {
3936
+				$transient = str_replace('_transient_', '', $result->option_name);
3937
+				get_transient($transient);
3938
+				if (is_multisite() && is_network_admin()) {
3939
+					get_site_transient($transient);
3940
+				}
3941
+			}
3942
+		}
3943
+	}
3944
+
3945
+
3946
+	/**
3947
+	 * get_view
3948
+	 *
3949
+	 * @return string content of _view property
3950
+	 */
3951
+	public function get_view()
3952
+	{
3953
+		return $this->_view;
3954
+	}
3955
+
3956
+
3957
+	/**
3958
+	 * getter for the protected $_views property
3959
+	 *
3960
+	 * @return array
3961
+	 */
3962
+	public function get_views()
3963
+	{
3964
+		return $this->_views;
3965
+	}
3966
+
3967
+
3968
+	/**
3969
+	 * get_current_page
3970
+	 *
3971
+	 * @return string _current_page property value
3972
+	 */
3973
+	public function get_current_page()
3974
+	{
3975
+		return $this->_current_page;
3976
+	}
3977
+
3978
+
3979
+	/**
3980
+	 * get_current_view
3981
+	 *
3982
+	 * @return string _current_view property value
3983
+	 */
3984
+	public function get_current_view()
3985
+	{
3986
+		return $this->_current_view;
3987
+	}
3988
+
3989
+
3990
+	/**
3991
+	 * get_current_screen
3992
+	 *
3993
+	 * @return object The current WP_Screen object
3994
+	 */
3995
+	public function get_current_screen()
3996
+	{
3997
+		return $this->_current_screen;
3998
+	}
3999
+
4000
+
4001
+	/**
4002
+	 * get_current_page_view_url
4003
+	 *
4004
+	 * @return string This returns the url for the current_page_view.
4005
+	 */
4006
+	public function get_current_page_view_url()
4007
+	{
4008
+		return $this->_current_page_view_url;
4009
+	}
4010
+
4011
+
4012
+	/**
4013
+	 * just returns the Request
4014
+	 *
4015
+	 * @return RequestInterface
4016
+	 */
4017
+	public function get_request()
4018
+	{
4019
+		return $this->request;
4020
+	}
4021
+
4022
+
4023
+	/**
4024
+	 * just returns the _req_data property
4025
+	 *
4026
+	 * @return array
4027
+	 */
4028
+	public function get_request_data()
4029
+	{
4030
+		return $this->request->requestParams();
4031
+	}
4032
+
4033
+
4034
+	/**
4035
+	 * returns the _req_data protected property
4036
+	 *
4037
+	 * @return string
4038
+	 */
4039
+	public function get_req_action()
4040
+	{
4041
+		return $this->_req_action;
4042
+	}
4043
+
4044
+
4045
+	/**
4046
+	 * @return bool  value of $_is_caf property
4047
+	 */
4048
+	public function is_caf()
4049
+	{
4050
+		return $this->_is_caf;
4051
+	}
4052
+
4053
+
4054
+	/**
4055
+	 * @return mixed
4056
+	 */
4057
+	public function default_espresso_metaboxes()
4058
+	{
4059
+		return $this->_default_espresso_metaboxes;
4060
+	}
4061
+
4062
+
4063
+	/**
4064
+	 * @return mixed
4065
+	 */
4066
+	public function admin_base_url()
4067
+	{
4068
+		return $this->_admin_base_url;
4069
+	}
4070
+
4071
+
4072
+	/**
4073
+	 * @return mixed
4074
+	 */
4075
+	public function wp_page_slug()
4076
+	{
4077
+		return $this->_wp_page_slug;
4078
+	}
4079
+
4080
+
4081
+	/**
4082
+	 * updates  espresso configuration settings
4083
+	 *
4084
+	 * @param string                   $tab
4085
+	 * @param EE_Config_Base|EE_Config $config
4086
+	 * @param string                   $file file where error occurred
4087
+	 * @param string                   $func function  where error occurred
4088
+	 * @param string                   $line line no where error occurred
4089
+	 * @return boolean
4090
+	 */
4091
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4092
+	{
4093
+		// remove any options that are NOT going to be saved with the config settings.
4094
+		if (isset($config->core->ee_ueip_optin)) {
4095
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4096
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4097
+			update_option('ee_ueip_has_notified', true);
4098
+		}
4099
+		// and save it (note we're also doing the network save here)
4100
+		$net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4101
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4102
+		if ($config_saved && $net_saved) {
4103
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4104
+			return true;
4105
+		}
4106
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4107
+		return false;
4108
+	}
4109
+
4110
+
4111
+	/**
4112
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4113
+	 *
4114
+	 * @return array
4115
+	 */
4116
+	public function get_yes_no_values()
4117
+	{
4118
+		return $this->_yes_no_values;
4119
+	}
4120
+
4121
+
4122
+	protected function _get_dir()
4123
+	{
4124
+		$reflector = new ReflectionClass(get_class($this));
4125
+		return dirname($reflector->getFileName());
4126
+	}
4127
+
4128
+
4129
+	/**
4130
+	 * A helper for getting a "next link".
4131
+	 *
4132
+	 * @param string $url   The url to link to
4133
+	 * @param string $class The class to use.
4134
+	 * @return string
4135
+	 */
4136
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4137
+	{
4138
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4139
+	}
4140
+
4141
+
4142
+	/**
4143
+	 * A helper for getting a "previous link".
4144
+	 *
4145
+	 * @param string $url   The url to link to
4146
+	 * @param string $class The class to use.
4147
+	 * @return string
4148
+	 */
4149
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4150
+	{
4151
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4152
+	}
4153
+
4154
+
4155
+
4156
+
4157
+
4158
+
4159
+
4160
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4161
+
4162
+
4163
+	/**
4164
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4165
+	 * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4166
+	 * _req_data array.
4167
+	 *
4168
+	 * @return bool success/fail
4169
+	 * @throws EE_Error
4170
+	 * @throws InvalidArgumentException
4171
+	 * @throws ReflectionException
4172
+	 * @throws InvalidDataTypeException
4173
+	 * @throws InvalidInterfaceException
4174
+	 */
4175
+	protected function _process_resend_registration()
4176
+	{
4177
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4178
+		do_action(
4179
+			'AHEE__EE_Admin_Page___process_resend_registration',
4180
+			$this->_template_args['success'],
4181
+			$this->request->requestParams()
4182
+		);
4183
+		return $this->_template_args['success'];
4184
+	}
4185
+
4186
+
4187
+	/**
4188
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4189
+	 *
4190
+	 * @param EE_Payment $payment
4191
+	 * @return bool success/fail
4192
+	 */
4193
+	protected function _process_payment_notification(EE_Payment $payment)
4194
+	{
4195
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4196
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4197
+		$this->_template_args['success'] = apply_filters(
4198
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4199
+			false,
4200
+			$payment
4201
+		);
4202
+		return $this->_template_args['success'];
4203
+	}
4204 4204
 }
Please login to merge, or discard this patch.
Spacing   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
         $ee_menu_slugs = (array) $ee_menu_slugs;
537 537
         if (
538 538
             ! $this->request->isAjax()
539
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
539
+            && ( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))
540 540
         ) {
541 541
             return;
542 542
         }
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
             : $req_action;
557 557
 
558 558
         $this->_current_view = $this->_req_action;
559
-        $this->_req_nonce    = $this->_req_action . '_nonce';
559
+        $this->_req_nonce    = $this->_req_action.'_nonce';
560 560
         $this->_define_page_props();
561 561
         $this->_current_page_view_url = add_query_arg(
562 562
             ['page' => $this->_current_page, 'action' => $this->_current_view],
@@ -593,21 +593,21 @@  discard block
 block discarded – undo
593 593
         }
594 594
         // filter routes and page_config so addons can add their stuff. Filtering done per class
595 595
         $this->_page_routes = apply_filters(
596
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
596
+            'FHEE__'.get_class($this).'__page_setup__page_routes',
597 597
             $this->_page_routes,
598 598
             $this
599 599
         );
600 600
         $this->_page_config = apply_filters(
601
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
601
+            'FHEE__'.get_class($this).'__page_setup__page_config',
602 602
             $this->_page_config,
603 603
             $this
604 604
         );
605 605
         // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
606 606
         // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
607
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
607
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
608 608
             add_action(
609 609
                 'AHEE__EE_Admin_Page__route_admin_request',
610
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
610
+                [$this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view],
611 611
                 10,
612 612
                 2
613 613
             );
@@ -620,8 +620,8 @@  discard block
 block discarded – undo
620 620
             if ($this->_is_UI_request) {
621 621
                 // admin_init stuff - global, all views for this page class, specific view
622 622
                 add_action('admin_init', [$this, 'admin_init'], 10);
623
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
624
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
623
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
624
+                    add_action('admin_init', [$this, 'admin_init_'.$this->_current_view], 15);
625 625
                 }
626 626
             } else {
627 627
                 // hijack regular WP loading and route admin request immediately
@@ -640,12 +640,12 @@  discard block
 block discarded – undo
640 640
      */
641 641
     private function _do_other_page_hooks()
642 642
     {
643
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
643
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, []);
644 644
         foreach ($registered_pages as $page) {
645 645
             // now let's setup the file name and class that should be present
646 646
             $classname = str_replace('.class.php', '', $page);
647 647
             // autoloaders should take care of loading file
648
-            if (! class_exists($classname)) {
648
+            if ( ! class_exists($classname)) {
649 649
                 $error_msg[] = sprintf(
650 650
                     esc_html__(
651 651
                         'Something went wrong with loading the %s admin hooks page.',
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
                                    ),
663 663
                                    $page,
664 664
                                    '<br />',
665
-                                   '<strong>' . $classname . '</strong>'
665
+                                   '<strong>'.$classname.'</strong>'
666 666
                                );
667 667
                 throw new EE_Error(implode('||', $error_msg));
668 668
             }
@@ -704,13 +704,13 @@  discard block
 block discarded – undo
704 704
         // load admin_notices - global, page class, and view specific
705 705
         add_action('admin_notices', [$this, 'admin_notices_global'], 5);
706 706
         add_action('admin_notices', [$this, 'admin_notices'], 10);
707
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
708
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
707
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
708
+            add_action('admin_notices', [$this, 'admin_notices_'.$this->_current_view], 15);
709 709
         }
710 710
         // load network admin_notices - global, page class, and view specific
711 711
         add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
712
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
713
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
712
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
713
+            add_action('network_admin_notices', [$this, 'network_admin_notices_'.$this->_current_view]);
714 714
         }
715 715
         // this will save any per_page screen options if they are present
716 716
         $this->_set_per_page_screen_options();
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
     protected function _verify_routes()
833 833
     {
834 834
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
835
-        if (! $this->_current_page && ! $this->request->isAjax()) {
835
+        if ( ! $this->_current_page && ! $this->request->isAjax()) {
836 836
             return false;
837 837
         }
838 838
         $this->_route = false;
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
                 $this->_admin_page_title
845 845
             );
846 846
             // developer error msg
847
-            $error_msg .= '||' . $error_msg
847
+            $error_msg .= '||'.$error_msg
848 848
                           . esc_html__(
849 849
                               ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
850 850
                               'event_espresso'
@@ -853,9 +853,9 @@  discard block
 block discarded – undo
853 853
         }
854 854
         // and that the requested page route exists
855 855
         if (array_key_exists($this->_req_action, $this->_page_routes)) {
856
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
857
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
858
-                ? $this->_page_config[ $this->_req_action ]
856
+            $this->_route        = $this->_page_routes[$this->_req_action];
857
+            $this->_route_config = isset($this->_page_config[$this->_req_action])
858
+                ? $this->_page_config[$this->_req_action]
859 859
                 : [];
860 860
         } else {
861 861
             // user error msg
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
                 $this->_admin_page_title
868 868
             );
869 869
             // developer error msg
870
-            $error_msg .= '||' . $error_msg
870
+            $error_msg .= '||'.$error_msg
871 871
                           . sprintf(
872 872
                               esc_html__(
873 873
                                   ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
             throw new EE_Error($error_msg);
879 879
         }
880 880
         // and that a default route exists
881
-        if (! array_key_exists('default', $this->_page_routes)) {
881
+        if ( ! array_key_exists('default', $this->_page_routes)) {
882 882
             // user error msg
883 883
             $error_msg = sprintf(
884 884
                 esc_html__(
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
                 $this->_admin_page_title
889 889
             );
890 890
             // developer error msg
891
-            $error_msg .= '||' . $error_msg
891
+            $error_msg .= '||'.$error_msg
892 892
                           . esc_html__(
893 893
                               ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
894 894
                               'event_espresso'
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
             $this->_admin_page_title
930 930
         );
931 931
         // developer error msg
932
-        $error_msg .= '||' . $error_msg
932
+        $error_msg .= '||'.$error_msg
933 933
                       . sprintf(
934 934
                           esc_html__(
935 935
                               ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
     protected function _verify_nonce($nonce, $nonce_ref)
955 955
     {
956 956
         // verify nonce against expected value
957
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
957
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
958 958
             // these are not the droids you are looking for !!!
959 959
             $msg = sprintf(
960 960
                 esc_html__('%sNonce Fail.%s', 'event_espresso'),
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
                     __CLASS__
972 972
                 );
973 973
             }
974
-            if (! $this->request->isAjax()) {
974
+            if ( ! $this->request->isAjax()) {
975 975
                 wp_die($msg);
976 976
             }
977 977
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
      */
996 996
     protected function _route_admin_request()
997 997
     {
998
-        if (! $this->_is_UI_request) {
998
+        if ( ! $this->_is_UI_request) {
999 999
             $this->_verify_routes();
1000 1000
         }
1001 1001
         $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
         $error_msg = '';
1016 1016
         // action right before calling route
1017 1017
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1018
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1018
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1019 1019
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1020 1020
         }
1021 1021
         // right before calling the route, let's clean the _wp_http_referer
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
                 wp_unslash($this->request->getServerParam('REQUEST_URI'))
1027 1027
             )
1028 1028
         );
1029
-        if (! empty($func)) {
1029
+        if ( ! empty($func)) {
1030 1030
             if (is_array($func)) {
1031 1031
                 list($class, $method) = $func;
1032 1032
             } elseif (strpos($func, '::') !== false) {
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
                 $class  = $this;
1036 1036
                 $method = $func;
1037 1037
             }
1038
-            if (! (is_object($class) && $class === $this)) {
1038
+            if ( ! (is_object($class) && $class === $this)) {
1039 1039
                 // send along this admin page object for access by addons.
1040 1040
                 $args['admin_page_object'] = $this;
1041 1041
             }
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
                     $method
1077 1077
                 );
1078 1078
             }
1079
-            if (! empty($error_msg)) {
1079
+            if ( ! empty($error_msg)) {
1080 1080
                 throw new EE_Error($error_msg);
1081 1081
             }
1082 1082
         }
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
                 if (strpos($key, 'nonce') !== false) {
1162 1162
                     continue;
1163 1163
                 }
1164
-                $args[ 'wp_referer[' . $key . ']' ] = htmlspecialchars($value);
1164
+                $args['wp_referer['.$key.']'] = htmlspecialchars($value);
1165 1165
             }
1166 1166
         }
1167 1167
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1201,8 +1201,8 @@  discard block
 block discarded – undo
1201 1201
     protected function _add_help_tabs()
1202 1202
     {
1203 1203
         $tour_buttons = '';
1204
-        if (isset($this->_page_config[ $this->_req_action ])) {
1205
-            $config = $this->_page_config[ $this->_req_action ];
1204
+        if (isset($this->_page_config[$this->_req_action])) {
1205
+            $config = $this->_page_config[$this->_req_action];
1206 1206
             // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1207 1207
             // is there a help tour for the current route?  if there is let's setup the tour buttons
1208 1208
             // if (isset($this->_help_tour[ $this->_req_action ])) {
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1226 1226
             if (is_array($config) && isset($config['help_sidebar'])) {
1227 1227
                 // check that the callback given is valid
1228
-                if (! method_exists($this, $config['help_sidebar'])) {
1228
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1229 1229
                     throw new EE_Error(
1230 1230
                         sprintf(
1231 1231
                             esc_html__(
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
                     );
1239 1239
                 }
1240 1240
                 $content = apply_filters(
1241
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1241
+                    'FHEE__'.get_class($this).'__add_help_tabs__help_sidebar',
1242 1242
                     $this->{$config['help_sidebar']}()
1243 1243
                 );
1244 1244
                 $content .= $tour_buttons; // add help tour buttons.
@@ -1246,27 +1246,27 @@  discard block
 block discarded – undo
1246 1246
                 $this->_current_screen->set_help_sidebar($content);
1247 1247
             }
1248 1248
             // if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1249
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1249
+            if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1250 1250
                 $this->_current_screen->set_help_sidebar($tour_buttons);
1251 1251
             }
1252 1252
             // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1253
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1253
+            if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1254 1254
                 $_ht['id']      = $this->page_slug;
1255 1255
                 $_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1256 1256
                 $_ht['content'] = '<p>'
1257 1257
                                   . esc_html__(
1258 1258
                                       'The buttons to the right allow you to start/restart any help tours available for this page',
1259 1259
                                       'event_espresso'
1260
-                                  ) . '</p>';
1260
+                                  ).'</p>';
1261 1261
                 $this->_current_screen->add_help_tab($_ht);
1262 1262
             }
1263
-            if (! isset($config['help_tabs'])) {
1263
+            if ( ! isset($config['help_tabs'])) {
1264 1264
                 return;
1265 1265
             } //no help tabs for this route
1266 1266
             foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1267 1267
                 // we're here so there ARE help tabs!
1268 1268
                 // make sure we've got what we need
1269
-                if (! isset($cfg['title'])) {
1269
+                if ( ! isset($cfg['title'])) {
1270 1270
                     throw new EE_Error(
1271 1271
                         esc_html__(
1272 1272
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1274,7 +1274,7 @@  discard block
 block discarded – undo
1274 1274
                         )
1275 1275
                     );
1276 1276
                 }
1277
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1277
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1278 1278
                     throw new EE_Error(
1279 1279
                         esc_html__(
1280 1280
                             'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
@@ -1283,11 +1283,11 @@  discard block
 block discarded – undo
1283 1283
                     );
1284 1284
                 }
1285 1285
                 // first priority goes to content.
1286
-                if (! empty($cfg['content'])) {
1286
+                if ( ! empty($cfg['content'])) {
1287 1287
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1288 1288
                     // second priority goes to filename
1289
-                } elseif (! empty($cfg['filename'])) {
1290
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1289
+                } elseif ( ! empty($cfg['filename'])) {
1290
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1291 1291
                     // it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1292 1292
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1293 1293
                                                              . basename($this->_get_dir())
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
                                                              . $cfg['filename']
1296 1296
                                                              . '.help_tab.php' : $file_path;
1297 1297
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1298
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1298
+                    if ( ! isset($cfg['callback']) && ! is_readable($file_path)) {
1299 1299
                         EE_Error::add_error(
1300 1300
                             sprintf(
1301 1301
                                 esc_html__(
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
                     return;
1344 1344
                 }
1345 1345
                 // setup config array for help tab method
1346
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1346
+                $id  = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1347 1347
                 $_ht = [
1348 1348
                     'id'       => $id,
1349 1349
                     'title'    => $cfg['title'],
@@ -1470,8 +1470,8 @@  discard block
 block discarded – undo
1470 1470
             $qtips = (array) $this->_route_config['qtips'];
1471 1471
             // load qtip loader
1472 1472
             $path = [
1473
-                $this->_get_dir() . '/qtips/',
1474
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1473
+                $this->_get_dir().'/qtips/',
1474
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1475 1475
             ];
1476 1476
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1477 1477
         }
@@ -1493,7 +1493,7 @@  discard block
 block discarded – undo
1493 1493
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1494 1494
         $i = 0;
1495 1495
         foreach ($this->_page_config as $slug => $config) {
1496
-            if (! is_array($config) || empty($config['nav'])) {
1496
+            if ( ! is_array($config) || empty($config['nav'])) {
1497 1497
                 continue;
1498 1498
             }
1499 1499
             // no nav tab for this config
@@ -1502,12 +1502,12 @@  discard block
 block discarded – undo
1502 1502
                 // nav tab is only to appear when route requested.
1503 1503
                 continue;
1504 1504
             }
1505
-            if (! $this->check_user_access($slug, true)) {
1505
+            if ( ! $this->check_user_access($slug, true)) {
1506 1506
                 // no nav tab because current user does not have access.
1507 1507
                 continue;
1508 1508
             }
1509
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1510
-            $this->_nav_tabs[ $slug ] = [
1509
+            $css_class                = isset($config['css_class']) ? $config['css_class'].' ' : '';
1510
+            $this->_nav_tabs[$slug] = [
1511 1511
                 'url'       => isset($config['nav']['url'])
1512 1512
                     ? $config['nav']['url']
1513 1513
                     : self::add_query_args_and_nonce(
@@ -1519,14 +1519,14 @@  discard block
 block discarded – undo
1519 1519
                     : ucwords(
1520 1520
                         str_replace('_', ' ', $slug)
1521 1521
                     ),
1522
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1522
+                'css_class' => $this->_req_action === $slug ? $css_class.'nav-tab-active' : $css_class,
1523 1523
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1524 1524
             ];
1525 1525
             $i++;
1526 1526
         }
1527 1527
         // if $this->_nav_tabs is empty then lets set the default
1528 1528
         if (empty($this->_nav_tabs)) {
1529
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1529
+            $this->_nav_tabs[$this->_default_nav_tab_name] = [
1530 1530
                 'url'       => $this->_admin_base_url,
1531 1531
                 'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1532 1532
                 'css_class' => 'nav-tab-active',
@@ -1551,10 +1551,10 @@  discard block
 block discarded – undo
1551 1551
             foreach ($this->_route_config['labels'] as $label => $text) {
1552 1552
                 if (is_array($text)) {
1553 1553
                     foreach ($text as $sublabel => $subtext) {
1554
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1554
+                        $this->_labels[$label][$sublabel] = $subtext;
1555 1555
                     }
1556 1556
                 } else {
1557
-                    $this->_labels[ $label ] = $text;
1557
+                    $this->_labels[$label] = $text;
1558 1558
                 }
1559 1559
             }
1560 1560
         }
@@ -1576,12 +1576,12 @@  discard block
 block discarded – undo
1576 1576
     {
1577 1577
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1578 1578
         $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1579
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1579
+        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1580 1580
                           && is_array(
1581
-                              $this->_page_routes[ $route_to_check ]
1581
+                              $this->_page_routes[$route_to_check]
1582 1582
                           )
1583
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1584
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1583
+                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1584
+            ? $this->_page_routes[$route_to_check]['capability'] : null;
1585 1585
         if (empty($capability) && empty($route_to_check)) {
1586 1586
             $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1587 1587
                 : $this->_route['capability'];
@@ -1706,7 +1706,7 @@  discard block
 block discarded – undo
1706 1706
         //     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1707 1707
         // }
1708 1708
         // current set timezone for timezone js
1709
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1709
+        echo '<span id="current_timezone" class="hidden">'.esc_html(EEH_DTT_Helper::get_timezone()).'</span>';
1710 1710
     }
1711 1711
 
1712 1712
 
@@ -1740,7 +1740,7 @@  discard block
 block discarded – undo
1740 1740
         // loop through the array and setup content
1741 1741
         foreach ($help_array as $trigger => $help) {
1742 1742
             // make sure the array is setup properly
1743
-            if (! isset($help['title']) || ! isset($help['content'])) {
1743
+            if ( ! isset($help['title']) || ! isset($help['content'])) {
1744 1744
                 throw new EE_Error(
1745 1745
                     esc_html__(
1746 1746
                         'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
@@ -1754,8 +1754,8 @@  discard block
 block discarded – undo
1754 1754
                 'help_popup_title'   => $help['title'],
1755 1755
                 'help_popup_content' => $help['content'],
1756 1756
             ];
1757
-            $content       .= EEH_Template::display_template(
1758
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1757
+            $content .= EEH_Template::display_template(
1758
+                EE_ADMIN_TEMPLATE.'admin_help_popup.template.php',
1759 1759
                 $template_args,
1760 1760
                 true
1761 1761
             );
@@ -1777,15 +1777,15 @@  discard block
 block discarded – undo
1777 1777
     private function _get_help_content()
1778 1778
     {
1779 1779
         // what is the method we're looking for?
1780
-        $method_name = '_help_popup_content_' . $this->_req_action;
1780
+        $method_name = '_help_popup_content_'.$this->_req_action;
1781 1781
         // if method doesn't exist let's get out.
1782
-        if (! method_exists($this, $method_name)) {
1782
+        if ( ! method_exists($this, $method_name)) {
1783 1783
             return [];
1784 1784
         }
1785 1785
         // k we're good to go let's retrieve the help array
1786 1786
         $help_array = call_user_func([$this, $method_name]);
1787 1787
         // make sure we've got an array!
1788
-        if (! is_array($help_array)) {
1788
+        if ( ! is_array($help_array)) {
1789 1789
             throw new EE_Error(
1790 1790
                 esc_html__(
1791 1791
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1817,15 +1817,15 @@  discard block
 block discarded – undo
1817 1817
         // let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1818 1818
         $help_array   = $this->_get_help_content();
1819 1819
         $help_content = '';
1820
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1821
-            $help_array[ $trigger_id ] = [
1820
+        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1821
+            $help_array[$trigger_id] = [
1822 1822
                 'title'   => esc_html__('Missing Content', 'event_espresso'),
1823 1823
                 'content' => esc_html__(
1824 1824
                     'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1825 1825
                     'event_espresso'
1826 1826
                 ),
1827 1827
             ];
1828
-            $help_content              = $this->_set_help_popup_content($help_array, false);
1828
+            $help_content = $this->_set_help_popup_content($help_array, false);
1829 1829
         }
1830 1830
         // let's setup the trigger
1831 1831
         $content = '<a class="ee-dialog" href="?height='
@@ -1893,15 +1893,15 @@  discard block
 block discarded – undo
1893 1893
         // register all styles
1894 1894
         wp_register_style(
1895 1895
             'espresso-ui-theme',
1896
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1896
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1897 1897
             [],
1898 1898
             EVENT_ESPRESSO_VERSION
1899 1899
         );
1900
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1900
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1901 1901
         // helpers styles
1902 1902
         wp_register_style(
1903 1903
             'ee-text-links',
1904
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1904
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css',
1905 1905
             [],
1906 1906
             EVENT_ESPRESSO_VERSION
1907 1907
         );
@@ -1909,21 +1909,21 @@  discard block
 block discarded – undo
1909 1909
         // register all scripts
1910 1910
         wp_register_script(
1911 1911
             'ee-dialog',
1912
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1912
+            EE_ADMIN_URL.'assets/ee-dialog-helper.js',
1913 1913
             ['jquery', 'jquery-ui-draggable'],
1914 1914
             EVENT_ESPRESSO_VERSION,
1915 1915
             true
1916 1916
         );
1917 1917
         wp_register_script(
1918 1918
             'ee_admin_js',
1919
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1919
+            EE_ADMIN_URL.'assets/ee-admin-page.js',
1920 1920
             ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1921 1921
             EVENT_ESPRESSO_VERSION,
1922 1922
             true
1923 1923
         );
1924 1924
         wp_register_script(
1925 1925
             'jquery-ui-timepicker-addon',
1926
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1926
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js',
1927 1927
             ['jquery-ui-datepicker', 'jquery-ui-slider'],
1928 1928
             EVENT_ESPRESSO_VERSION,
1929 1929
             true
@@ -1935,7 +1935,7 @@  discard block
 block discarded – undo
1935 1935
         // script for sorting tables
1936 1936
         wp_register_script(
1937 1937
             'espresso_ajax_table_sorting',
1938
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1938
+            EE_ADMIN_URL.'assets/espresso_ajax_table_sorting.js',
1939 1939
             ['ee_admin_js', 'jquery-ui-sortable'],
1940 1940
             EVENT_ESPRESSO_VERSION,
1941 1941
             true
@@ -1943,7 +1943,7 @@  discard block
 block discarded – undo
1943 1943
         // script for parsing uri's
1944 1944
         wp_register_script(
1945 1945
             'ee-parse-uri',
1946
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1946
+            EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js',
1947 1947
             [],
1948 1948
             EVENT_ESPRESSO_VERSION,
1949 1949
             true
@@ -1951,7 +1951,7 @@  discard block
 block discarded – undo
1951 1951
         // and parsing associative serialized form elements
1952 1952
         wp_register_script(
1953 1953
             'ee-serialize-full-array',
1954
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1954
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js',
1955 1955
             ['jquery'],
1956 1956
             EVENT_ESPRESSO_VERSION,
1957 1957
             true
@@ -1959,28 +1959,28 @@  discard block
 block discarded – undo
1959 1959
         // helpers scripts
1960 1960
         wp_register_script(
1961 1961
             'ee-text-links',
1962
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1962
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js',
1963 1963
             ['jquery'],
1964 1964
             EVENT_ESPRESSO_VERSION,
1965 1965
             true
1966 1966
         );
1967 1967
         wp_register_script(
1968 1968
             'ee-moment-core',
1969
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1969
+            EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js',
1970 1970
             [],
1971 1971
             EVENT_ESPRESSO_VERSION,
1972 1972
             true
1973 1973
         );
1974 1974
         wp_register_script(
1975 1975
             'ee-moment',
1976
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1976
+            EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js',
1977 1977
             ['ee-moment-core'],
1978 1978
             EVENT_ESPRESSO_VERSION,
1979 1979
             true
1980 1980
         );
1981 1981
         wp_register_script(
1982 1982
             'ee-datepicker',
1983
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1983
+            EE_ADMIN_URL.'assets/ee-datepicker.js',
1984 1984
             ['jquery-ui-timepicker-addon', 'ee-moment'],
1985 1985
             EVENT_ESPRESSO_VERSION,
1986 1986
             true
@@ -2041,7 +2041,7 @@  discard block
 block discarded – undo
2041 2041
 
2042 2042
         add_filter(
2043 2043
             'admin_body_class',
2044
-            function ($classes) {
2044
+            function($classes) {
2045 2045
                 if (strpos($classes, 'espresso-admin') === false) {
2046 2046
                     $classes .= ' espresso-admin';
2047 2047
                 }
@@ -2129,12 +2129,12 @@  discard block
 block discarded – undo
2129 2129
     protected function _set_list_table()
2130 2130
     {
2131 2131
         // first is this a list_table view?
2132
-        if (! isset($this->_route_config['list_table'])) {
2132
+        if ( ! isset($this->_route_config['list_table'])) {
2133 2133
             return;
2134 2134
         } //not a list_table view so get out.
2135 2135
         // list table functions are per view specific (because some admin pages might have more than one list table!)
2136
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2137
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2136
+        $list_table_view = '_set_list_table_views_'.$this->_req_action;
2137
+        if ( ! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2138 2138
             // user error msg
2139 2139
             $error_msg = esc_html__(
2140 2140
                 'An error occurred. The requested list table views could not be found.',
@@ -2154,10 +2154,10 @@  discard block
 block discarded – undo
2154 2154
         }
2155 2155
         // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2156 2156
         $this->_views = apply_filters(
2157
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2157
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
2158 2158
             $this->_views
2159 2159
         );
2160
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2160
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
2161 2161
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2162 2162
         $this->_set_list_table_view();
2163 2163
         $this->_set_list_table_object();
@@ -2192,7 +2192,7 @@  discard block
 block discarded – undo
2192 2192
     protected function _set_list_table_object()
2193 2193
     {
2194 2194
         if (isset($this->_route_config['list_table'])) {
2195
-            if (! class_exists($this->_route_config['list_table'])) {
2195
+            if ( ! class_exists($this->_route_config['list_table'])) {
2196 2196
                 throw new EE_Error(
2197 2197
                     sprintf(
2198 2198
                         esc_html__(
@@ -2230,15 +2230,15 @@  discard block
 block discarded – undo
2230 2230
         foreach ($this->_views as $key => $view) {
2231 2231
             $query_args = [];
2232 2232
             // check for current view
2233
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2233
+            $this->_views[$key]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2234 2234
             $query_args['action']                        = $this->_req_action;
2235
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2235
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2236 2236
             $query_args['status']                        = $view['slug'];
2237 2237
             // merge any other arguments sent in.
2238
-            if (isset($extra_query_args[ $view['slug'] ])) {
2239
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2238
+            if (isset($extra_query_args[$view['slug']])) {
2239
+                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2240 2240
             }
2241
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2241
+            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2242 2242
         }
2243 2243
         return $this->_views;
2244 2244
     }
@@ -2269,14 +2269,14 @@  discard block
 block discarded – undo
2269 2269
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2270 2270
         foreach ($values as $value) {
2271 2271
             if ($value < $max_entries) {
2272
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2272
+                $selected = $value === $per_page ? ' selected="'.$per_page.'"' : '';
2273 2273
                 $entries_per_page_dropdown .= '
2274
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2274
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2275 2275
             }
2276 2276
         }
2277
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2277
+        $selected = $max_entries === $per_page ? ' selected="'.$per_page.'"' : '';
2278 2278
         $entries_per_page_dropdown .= '
2279
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2279
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2280 2280
         $entries_per_page_dropdown .= '
2281 2281
 					</select>
2282 2282
 					entries
@@ -2300,7 +2300,7 @@  discard block
 block discarded – undo
2300 2300
             empty($this->_search_btn_label) ? $this->page_label
2301 2301
                 : $this->_search_btn_label
2302 2302
         );
2303
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2303
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2304 2304
     }
2305 2305
 
2306 2306
 
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
             $total_columns                                       = ! empty($screen_columns)
2389 2389
                 ? $screen_columns
2390 2390
                 : $this->_route_config['columns'][1];
2391
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2391
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2392 2392
             $this->_template_args['current_page']                = $this->_wp_page_slug;
2393 2393
             $this->_template_args['screen']                      = $this->_current_screen;
2394 2394
             $this->_column_template_path                         = EE_ADMIN_TEMPLATE
@@ -2433,7 +2433,7 @@  discard block
 block discarded – undo
2433 2433
      */
2434 2434
     protected function _espresso_ratings_request()
2435 2435
     {
2436
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2436
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2437 2437
             return;
2438 2438
         }
2439 2439
         $ratings_box_title = apply_filters(
@@ -2461,7 +2461,7 @@  discard block
 block discarded – undo
2461 2461
     public function espresso_ratings_request()
2462 2462
     {
2463 2463
         EEH_Template::display_template(
2464
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2464
+            EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php',
2465 2465
             []
2466 2466
         );
2467 2467
     }
@@ -2469,22 +2469,22 @@  discard block
 block discarded – undo
2469 2469
 
2470 2470
     public static function cached_rss_display($rss_id, $url)
2471 2471
     {
2472
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2472
+        $loading = '<p class="widget-loading hide-if-no-js">'
2473 2473
                      . esc_html__('Loading&#8230;', 'event_espresso')
2474 2474
                      . '</p><p class="hide-if-js">'
2475 2475
                      . esc_html__('This widget requires JavaScript.', 'event_espresso')
2476 2476
                      . '</p>';
2477
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2478
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2479
-        $post      = '</div>' . "\n";
2480
-        $cache_key = 'ee_rss_' . md5($rss_id);
2477
+        $pre       = '<div class="espresso-rss-display">'."\n\t";
2478
+        $pre .= '<span id="'.esc_attr($rss_id).'_url" class="hidden">'.esc_url_raw($url).'</span>';
2479
+        $post      = '</div>'."\n";
2480
+        $cache_key = 'ee_rss_'.md5($rss_id);
2481 2481
         $output    = get_transient($cache_key);
2482 2482
         if ($output !== false) {
2483
-            echo $pre . $output . $post; // already escaped
2483
+            echo $pre.$output.$post; // already escaped
2484 2484
             return true;
2485 2485
         }
2486
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2487
-            echo $pre . $loading . $post; // already escaped
2486
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
2487
+            echo $pre.$loading.$post; // already escaped
2488 2488
             return false;
2489 2489
         }
2490 2490
         ob_start();
@@ -2551,19 +2551,19 @@  discard block
 block discarded – undo
2551 2551
     public function espresso_sponsors_post_box()
2552 2552
     {
2553 2553
         EEH_Template::display_template(
2554
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2554
+            EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'
2555 2555
         );
2556 2556
     }
2557 2557
 
2558 2558
 
2559 2559
     private function _publish_post_box()
2560 2560
     {
2561
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2561
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2562 2562
         // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2563 2563
         // then we'll use that for the metabox label.
2564 2564
         // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2565
-        if (! empty($this->_labels['publishbox'])) {
2566
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2565
+        if ( ! empty($this->_labels['publishbox'])) {
2566
+            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2567 2567
                 : $this->_labels['publishbox'];
2568 2568
         } else {
2569 2569
             $box_label = esc_html__('Publish', 'event_espresso');
@@ -2592,7 +2592,7 @@  discard block
 block discarded – undo
2592 2592
             ? $this->_template_args['publish_box_extra_content']
2593 2593
             : '';
2594 2594
         echo EEH_Template::display_template(
2595
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2595
+            EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php',
2596 2596
             $this->_template_args,
2597 2597
             true
2598 2598
         );
@@ -2684,18 +2684,18 @@  discard block
 block discarded – undo
2684 2684
             );
2685 2685
         }
2686 2686
         $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2687
-        if (! empty($name) && ! empty($id)) {
2688
-            $hidden_field_arr[ $name ] = [
2687
+        if ( ! empty($name) && ! empty($id)) {
2688
+            $hidden_field_arr[$name] = [
2689 2689
                 'type'  => 'hidden',
2690 2690
                 'value' => $id,
2691 2691
             ];
2692
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2692
+            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2693 2693
         } else {
2694 2694
             $hf = '';
2695 2695
         }
2696 2696
         // add hidden field
2697 2697
         $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2698
-            ? $hf[ $name ]['field']
2698
+            ? $hf[$name]['field']
2699 2699
             : $hf;
2700 2700
     }
2701 2701
 
@@ -2797,7 +2797,7 @@  discard block
 block discarded – undo
2797 2797
         }
2798 2798
         // if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2799 2799
         $call_back_func = $create_func
2800
-            ? function ($post, $metabox) {
2800
+            ? function($post, $metabox) {
2801 2801
                 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2802 2802
                 echo EEH_Template::display_template(
2803 2803
                     $metabox['args']['template_path'],
@@ -2807,7 +2807,7 @@  discard block
 block discarded – undo
2807 2807
             }
2808 2808
             : $callback;
2809 2809
         add_meta_box(
2810
-            str_replace('_', '-', $action) . '-mbox',
2810
+            str_replace('_', '-', $action).'-mbox',
2811 2811
             $title,
2812 2812
             $call_back_func,
2813 2813
             $this->_wp_page_slug,
@@ -2899,9 +2899,9 @@  discard block
 block discarded – undo
2899 2899
             : 'espresso-default-admin';
2900 2900
         $template_path                                     = $sidebar
2901 2901
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2902
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2902
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2903 2903
         if ($this->request->isAjax()) {
2904
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2904
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2905 2905
         }
2906 2906
         $template_path                                     = ! empty($this->_column_template_path)
2907 2907
             ? $this->_column_template_path : $template_path;
@@ -2941,11 +2941,11 @@  discard block
 block discarded – undo
2941 2941
     public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2942 2942
     {
2943 2943
         // let's generate a default preview action button if there isn't one already present.
2944
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2944
+        $this->_labels['buttons']['buy_now'] = esc_html__(
2945 2945
             'Upgrade to Event Espresso 4 Right Now',
2946 2946
             'event_espresso'
2947 2947
         );
2948
-        $buy_now_url                                   = add_query_arg(
2948
+        $buy_now_url = add_query_arg(
2949 2949
             [
2950 2950
                 'ee_ver'       => 'ee4',
2951 2951
                 'utm_source'   => 'ee4_plugin_admin',
@@ -2965,8 +2965,8 @@  discard block
 block discarded – undo
2965 2965
                 true
2966 2966
             )
2967 2967
             : $this->_template_args['preview_action_button'];
2968
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2969
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2968
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2969
+            EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php',
2970 2970
             $this->_template_args,
2971 2971
             true
2972 2972
         );
@@ -3015,7 +3015,7 @@  discard block
 block discarded – undo
3015 3015
         // setup search attributes
3016 3016
         $this->_set_search_attributes();
3017 3017
         $this->_template_args['current_page']     = $this->_wp_page_slug;
3018
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3018
+        $template_path                            = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
3019 3019
         $this->_template_args['table_url']        = $this->request->isAjax()
3020 3020
             ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3021 3021
             : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
@@ -3023,10 +3023,10 @@  discard block
 block discarded – undo
3023 3023
         $this->_template_args['current_route']    = $this->_req_action;
3024 3024
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3025 3025
         $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3026
-        if (! empty($ajax_sorting_callback)) {
3026
+        if ( ! empty($ajax_sorting_callback)) {
3027 3027
             $sortable_list_table_form_fields = wp_nonce_field(
3028
-                $ajax_sorting_callback . '_nonce',
3029
-                $ajax_sorting_callback . '_nonce',
3028
+                $ajax_sorting_callback.'_nonce',
3029
+                $ajax_sorting_callback.'_nonce',
3030 3030
                 false,
3031 3031
                 false
3032 3032
             );
@@ -3044,20 +3044,20 @@  discard block
 block discarded – undo
3044 3044
             isset($this->_template_args['list_table_hidden_fields'])
3045 3045
                 ? $this->_template_args['list_table_hidden_fields']
3046 3046
                 : '';
3047
-        $nonce_ref                                               = $this->_req_action . '_nonce';
3048
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
3047
+        $nonce_ref = $this->_req_action.'_nonce';
3048
+        $hidden_form_fields .= '<input type="hidden" name="'
3049 3049
                                                                     . $nonce_ref
3050 3050
                                                                     . '" value="'
3051 3051
                                                                     . wp_create_nonce($nonce_ref)
3052 3052
                                                                     . '">';
3053
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3053
+        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3054 3054
         // display message about search results?
3055 3055
         $search = $this->request->getRequestParam('s');
3056 3056
         $this->_template_args['before_list_table'] .= ! empty($search)
3057
-            ? '<p class="ee-search-results">' . sprintf(
3057
+            ? '<p class="ee-search-results">'.sprintf(
3058 3058
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3059 3059
                 trim($search, '%')
3060
-            ) . '</p>'
3060
+            ).'</p>'
3061 3061
             : '';
3062 3062
         // filter before_list_table template arg
3063 3063
         $this->_template_args['before_list_table'] = apply_filters(
@@ -3091,7 +3091,7 @@  discard block
 block discarded – undo
3091 3091
         // convert to array and filter again
3092 3092
         // arrays are easier to inject new items in a specific location,
3093 3093
         // but would not be backwards compatible, so we have to add a new filter
3094
-        $this->_template_args['after_list_table']   = implode(
3094
+        $this->_template_args['after_list_table'] = implode(
3095 3095
             " \n",
3096 3096
             (array) apply_filters(
3097 3097
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
@@ -3138,7 +3138,7 @@  discard block
 block discarded – undo
3138 3138
             $this
3139 3139
         );
3140 3140
         return EEH_Template::display_template(
3141
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3141
+            EE_ADMIN_TEMPLATE.'admin_details_legend.template.php',
3142 3142
             $this->_template_args,
3143 3143
             true
3144 3144
         );
@@ -3245,17 +3245,17 @@  discard block
 block discarded – undo
3245 3245
                 ? $this->_template_args['before_admin_page_content']
3246 3246
                 : ''
3247 3247
         );
3248
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3248
+        $this->_template_args['after_admin_page_content'] = apply_filters(
3249 3249
             "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3250 3250
             isset($this->_template_args['after_admin_page_content'])
3251 3251
                 ? $this->_template_args['after_admin_page_content']
3252 3252
                 : ''
3253 3253
         );
3254
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3254
+        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3255 3255
         // load settings page wrapper template
3256 3256
         $template_path = ! $this->request->isAjax()
3257 3257
             ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3258
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
3258
+            : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php';
3259 3259
         // about page?
3260 3260
         $template_path = $about
3261 3261
             ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
@@ -3349,7 +3349,7 @@  discard block
 block discarded – undo
3349 3349
             : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3350 3350
               . $referrer
3351 3351
               . '" />';
3352
-        $button_text   = ! empty($text)
3352
+        $button_text = ! empty($text)
3353 3353
             ? $text
3354 3354
             : [
3355 3355
                 esc_html__('Save', 'event_espresso'),
@@ -3359,17 +3359,17 @@  discard block
 block discarded – undo
3359 3359
         // add in a hidden index for the current page (so save and close redirects properly)
3360 3360
         $this->_template_args['save_buttons'] = $referrer_url;
3361 3361
         foreach ($button_text as $key => $button) {
3362
-            $ref                                  = $default_names[ $key ];
3362
+            $ref = $default_names[$key];
3363 3363
             $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3364 3364
                                                      . $ref
3365 3365
                                                      . '" value="'
3366 3366
                                                      . $button
3367 3367
                                                      . '" name="'
3368
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3368
+                                                     . ( ! empty($actions) ? $actions[$key] : $ref)
3369 3369
                                                      . '" id="'
3370
-                                                     . $this->_current_view . '_' . $ref
3370
+                                                     . $this->_current_view.'_'.$ref
3371 3371
                                                      . '" />';
3372
-            if (! $both) {
3372
+            if ( ! $both) {
3373 3373
                 break;
3374 3374
             }
3375 3375
         }
@@ -3404,13 +3404,13 @@  discard block
 block discarded – undo
3404 3404
                 'An error occurred. No action was set for this page\'s form.',
3405 3405
                 'event_espresso'
3406 3406
             );
3407
-            $dev_msg  = $user_msg . "\n"
3407
+            $dev_msg = $user_msg."\n"
3408 3408
                         . sprintf(
3409 3409
                             esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3410 3410
                             __FUNCTION__,
3411 3411
                             __CLASS__
3412 3412
                         );
3413
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3413
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3414 3414
         }
3415 3415
         // open form
3416 3416
         $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
@@ -3419,9 +3419,9 @@  discard block
 block discarded – undo
3419 3419
                                                              . $route
3420 3420
                                                              . '_event_form" >';
3421 3421
         // add nonce
3422
-        $nonce                                             =
3423
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3424
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3422
+        $nonce =
3423
+            wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3424
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3425 3425
         // add REQUIRED form action
3426 3426
         $hidden_fields = [
3427 3427
             'action' => ['type' => 'hidden', 'value' => $route],
@@ -3434,7 +3434,7 @@  discard block
 block discarded – undo
3434 3434
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3435 3435
         // add fields to form
3436 3436
         foreach ((array) $form_fields as $field_name => $form_field) {
3437
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3437
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3438 3438
         }
3439 3439
         // close form
3440 3440
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3525,10 +3525,10 @@  discard block
 block discarded – undo
3525 3525
         $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3526 3526
         $notices      = EE_Error::get_notices(false);
3527 3527
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3528
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3528
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3529 3529
             EE_Error::overwrite_success();
3530 3530
         }
3531
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3531
+        if ( ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3532 3532
             // how many records affected ? more than one record ? or just one ?
3533 3533
             if ($success > 1) {
3534 3534
                 // set plural msg
@@ -3557,7 +3557,7 @@  discard block
 block discarded – undo
3557 3557
             }
3558 3558
         }
3559 3559
         // check that $query_args isn't something crazy
3560
-        if (! is_array($query_args)) {
3560
+        if ( ! is_array($query_args)) {
3561 3561
             $query_args = [];
3562 3562
         }
3563 3563
         /**
@@ -3586,7 +3586,7 @@  discard block
 block discarded – undo
3586 3586
             $redirect_url = admin_url('admin.php');
3587 3587
         }
3588 3588
         // merge any default query_args set in _default_route_query_args property
3589
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3589
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3590 3590
             $args_to_merge = [];
3591 3591
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3592 3592
                 // is there a wp_referer array in our _default_route_query_args property?
@@ -3598,15 +3598,15 @@  discard block
 block discarded – undo
3598 3598
                         }
3599 3599
                         // finally we will override any arguments in the referer with
3600 3600
                         // what might be set on the _default_route_query_args array.
3601
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3602
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3601
+                        if (isset($this->_default_route_query_args[$reference])) {
3602
+                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3603 3603
                         } else {
3604
-                            $args_to_merge[ $reference ] = urlencode($value);
3604
+                            $args_to_merge[$reference] = urlencode($value);
3605 3605
                         }
3606 3606
                     }
3607 3607
                     continue;
3608 3608
                 }
3609
-                $args_to_merge[ $query_param ] = $query_value;
3609
+                $args_to_merge[$query_param] = $query_value;
3610 3610
             }
3611 3611
             // now let's merge these arguments but override with what was specifically sent in to the
3612 3612
             // redirect.
@@ -3618,19 +3618,19 @@  discard block
 block discarded – undo
3618 3618
         if (isset($query_args['action'])) {
3619 3619
             // manually generate wp_nonce and merge that with the query vars
3620 3620
             // becuz the wp_nonce_url function wrecks havoc on some vars
3621
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3621
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3622 3622
         }
3623 3623
         // we're adding some hooks and filters in here for processing any things just before redirects
3624 3624
         // (example: an admin page has done an insert or update and we want to run something after that).
3625
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3625
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
3626 3626
         $redirect_url = apply_filters(
3627
-            'FHEE_redirect_' . $classname . $this->_req_action,
3627
+            'FHEE_redirect_'.$classname.$this->_req_action,
3628 3628
             self::add_query_args_and_nonce($query_args, $redirect_url),
3629 3629
             $query_args
3630 3630
         );
3631 3631
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3632 3632
         if ($this->request->isAjax()) {
3633
-            $default_data                    = [
3633
+            $default_data = [
3634 3634
                 'close'        => true,
3635 3635
                 'redirect_url' => $redirect_url,
3636 3636
                 'where'        => 'main',
@@ -3677,7 +3677,7 @@  discard block
 block discarded – undo
3677 3677
         }
3678 3678
         $this->_template_args['notices'] = EE_Error::get_notices();
3679 3679
         // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3680
-        if (! $this->request->isAjax() || $sticky_notices) {
3680
+        if ( ! $this->request->isAjax() || $sticky_notices) {
3681 3681
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3682 3682
             $this->_add_transient(
3683 3683
                 $route,
@@ -3717,7 +3717,7 @@  discard block
 block discarded – undo
3717 3717
         $exclude_nonce = false
3718 3718
     ) {
3719 3719
         // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3720
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3720
+        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3721 3721
             throw new EE_Error(
3722 3722
                 sprintf(
3723 3723
                     esc_html__(
@@ -3728,7 +3728,7 @@  discard block
 block discarded – undo
3728 3728
                 )
3729 3729
             );
3730 3730
         }
3731
-        if (! isset($this->_labels['buttons'][ $type ])) {
3731
+        if ( ! isset($this->_labels['buttons'][$type])) {
3732 3732
             throw new EE_Error(
3733 3733
                 sprintf(
3734 3734
                     esc_html__(
@@ -3741,7 +3741,7 @@  discard block
 block discarded – undo
3741 3741
         }
3742 3742
         // finally check user access for this button.
3743 3743
         $has_access = $this->check_user_access($action, true);
3744
-        if (! $has_access) {
3744
+        if ( ! $has_access) {
3745 3745
             return '';
3746 3746
         }
3747 3747
         $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3749,11 +3749,11 @@  discard block
 block discarded – undo
3749 3749
             'action' => $action,
3750 3750
         ];
3751 3751
         // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3752
-        if (! empty($extra_request)) {
3752
+        if ( ! empty($extra_request)) {
3753 3753
             $query_args = array_merge($extra_request, $query_args);
3754 3754
         }
3755 3755
         $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3756
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3756
+        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3757 3757
     }
3758 3758
 
3759 3759
 
@@ -3779,7 +3779,7 @@  discard block
 block discarded – undo
3779 3779
                 'FHEE__EE_Admin_Page___per_page_screen_options__default',
3780 3780
                 20
3781 3781
             ),
3782
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3782
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3783 3783
         ];
3784 3784
         // ONLY add the screen option if the user has access to it.
3785 3785
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3800,18 +3800,18 @@  discard block
 block discarded – undo
3800 3800
     {
3801 3801
         if ($this->request->requestParamIsSet('wp_screen_options')) {
3802 3802
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3803
-            if (! $user = wp_get_current_user()) {
3803
+            if ( ! $user = wp_get_current_user()) {
3804 3804
                 return;
3805 3805
             }
3806 3806
             $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3807
-            if (! $option) {
3807
+            if ( ! $option) {
3808 3808
                 return;
3809 3809
             }
3810
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3810
+            $value = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3811 3811
             $map_option = $option;
3812 3812
             $option     = str_replace('-', '_', $option);
3813 3813
             switch ($map_option) {
3814
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3814
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3815 3815
                     $max_value = apply_filters(
3816 3816
                         'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3817 3817
                         999,
@@ -3868,13 +3868,13 @@  discard block
 block discarded – undo
3868 3868
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3869 3869
     {
3870 3870
         $user_id = get_current_user_id();
3871
-        if (! $skip_route_verify) {
3871
+        if ( ! $skip_route_verify) {
3872 3872
             $this->_verify_route($route);
3873 3873
         }
3874 3874
         // now let's set the string for what kind of transient we're setting
3875 3875
         $transient = $notices
3876
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3877
-            : 'rte_tx_' . $route . '_' . $user_id;
3876
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3877
+            : 'rte_tx_'.$route.'_'.$user_id;
3878 3878
         $data      = $notices ? ['notices' => $data] : $data;
3879 3879
         // is there already a transient for this route?  If there is then let's ADD to that transient
3880 3880
         $existing = is_multisite() && is_network_admin()
@@ -3903,8 +3903,8 @@  discard block
 block discarded – undo
3903 3903
         $user_id   = get_current_user_id();
3904 3904
         $route     = ! $route ? $this->_req_action : $route;
3905 3905
         $transient = $notices
3906
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3907
-            : 'rte_tx_' . $route . '_' . $user_id;
3906
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3907
+            : 'rte_tx_'.$route.'_'.$user_id;
3908 3908
         $data      = is_multisite() && is_network_admin()
3909 3909
             ? get_site_transient($transient)
3910 3910
             : get_transient($transient);
@@ -4135,7 +4135,7 @@  discard block
 block discarded – undo
4135 4135
      */
4136 4136
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4137 4137
     {
4138
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4138
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4139 4139
     }
4140 4140
 
4141 4141
 
@@ -4148,7 +4148,7 @@  discard block
 block discarded – undo
4148 4148
      */
4149 4149
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4150 4150
     {
4151
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4151
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4152 4152
     }
4153 4153
 
4154 4154
 
Please login to merge, or discard this patch.
core/admin/EE_Admin_List_Table.core.php 1 patch
Indentation   +860 added lines, -860 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (! class_exists('WP_List_Table')) {
4
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
4
+	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
5 5
 }
6 6
 
7 7
 
@@ -20,873 +20,873 @@  discard block
 block discarded – undo
20 20
 abstract class EE_Admin_List_Table extends WP_List_Table
21 21
 {
22 22
 
23
-    /**
24
-     * holds the data that will be processed for the table
25
-     *
26
-     * @var array $_data
27
-     */
28
-    protected $_data;
29
-
30
-
31
-    /**
32
-     * This holds the value of all the data available for the given view (for all pages).
33
-     *
34
-     * @var int $_all_data_count
35
-     */
36
-    protected $_all_data_count;
37
-
38
-
39
-    /**
40
-     * Will contain the count of trashed items for the view label.
41
-     *
42
-     * @var int $_trashed_count
43
-     */
44
-    protected $_trashed_count;
45
-
46
-
47
-    /**
48
-     * This is what will be referenced as the slug for the current screen
49
-     *
50
-     * @var string $_screen
51
-     */
52
-    protected $_screen;
53
-
54
-
55
-    /**
56
-     * this is the EE_Admin_Page object
57
-     *
58
-     * @var EE_Admin_Page $_admin_page
59
-     */
60
-    protected $_admin_page;
61
-
62
-
63
-    /**
64
-     * The current view
65
-     *
66
-     * @var string $_view
67
-     */
68
-    protected $_view;
69
-
70
-
71
-    /**
72
-     * array of possible views for this table
73
-     *
74
-     * @var array $_views
75
-     */
76
-    protected $_views;
77
-
78
-
79
-    /**
80
-     * An array of key => value pairs containing information about the current table
81
-     * array(
82
-     *        'plural' => 'plural label',
83
-     *        'singular' => 'singular label',
84
-     *        'ajax' => false, //whether to use ajax or not
85
-     *        'screen' => null, //string used to reference what screen this is
86
-     *        (WP_List_table converts to screen object)
87
-     * )
88
-     *
89
-     * @var array $_wp_list_args
90
-     */
91
-    protected $_wp_list_args;
92
-
93
-    /**
94
-     * an array of column names
95
-     * array(
96
-     *    'internal-name' => 'Title'
97
-     * )
98
-     *
99
-     * @var array $_columns
100
-     */
101
-    protected $_columns;
102
-
103
-    /**
104
-     * An array of sortable columns
105
-     * array(
106
-     *    'internal-name' => 'orderby' //or
107
-     *    'internal-name' => array( 'orderby', true )
108
-     * )
109
-     *
110
-     * @var array $_sortable_columns
111
-     */
112
-    protected $_sortable_columns;
113
-
114
-    /**
115
-     * callback method used to perform AJAX row reordering
116
-     *
117
-     * @var string $_ajax_sorting_callback
118
-     */
119
-    protected $_ajax_sorting_callback;
120
-
121
-    /**
122
-     * An array of hidden columns (if needed)
123
-     * array('internal-name', 'internal-name')
124
-     *
125
-     * @var array $_hidden_columns
126
-     */
127
-    protected $_hidden_columns;
128
-
129
-    /**
130
-     * holds the per_page value
131
-     *
132
-     * @var int $_per_page
133
-     */
134
-    protected $_per_page;
135
-
136
-    /**
137
-     * holds what page number is currently being viewed
138
-     *
139
-     * @var int $_current_page
140
-     */
141
-    protected $_current_page;
142
-
143
-    /**
144
-     * the reference string for the nonce_action
145
-     *
146
-     * @var string $_nonce_action_ref
147
-     */
148
-    protected $_nonce_action_ref;
149
-
150
-    /**
151
-     * property to hold incoming request data (as set by the admin_page_core)
152
-     *
153
-     * @var array $_req_data
154
-     */
155
-    protected $_req_data;
156
-
157
-
158
-    /**
159
-     * yes / no array for admin form fields
160
-     *
161
-     * @var array $_yes_no
162
-     */
163
-    protected $_yes_no = [];
164
-
165
-    /**
166
-     * Array describing buttons that should appear at the bottom of the page
167
-     * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
168
-     * and the values are another array with the following keys
169
-     * array(
170
-     *    'route' => 'page_route',
171
-     *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
172
-     * )
173
-     *
174
-     * @var array $_bottom_buttons
175
-     */
176
-    protected $_bottom_buttons = [];
177
-
178
-
179
-    /**
180
-     * Used to indicate what should be the primary column for the list table.
181
-     * If not present then falls back to what WP calculates
182
-     * as the primary column.
183
-     *
184
-     * @type string $_primary_column
185
-     */
186
-    protected $_primary_column = '';
187
-
188
-
189
-    /**
190
-     * Used to indicate whether the table has a checkbox column or not.
191
-     *
192
-     * @type bool $_has_checkbox_column
193
-     */
194
-    protected $_has_checkbox_column = false;
195
-
196
-
197
-    /**
198
-     * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
199
-     */
200
-    public function __construct(EE_Admin_Page $admin_page)
201
-    {
202
-        $this->_admin_page   = $admin_page;
203
-        $this->_req_data     = $this->_admin_page->get_request_data();
204
-        $this->_view         = $this->_admin_page->get_view();
205
-        $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
206
-        $this->_current_page = $this->get_pagenum();
207
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
208
-        $this->_yes_no       = [
209
-            esc_html__('No', 'event_espresso'),
210
-            esc_html__('Yes', 'event_espresso')
211
-        ];
212
-
213
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
214
-
215
-        $this->_setup_data();
216
-        $this->_add_view_counts();
217
-
218
-        $this->_nonce_action_ref = $this->_view;
219
-
220
-        $this->_set_properties();
221
-
222
-        // set primary column
223
-        add_filter('list_table_primary_column', [$this, 'set_primary_column']);
224
-
225
-        // set parent defaults
226
-        parent::__construct($this->_wp_list_args);
227
-
228
-        $this->prepare_items();
229
-    }
230
-
231
-
232
-    /**
233
-     * _setup_data
234
-     * this method is used to setup the $_data, $_all_data_count, and _per_page properties
235
-     *
236
-     * @return void
237
-     * @uses $this->_admin_page
238
-     */
239
-    abstract protected function _setup_data();
240
-
241
-
242
-    /**
243
-     * set the properties that this class needs to be able to execute wp_list_table properly
244
-     * properties set:
245
-     * _wp_list_args = what the arguments required for the parent _wp_list_table.
246
-     * _columns = set the columns in an array.
247
-     * _sortable_columns = columns that are sortable (array).
248
-     * _hidden_columns = columns that are hidden (array)
249
-     * _default_orderby = the default orderby for sorting.
250
-     *
251
-     * @abstract
252
-     * @access protected
253
-     * @return void
254
-     */
255
-    abstract protected function _set_properties();
256
-
257
-
258
-    /**
259
-     * _get_table_filters
260
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
261
-     * gets shown in the table.
262
-     *
263
-     * @abstract
264
-     * @access protected
265
-     * @return string
266
-     */
267
-    abstract protected function _get_table_filters();
268
-
269
-
270
-    /**
271
-     * this is a method that child class will do to add counts to the views array so when views are displayed the
272
-     * counts of the views is accurate.
273
-     *
274
-     * @abstract
275
-     * @access protected
276
-     * @return void
277
-     */
278
-    abstract protected function _add_view_counts();
279
-
280
-
281
-    /**
282
-     * _get_hidden_fields
283
-     * returns a html string of hidden fields so if any table filters are used the current view will be respected.
284
-     *
285
-     * @return string
286
-     */
287
-    protected function _get_hidden_fields()
288
-    {
289
-        $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
290
-        $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
291
-        // if action is STILL empty, then we set it to default
292
-        $action = empty($action) ? 'default' : $action;
293
-        $field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
294
-        $field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
295
-        $field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
296
-
297
-        $bulk_actions = $this->_get_bulk_actions();
298
-        foreach ($bulk_actions as $bulk_action => $label) {
299
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
300
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
301
-        }
302
-
303
-        return $field;
304
-    }
305
-
306
-
307
-    /**
308
-     * _set_column_info
309
-     * we're using this to set the column headers property.
310
-     *
311
-     * @access protected
312
-     * @return void
313
-     */
314
-    protected function _set_column_info()
315
-    {
316
-        $columns   = $this->get_columns();
317
-        $hidden    = $this->get_hidden_columns();
318
-        $_sortable = $this->get_sortable_columns();
319
-
320
-        /**
321
-         * Dynamic hook allowing for adding sortable columns in this list table.
322
-         * Note that $this->screen->id is in the format
323
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
324
-         * table it is: event-espresso_page_espresso_messages.
325
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
326
-         * hook prefix ("event-espresso") will be different.
327
-         *
328
-         * @var array
329
-         */
330
-        $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
331
-
332
-        $sortable = [];
333
-        foreach ($_sortable as $id => $data) {
334
-            if (empty($data)) {
335
-                continue;
336
-            }
337
-            // fix for offset errors with WP_List_Table default get_columninfo()
338
-            if (is_array($data)) {
339
-                $_data[0] = key($data);
340
-                $_data[1] = isset($data[1]) ? $data[1] : false;
341
-            } else {
342
-                $_data[0] = $data;
343
-            }
344
-
345
-            $data = (array) $data;
346
-
347
-            if (! isset($data[1])) {
348
-                $_data[1] = false;
349
-            }
350
-
351
-            $sortable[ $id ] = $_data;
352
-        }
353
-        $primary               = $this->get_primary_column_name();
354
-        $this->_column_headers = [$columns, $hidden, $sortable, $primary];
355
-    }
356
-
357
-
358
-    /**
359
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
360
-     *
361
-     * @return string
362
-     */
363
-    protected function get_primary_column_name()
364
-    {
365
-        foreach (class_parents($this) as $parent) {
366
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
367
-                return parent::get_primary_column_name();
368
-            }
369
-        }
370
-        return $this->_primary_column;
371
-    }
372
-
373
-
374
-    /**
375
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
376
-     *
377
-     * @param EE_Base_Class $item
378
-     * @param string        $column_name
379
-     * @param string        $primary
380
-     * @return string
381
-     */
382
-    protected function handle_row_actions($item, $column_name, $primary)
383
-    {
384
-        foreach (class_parents($this) as $parent) {
385
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
386
-                return parent::handle_row_actions($item, $column_name, $primary);
387
-            }
388
-        }
389
-        return '';
390
-    }
391
-
392
-
393
-    /**
394
-     * _get_bulk_actions
395
-     * This is a wrapper called by WP_List_Table::get_bulk_actions()
396
-     *
397
-     * @access protected
398
-     * @return array bulk_actions
399
-     */
400
-    protected function _get_bulk_actions()
401
-    {
402
-        $actions = [];
403
-        // the _views property should have the bulk_actions, so let's go through and extract them into a properly
404
-        // formatted array for the wp_list_table();
405
-        foreach ($this->_views as $view => $args) {
406
-            if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
407
-                // each bulk action will correspond with a admin page route, so we can check whatever the capability is
408
-                // for that page route and skip adding the bulk action if no access for the current logged in user.
409
-                foreach ($args['bulk_action'] as $route => $label) {
410
-                    if ($this->_admin_page->check_user_access($route, true)) {
411
-                        $actions[ $route ] = $label;
412
-                    }
413
-                }
414
-            }
415
-        }
416
-        return $actions;
417
-    }
418
-
419
-
420
-    /**
421
-     * Generate the table navigation above or below the table.
422
-     * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
423
-     *
424
-     * @throws EE_Error
425
-     * @since 4.9.44.rc.001
426
-     */
427
-    public function display_tablenav($which)
428
-    {
429
-        if ('top' === $which) {
430
-            wp_nonce_field('bulk-' . $this->_args['plural']);
431
-        }
432
-        ?>
23
+	/**
24
+	 * holds the data that will be processed for the table
25
+	 *
26
+	 * @var array $_data
27
+	 */
28
+	protected $_data;
29
+
30
+
31
+	/**
32
+	 * This holds the value of all the data available for the given view (for all pages).
33
+	 *
34
+	 * @var int $_all_data_count
35
+	 */
36
+	protected $_all_data_count;
37
+
38
+
39
+	/**
40
+	 * Will contain the count of trashed items for the view label.
41
+	 *
42
+	 * @var int $_trashed_count
43
+	 */
44
+	protected $_trashed_count;
45
+
46
+
47
+	/**
48
+	 * This is what will be referenced as the slug for the current screen
49
+	 *
50
+	 * @var string $_screen
51
+	 */
52
+	protected $_screen;
53
+
54
+
55
+	/**
56
+	 * this is the EE_Admin_Page object
57
+	 *
58
+	 * @var EE_Admin_Page $_admin_page
59
+	 */
60
+	protected $_admin_page;
61
+
62
+
63
+	/**
64
+	 * The current view
65
+	 *
66
+	 * @var string $_view
67
+	 */
68
+	protected $_view;
69
+
70
+
71
+	/**
72
+	 * array of possible views for this table
73
+	 *
74
+	 * @var array $_views
75
+	 */
76
+	protected $_views;
77
+
78
+
79
+	/**
80
+	 * An array of key => value pairs containing information about the current table
81
+	 * array(
82
+	 *        'plural' => 'plural label',
83
+	 *        'singular' => 'singular label',
84
+	 *        'ajax' => false, //whether to use ajax or not
85
+	 *        'screen' => null, //string used to reference what screen this is
86
+	 *        (WP_List_table converts to screen object)
87
+	 * )
88
+	 *
89
+	 * @var array $_wp_list_args
90
+	 */
91
+	protected $_wp_list_args;
92
+
93
+	/**
94
+	 * an array of column names
95
+	 * array(
96
+	 *    'internal-name' => 'Title'
97
+	 * )
98
+	 *
99
+	 * @var array $_columns
100
+	 */
101
+	protected $_columns;
102
+
103
+	/**
104
+	 * An array of sortable columns
105
+	 * array(
106
+	 *    'internal-name' => 'orderby' //or
107
+	 *    'internal-name' => array( 'orderby', true )
108
+	 * )
109
+	 *
110
+	 * @var array $_sortable_columns
111
+	 */
112
+	protected $_sortable_columns;
113
+
114
+	/**
115
+	 * callback method used to perform AJAX row reordering
116
+	 *
117
+	 * @var string $_ajax_sorting_callback
118
+	 */
119
+	protected $_ajax_sorting_callback;
120
+
121
+	/**
122
+	 * An array of hidden columns (if needed)
123
+	 * array('internal-name', 'internal-name')
124
+	 *
125
+	 * @var array $_hidden_columns
126
+	 */
127
+	protected $_hidden_columns;
128
+
129
+	/**
130
+	 * holds the per_page value
131
+	 *
132
+	 * @var int $_per_page
133
+	 */
134
+	protected $_per_page;
135
+
136
+	/**
137
+	 * holds what page number is currently being viewed
138
+	 *
139
+	 * @var int $_current_page
140
+	 */
141
+	protected $_current_page;
142
+
143
+	/**
144
+	 * the reference string for the nonce_action
145
+	 *
146
+	 * @var string $_nonce_action_ref
147
+	 */
148
+	protected $_nonce_action_ref;
149
+
150
+	/**
151
+	 * property to hold incoming request data (as set by the admin_page_core)
152
+	 *
153
+	 * @var array $_req_data
154
+	 */
155
+	protected $_req_data;
156
+
157
+
158
+	/**
159
+	 * yes / no array for admin form fields
160
+	 *
161
+	 * @var array $_yes_no
162
+	 */
163
+	protected $_yes_no = [];
164
+
165
+	/**
166
+	 * Array describing buttons that should appear at the bottom of the page
167
+	 * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
168
+	 * and the values are another array with the following keys
169
+	 * array(
170
+	 *    'route' => 'page_route',
171
+	 *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
172
+	 * )
173
+	 *
174
+	 * @var array $_bottom_buttons
175
+	 */
176
+	protected $_bottom_buttons = [];
177
+
178
+
179
+	/**
180
+	 * Used to indicate what should be the primary column for the list table.
181
+	 * If not present then falls back to what WP calculates
182
+	 * as the primary column.
183
+	 *
184
+	 * @type string $_primary_column
185
+	 */
186
+	protected $_primary_column = '';
187
+
188
+
189
+	/**
190
+	 * Used to indicate whether the table has a checkbox column or not.
191
+	 *
192
+	 * @type bool $_has_checkbox_column
193
+	 */
194
+	protected $_has_checkbox_column = false;
195
+
196
+
197
+	/**
198
+	 * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
199
+	 */
200
+	public function __construct(EE_Admin_Page $admin_page)
201
+	{
202
+		$this->_admin_page   = $admin_page;
203
+		$this->_req_data     = $this->_admin_page->get_request_data();
204
+		$this->_view         = $this->_admin_page->get_view();
205
+		$this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
206
+		$this->_current_page = $this->get_pagenum();
207
+		$this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
208
+		$this->_yes_no       = [
209
+			esc_html__('No', 'event_espresso'),
210
+			esc_html__('Yes', 'event_espresso')
211
+		];
212
+
213
+		$this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
214
+
215
+		$this->_setup_data();
216
+		$this->_add_view_counts();
217
+
218
+		$this->_nonce_action_ref = $this->_view;
219
+
220
+		$this->_set_properties();
221
+
222
+		// set primary column
223
+		add_filter('list_table_primary_column', [$this, 'set_primary_column']);
224
+
225
+		// set parent defaults
226
+		parent::__construct($this->_wp_list_args);
227
+
228
+		$this->prepare_items();
229
+	}
230
+
231
+
232
+	/**
233
+	 * _setup_data
234
+	 * this method is used to setup the $_data, $_all_data_count, and _per_page properties
235
+	 *
236
+	 * @return void
237
+	 * @uses $this->_admin_page
238
+	 */
239
+	abstract protected function _setup_data();
240
+
241
+
242
+	/**
243
+	 * set the properties that this class needs to be able to execute wp_list_table properly
244
+	 * properties set:
245
+	 * _wp_list_args = what the arguments required for the parent _wp_list_table.
246
+	 * _columns = set the columns in an array.
247
+	 * _sortable_columns = columns that are sortable (array).
248
+	 * _hidden_columns = columns that are hidden (array)
249
+	 * _default_orderby = the default orderby for sorting.
250
+	 *
251
+	 * @abstract
252
+	 * @access protected
253
+	 * @return void
254
+	 */
255
+	abstract protected function _set_properties();
256
+
257
+
258
+	/**
259
+	 * _get_table_filters
260
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
261
+	 * gets shown in the table.
262
+	 *
263
+	 * @abstract
264
+	 * @access protected
265
+	 * @return string
266
+	 */
267
+	abstract protected function _get_table_filters();
268
+
269
+
270
+	/**
271
+	 * this is a method that child class will do to add counts to the views array so when views are displayed the
272
+	 * counts of the views is accurate.
273
+	 *
274
+	 * @abstract
275
+	 * @access protected
276
+	 * @return void
277
+	 */
278
+	abstract protected function _add_view_counts();
279
+
280
+
281
+	/**
282
+	 * _get_hidden_fields
283
+	 * returns a html string of hidden fields so if any table filters are used the current view will be respected.
284
+	 *
285
+	 * @return string
286
+	 */
287
+	protected function _get_hidden_fields()
288
+	{
289
+		$action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
290
+		$action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
291
+		// if action is STILL empty, then we set it to default
292
+		$action = empty($action) ? 'default' : $action;
293
+		$field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
294
+		$field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
295
+		$field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
296
+
297
+		$bulk_actions = $this->_get_bulk_actions();
298
+		foreach ($bulk_actions as $bulk_action => $label) {
299
+			$field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
300
+					  . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
301
+		}
302
+
303
+		return $field;
304
+	}
305
+
306
+
307
+	/**
308
+	 * _set_column_info
309
+	 * we're using this to set the column headers property.
310
+	 *
311
+	 * @access protected
312
+	 * @return void
313
+	 */
314
+	protected function _set_column_info()
315
+	{
316
+		$columns   = $this->get_columns();
317
+		$hidden    = $this->get_hidden_columns();
318
+		$_sortable = $this->get_sortable_columns();
319
+
320
+		/**
321
+		 * Dynamic hook allowing for adding sortable columns in this list table.
322
+		 * Note that $this->screen->id is in the format
323
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
324
+		 * table it is: event-espresso_page_espresso_messages.
325
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
326
+		 * hook prefix ("event-espresso") will be different.
327
+		 *
328
+		 * @var array
329
+		 */
330
+		$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
331
+
332
+		$sortable = [];
333
+		foreach ($_sortable as $id => $data) {
334
+			if (empty($data)) {
335
+				continue;
336
+			}
337
+			// fix for offset errors with WP_List_Table default get_columninfo()
338
+			if (is_array($data)) {
339
+				$_data[0] = key($data);
340
+				$_data[1] = isset($data[1]) ? $data[1] : false;
341
+			} else {
342
+				$_data[0] = $data;
343
+			}
344
+
345
+			$data = (array) $data;
346
+
347
+			if (! isset($data[1])) {
348
+				$_data[1] = false;
349
+			}
350
+
351
+			$sortable[ $id ] = $_data;
352
+		}
353
+		$primary               = $this->get_primary_column_name();
354
+		$this->_column_headers = [$columns, $hidden, $sortable, $primary];
355
+	}
356
+
357
+
358
+	/**
359
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
360
+	 *
361
+	 * @return string
362
+	 */
363
+	protected function get_primary_column_name()
364
+	{
365
+		foreach (class_parents($this) as $parent) {
366
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
367
+				return parent::get_primary_column_name();
368
+			}
369
+		}
370
+		return $this->_primary_column;
371
+	}
372
+
373
+
374
+	/**
375
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
376
+	 *
377
+	 * @param EE_Base_Class $item
378
+	 * @param string        $column_name
379
+	 * @param string        $primary
380
+	 * @return string
381
+	 */
382
+	protected function handle_row_actions($item, $column_name, $primary)
383
+	{
384
+		foreach (class_parents($this) as $parent) {
385
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
386
+				return parent::handle_row_actions($item, $column_name, $primary);
387
+			}
388
+		}
389
+		return '';
390
+	}
391
+
392
+
393
+	/**
394
+	 * _get_bulk_actions
395
+	 * This is a wrapper called by WP_List_Table::get_bulk_actions()
396
+	 *
397
+	 * @access protected
398
+	 * @return array bulk_actions
399
+	 */
400
+	protected function _get_bulk_actions()
401
+	{
402
+		$actions = [];
403
+		// the _views property should have the bulk_actions, so let's go through and extract them into a properly
404
+		// formatted array for the wp_list_table();
405
+		foreach ($this->_views as $view => $args) {
406
+			if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
407
+				// each bulk action will correspond with a admin page route, so we can check whatever the capability is
408
+				// for that page route and skip adding the bulk action if no access for the current logged in user.
409
+				foreach ($args['bulk_action'] as $route => $label) {
410
+					if ($this->_admin_page->check_user_access($route, true)) {
411
+						$actions[ $route ] = $label;
412
+					}
413
+				}
414
+			}
415
+		}
416
+		return $actions;
417
+	}
418
+
419
+
420
+	/**
421
+	 * Generate the table navigation above or below the table.
422
+	 * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
423
+	 *
424
+	 * @throws EE_Error
425
+	 * @since 4.9.44.rc.001
426
+	 */
427
+	public function display_tablenav($which)
428
+	{
429
+		if ('top' === $which) {
430
+			wp_nonce_field('bulk-' . $this->_args['plural']);
431
+		}
432
+		?>
433 433
         <div class="tablenav <?php echo esc_attr($which); ?>">
434 434
             <?php if ($this->_get_bulk_actions()) { ?>
435 435
                 <div class="alignleft actions bulkactions">
436 436
                     <?php $this->bulk_actions(); ?>
437 437
                 </div>
438 438
             <?php }
439
-            $this->extra_tablenav($which);
440
-            $this->pagination($which);
441
-            ?>
439
+			$this->extra_tablenav($which);
440
+			$this->pagination($which);
441
+			?>
442 442
 
443 443
             <br class="clear" />
444 444
         </div>
445 445
         <?php
446
-    }
447
-
448
-
449
-    /**
450
-     * _filters
451
-     * This receives the filters array from children _get_table_filters() and assembles the string including the filter
452
-     * button.
453
-     *
454
-     * @access private
455
-     * @return void  echos html showing filters
456
-     */
457
-    private function _filters()
458
-    {
459
-        $classname = get_class($this);
460
-        $filters   = apply_filters(
461
-            "FHEE__{$classname}__filters",
462
-            (array) $this->_get_table_filters(),
463
-            $this,
464
-            $this->_screen
465
-        );
466
-
467
-        if (empty($filters)) {
468
-            return;
469
-        }
470
-        foreach ($filters as $filter) {
471
-            echo $filter; // already escaped
472
-        }
473
-        // add filter button at end
474
-        echo '<input type="submit" class="button-secondary" value="'
475
-             . esc_html__('Filter', 'event_espresso')
476
-             . '" id="post-query-submit" />';
477
-        // add reset filters button at end
478
-        echo '<a class="button button-secondary"  href="'
479
-             . esc_url_raw($this->_admin_page->get_current_page_view_url())
480
-             . '" style="display:inline-block">'
481
-             . esc_html__('Reset Filters', 'event_espresso')
482
-             . '</a>';
483
-    }
484
-
485
-
486
-    /**
487
-     * Callback for 'list_table_primary_column' WordPress filter
488
-     * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
489
-     * column when class is instantiated.
490
-     *
491
-     * @param string $column_name
492
-     * @return string
493
-     * @see WP_List_Table::get_primary_column_name
494
-     */
495
-    public function set_primary_column($column_name)
496
-    {
497
-        return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
498
-    }
499
-
500
-
501
-    /**
502
-     *
503
-     */
504
-    public function prepare_items()
505
-    {
506
-
507
-        $this->_set_column_info();
508
-        // $this->_column_headers = $this->get_column_info();
509
-        $total_items = $this->_all_data_count;
510
-        $this->process_bulk_action();
511
-
512
-        $this->items = $this->_data;
513
-        $this->set_pagination_args(
514
-            [
515
-                'total_items' => $total_items,
516
-                'per_page'    => $this->_per_page,
517
-                'total_pages' => ceil($total_items / $this->_per_page),
518
-            ]
519
-        );
520
-    }
521
-
522
-
523
-    /**
524
-     * @param object|array $item
525
-     * @return string html content for the column
526
-     */
527
-    protected function column_cb($item)
528
-    {
529
-        return '';
530
-    }
531
-
532
-
533
-    /**
534
-     * This column is the default for when there is no defined column method for a registered column.
535
-     * This can be overridden by child classes, but allows for hooking in for custom columns.
536
-     *
537
-     * @param EE_Base_Class $item
538
-     * @param string        $column_name The column being called.
539
-     * @return string html content for the column
540
-     */
541
-    public function column_default($item, $column_name)
542
-    {
543
-        /**
544
-         * Dynamic hook allowing for adding additional column content in this list table.
545
-         * Note that $this->screen->id is in the format
546
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
547
-         * table it is: event-espresso_page_espresso_messages.
548
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
549
-         * hook prefix ("event-espresso") will be different.
550
-         */
551
-        ob_start();
552
-        do_action(
553
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
554
-            $item,
555
-            $this->_screen
556
-        );
557
-        return ob_get_clean();
558
-    }
559
-
560
-
561
-    /**
562
-     * Get a list of columns. The format is:
563
-     * 'internal-name' => 'Title'
564
-     *
565
-     * @return array
566
-     * @since  3.1.0
567
-     * @access public
568
-     * @abstract
569
-     */
570
-    public function get_columns()
571
-    {
572
-        /**
573
-         * Dynamic hook allowing for adding additional columns in this list table.
574
-         * Note that $this->screen->id is in the format
575
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
576
-         * table it is: event-espresso_page_espresso_messages.
577
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
578
-         * hook prefix ("event-espresso") will be different.
579
-         *
580
-         * @var array
581
-         */
582
-        return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
583
-    }
584
-
585
-
586
-    /**
587
-     * Get an associative array ( id => link ) with the list
588
-     * of views available on this table.
589
-     *
590
-     * @return array
591
-     * @since  3.1.0
592
-     * @access protected
593
-     */
594
-    public function get_views()
595
-    {
596
-        return $this->_views;
597
-    }
598
-
599
-
600
-    /**
601
-     * Generate the views html.
602
-     */
603
-    public function display_views()
604
-    {
605
-        $views           = $this->get_views();
606
-        $assembled_views = [];
607
-
608
-        if (empty($views)) {
609
-            return;
610
-        }
611
-        echo "<ul class='subsubsub'>\n";
612
-        foreach ($views as $view) {
613
-            $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
614
-            if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
615
-                $filter = "<li";
616
-                $filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
617
-                $filter .= ">";
618
-                $filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
619
-                $filter .= '<span class="count">(' . $count . ')</span>';
620
-                $filter .= '</li>';
621
-                $assembled_views[ $view['slug'] ] = $filter;
622
-            }
623
-        }
624
-
625
-        echo ! empty($assembled_views)
626
-            ? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
627
-            : '';
628
-        echo "</ul>";
629
-    }
630
-
631
-
632
-    /**
633
-     * Generates content for a single row of the table
634
-     *
635
-     * @param EE_Base_Class $item The current item
636
-     * @since  4.1
637
-     * @access public
638
-     */
639
-    public function single_row($item)
640
-    {
641
-        $row_class = $this->_get_row_class($item);
642
-        echo '<tr class="' . esc_attr($row_class) . '">';
643
-        $this->single_row_columns($item); // already escaped
644
-        echo '</tr>';
645
-    }
646
-
647
-
648
-    /**
649
-     * This simply sets up the row class for the table rows.
650
-     * Allows for easier overriding of child methods for setting up sorting.
651
-     *
652
-     * @param EE_Base_Class $item the current item
653
-     * @return string
654
-     */
655
-    protected function _get_row_class($item)
656
-    {
657
-        static $row_class = '';
658
-        $row_class = ($row_class === '' ? 'alternate' : '');
659
-
660
-        $new_row_class = $row_class;
661
-
662
-        if (! empty($this->_ajax_sorting_callback)) {
663
-            $new_row_class .= ' rowsortable';
664
-        }
665
-
666
-        return $new_row_class;
667
-    }
668
-
669
-
670
-    /**
671
-     * @return array
672
-     */
673
-    public function get_sortable_columns()
674
-    {
675
-        return (array) $this->_sortable_columns;
676
-    }
677
-
678
-
679
-    /**
680
-     * @return string
681
-     */
682
-    public function get_ajax_sorting_callback()
683
-    {
684
-        return $this->_ajax_sorting_callback;
685
-    }
686
-
687
-
688
-    /**
689
-     * @return array
690
-     */
691
-    public function get_hidden_columns()
692
-    {
693
-        $user_id     = get_current_user_id();
694
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
695
-        if (empty($has_default) && ! empty($this->_hidden_columns)) {
696
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
697
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
698
-        }
699
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
700
-        return (array) get_user_option($ref, $user_id);
701
-    }
702
-
703
-
704
-    /**
705
-     * Generates the columns for a single row of the table.
706
-     * Overridden from wp_list_table so as to allow us to filter the column content for a given
707
-     * column.
708
-     *
709
-     * @param EE_Base_Class $item The current item
710
-     * @since 3.1.0
711
-     */
712
-    public function single_row_columns($item)
713
-    {
714
-        list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
715
-
716
-        foreach ($columns as $column_name => $column_display_name) {
717
-
718
-            /**
719
-             * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
720
-             * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
721
-             */
722
-            $hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
723
-
724
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
725
-            if ($primary === $column_name) {
726
-                $classes .= ' has-row-actions column-primary';
727
-            }
728
-
729
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
730
-
731
-            $class = 'class="' . esc_attr($classes) . '"';
732
-
733
-            $attributes = "{$class}{$data}";
734
-
735
-            if ($column_name === 'cb') {
736
-                echo '<th scope="row" class="check-column">';
737
-                echo apply_filters(
738
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
739
-                    $this->column_cb($item), // already escaped
740
-                    $item,
741
-                    $this
742
-                );
743
-                echo '</th>';
744
-            } elseif (method_exists($this, 'column_' . $column_name)) {
745
-                echo "<td $attributes>"; // already escaped
746
-                echo apply_filters(
747
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
748
-                    call_user_func([$this, 'column_' . $column_name], $item),
749
-                    $item,
750
-                    $this
751
-                );
752
-                echo $this->handle_row_actions($item, $column_name, $primary);
753
-                echo "</td>";
754
-            } else {
755
-                echo "<td $attributes>"; // already escaped
756
-                echo apply_filters(
757
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
758
-                    $this->column_default($item, $column_name),
759
-                    $item,
760
-                    $column_name,
761
-                    $this
762
-                );
763
-                echo $this->handle_row_actions($item, $column_name, $primary);
764
-                echo "</td>";
765
-            }
766
-        }
767
-    }
768
-
769
-
770
-    /**
771
-     * Extra controls to be displayed between bulk actions and pagination
772
-     *
773
-     * @access public
774
-     * @param string $which
775
-     * @throws EE_Error
776
-     */
777
-    public function extra_tablenav($which)
778
-    {
779
-        if ($which === 'top') {
780
-            $this->_filters();
781
-            echo $this->_get_hidden_fields(); // already escaped
782
-        } else {
783
-            echo '<div class="list-table-bottom-buttons alignleft actions">';
784
-            foreach ($this->_bottom_buttons as $type => $action) {
785
-                $route         = isset($action['route']) ? $action['route'] : '';
786
-                $extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
787
-                // already escaped
788
-                echo $this->_admin_page->get_action_link_or_button(
789
-                    $route,
790
-                    $type,
791
-                    $extra_request,
792
-                    'button button-secondary'
793
-                );
794
-            }
795
-            do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
796
-            echo '</div>';
797
-        }
798
-    }
799
-
800
-
801
-    /**
802
-     * Get an associative array ( option_name => option_title ) with the list
803
-     * of bulk actions available on this table.
804
-     *
805
-     * @return array
806
-     * @since  3.1.0
807
-     * @access protected
808
-     */
809
-    public function get_bulk_actions()
810
-    {
811
-        return (array) $this->_get_bulk_actions();
812
-    }
813
-
814
-
815
-    /**
816
-     * Processing bulk actions.
817
-     */
818
-    public function process_bulk_action()
819
-    {
820
-        // this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
821
-        // reference in case there is a case where it gets used.
822
-    }
823
-
824
-
825
-    /**
826
-     * returns the EE admin page this list table is associated with
827
-     *
828
-     * @return EE_Admin_Page
829
-     */
830
-    public function get_admin_page()
831
-    {
832
-        return $this->_admin_page;
833
-    }
834
-
835
-
836
-    /**
837
-     * A "helper" function for all children to provide an html string of
838
-     * actions to output in their content.  It is preferable for child classes
839
-     * to use this method for generating their actions content so that it's
840
-     * filterable by plugins
841
-     *
842
-     * @param string        $action_container           what are the html container
843
-     *                                                  elements for this actions string?
844
-     * @param string        $action_class               What class is for the container
845
-     *                                                  element.
846
-     * @param string        $action_items               The contents for the action items
847
-     *                                                  container.  This is filtered before
848
-     *                                                  returned.
849
-     * @param string        $action_id                  What id (optional) is used for the
850
-     *                                                  container element.
851
-     * @param EE_Base_Class $item                       The object for the column displaying
852
-     *                                                  the actions.
853
-     * @return string The assembled action elements container.
854
-     */
855
-    protected function _action_string(
856
-        $action_items,
857
-        $item,
858
-        $action_container = 'ul',
859
-        $action_class = '',
860
-        $action_id = ''
861
-    ) {
862
-        $action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
863
-        $action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
864
-        $open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
865
-        $close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
866
-        try {
867
-            $content = apply_filters(
868
-                'FHEE__EE_Admin_List_Table___action_string__action_items',
869
-                $action_items,
870
-                $item,
871
-                $this
872
-            );
873
-        } catch (Exception $e) {
874
-            if (WP_DEBUG) {
875
-                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
876
-            }
877
-            $content = $action_items;
878
-        }
879
-        return "{$open_tag}{$content}{$close_tag}";
880
-    }
881
-
882
-
883
-    /**
884
-     * @return string
885
-     */
886
-    protected function getReturnUrl()
887
-    {
888
-        $host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
889
-        $uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
890
-        return urlencode(esc_url_raw("//{$host}{$uri}"));
891
-    }
446
+	}
447
+
448
+
449
+	/**
450
+	 * _filters
451
+	 * This receives the filters array from children _get_table_filters() and assembles the string including the filter
452
+	 * button.
453
+	 *
454
+	 * @access private
455
+	 * @return void  echos html showing filters
456
+	 */
457
+	private function _filters()
458
+	{
459
+		$classname = get_class($this);
460
+		$filters   = apply_filters(
461
+			"FHEE__{$classname}__filters",
462
+			(array) $this->_get_table_filters(),
463
+			$this,
464
+			$this->_screen
465
+		);
466
+
467
+		if (empty($filters)) {
468
+			return;
469
+		}
470
+		foreach ($filters as $filter) {
471
+			echo $filter; // already escaped
472
+		}
473
+		// add filter button at end
474
+		echo '<input type="submit" class="button-secondary" value="'
475
+			 . esc_html__('Filter', 'event_espresso')
476
+			 . '" id="post-query-submit" />';
477
+		// add reset filters button at end
478
+		echo '<a class="button button-secondary"  href="'
479
+			 . esc_url_raw($this->_admin_page->get_current_page_view_url())
480
+			 . '" style="display:inline-block">'
481
+			 . esc_html__('Reset Filters', 'event_espresso')
482
+			 . '</a>';
483
+	}
484
+
485
+
486
+	/**
487
+	 * Callback for 'list_table_primary_column' WordPress filter
488
+	 * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
489
+	 * column when class is instantiated.
490
+	 *
491
+	 * @param string $column_name
492
+	 * @return string
493
+	 * @see WP_List_Table::get_primary_column_name
494
+	 */
495
+	public function set_primary_column($column_name)
496
+	{
497
+		return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
498
+	}
499
+
500
+
501
+	/**
502
+	 *
503
+	 */
504
+	public function prepare_items()
505
+	{
506
+
507
+		$this->_set_column_info();
508
+		// $this->_column_headers = $this->get_column_info();
509
+		$total_items = $this->_all_data_count;
510
+		$this->process_bulk_action();
511
+
512
+		$this->items = $this->_data;
513
+		$this->set_pagination_args(
514
+			[
515
+				'total_items' => $total_items,
516
+				'per_page'    => $this->_per_page,
517
+				'total_pages' => ceil($total_items / $this->_per_page),
518
+			]
519
+		);
520
+	}
521
+
522
+
523
+	/**
524
+	 * @param object|array $item
525
+	 * @return string html content for the column
526
+	 */
527
+	protected function column_cb($item)
528
+	{
529
+		return '';
530
+	}
531
+
532
+
533
+	/**
534
+	 * This column is the default for when there is no defined column method for a registered column.
535
+	 * This can be overridden by child classes, but allows for hooking in for custom columns.
536
+	 *
537
+	 * @param EE_Base_Class $item
538
+	 * @param string        $column_name The column being called.
539
+	 * @return string html content for the column
540
+	 */
541
+	public function column_default($item, $column_name)
542
+	{
543
+		/**
544
+		 * Dynamic hook allowing for adding additional column content in this list table.
545
+		 * Note that $this->screen->id is in the format
546
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
547
+		 * table it is: event-espresso_page_espresso_messages.
548
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
549
+		 * hook prefix ("event-espresso") will be different.
550
+		 */
551
+		ob_start();
552
+		do_action(
553
+			'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
554
+			$item,
555
+			$this->_screen
556
+		);
557
+		return ob_get_clean();
558
+	}
559
+
560
+
561
+	/**
562
+	 * Get a list of columns. The format is:
563
+	 * 'internal-name' => 'Title'
564
+	 *
565
+	 * @return array
566
+	 * @since  3.1.0
567
+	 * @access public
568
+	 * @abstract
569
+	 */
570
+	public function get_columns()
571
+	{
572
+		/**
573
+		 * Dynamic hook allowing for adding additional columns in this list table.
574
+		 * Note that $this->screen->id is in the format
575
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
576
+		 * table it is: event-espresso_page_espresso_messages.
577
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
578
+		 * hook prefix ("event-espresso") will be different.
579
+		 *
580
+		 * @var array
581
+		 */
582
+		return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
583
+	}
584
+
585
+
586
+	/**
587
+	 * Get an associative array ( id => link ) with the list
588
+	 * of views available on this table.
589
+	 *
590
+	 * @return array
591
+	 * @since  3.1.0
592
+	 * @access protected
593
+	 */
594
+	public function get_views()
595
+	{
596
+		return $this->_views;
597
+	}
598
+
599
+
600
+	/**
601
+	 * Generate the views html.
602
+	 */
603
+	public function display_views()
604
+	{
605
+		$views           = $this->get_views();
606
+		$assembled_views = [];
607
+
608
+		if (empty($views)) {
609
+			return;
610
+		}
611
+		echo "<ul class='subsubsub'>\n";
612
+		foreach ($views as $view) {
613
+			$count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
614
+			if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
615
+				$filter = "<li";
616
+				$filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
617
+				$filter .= ">";
618
+				$filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
619
+				$filter .= '<span class="count">(' . $count . ')</span>';
620
+				$filter .= '</li>';
621
+				$assembled_views[ $view['slug'] ] = $filter;
622
+			}
623
+		}
624
+
625
+		echo ! empty($assembled_views)
626
+			? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
627
+			: '';
628
+		echo "</ul>";
629
+	}
630
+
631
+
632
+	/**
633
+	 * Generates content for a single row of the table
634
+	 *
635
+	 * @param EE_Base_Class $item The current item
636
+	 * @since  4.1
637
+	 * @access public
638
+	 */
639
+	public function single_row($item)
640
+	{
641
+		$row_class = $this->_get_row_class($item);
642
+		echo '<tr class="' . esc_attr($row_class) . '">';
643
+		$this->single_row_columns($item); // already escaped
644
+		echo '</tr>';
645
+	}
646
+
647
+
648
+	/**
649
+	 * This simply sets up the row class for the table rows.
650
+	 * Allows for easier overriding of child methods for setting up sorting.
651
+	 *
652
+	 * @param EE_Base_Class $item the current item
653
+	 * @return string
654
+	 */
655
+	protected function _get_row_class($item)
656
+	{
657
+		static $row_class = '';
658
+		$row_class = ($row_class === '' ? 'alternate' : '');
659
+
660
+		$new_row_class = $row_class;
661
+
662
+		if (! empty($this->_ajax_sorting_callback)) {
663
+			$new_row_class .= ' rowsortable';
664
+		}
665
+
666
+		return $new_row_class;
667
+	}
668
+
669
+
670
+	/**
671
+	 * @return array
672
+	 */
673
+	public function get_sortable_columns()
674
+	{
675
+		return (array) $this->_sortable_columns;
676
+	}
677
+
678
+
679
+	/**
680
+	 * @return string
681
+	 */
682
+	public function get_ajax_sorting_callback()
683
+	{
684
+		return $this->_ajax_sorting_callback;
685
+	}
686
+
687
+
688
+	/**
689
+	 * @return array
690
+	 */
691
+	public function get_hidden_columns()
692
+	{
693
+		$user_id     = get_current_user_id();
694
+		$has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
695
+		if (empty($has_default) && ! empty($this->_hidden_columns)) {
696
+			update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
697
+			update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
698
+		}
699
+		$ref = 'manage' . $this->screen->id . 'columnshidden';
700
+		return (array) get_user_option($ref, $user_id);
701
+	}
702
+
703
+
704
+	/**
705
+	 * Generates the columns for a single row of the table.
706
+	 * Overridden from wp_list_table so as to allow us to filter the column content for a given
707
+	 * column.
708
+	 *
709
+	 * @param EE_Base_Class $item The current item
710
+	 * @since 3.1.0
711
+	 */
712
+	public function single_row_columns($item)
713
+	{
714
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
715
+
716
+		foreach ($columns as $column_name => $column_display_name) {
717
+
718
+			/**
719
+			 * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
720
+			 * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
721
+			 */
722
+			$hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
723
+
724
+			$classes = $column_name . ' column-' . $column_name . $hidden_class;
725
+			if ($primary === $column_name) {
726
+				$classes .= ' has-row-actions column-primary';
727
+			}
728
+
729
+			$data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
730
+
731
+			$class = 'class="' . esc_attr($classes) . '"';
732
+
733
+			$attributes = "{$class}{$data}";
734
+
735
+			if ($column_name === 'cb') {
736
+				echo '<th scope="row" class="check-column">';
737
+				echo apply_filters(
738
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
739
+					$this->column_cb($item), // already escaped
740
+					$item,
741
+					$this
742
+				);
743
+				echo '</th>';
744
+			} elseif (method_exists($this, 'column_' . $column_name)) {
745
+				echo "<td $attributes>"; // already escaped
746
+				echo apply_filters(
747
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
748
+					call_user_func([$this, 'column_' . $column_name], $item),
749
+					$item,
750
+					$this
751
+				);
752
+				echo $this->handle_row_actions($item, $column_name, $primary);
753
+				echo "</td>";
754
+			} else {
755
+				echo "<td $attributes>"; // already escaped
756
+				echo apply_filters(
757
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
758
+					$this->column_default($item, $column_name),
759
+					$item,
760
+					$column_name,
761
+					$this
762
+				);
763
+				echo $this->handle_row_actions($item, $column_name, $primary);
764
+				echo "</td>";
765
+			}
766
+		}
767
+	}
768
+
769
+
770
+	/**
771
+	 * Extra controls to be displayed between bulk actions and pagination
772
+	 *
773
+	 * @access public
774
+	 * @param string $which
775
+	 * @throws EE_Error
776
+	 */
777
+	public function extra_tablenav($which)
778
+	{
779
+		if ($which === 'top') {
780
+			$this->_filters();
781
+			echo $this->_get_hidden_fields(); // already escaped
782
+		} else {
783
+			echo '<div class="list-table-bottom-buttons alignleft actions">';
784
+			foreach ($this->_bottom_buttons as $type => $action) {
785
+				$route         = isset($action['route']) ? $action['route'] : '';
786
+				$extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
787
+				// already escaped
788
+				echo $this->_admin_page->get_action_link_or_button(
789
+					$route,
790
+					$type,
791
+					$extra_request,
792
+					'button button-secondary'
793
+				);
794
+			}
795
+			do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
796
+			echo '</div>';
797
+		}
798
+	}
799
+
800
+
801
+	/**
802
+	 * Get an associative array ( option_name => option_title ) with the list
803
+	 * of bulk actions available on this table.
804
+	 *
805
+	 * @return array
806
+	 * @since  3.1.0
807
+	 * @access protected
808
+	 */
809
+	public function get_bulk_actions()
810
+	{
811
+		return (array) $this->_get_bulk_actions();
812
+	}
813
+
814
+
815
+	/**
816
+	 * Processing bulk actions.
817
+	 */
818
+	public function process_bulk_action()
819
+	{
820
+		// this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
821
+		// reference in case there is a case where it gets used.
822
+	}
823
+
824
+
825
+	/**
826
+	 * returns the EE admin page this list table is associated with
827
+	 *
828
+	 * @return EE_Admin_Page
829
+	 */
830
+	public function get_admin_page()
831
+	{
832
+		return $this->_admin_page;
833
+	}
834
+
835
+
836
+	/**
837
+	 * A "helper" function for all children to provide an html string of
838
+	 * actions to output in their content.  It is preferable for child classes
839
+	 * to use this method for generating their actions content so that it's
840
+	 * filterable by plugins
841
+	 *
842
+	 * @param string        $action_container           what are the html container
843
+	 *                                                  elements for this actions string?
844
+	 * @param string        $action_class               What class is for the container
845
+	 *                                                  element.
846
+	 * @param string        $action_items               The contents for the action items
847
+	 *                                                  container.  This is filtered before
848
+	 *                                                  returned.
849
+	 * @param string        $action_id                  What id (optional) is used for the
850
+	 *                                                  container element.
851
+	 * @param EE_Base_Class $item                       The object for the column displaying
852
+	 *                                                  the actions.
853
+	 * @return string The assembled action elements container.
854
+	 */
855
+	protected function _action_string(
856
+		$action_items,
857
+		$item,
858
+		$action_container = 'ul',
859
+		$action_class = '',
860
+		$action_id = ''
861
+	) {
862
+		$action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
863
+		$action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
864
+		$open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
865
+		$close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
866
+		try {
867
+			$content = apply_filters(
868
+				'FHEE__EE_Admin_List_Table___action_string__action_items',
869
+				$action_items,
870
+				$item,
871
+				$this
872
+			);
873
+		} catch (Exception $e) {
874
+			if (WP_DEBUG) {
875
+				EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
876
+			}
877
+			$content = $action_items;
878
+		}
879
+		return "{$open_tag}{$content}{$close_tag}";
880
+	}
881
+
882
+
883
+	/**
884
+	 * @return string
885
+	 */
886
+	protected function getReturnUrl()
887
+	{
888
+		$host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
889
+		$uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
890
+		return urlencode(esc_url_raw("//{$host}{$uri}"));
891
+	}
892 892
 }
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Registrations_List_Table.class.php 2 patches
Indentation   +1029 added lines, -1029 removed lines patch added patch discarded remove patch
@@ -15,1063 +15,1063 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * @var Registrations_Admin_Page
20
-     */
21
-    protected $_admin_page;
22
-
23
-    /**
24
-     * @var array
25
-     */
26
-    private $_status;
27
-
28
-    /**
29
-     * An array of transaction details for the related transaction to the registration being processed.
30
-     * This is set via the _set_related_details method.
31
-     *
32
-     * @var array
33
-     */
34
-    protected $_transaction_details = [];
35
-
36
-    /**
37
-     * An array of event details for the related event to the registration being processed.
38
-     * This is set via the _set_related_details method.
39
-     *
40
-     * @var array
41
-     */
42
-    protected $_event_details = [];
43
-
44
-
45
-    /**
46
-     * @param Registrations_Admin_Page $admin_page
47
-     */
48
-    public function __construct(Registrations_Admin_Page $admin_page)
49
-    {
50
-        $req_data = $admin_page->get_request_data();
51
-        if (! empty($req_data['event_id'])) {
52
-            $extra_query_args = [];
53
-            foreach ($admin_page->get_views() as $view_details) {
54
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
55
-            }
56
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
57
-        }
58
-        parent::__construct($admin_page);
59
-        $this->_status = $this->_admin_page->get_registration_status_array();
60
-    }
61
-
62
-
63
-    /**
64
-     * @return void
65
-     * @throws EE_Error
66
-     */
67
-    protected function _setup_data()
68
-    {
69
-        $this->_data           = $this->_admin_page->get_registrations($this->_per_page);
70
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
71
-    }
72
-
73
-
74
-    /**
75
-     * @return void
76
-     */
77
-    protected function _set_properties()
78
-    {
79
-        $return_url          = $this->getReturnUrl();
80
-        $this->_wp_list_args = [
81
-            'singular' => esc_html__('registration', 'event_espresso'),
82
-            'plural'   => esc_html__('registrations', 'event_espresso'),
83
-            'ajax'     => true,
84
-            'screen'   => $this->_admin_page->get_current_screen()->id,
85
-        ];
86
-        $ID_column_name      = esc_html__('ID', 'event_espresso');
87
-        $ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
88
-        $ID_column_name      .= esc_html__('Registrant Name', 'event_espresso');
89
-        $ID_column_name      .= '</span> ';
90
-        $req_data            = $this->_admin_page->get_request_data();
91
-        if (isset($req_data['event_id'])) {
92
-            $this->_columns        = [
93
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
94
-                '_REG_ID'          => $ID_column_name,
95
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
96
-                'ATT_email'        => esc_html__('Email', 'event_espresso'),
97
-                '_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
98
-                'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
99
-                '_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
100
-                'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
101
-                'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
102
-                'actions'          => esc_html__('Actions', 'event_espresso'),
103
-            ];
104
-            $this->_bottom_buttons = [
105
-                'report' => [
106
-                    'route'         => 'registrations_report',
107
-                    'extra_request' => [
108
-                        'EVT_ID'     => isset($this->_req_data['event_id'])
109
-                            ? $this->_req_data['event_id']
110
-                            : null,
111
-                        'return_url' => $return_url,
112
-                    ],
113
-                ],
114
-            ];
115
-        } else {
116
-            $this->_columns        = [
117
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
118
-                '_REG_ID'          => $ID_column_name,
119
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
120
-                '_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
121
-                'event_name'       => esc_html__('Event', 'event_espresso'),
122
-                'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
123
-                '_REG_final_price' => esc_html__('Price', 'event_espresso'),
124
-                '_REG_paid'        => esc_html__('Paid', 'event_espresso'),
125
-                'actions'          => esc_html__('Actions', 'event_espresso'),
126
-            ];
127
-            $this->_bottom_buttons = [
128
-                'report_all' => [
129
-                    'route'         => 'registrations_report',
130
-                    'extra_request' => [
131
-                        'return_url' => $return_url,
132
-                    ],
133
-                ],
134
-            ];
135
-        }
136
-        $this->_bottom_buttons['report_filtered'] = [
137
-            'route'         => 'registrations_report',
138
-            'extra_request' => [
139
-                'use_filters' => true,
140
-                'return_url'  => $return_url,
141
-            ],
142
-        ];
143
-        $filters                                  = array_diff_key(
144
-            $this->_req_data,
145
-            array_flip(
146
-                [
147
-                    'page',
148
-                    'action',
149
-                    'default_nonce',
150
-                ]
151
-            )
152
-        );
153
-        if (! empty($filters)) {
154
-            $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
155
-        }
156
-        $this->_primary_column   = '_REG_ID';
157
-        $this->_sortable_columns = [
158
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
159
-            /**
160
-             * Allows users to change the default sort if they wish.
161
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
162
-             * name.
163
-             */
164
-            'ATT_fname'     => [
165
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
166
-                true,
167
-                $this,
168
-            ]
169
-                ? ['ATT_lname' => false]
170
-                : ['ATT_fname' => false],
171
-            'event_name'    => ['event_name' => false],
172
-            'DTT_EVT_start' => ['DTT_EVT_start' => false],
173
-            '_REG_ID'       => ['_REG_ID' => false],
174
-        ];
175
-        $this->_hidden_columns   = [];
176
-    }
177
-
178
-
179
-    /**
180
-     * This simply sets up the row class for the table rows.
181
-     * Allows for easier overriding of child methods for setting up sorting.
182
-     *
183
-     * @param EE_Registration $item the current item
184
-     * @return string
185
-     */
186
-    protected function _get_row_class($item)
187
-    {
188
-        $class = parent::_get_row_class($item);
189
-        // add status class
190
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
191
-        if ($this->_has_checkbox_column) {
192
-            $class .= ' has-checkbox-column';
193
-        }
194
-        return $class;
195
-    }
196
-
197
-
198
-    /**
199
-     * Set the $_transaction_details property if not set yet.
200
-     *
201
-     * @param EE_Registration $registration
202
-     * @throws EE_Error
203
-     * @throws InvalidArgumentException
204
-     * @throws ReflectionException
205
-     * @throws InvalidDataTypeException
206
-     * @throws InvalidInterfaceException
207
-     */
208
-    protected function _set_related_details(EE_Registration $registration)
209
-    {
210
-        $transaction                = $registration->get_first_related('Transaction');
211
-        $status                     = $transaction instanceof EE_Transaction
212
-            ? $transaction->status_ID()
213
-            : EEM_Transaction::failed_status_code;
214
-        $this->_transaction_details = [
215
-            'transaction' => $transaction,
216
-            'status'      => $status,
217
-            'id'          => $transaction instanceof EE_Transaction
218
-                ? $transaction->ID()
219
-                : 0,
220
-            'title_attr'  => sprintf(
221
-                esc_html__('View Transaction Details (%s)', 'event_espresso'),
222
-                EEH_Template::pretty_status($status, false, 'sentence')
223
-            ),
224
-        ];
225
-        try {
226
-            $event = $registration->event();
227
-        } catch (EntityNotFoundException $e) {
228
-            $event = null;
229
-        }
230
-        $status               = $event instanceof EE_Event
231
-            ? $event->get_active_status()
232
-            : EE_Datetime::inactive;
233
-        $this->_event_details = [
234
-            'event'      => $event,
235
-            'status'     => $status,
236
-            'id'         => $event instanceof EE_Event
237
-                ? $event->ID()
238
-                : 0,
239
-            'title_attr' => sprintf(
240
-                esc_html__('Edit Event (%s)', 'event_espresso'),
241
-                EEH_Template::pretty_status($status, false, 'sentence')
242
-            ),
243
-        ];
244
-    }
245
-
246
-
247
-    /**
248
-     *    _get_table_filters
249
-     *
250
-     * @return array
251
-     */
252
-    protected function _get_table_filters()
253
-    {
254
-        $filters = [];
255
-        // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
256
-        // methods.
257
-        $cur_date     = isset($this->_req_data['month_range'])
258
-            ? $this->_req_data['month_range']
259
-            : '';
260
-        $cur_category = isset($this->_req_data['EVT_CAT'])
261
-            ? $this->_req_data['EVT_CAT']
262
-            : -1;
263
-        $reg_status   = isset($this->_req_data['_reg_status'])
264
-            ? $this->_req_data['_reg_status']
265
-            : '';
266
-        $filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
267
-        $filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
268
-        $status       = [];
269
-        $status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
270
-        foreach ($this->_status as $key => $value) {
271
-            $status[] = ['id' => $key, 'text' => $value];
272
-        }
273
-        if ($this->_view !== 'incomplete') {
274
-            $filters[] = EEH_Form_Fields::select_input(
275
-                '_reg_status',
276
-                $status,
277
-                isset($this->_req_data['_reg_status'])
278
-                    ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
279
-                    : ''
280
-            );
281
-        }
282
-        if (isset($this->_req_data['event_id'])) {
283
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
284
-        }
285
-        return $filters;
286
-    }
287
-
288
-
289
-    /**
290
-     * @return void
291
-     * @throws EE_Error
292
-     * @throws InvalidArgumentException
293
-     * @throws InvalidDataTypeException
294
-     * @throws InvalidInterfaceException
295
-     */
296
-    protected function _add_view_counts()
297
-    {
298
-        $this->_views['all']['count']   = $this->_total_registrations();
299
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
300
-        $this->_views['today']['count'] = $this->_total_registrations_today();
301
-        if (
302
-            EE_Registry::instance()->CAP->current_user_can(
303
-                'ee_delete_registrations',
304
-                'espresso_registrations_trash_registrations'
305
-            )
306
-        ) {
307
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
308
-            $this->_views['trash']['count']      = $this->_total_registrations('trash');
309
-        }
310
-    }
311
-
312
-
313
-    /**
314
-     * @param string $view
315
-     * @return int
316
-     * @throws EE_Error
317
-     * @throws InvalidArgumentException
318
-     * @throws InvalidDataTypeException
319
-     * @throws InvalidInterfaceException
320
-     */
321
-    protected function _total_registrations($view = '')
322
-    {
323
-        $_where = [];
324
-        $EVT_ID = isset($this->_req_data['event_id'])
325
-            ? absint($this->_req_data['event_id'])
326
-            : false;
327
-        if ($EVT_ID) {
328
-            $_where['EVT_ID'] = $EVT_ID;
329
-        }
330
-        switch ($view) {
331
-            case 'trash':
332
-                return EEM_Registration::instance()->count_deleted([$_where]);
333
-            case 'incomplete':
334
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
335
-                break;
336
-            default:
337
-                $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
338
-        }
339
-        return EEM_Registration::instance()->count([$_where]);
340
-    }
341
-
342
-
343
-    /**
344
-     * @return int
345
-     * @throws EE_Error
346
-     * @throws InvalidArgumentException
347
-     * @throws InvalidDataTypeException
348
-     * @throws InvalidInterfaceException
349
-     */
350
-    protected function _total_registrations_this_month()
351
-    {
352
-        $EVT_ID          = isset($this->_req_data['event_id'])
353
-            ? absint($this->_req_data['event_id'])
354
-            : false;
355
-        $_where          = $EVT_ID
356
-            ? ['EVT_ID' => $EVT_ID]
357
-            : [];
358
-        $this_year_r     = date('Y', current_time('timestamp'));
359
-        $time_start      = ' 00:00:00';
360
-        $time_end        = ' 23:59:59';
361
-        $this_month_r    = date('m', current_time('timestamp'));
362
-        $days_this_month = date('t', current_time('timestamp'));
363
-        // setup date query.
364
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
365
-            'REG_date',
366
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
367
-            'Y-m-d H:i:s'
368
-        );
369
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
370
-            'REG_date',
371
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
372
-            'Y-m-d H:i:s'
373
-        );
374
-        $_where['REG_date'] = [
375
-            'BETWEEN',
376
-            [
377
-                $beginning_string,
378
-                $end_string,
379
-            ],
380
-        ];
381
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
382
-        return EEM_Registration::instance()->count([$_where]);
383
-    }
384
-
385
-
386
-    /**
387
-     * @return int
388
-     * @throws EE_Error
389
-     * @throws InvalidArgumentException
390
-     * @throws InvalidDataTypeException
391
-     * @throws InvalidInterfaceException
392
-     */
393
-    protected function _total_registrations_today()
394
-    {
395
-        $EVT_ID             = isset($this->_req_data['event_id'])
396
-            ? absint($this->_req_data['event_id'])
397
-            : false;
398
-        $_where             = $EVT_ID
399
-            ? ['EVT_ID' => $EVT_ID]
400
-            : [];
401
-        $current_date       = date('Y-m-d', current_time('timestamp'));
402
-        $time_start         = ' 00:00:00';
403
-        $time_end           = ' 23:59:59';
404
-        $_where['REG_date'] = [
405
-            'BETWEEN',
406
-            [
407
-                EEM_Registration::instance()->convert_datetime_for_query(
408
-                    'REG_date',
409
-                    $current_date . $time_start,
410
-                    'Y-m-d H:i:s'
411
-                ),
412
-                EEM_Registration::instance()->convert_datetime_for_query(
413
-                    'REG_date',
414
-                    $current_date . $time_end,
415
-                    'Y-m-d H:i:s'
416
-                ),
417
-            ],
418
-        ];
419
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
420
-        return EEM_Registration::instance()->count([$_where]);
421
-    }
422
-
423
-
424
-    /**
425
-     * @param EE_Registration $item
426
-     * @return string
427
-     * @throws EE_Error
428
-     * @throws InvalidArgumentException
429
-     * @throws InvalidDataTypeException
430
-     * @throws InvalidInterfaceException
431
-     * @throws ReflectionException
432
-     */
433
-    public function column_cb($item)
434
-    {
435
-        /** checkbox/lock **/
436
-        $transaction   = $item->get_first_related('Transaction');
437
-        $payment_count = $transaction instanceof EE_Transaction
438
-            ? $transaction->count_related('Payment')
439
-            : 0;
440
-        return $payment_count > 0 || ! EE_Registry::instance()->CAP->current_user_can(
441
-            'ee_edit_registration',
442
-            'registration_list_table_checkbox_input',
443
-            $item->ID()
444
-        )
445
-            ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID())
446
-              . '<span class="ee-lock-icon"></span>'
447
-            : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID());
448
-    }
449
-
450
-
451
-    /**
452
-     * @param EE_Registration $item
453
-     * @return string
454
-     * @throws EE_Error
455
-     * @throws InvalidArgumentException
456
-     * @throws InvalidDataTypeException
457
-     * @throws InvalidInterfaceException
458
-     * @throws ReflectionException
459
-     */
460
-    public function column__REG_ID(EE_Registration $item)
461
-    {
462
-        $attendee = $item->attendee();
463
-        $content  = $item->ID();
464
-        $content  .= '<div class="show-on-mobile-view-only">';
465
-        $content  .= '<br>';
466
-        $content  .= $attendee instanceof EE_Attendee
467
-            ? $attendee->full_name()
468
-            : '';
469
-        $content  .= '&nbsp;';
470
-        $content  .= sprintf(
471
-            esc_html__('(%1$s / %2$s)', 'event_espresso'),
472
-            $item->count(),
473
-            $item->group_size()
474
-        );
475
-        $content  .= '<br>';
476
-        $content  .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
477
-        $content  .= '</div>';
478
-        return $content;
479
-    }
480
-
481
-
482
-    /**
483
-     * @param EE_Registration $item
484
-     * @return string
485
-     * @throws EE_Error
486
-     * @throws InvalidArgumentException
487
-     * @throws InvalidDataTypeException
488
-     * @throws InvalidInterfaceException
489
-     * @throws ReflectionException
490
-     */
491
-    public function column__REG_date(EE_Registration $item)
492
-    {
493
-        $this->_set_related_details($item);
494
-        // Build row actions
495
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
496
-            [
497
-                'action' => 'view_transaction',
498
-                'TXN_ID' => $this->_transaction_details['id'],
499
-            ],
500
-            TXN_ADMIN_URL
501
-        );
502
-        $view_link    = EE_Registry::instance()->CAP->current_user_can(
503
-            'ee_read_transaction',
504
-            'espresso_transactions_view_transaction'
505
-        )
506
-            ? '<a class="ee-status-color-'
507
-              . $this->_transaction_details['status']
508
-              . '" href="'
509
-              . $view_lnk_url
510
-              . '" title="'
511
-              . esc_attr($this->_transaction_details['title_attr'])
512
-              . '">'
513
-              . $item->get_i18n_datetime('REG_date')
514
-              . '</a>'
515
-            : $item->get_i18n_datetime('REG_date');
516
-        $view_link    .= '<br><span class="ee-status-text-small">'
517
-                         . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
518
-                         . '</span>';
519
-        return $view_link;
520
-    }
521
-
522
-
523
-    /**
524
-     * @param EE_Registration $item
525
-     * @return string
526
-     * @throws EE_Error
527
-     * @throws InvalidArgumentException
528
-     * @throws InvalidDataTypeException
529
-     * @throws InvalidInterfaceException
530
-     * @throws ReflectionException
531
-     */
532
-    public function column_event_name(EE_Registration $item)
533
-    {
534
-        $this->_set_related_details($item);
535
-        // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
536
-        $EVT_ID     = $item->event_ID();
537
-        $event_name = $item->event_name();
538
-        $event_name =
539
-            $event_name
540
-                ?: esc_html__("No Associated Event", 'event_espresso');
541
-        $event_name = wp_trim_words($event_name, 30, '...');
542
-        if ($EVT_ID) {
543
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
544
-                ['action' => 'edit', 'post' => $EVT_ID],
545
-                EVENTS_ADMIN_URL
546
-            );
547
-            $edit_event              =
548
-                EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
549
-                    ? '<a class="ee-status-color-'
550
-                      . $this->_event_details['status']
551
-                      . '" href="'
552
-                      . $edit_event_url
553
-                      . '" title="'
554
-                      . esc_attr($this->_event_details['title_attr'])
555
-                      . '">'
556
-                      . $event_name
557
-                      . '</a>'
558
-                    : $event_name;
559
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
560
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
561
-            $actions['event_filter'] .= sprintf(
562
-                esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
563
-                $event_name
564
-            );
565
-            $actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
566
-        } else {
567
-            $edit_event              = $event_name;
568
-            $actions['event_filter'] = '';
569
-        }
570
-        return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
571
-    }
572
-
573
-
574
-    /**
575
-     * @param EE_Registration $item
576
-     * @return string
577
-     * @throws EE_Error
578
-     * @throws InvalidArgumentException
579
-     * @throws InvalidDataTypeException
580
-     * @throws InvalidInterfaceException
581
-     * @throws ReflectionException
582
-     */
583
-    public function column_DTT_EVT_start(EE_Registration $item)
584
-    {
585
-        $datetime_strings = [];
586
-        $ticket           = $item->ticket();
587
-        if ($ticket instanceof EE_Ticket) {
588
-            $remove_defaults = ['default_where_conditions' => 'none'];
589
-            $datetimes       = $ticket->datetimes($remove_defaults);
590
-            foreach ($datetimes as $datetime) {
591
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
592
-            }
593
-            return $this->generateDisplayForDatetimes($datetime_strings);
594
-        }
595
-        return esc_html__('There is no ticket on this registration', 'event_espresso');
596
-    }
597
-
598
-
599
-    /**
600
-     * Receives an array of datetime strings to display and converts them to the html container for the column.
601
-     *
602
-     * @param array $datetime_strings
603
-     * @return string
604
-     */
605
-    public function generateDisplayForDateTimes(array $datetime_strings)
606
-    {
607
-        $content       = '<div class="ee-registration-event-datetimes-container">';
608
-        $expand_toggle = count($datetime_strings) > 1
609
-            ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
610
-              . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
611
-            : '';
612
-        // get first item for initial visibility
613
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
614
-        $content .= $expand_toggle;
615
-        if ($datetime_strings) {
616
-            $content .= '<div style="clear:both"></div>';
617
-            $content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
618
-            $content .= implode("<br />", $datetime_strings);
619
-            $content .= '</div>';
620
-        }
621
-        $content .= '</div>';
622
-        return $content;
623
-    }
624
-
625
-
626
-    /**
627
-     * @param EE_Registration $item
628
-     * @return string
629
-     * @throws EE_Error
630
-     * @throws InvalidArgumentException
631
-     * @throws InvalidDataTypeException
632
-     * @throws InvalidInterfaceException
633
-     * @throws ReflectionException
634
-     */
635
-    public function column_ATT_fname(EE_Registration $item)
636
-    {
637
-        $attendee      = $item->attendee();
638
-        $edit_lnk_url  = EE_Admin_Page::add_query_args_and_nonce(
639
-            [
640
-                'action'  => 'view_registration',
641
-                '_REG_ID' => $item->ID(),
642
-            ],
643
-            REG_ADMIN_URL
644
-        );
645
-        $attendee_name = $attendee instanceof EE_Attendee
646
-            ? $attendee->full_name()
647
-            : '';
648
-        $link          = EE_Registry::instance()->CAP->current_user_can(
649
-            'ee_read_registration',
650
-            'espresso_registrations_view_registration',
651
-            $item->ID()
652
-        )
653
-            ? '<a href="'
654
-              . $edit_lnk_url
655
-              . '" title="'
656
-              . esc_attr__('View Registration Details', 'event_espresso')
657
-              . '">'
658
-              . $attendee_name
659
-              . '</a>'
660
-            : $attendee_name;
661
-        $link          .= $item->count() === 1
662
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>'
663
-            : '';
664
-        $t             = $item->get_first_related('Transaction');
665
-        $payment_count = $t instanceof EE_Transaction
666
-            ? $t->count_related('Payment')
667
-            : 0;
668
-        // append group count to name
669
-        $link .= '&nbsp;' . sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
670
-        // append reg_code
671
-        $link .= '<br>' . sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
672
-        // reg status text for accessibility
673
-        $link   .= '<br><span class="ee-status-text-small">'
674
-                   . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
675
-                   . '</span>';
676
-        $action = ['_REG_ID' => $item->ID()];
677
-        if (isset($this->_req_data['event_id'])) {
678
-            $action['event_id'] = $item->event_ID();
679
-        }
680
-        // trash/restore/delete actions
681
-        $actions = [];
682
-        if (
683
-            $this->_view !== 'trash'
684
-            && $payment_count === 0
685
-            && EE_Registry::instance()->CAP->current_user_can(
686
-                'ee_delete_registration',
687
-                'espresso_registrations_trash_registrations',
688
-                $item->ID()
689
-            )
690
-        ) {
691
-            $action['action'] = 'trash_registrations';
692
-            $trash_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
693
-                $action,
694
-                REG_ADMIN_URL
695
-            );
696
-            $actions['trash'] = '<a href="'
697
-                                . $trash_lnk_url
698
-                                . '" title="'
699
-                                . esc_attr__('Trash Registration', 'event_espresso')
700
-                                . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
701
-        } elseif ($this->_view === 'trash') {
702
-            // restore registration link
703
-            if (
704
-                EE_Registry::instance()->CAP->current_user_can(
705
-                    'ee_delete_registration',
706
-                    'espresso_registrations_restore_registrations',
707
-                    $item->ID()
708
-                )
709
-            ) {
710
-                $action['action']   = 'restore_registrations';
711
-                $restore_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
712
-                    $action,
713
-                    REG_ADMIN_URL
714
-                );
715
-                $actions['restore'] = '<a href="'
716
-                                      . $restore_lnk_url
717
-                                      . '" title="'
718
-                                      . esc_attr__('Restore Registration', 'event_espresso') . '">'
719
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
720
-            }
721
-            if (
722
-                EE_Registry::instance()->CAP->current_user_can(
723
-                    'ee_delete_registration',
724
-                    'espresso_registrations_ee_delete_registrations',
725
-                    $item->ID()
726
-                )
727
-            ) {
728
-                $action['action']  = 'delete_registrations';
729
-                $delete_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
730
-                    $action,
731
-                    REG_ADMIN_URL
732
-                );
733
-                $actions['delete'] = '<a href="'
734
-                                     . $delete_lnk_url
735
-                                     . '" title="'
736
-                                     . esc_attr__('Delete Registration Permanently', 'event_espresso')
737
-                                     . '">'
738
-                                     . esc_html__('Delete', 'event_espresso')
739
-                                     . '</a>';
740
-            }
741
-        }
742
-        return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
743
-    }
744
-
745
-
746
-    /**
747
-     * @param EE_Registration $item
748
-     * @return string
749
-     * @throws EE_Error
750
-     * @throws InvalidArgumentException
751
-     * @throws InvalidDataTypeException
752
-     * @throws InvalidInterfaceException
753
-     * @throws ReflectionException
754
-     */
755
-    public function column_ATT_email(EE_Registration $item)
756
-    {
757
-        $attendee = $item->get_first_related('Attendee');
758
-        return ! $attendee instanceof EE_Attendee
759
-            ? esc_html__('No attached contact record.', 'event_espresso')
760
-            : $attendee->email();
761
-    }
762
-
763
-
764
-    /**
765
-     * @param EE_Registration $item
766
-     * @return string
767
-     */
768
-    public function column__REG_count(EE_Registration $item)
769
-    {
770
-        return sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
771
-    }
772
-
773
-
774
-    /**
775
-     * @param EE_Registration $item
776
-     * @return string
777
-     * @throws EE_Error
778
-     * @throws ReflectionException
779
-     */
780
-    public function column_PRC_amount(EE_Registration $item)
781
-    {
782
-        $ticket   = $item->ticket();
783
-        $req_data = $this->_admin_page->get_request_data();
784
-        $content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
785
-            ? '<span class="TKT_name">' . $ticket->name() . '</span><br />'
786
-            : '';
787
-        if ($item->final_price() > 0) {
788
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
789
-        } else {
790
-            // free event
791
-            $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
792
-                        . esc_html__('free', 'event_espresso')
793
-                        . '</span>';
794
-        }
795
-        return $content;
796
-    }
797
-
798
-
799
-    /**
800
-     * @param EE_Registration $item
801
-     * @return string
802
-     * @throws EE_Error
803
-     * @throws ReflectionException
804
-     */
805
-    public function column__REG_final_price(EE_Registration $item)
806
-    {
807
-        $ticket   = $item->ticket();
808
-        $req_data = $this->_admin_page->get_request_data();
809
-        $content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
810
-            ? ''
811
-            : '<span class="TKT_name">' . $ticket->name() . '</span><br />';
812
-        $content  .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
813
-        return $content;
814
-    }
815
-
816
-
817
-    /**
818
-     * @param EE_Registration $item
819
-     * @return string
820
-     * @throws EE_Error
821
-     */
822
-    public function column__REG_paid(EE_Registration $item)
823
-    {
824
-        $payment_method      = $item->payment_method();
825
-        $payment_method_name = $payment_method instanceof EE_Payment_Method
826
-            ? $payment_method->admin_name()
827
-            : esc_html__('Unknown', 'event_espresso');
828
-        $content             = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
829
-        if ($item->paid() > 0) {
830
-            $content .= '<br><span class="ee-status-text-small">'
831
-                        . sprintf(
832
-                            esc_html__('...via %s', 'event_espresso'),
833
-                            $payment_method_name
834
-                        )
835
-                        . '</span>';
836
-        }
837
-        return $content;
838
-    }
839
-
840
-
841
-    /**
842
-     * @param EE_Registration $item
843
-     * @return string
844
-     * @throws EE_Error
845
-     * @throws EntityNotFoundException
846
-     * @throws InvalidArgumentException
847
-     * @throws InvalidDataTypeException
848
-     * @throws InvalidInterfaceException
849
-     * @throws ReflectionException
850
-     */
851
-    public function column_TXN_total(EE_Registration $item)
852
-    {
853
-        if ($item->transaction()) {
854
-            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
855
-                [
856
-                    'action' => 'view_transaction',
857
-                    'TXN_ID' => $item->transaction_ID(),
858
-                ],
859
-                TXN_ADMIN_URL
860
-            );
861
-            return EE_Registry::instance()->CAP->current_user_can(
862
-                'ee_read_transaction',
863
-                'espresso_transactions_view_transaction',
864
-                $item->transaction_ID()
865
-            )
866
-                ? '<span class="reg-pad-rght"><a class="status-'
867
-                  . $item->transaction()->status_ID()
868
-                  . '" href="'
869
-                  . $view_txn_lnk_url
870
-                  . '"  title="'
871
-                  . esc_attr__('View Transaction', 'event_espresso')
872
-                  . '">'
873
-                  . $item->transaction()->pretty_total()
874
-                  . '</a></span>'
875
-                : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
876
-        } else {
877
-            return esc_html__("None", "event_espresso");
878
-        }
879
-    }
880
-
881
-
882
-    /**
883
-     * @param EE_Registration $item
884
-     * @return string
885
-     * @throws EE_Error
886
-     * @throws EntityNotFoundException
887
-     * @throws InvalidArgumentException
888
-     * @throws InvalidDataTypeException
889
-     * @throws InvalidInterfaceException
890
-     * @throws ReflectionException
891
-     */
892
-    public function column_TXN_paid(EE_Registration $item)
893
-    {
894
-        if ($item->count() === 1) {
895
-            $transaction = $item->transaction()
896
-                ? $item->transaction()
897
-                : EE_Transaction::new_instance();
898
-            if ($transaction->paid() >= $transaction->total()) {
899
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
900
-            } else {
901
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
902
-                    [
903
-                        'action' => 'view_transaction',
904
-                        'TXN_ID' => $item->transaction_ID(),
905
-                    ],
906
-                    TXN_ADMIN_URL
907
-                );
908
-                return EE_Registry::instance()->CAP->current_user_can(
909
-                    'ee_read_transaction',
910
-                    'espresso_transactions_view_transaction',
911
-                    $item->transaction_ID()
912
-                )
913
-                    ? '<span class="reg-pad-rght"><a class="status-'
914
-                      . $transaction->status_ID()
915
-                      . '" href="'
916
-                      . $view_txn_lnk_url
917
-                      . '"  title="'
918
-                      . esc_attr__('View Transaction', 'event_espresso')
919
-                      . '">'
920
-                      . $item->transaction()->pretty_paid()
921
-                      . '</a><span>'
922
-                    : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
923
-            }
924
-        }
925
-        return '&nbsp;';
926
-    }
927
-
928
-
929
-    /**
930
-     * column_actions
931
-     *
932
-     * @param EE_Registration $item
933
-     * @return string
934
-     * @throws EE_Error
935
-     * @throws InvalidArgumentException
936
-     * @throws InvalidDataTypeException
937
-     * @throws InvalidInterfaceException
938
-     * @throws ReflectionException
939
-     */
940
-    public function column_actions(EE_Registration $item)
941
-    {
942
-        $actions  = [];
943
-        $attendee = $item->attendee();
944
-        $this->_set_related_details($item);
945
-
946
-        // Build row actions
947
-        if (
948
-            EE_Registry::instance()->CAP->current_user_can(
949
-                'ee_read_registration',
950
-                'espresso_registrations_view_registration',
951
-                $item->ID()
952
-            )
953
-        ) {
954
-            $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
955
-                [
956
-                    'action'  => 'view_registration',
957
-                    '_REG_ID' => $item->ID(),
958
-                ],
959
-                REG_ADMIN_URL
960
-            );
961
-            $actions['view_lnk'] = '
18
+	/**
19
+	 * @var Registrations_Admin_Page
20
+	 */
21
+	protected $_admin_page;
22
+
23
+	/**
24
+	 * @var array
25
+	 */
26
+	private $_status;
27
+
28
+	/**
29
+	 * An array of transaction details for the related transaction to the registration being processed.
30
+	 * This is set via the _set_related_details method.
31
+	 *
32
+	 * @var array
33
+	 */
34
+	protected $_transaction_details = [];
35
+
36
+	/**
37
+	 * An array of event details for the related event to the registration being processed.
38
+	 * This is set via the _set_related_details method.
39
+	 *
40
+	 * @var array
41
+	 */
42
+	protected $_event_details = [];
43
+
44
+
45
+	/**
46
+	 * @param Registrations_Admin_Page $admin_page
47
+	 */
48
+	public function __construct(Registrations_Admin_Page $admin_page)
49
+	{
50
+		$req_data = $admin_page->get_request_data();
51
+		if (! empty($req_data['event_id'])) {
52
+			$extra_query_args = [];
53
+			foreach ($admin_page->get_views() as $view_details) {
54
+				$extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
55
+			}
56
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
57
+		}
58
+		parent::__construct($admin_page);
59
+		$this->_status = $this->_admin_page->get_registration_status_array();
60
+	}
61
+
62
+
63
+	/**
64
+	 * @return void
65
+	 * @throws EE_Error
66
+	 */
67
+	protected function _setup_data()
68
+	{
69
+		$this->_data           = $this->_admin_page->get_registrations($this->_per_page);
70
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
71
+	}
72
+
73
+
74
+	/**
75
+	 * @return void
76
+	 */
77
+	protected function _set_properties()
78
+	{
79
+		$return_url          = $this->getReturnUrl();
80
+		$this->_wp_list_args = [
81
+			'singular' => esc_html__('registration', 'event_espresso'),
82
+			'plural'   => esc_html__('registrations', 'event_espresso'),
83
+			'ajax'     => true,
84
+			'screen'   => $this->_admin_page->get_current_screen()->id,
85
+		];
86
+		$ID_column_name      = esc_html__('ID', 'event_espresso');
87
+		$ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
88
+		$ID_column_name      .= esc_html__('Registrant Name', 'event_espresso');
89
+		$ID_column_name      .= '</span> ';
90
+		$req_data            = $this->_admin_page->get_request_data();
91
+		if (isset($req_data['event_id'])) {
92
+			$this->_columns        = [
93
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
94
+				'_REG_ID'          => $ID_column_name,
95
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
96
+				'ATT_email'        => esc_html__('Email', 'event_espresso'),
97
+				'_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
98
+				'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
99
+				'_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
100
+				'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
101
+				'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
102
+				'actions'          => esc_html__('Actions', 'event_espresso'),
103
+			];
104
+			$this->_bottom_buttons = [
105
+				'report' => [
106
+					'route'         => 'registrations_report',
107
+					'extra_request' => [
108
+						'EVT_ID'     => isset($this->_req_data['event_id'])
109
+							? $this->_req_data['event_id']
110
+							: null,
111
+						'return_url' => $return_url,
112
+					],
113
+				],
114
+			];
115
+		} else {
116
+			$this->_columns        = [
117
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
118
+				'_REG_ID'          => $ID_column_name,
119
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
120
+				'_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
121
+				'event_name'       => esc_html__('Event', 'event_espresso'),
122
+				'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
123
+				'_REG_final_price' => esc_html__('Price', 'event_espresso'),
124
+				'_REG_paid'        => esc_html__('Paid', 'event_espresso'),
125
+				'actions'          => esc_html__('Actions', 'event_espresso'),
126
+			];
127
+			$this->_bottom_buttons = [
128
+				'report_all' => [
129
+					'route'         => 'registrations_report',
130
+					'extra_request' => [
131
+						'return_url' => $return_url,
132
+					],
133
+				],
134
+			];
135
+		}
136
+		$this->_bottom_buttons['report_filtered'] = [
137
+			'route'         => 'registrations_report',
138
+			'extra_request' => [
139
+				'use_filters' => true,
140
+				'return_url'  => $return_url,
141
+			],
142
+		];
143
+		$filters                                  = array_diff_key(
144
+			$this->_req_data,
145
+			array_flip(
146
+				[
147
+					'page',
148
+					'action',
149
+					'default_nonce',
150
+				]
151
+			)
152
+		);
153
+		if (! empty($filters)) {
154
+			$this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
155
+		}
156
+		$this->_primary_column   = '_REG_ID';
157
+		$this->_sortable_columns = [
158
+			'_REG_date'     => ['_REG_date' => true],   // true means its already sorted
159
+			/**
160
+			 * Allows users to change the default sort if they wish.
161
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
162
+			 * name.
163
+			 */
164
+			'ATT_fname'     => [
165
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
166
+				true,
167
+				$this,
168
+			]
169
+				? ['ATT_lname' => false]
170
+				: ['ATT_fname' => false],
171
+			'event_name'    => ['event_name' => false],
172
+			'DTT_EVT_start' => ['DTT_EVT_start' => false],
173
+			'_REG_ID'       => ['_REG_ID' => false],
174
+		];
175
+		$this->_hidden_columns   = [];
176
+	}
177
+
178
+
179
+	/**
180
+	 * This simply sets up the row class for the table rows.
181
+	 * Allows for easier overriding of child methods for setting up sorting.
182
+	 *
183
+	 * @param EE_Registration $item the current item
184
+	 * @return string
185
+	 */
186
+	protected function _get_row_class($item)
187
+	{
188
+		$class = parent::_get_row_class($item);
189
+		// add status class
190
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
191
+		if ($this->_has_checkbox_column) {
192
+			$class .= ' has-checkbox-column';
193
+		}
194
+		return $class;
195
+	}
196
+
197
+
198
+	/**
199
+	 * Set the $_transaction_details property if not set yet.
200
+	 *
201
+	 * @param EE_Registration $registration
202
+	 * @throws EE_Error
203
+	 * @throws InvalidArgumentException
204
+	 * @throws ReflectionException
205
+	 * @throws InvalidDataTypeException
206
+	 * @throws InvalidInterfaceException
207
+	 */
208
+	protected function _set_related_details(EE_Registration $registration)
209
+	{
210
+		$transaction                = $registration->get_first_related('Transaction');
211
+		$status                     = $transaction instanceof EE_Transaction
212
+			? $transaction->status_ID()
213
+			: EEM_Transaction::failed_status_code;
214
+		$this->_transaction_details = [
215
+			'transaction' => $transaction,
216
+			'status'      => $status,
217
+			'id'          => $transaction instanceof EE_Transaction
218
+				? $transaction->ID()
219
+				: 0,
220
+			'title_attr'  => sprintf(
221
+				esc_html__('View Transaction Details (%s)', 'event_espresso'),
222
+				EEH_Template::pretty_status($status, false, 'sentence')
223
+			),
224
+		];
225
+		try {
226
+			$event = $registration->event();
227
+		} catch (EntityNotFoundException $e) {
228
+			$event = null;
229
+		}
230
+		$status               = $event instanceof EE_Event
231
+			? $event->get_active_status()
232
+			: EE_Datetime::inactive;
233
+		$this->_event_details = [
234
+			'event'      => $event,
235
+			'status'     => $status,
236
+			'id'         => $event instanceof EE_Event
237
+				? $event->ID()
238
+				: 0,
239
+			'title_attr' => sprintf(
240
+				esc_html__('Edit Event (%s)', 'event_espresso'),
241
+				EEH_Template::pretty_status($status, false, 'sentence')
242
+			),
243
+		];
244
+	}
245
+
246
+
247
+	/**
248
+	 *    _get_table_filters
249
+	 *
250
+	 * @return array
251
+	 */
252
+	protected function _get_table_filters()
253
+	{
254
+		$filters = [];
255
+		// todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
256
+		// methods.
257
+		$cur_date     = isset($this->_req_data['month_range'])
258
+			? $this->_req_data['month_range']
259
+			: '';
260
+		$cur_category = isset($this->_req_data['EVT_CAT'])
261
+			? $this->_req_data['EVT_CAT']
262
+			: -1;
263
+		$reg_status   = isset($this->_req_data['_reg_status'])
264
+			? $this->_req_data['_reg_status']
265
+			: '';
266
+		$filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
267
+		$filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
268
+		$status       = [];
269
+		$status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
270
+		foreach ($this->_status as $key => $value) {
271
+			$status[] = ['id' => $key, 'text' => $value];
272
+		}
273
+		if ($this->_view !== 'incomplete') {
274
+			$filters[] = EEH_Form_Fields::select_input(
275
+				'_reg_status',
276
+				$status,
277
+				isset($this->_req_data['_reg_status'])
278
+					? strtoupper(sanitize_key($this->_req_data['_reg_status']))
279
+					: ''
280
+			);
281
+		}
282
+		if (isset($this->_req_data['event_id'])) {
283
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
284
+		}
285
+		return $filters;
286
+	}
287
+
288
+
289
+	/**
290
+	 * @return void
291
+	 * @throws EE_Error
292
+	 * @throws InvalidArgumentException
293
+	 * @throws InvalidDataTypeException
294
+	 * @throws InvalidInterfaceException
295
+	 */
296
+	protected function _add_view_counts()
297
+	{
298
+		$this->_views['all']['count']   = $this->_total_registrations();
299
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
300
+		$this->_views['today']['count'] = $this->_total_registrations_today();
301
+		if (
302
+			EE_Registry::instance()->CAP->current_user_can(
303
+				'ee_delete_registrations',
304
+				'espresso_registrations_trash_registrations'
305
+			)
306
+		) {
307
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
308
+			$this->_views['trash']['count']      = $this->_total_registrations('trash');
309
+		}
310
+	}
311
+
312
+
313
+	/**
314
+	 * @param string $view
315
+	 * @return int
316
+	 * @throws EE_Error
317
+	 * @throws InvalidArgumentException
318
+	 * @throws InvalidDataTypeException
319
+	 * @throws InvalidInterfaceException
320
+	 */
321
+	protected function _total_registrations($view = '')
322
+	{
323
+		$_where = [];
324
+		$EVT_ID = isset($this->_req_data['event_id'])
325
+			? absint($this->_req_data['event_id'])
326
+			: false;
327
+		if ($EVT_ID) {
328
+			$_where['EVT_ID'] = $EVT_ID;
329
+		}
330
+		switch ($view) {
331
+			case 'trash':
332
+				return EEM_Registration::instance()->count_deleted([$_where]);
333
+			case 'incomplete':
334
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
335
+				break;
336
+			default:
337
+				$_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
338
+		}
339
+		return EEM_Registration::instance()->count([$_where]);
340
+	}
341
+
342
+
343
+	/**
344
+	 * @return int
345
+	 * @throws EE_Error
346
+	 * @throws InvalidArgumentException
347
+	 * @throws InvalidDataTypeException
348
+	 * @throws InvalidInterfaceException
349
+	 */
350
+	protected function _total_registrations_this_month()
351
+	{
352
+		$EVT_ID          = isset($this->_req_data['event_id'])
353
+			? absint($this->_req_data['event_id'])
354
+			: false;
355
+		$_where          = $EVT_ID
356
+			? ['EVT_ID' => $EVT_ID]
357
+			: [];
358
+		$this_year_r     = date('Y', current_time('timestamp'));
359
+		$time_start      = ' 00:00:00';
360
+		$time_end        = ' 23:59:59';
361
+		$this_month_r    = date('m', current_time('timestamp'));
362
+		$days_this_month = date('t', current_time('timestamp'));
363
+		// setup date query.
364
+		$beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
365
+			'REG_date',
366
+			$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
367
+			'Y-m-d H:i:s'
368
+		);
369
+		$end_string         = EEM_Registration::instance()->convert_datetime_for_query(
370
+			'REG_date',
371
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
372
+			'Y-m-d H:i:s'
373
+		);
374
+		$_where['REG_date'] = [
375
+			'BETWEEN',
376
+			[
377
+				$beginning_string,
378
+				$end_string,
379
+			],
380
+		];
381
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
382
+		return EEM_Registration::instance()->count([$_where]);
383
+	}
384
+
385
+
386
+	/**
387
+	 * @return int
388
+	 * @throws EE_Error
389
+	 * @throws InvalidArgumentException
390
+	 * @throws InvalidDataTypeException
391
+	 * @throws InvalidInterfaceException
392
+	 */
393
+	protected function _total_registrations_today()
394
+	{
395
+		$EVT_ID             = isset($this->_req_data['event_id'])
396
+			? absint($this->_req_data['event_id'])
397
+			: false;
398
+		$_where             = $EVT_ID
399
+			? ['EVT_ID' => $EVT_ID]
400
+			: [];
401
+		$current_date       = date('Y-m-d', current_time('timestamp'));
402
+		$time_start         = ' 00:00:00';
403
+		$time_end           = ' 23:59:59';
404
+		$_where['REG_date'] = [
405
+			'BETWEEN',
406
+			[
407
+				EEM_Registration::instance()->convert_datetime_for_query(
408
+					'REG_date',
409
+					$current_date . $time_start,
410
+					'Y-m-d H:i:s'
411
+				),
412
+				EEM_Registration::instance()->convert_datetime_for_query(
413
+					'REG_date',
414
+					$current_date . $time_end,
415
+					'Y-m-d H:i:s'
416
+				),
417
+			],
418
+		];
419
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
420
+		return EEM_Registration::instance()->count([$_where]);
421
+	}
422
+
423
+
424
+	/**
425
+	 * @param EE_Registration $item
426
+	 * @return string
427
+	 * @throws EE_Error
428
+	 * @throws InvalidArgumentException
429
+	 * @throws InvalidDataTypeException
430
+	 * @throws InvalidInterfaceException
431
+	 * @throws ReflectionException
432
+	 */
433
+	public function column_cb($item)
434
+	{
435
+		/** checkbox/lock **/
436
+		$transaction   = $item->get_first_related('Transaction');
437
+		$payment_count = $transaction instanceof EE_Transaction
438
+			? $transaction->count_related('Payment')
439
+			: 0;
440
+		return $payment_count > 0 || ! EE_Registry::instance()->CAP->current_user_can(
441
+			'ee_edit_registration',
442
+			'registration_list_table_checkbox_input',
443
+			$item->ID()
444
+		)
445
+			? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID())
446
+			  . '<span class="ee-lock-icon"></span>'
447
+			: sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID());
448
+	}
449
+
450
+
451
+	/**
452
+	 * @param EE_Registration $item
453
+	 * @return string
454
+	 * @throws EE_Error
455
+	 * @throws InvalidArgumentException
456
+	 * @throws InvalidDataTypeException
457
+	 * @throws InvalidInterfaceException
458
+	 * @throws ReflectionException
459
+	 */
460
+	public function column__REG_ID(EE_Registration $item)
461
+	{
462
+		$attendee = $item->attendee();
463
+		$content  = $item->ID();
464
+		$content  .= '<div class="show-on-mobile-view-only">';
465
+		$content  .= '<br>';
466
+		$content  .= $attendee instanceof EE_Attendee
467
+			? $attendee->full_name()
468
+			: '';
469
+		$content  .= '&nbsp;';
470
+		$content  .= sprintf(
471
+			esc_html__('(%1$s / %2$s)', 'event_espresso'),
472
+			$item->count(),
473
+			$item->group_size()
474
+		);
475
+		$content  .= '<br>';
476
+		$content  .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
477
+		$content  .= '</div>';
478
+		return $content;
479
+	}
480
+
481
+
482
+	/**
483
+	 * @param EE_Registration $item
484
+	 * @return string
485
+	 * @throws EE_Error
486
+	 * @throws InvalidArgumentException
487
+	 * @throws InvalidDataTypeException
488
+	 * @throws InvalidInterfaceException
489
+	 * @throws ReflectionException
490
+	 */
491
+	public function column__REG_date(EE_Registration $item)
492
+	{
493
+		$this->_set_related_details($item);
494
+		// Build row actions
495
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
496
+			[
497
+				'action' => 'view_transaction',
498
+				'TXN_ID' => $this->_transaction_details['id'],
499
+			],
500
+			TXN_ADMIN_URL
501
+		);
502
+		$view_link    = EE_Registry::instance()->CAP->current_user_can(
503
+			'ee_read_transaction',
504
+			'espresso_transactions_view_transaction'
505
+		)
506
+			? '<a class="ee-status-color-'
507
+			  . $this->_transaction_details['status']
508
+			  . '" href="'
509
+			  . $view_lnk_url
510
+			  . '" title="'
511
+			  . esc_attr($this->_transaction_details['title_attr'])
512
+			  . '">'
513
+			  . $item->get_i18n_datetime('REG_date')
514
+			  . '</a>'
515
+			: $item->get_i18n_datetime('REG_date');
516
+		$view_link    .= '<br><span class="ee-status-text-small">'
517
+						 . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
518
+						 . '</span>';
519
+		return $view_link;
520
+	}
521
+
522
+
523
+	/**
524
+	 * @param EE_Registration $item
525
+	 * @return string
526
+	 * @throws EE_Error
527
+	 * @throws InvalidArgumentException
528
+	 * @throws InvalidDataTypeException
529
+	 * @throws InvalidInterfaceException
530
+	 * @throws ReflectionException
531
+	 */
532
+	public function column_event_name(EE_Registration $item)
533
+	{
534
+		$this->_set_related_details($item);
535
+		// page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
536
+		$EVT_ID     = $item->event_ID();
537
+		$event_name = $item->event_name();
538
+		$event_name =
539
+			$event_name
540
+				?: esc_html__("No Associated Event", 'event_espresso');
541
+		$event_name = wp_trim_words($event_name, 30, '...');
542
+		if ($EVT_ID) {
543
+			$edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
544
+				['action' => 'edit', 'post' => $EVT_ID],
545
+				EVENTS_ADMIN_URL
546
+			);
547
+			$edit_event              =
548
+				EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
549
+					? '<a class="ee-status-color-'
550
+					  . $this->_event_details['status']
551
+					  . '" href="'
552
+					  . $edit_event_url
553
+					  . '" title="'
554
+					  . esc_attr($this->_event_details['title_attr'])
555
+					  . '">'
556
+					  . $event_name
557
+					  . '</a>'
558
+					: $event_name;
559
+			$edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
560
+			$actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
561
+			$actions['event_filter'] .= sprintf(
562
+				esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
563
+				$event_name
564
+			);
565
+			$actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
566
+		} else {
567
+			$edit_event              = $event_name;
568
+			$actions['event_filter'] = '';
569
+		}
570
+		return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
571
+	}
572
+
573
+
574
+	/**
575
+	 * @param EE_Registration $item
576
+	 * @return string
577
+	 * @throws EE_Error
578
+	 * @throws InvalidArgumentException
579
+	 * @throws InvalidDataTypeException
580
+	 * @throws InvalidInterfaceException
581
+	 * @throws ReflectionException
582
+	 */
583
+	public function column_DTT_EVT_start(EE_Registration $item)
584
+	{
585
+		$datetime_strings = [];
586
+		$ticket           = $item->ticket();
587
+		if ($ticket instanceof EE_Ticket) {
588
+			$remove_defaults = ['default_where_conditions' => 'none'];
589
+			$datetimes       = $ticket->datetimes($remove_defaults);
590
+			foreach ($datetimes as $datetime) {
591
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
592
+			}
593
+			return $this->generateDisplayForDatetimes($datetime_strings);
594
+		}
595
+		return esc_html__('There is no ticket on this registration', 'event_espresso');
596
+	}
597
+
598
+
599
+	/**
600
+	 * Receives an array of datetime strings to display and converts them to the html container for the column.
601
+	 *
602
+	 * @param array $datetime_strings
603
+	 * @return string
604
+	 */
605
+	public function generateDisplayForDateTimes(array $datetime_strings)
606
+	{
607
+		$content       = '<div class="ee-registration-event-datetimes-container">';
608
+		$expand_toggle = count($datetime_strings) > 1
609
+			? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
610
+			  . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
611
+			: '';
612
+		// get first item for initial visibility
613
+		$content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
614
+		$content .= $expand_toggle;
615
+		if ($datetime_strings) {
616
+			$content .= '<div style="clear:both"></div>';
617
+			$content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
618
+			$content .= implode("<br />", $datetime_strings);
619
+			$content .= '</div>';
620
+		}
621
+		$content .= '</div>';
622
+		return $content;
623
+	}
624
+
625
+
626
+	/**
627
+	 * @param EE_Registration $item
628
+	 * @return string
629
+	 * @throws EE_Error
630
+	 * @throws InvalidArgumentException
631
+	 * @throws InvalidDataTypeException
632
+	 * @throws InvalidInterfaceException
633
+	 * @throws ReflectionException
634
+	 */
635
+	public function column_ATT_fname(EE_Registration $item)
636
+	{
637
+		$attendee      = $item->attendee();
638
+		$edit_lnk_url  = EE_Admin_Page::add_query_args_and_nonce(
639
+			[
640
+				'action'  => 'view_registration',
641
+				'_REG_ID' => $item->ID(),
642
+			],
643
+			REG_ADMIN_URL
644
+		);
645
+		$attendee_name = $attendee instanceof EE_Attendee
646
+			? $attendee->full_name()
647
+			: '';
648
+		$link          = EE_Registry::instance()->CAP->current_user_can(
649
+			'ee_read_registration',
650
+			'espresso_registrations_view_registration',
651
+			$item->ID()
652
+		)
653
+			? '<a href="'
654
+			  . $edit_lnk_url
655
+			  . '" title="'
656
+			  . esc_attr__('View Registration Details', 'event_espresso')
657
+			  . '">'
658
+			  . $attendee_name
659
+			  . '</a>'
660
+			: $attendee_name;
661
+		$link          .= $item->count() === 1
662
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>'
663
+			: '';
664
+		$t             = $item->get_first_related('Transaction');
665
+		$payment_count = $t instanceof EE_Transaction
666
+			? $t->count_related('Payment')
667
+			: 0;
668
+		// append group count to name
669
+		$link .= '&nbsp;' . sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
670
+		// append reg_code
671
+		$link .= '<br>' . sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
672
+		// reg status text for accessibility
673
+		$link   .= '<br><span class="ee-status-text-small">'
674
+				   . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
675
+				   . '</span>';
676
+		$action = ['_REG_ID' => $item->ID()];
677
+		if (isset($this->_req_data['event_id'])) {
678
+			$action['event_id'] = $item->event_ID();
679
+		}
680
+		// trash/restore/delete actions
681
+		$actions = [];
682
+		if (
683
+			$this->_view !== 'trash'
684
+			&& $payment_count === 0
685
+			&& EE_Registry::instance()->CAP->current_user_can(
686
+				'ee_delete_registration',
687
+				'espresso_registrations_trash_registrations',
688
+				$item->ID()
689
+			)
690
+		) {
691
+			$action['action'] = 'trash_registrations';
692
+			$trash_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
693
+				$action,
694
+				REG_ADMIN_URL
695
+			);
696
+			$actions['trash'] = '<a href="'
697
+								. $trash_lnk_url
698
+								. '" title="'
699
+								. esc_attr__('Trash Registration', 'event_espresso')
700
+								. '">' . esc_html__('Trash', 'event_espresso') . '</a>';
701
+		} elseif ($this->_view === 'trash') {
702
+			// restore registration link
703
+			if (
704
+				EE_Registry::instance()->CAP->current_user_can(
705
+					'ee_delete_registration',
706
+					'espresso_registrations_restore_registrations',
707
+					$item->ID()
708
+				)
709
+			) {
710
+				$action['action']   = 'restore_registrations';
711
+				$restore_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
712
+					$action,
713
+					REG_ADMIN_URL
714
+				);
715
+				$actions['restore'] = '<a href="'
716
+									  . $restore_lnk_url
717
+									  . '" title="'
718
+									  . esc_attr__('Restore Registration', 'event_espresso') . '">'
719
+									  . esc_html__('Restore', 'event_espresso') . '</a>';
720
+			}
721
+			if (
722
+				EE_Registry::instance()->CAP->current_user_can(
723
+					'ee_delete_registration',
724
+					'espresso_registrations_ee_delete_registrations',
725
+					$item->ID()
726
+				)
727
+			) {
728
+				$action['action']  = 'delete_registrations';
729
+				$delete_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
730
+					$action,
731
+					REG_ADMIN_URL
732
+				);
733
+				$actions['delete'] = '<a href="'
734
+									 . $delete_lnk_url
735
+									 . '" title="'
736
+									 . esc_attr__('Delete Registration Permanently', 'event_espresso')
737
+									 . '">'
738
+									 . esc_html__('Delete', 'event_espresso')
739
+									 . '</a>';
740
+			}
741
+		}
742
+		return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
743
+	}
744
+
745
+
746
+	/**
747
+	 * @param EE_Registration $item
748
+	 * @return string
749
+	 * @throws EE_Error
750
+	 * @throws InvalidArgumentException
751
+	 * @throws InvalidDataTypeException
752
+	 * @throws InvalidInterfaceException
753
+	 * @throws ReflectionException
754
+	 */
755
+	public function column_ATT_email(EE_Registration $item)
756
+	{
757
+		$attendee = $item->get_first_related('Attendee');
758
+		return ! $attendee instanceof EE_Attendee
759
+			? esc_html__('No attached contact record.', 'event_espresso')
760
+			: $attendee->email();
761
+	}
762
+
763
+
764
+	/**
765
+	 * @param EE_Registration $item
766
+	 * @return string
767
+	 */
768
+	public function column__REG_count(EE_Registration $item)
769
+	{
770
+		return sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
771
+	}
772
+
773
+
774
+	/**
775
+	 * @param EE_Registration $item
776
+	 * @return string
777
+	 * @throws EE_Error
778
+	 * @throws ReflectionException
779
+	 */
780
+	public function column_PRC_amount(EE_Registration $item)
781
+	{
782
+		$ticket   = $item->ticket();
783
+		$req_data = $this->_admin_page->get_request_data();
784
+		$content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
785
+			? '<span class="TKT_name">' . $ticket->name() . '</span><br />'
786
+			: '';
787
+		if ($item->final_price() > 0) {
788
+			$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
789
+		} else {
790
+			// free event
791
+			$content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
792
+						. esc_html__('free', 'event_espresso')
793
+						. '</span>';
794
+		}
795
+		return $content;
796
+	}
797
+
798
+
799
+	/**
800
+	 * @param EE_Registration $item
801
+	 * @return string
802
+	 * @throws EE_Error
803
+	 * @throws ReflectionException
804
+	 */
805
+	public function column__REG_final_price(EE_Registration $item)
806
+	{
807
+		$ticket   = $item->ticket();
808
+		$req_data = $this->_admin_page->get_request_data();
809
+		$content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
810
+			? ''
811
+			: '<span class="TKT_name">' . $ticket->name() . '</span><br />';
812
+		$content  .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
813
+		return $content;
814
+	}
815
+
816
+
817
+	/**
818
+	 * @param EE_Registration $item
819
+	 * @return string
820
+	 * @throws EE_Error
821
+	 */
822
+	public function column__REG_paid(EE_Registration $item)
823
+	{
824
+		$payment_method      = $item->payment_method();
825
+		$payment_method_name = $payment_method instanceof EE_Payment_Method
826
+			? $payment_method->admin_name()
827
+			: esc_html__('Unknown', 'event_espresso');
828
+		$content             = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
829
+		if ($item->paid() > 0) {
830
+			$content .= '<br><span class="ee-status-text-small">'
831
+						. sprintf(
832
+							esc_html__('...via %s', 'event_espresso'),
833
+							$payment_method_name
834
+						)
835
+						. '</span>';
836
+		}
837
+		return $content;
838
+	}
839
+
840
+
841
+	/**
842
+	 * @param EE_Registration $item
843
+	 * @return string
844
+	 * @throws EE_Error
845
+	 * @throws EntityNotFoundException
846
+	 * @throws InvalidArgumentException
847
+	 * @throws InvalidDataTypeException
848
+	 * @throws InvalidInterfaceException
849
+	 * @throws ReflectionException
850
+	 */
851
+	public function column_TXN_total(EE_Registration $item)
852
+	{
853
+		if ($item->transaction()) {
854
+			$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
855
+				[
856
+					'action' => 'view_transaction',
857
+					'TXN_ID' => $item->transaction_ID(),
858
+				],
859
+				TXN_ADMIN_URL
860
+			);
861
+			return EE_Registry::instance()->CAP->current_user_can(
862
+				'ee_read_transaction',
863
+				'espresso_transactions_view_transaction',
864
+				$item->transaction_ID()
865
+			)
866
+				? '<span class="reg-pad-rght"><a class="status-'
867
+				  . $item->transaction()->status_ID()
868
+				  . '" href="'
869
+				  . $view_txn_lnk_url
870
+				  . '"  title="'
871
+				  . esc_attr__('View Transaction', 'event_espresso')
872
+				  . '">'
873
+				  . $item->transaction()->pretty_total()
874
+				  . '</a></span>'
875
+				: '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
876
+		} else {
877
+			return esc_html__("None", "event_espresso");
878
+		}
879
+	}
880
+
881
+
882
+	/**
883
+	 * @param EE_Registration $item
884
+	 * @return string
885
+	 * @throws EE_Error
886
+	 * @throws EntityNotFoundException
887
+	 * @throws InvalidArgumentException
888
+	 * @throws InvalidDataTypeException
889
+	 * @throws InvalidInterfaceException
890
+	 * @throws ReflectionException
891
+	 */
892
+	public function column_TXN_paid(EE_Registration $item)
893
+	{
894
+		if ($item->count() === 1) {
895
+			$transaction = $item->transaction()
896
+				? $item->transaction()
897
+				: EE_Transaction::new_instance();
898
+			if ($transaction->paid() >= $transaction->total()) {
899
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
900
+			} else {
901
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
902
+					[
903
+						'action' => 'view_transaction',
904
+						'TXN_ID' => $item->transaction_ID(),
905
+					],
906
+					TXN_ADMIN_URL
907
+				);
908
+				return EE_Registry::instance()->CAP->current_user_can(
909
+					'ee_read_transaction',
910
+					'espresso_transactions_view_transaction',
911
+					$item->transaction_ID()
912
+				)
913
+					? '<span class="reg-pad-rght"><a class="status-'
914
+					  . $transaction->status_ID()
915
+					  . '" href="'
916
+					  . $view_txn_lnk_url
917
+					  . '"  title="'
918
+					  . esc_attr__('View Transaction', 'event_espresso')
919
+					  . '">'
920
+					  . $item->transaction()->pretty_paid()
921
+					  . '</a><span>'
922
+					: '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
923
+			}
924
+		}
925
+		return '&nbsp;';
926
+	}
927
+
928
+
929
+	/**
930
+	 * column_actions
931
+	 *
932
+	 * @param EE_Registration $item
933
+	 * @return string
934
+	 * @throws EE_Error
935
+	 * @throws InvalidArgumentException
936
+	 * @throws InvalidDataTypeException
937
+	 * @throws InvalidInterfaceException
938
+	 * @throws ReflectionException
939
+	 */
940
+	public function column_actions(EE_Registration $item)
941
+	{
942
+		$actions  = [];
943
+		$attendee = $item->attendee();
944
+		$this->_set_related_details($item);
945
+
946
+		// Build row actions
947
+		if (
948
+			EE_Registry::instance()->CAP->current_user_can(
949
+				'ee_read_registration',
950
+				'espresso_registrations_view_registration',
951
+				$item->ID()
952
+			)
953
+		) {
954
+			$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
955
+				[
956
+					'action'  => 'view_registration',
957
+					'_REG_ID' => $item->ID(),
958
+				],
959
+				REG_ADMIN_URL
960
+			);
961
+			$actions['view_lnk'] = '
962 962
             <li>
963 963
                 <a href="' . $view_lnk_url . '" title="'
964
-                . esc_attr__('View Registration Details', 'event_espresso')
965
-                . '" class="tiny-text">
964
+				. esc_attr__('View Registration Details', 'event_espresso')
965
+				. '" class="tiny-text">
966 966
 				    <div class="dashicons dashicons-clipboard"></div>
967 967
 			    </a>
968 968
 			</li>';
969
-        }
970
-
971
-        if (
972
-            $attendee instanceof EE_Attendee
973
-            && EE_Registry::instance()->CAP->current_user_can(
974
-                'ee_edit_contacts',
975
-                'espresso_registrations_edit_attendee'
976
-            )
977
-        ) {
978
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
979
-                [
980
-                    'action' => 'edit_attendee',
981
-                    'post'   => $item->attendee_ID(),
982
-                ],
983
-                REG_ADMIN_URL
984
-            );
985
-            $actions['edit_lnk'] = '
969
+		}
970
+
971
+		if (
972
+			$attendee instanceof EE_Attendee
973
+			&& EE_Registry::instance()->CAP->current_user_can(
974
+				'ee_edit_contacts',
975
+				'espresso_registrations_edit_attendee'
976
+			)
977
+		) {
978
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
979
+				[
980
+					'action' => 'edit_attendee',
981
+					'post'   => $item->attendee_ID(),
982
+				],
983
+				REG_ADMIN_URL
984
+			);
985
+			$actions['edit_lnk'] = '
986 986
 			<li>
987 987
                 <a href="' . $edit_lnk_url . '" title="'
988
-                . esc_attr__('Edit Contact Details', 'event_espresso')
989
-                . '" class="tiny-text">
988
+				. esc_attr__('Edit Contact Details', 'event_espresso')
989
+				. '" class="tiny-text">
990 990
                     <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
991 991
                 </a>
992 992
 			</li>';
993
-        }
994
-
995
-        if (
996
-            $attendee instanceof EE_Attendee
997
-            && EE_Registry::instance()->CAP->current_user_can(
998
-                'ee_send_message',
999
-                'espresso_registrations_resend_registration',
1000
-                $item->ID()
1001
-            )
1002
-        ) {
1003
-            $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
1004
-                [
1005
-                    'action'  => 'resend_registration',
1006
-                    '_REG_ID' => $item->ID(),
1007
-                ],
1008
-                REG_ADMIN_URL,
1009
-                true
1010
-            );
1011
-            $actions['resend_reg_lnk'] = '
993
+		}
994
+
995
+		if (
996
+			$attendee instanceof EE_Attendee
997
+			&& EE_Registry::instance()->CAP->current_user_can(
998
+				'ee_send_message',
999
+				'espresso_registrations_resend_registration',
1000
+				$item->ID()
1001
+			)
1002
+		) {
1003
+			$resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
1004
+				[
1005
+					'action'  => 'resend_registration',
1006
+					'_REG_ID' => $item->ID(),
1007
+				],
1008
+				REG_ADMIN_URL,
1009
+				true
1010
+			);
1011
+			$actions['resend_reg_lnk'] = '
1012 1012
 			<li>
1013 1013
 			    <a href="' . $resend_reg_lnk_url . '" title="'
1014
-                . esc_attr__('Resend Registration Details', 'event_espresso')
1015
-                . '" class="tiny-text">
1014
+				. esc_attr__('Resend Registration Details', 'event_espresso')
1015
+				. '" class="tiny-text">
1016 1016
 			        <div class="dashicons dashicons-email-alt"></div>
1017 1017
 			    </a>
1018 1018
             </li>';
1019
-        }
1020
-
1021
-        if (
1022
-            EE_Registry::instance()->CAP->current_user_can(
1023
-                'ee_read_transaction',
1024
-                'espresso_transactions_view_transaction',
1025
-                $this->_transaction_details['id']
1026
-            )
1027
-        ) {
1028
-            $view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
1029
-                [
1030
-                    'action' => 'view_transaction',
1031
-                    'TXN_ID' => $this->_transaction_details['id'],
1032
-                ],
1033
-                TXN_ADMIN_URL
1034
-            );
1035
-            $actions['view_txn_lnk'] = '
1019
+		}
1020
+
1021
+		if (
1022
+			EE_Registry::instance()->CAP->current_user_can(
1023
+				'ee_read_transaction',
1024
+				'espresso_transactions_view_transaction',
1025
+				$this->_transaction_details['id']
1026
+			)
1027
+		) {
1028
+			$view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
1029
+				[
1030
+					'action' => 'view_transaction',
1031
+					'TXN_ID' => $this->_transaction_details['id'],
1032
+				],
1033
+				TXN_ADMIN_URL
1034
+			);
1035
+			$actions['view_txn_lnk'] = '
1036 1036
 			<li>
1037 1037
                 <a class="ee-status-color-' . $this->_transaction_details['status']
1038
-                . ' tiny-text" href="' . $view_txn_lnk_url
1039
-                . '"  title="' . $this->_transaction_details['title_attr'] . '">
1038
+				. ' tiny-text" href="' . $view_txn_lnk_url
1039
+				. '"  title="' . $this->_transaction_details['title_attr'] . '">
1040 1040
                     <div class="dashicons dashicons-cart"></div>
1041 1041
                 </a>
1042 1042
 			</li>';
1043
-        }
1044
-
1045
-        // only show invoice link if message type is active.
1046
-        if (
1047
-            $attendee instanceof EE_Attendee
1048
-            && $item->is_primary_registrant()
1049
-            && EEH_MSG_Template::is_mt_active('invoice')
1050
-        ) {
1051
-            $actions['dl_invoice_lnk'] = '
1043
+		}
1044
+
1045
+		// only show invoice link if message type is active.
1046
+		if (
1047
+			$attendee instanceof EE_Attendee
1048
+			&& $item->is_primary_registrant()
1049
+			&& EEH_MSG_Template::is_mt_active('invoice')
1050
+		) {
1051
+			$actions['dl_invoice_lnk'] = '
1052 1052
             <li>
1053 1053
                 <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso')
1054
-                . '" target="_blank" href="' . $item->invoice_url() . '" class="tiny-text">
1054
+				. '" target="_blank" href="' . $item->invoice_url() . '" class="tiny-text">
1055 1055
                     <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
1056 1056
                 </a>
1057 1057
             </li>';
1058
-        }
1058
+		}
1059 1059
 
1060
-        // message list table link (filtered by REG_ID
1061
-        if (
1062
-            EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')
1063
-        ) {
1064
-            $actions['filtered_messages_link'] = '
1060
+		// message list table link (filtered by REG_ID
1061
+		if (
1062
+			EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')
1063
+		) {
1064
+			$actions['filtered_messages_link'] = '
1065 1065
             <li>
1066 1066
                 ' . EEH_MSG_Template::get_message_action_link(
1067
-                'see_notifications_for',
1068
-                null,
1069
-                ['_REG_ID' => $item->ID()]
1070
-            ) . '
1067
+				'see_notifications_for',
1068
+				null,
1069
+				['_REG_ID' => $item->ID()]
1070
+			) . '
1071 1071
             </li>';
1072
-        }
1072
+		}
1073 1073
 
1074
-        $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1075
-        return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
1076
-    }
1074
+		$actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1075
+		return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
1076
+	}
1077 1077
 }
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
     public function __construct(Registrations_Admin_Page $admin_page)
49 49
     {
50 50
         $req_data = $admin_page->get_request_data();
51
-        if (! empty($req_data['event_id'])) {
51
+        if ( ! empty($req_data['event_id'])) {
52 52
             $extra_query_args = [];
53 53
             foreach ($admin_page->get_views() as $view_details) {
54
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
54
+                $extra_query_args[$view_details['slug']] = ['event_id' => $req_data['event_id']];
55 55
             }
56 56
             $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
57 57
         }
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
             'ajax'     => true,
84 84
             'screen'   => $this->_admin_page->get_current_screen()->id,
85 85
         ];
86
-        $ID_column_name      = esc_html__('ID', 'event_espresso');
86
+        $ID_column_name = esc_html__('ID', 'event_espresso');
87 87
         $ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
88 88
         $ID_column_name      .= esc_html__('Registrant Name', 'event_espresso');
89 89
         $ID_column_name      .= '</span> ';
90
-        $req_data            = $this->_admin_page->get_request_data();
90
+        $req_data = $this->_admin_page->get_request_data();
91 91
         if (isset($req_data['event_id'])) {
92
-            $this->_columns        = [
92
+            $this->_columns = [
93 93
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
94 94
                 '_REG_ID'          => $ID_column_name,
95 95
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
                 ],
114 114
             ];
115 115
         } else {
116
-            $this->_columns        = [
116
+            $this->_columns = [
117 117
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
118 118
                 '_REG_ID'          => $ID_column_name,
119 119
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
                 'return_url'  => $return_url,
141 141
             ],
142 142
         ];
143
-        $filters                                  = array_diff_key(
143
+        $filters = array_diff_key(
144 144
             $this->_req_data,
145 145
             array_flip(
146 146
                 [
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
                 ]
151 151
             )
152 152
         );
153
-        if (! empty($filters)) {
153
+        if ( ! empty($filters)) {
154 154
             $this->_bottom_buttons['report_filtered']['extra_request']['filters'] = $filters;
155 155
         }
156 156
         $this->_primary_column   = '_REG_ID';
157 157
         $this->_sortable_columns = [
158
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
158
+            '_REG_date'     => ['_REG_date' => true], // true means its already sorted
159 159
             /**
160 160
              * Allows users to change the default sort if they wish.
161 161
              * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
             'DTT_EVT_start' => ['DTT_EVT_start' => false],
173 173
             '_REG_ID'       => ['_REG_ID' => false],
174 174
         ];
175
-        $this->_hidden_columns   = [];
175
+        $this->_hidden_columns = [];
176 176
     }
177 177
 
178 178
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     {
188 188
         $class = parent::_get_row_class($item);
189 189
         // add status class
190
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
190
+        $class .= ' ee-status-strip reg-status-'.$item->status_ID();
191 191
         if ($this->_has_checkbox_column) {
192 192
             $class .= ' has-checkbox-column';
193 193
         }
@@ -361,14 +361,14 @@  discard block
 block discarded – undo
361 361
         $this_month_r    = date('m', current_time('timestamp'));
362 362
         $days_this_month = date('t', current_time('timestamp'));
363 363
         // setup date query.
364
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
364
+        $beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
365 365
             'REG_date',
366
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
366
+            $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start,
367 367
             'Y-m-d H:i:s'
368 368
         );
369
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
369
+        $end_string = EEM_Registration::instance()->convert_datetime_for_query(
370 370
             'REG_date',
371
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
371
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
372 372
             'Y-m-d H:i:s'
373 373
         );
374 374
         $_where['REG_date'] = [
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
                 $end_string,
379 379
             ],
380 380
         ];
381
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
381
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
382 382
         return EEM_Registration::instance()->count([$_where]);
383 383
     }
384 384
 
@@ -406,17 +406,17 @@  discard block
 block discarded – undo
406 406
             [
407 407
                 EEM_Registration::instance()->convert_datetime_for_query(
408 408
                     'REG_date',
409
-                    $current_date . $time_start,
409
+                    $current_date.$time_start,
410 410
                     'Y-m-d H:i:s'
411 411
                 ),
412 412
                 EEM_Registration::instance()->convert_datetime_for_query(
413 413
                     'REG_date',
414
-                    $current_date . $time_end,
414
+                    $current_date.$time_end,
415 415
                     'Y-m-d H:i:s'
416 416
                 ),
417 417
             ],
418 418
         ];
419
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
419
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
420 420
         return EEM_Registration::instance()->count([$_where]);
421 421
     }
422 422
 
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
             ],
500 500
             TXN_ADMIN_URL
501 501
         );
502
-        $view_link    = EE_Registry::instance()->CAP->current_user_can(
502
+        $view_link = EE_Registry::instance()->CAP->current_user_can(
503 503
             'ee_read_transaction',
504 504
             'espresso_transactions_view_transaction'
505 505
         )
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
               . $item->get_i18n_datetime('REG_date')
514 514
               . '</a>'
515 515
             : $item->get_i18n_datetime('REG_date');
516
-        $view_link    .= '<br><span class="ee-status-text-small">'
516
+        $view_link .= '<br><span class="ee-status-text-small">'
517 517
                          . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
518 518
                          . '</span>';
519 519
         return $view_link;
@@ -540,11 +540,11 @@  discard block
 block discarded – undo
540 540
                 ?: esc_html__("No Associated Event", 'event_espresso');
541 541
         $event_name = wp_trim_words($event_name, 30, '...');
542 542
         if ($EVT_ID) {
543
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
543
+            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
544 544
                 ['action' => 'edit', 'post' => $EVT_ID],
545 545
                 EVENTS_ADMIN_URL
546 546
             );
547
-            $edit_event              =
547
+            $edit_event =
548 548
                 EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
549 549
                     ? '<a class="ee-status-color-'
550 550
                       . $this->_event_details['status']
@@ -557,12 +557,12 @@  discard block
 block discarded – undo
557 557
                       . '</a>'
558 558
                     : $event_name;
559 559
             $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
560
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
560
+            $actions['event_filter'] = '<a href="'.$edit_event_url.'" title="';
561 561
             $actions['event_filter'] .= sprintf(
562 562
                 esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
563 563
                 $event_name
564 564
             );
565
-            $actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
565
+            $actions['event_filter'] .= '">'.esc_html__('View Registrations', 'event_espresso').'</a>';
566 566
         } else {
567 567
             $edit_event              = $event_name;
568 568
             $actions['event_filter'] = '';
@@ -606,11 +606,11 @@  discard block
 block discarded – undo
606 606
     {
607 607
         $content       = '<div class="ee-registration-event-datetimes-container">';
608 608
         $expand_toggle = count($datetime_strings) > 1
609
-            ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
609
+            ? ' <span title="'.esc_attr__('Click to view all dates', 'event_espresso')
610 610
               . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
611 611
             : '';
612 612
         // get first item for initial visibility
613
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
613
+        $content .= '<div class="left">'.array_shift($datetime_strings).'</div>';
614 614
         $content .= $expand_toggle;
615 615
         if ($datetime_strings) {
616 616
             $content .= '<div style="clear:both"></div>';
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
               . $attendee_name
659 659
               . '</a>'
660 660
             : $attendee_name;
661
-        $link          .= $item->count() === 1
661
+        $link .= $item->count() === 1
662 662
             ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>'
663 663
             : '';
664 664
         $t             = $item->get_first_related('Transaction');
@@ -666,11 +666,11 @@  discard block
 block discarded – undo
666 666
             ? $t->count_related('Payment')
667 667
             : 0;
668 668
         // append group count to name
669
-        $link .= '&nbsp;' . sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
669
+        $link .= '&nbsp;'.sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
670 670
         // append reg_code
671
-        $link .= '<br>' . sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
671
+        $link .= '<br>'.sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
672 672
         // reg status text for accessibility
673
-        $link   .= '<br><span class="ee-status-text-small">'
673
+        $link .= '<br><span class="ee-status-text-small">'
674 674
                    . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
675 675
                    . '</span>';
676 676
         $action = ['_REG_ID' => $item->ID()];
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
                                 . $trash_lnk_url
698 698
                                 . '" title="'
699 699
                                 . esc_attr__('Trash Registration', 'event_espresso')
700
-                                . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
700
+                                . '">'.esc_html__('Trash', 'event_espresso').'</a>';
701 701
         } elseif ($this->_view === 'trash') {
702 702
             // restore registration link
703 703
             if (
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
                 $actions['restore'] = '<a href="'
716 716
                                       . $restore_lnk_url
717 717
                                       . '" title="'
718
-                                      . esc_attr__('Restore Registration', 'event_espresso') . '">'
719
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
718
+                                      . esc_attr__('Restore Registration', 'event_espresso').'">'
719
+                                      . esc_html__('Restore', 'event_espresso').'</a>';
720 720
             }
721 721
             if (
722 722
                 EE_Registry::instance()->CAP->current_user_can(
@@ -782,10 +782,10 @@  discard block
 block discarded – undo
782 782
         $ticket   = $item->ticket();
783 783
         $req_data = $this->_admin_page->get_request_data();
784 784
         $content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
785
-            ? '<span class="TKT_name">' . $ticket->name() . '</span><br />'
785
+            ? '<span class="TKT_name">'.$ticket->name().'</span><br />'
786 786
             : '';
787 787
         if ($item->final_price() > 0) {
788
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
788
+            $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
789 789
         } else {
790 790
             // free event
791 791
             $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
         $req_data = $this->_admin_page->get_request_data();
809 809
         $content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
810 810
             ? ''
811
-            : '<span class="TKT_name">' . $ticket->name() . '</span><br />';
812
-        $content  .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
811
+            : '<span class="TKT_name">'.$ticket->name().'</span><br />';
812
+        $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
813 813
         return $content;
814 814
     }
815 815
 
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
         $payment_method_name = $payment_method instanceof EE_Payment_Method
826 826
             ? $payment_method->admin_name()
827 827
             : esc_html__('Unknown', 'event_espresso');
828
-        $content             = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
828
+        $content             = '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>';
829 829
         if ($item->paid() > 0) {
830 830
             $content .= '<br><span class="ee-status-text-small">'
831 831
                         . sprintf(
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
                   . '">'
873 873
                   . $item->transaction()->pretty_total()
874 874
                   . '</a></span>'
875
-                : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
875
+                : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>';
876 876
         } else {
877 877
             return esc_html__("None", "event_espresso");
878 878
         }
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
                       . '">'
920 920
                       . $item->transaction()->pretty_paid()
921 921
                       . '</a><span>'
922
-                    : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
922
+                    : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
923 923
             }
924 924
         }
925 925
         return '&nbsp;';
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
             );
961 961
             $actions['view_lnk'] = '
962 962
             <li>
963
-                <a href="' . $view_lnk_url . '" title="'
963
+                <a href="' . $view_lnk_url.'" title="'
964 964
                 . esc_attr__('View Registration Details', 'event_espresso')
965 965
                 . '" class="tiny-text">
966 966
 				    <div class="dashicons dashicons-clipboard"></div>
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
             );
985 985
             $actions['edit_lnk'] = '
986 986
 			<li>
987
-                <a href="' . $edit_lnk_url . '" title="'
987
+                <a href="' . $edit_lnk_url.'" title="'
988 988
                 . esc_attr__('Edit Contact Details', 'event_espresso')
989 989
                 . '" class="tiny-text">
990 990
                     <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
             );
1011 1011
             $actions['resend_reg_lnk'] = '
1012 1012
 			<li>
1013
-			    <a href="' . $resend_reg_lnk_url . '" title="'
1013
+			    <a href="' . $resend_reg_lnk_url.'" title="'
1014 1014
                 . esc_attr__('Resend Registration Details', 'event_espresso')
1015 1015
                 . '" class="tiny-text">
1016 1016
 			        <div class="dashicons dashicons-email-alt"></div>
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
                 $this->_transaction_details['id']
1026 1026
             )
1027 1027
         ) {
1028
-            $view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
1028
+            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
1029 1029
                 [
1030 1030
                     'action' => 'view_transaction',
1031 1031
                     'TXN_ID' => $this->_transaction_details['id'],
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
             $actions['view_txn_lnk'] = '
1036 1036
 			<li>
1037 1037
                 <a class="ee-status-color-' . $this->_transaction_details['status']
1038
-                . ' tiny-text" href="' . $view_txn_lnk_url
1039
-                . '"  title="' . $this->_transaction_details['title_attr'] . '">
1038
+                . ' tiny-text" href="'.$view_txn_lnk_url
1039
+                . '"  title="'.$this->_transaction_details['title_attr'].'">
1040 1040
                     <div class="dashicons dashicons-cart"></div>
1041 1041
                 </a>
1042 1042
 			</li>';
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
             $actions['dl_invoice_lnk'] = '
1052 1052
             <li>
1053 1053
                 <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso')
1054
-                . '" target="_blank" href="' . $item->invoice_url() . '" class="tiny-text">
1054
+                . '" target="_blank" href="'.$item->invoice_url().'" class="tiny-text">
1055 1055
                     <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
1056 1056
                 </a>
1057 1057
             </li>';
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
                 'see_notifications_for',
1068 1068
                 null,
1069 1069
                 ['_REG_ID' => $item->ID()]
1070
-            ) . '
1070
+            ).'
1071 1071
             </li>';
1072 1072
         }
1073 1073
 
Please login to merge, or discard this patch.
core/exceptions/ExceptionStackTraceDisplay.php 2 patches
Indentation   +279 added lines, -279 removed lines patch added patch discarded remove patch
@@ -19,159 +19,159 @@  discard block
 block discarded – undo
19 19
 class ExceptionStackTraceDisplay
20 20
 {
21 21
 
22
-    /**
23
-     * @var   string
24
-     * @since $VID:$
25
-     */
26
-    private $class_name = '';
22
+	/**
23
+	 * @var   string
24
+	 * @since $VID:$
25
+	 */
26
+	private $class_name = '';
27 27
 
28
-    /**
29
-     * @var   string
30
-     * @since $VID:$
31
-     */
32
-    private $error_code = '';
28
+	/**
29
+	 * @var   string
30
+	 * @since $VID:$
31
+	 */
32
+	private $error_code = '';
33 33
 
34 34
 
35
-    /**
36
-     * @param Exception $exception
37
-     * @throws Exception
38
-     */
39
-    public function __construct(Exception $exception)
40
-    {
41
-        if (WP_DEBUG && ! defined('EE_TESTS_DIR')) {
42
-            $this->displayException($exception);
43
-        } else {
44
-            throw $exception;
45
-        }
46
-    }
35
+	/**
36
+	 * @param Exception $exception
37
+	 * @throws Exception
38
+	 */
39
+	public function __construct(Exception $exception)
40
+	{
41
+		if (WP_DEBUG && ! defined('EE_TESTS_DIR')) {
42
+			$this->displayException($exception);
43
+		} else {
44
+			throw $exception;
45
+		}
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * @access protected
51
-     * @param Exception $exception
52
-     * @throws ReflectionException
53
-     */
54
-    protected function displayException(Exception $exception)
55
-    {
56
-        // get separate user and developer messages if they exist
57
-        $msg = explode('||', $exception->getMessage());
58
-        $user_msg = $msg[0];
59
-        $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
60
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
61
-        // process trace info
62
-        $trace_details = $this->traceDetails($exception);
63
-        $code          = $exception->getCode() ?: $this->error_code;
64
-        // add helpful developer messages if debugging is on
65
-        // or generic non-identifying messages for non-privileged users
66
-        $error_message = WP_DEBUG
67
-            ? $this->developerError($exception, $msg, $code, $trace_details)
68
-            : $this->genericError($msg, $code);
69
-        // start gathering output
70
-        $output = '
49
+	/**
50
+	 * @access protected
51
+	 * @param Exception $exception
52
+	 * @throws ReflectionException
53
+	 */
54
+	protected function displayException(Exception $exception)
55
+	{
56
+		// get separate user and developer messages if they exist
57
+		$msg = explode('||', $exception->getMessage());
58
+		$user_msg = $msg[0];
59
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
60
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
61
+		// process trace info
62
+		$trace_details = $this->traceDetails($exception);
63
+		$code          = $exception->getCode() ?: $this->error_code;
64
+		// add helpful developer messages if debugging is on
65
+		// or generic non-identifying messages for non-privileged users
66
+		$error_message = WP_DEBUG
67
+			? $this->developerError($exception, $msg, $code, $trace_details)
68
+			: $this->genericError($msg, $code);
69
+		// start gathering output
70
+		$output = '
71 71
 <div id="ee-error-message" class="error">
72 72
     ' . $error_message . '
73 73
 </div>';
74
-        $styles = $this->exceptionStyles();
75
-        $scripts = $this->printScripts(true);
76
-        if (defined('DOING_AJAX')) {
77
-            echo wp_json_encode(array('error' => $styles . $output . $scripts));
78
-            exit();
79
-        }
80
-        echo $styles, $output, $scripts; // already escaped
81
-    }
74
+		$styles = $this->exceptionStyles();
75
+		$scripts = $this->printScripts(true);
76
+		if (defined('DOING_AJAX')) {
77
+			echo wp_json_encode(array('error' => $styles . $output . $scripts));
78
+			exit();
79
+		}
80
+		echo $styles, $output, $scripts; // already escaped
81
+	}
82 82
 
83 83
 
84
-    private function genericError($msg, $code)
85
-    {
86
-        return '
84
+	private function genericError($msg, $code)
85
+	{
86
+		return '
87 87
     <p>
88 88
         <span class="ee-error-user-msg-spn">' . trim($msg) . '</span> &nbsp; <sup>' . $code . '</sup>
89 89
     </p>';
90
-    }
90
+	}
91 91
 
92 92
 
93
-    /**
94
-     * @throws ReflectionException
95
-     */
96
-    private function developerError(Exception $exception, $msg, $code, $trace_details)
97
-    {
98
-        $time = time();
99
-        return '
93
+	/**
94
+	 * @throws ReflectionException
95
+	 */
96
+	private function developerError(Exception $exception, $msg, $code, $trace_details)
97
+	{
98
+		$time = time();
99
+		return '
100 100
 	<div class="ee-error-dev-msg-dv">
101 101
 		<p class="ee-error-dev-msg-pg">
102 102
 		    '
103
-            . sprintf(
104
-                esc_html__('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'),
105
-                '<strong class="ee-error-dev-msg-str">',
106
-                get_class($exception),
107
-                '</strong>  &nbsp; <span>',
108
-                $code . '</span>'
109
-            )
110
-            . '<br />
103
+			. sprintf(
104
+				esc_html__('%1$sAn %2$s was thrown!%3$s code: %4$s', 'event_espresso'),
105
+				'<strong class="ee-error-dev-msg-str">',
106
+				get_class($exception),
107
+				'</strong>  &nbsp; <span>',
108
+				$code . '</span>'
109
+			)
110
+			. '<br />
111 111
             <span class="big-text">"' . trim($msg) . '"</span><br/>
112 112
             <a id="display-ee-error-trace-1'
113
-               . $time
114
-               . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1'
115
-               . $time
116
-               . '">
113
+			   . $time
114
+			   . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1'
115
+			   . $time
116
+			   . '">
117 117
                 ' . esc_html__('click to view backtrace and class/method details', 'event_espresso') . '
118 118
             </a><br />
119 119
             '
120
-            . $exception->getFile()
121
-            . sprintf(
122
-                esc_html__('%1$s( line no: %2$s )%3$s', 'event_espresso'),
123
-                ' &nbsp; <span class="small-text lt-grey-text">',
124
-                $exception->getLine(),
125
-                '</span>'
126
-            )
127
-            . '
120
+			. $exception->getFile()
121
+			. sprintf(
122
+				esc_html__('%1$s( line no: %2$s )%3$s', 'event_espresso'),
123
+				' &nbsp; <span class="small-text lt-grey-text">',
124
+				$exception->getLine(),
125
+				'</span>'
126
+			)
127
+			. '
128 128
         </p>
129 129
         <div id="ee-error-trace-1'
130
-               . $time
131
-               . '-dv" class="ee-error-trace-dv" style="display: none;">
130
+			   . $time
131
+			   . '-dv" class="ee-error-trace-dv" style="display: none;">
132 132
             '
133
-               . $trace_details
134
-               . $this->classDetails() . '
133
+			   . $trace_details
134
+			   . $this->classDetails() . '
135 135
         </div>
136 136
     </div>';
137
-    }
137
+	}
138 138
 
139 139
 
140
-    /**
141
-     * @throws ReflectionException
142
-     */
143
-    private function classDetails()
144
-    {
145
-        if (empty($this->class_name)) {
146
-            return '';
147
-        }
148
-        $a = new ReflectionClass($this->class_name);
149
-        return '
140
+	/**
141
+	 * @throws ReflectionException
142
+	 */
143
+	private function classDetails()
144
+	{
145
+		if (empty($this->class_name)) {
146
+			return '';
147
+		}
148
+		$a = new ReflectionClass($this->class_name);
149
+		return '
150 150
             <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;">
151 151
                 <div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;">
152 152
                     <h3>' . esc_html__('Class Details', 'event_espresso') . '</h3>
153 153
                     <pre>' . $a . '</pre>
154 154
                 </div>
155 155
             </div>';
156
-    }
156
+	}
157 157
 
158
-    /**
159
-     * @param Exception $exception
160
-     * @return string
161
-     * @throws ReflectionException
162
-     * @since $VID:$
163
-     */
164
-    private function traceDetails(Exception $exception)
165
-    {
166
-        $trace = $exception->getTrace();
167
-        if (empty($trace)) {
168
-            return esc_html__(
169
-                'Sorry, but no trace information was available for this exception.',
170
-                'event_espresso'
171
-            );
172
-        }
158
+	/**
159
+	 * @param Exception $exception
160
+	 * @return string
161
+	 * @throws ReflectionException
162
+	 * @since $VID:$
163
+	 */
164
+	private function traceDetails(Exception $exception)
165
+	{
166
+		$trace = $exception->getTrace();
167
+		if (empty($trace)) {
168
+			return esc_html__(
169
+				'Sorry, but no trace information was available for this exception.',
170
+				'event_espresso'
171
+			);
172
+		}
173 173
 
174
-        $trace_details = '
174
+		$trace_details = '
175 175
         <div id="ee-trace-details">
176 176
             <table>
177 177
                 <tr>
@@ -180,160 +180,160 @@  discard block
 block discarded – undo
180 180
                     <th scope="col" class="ee-align-left" style="width:40%;">File</th>
181 181
                     <th scope="col" class="ee-align-left">
182 182
                     ' . esc_html__('Class', 'event_espresso')
183
-                              . '->'
184
-                              . esc_html__('Method( arguments )', 'event_espresso') . '
183
+							  . '->'
184
+							  . esc_html__('Method( arguments )', 'event_espresso') . '
185 185
                     </th>
186 186
                 </tr>';
187
-        $last_on_stack = count($trace) - 1;
188
-        // reverse array so that stack is in proper chronological order
189
-        $sorted_trace = array_reverse($trace);
190
-        foreach ($sorted_trace as $nmbr => $trace) {
191
-            $this->class_name = isset($trace['class']) ? $trace['class'] : '';
192
-            $file     = isset($trace['file']) ? $trace['file'] : '';
193
-            $type     = isset($trace['type']) ? $trace['type'] : '';
194
-            $function = isset($trace['function']) ? $trace['function'] : '';
195
-            $args     = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
196
-            $args     = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args;
197
-            $line     = isset($trace['line']) ? $trace['line'] : '';
198
-            if (empty($file) && ! empty($this->class_name)) {
199
-                $a    = new ReflectionClass($this->class_name);
200
-                $file = $a->getFileName();
201
-                if (empty($line) && ! empty($function)) {
202
-                    try {
203
-                        // if $function is a closure, this throws an exception
204
-                        $b    = new ReflectionMethod($this->class_name, $function);
205
-                        $line = $b->getStartLine();
206
-                    } catch (Exception $closure_exception) {
207
-                        $line = 'unknown';
208
-                    }
209
-                }
210
-            }
211
-            if ($nmbr === $last_on_stack) {
212
-                $file       = $exception->getFile() ?: $file;
213
-                $line       = $exception->getLine() ?: $line;
214
-                $this->error_code = $this->generate_error_code($file, $trace['function'], $line);
215
-            }
216
-            $file          = EEH_File::standardise_directory_separators($file);
217
-            $nmbr          = ! empty($nmbr) ? $nmbr : '&nbsp;';
218
-            $line          = ! empty($line) ? $line : '&nbsp;';
219
-            $file          = ! empty($file) ? $file : '&nbsp;';
220
-            $type          = ! empty($type) ? $type : '';
221
-            $function      = ! empty($function) ? $function : '';
222
-            $args          = ! empty($args) ? '( ' . $args . ' )' : '()';
223
-            $trace_details .= '
187
+		$last_on_stack = count($trace) - 1;
188
+		// reverse array so that stack is in proper chronological order
189
+		$sorted_trace = array_reverse($trace);
190
+		foreach ($sorted_trace as $nmbr => $trace) {
191
+			$this->class_name = isset($trace['class']) ? $trace['class'] : '';
192
+			$file     = isset($trace['file']) ? $trace['file'] : '';
193
+			$type     = isset($trace['type']) ? $trace['type'] : '';
194
+			$function = isset($trace['function']) ? $trace['function'] : '';
195
+			$args     = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
196
+			$args     = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args;
197
+			$line     = isset($trace['line']) ? $trace['line'] : '';
198
+			if (empty($file) && ! empty($this->class_name)) {
199
+				$a    = new ReflectionClass($this->class_name);
200
+				$file = $a->getFileName();
201
+				if (empty($line) && ! empty($function)) {
202
+					try {
203
+						// if $function is a closure, this throws an exception
204
+						$b    = new ReflectionMethod($this->class_name, $function);
205
+						$line = $b->getStartLine();
206
+					} catch (Exception $closure_exception) {
207
+						$line = 'unknown';
208
+					}
209
+				}
210
+			}
211
+			if ($nmbr === $last_on_stack) {
212
+				$file       = $exception->getFile() ?: $file;
213
+				$line       = $exception->getLine() ?: $line;
214
+				$this->error_code = $this->generate_error_code($file, $trace['function'], $line);
215
+			}
216
+			$file          = EEH_File::standardise_directory_separators($file);
217
+			$nmbr          = ! empty($nmbr) ? $nmbr : '&nbsp;';
218
+			$line          = ! empty($line) ? $line : '&nbsp;';
219
+			$file          = ! empty($file) ? $file : '&nbsp;';
220
+			$type          = ! empty($type) ? $type : '';
221
+			$function      = ! empty($function) ? $function : '';
222
+			$args          = ! empty($args) ? '( ' . $args . ' )' : '()';
223
+			$trace_details .= '
224 224
                 <tr>
225 225
                     <td class="ee-align-right">' . $nmbr . '</td>
226 226
                     <td class="ee-align-right">' . $line . '</td>
227 227
                     <td class="ee-align-left">' . $file . '</td>
228 228
                     <td class="ee-align-left">' . $this->class_name . $type . $function . $args . '</td>
229 229
                 </tr>';
230
-        }
231
-        $trace_details .= '
230
+		}
231
+		$trace_details .= '
232 232
             </table>
233 233
         </div>';
234
-        return $trace_details;
235
-    }
234
+		return $trace_details;
235
+	}
236 236
 
237 237
 
238
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
239
-    // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
238
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
239
+	// phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
240 240
 
241
-    /**
242
-     * generate string from exception trace args
243
-     *
244
-     * @param array $arguments
245
-     * @param int   $indent
246
-     * @param bool  $array
247
-     * @return string
248
-     */
249
-    private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false)
250
-    {
251
-        $args = array();
252
-        $args_count = count($arguments);
253
-        if ($args_count > 2) {
254
-            $indent++;
255
-            $args[] = '<br />';
256
-        }
257
-        $x = 0;
258
-        foreach ($arguments as $arg) {
259
-            $x++;
260
-            for ($i = 0; $i < $indent; $i++) {
261
-                $args[] = ' &nbsp;&nbsp; ';
262
-            }
263
-            if (is_string($arg)) {
264
-                if (! $array && strlen($arg) > 75) {
265
-                    $args[] = '<br />';
266
-                    for ($i = 0; $i <= $indent; $i++) {
267
-                        $args[] = ' &nbsp;&nbsp; ';
268
-                    }
269
-                    $args[] = "'" . $arg . "'<br />";
270
-                } else {
271
-                    $args[] = " '" . $arg . "'";
272
-                }
273
-            } elseif (is_array($arg)) {
274
-                $arg_count = count($arg);
275
-                if ($arg_count > 2) {
276
-                    $indent++;
277
-                    $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')';
278
-                    $indent--;
279
-                } elseif ($arg_count === 0) {
280
-                    $args[] = ' array()';
281
-                } else {
282
-                    $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )';
283
-                }
284
-            } elseif ($arg === null) {
285
-                $args[] = ' null';
286
-            } elseif (is_bool($arg)) {
287
-                $args[] = $arg ? ' true' : ' false';
288
-            } elseif (is_object($arg)) {
289
-                $args[] = get_class($arg);
290
-            } elseif (is_resource($arg)) {
291
-                $args[] = get_resource_type($arg);
292
-            } else {
293
-                $args[] = $arg;
294
-            }
295
-            if ($x === $args_count) {
296
-                if ($args_count > 2) {
297
-                    $args[] = '<br />';
298
-                    $indent--;
299
-                    for ($i = 1; $i < $indent; $i++) {
300
-                        $args[] = ' &nbsp;&nbsp; ';
301
-                    }
302
-                }
303
-            } else {
304
-                $args[] = $args_count > 2 ? ',<br />' : ', ';
305
-            }
306
-        }
307
-        return implode('', $args);
308
-    }
241
+	/**
242
+	 * generate string from exception trace args
243
+	 *
244
+	 * @param array $arguments
245
+	 * @param int   $indent
246
+	 * @param bool  $array
247
+	 * @return string
248
+	 */
249
+	private function _convert_args_to_string($arguments = array(), $indent = 0, $array = false)
250
+	{
251
+		$args = array();
252
+		$args_count = count($arguments);
253
+		if ($args_count > 2) {
254
+			$indent++;
255
+			$args[] = '<br />';
256
+		}
257
+		$x = 0;
258
+		foreach ($arguments as $arg) {
259
+			$x++;
260
+			for ($i = 0; $i < $indent; $i++) {
261
+				$args[] = ' &nbsp;&nbsp; ';
262
+			}
263
+			if (is_string($arg)) {
264
+				if (! $array && strlen($arg) > 75) {
265
+					$args[] = '<br />';
266
+					for ($i = 0; $i <= $indent; $i++) {
267
+						$args[] = ' &nbsp;&nbsp; ';
268
+					}
269
+					$args[] = "'" . $arg . "'<br />";
270
+				} else {
271
+					$args[] = " '" . $arg . "'";
272
+				}
273
+			} elseif (is_array($arg)) {
274
+				$arg_count = count($arg);
275
+				if ($arg_count > 2) {
276
+					$indent++;
277
+					$args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')';
278
+					$indent--;
279
+				} elseif ($arg_count === 0) {
280
+					$args[] = ' array()';
281
+				} else {
282
+					$args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )';
283
+				}
284
+			} elseif ($arg === null) {
285
+				$args[] = ' null';
286
+			} elseif (is_bool($arg)) {
287
+				$args[] = $arg ? ' true' : ' false';
288
+			} elseif (is_object($arg)) {
289
+				$args[] = get_class($arg);
290
+			} elseif (is_resource($arg)) {
291
+				$args[] = get_resource_type($arg);
292
+			} else {
293
+				$args[] = $arg;
294
+			}
295
+			if ($x === $args_count) {
296
+				if ($args_count > 2) {
297
+					$args[] = '<br />';
298
+					$indent--;
299
+					for ($i = 1; $i < $indent; $i++) {
300
+						$args[] = ' &nbsp;&nbsp; ';
301
+					}
302
+				}
303
+			} else {
304
+				$args[] = $args_count > 2 ? ',<br />' : ', ';
305
+			}
306
+		}
307
+		return implode('', $args);
308
+	}
309 309
 
310 310
 
311
-    /**
312
-     * create error code from filepath, function name,
313
-     * and line number where exception or error was thrown
314
-     *
315
-     * @access protected
316
-     * @param string $file
317
-     * @param string $func
318
-     * @param string $line
319
-     * @return string
320
-     */
321
-    protected function generate_error_code($file = '', $func = '', $line = '')
322
-    {
323
-        $file_bits = explode('.', basename($file));
324
-        $error_code = ! empty($file_bits[0]) ? $file_bits[0] : '';
325
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
326
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
327
-        return $error_code;
328
-    }
311
+	/**
312
+	 * create error code from filepath, function name,
313
+	 * and line number where exception or error was thrown
314
+	 *
315
+	 * @access protected
316
+	 * @param string $file
317
+	 * @param string $func
318
+	 * @param string $line
319
+	 * @return string
320
+	 */
321
+	protected function generate_error_code($file = '', $func = '', $line = '')
322
+	{
323
+		$file_bits = explode('.', basename($file));
324
+		$error_code = ! empty($file_bits[0]) ? $file_bits[0] : '';
325
+		$error_code .= ! empty($func) ? ' - ' . $func : '';
326
+		$error_code .= ! empty($line) ? ' - ' . $line : '';
327
+		return $error_code;
328
+	}
329 329
 
330 330
 
331
-    /**
332
-     * @return string
333
-     */
334
-    private function exceptionStyles()
335
-    {
336
-        return '
331
+	/**
332
+	 * @return string
333
+	 */
334
+	private function exceptionStyles()
335
+	{
336
+		return '
337 337
 <style media="screen">
338 338
 	#ee-error-message {
339 339
 		max-width:90% !important;
@@ -391,34 +391,34 @@  discard block
 block discarded – undo
391 391
 		color: #999;
392 392
 	}
393 393
 </style>';
394
-    }
394
+	}
395 395
 
396 396
 
397
-    /**
398
-     * _print_scripts
399
-     *
400
-     * @param bool $force_print
401
-     * @return string
402
-     */
403
-    private function printScripts($force_print = false)
404
-    {
405
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
406
-            //  if script is already enqueued then we can just get out
407
-            if (wp_script_is('ee_error_js')) {
408
-                return '';
409
-            }
410
-            if (wp_script_is('ee_error_js', 'registered')) {
411
-                wp_enqueue_style('espresso_default');
412
-                wp_enqueue_style('espresso_custom_css');
413
-                wp_enqueue_script('ee_error_js');
414
-                wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
415
-                return '';
416
-            }
417
-        }
418
-        $jquery = esc_url_raw(includes_url() . 'js/jquery/jquery.js');
419
-        $core = esc_url_raw(EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . espresso_version());
420
-        $ee_error = esc_url_raw(EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js?ver=' . espresso_version());
421
-        return '
397
+	/**
398
+	 * _print_scripts
399
+	 *
400
+	 * @param bool $force_print
401
+	 * @return string
402
+	 */
403
+	private function printScripts($force_print = false)
404
+	{
405
+		if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
406
+			//  if script is already enqueued then we can just get out
407
+			if (wp_script_is('ee_error_js')) {
408
+				return '';
409
+			}
410
+			if (wp_script_is('ee_error_js', 'registered')) {
411
+				wp_enqueue_style('espresso_default');
412
+				wp_enqueue_style('espresso_custom_css');
413
+				wp_enqueue_script('ee_error_js');
414
+				wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
415
+				return '';
416
+			}
417
+		}
418
+		$jquery = esc_url_raw(includes_url() . 'js/jquery/jquery.js');
419
+		$core = esc_url_raw(EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . espresso_version());
420
+		$ee_error = esc_url_raw(EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js?ver=' . espresso_version());
421
+		return '
422 422
 <script>
423 423
 /* <![CDATA[ */
424 424
 const ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
@@ -428,5 +428,5 @@  discard block
 block discarded – undo
428 428
 <script src="' . $core . '" type="text/javascript" ></script>
429 429
 <script src="' . $ee_error . '" type="text/javascript" ></script>
430 430
 ';
431
-    }
431
+	}
432 432
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
         // start gathering output
70 70
         $output = '
71 71
 <div id="ee-error-message" class="error">
72
-    ' . $error_message . '
72
+    ' . $error_message.'
73 73
 </div>';
74 74
         $styles = $this->exceptionStyles();
75 75
         $scripts = $this->printScripts(true);
76 76
         if (defined('DOING_AJAX')) {
77
-            echo wp_json_encode(array('error' => $styles . $output . $scripts));
77
+            echo wp_json_encode(array('error' => $styles.$output.$scripts));
78 78
             exit();
79 79
         }
80 80
         echo $styles, $output, $scripts; // already escaped
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     {
86 86
         return '
87 87
     <p>
88
-        <span class="ee-error-user-msg-spn">' . trim($msg) . '</span> &nbsp; <sup>' . $code . '</sup>
88
+        <span class="ee-error-user-msg-spn">' . trim($msg).'</span> &nbsp; <sup>'.$code.'</sup>
89 89
     </p>';
90 90
     }
91 91
 
@@ -105,16 +105,16 @@  discard block
 block discarded – undo
105 105
                 '<strong class="ee-error-dev-msg-str">',
106 106
                 get_class($exception),
107 107
                 '</strong>  &nbsp; <span>',
108
-                $code . '</span>'
108
+                $code.'</span>'
109 109
             )
110 110
             . '<br />
111
-            <span class="big-text">"' . trim($msg) . '"</span><br/>
111
+            <span class="big-text">"' . trim($msg).'"</span><br/>
112 112
             <a id="display-ee-error-trace-1'
113 113
                . $time
114 114
                . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-1'
115 115
                . $time
116 116
                . '">
117
-                ' . esc_html__('click to view backtrace and class/method details', 'event_espresso') . '
117
+                ' . esc_html__('click to view backtrace and class/method details', 'event_espresso').'
118 118
             </a><br />
119 119
             '
120 120
             . $exception->getFile()
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                . '-dv" class="ee-error-trace-dv" style="display: none;">
132 132
             '
133 133
                . $trace_details
134
-               . $this->classDetails() . '
134
+               . $this->classDetails().'
135 135
         </div>
136 136
     </div>';
137 137
     }
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
         return '
150 150
             <div style="padding:3px; margin:0 0 1em; border:1px solid #999; background:#fff; border-radius:3px;">
151 151
                 <div style="padding:1em 2em; border:1px solid #999; background:#fcfcfc;">
152
-                    <h3>' . esc_html__('Class Details', 'event_espresso') . '</h3>
153
-                    <pre>' . $a . '</pre>
152
+                    <h3>' . esc_html__('Class Details', 'event_espresso').'</h3>
153
+                    <pre>' . $a.'</pre>
154 154
                 </div>
155 155
             </div>';
156 156
     }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
                     <th scope="col" class="ee-align-left">
182 182
                     ' . esc_html__('Class', 'event_espresso')
183 183
                               . '->'
184
-                              . esc_html__('Method( arguments )', 'event_espresso') . '
184
+                              . esc_html__('Method( arguments )', 'event_espresso').'
185 185
                     </th>
186 186
                 </tr>';
187 187
         $last_on_stack = count($trace) - 1;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
             $type     = isset($trace['type']) ? $trace['type'] : '';
194 194
             $function = isset($trace['function']) ? $trace['function'] : '';
195 195
             $args     = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
196
-            $args     = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />' . $args . '<br />' : $args;
196
+            $args     = isset($trace['args']) && count($trace['args']) > 4 ? ' <br />'.$args.'<br />' : $args;
197 197
             $line     = isset($trace['line']) ? $trace['line'] : '';
198 198
             if (empty($file) && ! empty($this->class_name)) {
199 199
                 $a    = new ReflectionClass($this->class_name);
@@ -219,13 +219,13 @@  discard block
 block discarded – undo
219 219
             $file          = ! empty($file) ? $file : '&nbsp;';
220 220
             $type          = ! empty($type) ? $type : '';
221 221
             $function      = ! empty($function) ? $function : '';
222
-            $args          = ! empty($args) ? '( ' . $args . ' )' : '()';
222
+            $args          = ! empty($args) ? '( '.$args.' )' : '()';
223 223
             $trace_details .= '
224 224
                 <tr>
225
-                    <td class="ee-align-right">' . $nmbr . '</td>
226
-                    <td class="ee-align-right">' . $line . '</td>
227
-                    <td class="ee-align-left">' . $file . '</td>
228
-                    <td class="ee-align-left">' . $this->class_name . $type . $function . $args . '</td>
225
+                    <td class="ee-align-right">' . $nmbr.'</td>
226
+                    <td class="ee-align-right">' . $line.'</td>
227
+                    <td class="ee-align-left">' . $file.'</td>
228
+                    <td class="ee-align-left">' . $this->class_name.$type.$function.$args.'</td>
229 229
                 </tr>';
230 230
         }
231 231
         $trace_details .= '
@@ -261,25 +261,25 @@  discard block
 block discarded – undo
261 261
                 $args[] = ' &nbsp;&nbsp; ';
262 262
             }
263 263
             if (is_string($arg)) {
264
-                if (! $array && strlen($arg) > 75) {
264
+                if ( ! $array && strlen($arg) > 75) {
265 265
                     $args[] = '<br />';
266 266
                     for ($i = 0; $i <= $indent; $i++) {
267 267
                         $args[] = ' &nbsp;&nbsp; ';
268 268
                     }
269
-                    $args[] = "'" . $arg . "'<br />";
269
+                    $args[] = "'".$arg."'<br />";
270 270
                 } else {
271
-                    $args[] = " '" . $arg . "'";
271
+                    $args[] = " '".$arg."'";
272 272
                 }
273 273
             } elseif (is_array($arg)) {
274 274
                 $arg_count = count($arg);
275 275
                 if ($arg_count > 2) {
276 276
                     $indent++;
277
-                    $args[] = ' array(' . $this->_convert_args_to_string($arg, $indent, true) . ')';
277
+                    $args[] = ' array('.$this->_convert_args_to_string($arg, $indent, true).')';
278 278
                     $indent--;
279 279
                 } elseif ($arg_count === 0) {
280 280
                     $args[] = ' array()';
281 281
                 } else {
282
-                    $args[] = ' array( ' . $this->_convert_args_to_string($arg) . ' )';
282
+                    $args[] = ' array( '.$this->_convert_args_to_string($arg).' )';
283 283
                 }
284 284
             } elseif ($arg === null) {
285 285
                 $args[] = ' null';
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
     {
323 323
         $file_bits = explode('.', basename($file));
324 324
         $error_code = ! empty($file_bits[0]) ? $file_bits[0] : '';
325
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
326
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
325
+        $error_code .= ! empty($func) ? ' - '.$func : '';
326
+        $error_code .= ! empty($line) ? ' - '.$line : '';
327 327
         return $error_code;
328 328
     }
329 329
 
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
      */
403 403
     private function printScripts($force_print = false)
404 404
     {
405
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
405
+        if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
406 406
             //  if script is already enqueued then we can just get out
407 407
             if (wp_script_is('ee_error_js')) {
408 408
                 return '';
@@ -415,18 +415,18 @@  discard block
 block discarded – undo
415 415
                 return '';
416 416
             }
417 417
         }
418
-        $jquery = esc_url_raw(includes_url() . 'js/jquery/jquery.js');
419
-        $core = esc_url_raw(EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . espresso_version());
420
-        $ee_error = esc_url_raw(EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js?ver=' . espresso_version());
418
+        $jquery = esc_url_raw(includes_url().'js/jquery/jquery.js');
419
+        $core = esc_url_raw(EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.espresso_version());
420
+        $ee_error = esc_url_raw(EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js?ver='.espresso_version());
421 421
         return '
422 422
 <script>
423 423
 /* <![CDATA[ */
424
-const ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
424
+const ee_settings = {"wp_debug":"' . WP_DEBUG.'"};
425 425
 /* ]]> */
426 426
 </script>
427
-<script src="' . $jquery . '" type="text/javascript" ></script>
428
-<script src="' . $core . '" type="text/javascript" ></script>
429
-<script src="' . $ee_error . '" type="text/javascript" ></script>
427
+<script src="' . $jquery.'" type="text/javascript" ></script>
428
+<script src="' . $core.'" type="text/javascript" ></script>
429
+<script src="' . $ee_error.'" type="text/javascript" ></script>
430 430
 ';
431 431
     }
432 432
 }
Please login to merge, or discard this patch.
core/libraries/messages/messenger/EE_Email_messenger.class.php 1 patch
Indentation   +644 added lines, -644 removed lines patch added patch discarded remove patch
@@ -6,648 +6,648 @@
 block discarded – undo
6 6
 class EE_Email_messenger extends EE_messenger
7 7
 {
8 8
 
9
-    /**
10
-     * To field for email
11
-     * @var string
12
-     */
13
-    protected $_to = '';
14
-
15
-
16
-    /**
17
-     * CC field for email.
18
-     * @var string
19
-     */
20
-    protected $_cc = '';
21
-
22
-    /**
23
-     * From field for email
24
-     * @var string
25
-     */
26
-    protected $_from = '';
27
-
28
-
29
-    /**
30
-     * Subject field for email
31
-     * @var string
32
-     */
33
-    protected $_subject = '';
34
-
35
-
36
-    /**
37
-     * Content field for email
38
-     * @var string
39
-     */
40
-    protected $_content = '';
41
-
42
-
43
-    /**
44
-     * constructor
45
-     *
46
-     * @access public
47
-     */
48
-    public function __construct()
49
-    {
50
-        // set name and description properties
51
-        $this->name                = 'email';
52
-        $this->description         = sprintf(
53
-            esc_html__(
54
-                'This messenger delivers messages via email using the built-in %s function included with WordPress',
55
-                'event_espresso'
56
-            ),
57
-            '<code>wp_mail</code>'
58
-        );
59
-        $this->label               = array(
60
-            'singular' => esc_html__('email', 'event_espresso'),
61
-            'plural'   => esc_html__('emails', 'event_espresso'),
62
-        );
63
-        $this->activate_on_install = true;
64
-
65
-        // we're using defaults so let's call parent constructor that will take care of setting up all the other
66
-        // properties
67
-        parent::__construct();
68
-    }
69
-
70
-
71
-    /**
72
-     * see abstract declaration in parent class for details.
73
-     */
74
-    protected function _set_admin_pages()
75
-    {
76
-        $this->admin_registered_pages = array(
77
-            'events_edit' => true,
78
-        );
79
-    }
80
-
81
-
82
-    /**
83
-     * see abstract declaration in parent class for details
84
-     */
85
-    protected function _set_valid_shortcodes()
86
-    {
87
-        // remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the
88
-        // message type.
89
-        $this->_valid_shortcodes = array(
90
-            'to'   => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
91
-            'cc' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
92
-            'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
93
-        );
94
-    }
95
-
96
-
97
-    /**
98
-     * see abstract declaration in parent class for details
99
-     *
100
-     * @access protected
101
-     * @return void
102
-     */
103
-    protected function _set_validator_config()
104
-    {
105
-        $valid_shortcodes = $this->get_valid_shortcodes();
106
-
107
-        $this->_validator_config = array(
108
-            'to'            => array(
109
-                'shortcodes' => $valid_shortcodes['to'],
110
-                'type'       => 'email',
111
-            ),
112
-            'cc' => array(
113
-                'shortcodes' => $valid_shortcodes['to'],
114
-                'type' => 'email',
115
-            ),
116
-            'from'          => array(
117
-                'shortcodes' => $valid_shortcodes['from'],
118
-                'type'       => 'email',
119
-            ),
120
-            'subject'       => array(
121
-                'shortcodes' => array(
122
-                    'organization',
123
-                    'primary_registration_details',
124
-                    'event_author',
125
-                    'primary_registration_details',
126
-                    'recipient_details',
127
-                ),
128
-            ),
129
-            'content'       => array(
130
-                'shortcodes' => array(
131
-                    'event_list',
132
-                    'attendee_list',
133
-                    'ticket_list',
134
-                    'organization',
135
-                    'primary_registration_details',
136
-                    'primary_registration_list',
137
-                    'event_author',
138
-                    'recipient_details',
139
-                    'recipient_list',
140
-                    'transaction',
141
-                    'messenger',
142
-                ),
143
-            ),
144
-            'attendee_list' => array(
145
-                'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
146
-                'required'   => array('[ATTENDEE_LIST]'),
147
-            ),
148
-            'event_list'    => array(
149
-                'shortcodes' => array(
150
-                    'event',
151
-                    'attendee_list',
152
-                    'ticket_list',
153
-                    'venue',
154
-                    'datetime_list',
155
-                    'attendee',
156
-                    'primary_registration_details',
157
-                    'primary_registration_list',
158
-                    'event_author',
159
-                    'recipient_details',
160
-                    'recipient_list',
161
-                ),
162
-                'required'   => array('[EVENT_LIST]'),
163
-            ),
164
-            'ticket_list'   => array(
165
-                'shortcodes' => array(
166
-                    'event_list',
167
-                    'attendee_list',
168
-                    'ticket',
169
-                    'datetime_list',
170
-                    'primary_registration_details',
171
-                    'recipient_details',
172
-                ),
173
-                'required'   => array('[TICKET_LIST]'),
174
-            ),
175
-            'datetime_list' => array(
176
-                'shortcodes' => array('datetime'),
177
-                'required'   => array('[DATETIME_LIST]'),
178
-            ),
179
-        );
180
-    }
181
-
182
-
183
-    /**
184
-     * @see   parent EE_messenger class for docs
185
-     * @since 4.5.0
186
-     */
187
-    public function do_secondary_messenger_hooks($sending_messenger_name)
188
-    {
189
-        if ($sending_messenger_name === 'html') {
190
-            add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
191
-        }
192
-    }
193
-
194
-
195
-    public function add_email_css(
196
-        $variation_path,
197
-        $messenger,
198
-        $message_type,
199
-        $type,
200
-        $variation,
201
-        $file_extension,
202
-        $url,
203
-        EE_Messages_Template_Pack $template_pack
204
-    ) {
205
-        // prevent recursion on this callback.
206
-        remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10);
207
-        $variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false);
208
-
209
-        add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
210
-        return $variation;
211
-    }
212
-
213
-
214
-    /**
215
-     * See parent for details
216
-     *
217
-     * @access protected
218
-     * @return void
219
-     */
220
-    protected function _set_test_settings_fields()
221
-    {
222
-        $this->_test_settings_fields = array(
223
-            'to'      => array(
224
-                'input'      => 'text',
225
-                'label'      => esc_html__('Send a test email to', 'event_espresso'),
226
-                'type'       => 'email',
227
-                'required'   => false,
228
-                'validation' => true,
229
-                'css_class'  => 'large-text',
230
-                'format'     => '%s',
231
-                'default'    => get_bloginfo('admin_email'),
232
-            ),
233
-            'subject' => array(
234
-                'input'      => 'hidden',
235
-                'label'      => '',
236
-                'type'       => 'string',
237
-                'required'   => false,
238
-                'validation' => false,
239
-                'format'     => '%s',
240
-                'value'      => sprintf(esc_html__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')),
241
-                'default'    => '',
242
-                'css_class'  => '',
243
-            ),
244
-        );
245
-    }
246
-
247
-
248
-    /**
249
-     * _set_template_fields
250
-     * This sets up the fields that a messenger requires for the message to go out.
251
-     *
252
-     * @access  protected
253
-     * @return void
254
-     */
255
-    protected function _set_template_fields()
256
-    {
257
-        // any extra template fields that are NOT used by the messenger but will get used by a messenger field for
258
-        // shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field
259
-        // they relate to.  This is important for the Messages_admin to know what fields to display to the user.
260
-        //  Also, notice that the "values" are equal to the field type that messages admin will use to know what
261
-        // kind of field to display. The values ALSO have one index labeled "shortcode".  the values in that array
262
-        // indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be
263
-        // displayed.  If the required shortcode isn't part of the shortcodes array then the field is not needed and
264
-        // will not be displayed/parsed.
265
-        $this->_template_fields = array(
266
-            'to'      => array(
267
-                'input'      => 'text',
268
-                'label'      => esc_html_x(
269
-                    'To',
270
-                    'Label for the "To" field for email addresses',
271
-                    'event_espresso'
272
-                ),
273
-                'type'       => 'string',
274
-                'required'   => true,
275
-                'validation' => true,
276
-                'css_class'  => 'large-text',
277
-                'format'     => '%s',
278
-            ),
279
-            'cc'      => array(
280
-                'input'      => 'text',
281
-                'label'      => esc_html_x(
282
-                    'CC',
283
-                    'Label for the "Carbon Copy" field used for additional email addresses',
284
-                    'event_espresso'
285
-                ),
286
-                'type'       => 'string',
287
-                'required'   => false,
288
-                'validation' => true,
289
-                'css_class'  => 'large-text',
290
-                'format'     => '%s',
291
-            ),
292
-            'from'    => array(
293
-                'input'      => 'text',
294
-                'label'      => esc_html_x(
295
-                    'From',
296
-                    'Label for the "From" field for email addresses.',
297
-                    'event_espresso'
298
-                ),
299
-                'type'       => 'string',
300
-                'required'   => true,
301
-                'validation' => true,
302
-                'css_class'  => 'large-text',
303
-                'format'     => '%s',
304
-            ),
305
-            'subject' => array(
306
-                'input'      => 'text',
307
-                'label'      => esc_html_x(
308
-                    'Subject',
309
-                    'Label for the "Subject" field (short description of contents) for emails.',
310
-                    'event_espresso'
311
-                ),
312
-                'type'       => 'string',
313
-                'required'   => true,
314
-                'validation' => true,
315
-                'css_class'  => 'large-text',
316
-                'format'     => '%s',
317
-            ),
318
-            'content' => '',
319
-            // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
320
-            'extra'   => array(
321
-                'content' => array(
322
-                    'main'          => array(
323
-                        'input'      => 'wp_editor',
324
-                        'label'      => esc_html__('Main Content', 'event_espresso'),
325
-                        'type'       => 'string',
326
-                        'required'   => true,
327
-                        'validation' => true,
328
-                        'format'     => '%s',
329
-                        'rows'       => '15',
330
-                    ),
331
-                    'event_list'    => array(
332
-                        'input'               => 'wp_editor',
333
-                        'label'               => '[EVENT_LIST]',
334
-                        'type'                => 'string',
335
-                        'required'            => true,
336
-                        'validation'          => true,
337
-                        'format'              => '%s',
338
-                        'rows'                => '15',
339
-                        'shortcodes_required' => array('[EVENT_LIST]'),
340
-                    ),
341
-                    'attendee_list' => array(
342
-                        'input'               => 'textarea',
343
-                        'label'               => '[ATTENDEE_LIST]',
344
-                        'type'                => 'string',
345
-                        'required'            => true,
346
-                        'validation'          => true,
347
-                        'format'              => '%s',
348
-                        'css_class'           => 'large-text',
349
-                        'rows'                => '5',
350
-                        'shortcodes_required' => array('[ATTENDEE_LIST]'),
351
-                    ),
352
-                    'ticket_list'   => array(
353
-                        'input'               => 'textarea',
354
-                        'label'               => '[TICKET_LIST]',
355
-                        'type'                => 'string',
356
-                        'required'            => true,
357
-                        'validation'          => true,
358
-                        'format'              => '%s',
359
-                        'css_class'           => 'large-text',
360
-                        'rows'                => '10',
361
-                        'shortcodes_required' => array('[TICKET_LIST]'),
362
-                    ),
363
-                    'datetime_list' => array(
364
-                        'input'               => 'textarea',
365
-                        'label'               => '[DATETIME_LIST]',
366
-                        'type'                => 'string',
367
-                        'required'            => true,
368
-                        'validation'          => true,
369
-                        'format'              => '%s',
370
-                        'css_class'           => 'large-text',
371
-                        'rows'                => '10',
372
-                        'shortcodes_required' => array('[DATETIME_LIST]'),
373
-                    ),
374
-                ),
375
-            ),
376
-        );
377
-    }
378
-
379
-
380
-    /**
381
-     * See definition of this class in parent
382
-     */
383
-    protected function _set_default_message_types()
384
-    {
385
-        $this->_default_message_types = array(
386
-            'payment',
387
-            'payment_refund',
388
-            'registration',
389
-            'not_approved_registration',
390
-            'pending_approval',
391
-        );
392
-    }
393
-
394
-
395
-    /**
396
-     * @see   definition of this class in parent
397
-     * @since 4.5.0
398
-     */
399
-    protected function _set_valid_message_types()
400
-    {
401
-        $this->_valid_message_types = array(
402
-            'payment',
403
-            'registration',
404
-            'not_approved_registration',
405
-            'declined_registration',
406
-            'cancelled_registration',
407
-            'pending_approval',
408
-            'registration_summary',
409
-            'payment_reminder',
410
-            'payment_declined',
411
-            'payment_refund',
412
-        );
413
-    }
414
-
415
-
416
-    /**
417
-     * setting up admin_settings_fields for messenger.
418
-     */
419
-    protected function _set_admin_settings_fields()
420
-    {
421
-    }
422
-
423
-    /**
424
-     * We just deliver the messages don't kill us!!
425
-     *
426
-     * @return bool|WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if
427
-     *              present.
428
-     * @throws EE_Error
429
-     * @throws \TijsVerkoyen\CssToInlineStyles\Exception
430
-     */
431
-    protected function _send_message()
432
-    {
433
-        $success = wp_mail(
434
-            $this->_to,
435
-            // some old values for subject may be expecting HTML entities to be decoded in the subject
436
-            // and subjects aren't interpreted as HTML, so there should be no HTML in them
437
-            wp_strip_all_tags(wp_specialchars_decode($this->_subject, ENT_QUOTES)),
438
-            $this->_body(),
439
-            $this->_headers()
440
-        );
441
-        if (! $success) {
442
-            EE_Error::add_error(
443
-                sprintf(
444
-                    esc_html__(
445
-                        'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s',
446
-                        'event_espresso'
447
-                    ),
448
-                    $this->_to,
449
-                    $this->_from,
450
-                    '<br />'
451
-                ),
452
-                __FILE__,
453
-                __FUNCTION__,
454
-                __LINE__
455
-            );
456
-        }
457
-        return $success;
458
-    }
459
-
460
-
461
-    /**
462
-     * see parent for definition
463
-     *
464
-     * @return string html body of the message content and the related css.
465
-     * @throws EE_Error
466
-     * @throws \TijsVerkoyen\CssToInlineStyles\Exception
467
-     */
468
-    protected function _preview()
469
-    {
470
-        return $this->_body(true);
471
-    }
472
-
473
-
474
-    /**
475
-     * Setup headers for email
476
-     *
477
-     * @access protected
478
-     * @return string formatted header for email
479
-     */
480
-    protected function _headers()
481
-    {
482
-        $this->_ensure_has_from_email_address();
483
-        $from    = $this->_from;
484
-        $headers = array(
485
-            'From:' . $from,
486
-            'Reply-To:' . $from,
487
-            'Content-Type:text/html; charset=utf-8',
488
-        );
489
-
490
-        /**
491
-         * Second condition added as a result of https://events.codebasehq.com/projects/event-espresso/tickets/11416 to
492
-         * cover back compat where there may be users who have saved cc values in their db for the newsletter message
493
-         * type which they are no longer able to change.
494
-         */
495
-        if (! empty($this->_cc) && ! $this->_incoming_message_type instanceof EE_Newsletter_message_type) {
496
-            $headers[] = 'cc: ' . $this->_cc;
497
-        }
498
-
499
-        // but wait!  Header's for the from is NOT reliable because some plugins don't respect From: as set in the
500
-        // header.
501
-        add_filter('wp_mail_from', array($this, 'set_from_address'), 100);
502
-        add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100);
503
-        return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this);
504
-    }
505
-
506
-
507
-    /**
508
-     * This simply ensures that the from address is not empty.  If it is, then we use whatever is set as the site email
509
-     * address for the from address to avoid problems with sending emails.
510
-     */
511
-    protected function _ensure_has_from_email_address()
512
-    {
513
-        if (empty($this->_from)) {
514
-            $this->_from = get_bloginfo('admin_email');
515
-        }
516
-    }
517
-
518
-
519
-    /**
520
-     * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}>
521
-     * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY*
522
-     * be empty
523
-     *
524
-     * @since 4.3.1
525
-     * @return array
526
-     */
527
-    private function _parse_from()
528
-    {
529
-        if (strpos($this->_from, '<') !== false) {
530
-            $from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1);
531
-            $from_name = str_replace('"', '', $from_name);
532
-            $from_name = trim($from_name);
533
-
534
-            $from_email = substr($this->_from, strpos($this->_from, '<') + 1);
535
-            $from_email = str_replace('>', '', $from_email);
536
-            $from_email = trim($from_email);
537
-        } elseif (trim($this->_from) !== '') {
538
-            $from_name  = '';
539
-            $from_email = trim($this->_from);
540
-        } else {
541
-            $from_name = $from_email = '';
542
-        }
543
-        return array($from_name, $from_email);
544
-    }
545
-
546
-
547
-    /**
548
-     * Callback for the wp_mail_from filter.
549
-     *
550
-     * @since 4.3.1
551
-     * @param string $from_email What the original from_email is.
552
-     * @return string
553
-     */
554
-    public function set_from_address($from_email)
555
-    {
556
-        $parsed_from = $this->_parse_from();
557
-        // includes fallback if the parsing failed.
558
-        $from_email = is_array($parsed_from) && ! empty($parsed_from[1])
559
-            ? $parsed_from[1]
560
-            : get_bloginfo('admin_email');
561
-        return $from_email;
562
-    }
563
-
564
-
565
-    /**
566
-     * Callback fro the wp_mail_from_name filter.
567
-     *
568
-     * @since 4.3.1
569
-     * @param string $from_name The original from_name.
570
-     * @return string
571
-     */
572
-    public function set_from_name($from_name)
573
-    {
574
-        $parsed_from = $this->_parse_from();
575
-        if (is_array($parsed_from) && ! empty($parsed_from[0])) {
576
-            $from_name = $parsed_from[0];
577
-        }
578
-
579
-        // if from name is "WordPress" let's sub in the site name instead (more friendly!)
580
-        // but realize the default name is HTML entity-encoded
581
-        $from_name = $from_name == 'WordPress' ? wp_specialchars_decode(get_bloginfo(), ENT_QUOTES) : $from_name;
582
-
583
-        return $from_name;
584
-    }
585
-
586
-
587
-    /**
588
-     * setup body for email
589
-     *
590
-     * @param bool $preview will determine whether this is preview template or not.
591
-     * @return string formatted body for email.
592
-     * @throws EE_Error
593
-     * @throws \TijsVerkoyen\CssToInlineStyles\Exception
594
-     */
595
-    protected function _body($preview = false)
596
-    {
597
-        // setup template args!
598
-        $this->_template_args = array(
599
-            'subject'   => $this->_subject,
600
-            'from'      => $this->_from,
601
-            'main_body' => wpautop($this->_content),
602
-        );
603
-        $body                 = $this->_get_main_template($preview);
604
-
605
-        /**
606
-         * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
607
-         *
608
-         * @type    bool $preview Indicates whether a preview is being generated or not.
609
-         * @return  bool    true  indicates to use the inliner, false bypasses it.
610
-         */
611
-        if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
612
-            // require CssToInlineStyles library and its dependencies via composer autoloader
613
-            require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
614
-
615
-            // now if this isn't a preview, let's setup the body so it has inline styles
616
-            if (! $preview || ($preview && defined('DOING_AJAX'))) {
617
-                $style = file_get_contents(
618
-                    $this->get_variation(
619
-                        $this->_tmp_pack,
620
-                        $this->_incoming_message_type->name,
621
-                        false,
622
-                        'main',
623
-                        $this->_variation
624
-                    ),
625
-                    true
626
-                );
627
-                $CSS   = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style);
628
-                // for some reason the library has a bracket and new line at the beginning.  This takes care of that.
629
-                $body  = ltrim($CSS->convert(true), ">\n");
630
-                // see https://events.codebasehq.com/projects/event-espresso/tickets/8609
631
-                $body  = ltrim($body, "<?");
632
-            }
633
-        }
634
-        return $body;
635
-    }
636
-
637
-
638
-    /**
639
-     * This just returns any existing test settings that might be saved in the database
640
-     *
641
-     * @access public
642
-     * @return array
643
-     */
644
-    public function get_existing_test_settings()
645
-    {
646
-        $settings = parent::get_existing_test_settings();
647
-        // override subject if present because we always want it to be fresh.
648
-        if (is_array($settings) && ! empty($settings['subject'])) {
649
-            $settings['subject'] = sprintf(esc_html__('Test email sent from %s', 'event_espresso'), get_bloginfo('name'));
650
-        }
651
-        return $settings;
652
-    }
9
+	/**
10
+	 * To field for email
11
+	 * @var string
12
+	 */
13
+	protected $_to = '';
14
+
15
+
16
+	/**
17
+	 * CC field for email.
18
+	 * @var string
19
+	 */
20
+	protected $_cc = '';
21
+
22
+	/**
23
+	 * From field for email
24
+	 * @var string
25
+	 */
26
+	protected $_from = '';
27
+
28
+
29
+	/**
30
+	 * Subject field for email
31
+	 * @var string
32
+	 */
33
+	protected $_subject = '';
34
+
35
+
36
+	/**
37
+	 * Content field for email
38
+	 * @var string
39
+	 */
40
+	protected $_content = '';
41
+
42
+
43
+	/**
44
+	 * constructor
45
+	 *
46
+	 * @access public
47
+	 */
48
+	public function __construct()
49
+	{
50
+		// set name and description properties
51
+		$this->name                = 'email';
52
+		$this->description         = sprintf(
53
+			esc_html__(
54
+				'This messenger delivers messages via email using the built-in %s function included with WordPress',
55
+				'event_espresso'
56
+			),
57
+			'<code>wp_mail</code>'
58
+		);
59
+		$this->label               = array(
60
+			'singular' => esc_html__('email', 'event_espresso'),
61
+			'plural'   => esc_html__('emails', 'event_espresso'),
62
+		);
63
+		$this->activate_on_install = true;
64
+
65
+		// we're using defaults so let's call parent constructor that will take care of setting up all the other
66
+		// properties
67
+		parent::__construct();
68
+	}
69
+
70
+
71
+	/**
72
+	 * see abstract declaration in parent class for details.
73
+	 */
74
+	protected function _set_admin_pages()
75
+	{
76
+		$this->admin_registered_pages = array(
77
+			'events_edit' => true,
78
+		);
79
+	}
80
+
81
+
82
+	/**
83
+	 * see abstract declaration in parent class for details
84
+	 */
85
+	protected function _set_valid_shortcodes()
86
+	{
87
+		// remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the
88
+		// message type.
89
+		$this->_valid_shortcodes = array(
90
+			'to'   => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
91
+			'cc' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
92
+			'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
93
+		);
94
+	}
95
+
96
+
97
+	/**
98
+	 * see abstract declaration in parent class for details
99
+	 *
100
+	 * @access protected
101
+	 * @return void
102
+	 */
103
+	protected function _set_validator_config()
104
+	{
105
+		$valid_shortcodes = $this->get_valid_shortcodes();
106
+
107
+		$this->_validator_config = array(
108
+			'to'            => array(
109
+				'shortcodes' => $valid_shortcodes['to'],
110
+				'type'       => 'email',
111
+			),
112
+			'cc' => array(
113
+				'shortcodes' => $valid_shortcodes['to'],
114
+				'type' => 'email',
115
+			),
116
+			'from'          => array(
117
+				'shortcodes' => $valid_shortcodes['from'],
118
+				'type'       => 'email',
119
+			),
120
+			'subject'       => array(
121
+				'shortcodes' => array(
122
+					'organization',
123
+					'primary_registration_details',
124
+					'event_author',
125
+					'primary_registration_details',
126
+					'recipient_details',
127
+				),
128
+			),
129
+			'content'       => array(
130
+				'shortcodes' => array(
131
+					'event_list',
132
+					'attendee_list',
133
+					'ticket_list',
134
+					'organization',
135
+					'primary_registration_details',
136
+					'primary_registration_list',
137
+					'event_author',
138
+					'recipient_details',
139
+					'recipient_list',
140
+					'transaction',
141
+					'messenger',
142
+				),
143
+			),
144
+			'attendee_list' => array(
145
+				'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
146
+				'required'   => array('[ATTENDEE_LIST]'),
147
+			),
148
+			'event_list'    => array(
149
+				'shortcodes' => array(
150
+					'event',
151
+					'attendee_list',
152
+					'ticket_list',
153
+					'venue',
154
+					'datetime_list',
155
+					'attendee',
156
+					'primary_registration_details',
157
+					'primary_registration_list',
158
+					'event_author',
159
+					'recipient_details',
160
+					'recipient_list',
161
+				),
162
+				'required'   => array('[EVENT_LIST]'),
163
+			),
164
+			'ticket_list'   => array(
165
+				'shortcodes' => array(
166
+					'event_list',
167
+					'attendee_list',
168
+					'ticket',
169
+					'datetime_list',
170
+					'primary_registration_details',
171
+					'recipient_details',
172
+				),
173
+				'required'   => array('[TICKET_LIST]'),
174
+			),
175
+			'datetime_list' => array(
176
+				'shortcodes' => array('datetime'),
177
+				'required'   => array('[DATETIME_LIST]'),
178
+			),
179
+		);
180
+	}
181
+
182
+
183
+	/**
184
+	 * @see   parent EE_messenger class for docs
185
+	 * @since 4.5.0
186
+	 */
187
+	public function do_secondary_messenger_hooks($sending_messenger_name)
188
+	{
189
+		if ($sending_messenger_name === 'html') {
190
+			add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
191
+		}
192
+	}
193
+
194
+
195
+	public function add_email_css(
196
+		$variation_path,
197
+		$messenger,
198
+		$message_type,
199
+		$type,
200
+		$variation,
201
+		$file_extension,
202
+		$url,
203
+		EE_Messages_Template_Pack $template_pack
204
+	) {
205
+		// prevent recursion on this callback.
206
+		remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10);
207
+		$variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false);
208
+
209
+		add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
210
+		return $variation;
211
+	}
212
+
213
+
214
+	/**
215
+	 * See parent for details
216
+	 *
217
+	 * @access protected
218
+	 * @return void
219
+	 */
220
+	protected function _set_test_settings_fields()
221
+	{
222
+		$this->_test_settings_fields = array(
223
+			'to'      => array(
224
+				'input'      => 'text',
225
+				'label'      => esc_html__('Send a test email to', 'event_espresso'),
226
+				'type'       => 'email',
227
+				'required'   => false,
228
+				'validation' => true,
229
+				'css_class'  => 'large-text',
230
+				'format'     => '%s',
231
+				'default'    => get_bloginfo('admin_email'),
232
+			),
233
+			'subject' => array(
234
+				'input'      => 'hidden',
235
+				'label'      => '',
236
+				'type'       => 'string',
237
+				'required'   => false,
238
+				'validation' => false,
239
+				'format'     => '%s',
240
+				'value'      => sprintf(esc_html__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')),
241
+				'default'    => '',
242
+				'css_class'  => '',
243
+			),
244
+		);
245
+	}
246
+
247
+
248
+	/**
249
+	 * _set_template_fields
250
+	 * This sets up the fields that a messenger requires for the message to go out.
251
+	 *
252
+	 * @access  protected
253
+	 * @return void
254
+	 */
255
+	protected function _set_template_fields()
256
+	{
257
+		// any extra template fields that are NOT used by the messenger but will get used by a messenger field for
258
+		// shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field
259
+		// they relate to.  This is important for the Messages_admin to know what fields to display to the user.
260
+		//  Also, notice that the "values" are equal to the field type that messages admin will use to know what
261
+		// kind of field to display. The values ALSO have one index labeled "shortcode".  the values in that array
262
+		// indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be
263
+		// displayed.  If the required shortcode isn't part of the shortcodes array then the field is not needed and
264
+		// will not be displayed/parsed.
265
+		$this->_template_fields = array(
266
+			'to'      => array(
267
+				'input'      => 'text',
268
+				'label'      => esc_html_x(
269
+					'To',
270
+					'Label for the "To" field for email addresses',
271
+					'event_espresso'
272
+				),
273
+				'type'       => 'string',
274
+				'required'   => true,
275
+				'validation' => true,
276
+				'css_class'  => 'large-text',
277
+				'format'     => '%s',
278
+			),
279
+			'cc'      => array(
280
+				'input'      => 'text',
281
+				'label'      => esc_html_x(
282
+					'CC',
283
+					'Label for the "Carbon Copy" field used for additional email addresses',
284
+					'event_espresso'
285
+				),
286
+				'type'       => 'string',
287
+				'required'   => false,
288
+				'validation' => true,
289
+				'css_class'  => 'large-text',
290
+				'format'     => '%s',
291
+			),
292
+			'from'    => array(
293
+				'input'      => 'text',
294
+				'label'      => esc_html_x(
295
+					'From',
296
+					'Label for the "From" field for email addresses.',
297
+					'event_espresso'
298
+				),
299
+				'type'       => 'string',
300
+				'required'   => true,
301
+				'validation' => true,
302
+				'css_class'  => 'large-text',
303
+				'format'     => '%s',
304
+			),
305
+			'subject' => array(
306
+				'input'      => 'text',
307
+				'label'      => esc_html_x(
308
+					'Subject',
309
+					'Label for the "Subject" field (short description of contents) for emails.',
310
+					'event_espresso'
311
+				),
312
+				'type'       => 'string',
313
+				'required'   => true,
314
+				'validation' => true,
315
+				'css_class'  => 'large-text',
316
+				'format'     => '%s',
317
+			),
318
+			'content' => '',
319
+			// left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
320
+			'extra'   => array(
321
+				'content' => array(
322
+					'main'          => array(
323
+						'input'      => 'wp_editor',
324
+						'label'      => esc_html__('Main Content', 'event_espresso'),
325
+						'type'       => 'string',
326
+						'required'   => true,
327
+						'validation' => true,
328
+						'format'     => '%s',
329
+						'rows'       => '15',
330
+					),
331
+					'event_list'    => array(
332
+						'input'               => 'wp_editor',
333
+						'label'               => '[EVENT_LIST]',
334
+						'type'                => 'string',
335
+						'required'            => true,
336
+						'validation'          => true,
337
+						'format'              => '%s',
338
+						'rows'                => '15',
339
+						'shortcodes_required' => array('[EVENT_LIST]'),
340
+					),
341
+					'attendee_list' => array(
342
+						'input'               => 'textarea',
343
+						'label'               => '[ATTENDEE_LIST]',
344
+						'type'                => 'string',
345
+						'required'            => true,
346
+						'validation'          => true,
347
+						'format'              => '%s',
348
+						'css_class'           => 'large-text',
349
+						'rows'                => '5',
350
+						'shortcodes_required' => array('[ATTENDEE_LIST]'),
351
+					),
352
+					'ticket_list'   => array(
353
+						'input'               => 'textarea',
354
+						'label'               => '[TICKET_LIST]',
355
+						'type'                => 'string',
356
+						'required'            => true,
357
+						'validation'          => true,
358
+						'format'              => '%s',
359
+						'css_class'           => 'large-text',
360
+						'rows'                => '10',
361
+						'shortcodes_required' => array('[TICKET_LIST]'),
362
+					),
363
+					'datetime_list' => array(
364
+						'input'               => 'textarea',
365
+						'label'               => '[DATETIME_LIST]',
366
+						'type'                => 'string',
367
+						'required'            => true,
368
+						'validation'          => true,
369
+						'format'              => '%s',
370
+						'css_class'           => 'large-text',
371
+						'rows'                => '10',
372
+						'shortcodes_required' => array('[DATETIME_LIST]'),
373
+					),
374
+				),
375
+			),
376
+		);
377
+	}
378
+
379
+
380
+	/**
381
+	 * See definition of this class in parent
382
+	 */
383
+	protected function _set_default_message_types()
384
+	{
385
+		$this->_default_message_types = array(
386
+			'payment',
387
+			'payment_refund',
388
+			'registration',
389
+			'not_approved_registration',
390
+			'pending_approval',
391
+		);
392
+	}
393
+
394
+
395
+	/**
396
+	 * @see   definition of this class in parent
397
+	 * @since 4.5.0
398
+	 */
399
+	protected function _set_valid_message_types()
400
+	{
401
+		$this->_valid_message_types = array(
402
+			'payment',
403
+			'registration',
404
+			'not_approved_registration',
405
+			'declined_registration',
406
+			'cancelled_registration',
407
+			'pending_approval',
408
+			'registration_summary',
409
+			'payment_reminder',
410
+			'payment_declined',
411
+			'payment_refund',
412
+		);
413
+	}
414
+
415
+
416
+	/**
417
+	 * setting up admin_settings_fields for messenger.
418
+	 */
419
+	protected function _set_admin_settings_fields()
420
+	{
421
+	}
422
+
423
+	/**
424
+	 * We just deliver the messages don't kill us!!
425
+	 *
426
+	 * @return bool|WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if
427
+	 *              present.
428
+	 * @throws EE_Error
429
+	 * @throws \TijsVerkoyen\CssToInlineStyles\Exception
430
+	 */
431
+	protected function _send_message()
432
+	{
433
+		$success = wp_mail(
434
+			$this->_to,
435
+			// some old values for subject may be expecting HTML entities to be decoded in the subject
436
+			// and subjects aren't interpreted as HTML, so there should be no HTML in them
437
+			wp_strip_all_tags(wp_specialchars_decode($this->_subject, ENT_QUOTES)),
438
+			$this->_body(),
439
+			$this->_headers()
440
+		);
441
+		if (! $success) {
442
+			EE_Error::add_error(
443
+				sprintf(
444
+					esc_html__(
445
+						'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s',
446
+						'event_espresso'
447
+					),
448
+					$this->_to,
449
+					$this->_from,
450
+					'<br />'
451
+				),
452
+				__FILE__,
453
+				__FUNCTION__,
454
+				__LINE__
455
+			);
456
+		}
457
+		return $success;
458
+	}
459
+
460
+
461
+	/**
462
+	 * see parent for definition
463
+	 *
464
+	 * @return string html body of the message content and the related css.
465
+	 * @throws EE_Error
466
+	 * @throws \TijsVerkoyen\CssToInlineStyles\Exception
467
+	 */
468
+	protected function _preview()
469
+	{
470
+		return $this->_body(true);
471
+	}
472
+
473
+
474
+	/**
475
+	 * Setup headers for email
476
+	 *
477
+	 * @access protected
478
+	 * @return string formatted header for email
479
+	 */
480
+	protected function _headers()
481
+	{
482
+		$this->_ensure_has_from_email_address();
483
+		$from    = $this->_from;
484
+		$headers = array(
485
+			'From:' . $from,
486
+			'Reply-To:' . $from,
487
+			'Content-Type:text/html; charset=utf-8',
488
+		);
489
+
490
+		/**
491
+		 * Second condition added as a result of https://events.codebasehq.com/projects/event-espresso/tickets/11416 to
492
+		 * cover back compat where there may be users who have saved cc values in their db for the newsletter message
493
+		 * type which they are no longer able to change.
494
+		 */
495
+		if (! empty($this->_cc) && ! $this->_incoming_message_type instanceof EE_Newsletter_message_type) {
496
+			$headers[] = 'cc: ' . $this->_cc;
497
+		}
498
+
499
+		// but wait!  Header's for the from is NOT reliable because some plugins don't respect From: as set in the
500
+		// header.
501
+		add_filter('wp_mail_from', array($this, 'set_from_address'), 100);
502
+		add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100);
503
+		return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this);
504
+	}
505
+
506
+
507
+	/**
508
+	 * This simply ensures that the from address is not empty.  If it is, then we use whatever is set as the site email
509
+	 * address for the from address to avoid problems with sending emails.
510
+	 */
511
+	protected function _ensure_has_from_email_address()
512
+	{
513
+		if (empty($this->_from)) {
514
+			$this->_from = get_bloginfo('admin_email');
515
+		}
516
+	}
517
+
518
+
519
+	/**
520
+	 * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}>
521
+	 * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY*
522
+	 * be empty
523
+	 *
524
+	 * @since 4.3.1
525
+	 * @return array
526
+	 */
527
+	private function _parse_from()
528
+	{
529
+		if (strpos($this->_from, '<') !== false) {
530
+			$from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1);
531
+			$from_name = str_replace('"', '', $from_name);
532
+			$from_name = trim($from_name);
533
+
534
+			$from_email = substr($this->_from, strpos($this->_from, '<') + 1);
535
+			$from_email = str_replace('>', '', $from_email);
536
+			$from_email = trim($from_email);
537
+		} elseif (trim($this->_from) !== '') {
538
+			$from_name  = '';
539
+			$from_email = trim($this->_from);
540
+		} else {
541
+			$from_name = $from_email = '';
542
+		}
543
+		return array($from_name, $from_email);
544
+	}
545
+
546
+
547
+	/**
548
+	 * Callback for the wp_mail_from filter.
549
+	 *
550
+	 * @since 4.3.1
551
+	 * @param string $from_email What the original from_email is.
552
+	 * @return string
553
+	 */
554
+	public function set_from_address($from_email)
555
+	{
556
+		$parsed_from = $this->_parse_from();
557
+		// includes fallback if the parsing failed.
558
+		$from_email = is_array($parsed_from) && ! empty($parsed_from[1])
559
+			? $parsed_from[1]
560
+			: get_bloginfo('admin_email');
561
+		return $from_email;
562
+	}
563
+
564
+
565
+	/**
566
+	 * Callback fro the wp_mail_from_name filter.
567
+	 *
568
+	 * @since 4.3.1
569
+	 * @param string $from_name The original from_name.
570
+	 * @return string
571
+	 */
572
+	public function set_from_name($from_name)
573
+	{
574
+		$parsed_from = $this->_parse_from();
575
+		if (is_array($parsed_from) && ! empty($parsed_from[0])) {
576
+			$from_name = $parsed_from[0];
577
+		}
578
+
579
+		// if from name is "WordPress" let's sub in the site name instead (more friendly!)
580
+		// but realize the default name is HTML entity-encoded
581
+		$from_name = $from_name == 'WordPress' ? wp_specialchars_decode(get_bloginfo(), ENT_QUOTES) : $from_name;
582
+
583
+		return $from_name;
584
+	}
585
+
586
+
587
+	/**
588
+	 * setup body for email
589
+	 *
590
+	 * @param bool $preview will determine whether this is preview template or not.
591
+	 * @return string formatted body for email.
592
+	 * @throws EE_Error
593
+	 * @throws \TijsVerkoyen\CssToInlineStyles\Exception
594
+	 */
595
+	protected function _body($preview = false)
596
+	{
597
+		// setup template args!
598
+		$this->_template_args = array(
599
+			'subject'   => $this->_subject,
600
+			'from'      => $this->_from,
601
+			'main_body' => wpautop($this->_content),
602
+		);
603
+		$body                 = $this->_get_main_template($preview);
604
+
605
+		/**
606
+		 * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
607
+		 *
608
+		 * @type    bool $preview Indicates whether a preview is being generated or not.
609
+		 * @return  bool    true  indicates to use the inliner, false bypasses it.
610
+		 */
611
+		if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
612
+			// require CssToInlineStyles library and its dependencies via composer autoloader
613
+			require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
614
+
615
+			// now if this isn't a preview, let's setup the body so it has inline styles
616
+			if (! $preview || ($preview && defined('DOING_AJAX'))) {
617
+				$style = file_get_contents(
618
+					$this->get_variation(
619
+						$this->_tmp_pack,
620
+						$this->_incoming_message_type->name,
621
+						false,
622
+						'main',
623
+						$this->_variation
624
+					),
625
+					true
626
+				);
627
+				$CSS   = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style);
628
+				// for some reason the library has a bracket and new line at the beginning.  This takes care of that.
629
+				$body  = ltrim($CSS->convert(true), ">\n");
630
+				// see https://events.codebasehq.com/projects/event-espresso/tickets/8609
631
+				$body  = ltrim($body, "<?");
632
+			}
633
+		}
634
+		return $body;
635
+	}
636
+
637
+
638
+	/**
639
+	 * This just returns any existing test settings that might be saved in the database
640
+	 *
641
+	 * @access public
642
+	 * @return array
643
+	 */
644
+	public function get_existing_test_settings()
645
+	{
646
+		$settings = parent::get_existing_test_settings();
647
+		// override subject if present because we always want it to be fresh.
648
+		if (is_array($settings) && ! empty($settings['subject'])) {
649
+			$settings['subject'] = sprintf(esc_html__('Test email sent from %s', 'event_espresso'), get_bloginfo('name'));
650
+		}
651
+		return $settings;
652
+	}
653 653
 }
Please login to merge, or discard this patch.