Completed
Branch BUG/reg-csv-report-button (2ad0da)
by
unknown
05:24 queued 03:11
created
core/helpers/EEH_Template.helper.php 2 patches
Indentation   +926 added lines, -926 removed lines patch added patch discarded remove patch
@@ -7,36 +7,36 @@  discard block
 block discarded – undo
7 7
 use EventEspresso\core\services\request\sanitizers\AllowedTags;
8 8
 
9 9
 if (! function_exists('espresso_get_template_part')) {
10
-    /**
11
-     * espresso_get_template_part
12
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
13
-     * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
14
-     *
15
-     * @param string $slug The slug name for the generic template.
16
-     * @param string $name The name of the specialised template.
17
-     */
18
-    function espresso_get_template_part($slug = null, $name = null)
19
-    {
20
-        EEH_Template::get_template_part($slug, $name);
21
-    }
10
+	/**
11
+	 * espresso_get_template_part
12
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
13
+	 * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
14
+	 *
15
+	 * @param string $slug The slug name for the generic template.
16
+	 * @param string $name The name of the specialised template.
17
+	 */
18
+	function espresso_get_template_part($slug = null, $name = null)
19
+	{
20
+		EEH_Template::get_template_part($slug, $name);
21
+	}
22 22
 }
23 23
 
24 24
 
25 25
 if (! function_exists('espresso_get_object_css_class')) {
26
-    /**
27
-     * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
28
-     *
29
-     * @param EE_Base_Class $object the EE object the css class is being generated for
30
-     * @param string        $prefix added to the beginning of the generated class
31
-     * @param string        $suffix added to the end of the generated class
32
-     * @return string
33
-     * @throws EE_Error
34
-     * @throws ReflectionException
35
-     */
36
-    function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
37
-    {
38
-        return EEH_Template::get_object_css_class($object, $prefix, $suffix);
39
-    }
26
+	/**
27
+	 * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
28
+	 *
29
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
30
+	 * @param string        $prefix added to the beginning of the generated class
31
+	 * @param string        $suffix added to the end of the generated class
32
+	 * @return string
33
+	 * @throws EE_Error
34
+	 * @throws ReflectionException
35
+	 */
36
+	function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
37
+	{
38
+		return EEH_Template::get_object_css_class($object, $prefix, $suffix);
39
+	}
40 40
 }
41 41
 
42 42
 
@@ -51,640 +51,640 @@  discard block
 block discarded – undo
51 51
 class EEH_Template
52 52
 {
53 53
 
54
-    private static $_espresso_themes = [];
55
-
56
-
57
-    /**
58
-     *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
59
-     *
60
-     * @return boolean
61
-     */
62
-    public static function is_espresso_theme()
63
-    {
64
-        return wp_get_theme()->get('TextDomain') === 'event_espresso';
65
-    }
66
-
67
-
68
-    /**
69
-     *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
70
-     *    load its functions.php file ( if not already loaded )
71
-     *
72
-     * @return void
73
-     */
74
-    public static function load_espresso_theme_functions()
75
-    {
76
-        if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
77
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
78
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
79
-            }
80
-        }
81
-    }
82
-
83
-
84
-    /**
85
-     *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
86
-     *
87
-     * @return array
88
-     */
89
-    public static function get_espresso_themes()
90
-    {
91
-        if (empty(EEH_Template::$_espresso_themes)) {
92
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
93
-            if (empty($espresso_themes)) {
94
-                return [];
95
-            }
96
-            if (($key = array_search('global_assets', $espresso_themes)) !== false) {
97
-                unset($espresso_themes[ $key ]);
98
-            }
99
-            EEH_Template::$_espresso_themes = [];
100
-            foreach ($espresso_themes as $espresso_theme) {
101
-                EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
102
-            }
103
-        }
104
-        return EEH_Template::$_espresso_themes;
105
-    }
106
-
107
-
108
-    /**
109
-     * EEH_Template::get_template_part
110
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
111
-     * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
112
-     * filtering based off of the entire template part name
113
-     *
114
-     * @param string $slug The slug name for the generic template.
115
-     * @param string $name The name of the specialised template.
116
-     * @param array  $template_args
117
-     * @param bool   $return_string
118
-     * @return string        the html output for the formatted money value
119
-     */
120
-    public static function get_template_part(
121
-        $slug = null,
122
-        $name = null,
123
-        $template_args = [],
124
-        $return_string = false
125
-    ) {
126
-        do_action("get_template_part_{$slug}-{$name}", $slug, $name);
127
-        $templates = [];
128
-        $name      = (string) $name;
129
-        if ($name != '') {
130
-            $templates[] = "{$slug}-{$name}.php";
131
-        }
132
-        // allow template parts to be turned off via something like:
133
-        // add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
134
-        if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
135
-            return EEH_Template::locate_template($templates, $template_args, true, $return_string);
136
-        }
137
-        return '';
138
-    }
139
-
140
-
141
-    /**
142
-     *    locate_template
143
-     *    locate a template file by looking in the following places, in the following order:
144
-     *        <server path up to>/wp-content/themes/<current active WordPress theme>/
145
-     *        <assumed full absolute server path>
146
-     *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
147
-     *        <server path up to>/wp-content/uploads/espresso/templates/
148
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
149
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
150
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/
151
-     *    as soon as the template is found in one of these locations, it will be returned or loaded
152
-     *        Example:
153
-     *          You are using the WordPress Twenty Sixteen theme,
154
-     *        and you want to customize the "some-event.template.php" template,
155
-     *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
156
-     *          Assuming WP is installed on your server in the "/home/public_html/" folder,
157
-     *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
158
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
159
-     *        /relative/path/to/some-event.template.php
160
-     *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
161
-     *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
162
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
163
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
164
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
165
-     *          Had you passed an absolute path to your template that was in some other location,
166
-     *        ie: "/absolute/path/to/some-event.template.php"
167
-     *          then the search would have been :
168
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
169
-     *        /absolute/path/to/some-event.template.php
170
-     *          and stopped there upon finding it in the second location
171
-     *
172
-     * @param array|string $templates       array of template file names including extension (or just a single string)
173
-     * @param array        $template_args   an array of arguments to be extracted for use in the template
174
-     * @param boolean      $load            whether to pass the located template path on to the
175
-     *                                      EEH_Template::display_template() method or simply return it
176
-     * @param boolean      $return_string   whether to send output immediately to screen, or capture and return as a
177
-     *                                      string
178
-     * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
179
-     *                                      generate a custom template or not. Used in places where you don't actually
180
-     *                                      load the template, you just want to know if there's a custom version of it.
181
-     * @return mixed
182
-     * @throws DomainException
183
-     * @throws InvalidArgumentException
184
-     * @throws InvalidDataTypeException
185
-     * @throws InvalidInterfaceException
186
-     */
187
-    public static function locate_template(
188
-        $templates = [],
189
-        $template_args = [],
190
-        $load = true,
191
-        $return_string = true,
192
-        $check_if_custom = false
193
-    ) {
194
-        // first use WP locate_template to check for template in the current theme folder
195
-        $template_path = locate_template($templates);
196
-
197
-        if ($check_if_custom && ! empty($template_path)) {
198
-            return true;
199
-        }
200
-
201
-        // not in the theme
202
-        if (empty($template_path)) {
203
-            // not even a template to look for ?
204
-            if (empty($templates)) {
205
-                $loader = LoaderFactory::getLoader();
206
-                /** @var RequestInterface $request */
207
-                $request = $loader->getShared(RequestInterface::class);
208
-                // get post_type
209
-                $post_type = $request->getRequestParam('post_type');
210
-                /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
211
-                $custom_post_types = $loader->getShared(
212
-                    'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
213
-                );
214
-                // get array of EE Custom Post Types
215
-                $EE_CPTs = $custom_post_types->getDefinitions();
216
-                // build template name based on request
217
-                if (isset($EE_CPTs[ $post_type ])) {
218
-                    $archive_or_single = is_archive() ? 'archive' : '';
219
-                    $archive_or_single = is_single() ? 'single' : $archive_or_single;
220
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
221
-                }
222
-            }
223
-            // currently active EE template theme
224
-            $current_theme = EE_Config::get_current_theme();
225
-
226
-            // array of paths to folders that may contain templates
227
-            $template_folder_paths = [
228
-                // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
229
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
230
-                // then in the root of the /wp-content/uploads/espresso/templates/ folder
231
-                EVENT_ESPRESSO_TEMPLATE_DIR,
232
-            ];
233
-
234
-            // add core plugin folders for checking only if we're not $check_if_custom
235
-            if (! $check_if_custom) {
236
-                $core_paths            = [
237
-                    // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
238
-                    EE_PUBLIC . $current_theme,
239
-                    // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
240
-                    EE_TEMPLATES . $current_theme,
241
-                    // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
242
-                    EE_PLUGIN_DIR_PATH,
243
-                ];
244
-                $template_folder_paths = array_merge($template_folder_paths, $core_paths);
245
-            }
246
-
247
-            // now filter that array
248
-            $template_folder_paths = apply_filters(
249
-                'FHEE__EEH_Template__locate_template__template_folder_paths',
250
-                $template_folder_paths
251
-            );
252
-            $templates             = is_array($templates) ? $templates : [$templates];
253
-            $template_folder_paths =
254
-                is_array($template_folder_paths) ? $template_folder_paths : [$template_folder_paths];
255
-            // array to hold all possible template paths
256
-            $full_template_paths = [];
257
-            $file_name           = '';
258
-
259
-            // loop through $templates
260
-            foreach ($templates as $template) {
261
-                // normalize directory separators
262
-                $template                      = EEH_File::standardise_directory_separators($template);
263
-                $file_name                     = basename($template);
264
-                $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
265
-                // while looping through all template folder paths
266
-                foreach ($template_folder_paths as $template_folder_path) {
267
-                    // normalize directory separators
268
-                    $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
269
-                    // determine if any common base path exists between the two paths
270
-                    $common_base_path = EEH_Template::_find_common_base_path(
271
-                        [$template_folder_path, $template_path_minus_file_name]
272
-                    );
273
-                    if ($common_base_path !== '') {
274
-                        // both paths have a common base, so just tack the filename onto our search path
275
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
276
-                    } else {
277
-                        // no common base path, so let's just concatenate
278
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
279
-                    }
280
-                    // build up our template locations array by adding our resolved paths
281
-                    $full_template_paths[] = $resolved_path;
282
-                }
283
-                // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
284
-                array_unshift($full_template_paths, $template);
285
-                // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
286
-                array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
287
-            }
288
-            // filter final array of full template paths
289
-            $full_template_paths = apply_filters(
290
-                'FHEE__EEH_Template__locate_template__full_template_paths',
291
-                $full_template_paths,
292
-                $file_name
293
-            );
294
-            // now loop through our final array of template location paths and check each location
295
-            foreach ((array) $full_template_paths as $full_template_path) {
296
-                if (is_readable($full_template_path)) {
297
-                    $template_path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $full_template_path);
298
-                    break;
299
-                }
300
-            }
301
-        }
302
-
303
-        // hook that can be used to display the full template path that will be used
304
-        do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
305
-
306
-        // if we got it and you want to see it...
307
-        if ($template_path && $load && ! $check_if_custom) {
308
-            if ($return_string) {
309
-                return EEH_Template::display_template($template_path, $template_args, true);
310
-            }
311
-            EEH_Template::display_template($template_path, $template_args);
312
-        }
313
-        return $check_if_custom && ! empty($template_path) ? true : $template_path;
314
-    }
315
-
316
-
317
-    /**
318
-     * _find_common_base_path
319
-     * given two paths, this determines if there is a common base path between the two
320
-     *
321
-     * @param array $paths
322
-     * @return string
323
-     */
324
-    protected static function _find_common_base_path($paths)
325
-    {
326
-        $last_offset      = 0;
327
-        $common_base_path = '';
328
-        while (($index = strpos($paths[0], '/', $last_offset)) !== false) {
329
-            $dir_length = $index - $last_offset + 1;
330
-            $directory  = substr($paths[0], $last_offset, $dir_length);
331
-            foreach ($paths as $path) {
332
-                if (substr($path, $last_offset, $dir_length) != $directory) {
333
-                    return $common_base_path;
334
-                }
335
-            }
336
-            $common_base_path .= $directory;
337
-            $last_offset      = $index + 1;
338
-        }
339
-        return substr($common_base_path, 0, -1);
340
-    }
341
-
342
-
343
-    /**
344
-     * load and display a template
345
-     *
346
-     * @param bool|string $template_path    server path to the file to be loaded, including file name and extension
347
-     * @param array       $template_args    an array of arguments to be extracted for use in the template
348
-     * @param boolean     $return_string    whether to send output immediately to screen, or capture and return as a
349
-     *                                      string
350
-     * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
351
-     *                                      not found or is not readable
352
-     * @return string
353
-     * @throws DomainException
354
-     */
355
-    public static function display_template(
356
-        $template_path = false,
357
-        $template_args = [],
358
-        $return_string = false,
359
-        $throw_exceptions = false
360
-    ) {
361
-
362
-        /**
363
-         * These two filters are intended for last minute changes to templates being loaded and/or template arg
364
-         * modifications.  NOTE... modifying these things can cause breakage as most templates running through
365
-         * the display_template method are templates we DON'T want modified (usually because of js
366
-         * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
367
-         * using this.
368
-         *
369
-         * @since 4.6.0
370
-         */
371
-        $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
372
-        $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
373
-
374
-        // you gimme nuttin - YOU GET NUTTIN !!
375
-        if (! $template_path || ! is_readable($template_path)) {
376
-            // ignore whether template is accessible ?
377
-            if ($throw_exceptions) {
378
-                throw new DomainException(
379
-                    esc_html__('Invalid, unreadable, or missing file.', 'event_espresso')
380
-                );
381
-            }
382
-            return '';
383
-        }
384
-        // if $template_args are not in an array, then make it so
385
-        if (! is_array($template_args) && ! is_object($template_args)) {
386
-            $template_args = [$template_args];
387
-        }
388
-        extract($template_args, EXTR_SKIP);
389
-
390
-        if ($return_string) {
391
-            // because we want to return a string, we are going to capture the output
392
-            ob_start();
393
-            include($template_path);
394
-            return ob_get_clean();
395
-        }
396
-        include($template_path);
397
-        return '';
398
-    }
399
-
400
-
401
-    /**
402
-     * get_object_css_class - attempts to generate a css class based on the type of EE object passed
403
-     *
404
-     * @param EE_Base_Class $object the EE object the css class is being generated for
405
-     * @param string        $prefix added to the beginning of the generated class
406
-     * @param string        $suffix added to the end of the generated class
407
-     * @return string
408
-     * @throws EE_Error
409
-     * @throws ReflectionException
410
-     */
411
-    public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
412
-    {
413
-        // in the beginning...
414
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
415
-        // da muddle
416
-        $class = '';
417
-        // the end
418
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
419
-        // is the passed object an EE object ?
420
-        if ($object instanceof EE_Base_Class) {
421
-            // grab the exact type of object
422
-            $obj_class = get_class($object);
423
-            // depending on the type of object...
424
-            switch ($obj_class) {
425
-                // no specifics just yet...
426
-                default:
427
-                    $class = strtolower(str_replace('_', '-', $obj_class));
428
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
429
-            }
430
-        }
431
-        return $prefix . $class . $suffix;
432
-    }
433
-
434
-
435
-    /**
436
-     * EEH_Template::format_currency
437
-     * This helper takes a raw float value and formats it according to the default config country currency settings, or
438
-     * the country currency settings from the supplied country ISO code
439
-     *
440
-     * @param float   $amount       raw money value
441
-     * @param boolean $return_raw   whether to return the formatted float value only with no currency sign or code
442
-     * @param boolean $display_code whether to display the country code (USD). Default = TRUE
443
-     * @param string  $CNT_ISO      2 letter ISO code for a country
444
-     * @param string  $cur_code_span_class
445
-     * @return string        the html output for the formatted money value
446
-     */
447
-    public static function format_currency(
448
-        $amount = null,
449
-        $return_raw = false,
450
-        $display_code = true,
451
-        $CNT_ISO = '',
452
-        $cur_code_span_class = 'currency-code'
453
-    ) {
454
-        // ensure amount was received
455
-        if ($amount === null) {
456
-            $msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso');
457
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
458
-            return '';
459
-        }
460
-        // ensure amount is float
461
-        $amount  = (float) apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
462
-        $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
463
-        // filter raw amount (allows 0.00 to be changed to "free" for example)
464
-        $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
465
-        // still a number, or was amount converted to a string like "free" ?
466
-        if (! is_float($amount_formatted)) {
467
-            return esc_html($amount_formatted);
468
-        }
469
-        try {
470
-            // was a country ISO code passed ? if so generate currency config object for that country
471
-            $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
472
-        } catch (Exception $e) {
473
-            // eat exception
474
-            $mny = null;
475
-        }
476
-        // verify results
477
-        if (! $mny instanceof EE_Currency_Config) {
478
-            // set default config country currency settings
479
-            $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
480
-                ? EE_Registry::instance()->CFG->currency
481
-                : new EE_Currency_Config();
482
-        }
483
-        // format float
484
-        $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
485
-        // add formatting ?
486
-        if (! $return_raw) {
487
-            // add currency sign
488
-            if ($mny->sign_b4) {
489
-                if ($amount >= 0) {
490
-                    $amount_formatted = $mny->sign . $amount_formatted;
491
-                } else {
492
-                    $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
493
-                }
494
-            } else {
495
-                $amount_formatted = $amount_formatted . $mny->sign;
496
-            }
497
-
498
-            // filter to allow global setting of display_code
499
-            $display_code = (bool) apply_filters(
500
-                'FHEE__EEH_Template__format_currency__display_code',
501
-                $display_code
502
-            );
503
-
504
-            // add currency code ?
505
-            $amount_formatted = $display_code
506
-                ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
507
-                : $amount_formatted;
508
-        }
509
-        // filter results
510
-        $amount_formatted = apply_filters(
511
-            'FHEE__EEH_Template__format_currency__amount_formatted',
512
-            $amount_formatted,
513
-            $mny,
514
-            $return_raw
515
-        );
516
-        // clean up vars
517
-        unset($mny);
518
-        // return formatted currency amount
519
-        return $amount_formatted;
520
-    }
521
-
522
-
523
-    /**
524
-     * This function is used for outputting the localized label for a given status id in the schema requested (and
525
-     * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
526
-     * related status model or model object (i.e. in documentation etc.)
527
-     *
528
-     * @param string  $status_id  Status ID matching a registered status in the esp_status table.  If there is no
529
-     *                            match, then 'Unknown' will be returned.
530
-     * @param boolean $plural     Whether to return plural or not
531
-     * @param string  $schema     'UPPER', 'lower', or 'Sentence'
532
-     * @return string             The localized label for the status id.
533
-     * @throws EE_Error
534
-     */
535
-    public static function pretty_status($status_id, $plural = false, $schema = 'upper')
536
-    {
537
-        $status = EEM_Status::instance()->localized_status(
538
-            [$status_id => esc_html__('unknown', 'event_espresso')],
539
-            $plural,
540
-            $schema
541
-        );
542
-        return $status[ $status_id ];
543
-    }
544
-
545
-
546
-    /**
547
-     * This helper just returns a button or link for the given parameters
548
-     *
549
-     * @param string $url   the url for the link, note that `esc_url` will be called on it
550
-     * @param string $label What is the label you want displayed for the button
551
-     * @param string $class what class is used for the button (defaults to 'button-primary')
552
-     * @param string $icon
553
-     * @param string $title
554
-     * @return string the html output for the button
555
-     */
556
-    public static function get_button_or_link($url, $label, $class = 'button button--primary', $icon = '', $title = '')
557
-    {
558
-        $icon_html = '';
559
-        if (! empty($icon)) {
560
-            $dashicons = preg_split("(ee-icon |dashicons )", $icon);
561
-            $dashicons = array_filter($dashicons);
562
-            $count     = count($dashicons);
563
-            $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
564
-            foreach ($dashicons as $dashicon) {
565
-                $type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
566
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
567
-            }
568
-            $icon_html .= $count > 1 ? '</span>' : '';
569
-        }
570
-        // sanitize & escape
571
-        $id    = sanitize_title_with_dashes($label);
572
-        $url   = esc_url_raw($url);
573
-        $class = esc_attr($class);
574
-        $title = esc_attr($title);
575
-        $label = esc_html($label);
576
-        return "<a id='{$id}' href='{$url}' class='{$class}' title='{$title}'>{$icon_html}{$label}</a>";
577
-    }
578
-
579
-
580
-    /**
581
-     * This returns a generated link that will load the related help tab on admin pages.
582
-     *
583
-     * @param string      $help_tab_id the id for the connected help tab
584
-     * @param bool|string $page        The page identifier for the page the help tab is on
585
-     * @param bool|string $action      The action (route) for the admin page the help tab is on.
586
-     * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
587
-     * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
588
-     * @return string              generated link
589
-     */
590
-    public static function get_help_tab_link(
591
-        $help_tab_id,
592
-        $page = false,
593
-        $action = false,
594
-        $icon_style = false,
595
-        $help_text = false
596
-    ) {
597
-        $allowedtags = AllowedTags::getAllowedTags();
598
-        /** @var RequestInterface $request */
599
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
600
-        $page    = $page ?: $request->getRequestParam('page', '', 'key');
601
-        $action  = $action ?: $request->getRequestParam('action', 'default', 'key');
602
-
603
-
604
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
605
-        $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
606
-        $help_text    = ! $help_text ? '' : $help_text;
607
-        return '<a id="'
608
-               . esc_attr($help_tab_lnk)
609
-               . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'
610
-               . esc_attr($icon)
611
-               . '" title="'
612
-               . esc_attr__(
613
-                   'Click to open the \'Help\' tab for more information about this feature.',
614
-                   'event_espresso'
615
-               )
616
-               . '" > '
617
-               . wp_kses($help_text, $allowedtags)
618
-               . ' </a>';
619
-    }
620
-
621
-
622
-    /**
623
-     * This is a helper method to generate a status legend for a given status array.
624
-     * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
625
-     * status_array.
626
-     *
627
-     * @param array  $status_array   array of statuses that will make up the legend. In format:
628
-     *                               array(
629
-     *                               'status_item' => 'status_name'
630
-     *                               )
631
-     * @param string $active_status  This is used to indicate what the active status is IF that is to be highlighted in
632
-     *                               the legend.
633
-     * @return string               html structure for status.
634
-     * @throws EE_Error
635
-     */
636
-    public static function status_legend($status_array, $active_status = '')
637
-    {
638
-        if (! is_array($status_array)) {
639
-            throw new EE_Error(
640
-                esc_html__(
641
-                    'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
642
-                    'event_espresso'
643
-                )
644
-            );
645
-        }
646
-
647
-        $content = '
54
+	private static $_espresso_themes = [];
55
+
56
+
57
+	/**
58
+	 *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
59
+	 *
60
+	 * @return boolean
61
+	 */
62
+	public static function is_espresso_theme()
63
+	{
64
+		return wp_get_theme()->get('TextDomain') === 'event_espresso';
65
+	}
66
+
67
+
68
+	/**
69
+	 *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
70
+	 *    load its functions.php file ( if not already loaded )
71
+	 *
72
+	 * @return void
73
+	 */
74
+	public static function load_espresso_theme_functions()
75
+	{
76
+		if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
77
+			if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
78
+				require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
79
+			}
80
+		}
81
+	}
82
+
83
+
84
+	/**
85
+	 *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
86
+	 *
87
+	 * @return array
88
+	 */
89
+	public static function get_espresso_themes()
90
+	{
91
+		if (empty(EEH_Template::$_espresso_themes)) {
92
+			$espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
93
+			if (empty($espresso_themes)) {
94
+				return [];
95
+			}
96
+			if (($key = array_search('global_assets', $espresso_themes)) !== false) {
97
+				unset($espresso_themes[ $key ]);
98
+			}
99
+			EEH_Template::$_espresso_themes = [];
100
+			foreach ($espresso_themes as $espresso_theme) {
101
+				EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
102
+			}
103
+		}
104
+		return EEH_Template::$_espresso_themes;
105
+	}
106
+
107
+
108
+	/**
109
+	 * EEH_Template::get_template_part
110
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
111
+	 * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
112
+	 * filtering based off of the entire template part name
113
+	 *
114
+	 * @param string $slug The slug name for the generic template.
115
+	 * @param string $name The name of the specialised template.
116
+	 * @param array  $template_args
117
+	 * @param bool   $return_string
118
+	 * @return string        the html output for the formatted money value
119
+	 */
120
+	public static function get_template_part(
121
+		$slug = null,
122
+		$name = null,
123
+		$template_args = [],
124
+		$return_string = false
125
+	) {
126
+		do_action("get_template_part_{$slug}-{$name}", $slug, $name);
127
+		$templates = [];
128
+		$name      = (string) $name;
129
+		if ($name != '') {
130
+			$templates[] = "{$slug}-{$name}.php";
131
+		}
132
+		// allow template parts to be turned off via something like:
133
+		// add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
134
+		if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
135
+			return EEH_Template::locate_template($templates, $template_args, true, $return_string);
136
+		}
137
+		return '';
138
+	}
139
+
140
+
141
+	/**
142
+	 *    locate_template
143
+	 *    locate a template file by looking in the following places, in the following order:
144
+	 *        <server path up to>/wp-content/themes/<current active WordPress theme>/
145
+	 *        <assumed full absolute server path>
146
+	 *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
147
+	 *        <server path up to>/wp-content/uploads/espresso/templates/
148
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
149
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
150
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/
151
+	 *    as soon as the template is found in one of these locations, it will be returned or loaded
152
+	 *        Example:
153
+	 *          You are using the WordPress Twenty Sixteen theme,
154
+	 *        and you want to customize the "some-event.template.php" template,
155
+	 *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
156
+	 *          Assuming WP is installed on your server in the "/home/public_html/" folder,
157
+	 *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
158
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
159
+	 *        /relative/path/to/some-event.template.php
160
+	 *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
161
+	 *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
162
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
163
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
164
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
165
+	 *          Had you passed an absolute path to your template that was in some other location,
166
+	 *        ie: "/absolute/path/to/some-event.template.php"
167
+	 *          then the search would have been :
168
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
169
+	 *        /absolute/path/to/some-event.template.php
170
+	 *          and stopped there upon finding it in the second location
171
+	 *
172
+	 * @param array|string $templates       array of template file names including extension (or just a single string)
173
+	 * @param array        $template_args   an array of arguments to be extracted for use in the template
174
+	 * @param boolean      $load            whether to pass the located template path on to the
175
+	 *                                      EEH_Template::display_template() method or simply return it
176
+	 * @param boolean      $return_string   whether to send output immediately to screen, or capture and return as a
177
+	 *                                      string
178
+	 * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
179
+	 *                                      generate a custom template or not. Used in places where you don't actually
180
+	 *                                      load the template, you just want to know if there's a custom version of it.
181
+	 * @return mixed
182
+	 * @throws DomainException
183
+	 * @throws InvalidArgumentException
184
+	 * @throws InvalidDataTypeException
185
+	 * @throws InvalidInterfaceException
186
+	 */
187
+	public static function locate_template(
188
+		$templates = [],
189
+		$template_args = [],
190
+		$load = true,
191
+		$return_string = true,
192
+		$check_if_custom = false
193
+	) {
194
+		// first use WP locate_template to check for template in the current theme folder
195
+		$template_path = locate_template($templates);
196
+
197
+		if ($check_if_custom && ! empty($template_path)) {
198
+			return true;
199
+		}
200
+
201
+		// not in the theme
202
+		if (empty($template_path)) {
203
+			// not even a template to look for ?
204
+			if (empty($templates)) {
205
+				$loader = LoaderFactory::getLoader();
206
+				/** @var RequestInterface $request */
207
+				$request = $loader->getShared(RequestInterface::class);
208
+				// get post_type
209
+				$post_type = $request->getRequestParam('post_type');
210
+				/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
211
+				$custom_post_types = $loader->getShared(
212
+					'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
213
+				);
214
+				// get array of EE Custom Post Types
215
+				$EE_CPTs = $custom_post_types->getDefinitions();
216
+				// build template name based on request
217
+				if (isset($EE_CPTs[ $post_type ])) {
218
+					$archive_or_single = is_archive() ? 'archive' : '';
219
+					$archive_or_single = is_single() ? 'single' : $archive_or_single;
220
+					$templates         = $archive_or_single . '-' . $post_type . '.php';
221
+				}
222
+			}
223
+			// currently active EE template theme
224
+			$current_theme = EE_Config::get_current_theme();
225
+
226
+			// array of paths to folders that may contain templates
227
+			$template_folder_paths = [
228
+				// first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
229
+				EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
230
+				// then in the root of the /wp-content/uploads/espresso/templates/ folder
231
+				EVENT_ESPRESSO_TEMPLATE_DIR,
232
+			];
233
+
234
+			// add core plugin folders for checking only if we're not $check_if_custom
235
+			if (! $check_if_custom) {
236
+				$core_paths            = [
237
+					// in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
238
+					EE_PUBLIC . $current_theme,
239
+					// in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
240
+					EE_TEMPLATES . $current_theme,
241
+					// or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
242
+					EE_PLUGIN_DIR_PATH,
243
+				];
244
+				$template_folder_paths = array_merge($template_folder_paths, $core_paths);
245
+			}
246
+
247
+			// now filter that array
248
+			$template_folder_paths = apply_filters(
249
+				'FHEE__EEH_Template__locate_template__template_folder_paths',
250
+				$template_folder_paths
251
+			);
252
+			$templates             = is_array($templates) ? $templates : [$templates];
253
+			$template_folder_paths =
254
+				is_array($template_folder_paths) ? $template_folder_paths : [$template_folder_paths];
255
+			// array to hold all possible template paths
256
+			$full_template_paths = [];
257
+			$file_name           = '';
258
+
259
+			// loop through $templates
260
+			foreach ($templates as $template) {
261
+				// normalize directory separators
262
+				$template                      = EEH_File::standardise_directory_separators($template);
263
+				$file_name                     = basename($template);
264
+				$template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
265
+				// while looping through all template folder paths
266
+				foreach ($template_folder_paths as $template_folder_path) {
267
+					// normalize directory separators
268
+					$template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
269
+					// determine if any common base path exists between the two paths
270
+					$common_base_path = EEH_Template::_find_common_base_path(
271
+						[$template_folder_path, $template_path_minus_file_name]
272
+					);
273
+					if ($common_base_path !== '') {
274
+						// both paths have a common base, so just tack the filename onto our search path
275
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
276
+					} else {
277
+						// no common base path, so let's just concatenate
278
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
279
+					}
280
+					// build up our template locations array by adding our resolved paths
281
+					$full_template_paths[] = $resolved_path;
282
+				}
283
+				// if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
284
+				array_unshift($full_template_paths, $template);
285
+				// path to the directory of the current theme: /wp-content/themes/(current WP theme)/
286
+				array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
287
+			}
288
+			// filter final array of full template paths
289
+			$full_template_paths = apply_filters(
290
+				'FHEE__EEH_Template__locate_template__full_template_paths',
291
+				$full_template_paths,
292
+				$file_name
293
+			);
294
+			// now loop through our final array of template location paths and check each location
295
+			foreach ((array) $full_template_paths as $full_template_path) {
296
+				if (is_readable($full_template_path)) {
297
+					$template_path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $full_template_path);
298
+					break;
299
+				}
300
+			}
301
+		}
302
+
303
+		// hook that can be used to display the full template path that will be used
304
+		do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
305
+
306
+		// if we got it and you want to see it...
307
+		if ($template_path && $load && ! $check_if_custom) {
308
+			if ($return_string) {
309
+				return EEH_Template::display_template($template_path, $template_args, true);
310
+			}
311
+			EEH_Template::display_template($template_path, $template_args);
312
+		}
313
+		return $check_if_custom && ! empty($template_path) ? true : $template_path;
314
+	}
315
+
316
+
317
+	/**
318
+	 * _find_common_base_path
319
+	 * given two paths, this determines if there is a common base path between the two
320
+	 *
321
+	 * @param array $paths
322
+	 * @return string
323
+	 */
324
+	protected static function _find_common_base_path($paths)
325
+	{
326
+		$last_offset      = 0;
327
+		$common_base_path = '';
328
+		while (($index = strpos($paths[0], '/', $last_offset)) !== false) {
329
+			$dir_length = $index - $last_offset + 1;
330
+			$directory  = substr($paths[0], $last_offset, $dir_length);
331
+			foreach ($paths as $path) {
332
+				if (substr($path, $last_offset, $dir_length) != $directory) {
333
+					return $common_base_path;
334
+				}
335
+			}
336
+			$common_base_path .= $directory;
337
+			$last_offset      = $index + 1;
338
+		}
339
+		return substr($common_base_path, 0, -1);
340
+	}
341
+
342
+
343
+	/**
344
+	 * load and display a template
345
+	 *
346
+	 * @param bool|string $template_path    server path to the file to be loaded, including file name and extension
347
+	 * @param array       $template_args    an array of arguments to be extracted for use in the template
348
+	 * @param boolean     $return_string    whether to send output immediately to screen, or capture and return as a
349
+	 *                                      string
350
+	 * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
351
+	 *                                      not found or is not readable
352
+	 * @return string
353
+	 * @throws DomainException
354
+	 */
355
+	public static function display_template(
356
+		$template_path = false,
357
+		$template_args = [],
358
+		$return_string = false,
359
+		$throw_exceptions = false
360
+	) {
361
+
362
+		/**
363
+		 * These two filters are intended for last minute changes to templates being loaded and/or template arg
364
+		 * modifications.  NOTE... modifying these things can cause breakage as most templates running through
365
+		 * the display_template method are templates we DON'T want modified (usually because of js
366
+		 * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
367
+		 * using this.
368
+		 *
369
+		 * @since 4.6.0
370
+		 */
371
+		$template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
372
+		$template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
373
+
374
+		// you gimme nuttin - YOU GET NUTTIN !!
375
+		if (! $template_path || ! is_readable($template_path)) {
376
+			// ignore whether template is accessible ?
377
+			if ($throw_exceptions) {
378
+				throw new DomainException(
379
+					esc_html__('Invalid, unreadable, or missing file.', 'event_espresso')
380
+				);
381
+			}
382
+			return '';
383
+		}
384
+		// if $template_args are not in an array, then make it so
385
+		if (! is_array($template_args) && ! is_object($template_args)) {
386
+			$template_args = [$template_args];
387
+		}
388
+		extract($template_args, EXTR_SKIP);
389
+
390
+		if ($return_string) {
391
+			// because we want to return a string, we are going to capture the output
392
+			ob_start();
393
+			include($template_path);
394
+			return ob_get_clean();
395
+		}
396
+		include($template_path);
397
+		return '';
398
+	}
399
+
400
+
401
+	/**
402
+	 * get_object_css_class - attempts to generate a css class based on the type of EE object passed
403
+	 *
404
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
405
+	 * @param string        $prefix added to the beginning of the generated class
406
+	 * @param string        $suffix added to the end of the generated class
407
+	 * @return string
408
+	 * @throws EE_Error
409
+	 * @throws ReflectionException
410
+	 */
411
+	public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
412
+	{
413
+		// in the beginning...
414
+		$prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
415
+		// da muddle
416
+		$class = '';
417
+		// the end
418
+		$suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
419
+		// is the passed object an EE object ?
420
+		if ($object instanceof EE_Base_Class) {
421
+			// grab the exact type of object
422
+			$obj_class = get_class($object);
423
+			// depending on the type of object...
424
+			switch ($obj_class) {
425
+				// no specifics just yet...
426
+				default:
427
+					$class = strtolower(str_replace('_', '-', $obj_class));
428
+					$class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
429
+			}
430
+		}
431
+		return $prefix . $class . $suffix;
432
+	}
433
+
434
+
435
+	/**
436
+	 * EEH_Template::format_currency
437
+	 * This helper takes a raw float value and formats it according to the default config country currency settings, or
438
+	 * the country currency settings from the supplied country ISO code
439
+	 *
440
+	 * @param float   $amount       raw money value
441
+	 * @param boolean $return_raw   whether to return the formatted float value only with no currency sign or code
442
+	 * @param boolean $display_code whether to display the country code (USD). Default = TRUE
443
+	 * @param string  $CNT_ISO      2 letter ISO code for a country
444
+	 * @param string  $cur_code_span_class
445
+	 * @return string        the html output for the formatted money value
446
+	 */
447
+	public static function format_currency(
448
+		$amount = null,
449
+		$return_raw = false,
450
+		$display_code = true,
451
+		$CNT_ISO = '',
452
+		$cur_code_span_class = 'currency-code'
453
+	) {
454
+		// ensure amount was received
455
+		if ($amount === null) {
456
+			$msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso');
457
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
458
+			return '';
459
+		}
460
+		// ensure amount is float
461
+		$amount  = (float) apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
462
+		$CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
463
+		// filter raw amount (allows 0.00 to be changed to "free" for example)
464
+		$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
465
+		// still a number, or was amount converted to a string like "free" ?
466
+		if (! is_float($amount_formatted)) {
467
+			return esc_html($amount_formatted);
468
+		}
469
+		try {
470
+			// was a country ISO code passed ? if so generate currency config object for that country
471
+			$mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
472
+		} catch (Exception $e) {
473
+			// eat exception
474
+			$mny = null;
475
+		}
476
+		// verify results
477
+		if (! $mny instanceof EE_Currency_Config) {
478
+			// set default config country currency settings
479
+			$mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
480
+				? EE_Registry::instance()->CFG->currency
481
+				: new EE_Currency_Config();
482
+		}
483
+		// format float
484
+		$amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
485
+		// add formatting ?
486
+		if (! $return_raw) {
487
+			// add currency sign
488
+			if ($mny->sign_b4) {
489
+				if ($amount >= 0) {
490
+					$amount_formatted = $mny->sign . $amount_formatted;
491
+				} else {
492
+					$amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
493
+				}
494
+			} else {
495
+				$amount_formatted = $amount_formatted . $mny->sign;
496
+			}
497
+
498
+			// filter to allow global setting of display_code
499
+			$display_code = (bool) apply_filters(
500
+				'FHEE__EEH_Template__format_currency__display_code',
501
+				$display_code
502
+			);
503
+
504
+			// add currency code ?
505
+			$amount_formatted = $display_code
506
+				? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
507
+				: $amount_formatted;
508
+		}
509
+		// filter results
510
+		$amount_formatted = apply_filters(
511
+			'FHEE__EEH_Template__format_currency__amount_formatted',
512
+			$amount_formatted,
513
+			$mny,
514
+			$return_raw
515
+		);
516
+		// clean up vars
517
+		unset($mny);
518
+		// return formatted currency amount
519
+		return $amount_formatted;
520
+	}
521
+
522
+
523
+	/**
524
+	 * This function is used for outputting the localized label for a given status id in the schema requested (and
525
+	 * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
526
+	 * related status model or model object (i.e. in documentation etc.)
527
+	 *
528
+	 * @param string  $status_id  Status ID matching a registered status in the esp_status table.  If there is no
529
+	 *                            match, then 'Unknown' will be returned.
530
+	 * @param boolean $plural     Whether to return plural or not
531
+	 * @param string  $schema     'UPPER', 'lower', or 'Sentence'
532
+	 * @return string             The localized label for the status id.
533
+	 * @throws EE_Error
534
+	 */
535
+	public static function pretty_status($status_id, $plural = false, $schema = 'upper')
536
+	{
537
+		$status = EEM_Status::instance()->localized_status(
538
+			[$status_id => esc_html__('unknown', 'event_espresso')],
539
+			$plural,
540
+			$schema
541
+		);
542
+		return $status[ $status_id ];
543
+	}
544
+
545
+
546
+	/**
547
+	 * This helper just returns a button or link for the given parameters
548
+	 *
549
+	 * @param string $url   the url for the link, note that `esc_url` will be called on it
550
+	 * @param string $label What is the label you want displayed for the button
551
+	 * @param string $class what class is used for the button (defaults to 'button-primary')
552
+	 * @param string $icon
553
+	 * @param string $title
554
+	 * @return string the html output for the button
555
+	 */
556
+	public static function get_button_or_link($url, $label, $class = 'button button--primary', $icon = '', $title = '')
557
+	{
558
+		$icon_html = '';
559
+		if (! empty($icon)) {
560
+			$dashicons = preg_split("(ee-icon |dashicons )", $icon);
561
+			$dashicons = array_filter($dashicons);
562
+			$count     = count($dashicons);
563
+			$icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
564
+			foreach ($dashicons as $dashicon) {
565
+				$type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
566
+				$icon_html .= '<span class="' . $type . $dashicon . '"></span>';
567
+			}
568
+			$icon_html .= $count > 1 ? '</span>' : '';
569
+		}
570
+		// sanitize & escape
571
+		$id    = sanitize_title_with_dashes($label);
572
+		$url   = esc_url_raw($url);
573
+		$class = esc_attr($class);
574
+		$title = esc_attr($title);
575
+		$label = esc_html($label);
576
+		return "<a id='{$id}' href='{$url}' class='{$class}' title='{$title}'>{$icon_html}{$label}</a>";
577
+	}
578
+
579
+
580
+	/**
581
+	 * This returns a generated link that will load the related help tab on admin pages.
582
+	 *
583
+	 * @param string      $help_tab_id the id for the connected help tab
584
+	 * @param bool|string $page        The page identifier for the page the help tab is on
585
+	 * @param bool|string $action      The action (route) for the admin page the help tab is on.
586
+	 * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
587
+	 * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
588
+	 * @return string              generated link
589
+	 */
590
+	public static function get_help_tab_link(
591
+		$help_tab_id,
592
+		$page = false,
593
+		$action = false,
594
+		$icon_style = false,
595
+		$help_text = false
596
+	) {
597
+		$allowedtags = AllowedTags::getAllowedTags();
598
+		/** @var RequestInterface $request */
599
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
600
+		$page    = $page ?: $request->getRequestParam('page', '', 'key');
601
+		$action  = $action ?: $request->getRequestParam('action', 'default', 'key');
602
+
603
+
604
+		$help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
605
+		$icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
606
+		$help_text    = ! $help_text ? '' : $help_text;
607
+		return '<a id="'
608
+			   . esc_attr($help_tab_lnk)
609
+			   . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'
610
+			   . esc_attr($icon)
611
+			   . '" title="'
612
+			   . esc_attr__(
613
+				   'Click to open the \'Help\' tab for more information about this feature.',
614
+				   'event_espresso'
615
+			   )
616
+			   . '" > '
617
+			   . wp_kses($help_text, $allowedtags)
618
+			   . ' </a>';
619
+	}
620
+
621
+
622
+	/**
623
+	 * This is a helper method to generate a status legend for a given status array.
624
+	 * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
625
+	 * status_array.
626
+	 *
627
+	 * @param array  $status_array   array of statuses that will make up the legend. In format:
628
+	 *                               array(
629
+	 *                               'status_item' => 'status_name'
630
+	 *                               )
631
+	 * @param string $active_status  This is used to indicate what the active status is IF that is to be highlighted in
632
+	 *                               the legend.
633
+	 * @return string               html structure for status.
634
+	 * @throws EE_Error
635
+	 */
636
+	public static function status_legend($status_array, $active_status = '')
637
+	{
638
+		if (! is_array($status_array)) {
639
+			throw new EE_Error(
640
+				esc_html__(
641
+					'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
642
+					'event_espresso'
643
+				)
644
+			);
645
+		}
646
+
647
+		$content = '
648 648
             <div class="ee-list-table-legend-container">
649 649
                 <h4 class="status-legend-title">
650 650
                     ' . esc_html__('Status Legend', 'event_espresso') . '
651 651
                 </h4>
652 652
                 <dl class="ee-list-table-legend">';
653 653
 
654
-        foreach ($status_array as $item => $status) {
655
-            $active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
656
-            $content      .= '
654
+		foreach ($status_array as $item => $status) {
655
+			$active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
656
+			$content      .= '
657 657
                     <dt id="' . esc_attr('ee-legend-item-tooltip-' . $item) . '" ' . $active_class . '>
658 658
                         <span class="' . esc_attr('ee-status-legend ee-status-legend-' . $status) . '"></span>
659 659
                         <span class="ee-legend-description">
660 660
                             ' . EEH_Template::pretty_status($status, false, 'sentence') . '
661 661
                         </span>
662 662
                     </dt>';
663
-        }
663
+		}
664 664
 
665
-        $content .= '
665
+		$content .= '
666 666
                 </dl>
667 667
             </div>
668 668
 ';
669
-        return $content;
670
-    }
671
-
672
-
673
-    /**
674
-     * Gets HTML for laying out a deeply-nested array (and objects) in a format
675
-     * that's nice for presenting in the wp admin
676
-     *
677
-     * @param mixed $data
678
-     * @return string
679
-     */
680
-    public static function layout_array_as_table($data)
681
-    {
682
-        if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
683
-            $data = (array) $data;
684
-        }
685
-        ob_start();
686
-        if (is_array($data)) {
687
-            if (EEH_Array::is_associative_array($data)) { ?>
669
+		return $content;
670
+	}
671
+
672
+
673
+	/**
674
+	 * Gets HTML for laying out a deeply-nested array (and objects) in a format
675
+	 * that's nice for presenting in the wp admin
676
+	 *
677
+	 * @param mixed $data
678
+	 * @return string
679
+	 */
680
+	public static function layout_array_as_table($data)
681
+	{
682
+		if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
683
+			$data = (array) $data;
684
+		}
685
+		ob_start();
686
+		if (is_array($data)) {
687
+			if (EEH_Array::is_associative_array($data)) { ?>
688 688
                 <table class="widefat">
689 689
                     <tbody>
690 690
                     <?php foreach ($data as $data_key => $data_values) { ?>
@@ -702,292 +702,292 @@  discard block
 block discarded – undo
702 702
             <?php } else { ?>
703 703
                 <ul>
704 704
                     <?php
705
-                    foreach ($data as $datum) {
706
-                        echo "<li>";
707
-                        echo self::layout_array_as_table($datum);
708
-                        echo "</li>";
709
-                    } ?>
705
+					foreach ($data as $datum) {
706
+						echo "<li>";
707
+						echo self::layout_array_as_table($datum);
708
+						echo "</li>";
709
+					} ?>
710 710
                 </ul>
711 711
             <?php }
712
-        } else {
713
-            // simple value
714
-            echo esc_html($data);
715
-        }
716
-        return ob_get_clean();
717
-    }
718
-
719
-
720
-    /**
721
-     * wrapper for self::get_paging_html() that simply echos the generated paging html
722
-     *
723
-     * @param        $total_items
724
-     * @param        $current
725
-     * @param        $per_page
726
-     * @param        $url
727
-     * @param bool   $show_num_field
728
-     * @param string $paged_arg_name
729
-     * @param array  $items_label
730
-     * @see   self:get_paging_html() for argument docs.
731
-     * @since 4.4.0
732
-     */
733
-    public static function paging_html(
734
-        $total_items,
735
-        $current,
736
-        $per_page,
737
-        $url,
738
-        $show_num_field = true,
739
-        $paged_arg_name = 'paged',
740
-        $items_label = []
741
-    ) {
742
-        echo self::get_paging_html(
743
-            $total_items,
744
-            $current,
745
-            $per_page,
746
-            $url,
747
-            $show_num_field,
748
-            $paged_arg_name,
749
-            $items_label
750
-        );
751
-    }
752
-
753
-
754
-    /**
755
-     * A method for generating paging similar to WP_List_Table
756
-     *
757
-     * @param integer $total_items      How many total items there are to page.
758
-     * @param integer $current          What the current page is.
759
-     * @param integer $per_page         How many items per page.
760
-     * @param string  $url              What the base url for page links is.
761
-     * @param boolean $show_num_field   Whether to show the input for changing page number.
762
-     * @param string  $paged_arg_name   The name of the key for the paged query argument.
763
-     * @param array   $items_label      An array of singular/plural values for the items label:
764
-     *                                  array(
765
-     *                                  'single' => 'item',
766
-     *                                  'plural' => 'items'
767
-     *                                  )
768
-     * @return  string
769
-     * @since    4.4.0
770
-     * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
771
-     */
772
-    public static function get_paging_html(
773
-        $total_items,
774
-        $current,
775
-        $per_page,
776
-        $url,
777
-        $show_num_field = true,
778
-        $paged_arg_name = 'paged',
779
-        $items_label = []
780
-    ) {
781
-        $page_links     = [];
782
-        $disable_first  = $disable_last = '';
783
-        $total_items    = (int) $total_items;
784
-        $per_page       = (int) $per_page;
785
-        $current        = (int) $current;
786
-        $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
787
-
788
-        // filter items_label
789
-        $items_label = apply_filters(
790
-            'FHEE__EEH_Template__get_paging_html__items_label',
791
-            $items_label
792
-        );
793
-
794
-        if (
795
-            empty($items_label)
796
-            || ! is_array($items_label)
797
-            || ! isset($items_label['single'])
798
-            || ! isset($items_label['plural'])
799
-        ) {
800
-            $items_label = [
801
-                'single' => esc_html__('1 item', 'event_espresso'),
802
-                'plural' => esc_html__('%s items', 'event_espresso'),
803
-            ];
804
-        } else {
805
-            $items_label = [
806
-                'single' => '1 ' . esc_html($items_label['single']),
807
-                'plural' => '%s ' . esc_html($items_label['plural']),
808
-            ];
809
-        }
810
-
811
-        $total_pages = ceil($total_items / $per_page);
812
-
813
-        if ($total_pages <= 1) {
814
-            return '';
815
-        }
816
-
817
-        $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
818
-
819
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
820
-
821
-        if ($current === 1) {
822
-            $disable_first = ' disabled';
823
-        }
824
-        if ($current == $total_pages) {
825
-            $disable_last = ' disabled';
826
-        }
827
-
828
-        $page_links[] = sprintf(
829
-            "<a class='%s' title='%s' href='%s'>%s</a>",
830
-            'first-page' . $disable_first,
831
-            esc_attr__('Go to the first page', 'event_espresso'),
832
-            esc_url_raw(remove_query_arg($paged_arg_name, $url)),
833
-            '&laquo;'
834
-        );
835
-
836
-        $page_links[] = sprintf(
837
-            '<a class="%s" title="%s" href="%s">%s</a>',
838
-            'prev-page' . $disable_first,
839
-            esc_attr__('Go to the previous page', 'event_espresso'),
840
-            esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
841
-            '&lsaquo;'
842
-        );
843
-
844
-        if (! $show_num_field) {
845
-            $html_current_page = $current;
846
-        } else {
847
-            $html_current_page = sprintf(
848
-                "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
849
-                esc_attr__('Current page', 'event_espresso'),
850
-                esc_attr($current),
851
-                strlen($total_pages)
852
-            );
853
-        }
854
-
855
-        $html_total_pages = sprintf(
856
-            '<span class="total-pages">%s</span>',
857
-            number_format_i18n($total_pages)
858
-        );
859
-        $page_links[]     = sprintf(
860
-            _x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
861
-            $html_current_page,
862
-            $html_total_pages,
863
-            '<span class="paging-input">',
864
-            '</span>'
865
-        );
866
-
867
-        $page_links[] = sprintf(
868
-            '<a class="%s" title="%s" href="%s">%s</a>',
869
-            'next-page' . $disable_last,
870
-            esc_attr__('Go to the next page', 'event_espresso'),
871
-            esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
872
-            '&rsaquo;'
873
-        );
874
-
875
-        $page_links[] = sprintf(
876
-            '<a class="%s" title="%s" href="%s">%s</a>',
877
-            'last-page' . $disable_last,
878
-            esc_attr__('Go to the last page', 'event_espresso'),
879
-            esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
880
-            '&raquo;'
881
-        );
882
-
883
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
884
-        // set page class
885
-        if ($total_pages) {
886
-            $page_class = $total_pages < 2 ? ' one-page' : '';
887
-        } else {
888
-            $page_class = ' no-pages';
889
-        }
890
-
891
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
892
-    }
893
-
894
-
895
-    /**
896
-     * @param string $wrap_class
897
-     * @param string $wrap_id
898
-     * @return string
899
-     */
900
-    public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = [])
901
-    {
902
-        $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
903
-        if (
904
-            ! $admin
905
-            && ! apply_filters(
906
-                'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
907
-                EE_Registry::instance()->CFG->admin->show_reg_footer
908
-            )
909
-        ) {
910
-            return '';
911
-        }
912
-        $tag        = $admin ? 'span' : 'div';
913
-        $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
914
-        $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
915
-        $attributes .= ! empty($wrap_class)
916
-            ? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
917
-            : ' class="powered-by-event-espresso-credit"';
918
-        $query_args = array_merge(
919
-            [
920
-                'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
921
-                'utm_source'   => 'powered_by_event_espresso',
922
-                'utm_medium'   => 'link',
923
-                'utm_campaign' => 'powered_by',
924
-            ],
925
-            $query_args
926
-        );
927
-        $powered_by = apply_filters(
928
-            'FHEE__EEH_Template__powered_by_event_espresso_text',
929
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
930
-        );
931
-        $url        = add_query_arg($query_args, 'https://eventespresso.com/');
932
-        $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
933
-        return (string) apply_filters(
934
-            'FHEE__EEH_Template__powered_by_event_espresso__html',
935
-            sprintf(
936
-                esc_html_x(
937
-                    '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
938
-                    'Online event registration and ticketing powered by [link to eventespresso.com]',
939
-                    'event_espresso'
940
-                ),
941
-                "<{$tag}{$attributes}>",
942
-                "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
943
-                $admin ? '' : '<br />'
944
-            ),
945
-            $wrap_class,
946
-            $wrap_id
947
-        );
948
-    }
949
-
950
-
951
-    /**
952
-     * @param string $image_name
953
-     * @return string|null
954
-     * @since   4.10.14.p
955
-     */
956
-    public static function getScreenshotUrl($image_name)
957
-    {
958
-        return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
959
-    }
712
+		} else {
713
+			// simple value
714
+			echo esc_html($data);
715
+		}
716
+		return ob_get_clean();
717
+	}
718
+
719
+
720
+	/**
721
+	 * wrapper for self::get_paging_html() that simply echos the generated paging html
722
+	 *
723
+	 * @param        $total_items
724
+	 * @param        $current
725
+	 * @param        $per_page
726
+	 * @param        $url
727
+	 * @param bool   $show_num_field
728
+	 * @param string $paged_arg_name
729
+	 * @param array  $items_label
730
+	 * @see   self:get_paging_html() for argument docs.
731
+	 * @since 4.4.0
732
+	 */
733
+	public static function paging_html(
734
+		$total_items,
735
+		$current,
736
+		$per_page,
737
+		$url,
738
+		$show_num_field = true,
739
+		$paged_arg_name = 'paged',
740
+		$items_label = []
741
+	) {
742
+		echo self::get_paging_html(
743
+			$total_items,
744
+			$current,
745
+			$per_page,
746
+			$url,
747
+			$show_num_field,
748
+			$paged_arg_name,
749
+			$items_label
750
+		);
751
+	}
752
+
753
+
754
+	/**
755
+	 * A method for generating paging similar to WP_List_Table
756
+	 *
757
+	 * @param integer $total_items      How many total items there are to page.
758
+	 * @param integer $current          What the current page is.
759
+	 * @param integer $per_page         How many items per page.
760
+	 * @param string  $url              What the base url for page links is.
761
+	 * @param boolean $show_num_field   Whether to show the input for changing page number.
762
+	 * @param string  $paged_arg_name   The name of the key for the paged query argument.
763
+	 * @param array   $items_label      An array of singular/plural values for the items label:
764
+	 *                                  array(
765
+	 *                                  'single' => 'item',
766
+	 *                                  'plural' => 'items'
767
+	 *                                  )
768
+	 * @return  string
769
+	 * @since    4.4.0
770
+	 * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
771
+	 */
772
+	public static function get_paging_html(
773
+		$total_items,
774
+		$current,
775
+		$per_page,
776
+		$url,
777
+		$show_num_field = true,
778
+		$paged_arg_name = 'paged',
779
+		$items_label = []
780
+	) {
781
+		$page_links     = [];
782
+		$disable_first  = $disable_last = '';
783
+		$total_items    = (int) $total_items;
784
+		$per_page       = (int) $per_page;
785
+		$current        = (int) $current;
786
+		$paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
787
+
788
+		// filter items_label
789
+		$items_label = apply_filters(
790
+			'FHEE__EEH_Template__get_paging_html__items_label',
791
+			$items_label
792
+		);
793
+
794
+		if (
795
+			empty($items_label)
796
+			|| ! is_array($items_label)
797
+			|| ! isset($items_label['single'])
798
+			|| ! isset($items_label['plural'])
799
+		) {
800
+			$items_label = [
801
+				'single' => esc_html__('1 item', 'event_espresso'),
802
+				'plural' => esc_html__('%s items', 'event_espresso'),
803
+			];
804
+		} else {
805
+			$items_label = [
806
+				'single' => '1 ' . esc_html($items_label['single']),
807
+				'plural' => '%s ' . esc_html($items_label['plural']),
808
+			];
809
+		}
810
+
811
+		$total_pages = ceil($total_items / $per_page);
812
+
813
+		if ($total_pages <= 1) {
814
+			return '';
815
+		}
816
+
817
+		$item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
818
+
819
+		$output = '<span class="displaying-num">' . $item_label . '</span>';
820
+
821
+		if ($current === 1) {
822
+			$disable_first = ' disabled';
823
+		}
824
+		if ($current == $total_pages) {
825
+			$disable_last = ' disabled';
826
+		}
827
+
828
+		$page_links[] = sprintf(
829
+			"<a class='%s' title='%s' href='%s'>%s</a>",
830
+			'first-page' . $disable_first,
831
+			esc_attr__('Go to the first page', 'event_espresso'),
832
+			esc_url_raw(remove_query_arg($paged_arg_name, $url)),
833
+			'&laquo;'
834
+		);
835
+
836
+		$page_links[] = sprintf(
837
+			'<a class="%s" title="%s" href="%s">%s</a>',
838
+			'prev-page' . $disable_first,
839
+			esc_attr__('Go to the previous page', 'event_espresso'),
840
+			esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
841
+			'&lsaquo;'
842
+		);
843
+
844
+		if (! $show_num_field) {
845
+			$html_current_page = $current;
846
+		} else {
847
+			$html_current_page = sprintf(
848
+				"<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
849
+				esc_attr__('Current page', 'event_espresso'),
850
+				esc_attr($current),
851
+				strlen($total_pages)
852
+			);
853
+		}
854
+
855
+		$html_total_pages = sprintf(
856
+			'<span class="total-pages">%s</span>',
857
+			number_format_i18n($total_pages)
858
+		);
859
+		$page_links[]     = sprintf(
860
+			_x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
861
+			$html_current_page,
862
+			$html_total_pages,
863
+			'<span class="paging-input">',
864
+			'</span>'
865
+		);
866
+
867
+		$page_links[] = sprintf(
868
+			'<a class="%s" title="%s" href="%s">%s</a>',
869
+			'next-page' . $disable_last,
870
+			esc_attr__('Go to the next page', 'event_espresso'),
871
+			esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
872
+			'&rsaquo;'
873
+		);
874
+
875
+		$page_links[] = sprintf(
876
+			'<a class="%s" title="%s" href="%s">%s</a>',
877
+			'last-page' . $disable_last,
878
+			esc_attr__('Go to the last page', 'event_espresso'),
879
+			esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
880
+			'&raquo;'
881
+		);
882
+
883
+		$output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
884
+		// set page class
885
+		if ($total_pages) {
886
+			$page_class = $total_pages < 2 ? ' one-page' : '';
887
+		} else {
888
+			$page_class = ' no-pages';
889
+		}
890
+
891
+		return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
892
+	}
893
+
894
+
895
+	/**
896
+	 * @param string $wrap_class
897
+	 * @param string $wrap_id
898
+	 * @return string
899
+	 */
900
+	public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = [])
901
+	{
902
+		$admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
903
+		if (
904
+			! $admin
905
+			&& ! apply_filters(
906
+				'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
907
+				EE_Registry::instance()->CFG->admin->show_reg_footer
908
+			)
909
+		) {
910
+			return '';
911
+		}
912
+		$tag        = $admin ? 'span' : 'div';
913
+		$attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
914
+		$wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
915
+		$attributes .= ! empty($wrap_class)
916
+			? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
917
+			: ' class="powered-by-event-espresso-credit"';
918
+		$query_args = array_merge(
919
+			[
920
+				'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
921
+				'utm_source'   => 'powered_by_event_espresso',
922
+				'utm_medium'   => 'link',
923
+				'utm_campaign' => 'powered_by',
924
+			],
925
+			$query_args
926
+		);
927
+		$powered_by = apply_filters(
928
+			'FHEE__EEH_Template__powered_by_event_espresso_text',
929
+			$admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
930
+		);
931
+		$url        = add_query_arg($query_args, 'https://eventespresso.com/');
932
+		$url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
933
+		return (string) apply_filters(
934
+			'FHEE__EEH_Template__powered_by_event_espresso__html',
935
+			sprintf(
936
+				esc_html_x(
937
+					'%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
938
+					'Online event registration and ticketing powered by [link to eventespresso.com]',
939
+					'event_espresso'
940
+				),
941
+				"<{$tag}{$attributes}>",
942
+				"<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
943
+				$admin ? '' : '<br />'
944
+			),
945
+			$wrap_class,
946
+			$wrap_id
947
+		);
948
+	}
949
+
950
+
951
+	/**
952
+	 * @param string $image_name
953
+	 * @return string|null
954
+	 * @since   4.10.14.p
955
+	 */
956
+	public static function getScreenshotUrl($image_name)
957
+	{
958
+		return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
959
+	}
960 960
 }
961 961
 
962 962
 
963 963
 if (! function_exists('espresso_pagination')) {
964
-    /**
965
-     *    espresso_pagination
966
-     *
967
-     * @access    public
968
-     * @return    void
969
-     */
970
-    function espresso_pagination()
971
-    {
972
-        global $wp_query;
973
-        $big        = 999999999; // need an unlikely integer
974
-        $pagination = paginate_links(
975
-            [
976
-                'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
977
-                'format'       => '?paged=%#%',
978
-                'current'      => max(1, get_query_var('paged')),
979
-                'total'        => $wp_query->max_num_pages,
980
-                'show_all'     => true,
981
-                'end_size'     => 10,
982
-                'mid_size'     => 6,
983
-                'prev_next'    => true,
984
-                'prev_text'    => esc_html__('&lsaquo; PREV', 'event_espresso'),
985
-                'next_text'    => esc_html__('NEXT &rsaquo;', 'event_espresso'),
986
-                'type'         => 'plain',
987
-                'add_args'     => false,
988
-                'add_fragment' => '',
989
-            ]
990
-        );
991
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
992
-    }
964
+	/**
965
+	 *    espresso_pagination
966
+	 *
967
+	 * @access    public
968
+	 * @return    void
969
+	 */
970
+	function espresso_pagination()
971
+	{
972
+		global $wp_query;
973
+		$big        = 999999999; // need an unlikely integer
974
+		$pagination = paginate_links(
975
+			[
976
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
977
+				'format'       => '?paged=%#%',
978
+				'current'      => max(1, get_query_var('paged')),
979
+				'total'        => $wp_query->max_num_pages,
980
+				'show_all'     => true,
981
+				'end_size'     => 10,
982
+				'mid_size'     => 6,
983
+				'prev_next'    => true,
984
+				'prev_text'    => esc_html__('&lsaquo; PREV', 'event_espresso'),
985
+				'next_text'    => esc_html__('NEXT &rsaquo;', 'event_espresso'),
986
+				'type'         => 'plain',
987
+				'add_args'     => false,
988
+				'add_fragment' => '',
989
+			]
990
+		);
991
+		echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
992
+	}
993 993
 }
994 994
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 use EventEspresso\core\services\request\RequestInterface;
7 7
 use EventEspresso\core\services\request\sanitizers\AllowedTags;
8 8
 
9
-if (! function_exists('espresso_get_template_part')) {
9
+if ( ! function_exists('espresso_get_template_part')) {
10 10
     /**
11 11
      * espresso_get_template_part
12 12
      * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 }
23 23
 
24 24
 
25
-if (! function_exists('espresso_get_object_css_class')) {
25
+if ( ! function_exists('espresso_get_object_css_class')) {
26 26
     /**
27 27
      * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
28 28
      *
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public static function load_espresso_theme_functions()
75 75
     {
76
-        if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
77
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
78
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
76
+        if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
77
+            if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().'/functions.php')) {
78
+                require_once(EE_PUBLIC.EE_Config::get_current_theme().'/functions.php');
79 79
             }
80 80
         }
81 81
     }
@@ -89,16 +89,16 @@  discard block
 block discarded – undo
89 89
     public static function get_espresso_themes()
90 90
     {
91 91
         if (empty(EEH_Template::$_espresso_themes)) {
92
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
92
+            $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR);
93 93
             if (empty($espresso_themes)) {
94 94
                 return [];
95 95
             }
96 96
             if (($key = array_search('global_assets', $espresso_themes)) !== false) {
97
-                unset($espresso_themes[ $key ]);
97
+                unset($espresso_themes[$key]);
98 98
             }
99 99
             EEH_Template::$_espresso_themes = [];
100 100
             foreach ($espresso_themes as $espresso_theme) {
101
-                EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
101
+                EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
102 102
             }
103 103
         }
104 104
         return EEH_Template::$_espresso_themes;
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
                 // get array of EE Custom Post Types
215 215
                 $EE_CPTs = $custom_post_types->getDefinitions();
216 216
                 // build template name based on request
217
-                if (isset($EE_CPTs[ $post_type ])) {
217
+                if (isset($EE_CPTs[$post_type])) {
218 218
                     $archive_or_single = is_archive() ? 'archive' : '';
219 219
                     $archive_or_single = is_single() ? 'single' : $archive_or_single;
220
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
220
+                    $templates         = $archive_or_single.'-'.$post_type.'.php';
221 221
                 }
222 222
             }
223 223
             // currently active EE template theme
@@ -226,18 +226,18 @@  discard block
 block discarded – undo
226 226
             // array of paths to folders that may contain templates
227 227
             $template_folder_paths = [
228 228
                 // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
229
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
229
+                EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme,
230 230
                 // then in the root of the /wp-content/uploads/espresso/templates/ folder
231 231
                 EVENT_ESPRESSO_TEMPLATE_DIR,
232 232
             ];
233 233
 
234 234
             // add core plugin folders for checking only if we're not $check_if_custom
235
-            if (! $check_if_custom) {
236
-                $core_paths            = [
235
+            if ( ! $check_if_custom) {
236
+                $core_paths = [
237 237
                     // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
238
-                    EE_PUBLIC . $current_theme,
238
+                    EE_PUBLIC.$current_theme,
239 239
                     // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
240
-                    EE_TEMPLATES . $current_theme,
240
+                    EE_TEMPLATES.$current_theme,
241 241
                     // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
242 242
                     EE_PLUGIN_DIR_PATH,
243 243
                 ];
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
                     );
273 273
                     if ($common_base_path !== '') {
274 274
                         // both paths have a common base, so just tack the filename onto our search path
275
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
275
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name;
276 276
                     } else {
277 277
                         // no common base path, so let's just concatenate
278
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
278
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template;
279 279
                     }
280 280
                     // build up our template locations array by adding our resolved paths
281 281
                     $full_template_paths[] = $resolved_path;
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                 // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
284 284
                 array_unshift($full_template_paths, $template);
285 285
                 // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
286
-                array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
286
+                array_unshift($full_template_paths, get_stylesheet_directory().'/'.$file_name);
287 287
             }
288 288
             // filter final array of full template paths
289 289
             $full_template_paths = apply_filters(
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
                 }
335 335
             }
336 336
             $common_base_path .= $directory;
337
-            $last_offset      = $index + 1;
337
+            $last_offset = $index + 1;
338 338
         }
339 339
         return substr($common_base_path, 0, -1);
340 340
     }
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
         $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
373 373
 
374 374
         // you gimme nuttin - YOU GET NUTTIN !!
375
-        if (! $template_path || ! is_readable($template_path)) {
375
+        if ( ! $template_path || ! is_readable($template_path)) {
376 376
             // ignore whether template is accessible ?
377 377
             if ($throw_exceptions) {
378 378
                 throw new DomainException(
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
             return '';
383 383
         }
384 384
         // if $template_args are not in an array, then make it so
385
-        if (! is_array($template_args) && ! is_object($template_args)) {
385
+        if ( ! is_array($template_args) && ! is_object($template_args)) {
386 386
             $template_args = [$template_args];
387 387
         }
388 388
         extract($template_args, EXTR_SKIP);
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
     public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
412 412
     {
413 413
         // in the beginning...
414
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
414
+        $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : '';
415 415
         // da muddle
416 416
         $class = '';
417 417
         // the end
418
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
418
+        $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : '';
419 419
         // is the passed object an EE object ?
420 420
         if ($object instanceof EE_Base_Class) {
421 421
             // grab the exact type of object
@@ -425,10 +425,10 @@  discard block
 block discarded – undo
425 425
                 // no specifics just yet...
426 426
                 default:
427 427
                     $class = strtolower(str_replace('_', '-', $obj_class));
428
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
428
+                    $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : '';
429 429
             }
430 430
         }
431
-        return $prefix . $class . $suffix;
431
+        return $prefix.$class.$suffix;
432 432
     }
433 433
 
434 434
 
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
         // filter raw amount (allows 0.00 to be changed to "free" for example)
464 464
         $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
465 465
         // still a number, or was amount converted to a string like "free" ?
466
-        if (! is_float($amount_formatted)) {
466
+        if ( ! is_float($amount_formatted)) {
467 467
             return esc_html($amount_formatted);
468 468
         }
469 469
         try {
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
             $mny = null;
475 475
         }
476 476
         // verify results
477
-        if (! $mny instanceof EE_Currency_Config) {
477
+        if ( ! $mny instanceof EE_Currency_Config) {
478 478
             // set default config country currency settings
479 479
             $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
480 480
                 ? EE_Registry::instance()->CFG->currency
@@ -483,16 +483,16 @@  discard block
 block discarded – undo
483 483
         // format float
484 484
         $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
485 485
         // add formatting ?
486
-        if (! $return_raw) {
486
+        if ( ! $return_raw) {
487 487
             // add currency sign
488 488
             if ($mny->sign_b4) {
489 489
                 if ($amount >= 0) {
490
-                    $amount_formatted = $mny->sign . $amount_formatted;
490
+                    $amount_formatted = $mny->sign.$amount_formatted;
491 491
                 } else {
492
-                    $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
492
+                    $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted);
493 493
                 }
494 494
             } else {
495
-                $amount_formatted = $amount_formatted . $mny->sign;
495
+                $amount_formatted = $amount_formatted.$mny->sign;
496 496
             }
497 497
 
498 498
             // filter to allow global setting of display_code
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 
504 504
             // add currency code ?
505 505
             $amount_formatted = $display_code
506
-                ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
506
+                ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>'
507 507
                 : $amount_formatted;
508 508
         }
509 509
         // filter results
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
             $plural,
540 540
             $schema
541 541
         );
542
-        return $status[ $status_id ];
542
+        return $status[$status_id];
543 543
     }
544 544
 
545 545
 
@@ -556,14 +556,14 @@  discard block
 block discarded – undo
556 556
     public static function get_button_or_link($url, $label, $class = 'button button--primary', $icon = '', $title = '')
557 557
     {
558 558
         $icon_html = '';
559
-        if (! empty($icon)) {
559
+        if ( ! empty($icon)) {
560 560
             $dashicons = preg_split("(ee-icon |dashicons )", $icon);
561 561
             $dashicons = array_filter($dashicons);
562 562
             $count     = count($dashicons);
563 563
             $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
564 564
             foreach ($dashicons as $dashicon) {
565
-                $type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
566
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
565
+                $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
566
+                $icon_html .= '<span class="'.$type.$dashicon.'"></span>';
567 567
             }
568 568
             $icon_html .= $count > 1 ? '</span>' : '';
569 569
         }
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
         $action  = $action ?: $request->getRequestParam('action', 'default', 'key');
602 602
 
603 603
 
604
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
604
+        $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id;
605 605
         $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
606 606
         $help_text    = ! $help_text ? '' : $help_text;
607 607
         return '<a id="'
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
      */
636 636
     public static function status_legend($status_array, $active_status = '')
637 637
     {
638
-        if (! is_array($status_array)) {
638
+        if ( ! is_array($status_array)) {
639 639
             throw new EE_Error(
640 640
                 esc_html__(
641 641
                     'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
@@ -647,17 +647,17 @@  discard block
 block discarded – undo
647 647
         $content = '
648 648
             <div class="ee-list-table-legend-container">
649 649
                 <h4 class="status-legend-title">
650
-                    ' . esc_html__('Status Legend', 'event_espresso') . '
650
+                    ' . esc_html__('Status Legend', 'event_espresso').'
651 651
                 </h4>
652 652
                 <dl class="ee-list-table-legend">';
653 653
 
654 654
         foreach ($status_array as $item => $status) {
655 655
             $active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
656
-            $content      .= '
657
-                    <dt id="' . esc_attr('ee-legend-item-tooltip-' . $item) . '" ' . $active_class . '>
658
-                        <span class="' . esc_attr('ee-status-legend ee-status-legend-' . $status) . '"></span>
656
+            $content .= '
657
+                    <dt id="' . esc_attr('ee-legend-item-tooltip-'.$item).'" '.$active_class.'>
658
+                        <span class="' . esc_attr('ee-status-legend ee-status-legend-'.$status).'"></span>
659 659
                         <span class="ee-legend-description">
660
-                            ' . EEH_Template::pretty_status($status, false, 'sentence') . '
660
+                            ' . EEH_Template::pretty_status($status, false, 'sentence').'
661 661
                         </span>
662 662
                     </dt>';
663 663
         }
@@ -803,8 +803,8 @@  discard block
 block discarded – undo
803 803
             ];
804 804
         } else {
805 805
             $items_label = [
806
-                'single' => '1 ' . esc_html($items_label['single']),
807
-                'plural' => '%s ' . esc_html($items_label['plural']),
806
+                'single' => '1 '.esc_html($items_label['single']),
807
+                'plural' => '%s '.esc_html($items_label['plural']),
808 808
             ];
809 809
         }
810 810
 
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 
817 817
         $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
818 818
 
819
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
819
+        $output = '<span class="displaying-num">'.$item_label.'</span>';
820 820
 
821 821
         if ($current === 1) {
822 822
             $disable_first = ' disabled';
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 
828 828
         $page_links[] = sprintf(
829 829
             "<a class='%s' title='%s' href='%s'>%s</a>",
830
-            'first-page' . $disable_first,
830
+            'first-page'.$disable_first,
831 831
             esc_attr__('Go to the first page', 'event_espresso'),
832 832
             esc_url_raw(remove_query_arg($paged_arg_name, $url)),
833 833
             '&laquo;'
@@ -835,13 +835,13 @@  discard block
 block discarded – undo
835 835
 
836 836
         $page_links[] = sprintf(
837 837
             '<a class="%s" title="%s" href="%s">%s</a>',
838
-            'prev-page' . $disable_first,
838
+            'prev-page'.$disable_first,
839 839
             esc_attr__('Go to the previous page', 'event_espresso'),
840 840
             esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
841 841
             '&lsaquo;'
842 842
         );
843 843
 
844
-        if (! $show_num_field) {
844
+        if ( ! $show_num_field) {
845 845
             $html_current_page = $current;
846 846
         } else {
847 847
             $html_current_page = sprintf(
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
             '<span class="total-pages">%s</span>',
857 857
             number_format_i18n($total_pages)
858 858
         );
859
-        $page_links[]     = sprintf(
859
+        $page_links[] = sprintf(
860 860
             _x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
861 861
             $html_current_page,
862 862
             $html_total_pages,
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 
867 867
         $page_links[] = sprintf(
868 868
             '<a class="%s" title="%s" href="%s">%s</a>',
869
-            'next-page' . $disable_last,
869
+            'next-page'.$disable_last,
870 870
             esc_attr__('Go to the next page', 'event_espresso'),
871 871
             esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
872 872
             '&rsaquo;'
@@ -874,13 +874,13 @@  discard block
 block discarded – undo
874 874
 
875 875
         $page_links[] = sprintf(
876 876
             '<a class="%s" title="%s" href="%s">%s</a>',
877
-            'last-page' . $disable_last,
877
+            'last-page'.$disable_last,
878 878
             esc_attr__('Go to the last page', 'event_espresso'),
879 879
             esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
880 880
             '&raquo;'
881 881
         );
882 882
 
883
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
883
+        $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>';
884 884
         // set page class
885 885
         if ($total_pages) {
886 886
             $page_class = $total_pages < 2 ? ' one-page' : '';
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
             $page_class = ' no-pages';
889 889
         }
890 890
 
891
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
891
+        return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>';
892 892
     }
893 893
 
894 894
 
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
         );
927 927
         $powered_by = apply_filters(
928 928
             'FHEE__EEH_Template__powered_by_event_espresso_text',
929
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
929
+            $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso'
930 930
         );
931 931
         $url        = add_query_arg($query_args, 'https://eventespresso.com/');
932 932
         $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
@@ -955,12 +955,12 @@  discard block
 block discarded – undo
955 955
      */
956 956
     public static function getScreenshotUrl($image_name)
957 957
     {
958
-        return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
958
+        return esc_url_raw(EE_GLOBAL_ASSETS_URL.'images/screenshots/'.$image_name.'.jpg');
959 959
     }
960 960
 }
961 961
 
962 962
 
963
-if (! function_exists('espresso_pagination')) {
963
+if ( ! function_exists('espresso_pagination')) {
964 964
     /**
965 965
      *    espresso_pagination
966 966
      *
@@ -988,6 +988,6 @@  discard block
 block discarded – undo
988 988
                 'add_fragment' => '',
989 989
             ]
990 990
         );
991
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
991
+        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : '';
992 992
     }
993 993
 }
994 994
\ No newline at end of file
Please login to merge, or discard this patch.
core/admin/EE_Admin_List_Table.core.php 1 patch
Indentation   +878 added lines, -878 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\services\request\sanitizers\AllowedTags;
4 4
 
5 5
 if (! class_exists('WP_List_Table')) {
6
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
+	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
7 7
 }
8 8
 
9 9
 
@@ -21,891 +21,891 @@  discard block
 block discarded – undo
21 21
  */
22 22
 abstract class EE_Admin_List_Table extends WP_List_Table
23 23
 {
24
-    const ACTION_COPY    = 'duplicate';
25
-
26
-    const ACTION_DELETE  = 'delete';
27
-
28
-    const ACTION_EDIT    = 'edit';
29
-
30
-    const ACTION_RESTORE = 'restore';
31
-
32
-    const ACTION_TRASH   = 'trash';
33
-
34
-    protected static $actions = [
35
-        self::ACTION_COPY,
36
-        self::ACTION_DELETE,
37
-        self::ACTION_EDIT,
38
-        self::ACTION_RESTORE,
39
-        self::ACTION_TRASH,
40
-    ];
41
-
42
-    /**
43
-     * holds the data that will be processed for the table
44
-     *
45
-     * @var array $_data
46
-     */
47
-    protected $_data;
48
-
49
-
50
-    /**
51
-     * This holds the value of all the data available for the given view (for all pages).
52
-     *
53
-     * @var int $_all_data_count
54
-     */
55
-    protected $_all_data_count;
56
-
57
-
58
-    /**
59
-     * Will contain the count of trashed items for the view label.
60
-     *
61
-     * @var int $_trashed_count
62
-     */
63
-    protected $_trashed_count;
64
-
65
-
66
-    /**
67
-     * This is what will be referenced as the slug for the current screen
68
-     *
69
-     * @var string $_screen
70
-     */
71
-    protected $_screen;
72
-
73
-
74
-    /**
75
-     * this is the EE_Admin_Page object
76
-     *
77
-     * @var EE_Admin_Page $_admin_page
78
-     */
79
-    protected $_admin_page;
80
-
81
-
82
-    /**
83
-     * The current view
84
-     *
85
-     * @var string $_view
86
-     */
87
-    protected $_view;
88
-
89
-
90
-    /**
91
-     * array of possible views for this table
92
-     *
93
-     * @var array $_views
94
-     */
95
-    protected $_views;
96
-
97
-
98
-    /**
99
-     * An array of key => value pairs containing information about the current table
100
-     * array(
101
-     *        'plural' => 'plural label',
102
-     *        'singular' => 'singular label',
103
-     *        'ajax' => false, //whether to use ajax or not
104
-     *        'screen' => null, //string used to reference what screen this is
105
-     *        (WP_List_table converts to screen object)
106
-     * )
107
-     *
108
-     * @var array $_wp_list_args
109
-     */
110
-    protected $_wp_list_args;
111
-
112
-    /**
113
-     * an array of column names
114
-     * array(
115
-     *    'internal-name' => 'Title'
116
-     * )
117
-     *
118
-     * @var array $_columns
119
-     */
120
-    protected $_columns;
121
-
122
-    /**
123
-     * An array of sortable columns
124
-     * array(
125
-     *    'internal-name' => 'orderby' //or
126
-     *    'internal-name' => array( 'orderby', true )
127
-     * )
128
-     *
129
-     * @var array $_sortable_columns
130
-     */
131
-    protected $_sortable_columns;
132
-
133
-    /**
134
-     * callback method used to perform AJAX row reordering
135
-     *
136
-     * @var string $_ajax_sorting_callback
137
-     */
138
-    protected $_ajax_sorting_callback;
139
-
140
-    /**
141
-     * An array of hidden columns (if needed)
142
-     * array('internal-name', 'internal-name')
143
-     *
144
-     * @var array $_hidden_columns
145
-     */
146
-    protected $_hidden_columns;
147
-
148
-    /**
149
-     * holds the per_page value
150
-     *
151
-     * @var int $_per_page
152
-     */
153
-    protected $_per_page;
154
-
155
-    /**
156
-     * holds what page number is currently being viewed
157
-     *
158
-     * @var int $_current_page
159
-     */
160
-    protected $_current_page;
161
-
162
-    /**
163
-     * the reference string for the nonce_action
164
-     *
165
-     * @var string $_nonce_action_ref
166
-     */
167
-    protected $_nonce_action_ref;
168
-
169
-    /**
170
-     * property to hold incoming request data (as set by the admin_page_core)
171
-     *
172
-     * @var array $_req_data
173
-     */
174
-    protected $_req_data;
175
-
176
-
177
-    /**
178
-     * yes / no array for admin form fields
179
-     *
180
-     * @var array $_yes_no
181
-     */
182
-    protected $_yes_no = [];
183
-
184
-    /**
185
-     * Array describing buttons that should appear at the bottom of the page
186
-     * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
187
-     * and the values are another array with the following keys
188
-     * array(
189
-     *    'route' => 'page_route',
190
-     *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
191
-     * )
192
-     *
193
-     * @var array $_bottom_buttons
194
-     */
195
-    protected $_bottom_buttons = [];
196
-
197
-
198
-    /**
199
-     * Used to indicate what should be the primary column for the list table.
200
-     * If not present then falls back to what WP calculates
201
-     * as the primary column.
202
-     *
203
-     * @type string $_primary_column
204
-     */
205
-    protected $_primary_column = '';
206
-
207
-
208
-    /**
209
-     * Used to indicate whether the table has a checkbox column or not.
210
-     *
211
-     * @type bool $_has_checkbox_column
212
-     */
213
-    protected $_has_checkbox_column = false;
214
-
215
-
216
-    /**
217
-     * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
218
-     */
219
-    public function __construct(EE_Admin_Page $admin_page)
220
-    {
221
-        $this->_admin_page   = $admin_page;
222
-        $this->_req_data     = $this->_admin_page->get_request_data();
223
-        $this->_view         = $this->_admin_page->get_view();
224
-        $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
225
-        $this->_current_page = $this->get_pagenum();
226
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
227
-        $this->_yes_no       = [
228
-            esc_html__('No', 'event_espresso'),
229
-            esc_html__('Yes', 'event_espresso')
230
-        ];
231
-
232
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
233
-
234
-        $this->_setup_data();
235
-        $this->_add_view_counts();
236
-
237
-        $this->_nonce_action_ref = $this->_view;
238
-
239
-        $this->_set_properties();
240
-
241
-        // set primary column
242
-        add_filter('list_table_primary_column', [$this, 'set_primary_column']);
243
-
244
-        // set parent defaults
245
-        parent::__construct($this->_wp_list_args);
246
-
247
-        $this->prepare_items();
248
-    }
249
-
250
-
251
-    /**
252
-     * _setup_data
253
-     * this method is used to setup the $_data, $_all_data_count, and _per_page properties
254
-     *
255
-     * @return void
256
-     * @uses $this->_admin_page
257
-     */
258
-    abstract protected function _setup_data();
259
-
260
-
261
-    /**
262
-     * set the properties that this class needs to be able to execute wp_list_table properly
263
-     * properties set:
264
-     * _wp_list_args = what the arguments required for the parent _wp_list_table.
265
-     * _columns = set the columns in an array.
266
-     * _sortable_columns = columns that are sortable (array).
267
-     * _hidden_columns = columns that are hidden (array)
268
-     * _default_orderby = the default orderby for sorting.
269
-     *
270
-     * @abstract
271
-     * @access protected
272
-     * @return void
273
-     */
274
-    abstract protected function _set_properties();
275
-
276
-
277
-    /**
278
-     * _get_table_filters
279
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
280
-     * gets shown in the table.
281
-     *
282
-     * @abstract
283
-     * @access protected
284
-     * @return string
285
-     */
286
-    abstract protected function _get_table_filters();
287
-
288
-
289
-    /**
290
-     * this is a method that child class will do to add counts to the views array so when views are displayed the
291
-     * counts of the views is accurate.
292
-     *
293
-     * @abstract
294
-     * @access protected
295
-     * @return void
296
-     */
297
-    abstract protected function _add_view_counts();
298
-
299
-
300
-    /**
301
-     * _get_hidden_fields
302
-     * returns a html string of hidden fields so if any table filters are used the current view will be respected.
303
-     *
304
-     * @return string
305
-     */
306
-    protected function _get_hidden_fields()
307
-    {
308
-        $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
309
-        $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
310
-        // if action is STILL empty, then we set it to default
311
-        $action = empty($action) ? 'default' : $action;
312
-        $field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
313
-        $field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
314
-        $field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
315
-
316
-        $bulk_actions = $this->_get_bulk_actions();
317
-        foreach ($bulk_actions as $bulk_action => $label) {
318
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
319
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
320
-        }
321
-
322
-        return $field;
323
-    }
324
-
325
-
326
-    /**
327
-     * _set_column_info
328
-     * we're using this to set the column headers property.
329
-     *
330
-     * @access protected
331
-     * @return void
332
-     */
333
-    protected function _set_column_info()
334
-    {
335
-        $columns   = $this->get_columns();
336
-        $hidden    = $this->get_hidden_columns();
337
-        $_sortable = $this->get_sortable_columns();
338
-
339
-        /**
340
-         * Dynamic hook allowing for adding sortable columns in this list table.
341
-         * Note that $this->screen->id is in the format
342
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
343
-         * table it is: event-espresso_page_espresso_messages.
344
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
345
-         * hook prefix ("event-espresso") will be different.
346
-         *
347
-         * @var array
348
-         */
349
-        $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
350
-
351
-        $sortable = [];
352
-        foreach ($_sortable as $id => $data) {
353
-            if (empty($data)) {
354
-                continue;
355
-            }
356
-            // fix for offset errors with WP_List_Table default get_columninfo()
357
-            if (is_array($data)) {
358
-                $_data[0] = key($data);
359
-                $_data[1] = isset($data[1]) ? $data[1] : false;
360
-            } else {
361
-                $_data[0] = $data;
362
-            }
363
-
364
-            $data = (array) $data;
365
-
366
-            if (! isset($data[1])) {
367
-                $_data[1] = false;
368
-            }
369
-
370
-            $sortable[ $id ] = $_data;
371
-        }
372
-        $primary               = $this->get_primary_column_name();
373
-        $this->_column_headers = [$columns, $hidden, $sortable, $primary];
374
-    }
375
-
376
-
377
-    /**
378
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
379
-     *
380
-     * @return string
381
-     */
382
-    protected function get_primary_column_name()
383
-    {
384
-        foreach (class_parents($this) as $parent) {
385
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
386
-                return parent::get_primary_column_name();
387
-            }
388
-        }
389
-        return $this->_primary_column;
390
-    }
391
-
392
-
393
-    /**
394
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
395
-     *
396
-     * @param EE_Base_Class $item
397
-     * @param string        $column_name
398
-     * @param string        $primary
399
-     * @return string
400
-     */
401
-    protected function handle_row_actions($item, $column_name, $primary)
402
-    {
403
-        foreach (class_parents($this) as $parent) {
404
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
405
-                return parent::handle_row_actions($item, $column_name, $primary);
406
-            }
407
-        }
408
-        return '';
409
-    }
410
-
411
-
412
-    /**
413
-     * _get_bulk_actions
414
-     * This is a wrapper called by WP_List_Table::get_bulk_actions()
415
-     *
416
-     * @access protected
417
-     * @return array bulk_actions
418
-     */
419
-    protected function _get_bulk_actions()
420
-    {
421
-        $actions = [];
422
-        // the _views property should have the bulk_actions, so let's go through and extract them into a properly
423
-        // formatted array for the wp_list_table();
424
-        foreach ($this->_views as $view => $args) {
425
-            if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
426
-                // each bulk action will correspond with a admin page route, so we can check whatever the capability is
427
-                // for that page route and skip adding the bulk action if no access for the current logged in user.
428
-                foreach ($args['bulk_action'] as $route => $label) {
429
-                    if ($this->_admin_page->check_user_access($route, true)) {
430
-                        $actions[ $route ] = $label;
431
-                    }
432
-                }
433
-            }
434
-        }
435
-        return $actions;
436
-    }
437
-
438
-
439
-    /**
440
-     * Generate the table navigation above or below the table.
441
-     * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
442
-     *
443
-     * @throws EE_Error
444
-     * @since 4.9.44.rc.001
445
-     */
446
-    public function display_tablenav($which)
447
-    {
448
-        if ('top' === $which) {
449
-            wp_nonce_field('bulk-' . $this->_args['plural']);
450
-        }
451
-        ?>
24
+	const ACTION_COPY    = 'duplicate';
25
+
26
+	const ACTION_DELETE  = 'delete';
27
+
28
+	const ACTION_EDIT    = 'edit';
29
+
30
+	const ACTION_RESTORE = 'restore';
31
+
32
+	const ACTION_TRASH   = 'trash';
33
+
34
+	protected static $actions = [
35
+		self::ACTION_COPY,
36
+		self::ACTION_DELETE,
37
+		self::ACTION_EDIT,
38
+		self::ACTION_RESTORE,
39
+		self::ACTION_TRASH,
40
+	];
41
+
42
+	/**
43
+	 * holds the data that will be processed for the table
44
+	 *
45
+	 * @var array $_data
46
+	 */
47
+	protected $_data;
48
+
49
+
50
+	/**
51
+	 * This holds the value of all the data available for the given view (for all pages).
52
+	 *
53
+	 * @var int $_all_data_count
54
+	 */
55
+	protected $_all_data_count;
56
+
57
+
58
+	/**
59
+	 * Will contain the count of trashed items for the view label.
60
+	 *
61
+	 * @var int $_trashed_count
62
+	 */
63
+	protected $_trashed_count;
64
+
65
+
66
+	/**
67
+	 * This is what will be referenced as the slug for the current screen
68
+	 *
69
+	 * @var string $_screen
70
+	 */
71
+	protected $_screen;
72
+
73
+
74
+	/**
75
+	 * this is the EE_Admin_Page object
76
+	 *
77
+	 * @var EE_Admin_Page $_admin_page
78
+	 */
79
+	protected $_admin_page;
80
+
81
+
82
+	/**
83
+	 * The current view
84
+	 *
85
+	 * @var string $_view
86
+	 */
87
+	protected $_view;
88
+
89
+
90
+	/**
91
+	 * array of possible views for this table
92
+	 *
93
+	 * @var array $_views
94
+	 */
95
+	protected $_views;
96
+
97
+
98
+	/**
99
+	 * An array of key => value pairs containing information about the current table
100
+	 * array(
101
+	 *        'plural' => 'plural label',
102
+	 *        'singular' => 'singular label',
103
+	 *        'ajax' => false, //whether to use ajax or not
104
+	 *        'screen' => null, //string used to reference what screen this is
105
+	 *        (WP_List_table converts to screen object)
106
+	 * )
107
+	 *
108
+	 * @var array $_wp_list_args
109
+	 */
110
+	protected $_wp_list_args;
111
+
112
+	/**
113
+	 * an array of column names
114
+	 * array(
115
+	 *    'internal-name' => 'Title'
116
+	 * )
117
+	 *
118
+	 * @var array $_columns
119
+	 */
120
+	protected $_columns;
121
+
122
+	/**
123
+	 * An array of sortable columns
124
+	 * array(
125
+	 *    'internal-name' => 'orderby' //or
126
+	 *    'internal-name' => array( 'orderby', true )
127
+	 * )
128
+	 *
129
+	 * @var array $_sortable_columns
130
+	 */
131
+	protected $_sortable_columns;
132
+
133
+	/**
134
+	 * callback method used to perform AJAX row reordering
135
+	 *
136
+	 * @var string $_ajax_sorting_callback
137
+	 */
138
+	protected $_ajax_sorting_callback;
139
+
140
+	/**
141
+	 * An array of hidden columns (if needed)
142
+	 * array('internal-name', 'internal-name')
143
+	 *
144
+	 * @var array $_hidden_columns
145
+	 */
146
+	protected $_hidden_columns;
147
+
148
+	/**
149
+	 * holds the per_page value
150
+	 *
151
+	 * @var int $_per_page
152
+	 */
153
+	protected $_per_page;
154
+
155
+	/**
156
+	 * holds what page number is currently being viewed
157
+	 *
158
+	 * @var int $_current_page
159
+	 */
160
+	protected $_current_page;
161
+
162
+	/**
163
+	 * the reference string for the nonce_action
164
+	 *
165
+	 * @var string $_nonce_action_ref
166
+	 */
167
+	protected $_nonce_action_ref;
168
+
169
+	/**
170
+	 * property to hold incoming request data (as set by the admin_page_core)
171
+	 *
172
+	 * @var array $_req_data
173
+	 */
174
+	protected $_req_data;
175
+
176
+
177
+	/**
178
+	 * yes / no array for admin form fields
179
+	 *
180
+	 * @var array $_yes_no
181
+	 */
182
+	protected $_yes_no = [];
183
+
184
+	/**
185
+	 * Array describing buttons that should appear at the bottom of the page
186
+	 * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
187
+	 * and the values are another array with the following keys
188
+	 * array(
189
+	 *    'route' => 'page_route',
190
+	 *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
191
+	 * )
192
+	 *
193
+	 * @var array $_bottom_buttons
194
+	 */
195
+	protected $_bottom_buttons = [];
196
+
197
+
198
+	/**
199
+	 * Used to indicate what should be the primary column for the list table.
200
+	 * If not present then falls back to what WP calculates
201
+	 * as the primary column.
202
+	 *
203
+	 * @type string $_primary_column
204
+	 */
205
+	protected $_primary_column = '';
206
+
207
+
208
+	/**
209
+	 * Used to indicate whether the table has a checkbox column or not.
210
+	 *
211
+	 * @type bool $_has_checkbox_column
212
+	 */
213
+	protected $_has_checkbox_column = false;
214
+
215
+
216
+	/**
217
+	 * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
218
+	 */
219
+	public function __construct(EE_Admin_Page $admin_page)
220
+	{
221
+		$this->_admin_page   = $admin_page;
222
+		$this->_req_data     = $this->_admin_page->get_request_data();
223
+		$this->_view         = $this->_admin_page->get_view();
224
+		$this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
225
+		$this->_current_page = $this->get_pagenum();
226
+		$this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
227
+		$this->_yes_no       = [
228
+			esc_html__('No', 'event_espresso'),
229
+			esc_html__('Yes', 'event_espresso')
230
+		];
231
+
232
+		$this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
233
+
234
+		$this->_setup_data();
235
+		$this->_add_view_counts();
236
+
237
+		$this->_nonce_action_ref = $this->_view;
238
+
239
+		$this->_set_properties();
240
+
241
+		// set primary column
242
+		add_filter('list_table_primary_column', [$this, 'set_primary_column']);
243
+
244
+		// set parent defaults
245
+		parent::__construct($this->_wp_list_args);
246
+
247
+		$this->prepare_items();
248
+	}
249
+
250
+
251
+	/**
252
+	 * _setup_data
253
+	 * this method is used to setup the $_data, $_all_data_count, and _per_page properties
254
+	 *
255
+	 * @return void
256
+	 * @uses $this->_admin_page
257
+	 */
258
+	abstract protected function _setup_data();
259
+
260
+
261
+	/**
262
+	 * set the properties that this class needs to be able to execute wp_list_table properly
263
+	 * properties set:
264
+	 * _wp_list_args = what the arguments required for the parent _wp_list_table.
265
+	 * _columns = set the columns in an array.
266
+	 * _sortable_columns = columns that are sortable (array).
267
+	 * _hidden_columns = columns that are hidden (array)
268
+	 * _default_orderby = the default orderby for sorting.
269
+	 *
270
+	 * @abstract
271
+	 * @access protected
272
+	 * @return void
273
+	 */
274
+	abstract protected function _set_properties();
275
+
276
+
277
+	/**
278
+	 * _get_table_filters
279
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
280
+	 * gets shown in the table.
281
+	 *
282
+	 * @abstract
283
+	 * @access protected
284
+	 * @return string
285
+	 */
286
+	abstract protected function _get_table_filters();
287
+
288
+
289
+	/**
290
+	 * this is a method that child class will do to add counts to the views array so when views are displayed the
291
+	 * counts of the views is accurate.
292
+	 *
293
+	 * @abstract
294
+	 * @access protected
295
+	 * @return void
296
+	 */
297
+	abstract protected function _add_view_counts();
298
+
299
+
300
+	/**
301
+	 * _get_hidden_fields
302
+	 * returns a html string of hidden fields so if any table filters are used the current view will be respected.
303
+	 *
304
+	 * @return string
305
+	 */
306
+	protected function _get_hidden_fields()
307
+	{
308
+		$action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
309
+		$action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
310
+		// if action is STILL empty, then we set it to default
311
+		$action = empty($action) ? 'default' : $action;
312
+		$field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
313
+		$field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
314
+		$field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
315
+
316
+		$bulk_actions = $this->_get_bulk_actions();
317
+		foreach ($bulk_actions as $bulk_action => $label) {
318
+			$field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
319
+					  . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
320
+		}
321
+
322
+		return $field;
323
+	}
324
+
325
+
326
+	/**
327
+	 * _set_column_info
328
+	 * we're using this to set the column headers property.
329
+	 *
330
+	 * @access protected
331
+	 * @return void
332
+	 */
333
+	protected function _set_column_info()
334
+	{
335
+		$columns   = $this->get_columns();
336
+		$hidden    = $this->get_hidden_columns();
337
+		$_sortable = $this->get_sortable_columns();
338
+
339
+		/**
340
+		 * Dynamic hook allowing for adding sortable columns in this list table.
341
+		 * Note that $this->screen->id is in the format
342
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
343
+		 * table it is: event-espresso_page_espresso_messages.
344
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
345
+		 * hook prefix ("event-espresso") will be different.
346
+		 *
347
+		 * @var array
348
+		 */
349
+		$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
350
+
351
+		$sortable = [];
352
+		foreach ($_sortable as $id => $data) {
353
+			if (empty($data)) {
354
+				continue;
355
+			}
356
+			// fix for offset errors with WP_List_Table default get_columninfo()
357
+			if (is_array($data)) {
358
+				$_data[0] = key($data);
359
+				$_data[1] = isset($data[1]) ? $data[1] : false;
360
+			} else {
361
+				$_data[0] = $data;
362
+			}
363
+
364
+			$data = (array) $data;
365
+
366
+			if (! isset($data[1])) {
367
+				$_data[1] = false;
368
+			}
369
+
370
+			$sortable[ $id ] = $_data;
371
+		}
372
+		$primary               = $this->get_primary_column_name();
373
+		$this->_column_headers = [$columns, $hidden, $sortable, $primary];
374
+	}
375
+
376
+
377
+	/**
378
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
379
+	 *
380
+	 * @return string
381
+	 */
382
+	protected function get_primary_column_name()
383
+	{
384
+		foreach (class_parents($this) as $parent) {
385
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
386
+				return parent::get_primary_column_name();
387
+			}
388
+		}
389
+		return $this->_primary_column;
390
+	}
391
+
392
+
393
+	/**
394
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
395
+	 *
396
+	 * @param EE_Base_Class $item
397
+	 * @param string        $column_name
398
+	 * @param string        $primary
399
+	 * @return string
400
+	 */
401
+	protected function handle_row_actions($item, $column_name, $primary)
402
+	{
403
+		foreach (class_parents($this) as $parent) {
404
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
405
+				return parent::handle_row_actions($item, $column_name, $primary);
406
+			}
407
+		}
408
+		return '';
409
+	}
410
+
411
+
412
+	/**
413
+	 * _get_bulk_actions
414
+	 * This is a wrapper called by WP_List_Table::get_bulk_actions()
415
+	 *
416
+	 * @access protected
417
+	 * @return array bulk_actions
418
+	 */
419
+	protected function _get_bulk_actions()
420
+	{
421
+		$actions = [];
422
+		// the _views property should have the bulk_actions, so let's go through and extract them into a properly
423
+		// formatted array for the wp_list_table();
424
+		foreach ($this->_views as $view => $args) {
425
+			if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
426
+				// each bulk action will correspond with a admin page route, so we can check whatever the capability is
427
+				// for that page route and skip adding the bulk action if no access for the current logged in user.
428
+				foreach ($args['bulk_action'] as $route => $label) {
429
+					if ($this->_admin_page->check_user_access($route, true)) {
430
+						$actions[ $route ] = $label;
431
+					}
432
+				}
433
+			}
434
+		}
435
+		return $actions;
436
+	}
437
+
438
+
439
+	/**
440
+	 * Generate the table navigation above or below the table.
441
+	 * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
442
+	 *
443
+	 * @throws EE_Error
444
+	 * @since 4.9.44.rc.001
445
+	 */
446
+	public function display_tablenav($which)
447
+	{
448
+		if ('top' === $which) {
449
+			wp_nonce_field('bulk-' . $this->_args['plural']);
450
+		}
451
+		?>
452 452
         <div class="tablenav <?php echo esc_attr($which); ?>">
453 453
             <?php if ($this->_get_bulk_actions()) { ?>
454 454
                 <div class="alignleft actions bulkactions">
455 455
                     <?php $this->bulk_actions(); ?>
456 456
                 </div>
457 457
             <?php }
458
-            $this->extra_tablenav($which);
459
-            $this->pagination($which);
460
-            ?>
458
+			$this->extra_tablenav($which);
459
+			$this->pagination($which);
460
+			?>
461 461
 
462 462
             <br class="clear" />
463 463
         </div>
464 464
         <?php
465
-    }
466
-
467
-
468
-    /**
469
-     * _filters
470
-     * This receives the filters array from children _get_table_filters() and assembles the string including the filter
471
-     * button.
472
-     *
473
-     * @access private
474
-     * @return void  echos html showing filters
475
-     */
476
-    private function _filters()
477
-    {
478
-        $classname = get_class($this);
479
-        $filters   = apply_filters(
480
-            "FHEE__{$classname}__filters",
481
-            (array) $this->_get_table_filters(),
482
-            $this,
483
-            $this->_screen
484
-        );
485
-
486
-        if (empty($filters)) {
487
-            return;
488
-        }
489
-        foreach ($filters as $filter) {
490
-            echo wp_kses($filter, AllowedTags::getWithFormTags());
491
-        }
492
-        // add filter button at end
493
-        echo '<input type="submit" class="button-secondary" value="'
494
-             . esc_html__('Filter', 'event_espresso')
495
-             . '" id="post-query-submit" />';
496
-        // add reset filters button at end
497
-        echo '<a class="button button-secondary"  href="'
498
-             . esc_url_raw($this->_admin_page->get_current_page_view_url())
499
-             . '" style="display:inline-block">'
500
-             . esc_html__('Reset Filters', 'event_espresso')
501
-             . '</a>';
502
-    }
503
-
504
-
505
-    /**
506
-     * Callback for 'list_table_primary_column' WordPress filter
507
-     * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
508
-     * column when class is instantiated.
509
-     *
510
-     * @param string $column_name
511
-     * @return string
512
-     * @see WP_List_Table::get_primary_column_name
513
-     */
514
-    public function set_primary_column($column_name)
515
-    {
516
-        return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
517
-    }
518
-
519
-
520
-    /**
521
-     *
522
-     */
523
-    public function prepare_items()
524
-    {
525
-
526
-        $this->_set_column_info();
527
-        // $this->_column_headers = $this->get_column_info();
528
-        $total_items = $this->_all_data_count;
529
-        $this->process_bulk_action();
530
-
531
-        $this->items = $this->_data;
532
-        $this->set_pagination_args(
533
-            [
534
-                'total_items' => $total_items,
535
-                'per_page'    => $this->_per_page,
536
-                'total_pages' => ceil($total_items / $this->_per_page),
537
-            ]
538
-        );
539
-    }
540
-
541
-
542
-    /**
543
-     * @param object|array $item
544
-     * @return string html content for the column
545
-     */
546
-    protected function column_cb($item)
547
-    {
548
-        return '';
549
-    }
550
-
551
-
552
-    /**
553
-     * This column is the default for when there is no defined column method for a registered column.
554
-     * This can be overridden by child classes, but allows for hooking in for custom columns.
555
-     *
556
-     * @param EE_Base_Class $item
557
-     * @param string        $column_name The column being called.
558
-     * @return string html content for the column
559
-     */
560
-    public function column_default($item, $column_name)
561
-    {
562
-        /**
563
-         * Dynamic hook allowing for adding additional column content in this list table.
564
-         * Note that $this->screen->id is in the format
565
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
566
-         * table it is: event-espresso_page_espresso_messages.
567
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
568
-         * hook prefix ("event-espresso") will be different.
569
-         */
570
-        ob_start();
571
-        do_action(
572
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
573
-            $item,
574
-            $this->_screen
575
-        );
576
-        return ob_get_clean();
577
-    }
578
-
579
-
580
-    /**
581
-     * Get a list of columns. The format is:
582
-     * 'internal-name' => 'Title'
583
-     *
584
-     * @return array
585
-     * @since  3.1.0
586
-     * @access public
587
-     * @abstract
588
-     */
589
-    public function get_columns()
590
-    {
591
-        /**
592
-         * Dynamic hook allowing for adding additional columns in this list table.
593
-         * Note that $this->screen->id is in the format
594
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
595
-         * table it is: event-espresso_page_espresso_messages.
596
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
597
-         * hook prefix ("event-espresso") will be different.
598
-         *
599
-         * @var array
600
-         */
601
-        return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
602
-    }
603
-
604
-
605
-    /**
606
-     * Get an associative array ( id => link ) with the list
607
-     * of views available on this table.
608
-     *
609
-     * @return array
610
-     * @since  3.1.0
611
-     * @access protected
612
-     */
613
-    public function get_views()
614
-    {
615
-        return $this->_views;
616
-    }
617
-
618
-
619
-    /**
620
-     * Generate the views html.
621
-     */
622
-    public function display_views()
623
-    {
624
-        $views           = $this->get_views();
625
-        $assembled_views = [];
626
-
627
-        if (empty($views)) {
628
-            return;
629
-        }
630
-        echo "<ul class='subsubsub'>\n";
631
-        foreach ($views as $view) {
632
-            $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
633
-            if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
634
-                $filter = "<li";
635
-                $filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
636
-                $filter .= ">";
637
-                $filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
638
-                $filter .= '<span class="count">(' . $count . ')</span>';
639
-                $filter .= '</li>';
640
-                $assembled_views[ $view['slug'] ] = $filter;
641
-            }
642
-        }
643
-
644
-        echo ! empty($assembled_views)
645
-            ? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
646
-            : '';
647
-        echo "</ul>";
648
-    }
649
-
650
-
651
-    /**
652
-     * Generates content for a single row of the table
653
-     *
654
-     * @param EE_Base_Class $item The current item
655
-     * @since  4.1
656
-     * @access public
657
-     */
658
-    public function single_row($item)
659
-    {
660
-        $row_class = $this->_get_row_class($item);
661
-        echo '<tr class="' . esc_attr($row_class) . '">';
662
-        $this->single_row_columns($item); // already escaped
663
-        echo '</tr>';
664
-    }
665
-
666
-
667
-    /**
668
-     * This simply sets up the row class for the table rows.
669
-     * Allows for easier overriding of child methods for setting up sorting.
670
-     *
671
-     * @param EE_Base_Class $item the current item
672
-     * @return string
673
-     */
674
-    protected function _get_row_class($item)
675
-    {
676
-        static $row_class = '';
677
-        $row_class = ($row_class === '' ? 'alternate' : '');
678
-
679
-        $new_row_class = $row_class;
680
-
681
-        if (! empty($this->_ajax_sorting_callback)) {
682
-            $new_row_class .= ' rowsortable';
683
-        }
684
-
685
-        return $new_row_class;
686
-    }
687
-
688
-
689
-    /**
690
-     * @return array
691
-     */
692
-    public function get_sortable_columns()
693
-    {
694
-        return (array) $this->_sortable_columns;
695
-    }
696
-
697
-
698
-    /**
699
-     * @return string
700
-     */
701
-    public function get_ajax_sorting_callback()
702
-    {
703
-        return $this->_ajax_sorting_callback;
704
-    }
705
-
706
-
707
-    /**
708
-     * @return array
709
-     */
710
-    public function get_hidden_columns()
711
-    {
712
-        $user_id     = get_current_user_id();
713
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
714
-        if (empty($has_default) && ! empty($this->_hidden_columns)) {
715
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
716
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
717
-        }
718
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
719
-        return (array) get_user_option($ref, $user_id);
720
-    }
721
-
722
-
723
-    /**
724
-     * Generates the columns for a single row of the table.
725
-     * Overridden from wp_list_table so as to allow us to filter the column content for a given
726
-     * column.
727
-     *
728
-     * @param EE_Base_Class $item The current item
729
-     * @since 3.1.0
730
-     */
731
-    public function single_row_columns($item)
732
-    {
733
-        [$columns, $hidden, $sortable, $primary] = $this->get_column_info();
734
-
735
-        foreach ($columns as $column_name => $column_display_name) {
736
-
737
-            /**
738
-             * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
739
-             * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
740
-             */
741
-            $hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
742
-
743
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
744
-            if ($primary === $column_name) {
745
-                $classes .= ' has-row-actions column-primary';
746
-            }
747
-
748
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
749
-
750
-            $class = 'class="' . esc_attr($classes) . '"';
751
-
752
-            $attributes = "{$class}{$data}";
753
-
754
-            if ($column_name === 'cb') {
755
-                echo '<th scope="row" class="check-column">';
756
-                echo apply_filters(
757
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
758
-                    $this->column_cb($item), // already escaped
759
-                    $item,
760
-                    $this
761
-                );
762
-                echo '</th>';
763
-            } elseif (method_exists($this, 'column_' . $column_name)) {
764
-                echo "<td $attributes>"; // already escaped
765
-                echo apply_filters(
766
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
767
-                    call_user_func([$this, 'column_' . $column_name], $item),
768
-                    $item,
769
-                    $this
770
-                );
771
-                echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
772
-                echo "</td>";
773
-            } else {
774
-                echo "<td $attributes>"; // already escaped
775
-                echo apply_filters(
776
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
777
-                    $this->column_default($item, $column_name),
778
-                    $item,
779
-                    $column_name,
780
-                    $this
781
-                );
782
-                echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
783
-                echo "</td>";
784
-            }
785
-        }
786
-    }
787
-
788
-
789
-    /**
790
-     * Extra controls to be displayed between bulk actions and pagination
791
-     *
792
-     * @access public
793
-     * @param string $which
794
-     * @throws EE_Error
795
-     */
796
-    public function extra_tablenav($which)
797
-    {
798
-        if ($which === 'top') {
799
-            $this->_filters();
800
-            echo wp_kses($this->_get_hidden_fields(), AllowedTags::getWithFormTags());
801
-        } else {
802
-            echo '<div class="list-table-bottom-buttons alignleft actions">';
803
-            foreach ($this->_bottom_buttons as $type => $action) {
804
-                $route         = $action['route'] ?? '';
805
-                $extra_request = $action['extra_request'] ?? '';
806
-                // already escaped
807
-                echo wp_kses($this->_admin_page->get_action_link_or_button(
808
-                    $route,
809
-                    $type,
810
-                    $extra_request,
811
-                    'button button--secondary'
812
-                ), AllowedTags::getWithFormTags());
813
-            }
814
-            do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
815
-            echo '</div>';
816
-        }
817
-    }
818
-
819
-
820
-    /**
821
-     * Get an associative array ( option_name => option_title ) with the list
822
-     * of bulk actions available on this table.
823
-     *
824
-     * @return array
825
-     * @since  3.1.0
826
-     * @access protected
827
-     */
828
-    public function get_bulk_actions()
829
-    {
830
-        return (array) $this->_get_bulk_actions();
831
-    }
832
-
833
-
834
-    /**
835
-     * Processing bulk actions.
836
-     */
837
-    public function process_bulk_action()
838
-    {
839
-        // this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
840
-        // reference in case there is a case where it gets used.
841
-    }
842
-
843
-
844
-    /**
845
-     * returns the EE admin page this list table is associated with
846
-     *
847
-     * @return EE_Admin_Page
848
-     */
849
-    public function get_admin_page()
850
-    {
851
-        return $this->_admin_page;
852
-    }
853
-
854
-
855
-    /**
856
-     * A "helper" function for all children to provide an html string of
857
-     * actions to output in their content.  It is preferable for child classes
858
-     * to use this method for generating their actions content so that it's
859
-     * filterable by plugins
860
-     *
861
-     * @param string        $action_container           what are the html container
862
-     *                                                  elements for this actions string?
863
-     * @param string        $action_class               What class is for the container
864
-     *                                                  element.
865
-     * @param string        $action_items               The contents for the action items
866
-     *                                                  container.  This is filtered before
867
-     *                                                  returned.
868
-     * @param string        $action_id                  What id (optional) is used for the
869
-     *                                                  container element.
870
-     * @param EE_Base_Class $item                       The object for the column displaying
871
-     *                                                  the actions.
872
-     * @return string The assembled action elements container.
873
-     */
874
-    protected function _action_string(
875
-        $action_items,
876
-        $item,
877
-        $action_container = 'ul',
878
-        $action_class = '',
879
-        $action_id = ''
880
-    ) {
881
-        $action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
882
-        $action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
883
-        $open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
884
-        $close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
885
-        try {
886
-            $content = apply_filters(
887
-                'FHEE__EE_Admin_List_Table___action_string__action_items',
888
-                $action_items,
889
-                $item,
890
-                $this
891
-            );
892
-        } catch (Exception $e) {
893
-            if (WP_DEBUG) {
894
-                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
895
-            }
896
-            $content = $action_items;
897
-        }
898
-        return "{$open_tag}{$content}{$close_tag}";
899
-    }
900
-
901
-
902
-    /**
903
-     * @return string
904
-     */
905
-    protected function getReturnUrl()
906
-    {
907
-        $host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
908
-        $uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
909
-        return urlencode(esc_url_raw("//{$host}{$uri}"));
910
-    }
465
+	}
466
+
467
+
468
+	/**
469
+	 * _filters
470
+	 * This receives the filters array from children _get_table_filters() and assembles the string including the filter
471
+	 * button.
472
+	 *
473
+	 * @access private
474
+	 * @return void  echos html showing filters
475
+	 */
476
+	private function _filters()
477
+	{
478
+		$classname = get_class($this);
479
+		$filters   = apply_filters(
480
+			"FHEE__{$classname}__filters",
481
+			(array) $this->_get_table_filters(),
482
+			$this,
483
+			$this->_screen
484
+		);
485
+
486
+		if (empty($filters)) {
487
+			return;
488
+		}
489
+		foreach ($filters as $filter) {
490
+			echo wp_kses($filter, AllowedTags::getWithFormTags());
491
+		}
492
+		// add filter button at end
493
+		echo '<input type="submit" class="button-secondary" value="'
494
+			 . esc_html__('Filter', 'event_espresso')
495
+			 . '" id="post-query-submit" />';
496
+		// add reset filters button at end
497
+		echo '<a class="button button-secondary"  href="'
498
+			 . esc_url_raw($this->_admin_page->get_current_page_view_url())
499
+			 . '" style="display:inline-block">'
500
+			 . esc_html__('Reset Filters', 'event_espresso')
501
+			 . '</a>';
502
+	}
503
+
504
+
505
+	/**
506
+	 * Callback for 'list_table_primary_column' WordPress filter
507
+	 * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
508
+	 * column when class is instantiated.
509
+	 *
510
+	 * @param string $column_name
511
+	 * @return string
512
+	 * @see WP_List_Table::get_primary_column_name
513
+	 */
514
+	public function set_primary_column($column_name)
515
+	{
516
+		return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
517
+	}
518
+
519
+
520
+	/**
521
+	 *
522
+	 */
523
+	public function prepare_items()
524
+	{
525
+
526
+		$this->_set_column_info();
527
+		// $this->_column_headers = $this->get_column_info();
528
+		$total_items = $this->_all_data_count;
529
+		$this->process_bulk_action();
530
+
531
+		$this->items = $this->_data;
532
+		$this->set_pagination_args(
533
+			[
534
+				'total_items' => $total_items,
535
+				'per_page'    => $this->_per_page,
536
+				'total_pages' => ceil($total_items / $this->_per_page),
537
+			]
538
+		);
539
+	}
540
+
541
+
542
+	/**
543
+	 * @param object|array $item
544
+	 * @return string html content for the column
545
+	 */
546
+	protected function column_cb($item)
547
+	{
548
+		return '';
549
+	}
550
+
551
+
552
+	/**
553
+	 * This column is the default for when there is no defined column method for a registered column.
554
+	 * This can be overridden by child classes, but allows for hooking in for custom columns.
555
+	 *
556
+	 * @param EE_Base_Class $item
557
+	 * @param string        $column_name The column being called.
558
+	 * @return string html content for the column
559
+	 */
560
+	public function column_default($item, $column_name)
561
+	{
562
+		/**
563
+		 * Dynamic hook allowing for adding additional column content in this list table.
564
+		 * Note that $this->screen->id is in the format
565
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
566
+		 * table it is: event-espresso_page_espresso_messages.
567
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
568
+		 * hook prefix ("event-espresso") will be different.
569
+		 */
570
+		ob_start();
571
+		do_action(
572
+			'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
573
+			$item,
574
+			$this->_screen
575
+		);
576
+		return ob_get_clean();
577
+	}
578
+
579
+
580
+	/**
581
+	 * Get a list of columns. The format is:
582
+	 * 'internal-name' => 'Title'
583
+	 *
584
+	 * @return array
585
+	 * @since  3.1.0
586
+	 * @access public
587
+	 * @abstract
588
+	 */
589
+	public function get_columns()
590
+	{
591
+		/**
592
+		 * Dynamic hook allowing for adding additional columns in this list table.
593
+		 * Note that $this->screen->id is in the format
594
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
595
+		 * table it is: event-espresso_page_espresso_messages.
596
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
597
+		 * hook prefix ("event-espresso") will be different.
598
+		 *
599
+		 * @var array
600
+		 */
601
+		return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
602
+	}
603
+
604
+
605
+	/**
606
+	 * Get an associative array ( id => link ) with the list
607
+	 * of views available on this table.
608
+	 *
609
+	 * @return array
610
+	 * @since  3.1.0
611
+	 * @access protected
612
+	 */
613
+	public function get_views()
614
+	{
615
+		return $this->_views;
616
+	}
617
+
618
+
619
+	/**
620
+	 * Generate the views html.
621
+	 */
622
+	public function display_views()
623
+	{
624
+		$views           = $this->get_views();
625
+		$assembled_views = [];
626
+
627
+		if (empty($views)) {
628
+			return;
629
+		}
630
+		echo "<ul class='subsubsub'>\n";
631
+		foreach ($views as $view) {
632
+			$count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
633
+			if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
634
+				$filter = "<li";
635
+				$filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
636
+				$filter .= ">";
637
+				$filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
638
+				$filter .= '<span class="count">(' . $count . ')</span>';
639
+				$filter .= '</li>';
640
+				$assembled_views[ $view['slug'] ] = $filter;
641
+			}
642
+		}
643
+
644
+		echo ! empty($assembled_views)
645
+			? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
646
+			: '';
647
+		echo "</ul>";
648
+	}
649
+
650
+
651
+	/**
652
+	 * Generates content for a single row of the table
653
+	 *
654
+	 * @param EE_Base_Class $item The current item
655
+	 * @since  4.1
656
+	 * @access public
657
+	 */
658
+	public function single_row($item)
659
+	{
660
+		$row_class = $this->_get_row_class($item);
661
+		echo '<tr class="' . esc_attr($row_class) . '">';
662
+		$this->single_row_columns($item); // already escaped
663
+		echo '</tr>';
664
+	}
665
+
666
+
667
+	/**
668
+	 * This simply sets up the row class for the table rows.
669
+	 * Allows for easier overriding of child methods for setting up sorting.
670
+	 *
671
+	 * @param EE_Base_Class $item the current item
672
+	 * @return string
673
+	 */
674
+	protected function _get_row_class($item)
675
+	{
676
+		static $row_class = '';
677
+		$row_class = ($row_class === '' ? 'alternate' : '');
678
+
679
+		$new_row_class = $row_class;
680
+
681
+		if (! empty($this->_ajax_sorting_callback)) {
682
+			$new_row_class .= ' rowsortable';
683
+		}
684
+
685
+		return $new_row_class;
686
+	}
687
+
688
+
689
+	/**
690
+	 * @return array
691
+	 */
692
+	public function get_sortable_columns()
693
+	{
694
+		return (array) $this->_sortable_columns;
695
+	}
696
+
697
+
698
+	/**
699
+	 * @return string
700
+	 */
701
+	public function get_ajax_sorting_callback()
702
+	{
703
+		return $this->_ajax_sorting_callback;
704
+	}
705
+
706
+
707
+	/**
708
+	 * @return array
709
+	 */
710
+	public function get_hidden_columns()
711
+	{
712
+		$user_id     = get_current_user_id();
713
+		$has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
714
+		if (empty($has_default) && ! empty($this->_hidden_columns)) {
715
+			update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
716
+			update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
717
+		}
718
+		$ref = 'manage' . $this->screen->id . 'columnshidden';
719
+		return (array) get_user_option($ref, $user_id);
720
+	}
721
+
722
+
723
+	/**
724
+	 * Generates the columns for a single row of the table.
725
+	 * Overridden from wp_list_table so as to allow us to filter the column content for a given
726
+	 * column.
727
+	 *
728
+	 * @param EE_Base_Class $item The current item
729
+	 * @since 3.1.0
730
+	 */
731
+	public function single_row_columns($item)
732
+	{
733
+		[$columns, $hidden, $sortable, $primary] = $this->get_column_info();
734
+
735
+		foreach ($columns as $column_name => $column_display_name) {
736
+
737
+			/**
738
+			 * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
739
+			 * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
740
+			 */
741
+			$hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
742
+
743
+			$classes = $column_name . ' column-' . $column_name . $hidden_class;
744
+			if ($primary === $column_name) {
745
+				$classes .= ' has-row-actions column-primary';
746
+			}
747
+
748
+			$data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
749
+
750
+			$class = 'class="' . esc_attr($classes) . '"';
751
+
752
+			$attributes = "{$class}{$data}";
753
+
754
+			if ($column_name === 'cb') {
755
+				echo '<th scope="row" class="check-column">';
756
+				echo apply_filters(
757
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
758
+					$this->column_cb($item), // already escaped
759
+					$item,
760
+					$this
761
+				);
762
+				echo '</th>';
763
+			} elseif (method_exists($this, 'column_' . $column_name)) {
764
+				echo "<td $attributes>"; // already escaped
765
+				echo apply_filters(
766
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
767
+					call_user_func([$this, 'column_' . $column_name], $item),
768
+					$item,
769
+					$this
770
+				);
771
+				echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
772
+				echo "</td>";
773
+			} else {
774
+				echo "<td $attributes>"; // already escaped
775
+				echo apply_filters(
776
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
777
+					$this->column_default($item, $column_name),
778
+					$item,
779
+					$column_name,
780
+					$this
781
+				);
782
+				echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
783
+				echo "</td>";
784
+			}
785
+		}
786
+	}
787
+
788
+
789
+	/**
790
+	 * Extra controls to be displayed between bulk actions and pagination
791
+	 *
792
+	 * @access public
793
+	 * @param string $which
794
+	 * @throws EE_Error
795
+	 */
796
+	public function extra_tablenav($which)
797
+	{
798
+		if ($which === 'top') {
799
+			$this->_filters();
800
+			echo wp_kses($this->_get_hidden_fields(), AllowedTags::getWithFormTags());
801
+		} else {
802
+			echo '<div class="list-table-bottom-buttons alignleft actions">';
803
+			foreach ($this->_bottom_buttons as $type => $action) {
804
+				$route         = $action['route'] ?? '';
805
+				$extra_request = $action['extra_request'] ?? '';
806
+				// already escaped
807
+				echo wp_kses($this->_admin_page->get_action_link_or_button(
808
+					$route,
809
+					$type,
810
+					$extra_request,
811
+					'button button--secondary'
812
+				), AllowedTags::getWithFormTags());
813
+			}
814
+			do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
815
+			echo '</div>';
816
+		}
817
+	}
818
+
819
+
820
+	/**
821
+	 * Get an associative array ( option_name => option_title ) with the list
822
+	 * of bulk actions available on this table.
823
+	 *
824
+	 * @return array
825
+	 * @since  3.1.0
826
+	 * @access protected
827
+	 */
828
+	public function get_bulk_actions()
829
+	{
830
+		return (array) $this->_get_bulk_actions();
831
+	}
832
+
833
+
834
+	/**
835
+	 * Processing bulk actions.
836
+	 */
837
+	public function process_bulk_action()
838
+	{
839
+		// this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
840
+		// reference in case there is a case where it gets used.
841
+	}
842
+
843
+
844
+	/**
845
+	 * returns the EE admin page this list table is associated with
846
+	 *
847
+	 * @return EE_Admin_Page
848
+	 */
849
+	public function get_admin_page()
850
+	{
851
+		return $this->_admin_page;
852
+	}
853
+
854
+
855
+	/**
856
+	 * A "helper" function for all children to provide an html string of
857
+	 * actions to output in their content.  It is preferable for child classes
858
+	 * to use this method for generating their actions content so that it's
859
+	 * filterable by plugins
860
+	 *
861
+	 * @param string        $action_container           what are the html container
862
+	 *                                                  elements for this actions string?
863
+	 * @param string        $action_class               What class is for the container
864
+	 *                                                  element.
865
+	 * @param string        $action_items               The contents for the action items
866
+	 *                                                  container.  This is filtered before
867
+	 *                                                  returned.
868
+	 * @param string        $action_id                  What id (optional) is used for the
869
+	 *                                                  container element.
870
+	 * @param EE_Base_Class $item                       The object for the column displaying
871
+	 *                                                  the actions.
872
+	 * @return string The assembled action elements container.
873
+	 */
874
+	protected function _action_string(
875
+		$action_items,
876
+		$item,
877
+		$action_container = 'ul',
878
+		$action_class = '',
879
+		$action_id = ''
880
+	) {
881
+		$action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
882
+		$action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
883
+		$open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
884
+		$close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
885
+		try {
886
+			$content = apply_filters(
887
+				'FHEE__EE_Admin_List_Table___action_string__action_items',
888
+				$action_items,
889
+				$item,
890
+				$this
891
+			);
892
+		} catch (Exception $e) {
893
+			if (WP_DEBUG) {
894
+				EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
895
+			}
896
+			$content = $action_items;
897
+		}
898
+		return "{$open_tag}{$content}{$close_tag}";
899
+	}
900
+
901
+
902
+	/**
903
+	 * @return string
904
+	 */
905
+	protected function getReturnUrl()
906
+	{
907
+		$host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
908
+		$uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
909
+		return urlencode(esc_url_raw("//{$host}{$uri}"));
910
+	}
911 911
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +4093 added lines, -4093 removed lines patch added patch discarded remove patch
@@ -19,4167 +19,4167 @@
 block discarded – undo
19 19
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
20 20
 {
21 21
 
22
-    /**
23
-     * @var LoaderInterface
24
-     */
25
-    protected $loader;
22
+	/**
23
+	 * @var LoaderInterface
24
+	 */
25
+	protected $loader;
26 26
 
27
-    /**
28
-     * @var RequestInterface
29
-     */
30
-    protected $request;
27
+	/**
28
+	 * @var RequestInterface
29
+	 */
30
+	protected $request;
31 31
 
32
-    // set in _init_page_props()
33
-    public $page_slug;
32
+	// set in _init_page_props()
33
+	public $page_slug;
34 34
 
35
-    public $page_label;
35
+	public $page_label;
36 36
 
37
-    public $page_folder;
37
+	public $page_folder;
38 38
 
39
-    // set in define_page_props()
40
-    protected $_admin_base_url;
39
+	// set in define_page_props()
40
+	protected $_admin_base_url;
41 41
 
42
-    protected $_admin_base_path;
42
+	protected $_admin_base_path;
43 43
 
44
-    protected $_admin_page_title;
44
+	protected $_admin_page_title;
45 45
 
46
-    protected $_labels;
46
+	protected $_labels;
47 47
 
48 48
 
49
-    // set early within EE_Admin_Init
50
-    protected $_wp_page_slug;
49
+	// set early within EE_Admin_Init
50
+	protected $_wp_page_slug;
51 51
 
52
-    // navtabs
53
-    protected $_nav_tabs;
52
+	// navtabs
53
+	protected $_nav_tabs;
54 54
 
55
-    protected $_default_nav_tab_name;
55
+	protected $_default_nav_tab_name;
56 56
 
57 57
 
58
-    // template variables (used by templates)
59
-    protected $_template_path;
58
+	// template variables (used by templates)
59
+	protected $_template_path;
60 60
 
61
-    protected $_column_template_path;
61
+	protected $_column_template_path;
62 62
 
63
-    /**
64
-     * @var array $_template_args
65
-     */
66
-    protected $_template_args = [];
63
+	/**
64
+	 * @var array $_template_args
65
+	 */
66
+	protected $_template_args = [];
67 67
 
68
-    /**
69
-     * this will hold the list table object for a given view.
70
-     *
71
-     * @var EE_Admin_List_Table $_list_table_object
72
-     */
73
-    protected $_list_table_object;
68
+	/**
69
+	 * this will hold the list table object for a given view.
70
+	 *
71
+	 * @var EE_Admin_List_Table $_list_table_object
72
+	 */
73
+	protected $_list_table_object;
74 74
 
75
-    // bools
76
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
75
+	// bools
76
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
77 77
 
78
-    protected $_routing;
78
+	protected $_routing;
79 79
 
80
-    // list table args
81
-    protected $_view;
80
+	// list table args
81
+	protected $_view;
82 82
 
83
-    protected $_views;
83
+	protected $_views;
84 84
 
85 85
 
86
-    // action => method pairs used for routing incoming requests
87
-    protected $_page_routes;
86
+	// action => method pairs used for routing incoming requests
87
+	protected $_page_routes;
88 88
 
89
-    /**
90
-     * @var array $_page_config
91
-     */
92
-    protected $_page_config;
89
+	/**
90
+	 * @var array $_page_config
91
+	 */
92
+	protected $_page_config;
93 93
 
94
-    /**
95
-     * the current page route and route config
96
-     *
97
-     * @var string $_route
98
-     */
99
-    protected $_route;
94
+	/**
95
+	 * the current page route and route config
96
+	 *
97
+	 * @var string $_route
98
+	 */
99
+	protected $_route;
100 100
 
101
-    /**
102
-     * @var string $_cpt_route
103
-     */
104
-    protected $_cpt_route;
101
+	/**
102
+	 * @var string $_cpt_route
103
+	 */
104
+	protected $_cpt_route;
105 105
 
106
-    /**
107
-     * @var array $_route_config
108
-     */
109
-    protected $_route_config;
106
+	/**
107
+	 * @var array $_route_config
108
+	 */
109
+	protected $_route_config;
110 110
 
111
-    /**
112
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
113
-     * actions.
114
-     *
115
-     * @since 4.6.x
116
-     * @var array.
117
-     */
118
-    protected $_default_route_query_args;
119
-
120
-    // set via request page and action args.
121
-    protected $_current_page;
122
-
123
-    protected $_current_view;
124
-
125
-    protected $_current_page_view_url;
126
-
127
-    /**
128
-     * unprocessed value for the 'action' request param (default '')
129
-     *
130
-     * @var string
131
-     */
132
-    protected $raw_req_action = '';
133
-
134
-    /**
135
-     * unprocessed value for the 'page' request param (default '')
136
-     *
137
-     * @var string
138
-     */
139
-    protected $raw_req_page = '';
140
-
141
-    /**
142
-     * sanitized request action (and nonce)
143
-     *
144
-     * @var string
145
-     */
146
-    protected $_req_action = '';
147
-
148
-    /**
149
-     * sanitized request action nonce
150
-     *
151
-     * @var string
152
-     */
153
-    protected $_req_nonce = '';
154
-
155
-    /**
156
-     * @var string
157
-     */
158
-    protected $_search_btn_label = '';
159
-
160
-    /**
161
-     * @var string
162
-     */
163
-    protected $_search_box_callback = '';
164
-
165
-    /**
166
-     * @var WP_Screen
167
-     */
168
-    protected $_current_screen;
169
-
170
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
171
-    protected $_hook_obj;
172
-
173
-    // for holding incoming request data
174
-    protected $_req_data = [];
175
-
176
-    // yes / no array for admin form fields
177
-    protected $_yes_no_values = [];
178
-
179
-    // some default things shared by all child classes
180
-    protected $_default_espresso_metaboxes;
181
-
182
-    /**
183
-     * @var EE_Registry
184
-     */
185
-    protected $EE = null;
186
-
187
-
188
-    /**
189
-     * This is just a property that flags whether the given route is a caffeinated route or not.
190
-     *
191
-     * @var boolean
192
-     */
193
-    protected $_is_caf = false;
194
-
195
-
196
-    /**
197
-     * @Constructor
198
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
199
-     * @throws EE_Error
200
-     * @throws InvalidArgumentException
201
-     * @throws ReflectionException
202
-     * @throws InvalidDataTypeException
203
-     * @throws InvalidInterfaceException
204
-     */
205
-    public function __construct($routing = true)
206
-    {
207
-        $this->loader  = LoaderFactory::getLoader();
208
-        $this->request = $this->loader->getShared(RequestInterface::class);
209
-        $this->_routing = $routing;
210
-
211
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
212
-            $this->_is_caf = true;
213
-        }
214
-        $this->_yes_no_values = [
215
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
216
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
217
-        ];
218
-        // set the _req_data property.
219
-        $this->_req_data = $this->request->requestParams();
220
-        // set initial page props (child method)
221
-        $this->_init_page_props();
222
-        // set global defaults
223
-        $this->_set_defaults();
224
-        // set early because incoming requests could be ajax related and we need to register those hooks.
225
-        $this->_global_ajax_hooks();
226
-        $this->_ajax_hooks();
227
-        // other_page_hooks have to be early too.
228
-        $this->_do_other_page_hooks();
229
-        // set up page dependencies
230
-        $this->_before_page_setup();
231
-        $this->_page_setup();
232
-        // die();
233
-    }
234
-
235
-
236
-    /**
237
-     * _init_page_props
238
-     * Child classes use to set at least the following properties:
239
-     * $page_slug.
240
-     * $page_label.
241
-     *
242
-     * @abstract
243
-     * @return void
244
-     */
245
-    abstract protected function _init_page_props();
246
-
247
-
248
-    /**
249
-     * _ajax_hooks
250
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
251
-     * Note: within the ajax callback methods.
252
-     *
253
-     * @abstract
254
-     * @return void
255
-     */
256
-    abstract protected function _ajax_hooks();
257
-
258
-
259
-    /**
260
-     * _define_page_props
261
-     * child classes define page properties in here.  Must include at least:
262
-     * $_admin_base_url = base_url for all admin pages
263
-     * $_admin_page_title = default admin_page_title for admin pages
264
-     * $_labels = array of default labels for various automatically generated elements:
265
-     *    array(
266
-     *        'buttons' => array(
267
-     *            'add' => esc_html__('label for add new button'),
268
-     *            'edit' => esc_html__('label for edit button'),
269
-     *            'delete' => esc_html__('label for delete button')
270
-     *            )
271
-     *        )
272
-     *
273
-     * @abstract
274
-     * @return void
275
-     */
276
-    abstract protected function _define_page_props();
277
-
278
-
279
-    /**
280
-     * _set_page_routes
281
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
282
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
283
-     * have a 'default' route. Here's the format
284
-     * $this->_page_routes = array(
285
-     *        'default' => array(
286
-     *            'func' => '_default_method_handling_route',
287
-     *            'args' => array('array','of','args'),
288
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
289
-     *            ajax request, backend processing)
290
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
291
-     *            headers route after.  The string you enter here should match the defined route reference for a
292
-     *            headers sent route.
293
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
294
-     *            this route.
295
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
296
-     *            checks).
297
-     *        ),
298
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
299
-     *        handling method.
300
-     *        )
301
-     * )
302
-     *
303
-     * @abstract
304
-     * @return void
305
-     */
306
-    abstract protected function _set_page_routes();
307
-
308
-
309
-    /**
310
-     * _set_page_config
311
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
312
-     * array corresponds to the page_route for the loaded page. Format:
313
-     * $this->_page_config = array(
314
-     *        'default' => array(
315
-     *            'labels' => array(
316
-     *                'buttons' => array(
317
-     *                    'add' => esc_html__('label for adding item'),
318
-     *                    'edit' => esc_html__('label for editing item'),
319
-     *                    'delete' => esc_html__('label for deleting item')
320
-     *                ),
321
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
322
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
323
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
324
-     *            _define_page_props() method
325
-     *            'nav' => array(
326
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
327
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
328
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
329
-     *                'order' => 10, //required to indicate tab position.
330
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
331
-     *                displayed then add this parameter.
332
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
333
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
334
-     *            metaboxes set for eventespresso admin pages.
335
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
336
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
337
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
338
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
339
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
340
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
341
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
342
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
343
-     *            want to display.
344
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
345
-     *                'tab_id' => array(
346
-     *                    'title' => 'tab_title',
347
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
348
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
349
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
350
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
351
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
352
-     *                    attempt to use the callback which should match the name of a method in the class
353
-     *                    ),
354
-     *                'tab2_id' => array(
355
-     *                    'title' => 'tab2 title',
356
-     *                    'filename' => 'file_name_2'
357
-     *                    'callback' => 'callback_method_for_content',
358
-     *                 ),
359
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
360
-     *            help tab area on an admin page. @return void
361
-     *
362
-     * @abstract
363
-     */
364
-    abstract protected function _set_page_config();
365
-
366
-
367
-    /**
368
-     * _add_screen_options
369
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
370
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
371
-     * to a particular view.
372
-     *
373
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
374
-     *         see also WP_Screen object documents...
375
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
376
-     * @abstract
377
-     * @return void
378
-     */
379
-    abstract protected function _add_screen_options();
380
-
381
-
382
-    /**
383
-     * _add_feature_pointers
384
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
385
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
386
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
387
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
388
-     * extended) also see:
389
-     *
390
-     * @link   http://eamann.com/tech/wordpress-portland/
391
-     * @abstract
392
-     * @return void
393
-     */
394
-    abstract protected function _add_feature_pointers();
395
-
396
-
397
-    /**
398
-     * load_scripts_styles
399
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
400
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
401
-     * scripts/styles per view by putting them in a dynamic function in this format
402
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
403
-     *
404
-     * @abstract
405
-     * @return void
406
-     */
407
-    abstract public function load_scripts_styles();
408
-
409
-
410
-    /**
411
-     * admin_init
412
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
413
-     * all pages/views loaded by child class.
414
-     *
415
-     * @abstract
416
-     * @return void
417
-     */
418
-    abstract public function admin_init();
419
-
420
-
421
-    /**
422
-     * admin_notices
423
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
424
-     * all pages/views loaded by child class.
425
-     *
426
-     * @abstract
427
-     * @return void
428
-     */
429
-    abstract public function admin_notices();
430
-
431
-
432
-    /**
433
-     * admin_footer_scripts
434
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
435
-     * will apply to all pages/views loaded by child class.
436
-     *
437
-     * @return void
438
-     */
439
-    abstract public function admin_footer_scripts();
440
-
441
-
442
-    /**
443
-     * admin_footer
444
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
445
-     * apply to all pages/views loaded by child class.
446
-     *
447
-     * @return void
448
-     */
449
-    public function admin_footer()
450
-    {
451
-    }
452
-
453
-
454
-    /**
455
-     * _global_ajax_hooks
456
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
457
-     * Note: within the ajax callback methods.
458
-     *
459
-     * @abstract
460
-     * @return void
461
-     */
462
-    protected function _global_ajax_hooks()
463
-    {
464
-        // for lazy loading of metabox content
465
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
466
-    }
467
-
468
-
469
-    public function ajax_metabox_content()
470
-    {
471
-        $content_id  = $this->request->getRequestParam('contentid', '');
472
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
473
-        self::cached_rss_display($content_id, $content_url);
474
-        wp_die();
475
-    }
476
-
477
-
478
-    /**
479
-     * allows extending classes do something specific before the parent constructor runs _page_setup().
480
-     *
481
-     * @return void
482
-     */
483
-    protected function _before_page_setup()
484
-    {
485
-        // default is to do nothing
486
-    }
487
-
488
-
489
-    /**
490
-     * Makes sure any things that need to be loaded early get handled.
491
-     * We also escape early here if the page requested doesn't match the object.
492
-     *
493
-     * @final
494
-     * @return void
495
-     * @throws EE_Error
496
-     * @throws InvalidArgumentException
497
-     * @throws ReflectionException
498
-     * @throws InvalidDataTypeException
499
-     * @throws InvalidInterfaceException
500
-     */
501
-    final protected function _page_setup()
502
-    {
503
-        // requires?
504
-        // admin_init stuff - global - we're setting this REALLY early
505
-        // so if EE_Admin pages have to hook into other WP pages they can.
506
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
507
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
508
-        // next verify if we need to load anything...
509
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
510
-        $this->page_folder   = strtolower(
511
-            str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
512
-        );
513
-        global $ee_menu_slugs;
514
-        $ee_menu_slugs = (array) $ee_menu_slugs;
515
-        if (
516
-            ! $this->request->isAjax()
517
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
518
-        ) {
519
-            return;
520
-        }
521
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
522
-        // we need to copy the action from the second to the first
523
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
524
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
525
-        $action     = $action !== '-1' ? $action : $action2;
526
-        $req_action = $action !== '-1' ? $action : 'default';
527
-
528
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
529
-        // then let's use the route as the action.
530
-        // This covers cases where we're coming in from a list table that isn't on the default route.
531
-        $route = $this->request->getRequestParam('route');
532
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
533
-            ? $route
534
-            : $req_action;
535
-
536
-        $this->_current_view = $this->_req_action;
537
-        $this->_req_nonce    = $this->_req_action . '_nonce';
538
-        $this->_define_page_props();
539
-        $this->_current_page_view_url = add_query_arg(
540
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
541
-            $this->_admin_base_url
542
-        );
543
-        // default things
544
-        $this->_default_espresso_metaboxes = [
545
-            '_espresso_news_post_box',
546
-            '_espresso_links_post_box',
547
-            '_espresso_ratings_request',
548
-            '_espresso_sponsors_post_box',
549
-        ];
550
-        // set page configs
551
-        $this->_set_page_routes();
552
-        $this->_set_page_config();
553
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
554
-        if ($this->request->requestParamIsSet('wp_referer')) {
555
-            $wp_referer = $this->request->getRequestParam('wp_referer');
556
-            if ($wp_referer) {
557
-                $this->_default_route_query_args['wp_referer'] = $wp_referer;
558
-            }
559
-        }
560
-        // for caffeinated and other extended functionality.
561
-        //  If there is a _extend_page_config method
562
-        // then let's run that to modify the all the various page configuration arrays
563
-        if (method_exists($this, '_extend_page_config')) {
564
-            $this->_extend_page_config();
565
-        }
566
-        // for CPT and other extended functionality.
567
-        // If there is an _extend_page_config_for_cpt
568
-        // then let's run that to modify all the various page configuration arrays.
569
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
570
-            $this->_extend_page_config_for_cpt();
571
-        }
572
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
573
-        $this->_page_routes = apply_filters(
574
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
575
-            $this->_page_routes,
576
-            $this
577
-        );
578
-        $this->_page_config = apply_filters(
579
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
580
-            $this->_page_config,
581
-            $this
582
-        );
583
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
584
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
585
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
586
-            add_action(
587
-                'AHEE__EE_Admin_Page__route_admin_request',
588
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
589
-                10,
590
-                2
591
-            );
592
-        }
593
-        // next route only if routing enabled
594
-        if ($this->_routing && ! $this->request->isAjax()) {
595
-            $this->_verify_routes();
596
-            // next let's just check user_access and kill if no access
597
-            $this->check_user_access();
598
-            if ($this->_is_UI_request) {
599
-                // admin_init stuff - global, all views for this page class, specific view
600
-                add_action('admin_init', [$this, 'admin_init'], 10);
601
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
602
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
603
-                }
604
-            } else {
605
-                // hijack regular WP loading and route admin request immediately
606
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
607
-                $this->route_admin_request();
608
-            }
609
-        }
610
-    }
611
-
612
-
613
-    /**
614
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
615
-     *
616
-     * @return void
617
-     * @throws EE_Error
618
-     */
619
-    private function _do_other_page_hooks()
620
-    {
621
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
622
-        foreach ($registered_pages as $page) {
623
-            // now let's setup the file name and class that should be present
624
-            $classname = str_replace('.class.php', '', $page);
625
-            // autoloaders should take care of loading file
626
-            if (! class_exists($classname)) {
627
-                $error_msg[] = sprintf(
628
-                    esc_html__(
629
-                        'Something went wrong with loading the %s admin hooks page.',
630
-                        'event_espresso'
631
-                    ),
632
-                    $page
633
-                );
634
-                $error_msg[] = $error_msg[0]
635
-                               . "\r\n"
636
-                               . sprintf(
637
-                                   esc_html__(
638
-                                       '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',
639
-                                       'event_espresso'
640
-                                   ),
641
-                                   $page,
642
-                                   '<br />',
643
-                                   '<strong>' . $classname . '</strong>'
644
-                               );
645
-                throw new EE_Error(implode('||', $error_msg));
646
-            }
647
-            // notice we are passing the instance of this class to the hook object.
648
-            $this->loader->getShared($classname, [$this]);
649
-        }
650
-    }
651
-
652
-
653
-    /**
654
-     * @throws ReflectionException
655
-     * @throws EE_Error
656
-     */
657
-    public function load_page_dependencies()
658
-    {
659
-        try {
660
-            $this->_load_page_dependencies();
661
-        } catch (EE_Error $e) {
662
-            $e->get_error();
663
-        }
664
-    }
665
-
666
-
667
-    /**
668
-     * load_page_dependencies
669
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
670
-     *
671
-     * @return void
672
-     * @throws DomainException
673
-     * @throws EE_Error
674
-     * @throws InvalidArgumentException
675
-     * @throws InvalidDataTypeException
676
-     * @throws InvalidInterfaceException
677
-     */
678
-    protected function _load_page_dependencies()
679
-    {
680
-        // let's set the current_screen and screen options to override what WP set
681
-        $this->_current_screen = get_current_screen();
682
-        // load admin_notices - global, page class, and view specific
683
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
684
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
685
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
686
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
687
-        }
688
-        // load network admin_notices - global, page class, and view specific
689
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
690
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
691
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
692
-        }
693
-        // this will save any per_page screen options if they are present
694
-        $this->_set_per_page_screen_options();
695
-        // setup list table properties
696
-        $this->_set_list_table();
697
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
698
-        // However in some cases the metaboxes will need to be added within a route handling callback.
699
-        $this->_add_registered_meta_boxes();
700
-        $this->_add_screen_columns();
701
-        // add screen options - global, page child class, and view specific
702
-        $this->_add_global_screen_options();
703
-        $this->_add_screen_options();
704
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
705
-        if (method_exists($this, $add_screen_options)) {
706
-            $this->{$add_screen_options}();
707
-        }
708
-        // add help tab(s) - set via page_config and qtips.
709
-        $this->_add_help_tabs();
710
-        $this->_add_qtips();
711
-        // add feature_pointers - global, page child class, and view specific
712
-        $this->_add_feature_pointers();
713
-        $this->_add_global_feature_pointers();
714
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
715
-        if (method_exists($this, $add_feature_pointer)) {
716
-            $this->{$add_feature_pointer}();
717
-        }
718
-        // enqueue scripts/styles - global, page class, and view specific
719
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
720
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
721
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
722
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
723
-        }
724
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
725
-        // admin_print_footer_scripts - global, page child class, and view specific.
726
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
727
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
728
-        // is a good use case. Notice the late priority we're giving these
729
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
730
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
731
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
732
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
733
-        }
734
-        // admin footer scripts
735
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
736
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
737
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
738
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
739
-        }
740
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
741
-        // targeted hook
742
-        do_action(
743
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
744
-        );
745
-    }
746
-
747
-
748
-    /**
749
-     * _set_defaults
750
-     * This sets some global defaults for class properties.
751
-     */
752
-    private function _set_defaults()
753
-    {
754
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
755
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
756
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
757
-        $this->_page_config          = $this->_default_route_query_args = [];
758
-        $this->_default_nav_tab_name = 'overview';
759
-        // init template args
760
-        $this->_template_args = [
761
-            'admin_page_header'  => '',
762
-            'admin_page_content' => '',
763
-            'post_body_content'  => '',
764
-            'before_list_table'  => '',
765
-            'after_list_table'   => '',
766
-        ];
767
-    }
768
-
769
-
770
-    /**
771
-     * route_admin_request
772
-     *
773
-     * @return void
774
-     * @throws InvalidArgumentException
775
-     * @throws InvalidInterfaceException
776
-     * @throws InvalidDataTypeException
777
-     * @throws EE_Error
778
-     * @throws ReflectionException
779
-     * @see    _route_admin_request()
780
-     */
781
-    public function route_admin_request()
782
-    {
783
-        try {
784
-            $this->_route_admin_request();
785
-        } catch (EE_Error $e) {
786
-            $e->get_error();
787
-        }
788
-    }
789
-
790
-
791
-    public function set_wp_page_slug($wp_page_slug)
792
-    {
793
-        $this->_wp_page_slug = $wp_page_slug;
794
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
795
-        if (is_network_admin()) {
796
-            $this->_wp_page_slug .= '-network';
797
-        }
798
-    }
799
-
800
-
801
-    /**
802
-     * _verify_routes
803
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
804
-     * we know if we need to drop out.
805
-     *
806
-     * @return bool
807
-     * @throws EE_Error
808
-     */
809
-    protected function _verify_routes()
810
-    {
811
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
812
-        if (! $this->_current_page && ! $this->request->isAjax()) {
813
-            return false;
814
-        }
815
-        $this->_route = false;
816
-        // check that the page_routes array is not empty
817
-        if (empty($this->_page_routes)) {
818
-            // user error msg
819
-            $error_msg = sprintf(
820
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
821
-                $this->_admin_page_title
822
-            );
823
-            // developer error msg
824
-            $error_msg .= '||' . $error_msg
825
-                          . esc_html__(
826
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
827
-                              'event_espresso'
828
-                          );
829
-            throw new EE_Error($error_msg);
830
-        }
831
-        // and that the requested page route exists
832
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
833
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
834
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
835
-                ? $this->_page_config[ $this->_req_action ]
836
-                : [];
837
-        } else {
838
-            // user error msg
839
-            $error_msg = sprintf(
840
-                esc_html__(
841
-                    'The requested page route does not exist for the %s admin page.',
842
-                    'event_espresso'
843
-                ),
844
-                $this->_admin_page_title
845
-            );
846
-            // developer error msg
847
-            $error_msg .= '||' . $error_msg
848
-                          . sprintf(
849
-                              esc_html__(
850
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
851
-                                  'event_espresso'
852
-                              ),
853
-                              $this->_req_action
854
-                          );
855
-            throw new EE_Error($error_msg);
856
-        }
857
-        // and that a default route exists
858
-        if (! array_key_exists('default', $this->_page_routes)) {
859
-            // user error msg
860
-            $error_msg = sprintf(
861
-                esc_html__(
862
-                    'A default page route has not been set for the % admin page.',
863
-                    'event_espresso'
864
-                ),
865
-                $this->_admin_page_title
866
-            );
867
-            // developer error msg
868
-            $error_msg .= '||' . $error_msg
869
-                          . esc_html__(
870
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
871
-                              'event_espresso'
872
-                          );
873
-            throw new EE_Error($error_msg);
874
-        }
875
-        // first lets' catch if the UI request has EVER been set.
876
-        if ($this->_is_UI_request === null) {
877
-            // lets set if this is a UI request or not.
878
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
879
-            // wait a minute... we might have a noheader in the route array
880
-            $this->_is_UI_request = ! (
881
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
882
-            )
883
-                ? $this->_is_UI_request
884
-                : false;
885
-        }
886
-        $this->_set_current_labels();
887
-        return true;
888
-    }
889
-
890
-
891
-    /**
892
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
893
-     *
894
-     * @param string $route the route name we're verifying
895
-     * @return bool we'll throw an exception if this isn't a valid route.
896
-     * @throws EE_Error
897
-     */
898
-    protected function _verify_route($route)
899
-    {
900
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
901
-            return true;
902
-        }
903
-        // user error msg
904
-        $error_msg = sprintf(
905
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
906
-            $this->_admin_page_title
907
-        );
908
-        // developer error msg
909
-        $error_msg .= '||' . $error_msg
910
-                      . sprintf(
911
-                          esc_html__(
912
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
913
-                              'event_espresso'
914
-                          ),
915
-                          $route
916
-                      );
917
-        throw new EE_Error($error_msg);
918
-    }
919
-
920
-
921
-    /**
922
-     * perform nonce verification
923
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
924
-     * using this method (and save retyping!)
925
-     *
926
-     * @param string $nonce     The nonce sent
927
-     * @param string $nonce_ref The nonce reference string (name0)
928
-     * @return void
929
-     * @throws EE_Error
930
-     */
931
-    protected function _verify_nonce($nonce, $nonce_ref)
932
-    {
933
-        // verify nonce against expected value
934
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
935
-            // these are not the droids you are looking for !!!
936
-            $msg = sprintf(
937
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
938
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
939
-                '</a>'
940
-            );
941
-            if (WP_DEBUG) {
942
-                $msg .= "\n  ";
943
-                $msg .= sprintf(
944
-                    esc_html__(
945
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
946
-                        'event_espresso'
947
-                    ),
948
-                    __CLASS__
949
-                );
950
-            }
951
-            if (! $this->request->isAjax()) {
952
-                wp_die($msg);
953
-            }
954
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
955
-            $this->_return_json();
956
-        }
957
-    }
958
-
959
-
960
-    /**
961
-     * _route_admin_request()
962
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
963
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
964
-     * in the page routes and then will try to load the corresponding method.
965
-     *
966
-     * @return void
967
-     * @throws EE_Error
968
-     * @throws InvalidArgumentException
969
-     * @throws InvalidDataTypeException
970
-     * @throws InvalidInterfaceException
971
-     * @throws ReflectionException
972
-     */
973
-    protected function _route_admin_request()
974
-    {
975
-        if (! $this->_is_UI_request) {
976
-            $this->_verify_routes();
977
-        }
978
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
979
-        if ($this->_req_action !== 'default' && $nonce_check) {
980
-            // set nonce from post data
981
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
982
-            $this->_verify_nonce($nonce, $this->_req_nonce);
983
-        }
984
-        // set the nav_tabs array but ONLY if this is  UI_request
985
-        if ($this->_is_UI_request) {
986
-            $this->_set_nav_tabs();
987
-        }
988
-        // grab callback function
989
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
990
-        // check if callback has args
991
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
992
-        $error_msg = '';
993
-        // action right before calling route
994
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
995
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
996
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
997
-        }
998
-        // right before calling the route, let's clean the _wp_http_referer
999
-        $this->request->setServerParam(
1000
-            'REQUEST_URI',
1001
-            remove_query_arg(
1002
-                '_wp_http_referer',
1003
-                wp_unslash($this->request->getServerParam('REQUEST_URI'))
1004
-            )
1005
-        );
1006
-        if (! empty($func)) {
1007
-            if (is_array($func)) {
1008
-                [$class, $method] = $func;
1009
-            } elseif (strpos($func, '::') !== false) {
1010
-                [$class, $method] = explode('::', $func);
1011
-            } else {
1012
-                $class  = $this;
1013
-                $method = $func;
1014
-            }
1015
-            if (! (is_object($class) && $class === $this)) {
1016
-                // send along this admin page object for access by addons.
1017
-                $args['admin_page_object'] = $this;
1018
-            }
1019
-            if (
1020
-                // is it a method on a class that doesn't work?
1021
-                (
1022
-                    (
1023
-                        method_exists($class, $method)
1024
-                        && call_user_func_array([$class, $method], $args) === false
1025
-                    )
1026
-                    && (
1027
-                        // is it a standalone function that doesn't work?
1028
-                        function_exists($method)
1029
-                        && call_user_func_array(
1030
-                            $func,
1031
-                            array_merge(['admin_page_object' => $this], $args)
1032
-                        ) === false
1033
-                    )
1034
-                )
1035
-                || (
1036
-                    // is it neither a class method NOR a standalone function?
1037
-                    ! method_exists($class, $method)
1038
-                    && ! function_exists($method)
1039
-                )
1040
-            ) {
1041
-                // user error msg
1042
-                $error_msg = esc_html__(
1043
-                    'An error occurred. The  requested page route could not be found.',
1044
-                    'event_espresso'
1045
-                );
1046
-                // developer error msg
1047
-                $error_msg .= '||';
1048
-                $error_msg .= sprintf(
1049
-                    esc_html__(
1050
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1051
-                        'event_espresso'
1052
-                    ),
1053
-                    $method
1054
-                );
1055
-            }
1056
-            if (! empty($error_msg)) {
1057
-                throw new EE_Error($error_msg);
1058
-            }
1059
-        }
1060
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1061
-        // then we need to reset the routing properties to the new route.
1062
-        // 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.
1063
-        if (
1064
-            $this->_is_UI_request === false
1065
-            && is_array($this->_route)
1066
-            && ! empty($this->_route['headers_sent_route'])
1067
-        ) {
1068
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1069
-        }
1070
-    }
1071
-
1072
-
1073
-    /**
1074
-     * This method just allows the resetting of page properties in the case where a no headers
1075
-     * route redirects to a headers route in its route config.
1076
-     *
1077
-     * @param string $new_route New (non header) route to redirect to.
1078
-     * @return   void
1079
-     * @throws ReflectionException
1080
-     * @throws InvalidArgumentException
1081
-     * @throws InvalidInterfaceException
1082
-     * @throws InvalidDataTypeException
1083
-     * @throws EE_Error
1084
-     * @since   4.3.0
1085
-     */
1086
-    protected function _reset_routing_properties($new_route)
1087
-    {
1088
-        $this->_is_UI_request = true;
1089
-        // now we set the current route to whatever the headers_sent_route is set at
1090
-        $this->request->setRequestParam('action', $new_route);
1091
-        // rerun page setup
1092
-        $this->_page_setup();
1093
-    }
1094
-
1095
-
1096
-    /**
1097
-     * _add_query_arg
1098
-     * adds nonce to array of arguments then calls WP add_query_arg function
1099
-     *(internally just uses EEH_URL's function with the same name)
1100
-     *
1101
-     * @param array  $args
1102
-     * @param string $url
1103
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1104
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1105
-     *                                        Example usage: If the current page is:
1106
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1107
-     *                                        &action=default&event_id=20&month_range=March%202015
1108
-     *                                        &_wpnonce=5467821
1109
-     *                                        and you call:
1110
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1111
-     *                                        array(
1112
-     *                                        'action' => 'resend_something',
1113
-     *                                        'page=>espresso_registrations'
1114
-     *                                        ),
1115
-     *                                        $some_url,
1116
-     *                                        true
1117
-     *                                        );
1118
-     *                                        It will produce a url in this structure:
1119
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1120
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1121
-     *                                        month_range]=March%202015
1122
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1123
-     * @return string
1124
-     */
1125
-    public static function add_query_args_and_nonce(
1126
-        $args = [],
1127
-        $url = false,
1128
-        $sticky = false,
1129
-        $exclude_nonce = false
1130
-    ) {
1131
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1132
-        if ($sticky) {
1133
-            /** @var RequestInterface $request */
1134
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1135
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1136
-            foreach ($request->requestParams() as $key => $value) {
1137
-                // do not add nonces
1138
-                if (strpos($key, 'nonce') !== false) {
1139
-                    continue;
1140
-                }
1141
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1142
-            }
1143
-        }
1144
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1145
-    }
1146
-
1147
-
1148
-    /**
1149
-     * This returns a generated link that will load the related help tab.
1150
-     *
1151
-     * @param string $help_tab_id the id for the connected help tab
1152
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1153
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1154
-     * @return string              generated link
1155
-     * @uses EEH_Template::get_help_tab_link()
1156
-     */
1157
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1158
-    {
1159
-        return EEH_Template::get_help_tab_link(
1160
-            $help_tab_id,
1161
-            $this->page_slug,
1162
-            $this->_req_action,
1163
-            $icon_style,
1164
-            $help_text
1165
-        );
1166
-    }
1167
-
1168
-
1169
-    /**
1170
-     * _add_help_tabs
1171
-     * Note child classes define their help tabs within the page_config array.
1172
-     *
1173
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1174
-     * @return void
1175
-     * @throws DomainException
1176
-     * @throws EE_Error
1177
-     */
1178
-    protected function _add_help_tabs()
1179
-    {
1180
-        if (isset($this->_page_config[ $this->_req_action ])) {
1181
-            $config = $this->_page_config[ $this->_req_action ];
1182
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1183
-            if (is_array($config) && isset($config['help_sidebar'])) {
1184
-                // check that the callback given is valid
1185
-                if (! method_exists($this, $config['help_sidebar'])) {
1186
-                    throw new EE_Error(
1187
-                        sprintf(
1188
-                            esc_html__(
1189
-                                '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',
1190
-                                'event_espresso'
1191
-                            ),
1192
-                            $config['help_sidebar'],
1193
-                            get_class($this)
1194
-                        )
1195
-                    );
1196
-                }
1197
-                $content = apply_filters(
1198
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1199
-                    $this->{$config['help_sidebar']}()
1200
-                );
1201
-                $this->_current_screen->set_help_sidebar($content);
1202
-            }
1203
-            if (! isset($config['help_tabs'])) {
1204
-                return;
1205
-            } //no help tabs for this route
1206
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1207
-                // we're here so there ARE help tabs!
1208
-                // make sure we've got what we need
1209
-                if (! isset($cfg['title'])) {
1210
-                    throw new EE_Error(
1211
-                        esc_html__(
1212
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1213
-                            'event_espresso'
1214
-                        )
1215
-                    );
1216
-                }
1217
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1218
-                    throw new EE_Error(
1219
-                        esc_html__(
1220
-                            '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',
1221
-                            'event_espresso'
1222
-                        )
1223
-                    );
1224
-                }
1225
-                // first priority goes to content.
1226
-                if (! empty($cfg['content'])) {
1227
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1228
-                    // second priority goes to filename
1229
-                } elseif (! empty($cfg['filename'])) {
1230
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1231
-                    // 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)
1232
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1233
-                                                             . basename($this->_get_dir())
1234
-                                                             . '/help_tabs/'
1235
-                                                             . $cfg['filename']
1236
-                                                             . '.help_tab.php' : $file_path;
1237
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1238
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1239
-                        EE_Error::add_error(
1240
-                            sprintf(
1241
-                                esc_html__(
1242
-                                    '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',
1243
-                                    'event_espresso'
1244
-                                ),
1245
-                                $tab_id,
1246
-                                key($config),
1247
-                                $file_path
1248
-                            ),
1249
-                            __FILE__,
1250
-                            __FUNCTION__,
1251
-                            __LINE__
1252
-                        );
1253
-                        return;
1254
-                    }
1255
-                    $template_args['admin_page_obj'] = $this;
1256
-                    $content                         = EEH_Template::display_template(
1257
-                        $file_path,
1258
-                        $template_args,
1259
-                        true
1260
-                    );
1261
-                } else {
1262
-                    $content = '';
1263
-                }
1264
-                // check if callback is valid
1265
-                if (
1266
-                    empty($content)
1267
-                    && (
1268
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1269
-                    )
1270
-                ) {
1271
-                    EE_Error::add_error(
1272
-                        sprintf(
1273
-                            esc_html__(
1274
-                                '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.',
1275
-                                'event_espresso'
1276
-                            ),
1277
-                            $cfg['title']
1278
-                        ),
1279
-                        __FILE__,
1280
-                        __FUNCTION__,
1281
-                        __LINE__
1282
-                    );
1283
-                    return;
1284
-                }
1285
-                // setup config array for help tab method
1286
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1287
-                $_ht = [
1288
-                    'id'       => $id,
1289
-                    'title'    => $cfg['title'],
1290
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1291
-                    'content'  => $content,
1292
-                ];
1293
-                $this->_current_screen->add_help_tab($_ht);
1294
-            }
1295
-        }
1296
-    }
1297
-
1298
-
1299
-    /**
1300
-     * This simply sets up any qtips that have been defined in the page config
1301
-     *
1302
-     * @return void
1303
-     */
1304
-    protected function _add_qtips()
1305
-    {
1306
-        if (isset($this->_route_config['qtips'])) {
1307
-            $qtips = (array) $this->_route_config['qtips'];
1308
-            // load qtip loader
1309
-            $path = [
1310
-                $this->_get_dir() . '/qtips/',
1311
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1312
-            ];
1313
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1314
-        }
1315
-    }
1316
-
1317
-
1318
-    /**
1319
-     * _set_nav_tabs
1320
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1321
-     * wish to add additional tabs or modify accordingly.
1322
-     *
1323
-     * @return void
1324
-     * @throws InvalidArgumentException
1325
-     * @throws InvalidInterfaceException
1326
-     * @throws InvalidDataTypeException
1327
-     */
1328
-    protected function _set_nav_tabs()
1329
-    {
1330
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1331
-        $i = 0;
1332
-        foreach ($this->_page_config as $slug => $config) {
1333
-            if (! is_array($config) || empty($config['nav'])) {
1334
-                continue;
1335
-            }
1336
-            // no nav tab for this config
1337
-            // check for persistent flag
1338
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1339
-                // nav tab is only to appear when route requested.
1340
-                continue;
1341
-            }
1342
-            if (! $this->check_user_access($slug, true)) {
1343
-                // no nav tab because current user does not have access.
1344
-                continue;
1345
-            }
1346
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1347
-            $this->_nav_tabs[ $slug ] = [
1348
-                'url'       => isset($config['nav']['url'])
1349
-                    ? $config['nav']['url']
1350
-                    : self::add_query_args_and_nonce(
1351
-                        ['action' => $slug],
1352
-                        $this->_admin_base_url
1353
-                    ),
1354
-                'link_text' => isset($config['nav']['label'])
1355
-                    ? $config['nav']['label']
1356
-                    : ucwords(
1357
-                        str_replace('_', ' ', $slug)
1358
-                    ),
1359
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1360
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1361
-            ];
1362
-            $i++;
1363
-        }
1364
-        // if $this->_nav_tabs is empty then lets set the default
1365
-        if (empty($this->_nav_tabs)) {
1366
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1367
-                'url'       => $this->_admin_base_url,
1368
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1369
-                'css_class' => 'nav-tab-active',
1370
-                'order'     => 10,
1371
-            ];
1372
-        }
1373
-        // now let's sort the tabs according to order
1374
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1375
-    }
1376
-
1377
-
1378
-    /**
1379
-     * _set_current_labels
1380
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1381
-     * property array
1382
-     *
1383
-     * @return void
1384
-     */
1385
-    private function _set_current_labels()
1386
-    {
1387
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1388
-            foreach ($this->_route_config['labels'] as $label => $text) {
1389
-                if (is_array($text)) {
1390
-                    foreach ($text as $sublabel => $subtext) {
1391
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1392
-                    }
1393
-                } else {
1394
-                    $this->_labels[ $label ] = $text;
1395
-                }
1396
-            }
1397
-        }
1398
-    }
1399
-
1400
-
1401
-    /**
1402
-     *        verifies user access for this admin page
1403
-     *
1404
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1405
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1406
-     *                               return false if verify fail.
1407
-     * @return bool
1408
-     * @throws InvalidArgumentException
1409
-     * @throws InvalidDataTypeException
1410
-     * @throws InvalidInterfaceException
1411
-     */
1412
-    public function check_user_access($route_to_check = '', $verify_only = false)
1413
-    {
1414
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1415
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1416
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1417
-                          && is_array(
1418
-                              $this->_page_routes[ $route_to_check ]
1419
-                          )
1420
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1421
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1422
-        if (empty($capability) && empty($route_to_check)) {
1423
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1424
-                : $this->_route['capability'];
1425
-        } else {
1426
-            $capability = empty($capability) ? 'manage_options' : $capability;
1427
-        }
1428
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1429
-        if (
1430
-            ! $this->request->isAjax()
1431
-            && (
1432
-                ! function_exists('is_admin')
1433
-                || ! EE_Registry::instance()->CAP->current_user_can(
1434
-                    $capability,
1435
-                    $this->page_slug
1436
-                    . '_'
1437
-                    . $route_to_check,
1438
-                    $id
1439
-                )
1440
-            )
1441
-        ) {
1442
-            if ($verify_only) {
1443
-                return false;
1444
-            }
1445
-            if (is_user_logged_in()) {
1446
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1447
-            } else {
1448
-                return false;
1449
-            }
1450
-        }
1451
-        return true;
1452
-    }
1453
-
1454
-
1455
-    /**
1456
-     * admin_init_global
1457
-     * This runs all the code that we want executed within the WP admin_init hook.
1458
-     * This method executes for ALL EE Admin pages.
1459
-     *
1460
-     * @return void
1461
-     */
1462
-    public function admin_init_global()
1463
-    {
1464
-    }
1465
-
1466
-
1467
-    /**
1468
-     * wp_loaded_global
1469
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1470
-     * EE_Admin page and will execute on every EE Admin Page load
1471
-     *
1472
-     * @return void
1473
-     */
1474
-    public function wp_loaded()
1475
-    {
1476
-    }
1477
-
1478
-
1479
-    /**
1480
-     * admin_notices
1481
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1482
-     * ALL EE_Admin pages.
1483
-     *
1484
-     * @return void
1485
-     */
1486
-    public function admin_notices_global()
1487
-    {
1488
-        $this->_display_no_javascript_warning();
1489
-        $this->_display_espresso_notices();
1490
-    }
1491
-
1492
-
1493
-    public function network_admin_notices_global()
1494
-    {
1495
-        $this->_display_no_javascript_warning();
1496
-        $this->_display_espresso_notices();
1497
-    }
1498
-
1499
-
1500
-    /**
1501
-     * admin_footer_scripts_global
1502
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1503
-     * will apply on ALL EE_Admin pages.
1504
-     *
1505
-     * @return void
1506
-     */
1507
-    public function admin_footer_scripts_global()
1508
-    {
1509
-        $this->_add_admin_page_ajax_loading_img();
1510
-        $this->_add_admin_page_overlay();
1511
-        // if metaboxes are present we need to add the nonce field
1512
-        if (
1513
-            isset($this->_route_config['metaboxes'])
1514
-            || isset($this->_route_config['list_table'])
1515
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1516
-        ) {
1517
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1518
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1519
-        }
1520
-    }
1521
-
1522
-
1523
-    /**
1524
-     * admin_footer_global
1525
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1526
-     * ALL EE_Admin Pages.
1527
-     *
1528
-     * @return void
1529
-     */
1530
-    public function admin_footer_global()
1531
-    {
1532
-        // dialog container for dialog helper
1533
-        echo '
111
+	/**
112
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
113
+	 * actions.
114
+	 *
115
+	 * @since 4.6.x
116
+	 * @var array.
117
+	 */
118
+	protected $_default_route_query_args;
119
+
120
+	// set via request page and action args.
121
+	protected $_current_page;
122
+
123
+	protected $_current_view;
124
+
125
+	protected $_current_page_view_url;
126
+
127
+	/**
128
+	 * unprocessed value for the 'action' request param (default '')
129
+	 *
130
+	 * @var string
131
+	 */
132
+	protected $raw_req_action = '';
133
+
134
+	/**
135
+	 * unprocessed value for the 'page' request param (default '')
136
+	 *
137
+	 * @var string
138
+	 */
139
+	protected $raw_req_page = '';
140
+
141
+	/**
142
+	 * sanitized request action (and nonce)
143
+	 *
144
+	 * @var string
145
+	 */
146
+	protected $_req_action = '';
147
+
148
+	/**
149
+	 * sanitized request action nonce
150
+	 *
151
+	 * @var string
152
+	 */
153
+	protected $_req_nonce = '';
154
+
155
+	/**
156
+	 * @var string
157
+	 */
158
+	protected $_search_btn_label = '';
159
+
160
+	/**
161
+	 * @var string
162
+	 */
163
+	protected $_search_box_callback = '';
164
+
165
+	/**
166
+	 * @var WP_Screen
167
+	 */
168
+	protected $_current_screen;
169
+
170
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
171
+	protected $_hook_obj;
172
+
173
+	// for holding incoming request data
174
+	protected $_req_data = [];
175
+
176
+	// yes / no array for admin form fields
177
+	protected $_yes_no_values = [];
178
+
179
+	// some default things shared by all child classes
180
+	protected $_default_espresso_metaboxes;
181
+
182
+	/**
183
+	 * @var EE_Registry
184
+	 */
185
+	protected $EE = null;
186
+
187
+
188
+	/**
189
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
190
+	 *
191
+	 * @var boolean
192
+	 */
193
+	protected $_is_caf = false;
194
+
195
+
196
+	/**
197
+	 * @Constructor
198
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
199
+	 * @throws EE_Error
200
+	 * @throws InvalidArgumentException
201
+	 * @throws ReflectionException
202
+	 * @throws InvalidDataTypeException
203
+	 * @throws InvalidInterfaceException
204
+	 */
205
+	public function __construct($routing = true)
206
+	{
207
+		$this->loader  = LoaderFactory::getLoader();
208
+		$this->request = $this->loader->getShared(RequestInterface::class);
209
+		$this->_routing = $routing;
210
+
211
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
212
+			$this->_is_caf = true;
213
+		}
214
+		$this->_yes_no_values = [
215
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
216
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
217
+		];
218
+		// set the _req_data property.
219
+		$this->_req_data = $this->request->requestParams();
220
+		// set initial page props (child method)
221
+		$this->_init_page_props();
222
+		// set global defaults
223
+		$this->_set_defaults();
224
+		// set early because incoming requests could be ajax related and we need to register those hooks.
225
+		$this->_global_ajax_hooks();
226
+		$this->_ajax_hooks();
227
+		// other_page_hooks have to be early too.
228
+		$this->_do_other_page_hooks();
229
+		// set up page dependencies
230
+		$this->_before_page_setup();
231
+		$this->_page_setup();
232
+		// die();
233
+	}
234
+
235
+
236
+	/**
237
+	 * _init_page_props
238
+	 * Child classes use to set at least the following properties:
239
+	 * $page_slug.
240
+	 * $page_label.
241
+	 *
242
+	 * @abstract
243
+	 * @return void
244
+	 */
245
+	abstract protected function _init_page_props();
246
+
247
+
248
+	/**
249
+	 * _ajax_hooks
250
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
251
+	 * Note: within the ajax callback methods.
252
+	 *
253
+	 * @abstract
254
+	 * @return void
255
+	 */
256
+	abstract protected function _ajax_hooks();
257
+
258
+
259
+	/**
260
+	 * _define_page_props
261
+	 * child classes define page properties in here.  Must include at least:
262
+	 * $_admin_base_url = base_url for all admin pages
263
+	 * $_admin_page_title = default admin_page_title for admin pages
264
+	 * $_labels = array of default labels for various automatically generated elements:
265
+	 *    array(
266
+	 *        'buttons' => array(
267
+	 *            'add' => esc_html__('label for add new button'),
268
+	 *            'edit' => esc_html__('label for edit button'),
269
+	 *            'delete' => esc_html__('label for delete button')
270
+	 *            )
271
+	 *        )
272
+	 *
273
+	 * @abstract
274
+	 * @return void
275
+	 */
276
+	abstract protected function _define_page_props();
277
+
278
+
279
+	/**
280
+	 * _set_page_routes
281
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
282
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
283
+	 * have a 'default' route. Here's the format
284
+	 * $this->_page_routes = array(
285
+	 *        'default' => array(
286
+	 *            'func' => '_default_method_handling_route',
287
+	 *            'args' => array('array','of','args'),
288
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
289
+	 *            ajax request, backend processing)
290
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
291
+	 *            headers route after.  The string you enter here should match the defined route reference for a
292
+	 *            headers sent route.
293
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
294
+	 *            this route.
295
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
296
+	 *            checks).
297
+	 *        ),
298
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
299
+	 *        handling method.
300
+	 *        )
301
+	 * )
302
+	 *
303
+	 * @abstract
304
+	 * @return void
305
+	 */
306
+	abstract protected function _set_page_routes();
307
+
308
+
309
+	/**
310
+	 * _set_page_config
311
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
312
+	 * array corresponds to the page_route for the loaded page. Format:
313
+	 * $this->_page_config = array(
314
+	 *        'default' => array(
315
+	 *            'labels' => array(
316
+	 *                'buttons' => array(
317
+	 *                    'add' => esc_html__('label for adding item'),
318
+	 *                    'edit' => esc_html__('label for editing item'),
319
+	 *                    'delete' => esc_html__('label for deleting item')
320
+	 *                ),
321
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
322
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
323
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
324
+	 *            _define_page_props() method
325
+	 *            'nav' => array(
326
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
327
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
328
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
329
+	 *                'order' => 10, //required to indicate tab position.
330
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
331
+	 *                displayed then add this parameter.
332
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
333
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
334
+	 *            metaboxes set for eventespresso admin pages.
335
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
336
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
337
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
338
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
339
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
340
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
341
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
342
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
343
+	 *            want to display.
344
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
345
+	 *                'tab_id' => array(
346
+	 *                    'title' => 'tab_title',
347
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
348
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
349
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
350
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
351
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
352
+	 *                    attempt to use the callback which should match the name of a method in the class
353
+	 *                    ),
354
+	 *                'tab2_id' => array(
355
+	 *                    'title' => 'tab2 title',
356
+	 *                    'filename' => 'file_name_2'
357
+	 *                    'callback' => 'callback_method_for_content',
358
+	 *                 ),
359
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
360
+	 *            help tab area on an admin page. @return void
361
+	 *
362
+	 * @abstract
363
+	 */
364
+	abstract protected function _set_page_config();
365
+
366
+
367
+	/**
368
+	 * _add_screen_options
369
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
370
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
371
+	 * to a particular view.
372
+	 *
373
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
374
+	 *         see also WP_Screen object documents...
375
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
376
+	 * @abstract
377
+	 * @return void
378
+	 */
379
+	abstract protected function _add_screen_options();
380
+
381
+
382
+	/**
383
+	 * _add_feature_pointers
384
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
385
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
386
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
387
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
388
+	 * extended) also see:
389
+	 *
390
+	 * @link   http://eamann.com/tech/wordpress-portland/
391
+	 * @abstract
392
+	 * @return void
393
+	 */
394
+	abstract protected function _add_feature_pointers();
395
+
396
+
397
+	/**
398
+	 * load_scripts_styles
399
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
400
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
401
+	 * scripts/styles per view by putting them in a dynamic function in this format
402
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
403
+	 *
404
+	 * @abstract
405
+	 * @return void
406
+	 */
407
+	abstract public function load_scripts_styles();
408
+
409
+
410
+	/**
411
+	 * admin_init
412
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
413
+	 * all pages/views loaded by child class.
414
+	 *
415
+	 * @abstract
416
+	 * @return void
417
+	 */
418
+	abstract public function admin_init();
419
+
420
+
421
+	/**
422
+	 * admin_notices
423
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
424
+	 * all pages/views loaded by child class.
425
+	 *
426
+	 * @abstract
427
+	 * @return void
428
+	 */
429
+	abstract public function admin_notices();
430
+
431
+
432
+	/**
433
+	 * admin_footer_scripts
434
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
435
+	 * will apply to all pages/views loaded by child class.
436
+	 *
437
+	 * @return void
438
+	 */
439
+	abstract public function admin_footer_scripts();
440
+
441
+
442
+	/**
443
+	 * admin_footer
444
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
445
+	 * apply to all pages/views loaded by child class.
446
+	 *
447
+	 * @return void
448
+	 */
449
+	public function admin_footer()
450
+	{
451
+	}
452
+
453
+
454
+	/**
455
+	 * _global_ajax_hooks
456
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
457
+	 * Note: within the ajax callback methods.
458
+	 *
459
+	 * @abstract
460
+	 * @return void
461
+	 */
462
+	protected function _global_ajax_hooks()
463
+	{
464
+		// for lazy loading of metabox content
465
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
466
+	}
467
+
468
+
469
+	public function ajax_metabox_content()
470
+	{
471
+		$content_id  = $this->request->getRequestParam('contentid', '');
472
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
473
+		self::cached_rss_display($content_id, $content_url);
474
+		wp_die();
475
+	}
476
+
477
+
478
+	/**
479
+	 * allows extending classes do something specific before the parent constructor runs _page_setup().
480
+	 *
481
+	 * @return void
482
+	 */
483
+	protected function _before_page_setup()
484
+	{
485
+		// default is to do nothing
486
+	}
487
+
488
+
489
+	/**
490
+	 * Makes sure any things that need to be loaded early get handled.
491
+	 * We also escape early here if the page requested doesn't match the object.
492
+	 *
493
+	 * @final
494
+	 * @return void
495
+	 * @throws EE_Error
496
+	 * @throws InvalidArgumentException
497
+	 * @throws ReflectionException
498
+	 * @throws InvalidDataTypeException
499
+	 * @throws InvalidInterfaceException
500
+	 */
501
+	final protected function _page_setup()
502
+	{
503
+		// requires?
504
+		// admin_init stuff - global - we're setting this REALLY early
505
+		// so if EE_Admin pages have to hook into other WP pages they can.
506
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
507
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
508
+		// next verify if we need to load anything...
509
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
510
+		$this->page_folder   = strtolower(
511
+			str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
512
+		);
513
+		global $ee_menu_slugs;
514
+		$ee_menu_slugs = (array) $ee_menu_slugs;
515
+		if (
516
+			! $this->request->isAjax()
517
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
518
+		) {
519
+			return;
520
+		}
521
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
522
+		// we need to copy the action from the second to the first
523
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
524
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
525
+		$action     = $action !== '-1' ? $action : $action2;
526
+		$req_action = $action !== '-1' ? $action : 'default';
527
+
528
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
529
+		// then let's use the route as the action.
530
+		// This covers cases where we're coming in from a list table that isn't on the default route.
531
+		$route = $this->request->getRequestParam('route');
532
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
533
+			? $route
534
+			: $req_action;
535
+
536
+		$this->_current_view = $this->_req_action;
537
+		$this->_req_nonce    = $this->_req_action . '_nonce';
538
+		$this->_define_page_props();
539
+		$this->_current_page_view_url = add_query_arg(
540
+			['page' => $this->_current_page, 'action' => $this->_current_view],
541
+			$this->_admin_base_url
542
+		);
543
+		// default things
544
+		$this->_default_espresso_metaboxes = [
545
+			'_espresso_news_post_box',
546
+			'_espresso_links_post_box',
547
+			'_espresso_ratings_request',
548
+			'_espresso_sponsors_post_box',
549
+		];
550
+		// set page configs
551
+		$this->_set_page_routes();
552
+		$this->_set_page_config();
553
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
554
+		if ($this->request->requestParamIsSet('wp_referer')) {
555
+			$wp_referer = $this->request->getRequestParam('wp_referer');
556
+			if ($wp_referer) {
557
+				$this->_default_route_query_args['wp_referer'] = $wp_referer;
558
+			}
559
+		}
560
+		// for caffeinated and other extended functionality.
561
+		//  If there is a _extend_page_config method
562
+		// then let's run that to modify the all the various page configuration arrays
563
+		if (method_exists($this, '_extend_page_config')) {
564
+			$this->_extend_page_config();
565
+		}
566
+		// for CPT and other extended functionality.
567
+		// If there is an _extend_page_config_for_cpt
568
+		// then let's run that to modify all the various page configuration arrays.
569
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
570
+			$this->_extend_page_config_for_cpt();
571
+		}
572
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
573
+		$this->_page_routes = apply_filters(
574
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
575
+			$this->_page_routes,
576
+			$this
577
+		);
578
+		$this->_page_config = apply_filters(
579
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
580
+			$this->_page_config,
581
+			$this
582
+		);
583
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
584
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
585
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
586
+			add_action(
587
+				'AHEE__EE_Admin_Page__route_admin_request',
588
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
589
+				10,
590
+				2
591
+			);
592
+		}
593
+		// next route only if routing enabled
594
+		if ($this->_routing && ! $this->request->isAjax()) {
595
+			$this->_verify_routes();
596
+			// next let's just check user_access and kill if no access
597
+			$this->check_user_access();
598
+			if ($this->_is_UI_request) {
599
+				// admin_init stuff - global, all views for this page class, specific view
600
+				add_action('admin_init', [$this, 'admin_init'], 10);
601
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
602
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
603
+				}
604
+			} else {
605
+				// hijack regular WP loading and route admin request immediately
606
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
607
+				$this->route_admin_request();
608
+			}
609
+		}
610
+	}
611
+
612
+
613
+	/**
614
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
615
+	 *
616
+	 * @return void
617
+	 * @throws EE_Error
618
+	 */
619
+	private function _do_other_page_hooks()
620
+	{
621
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
622
+		foreach ($registered_pages as $page) {
623
+			// now let's setup the file name and class that should be present
624
+			$classname = str_replace('.class.php', '', $page);
625
+			// autoloaders should take care of loading file
626
+			if (! class_exists($classname)) {
627
+				$error_msg[] = sprintf(
628
+					esc_html__(
629
+						'Something went wrong with loading the %s admin hooks page.',
630
+						'event_espresso'
631
+					),
632
+					$page
633
+				);
634
+				$error_msg[] = $error_msg[0]
635
+							   . "\r\n"
636
+							   . sprintf(
637
+								   esc_html__(
638
+									   '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',
639
+									   'event_espresso'
640
+								   ),
641
+								   $page,
642
+								   '<br />',
643
+								   '<strong>' . $classname . '</strong>'
644
+							   );
645
+				throw new EE_Error(implode('||', $error_msg));
646
+			}
647
+			// notice we are passing the instance of this class to the hook object.
648
+			$this->loader->getShared($classname, [$this]);
649
+		}
650
+	}
651
+
652
+
653
+	/**
654
+	 * @throws ReflectionException
655
+	 * @throws EE_Error
656
+	 */
657
+	public function load_page_dependencies()
658
+	{
659
+		try {
660
+			$this->_load_page_dependencies();
661
+		} catch (EE_Error $e) {
662
+			$e->get_error();
663
+		}
664
+	}
665
+
666
+
667
+	/**
668
+	 * load_page_dependencies
669
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
670
+	 *
671
+	 * @return void
672
+	 * @throws DomainException
673
+	 * @throws EE_Error
674
+	 * @throws InvalidArgumentException
675
+	 * @throws InvalidDataTypeException
676
+	 * @throws InvalidInterfaceException
677
+	 */
678
+	protected function _load_page_dependencies()
679
+	{
680
+		// let's set the current_screen and screen options to override what WP set
681
+		$this->_current_screen = get_current_screen();
682
+		// load admin_notices - global, page class, and view specific
683
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
684
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
685
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
686
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
687
+		}
688
+		// load network admin_notices - global, page class, and view specific
689
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
690
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
691
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
692
+		}
693
+		// this will save any per_page screen options if they are present
694
+		$this->_set_per_page_screen_options();
695
+		// setup list table properties
696
+		$this->_set_list_table();
697
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
698
+		// However in some cases the metaboxes will need to be added within a route handling callback.
699
+		$this->_add_registered_meta_boxes();
700
+		$this->_add_screen_columns();
701
+		// add screen options - global, page child class, and view specific
702
+		$this->_add_global_screen_options();
703
+		$this->_add_screen_options();
704
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
705
+		if (method_exists($this, $add_screen_options)) {
706
+			$this->{$add_screen_options}();
707
+		}
708
+		// add help tab(s) - set via page_config and qtips.
709
+		$this->_add_help_tabs();
710
+		$this->_add_qtips();
711
+		// add feature_pointers - global, page child class, and view specific
712
+		$this->_add_feature_pointers();
713
+		$this->_add_global_feature_pointers();
714
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
715
+		if (method_exists($this, $add_feature_pointer)) {
716
+			$this->{$add_feature_pointer}();
717
+		}
718
+		// enqueue scripts/styles - global, page class, and view specific
719
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
720
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
721
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
722
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
723
+		}
724
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
725
+		// admin_print_footer_scripts - global, page child class, and view specific.
726
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
727
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
728
+		// is a good use case. Notice the late priority we're giving these
729
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
730
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
731
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
732
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
733
+		}
734
+		// admin footer scripts
735
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
736
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
737
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
738
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
739
+		}
740
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
741
+		// targeted hook
742
+		do_action(
743
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
744
+		);
745
+	}
746
+
747
+
748
+	/**
749
+	 * _set_defaults
750
+	 * This sets some global defaults for class properties.
751
+	 */
752
+	private function _set_defaults()
753
+	{
754
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
755
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
756
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
757
+		$this->_page_config          = $this->_default_route_query_args = [];
758
+		$this->_default_nav_tab_name = 'overview';
759
+		// init template args
760
+		$this->_template_args = [
761
+			'admin_page_header'  => '',
762
+			'admin_page_content' => '',
763
+			'post_body_content'  => '',
764
+			'before_list_table'  => '',
765
+			'after_list_table'   => '',
766
+		];
767
+	}
768
+
769
+
770
+	/**
771
+	 * route_admin_request
772
+	 *
773
+	 * @return void
774
+	 * @throws InvalidArgumentException
775
+	 * @throws InvalidInterfaceException
776
+	 * @throws InvalidDataTypeException
777
+	 * @throws EE_Error
778
+	 * @throws ReflectionException
779
+	 * @see    _route_admin_request()
780
+	 */
781
+	public function route_admin_request()
782
+	{
783
+		try {
784
+			$this->_route_admin_request();
785
+		} catch (EE_Error $e) {
786
+			$e->get_error();
787
+		}
788
+	}
789
+
790
+
791
+	public function set_wp_page_slug($wp_page_slug)
792
+	{
793
+		$this->_wp_page_slug = $wp_page_slug;
794
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
795
+		if (is_network_admin()) {
796
+			$this->_wp_page_slug .= '-network';
797
+		}
798
+	}
799
+
800
+
801
+	/**
802
+	 * _verify_routes
803
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
804
+	 * we know if we need to drop out.
805
+	 *
806
+	 * @return bool
807
+	 * @throws EE_Error
808
+	 */
809
+	protected function _verify_routes()
810
+	{
811
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
812
+		if (! $this->_current_page && ! $this->request->isAjax()) {
813
+			return false;
814
+		}
815
+		$this->_route = false;
816
+		// check that the page_routes array is not empty
817
+		if (empty($this->_page_routes)) {
818
+			// user error msg
819
+			$error_msg = sprintf(
820
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
821
+				$this->_admin_page_title
822
+			);
823
+			// developer error msg
824
+			$error_msg .= '||' . $error_msg
825
+						  . esc_html__(
826
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
827
+							  'event_espresso'
828
+						  );
829
+			throw new EE_Error($error_msg);
830
+		}
831
+		// and that the requested page route exists
832
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
833
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
834
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
835
+				? $this->_page_config[ $this->_req_action ]
836
+				: [];
837
+		} else {
838
+			// user error msg
839
+			$error_msg = sprintf(
840
+				esc_html__(
841
+					'The requested page route does not exist for the %s admin page.',
842
+					'event_espresso'
843
+				),
844
+				$this->_admin_page_title
845
+			);
846
+			// developer error msg
847
+			$error_msg .= '||' . $error_msg
848
+						  . sprintf(
849
+							  esc_html__(
850
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
851
+								  'event_espresso'
852
+							  ),
853
+							  $this->_req_action
854
+						  );
855
+			throw new EE_Error($error_msg);
856
+		}
857
+		// and that a default route exists
858
+		if (! array_key_exists('default', $this->_page_routes)) {
859
+			// user error msg
860
+			$error_msg = sprintf(
861
+				esc_html__(
862
+					'A default page route has not been set for the % admin page.',
863
+					'event_espresso'
864
+				),
865
+				$this->_admin_page_title
866
+			);
867
+			// developer error msg
868
+			$error_msg .= '||' . $error_msg
869
+						  . esc_html__(
870
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
871
+							  'event_espresso'
872
+						  );
873
+			throw new EE_Error($error_msg);
874
+		}
875
+		// first lets' catch if the UI request has EVER been set.
876
+		if ($this->_is_UI_request === null) {
877
+			// lets set if this is a UI request or not.
878
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
879
+			// wait a minute... we might have a noheader in the route array
880
+			$this->_is_UI_request = ! (
881
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
882
+			)
883
+				? $this->_is_UI_request
884
+				: false;
885
+		}
886
+		$this->_set_current_labels();
887
+		return true;
888
+	}
889
+
890
+
891
+	/**
892
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
893
+	 *
894
+	 * @param string $route the route name we're verifying
895
+	 * @return bool we'll throw an exception if this isn't a valid route.
896
+	 * @throws EE_Error
897
+	 */
898
+	protected function _verify_route($route)
899
+	{
900
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
901
+			return true;
902
+		}
903
+		// user error msg
904
+		$error_msg = sprintf(
905
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
906
+			$this->_admin_page_title
907
+		);
908
+		// developer error msg
909
+		$error_msg .= '||' . $error_msg
910
+					  . sprintf(
911
+						  esc_html__(
912
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
913
+							  'event_espresso'
914
+						  ),
915
+						  $route
916
+					  );
917
+		throw new EE_Error($error_msg);
918
+	}
919
+
920
+
921
+	/**
922
+	 * perform nonce verification
923
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
924
+	 * using this method (and save retyping!)
925
+	 *
926
+	 * @param string $nonce     The nonce sent
927
+	 * @param string $nonce_ref The nonce reference string (name0)
928
+	 * @return void
929
+	 * @throws EE_Error
930
+	 */
931
+	protected function _verify_nonce($nonce, $nonce_ref)
932
+	{
933
+		// verify nonce against expected value
934
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
935
+			// these are not the droids you are looking for !!!
936
+			$msg = sprintf(
937
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
938
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
939
+				'</a>'
940
+			);
941
+			if (WP_DEBUG) {
942
+				$msg .= "\n  ";
943
+				$msg .= sprintf(
944
+					esc_html__(
945
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
946
+						'event_espresso'
947
+					),
948
+					__CLASS__
949
+				);
950
+			}
951
+			if (! $this->request->isAjax()) {
952
+				wp_die($msg);
953
+			}
954
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
955
+			$this->_return_json();
956
+		}
957
+	}
958
+
959
+
960
+	/**
961
+	 * _route_admin_request()
962
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
963
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
964
+	 * in the page routes and then will try to load the corresponding method.
965
+	 *
966
+	 * @return void
967
+	 * @throws EE_Error
968
+	 * @throws InvalidArgumentException
969
+	 * @throws InvalidDataTypeException
970
+	 * @throws InvalidInterfaceException
971
+	 * @throws ReflectionException
972
+	 */
973
+	protected function _route_admin_request()
974
+	{
975
+		if (! $this->_is_UI_request) {
976
+			$this->_verify_routes();
977
+		}
978
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
979
+		if ($this->_req_action !== 'default' && $nonce_check) {
980
+			// set nonce from post data
981
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
982
+			$this->_verify_nonce($nonce, $this->_req_nonce);
983
+		}
984
+		// set the nav_tabs array but ONLY if this is  UI_request
985
+		if ($this->_is_UI_request) {
986
+			$this->_set_nav_tabs();
987
+		}
988
+		// grab callback function
989
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
990
+		// check if callback has args
991
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
992
+		$error_msg = '';
993
+		// action right before calling route
994
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
995
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
996
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
997
+		}
998
+		// right before calling the route, let's clean the _wp_http_referer
999
+		$this->request->setServerParam(
1000
+			'REQUEST_URI',
1001
+			remove_query_arg(
1002
+				'_wp_http_referer',
1003
+				wp_unslash($this->request->getServerParam('REQUEST_URI'))
1004
+			)
1005
+		);
1006
+		if (! empty($func)) {
1007
+			if (is_array($func)) {
1008
+				[$class, $method] = $func;
1009
+			} elseif (strpos($func, '::') !== false) {
1010
+				[$class, $method] = explode('::', $func);
1011
+			} else {
1012
+				$class  = $this;
1013
+				$method = $func;
1014
+			}
1015
+			if (! (is_object($class) && $class === $this)) {
1016
+				// send along this admin page object for access by addons.
1017
+				$args['admin_page_object'] = $this;
1018
+			}
1019
+			if (
1020
+				// is it a method on a class that doesn't work?
1021
+				(
1022
+					(
1023
+						method_exists($class, $method)
1024
+						&& call_user_func_array([$class, $method], $args) === false
1025
+					)
1026
+					&& (
1027
+						// is it a standalone function that doesn't work?
1028
+						function_exists($method)
1029
+						&& call_user_func_array(
1030
+							$func,
1031
+							array_merge(['admin_page_object' => $this], $args)
1032
+						) === false
1033
+					)
1034
+				)
1035
+				|| (
1036
+					// is it neither a class method NOR a standalone function?
1037
+					! method_exists($class, $method)
1038
+					&& ! function_exists($method)
1039
+				)
1040
+			) {
1041
+				// user error msg
1042
+				$error_msg = esc_html__(
1043
+					'An error occurred. The  requested page route could not be found.',
1044
+					'event_espresso'
1045
+				);
1046
+				// developer error msg
1047
+				$error_msg .= '||';
1048
+				$error_msg .= sprintf(
1049
+					esc_html__(
1050
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1051
+						'event_espresso'
1052
+					),
1053
+					$method
1054
+				);
1055
+			}
1056
+			if (! empty($error_msg)) {
1057
+				throw new EE_Error($error_msg);
1058
+			}
1059
+		}
1060
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1061
+		// then we need to reset the routing properties to the new route.
1062
+		// 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.
1063
+		if (
1064
+			$this->_is_UI_request === false
1065
+			&& is_array($this->_route)
1066
+			&& ! empty($this->_route['headers_sent_route'])
1067
+		) {
1068
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1069
+		}
1070
+	}
1071
+
1072
+
1073
+	/**
1074
+	 * This method just allows the resetting of page properties in the case where a no headers
1075
+	 * route redirects to a headers route in its route config.
1076
+	 *
1077
+	 * @param string $new_route New (non header) route to redirect to.
1078
+	 * @return   void
1079
+	 * @throws ReflectionException
1080
+	 * @throws InvalidArgumentException
1081
+	 * @throws InvalidInterfaceException
1082
+	 * @throws InvalidDataTypeException
1083
+	 * @throws EE_Error
1084
+	 * @since   4.3.0
1085
+	 */
1086
+	protected function _reset_routing_properties($new_route)
1087
+	{
1088
+		$this->_is_UI_request = true;
1089
+		// now we set the current route to whatever the headers_sent_route is set at
1090
+		$this->request->setRequestParam('action', $new_route);
1091
+		// rerun page setup
1092
+		$this->_page_setup();
1093
+	}
1094
+
1095
+
1096
+	/**
1097
+	 * _add_query_arg
1098
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1099
+	 *(internally just uses EEH_URL's function with the same name)
1100
+	 *
1101
+	 * @param array  $args
1102
+	 * @param string $url
1103
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1104
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1105
+	 *                                        Example usage: If the current page is:
1106
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1107
+	 *                                        &action=default&event_id=20&month_range=March%202015
1108
+	 *                                        &_wpnonce=5467821
1109
+	 *                                        and you call:
1110
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1111
+	 *                                        array(
1112
+	 *                                        'action' => 'resend_something',
1113
+	 *                                        'page=>espresso_registrations'
1114
+	 *                                        ),
1115
+	 *                                        $some_url,
1116
+	 *                                        true
1117
+	 *                                        );
1118
+	 *                                        It will produce a url in this structure:
1119
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1120
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1121
+	 *                                        month_range]=March%202015
1122
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1123
+	 * @return string
1124
+	 */
1125
+	public static function add_query_args_and_nonce(
1126
+		$args = [],
1127
+		$url = false,
1128
+		$sticky = false,
1129
+		$exclude_nonce = false
1130
+	) {
1131
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1132
+		if ($sticky) {
1133
+			/** @var RequestInterface $request */
1134
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1135
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1136
+			foreach ($request->requestParams() as $key => $value) {
1137
+				// do not add nonces
1138
+				if (strpos($key, 'nonce') !== false) {
1139
+					continue;
1140
+				}
1141
+				$args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1142
+			}
1143
+		}
1144
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1145
+	}
1146
+
1147
+
1148
+	/**
1149
+	 * This returns a generated link that will load the related help tab.
1150
+	 *
1151
+	 * @param string $help_tab_id the id for the connected help tab
1152
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1153
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1154
+	 * @return string              generated link
1155
+	 * @uses EEH_Template::get_help_tab_link()
1156
+	 */
1157
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1158
+	{
1159
+		return EEH_Template::get_help_tab_link(
1160
+			$help_tab_id,
1161
+			$this->page_slug,
1162
+			$this->_req_action,
1163
+			$icon_style,
1164
+			$help_text
1165
+		);
1166
+	}
1167
+
1168
+
1169
+	/**
1170
+	 * _add_help_tabs
1171
+	 * Note child classes define their help tabs within the page_config array.
1172
+	 *
1173
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1174
+	 * @return void
1175
+	 * @throws DomainException
1176
+	 * @throws EE_Error
1177
+	 */
1178
+	protected function _add_help_tabs()
1179
+	{
1180
+		if (isset($this->_page_config[ $this->_req_action ])) {
1181
+			$config = $this->_page_config[ $this->_req_action ];
1182
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1183
+			if (is_array($config) && isset($config['help_sidebar'])) {
1184
+				// check that the callback given is valid
1185
+				if (! method_exists($this, $config['help_sidebar'])) {
1186
+					throw new EE_Error(
1187
+						sprintf(
1188
+							esc_html__(
1189
+								'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',
1190
+								'event_espresso'
1191
+							),
1192
+							$config['help_sidebar'],
1193
+							get_class($this)
1194
+						)
1195
+					);
1196
+				}
1197
+				$content = apply_filters(
1198
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1199
+					$this->{$config['help_sidebar']}()
1200
+				);
1201
+				$this->_current_screen->set_help_sidebar($content);
1202
+			}
1203
+			if (! isset($config['help_tabs'])) {
1204
+				return;
1205
+			} //no help tabs for this route
1206
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1207
+				// we're here so there ARE help tabs!
1208
+				// make sure we've got what we need
1209
+				if (! isset($cfg['title'])) {
1210
+					throw new EE_Error(
1211
+						esc_html__(
1212
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1213
+							'event_espresso'
1214
+						)
1215
+					);
1216
+				}
1217
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1218
+					throw new EE_Error(
1219
+						esc_html__(
1220
+							'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',
1221
+							'event_espresso'
1222
+						)
1223
+					);
1224
+				}
1225
+				// first priority goes to content.
1226
+				if (! empty($cfg['content'])) {
1227
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1228
+					// second priority goes to filename
1229
+				} elseif (! empty($cfg['filename'])) {
1230
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1231
+					// 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)
1232
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1233
+															 . basename($this->_get_dir())
1234
+															 . '/help_tabs/'
1235
+															 . $cfg['filename']
1236
+															 . '.help_tab.php' : $file_path;
1237
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1238
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1239
+						EE_Error::add_error(
1240
+							sprintf(
1241
+								esc_html__(
1242
+									'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',
1243
+									'event_espresso'
1244
+								),
1245
+								$tab_id,
1246
+								key($config),
1247
+								$file_path
1248
+							),
1249
+							__FILE__,
1250
+							__FUNCTION__,
1251
+							__LINE__
1252
+						);
1253
+						return;
1254
+					}
1255
+					$template_args['admin_page_obj'] = $this;
1256
+					$content                         = EEH_Template::display_template(
1257
+						$file_path,
1258
+						$template_args,
1259
+						true
1260
+					);
1261
+				} else {
1262
+					$content = '';
1263
+				}
1264
+				// check if callback is valid
1265
+				if (
1266
+					empty($content)
1267
+					&& (
1268
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1269
+					)
1270
+				) {
1271
+					EE_Error::add_error(
1272
+						sprintf(
1273
+							esc_html__(
1274
+								'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.',
1275
+								'event_espresso'
1276
+							),
1277
+							$cfg['title']
1278
+						),
1279
+						__FILE__,
1280
+						__FUNCTION__,
1281
+						__LINE__
1282
+					);
1283
+					return;
1284
+				}
1285
+				// setup config array for help tab method
1286
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1287
+				$_ht = [
1288
+					'id'       => $id,
1289
+					'title'    => $cfg['title'],
1290
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1291
+					'content'  => $content,
1292
+				];
1293
+				$this->_current_screen->add_help_tab($_ht);
1294
+			}
1295
+		}
1296
+	}
1297
+
1298
+
1299
+	/**
1300
+	 * This simply sets up any qtips that have been defined in the page config
1301
+	 *
1302
+	 * @return void
1303
+	 */
1304
+	protected function _add_qtips()
1305
+	{
1306
+		if (isset($this->_route_config['qtips'])) {
1307
+			$qtips = (array) $this->_route_config['qtips'];
1308
+			// load qtip loader
1309
+			$path = [
1310
+				$this->_get_dir() . '/qtips/',
1311
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1312
+			];
1313
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1314
+		}
1315
+	}
1316
+
1317
+
1318
+	/**
1319
+	 * _set_nav_tabs
1320
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1321
+	 * wish to add additional tabs or modify accordingly.
1322
+	 *
1323
+	 * @return void
1324
+	 * @throws InvalidArgumentException
1325
+	 * @throws InvalidInterfaceException
1326
+	 * @throws InvalidDataTypeException
1327
+	 */
1328
+	protected function _set_nav_tabs()
1329
+	{
1330
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1331
+		$i = 0;
1332
+		foreach ($this->_page_config as $slug => $config) {
1333
+			if (! is_array($config) || empty($config['nav'])) {
1334
+				continue;
1335
+			}
1336
+			// no nav tab for this config
1337
+			// check for persistent flag
1338
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1339
+				// nav tab is only to appear when route requested.
1340
+				continue;
1341
+			}
1342
+			if (! $this->check_user_access($slug, true)) {
1343
+				// no nav tab because current user does not have access.
1344
+				continue;
1345
+			}
1346
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1347
+			$this->_nav_tabs[ $slug ] = [
1348
+				'url'       => isset($config['nav']['url'])
1349
+					? $config['nav']['url']
1350
+					: self::add_query_args_and_nonce(
1351
+						['action' => $slug],
1352
+						$this->_admin_base_url
1353
+					),
1354
+				'link_text' => isset($config['nav']['label'])
1355
+					? $config['nav']['label']
1356
+					: ucwords(
1357
+						str_replace('_', ' ', $slug)
1358
+					),
1359
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1360
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1361
+			];
1362
+			$i++;
1363
+		}
1364
+		// if $this->_nav_tabs is empty then lets set the default
1365
+		if (empty($this->_nav_tabs)) {
1366
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1367
+				'url'       => $this->_admin_base_url,
1368
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1369
+				'css_class' => 'nav-tab-active',
1370
+				'order'     => 10,
1371
+			];
1372
+		}
1373
+		// now let's sort the tabs according to order
1374
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1375
+	}
1376
+
1377
+
1378
+	/**
1379
+	 * _set_current_labels
1380
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1381
+	 * property array
1382
+	 *
1383
+	 * @return void
1384
+	 */
1385
+	private function _set_current_labels()
1386
+	{
1387
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1388
+			foreach ($this->_route_config['labels'] as $label => $text) {
1389
+				if (is_array($text)) {
1390
+					foreach ($text as $sublabel => $subtext) {
1391
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1392
+					}
1393
+				} else {
1394
+					$this->_labels[ $label ] = $text;
1395
+				}
1396
+			}
1397
+		}
1398
+	}
1399
+
1400
+
1401
+	/**
1402
+	 *        verifies user access for this admin page
1403
+	 *
1404
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1405
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1406
+	 *                               return false if verify fail.
1407
+	 * @return bool
1408
+	 * @throws InvalidArgumentException
1409
+	 * @throws InvalidDataTypeException
1410
+	 * @throws InvalidInterfaceException
1411
+	 */
1412
+	public function check_user_access($route_to_check = '', $verify_only = false)
1413
+	{
1414
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1415
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1416
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1417
+						  && is_array(
1418
+							  $this->_page_routes[ $route_to_check ]
1419
+						  )
1420
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1421
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1422
+		if (empty($capability) && empty($route_to_check)) {
1423
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1424
+				: $this->_route['capability'];
1425
+		} else {
1426
+			$capability = empty($capability) ? 'manage_options' : $capability;
1427
+		}
1428
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1429
+		if (
1430
+			! $this->request->isAjax()
1431
+			&& (
1432
+				! function_exists('is_admin')
1433
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1434
+					$capability,
1435
+					$this->page_slug
1436
+					. '_'
1437
+					. $route_to_check,
1438
+					$id
1439
+				)
1440
+			)
1441
+		) {
1442
+			if ($verify_only) {
1443
+				return false;
1444
+			}
1445
+			if (is_user_logged_in()) {
1446
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1447
+			} else {
1448
+				return false;
1449
+			}
1450
+		}
1451
+		return true;
1452
+	}
1453
+
1454
+
1455
+	/**
1456
+	 * admin_init_global
1457
+	 * This runs all the code that we want executed within the WP admin_init hook.
1458
+	 * This method executes for ALL EE Admin pages.
1459
+	 *
1460
+	 * @return void
1461
+	 */
1462
+	public function admin_init_global()
1463
+	{
1464
+	}
1465
+
1466
+
1467
+	/**
1468
+	 * wp_loaded_global
1469
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1470
+	 * EE_Admin page and will execute on every EE Admin Page load
1471
+	 *
1472
+	 * @return void
1473
+	 */
1474
+	public function wp_loaded()
1475
+	{
1476
+	}
1477
+
1478
+
1479
+	/**
1480
+	 * admin_notices
1481
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1482
+	 * ALL EE_Admin pages.
1483
+	 *
1484
+	 * @return void
1485
+	 */
1486
+	public function admin_notices_global()
1487
+	{
1488
+		$this->_display_no_javascript_warning();
1489
+		$this->_display_espresso_notices();
1490
+	}
1491
+
1492
+
1493
+	public function network_admin_notices_global()
1494
+	{
1495
+		$this->_display_no_javascript_warning();
1496
+		$this->_display_espresso_notices();
1497
+	}
1498
+
1499
+
1500
+	/**
1501
+	 * admin_footer_scripts_global
1502
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1503
+	 * will apply on ALL EE_Admin pages.
1504
+	 *
1505
+	 * @return void
1506
+	 */
1507
+	public function admin_footer_scripts_global()
1508
+	{
1509
+		$this->_add_admin_page_ajax_loading_img();
1510
+		$this->_add_admin_page_overlay();
1511
+		// if metaboxes are present we need to add the nonce field
1512
+		if (
1513
+			isset($this->_route_config['metaboxes'])
1514
+			|| isset($this->_route_config['list_table'])
1515
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1516
+		) {
1517
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1518
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1519
+		}
1520
+	}
1521
+
1522
+
1523
+	/**
1524
+	 * admin_footer_global
1525
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1526
+	 * ALL EE_Admin Pages.
1527
+	 *
1528
+	 * @return void
1529
+	 */
1530
+	public function admin_footer_global()
1531
+	{
1532
+		// dialog container for dialog helper
1533
+		echo '
1534 1534
         <div class="ee-admin-dialog-container auto-hide hidden">
1535 1535
             <div class="ee-notices"></div>
1536 1536
             <div class="ee-admin-dialog-container-inner-content"></div>
1537 1537
         </div>
1538 1538
         ';
1539 1539
 
1540
-        // current set timezone for timezone js
1541
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1542
-    }
1543
-
1544
-
1545
-    /**
1546
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1547
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1548
-     * help popups then in your templates or your content you set "triggers" for the content using the
1549
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1550
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1551
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1552
-     * for the
1553
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1554
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1555
-     *    'help_trigger_id' => array(
1556
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1557
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1558
-     *    )
1559
-     * );
1560
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1561
-     *
1562
-     * @param array $help_array
1563
-     * @param bool  $display
1564
-     * @return string content
1565
-     * @throws DomainException
1566
-     * @throws EE_Error
1567
-     */
1568
-    protected function _set_help_popup_content($help_array = [], $display = false)
1569
-    {
1570
-        $content    = '';
1571
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1572
-        // loop through the array and setup content
1573
-        foreach ($help_array as $trigger => $help) {
1574
-            // make sure the array is setup properly
1575
-            if (! isset($help['title']) || ! isset($help['content'])) {
1576
-                throw new EE_Error(
1577
-                    esc_html__(
1578
-                        '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',
1579
-                        'event_espresso'
1580
-                    )
1581
-                );
1582
-            }
1583
-            // we're good so let's setup the template vars and then assign parsed template content to our content.
1584
-            $template_args = [
1585
-                'help_popup_id'      => $trigger,
1586
-                'help_popup_title'   => $help['title'],
1587
-                'help_popup_content' => $help['content'],
1588
-            ];
1589
-            $content       .= EEH_Template::display_template(
1590
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1591
-                $template_args,
1592
-                true
1593
-            );
1594
-        }
1595
-        if ($display) {
1596
-            echo wp_kses($content, AllowedTags::getWithFormTags());
1597
-            return '';
1598
-        }
1599
-        return $content;
1600
-    }
1601
-
1602
-
1603
-    /**
1604
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1605
-     *
1606
-     * @return array properly formatted array for help popup content
1607
-     * @throws EE_Error
1608
-     */
1609
-    private function _get_help_content()
1610
-    {
1611
-        // what is the method we're looking for?
1612
-        $method_name = '_help_popup_content_' . $this->_req_action;
1613
-        // if method doesn't exist let's get out.
1614
-        if (! method_exists($this, $method_name)) {
1615
-            return [];
1616
-        }
1617
-        // k we're good to go let's retrieve the help array
1618
-        $help_array = call_user_func([$this, $method_name]);
1619
-        // make sure we've got an array!
1620
-        if (! is_array($help_array)) {
1621
-            throw new EE_Error(
1622
-                esc_html__(
1623
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1624
-                    'event_espresso'
1625
-                )
1626
-            );
1627
-        }
1628
-        return $help_array;
1629
-    }
1630
-
1631
-
1632
-    /**
1633
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1634
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1635
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1636
-     *
1637
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1638
-     * @param boolean $display    if false then we return the trigger string
1639
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1640
-     * @return string
1641
-     * @throws DomainException
1642
-     * @throws EE_Error
1643
-     */
1644
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1645
-    {
1646
-        if ($this->request->isAjax()) {
1647
-            return '';
1648
-        }
1649
-        // 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
1650
-        $help_array   = $this->_get_help_content();
1651
-        $help_content = '';
1652
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1653
-            $help_array[ $trigger_id ] = [
1654
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1655
-                'content' => esc_html__(
1656
-                    '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.)',
1657
-                    'event_espresso'
1658
-                ),
1659
-            ];
1660
-            $help_content              = $this->_set_help_popup_content($help_array);
1661
-        }
1662
-        // let's setup the trigger
1663
-        $content = '<a class="ee-dialog" href="?height='
1664
-                   . esc_attr($dimensions[0])
1665
-                   . '&width='
1666
-                   . esc_attr($dimensions[1])
1667
-                   . '&inlineId='
1668
-                   . esc_attr($trigger_id)
1669
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1670
-        $content .= $help_content;
1671
-        if ($display) {
1672
-            echo wp_kses($content, AllowedTags::getWithFormTags());
1673
-            return '';
1674
-        }
1675
-        return $content;
1676
-    }
1677
-
1678
-
1679
-    /**
1680
-     * _add_global_screen_options
1681
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1682
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1683
-     *
1684
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1685
-     *         see also WP_Screen object documents...
1686
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1687
-     * @abstract
1688
-     * @return void
1689
-     */
1690
-    private function _add_global_screen_options()
1691
-    {
1692
-    }
1693
-
1694
-
1695
-    /**
1696
-     * _add_global_feature_pointers
1697
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1698
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1699
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1700
-     *
1701
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1702
-     *         extended) also see:
1703
-     * @link   http://eamann.com/tech/wordpress-portland/
1704
-     * @abstract
1705
-     * @return void
1706
-     */
1707
-    private function _add_global_feature_pointers()
1708
-    {
1709
-    }
1710
-
1711
-
1712
-    /**
1713
-     * load_global_scripts_styles
1714
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1715
-     *
1716
-     * @return void
1717
-     */
1718
-    public function load_global_scripts_styles()
1719
-    {
1720
-        /** STYLES **/
1721
-        // add debugging styles
1722
-        if (WP_DEBUG) {
1723
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1724
-        }
1725
-        // register all styles
1726
-        wp_register_style(
1727
-            'espresso-ui-theme',
1728
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1729
-            [],
1730
-            EVENT_ESPRESSO_VERSION
1731
-        );
1732
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1733
-        // helpers styles
1734
-        wp_register_style(
1735
-            'ee-text-links',
1736
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1737
-            [],
1738
-            EVENT_ESPRESSO_VERSION
1739
-        );
1740
-        /** SCRIPTS **/
1741
-        // register all scripts
1742
-        wp_register_script(
1743
-            'ee-dialog',
1744
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1745
-            ['jquery', 'jquery-ui-draggable'],
1746
-            EVENT_ESPRESSO_VERSION,
1747
-            true
1748
-        );
1749
-        wp_register_script(
1750
-            'ee_admin_js',
1751
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1752
-            ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1753
-            EVENT_ESPRESSO_VERSION,
1754
-            true
1755
-        );
1756
-        wp_register_script(
1757
-            'jquery-ui-timepicker-addon',
1758
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1759
-            ['jquery-ui-datepicker', 'jquery-ui-slider'],
1760
-            EVENT_ESPRESSO_VERSION,
1761
-            true
1762
-        );
1763
-        // script for sorting tables
1764
-        wp_register_script(
1765
-            'espresso_ajax_table_sorting',
1766
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1767
-            ['ee_admin_js', 'jquery-ui-sortable'],
1768
-            EVENT_ESPRESSO_VERSION,
1769
-            true
1770
-        );
1771
-        // script for parsing uri's
1772
-        wp_register_script(
1773
-            'ee-parse-uri',
1774
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1775
-            [],
1776
-            EVENT_ESPRESSO_VERSION,
1777
-            true
1778
-        );
1779
-        // and parsing associative serialized form elements
1780
-        wp_register_script(
1781
-            'ee-serialize-full-array',
1782
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1783
-            ['jquery'],
1784
-            EVENT_ESPRESSO_VERSION,
1785
-            true
1786
-        );
1787
-        // helpers scripts
1788
-        wp_register_script(
1789
-            'ee-text-links',
1790
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1791
-            ['jquery'],
1792
-            EVENT_ESPRESSO_VERSION,
1793
-            true
1794
-        );
1795
-        wp_register_script(
1796
-            'ee-moment-core',
1797
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1798
-            [],
1799
-            EVENT_ESPRESSO_VERSION,
1800
-            true
1801
-        );
1802
-        wp_register_script(
1803
-            'ee-moment',
1804
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1805
-            ['ee-moment-core'],
1806
-            EVENT_ESPRESSO_VERSION,
1807
-            true
1808
-        );
1809
-        wp_register_script(
1810
-            'ee-datepicker',
1811
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1812
-            ['jquery-ui-timepicker-addon', 'ee-moment'],
1813
-            EVENT_ESPRESSO_VERSION,
1814
-            true
1815
-        );
1816
-        // google charts
1817
-        wp_register_script(
1818
-            'google-charts',
1819
-            'https://www.gstatic.com/charts/loader.js',
1820
-            [],
1821
-            EVENT_ESPRESSO_VERSION
1822
-        );
1823
-        // ENQUEUE ALL BASICS BY DEFAULT
1824
-        wp_enqueue_style('ee-admin-css');
1825
-        wp_enqueue_script('ee_admin_js');
1826
-        wp_enqueue_script('ee-accounting');
1827
-        wp_enqueue_script('jquery-validate');
1828
-        // taking care of metaboxes
1829
-        if (
1830
-            empty($this->_cpt_route)
1831
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1832
-        ) {
1833
-            wp_enqueue_script('dashboard');
1834
-        }
1835
-        // LOCALIZED DATA
1836
-        // localize script for ajax lazy loading
1837
-        $lazy_loader_container_ids = apply_filters(
1838
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1839
-            ['espresso_news_post_box_content']
1840
-        );
1841
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1842
-        add_filter(
1843
-            'admin_body_class',
1844
-            function ($classes) {
1845
-                if (strpos($classes, 'espresso-admin') === false) {
1846
-                    $classes .= ' espresso-admin';
1847
-                }
1848
-                return $classes;
1849
-            }
1850
-        );
1851
-    }
1852
-
1853
-
1854
-    /**
1855
-     *        admin_footer_scripts_eei18n_js_strings
1856
-     *
1857
-     * @return        void
1858
-     */
1859
-    public function admin_footer_scripts_eei18n_js_strings()
1860
-    {
1861
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1862
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1863
-            __(
1864
-                '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!!!',
1865
-                'event_espresso'
1866
-            )
1867
-        );
1868
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1869
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1870
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1871
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1872
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1873
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1874
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1875
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1876
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1877
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1878
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1879
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1880
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1881
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1882
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1883
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1884
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1885
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1886
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1887
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1888
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1889
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1890
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1891
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1892
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1893
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1894
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1895
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1896
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1897
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1898
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1899
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1900
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1901
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1902
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1903
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1904
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1905
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1906
-    }
1907
-
1908
-
1909
-    /**
1910
-     *        load enhanced xdebug styles for ppl with failing eyesight
1911
-     *
1912
-     * @return        void
1913
-     */
1914
-    public function add_xdebug_style()
1915
-    {
1916
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1917
-    }
1918
-
1919
-
1920
-    /************************/
1921
-    /** LIST TABLE METHODS **/
1922
-    /************************/
1923
-    /**
1924
-     * this sets up the list table if the current view requires it.
1925
-     *
1926
-     * @return void
1927
-     * @throws EE_Error
1928
-     */
1929
-    protected function _set_list_table()
1930
-    {
1931
-        // first is this a list_table view?
1932
-        if (! isset($this->_route_config['list_table'])) {
1933
-            return;
1934
-        } //not a list_table view so get out.
1935
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
1936
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
1937
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1938
-            // user error msg
1939
-            $error_msg = esc_html__(
1940
-                'An error occurred. The requested list table views could not be found.',
1941
-                'event_espresso'
1942
-            );
1943
-            // developer error msg
1944
-            $error_msg .= '||'
1945
-                          . sprintf(
1946
-                              esc_html__(
1947
-                                  '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.',
1948
-                                  'event_espresso'
1949
-                              ),
1950
-                              $this->_req_action,
1951
-                              $list_table_view
1952
-                          );
1953
-            throw new EE_Error($error_msg);
1954
-        }
1955
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1956
-        $this->_views = apply_filters(
1957
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1958
-            $this->_views
1959
-        );
1960
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1961
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1962
-        $this->_set_list_table_view();
1963
-        $this->_set_list_table_object();
1964
-    }
1965
-
1966
-
1967
-    /**
1968
-     * set current view for List Table
1969
-     *
1970
-     * @return void
1971
-     */
1972
-    protected function _set_list_table_view()
1973
-    {
1974
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1975
-        $status = $this->request->getRequestParam('status', null, 'key');
1976
-        $this->_view = $status && array_key_exists($status, $this->_views)
1977
-            ? $status
1978
-            : $this->_view;
1979
-    }
1980
-
1981
-
1982
-    /**
1983
-     * _set_list_table_object
1984
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1985
-     *
1986
-     * @throws InvalidInterfaceException
1987
-     * @throws InvalidArgumentException
1988
-     * @throws InvalidDataTypeException
1989
-     * @throws EE_Error
1990
-     * @throws InvalidInterfaceException
1991
-     */
1992
-    protected function _set_list_table_object()
1993
-    {
1994
-        if (isset($this->_route_config['list_table'])) {
1995
-            if (! class_exists($this->_route_config['list_table'])) {
1996
-                throw new EE_Error(
1997
-                    sprintf(
1998
-                        esc_html__(
1999
-                            '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.',
2000
-                            'event_espresso'
2001
-                        ),
2002
-                        $this->_route_config['list_table'],
2003
-                        get_class($this)
2004
-                    )
2005
-                );
2006
-            }
2007
-            $this->_list_table_object = $this->loader->getShared(
2008
-                $this->_route_config['list_table'],
2009
-                [$this]
2010
-            );
2011
-        }
2012
-    }
2013
-
2014
-
2015
-    /**
2016
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2017
-     *
2018
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2019
-     *                                                    urls.  The array should be indexed by the view it is being
2020
-     *                                                    added to.
2021
-     * @return array
2022
-     */
2023
-    public function get_list_table_view_RLs($extra_query_args = [])
2024
-    {
2025
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2026
-        if (empty($this->_views)) {
2027
-            $this->_views = [];
2028
-        }
2029
-        // cycle thru views
2030
-        foreach ($this->_views as $key => $view) {
2031
-            $query_args = [];
2032
-            // check for current view
2033
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2034
-            $query_args['action']                        = $this->_req_action;
2035
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2036
-            $query_args['status']                        = $view['slug'];
2037
-            // merge any other arguments sent in.
2038
-            if (isset($extra_query_args[ $view['slug'] ])) {
2039
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2040
-            }
2041
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2042
-        }
2043
-        return $this->_views;
2044
-    }
2045
-
2046
-
2047
-    /**
2048
-     * _entries_per_page_dropdown
2049
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2050
-     *
2051
-     * @param int $max_entries total number of rows in the table
2052
-     * @return string
2053
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2054
-     *         WP does it.
2055
-     */
2056
-    protected function _entries_per_page_dropdown($max_entries = 0)
2057
-    {
2058
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2059
-        $values   = [10, 25, 50, 100];
2060
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2061
-        if ($max_entries) {
2062
-            $values[] = $max_entries;
2063
-            sort($values);
2064
-        }
2065
-        $entries_per_page_dropdown = '
1540
+		// current set timezone for timezone js
1541
+		echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1542
+	}
1543
+
1544
+
1545
+	/**
1546
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1547
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1548
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1549
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1550
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1551
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1552
+	 * for the
1553
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1554
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1555
+	 *    'help_trigger_id' => array(
1556
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1557
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1558
+	 *    )
1559
+	 * );
1560
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1561
+	 *
1562
+	 * @param array $help_array
1563
+	 * @param bool  $display
1564
+	 * @return string content
1565
+	 * @throws DomainException
1566
+	 * @throws EE_Error
1567
+	 */
1568
+	protected function _set_help_popup_content($help_array = [], $display = false)
1569
+	{
1570
+		$content    = '';
1571
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1572
+		// loop through the array and setup content
1573
+		foreach ($help_array as $trigger => $help) {
1574
+			// make sure the array is setup properly
1575
+			if (! isset($help['title']) || ! isset($help['content'])) {
1576
+				throw new EE_Error(
1577
+					esc_html__(
1578
+						'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',
1579
+						'event_espresso'
1580
+					)
1581
+				);
1582
+			}
1583
+			// we're good so let's setup the template vars and then assign parsed template content to our content.
1584
+			$template_args = [
1585
+				'help_popup_id'      => $trigger,
1586
+				'help_popup_title'   => $help['title'],
1587
+				'help_popup_content' => $help['content'],
1588
+			];
1589
+			$content       .= EEH_Template::display_template(
1590
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1591
+				$template_args,
1592
+				true
1593
+			);
1594
+		}
1595
+		if ($display) {
1596
+			echo wp_kses($content, AllowedTags::getWithFormTags());
1597
+			return '';
1598
+		}
1599
+		return $content;
1600
+	}
1601
+
1602
+
1603
+	/**
1604
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1605
+	 *
1606
+	 * @return array properly formatted array for help popup content
1607
+	 * @throws EE_Error
1608
+	 */
1609
+	private function _get_help_content()
1610
+	{
1611
+		// what is the method we're looking for?
1612
+		$method_name = '_help_popup_content_' . $this->_req_action;
1613
+		// if method doesn't exist let's get out.
1614
+		if (! method_exists($this, $method_name)) {
1615
+			return [];
1616
+		}
1617
+		// k we're good to go let's retrieve the help array
1618
+		$help_array = call_user_func([$this, $method_name]);
1619
+		// make sure we've got an array!
1620
+		if (! is_array($help_array)) {
1621
+			throw new EE_Error(
1622
+				esc_html__(
1623
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1624
+					'event_espresso'
1625
+				)
1626
+			);
1627
+		}
1628
+		return $help_array;
1629
+	}
1630
+
1631
+
1632
+	/**
1633
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1634
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1635
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1636
+	 *
1637
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1638
+	 * @param boolean $display    if false then we return the trigger string
1639
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1640
+	 * @return string
1641
+	 * @throws DomainException
1642
+	 * @throws EE_Error
1643
+	 */
1644
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1645
+	{
1646
+		if ($this->request->isAjax()) {
1647
+			return '';
1648
+		}
1649
+		// 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
1650
+		$help_array   = $this->_get_help_content();
1651
+		$help_content = '';
1652
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1653
+			$help_array[ $trigger_id ] = [
1654
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1655
+				'content' => esc_html__(
1656
+					'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.)',
1657
+					'event_espresso'
1658
+				),
1659
+			];
1660
+			$help_content              = $this->_set_help_popup_content($help_array);
1661
+		}
1662
+		// let's setup the trigger
1663
+		$content = '<a class="ee-dialog" href="?height='
1664
+				   . esc_attr($dimensions[0])
1665
+				   . '&width='
1666
+				   . esc_attr($dimensions[1])
1667
+				   . '&inlineId='
1668
+				   . esc_attr($trigger_id)
1669
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1670
+		$content .= $help_content;
1671
+		if ($display) {
1672
+			echo wp_kses($content, AllowedTags::getWithFormTags());
1673
+			return '';
1674
+		}
1675
+		return $content;
1676
+	}
1677
+
1678
+
1679
+	/**
1680
+	 * _add_global_screen_options
1681
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1682
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1683
+	 *
1684
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1685
+	 *         see also WP_Screen object documents...
1686
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1687
+	 * @abstract
1688
+	 * @return void
1689
+	 */
1690
+	private function _add_global_screen_options()
1691
+	{
1692
+	}
1693
+
1694
+
1695
+	/**
1696
+	 * _add_global_feature_pointers
1697
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1698
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1699
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1700
+	 *
1701
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1702
+	 *         extended) also see:
1703
+	 * @link   http://eamann.com/tech/wordpress-portland/
1704
+	 * @abstract
1705
+	 * @return void
1706
+	 */
1707
+	private function _add_global_feature_pointers()
1708
+	{
1709
+	}
1710
+
1711
+
1712
+	/**
1713
+	 * load_global_scripts_styles
1714
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1715
+	 *
1716
+	 * @return void
1717
+	 */
1718
+	public function load_global_scripts_styles()
1719
+	{
1720
+		/** STYLES **/
1721
+		// add debugging styles
1722
+		if (WP_DEBUG) {
1723
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1724
+		}
1725
+		// register all styles
1726
+		wp_register_style(
1727
+			'espresso-ui-theme',
1728
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1729
+			[],
1730
+			EVENT_ESPRESSO_VERSION
1731
+		);
1732
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1733
+		// helpers styles
1734
+		wp_register_style(
1735
+			'ee-text-links',
1736
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1737
+			[],
1738
+			EVENT_ESPRESSO_VERSION
1739
+		);
1740
+		/** SCRIPTS **/
1741
+		// register all scripts
1742
+		wp_register_script(
1743
+			'ee-dialog',
1744
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1745
+			['jquery', 'jquery-ui-draggable'],
1746
+			EVENT_ESPRESSO_VERSION,
1747
+			true
1748
+		);
1749
+		wp_register_script(
1750
+			'ee_admin_js',
1751
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1752
+			['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1753
+			EVENT_ESPRESSO_VERSION,
1754
+			true
1755
+		);
1756
+		wp_register_script(
1757
+			'jquery-ui-timepicker-addon',
1758
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1759
+			['jquery-ui-datepicker', 'jquery-ui-slider'],
1760
+			EVENT_ESPRESSO_VERSION,
1761
+			true
1762
+		);
1763
+		// script for sorting tables
1764
+		wp_register_script(
1765
+			'espresso_ajax_table_sorting',
1766
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1767
+			['ee_admin_js', 'jquery-ui-sortable'],
1768
+			EVENT_ESPRESSO_VERSION,
1769
+			true
1770
+		);
1771
+		// script for parsing uri's
1772
+		wp_register_script(
1773
+			'ee-parse-uri',
1774
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1775
+			[],
1776
+			EVENT_ESPRESSO_VERSION,
1777
+			true
1778
+		);
1779
+		// and parsing associative serialized form elements
1780
+		wp_register_script(
1781
+			'ee-serialize-full-array',
1782
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1783
+			['jquery'],
1784
+			EVENT_ESPRESSO_VERSION,
1785
+			true
1786
+		);
1787
+		// helpers scripts
1788
+		wp_register_script(
1789
+			'ee-text-links',
1790
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1791
+			['jquery'],
1792
+			EVENT_ESPRESSO_VERSION,
1793
+			true
1794
+		);
1795
+		wp_register_script(
1796
+			'ee-moment-core',
1797
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1798
+			[],
1799
+			EVENT_ESPRESSO_VERSION,
1800
+			true
1801
+		);
1802
+		wp_register_script(
1803
+			'ee-moment',
1804
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1805
+			['ee-moment-core'],
1806
+			EVENT_ESPRESSO_VERSION,
1807
+			true
1808
+		);
1809
+		wp_register_script(
1810
+			'ee-datepicker',
1811
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1812
+			['jquery-ui-timepicker-addon', 'ee-moment'],
1813
+			EVENT_ESPRESSO_VERSION,
1814
+			true
1815
+		);
1816
+		// google charts
1817
+		wp_register_script(
1818
+			'google-charts',
1819
+			'https://www.gstatic.com/charts/loader.js',
1820
+			[],
1821
+			EVENT_ESPRESSO_VERSION
1822
+		);
1823
+		// ENQUEUE ALL BASICS BY DEFAULT
1824
+		wp_enqueue_style('ee-admin-css');
1825
+		wp_enqueue_script('ee_admin_js');
1826
+		wp_enqueue_script('ee-accounting');
1827
+		wp_enqueue_script('jquery-validate');
1828
+		// taking care of metaboxes
1829
+		if (
1830
+			empty($this->_cpt_route)
1831
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1832
+		) {
1833
+			wp_enqueue_script('dashboard');
1834
+		}
1835
+		// LOCALIZED DATA
1836
+		// localize script for ajax lazy loading
1837
+		$lazy_loader_container_ids = apply_filters(
1838
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1839
+			['espresso_news_post_box_content']
1840
+		);
1841
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1842
+		add_filter(
1843
+			'admin_body_class',
1844
+			function ($classes) {
1845
+				if (strpos($classes, 'espresso-admin') === false) {
1846
+					$classes .= ' espresso-admin';
1847
+				}
1848
+				return $classes;
1849
+			}
1850
+		);
1851
+	}
1852
+
1853
+
1854
+	/**
1855
+	 *        admin_footer_scripts_eei18n_js_strings
1856
+	 *
1857
+	 * @return        void
1858
+	 */
1859
+	public function admin_footer_scripts_eei18n_js_strings()
1860
+	{
1861
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1862
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1863
+			__(
1864
+				'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!!!',
1865
+				'event_espresso'
1866
+			)
1867
+		);
1868
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1869
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1870
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1871
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1872
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1873
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1874
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1875
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1876
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1877
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1878
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1879
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1880
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1881
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1882
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1883
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1884
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1885
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1886
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1887
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1888
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1889
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1890
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1891
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1892
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1893
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1894
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1895
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1896
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1897
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1898
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1899
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1900
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1901
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1902
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1903
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1904
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1905
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1906
+	}
1907
+
1908
+
1909
+	/**
1910
+	 *        load enhanced xdebug styles for ppl with failing eyesight
1911
+	 *
1912
+	 * @return        void
1913
+	 */
1914
+	public function add_xdebug_style()
1915
+	{
1916
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1917
+	}
1918
+
1919
+
1920
+	/************************/
1921
+	/** LIST TABLE METHODS **/
1922
+	/************************/
1923
+	/**
1924
+	 * this sets up the list table if the current view requires it.
1925
+	 *
1926
+	 * @return void
1927
+	 * @throws EE_Error
1928
+	 */
1929
+	protected function _set_list_table()
1930
+	{
1931
+		// first is this a list_table view?
1932
+		if (! isset($this->_route_config['list_table'])) {
1933
+			return;
1934
+		} //not a list_table view so get out.
1935
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
1936
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
1937
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1938
+			// user error msg
1939
+			$error_msg = esc_html__(
1940
+				'An error occurred. The requested list table views could not be found.',
1941
+				'event_espresso'
1942
+			);
1943
+			// developer error msg
1944
+			$error_msg .= '||'
1945
+						  . sprintf(
1946
+							  esc_html__(
1947
+								  '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.',
1948
+								  'event_espresso'
1949
+							  ),
1950
+							  $this->_req_action,
1951
+							  $list_table_view
1952
+						  );
1953
+			throw new EE_Error($error_msg);
1954
+		}
1955
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1956
+		$this->_views = apply_filters(
1957
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1958
+			$this->_views
1959
+		);
1960
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1961
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1962
+		$this->_set_list_table_view();
1963
+		$this->_set_list_table_object();
1964
+	}
1965
+
1966
+
1967
+	/**
1968
+	 * set current view for List Table
1969
+	 *
1970
+	 * @return void
1971
+	 */
1972
+	protected function _set_list_table_view()
1973
+	{
1974
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1975
+		$status = $this->request->getRequestParam('status', null, 'key');
1976
+		$this->_view = $status && array_key_exists($status, $this->_views)
1977
+			? $status
1978
+			: $this->_view;
1979
+	}
1980
+
1981
+
1982
+	/**
1983
+	 * _set_list_table_object
1984
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1985
+	 *
1986
+	 * @throws InvalidInterfaceException
1987
+	 * @throws InvalidArgumentException
1988
+	 * @throws InvalidDataTypeException
1989
+	 * @throws EE_Error
1990
+	 * @throws InvalidInterfaceException
1991
+	 */
1992
+	protected function _set_list_table_object()
1993
+	{
1994
+		if (isset($this->_route_config['list_table'])) {
1995
+			if (! class_exists($this->_route_config['list_table'])) {
1996
+				throw new EE_Error(
1997
+					sprintf(
1998
+						esc_html__(
1999
+							'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.',
2000
+							'event_espresso'
2001
+						),
2002
+						$this->_route_config['list_table'],
2003
+						get_class($this)
2004
+					)
2005
+				);
2006
+			}
2007
+			$this->_list_table_object = $this->loader->getShared(
2008
+				$this->_route_config['list_table'],
2009
+				[$this]
2010
+			);
2011
+		}
2012
+	}
2013
+
2014
+
2015
+	/**
2016
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2017
+	 *
2018
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2019
+	 *                                                    urls.  The array should be indexed by the view it is being
2020
+	 *                                                    added to.
2021
+	 * @return array
2022
+	 */
2023
+	public function get_list_table_view_RLs($extra_query_args = [])
2024
+	{
2025
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2026
+		if (empty($this->_views)) {
2027
+			$this->_views = [];
2028
+		}
2029
+		// cycle thru views
2030
+		foreach ($this->_views as $key => $view) {
2031
+			$query_args = [];
2032
+			// check for current view
2033
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2034
+			$query_args['action']                        = $this->_req_action;
2035
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2036
+			$query_args['status']                        = $view['slug'];
2037
+			// merge any other arguments sent in.
2038
+			if (isset($extra_query_args[ $view['slug'] ])) {
2039
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2040
+			}
2041
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2042
+		}
2043
+		return $this->_views;
2044
+	}
2045
+
2046
+
2047
+	/**
2048
+	 * _entries_per_page_dropdown
2049
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2050
+	 *
2051
+	 * @param int $max_entries total number of rows in the table
2052
+	 * @return string
2053
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2054
+	 *         WP does it.
2055
+	 */
2056
+	protected function _entries_per_page_dropdown($max_entries = 0)
2057
+	{
2058
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2059
+		$values   = [10, 25, 50, 100];
2060
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2061
+		if ($max_entries) {
2062
+			$values[] = $max_entries;
2063
+			sort($values);
2064
+		}
2065
+		$entries_per_page_dropdown = '
2066 2066
 			<div id="entries-per-page-dv" class="alignleft actions">
2067 2067
 				<label class="hide-if-no-js">
2068 2068
 					Show
2069 2069
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2070
-        foreach ($values as $value) {
2071
-            if ($value < $max_entries) {
2072
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2073
-                $entries_per_page_dropdown .= '
2070
+		foreach ($values as $value) {
2071
+			if ($value < $max_entries) {
2072
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2073
+				$entries_per_page_dropdown .= '
2074 2074
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2075
-            }
2076
-        }
2077
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2078
-        $entries_per_page_dropdown .= '
2075
+			}
2076
+		}
2077
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2078
+		$entries_per_page_dropdown .= '
2079 2079
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2080
-        $entries_per_page_dropdown .= '
2080
+		$entries_per_page_dropdown .= '
2081 2081
 					</select>
2082 2082
 					entries
2083 2083
 				</label>
2084 2084
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2085 2085
 			</div>
2086 2086
 		';
2087
-        return $entries_per_page_dropdown;
2088
-    }
2089
-
2090
-
2091
-    /**
2092
-     *        _set_search_attributes
2093
-     *
2094
-     * @return        void
2095
-     */
2096
-    public function _set_search_attributes()
2097
-    {
2098
-        $this->_template_args['search']['btn_label'] = sprintf(
2099
-            esc_html__('Search %s', 'event_espresso'),
2100
-            empty($this->_search_btn_label) ? $this->page_label
2101
-                : $this->_search_btn_label
2102
-        );
2103
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2104
-    }
2105
-
2106
-
2107
-
2108
-    /*** END LIST TABLE METHODS **/
2109
-
2110
-
2111
-    /**
2112
-     * _add_registered_metaboxes
2113
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2114
-     *
2115
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2116
-     * @return void
2117
-     * @throws EE_Error
2118
-     */
2119
-    private function _add_registered_meta_boxes()
2120
-    {
2121
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2122
-        // we only add meta boxes if the page_route calls for it
2123
-        if (
2124
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2125
-            && is_array(
2126
-                $this->_route_config['metaboxes']
2127
-            )
2128
-        ) {
2129
-            // this simply loops through the callbacks provided
2130
-            // and checks if there is a corresponding callback registered by the child
2131
-            // if there is then we go ahead and process the metabox loader.
2132
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2133
-                // first check for Closures
2134
-                if ($metabox_callback instanceof Closure) {
2135
-                    $result = $metabox_callback();
2136
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2137
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2138
-                } else {
2139
-                    $result = call_user_func([$this, &$metabox_callback]);
2140
-                }
2141
-                if ($result === false) {
2142
-                    // user error msg
2143
-                    $error_msg = esc_html__(
2144
-                        'An error occurred. The  requested metabox could not be found.',
2145
-                        'event_espresso'
2146
-                    );
2147
-                    // developer error msg
2148
-                    $error_msg .= '||'
2149
-                                  . sprintf(
2150
-                                      esc_html__(
2151
-                                          '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.',
2152
-                                          'event_espresso'
2153
-                                      ),
2154
-                                      $metabox_callback
2155
-                                  );
2156
-                    throw new EE_Error($error_msg);
2157
-                }
2158
-            }
2159
-        }
2160
-    }
2161
-
2162
-
2163
-    /**
2164
-     * _add_screen_columns
2165
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2166
-     * the dynamic column template and we'll setup the column options for the page.
2167
-     *
2168
-     * @return void
2169
-     */
2170
-    private function _add_screen_columns()
2171
-    {
2172
-        if (
2173
-            is_array($this->_route_config)
2174
-            && isset($this->_route_config['columns'])
2175
-            && is_array($this->_route_config['columns'])
2176
-            && count($this->_route_config['columns']) === 2
2177
-        ) {
2178
-            add_screen_option(
2179
-                'layout_columns',
2180
-                [
2181
-                    'max'     => (int) $this->_route_config['columns'][0],
2182
-                    'default' => (int) $this->_route_config['columns'][1],
2183
-                ]
2184
-            );
2185
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2186
-            $screen_id                                           = $this->_current_screen->id;
2187
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2188
-            $total_columns                                       = ! empty($screen_columns)
2189
-                ? $screen_columns
2190
-                : $this->_route_config['columns'][1];
2191
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2192
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2193
-            $this->_template_args['screen']                      = $this->_current_screen;
2194
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2195
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2196
-            // finally if we don't have has_metaboxes set in the route config
2197
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2198
-            $this->_route_config['has_metaboxes'] = true;
2199
-        }
2200
-    }
2201
-
2202
-
2203
-
2204
-    /** GLOBALLY AVAILABLE METABOXES **/
2205
-
2206
-
2207
-    /**
2208
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2209
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2210
-     * these get loaded on.
2211
-     */
2212
-    private function _espresso_news_post_box()
2213
-    {
2214
-        $news_box_title = apply_filters(
2215
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2216
-            esc_html__('New @ Event Espresso', 'event_espresso')
2217
-        );
2218
-        add_meta_box(
2219
-            'espresso_news_post_box',
2220
-            $news_box_title,
2221
-            [
2222
-                $this,
2223
-                'espresso_news_post_box',
2224
-            ],
2225
-            $this->_wp_page_slug,
2226
-            'side'
2227
-        );
2228
-    }
2229
-
2230
-
2231
-    /**
2232
-     * Code for setting up espresso ratings request metabox.
2233
-     */
2234
-    protected function _espresso_ratings_request()
2235
-    {
2236
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2237
-            return;
2238
-        }
2239
-        $ratings_box_title = apply_filters(
2240
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2241
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2242
-        );
2243
-        add_meta_box(
2244
-            'espresso_ratings_request',
2245
-            $ratings_box_title,
2246
-            [
2247
-                $this,
2248
-                'espresso_ratings_request',
2249
-            ],
2250
-            $this->_wp_page_slug,
2251
-            'side'
2252
-        );
2253
-    }
2254
-
2255
-
2256
-    /**
2257
-     * Code for setting up espresso ratings request metabox content.
2258
-     *
2259
-     * @throws DomainException
2260
-     */
2261
-    public function espresso_ratings_request()
2262
-    {
2263
-        EEH_Template::display_template(
2264
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2265
-            []
2266
-        );
2267
-    }
2268
-
2269
-
2270
-    public static function cached_rss_display($rss_id, $url)
2271
-    {
2272
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2273
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2274
-                     . '</p><p class="hide-if-js">'
2275
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2276
-                     . '</p>';
2277
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2278
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2279
-        $post      = '</div>' . "\n";
2280
-        $cache_key = 'ee_rss_' . md5($rss_id);
2281
-        $output    = get_transient($cache_key);
2282
-        if ($output !== false) {
2283
-            echo wp_kses($pre . $output . $post, AllowedTags::getWithFormTags());
2284
-            return true;
2285
-        }
2286
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2287
-            echo wp_kses($pre . $loading . $post, AllowedTags::getWithFormTags());
2288
-            return false;
2289
-        }
2290
-        ob_start();
2291
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2292
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2293
-        return true;
2294
-    }
2295
-
2296
-
2297
-    public function espresso_news_post_box()
2298
-    {
2299
-        ?>
2087
+		return $entries_per_page_dropdown;
2088
+	}
2089
+
2090
+
2091
+	/**
2092
+	 *        _set_search_attributes
2093
+	 *
2094
+	 * @return        void
2095
+	 */
2096
+	public function _set_search_attributes()
2097
+	{
2098
+		$this->_template_args['search']['btn_label'] = sprintf(
2099
+			esc_html__('Search %s', 'event_espresso'),
2100
+			empty($this->_search_btn_label) ? $this->page_label
2101
+				: $this->_search_btn_label
2102
+		);
2103
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2104
+	}
2105
+
2106
+
2107
+
2108
+	/*** END LIST TABLE METHODS **/
2109
+
2110
+
2111
+	/**
2112
+	 * _add_registered_metaboxes
2113
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2114
+	 *
2115
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2116
+	 * @return void
2117
+	 * @throws EE_Error
2118
+	 */
2119
+	private function _add_registered_meta_boxes()
2120
+	{
2121
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2122
+		// we only add meta boxes if the page_route calls for it
2123
+		if (
2124
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2125
+			&& is_array(
2126
+				$this->_route_config['metaboxes']
2127
+			)
2128
+		) {
2129
+			// this simply loops through the callbacks provided
2130
+			// and checks if there is a corresponding callback registered by the child
2131
+			// if there is then we go ahead and process the metabox loader.
2132
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2133
+				// first check for Closures
2134
+				if ($metabox_callback instanceof Closure) {
2135
+					$result = $metabox_callback();
2136
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2137
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2138
+				} else {
2139
+					$result = call_user_func([$this, &$metabox_callback]);
2140
+				}
2141
+				if ($result === false) {
2142
+					// user error msg
2143
+					$error_msg = esc_html__(
2144
+						'An error occurred. The  requested metabox could not be found.',
2145
+						'event_espresso'
2146
+					);
2147
+					// developer error msg
2148
+					$error_msg .= '||'
2149
+								  . sprintf(
2150
+									  esc_html__(
2151
+										  '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.',
2152
+										  'event_espresso'
2153
+									  ),
2154
+									  $metabox_callback
2155
+								  );
2156
+					throw new EE_Error($error_msg);
2157
+				}
2158
+			}
2159
+		}
2160
+	}
2161
+
2162
+
2163
+	/**
2164
+	 * _add_screen_columns
2165
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2166
+	 * the dynamic column template and we'll setup the column options for the page.
2167
+	 *
2168
+	 * @return void
2169
+	 */
2170
+	private function _add_screen_columns()
2171
+	{
2172
+		if (
2173
+			is_array($this->_route_config)
2174
+			&& isset($this->_route_config['columns'])
2175
+			&& is_array($this->_route_config['columns'])
2176
+			&& count($this->_route_config['columns']) === 2
2177
+		) {
2178
+			add_screen_option(
2179
+				'layout_columns',
2180
+				[
2181
+					'max'     => (int) $this->_route_config['columns'][0],
2182
+					'default' => (int) $this->_route_config['columns'][1],
2183
+				]
2184
+			);
2185
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2186
+			$screen_id                                           = $this->_current_screen->id;
2187
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2188
+			$total_columns                                       = ! empty($screen_columns)
2189
+				? $screen_columns
2190
+				: $this->_route_config['columns'][1];
2191
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2192
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2193
+			$this->_template_args['screen']                      = $this->_current_screen;
2194
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2195
+																   . 'admin_details_metabox_column_wrapper.template.php';
2196
+			// finally if we don't have has_metaboxes set in the route config
2197
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2198
+			$this->_route_config['has_metaboxes'] = true;
2199
+		}
2200
+	}
2201
+
2202
+
2203
+
2204
+	/** GLOBALLY AVAILABLE METABOXES **/
2205
+
2206
+
2207
+	/**
2208
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2209
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2210
+	 * these get loaded on.
2211
+	 */
2212
+	private function _espresso_news_post_box()
2213
+	{
2214
+		$news_box_title = apply_filters(
2215
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2216
+			esc_html__('New @ Event Espresso', 'event_espresso')
2217
+		);
2218
+		add_meta_box(
2219
+			'espresso_news_post_box',
2220
+			$news_box_title,
2221
+			[
2222
+				$this,
2223
+				'espresso_news_post_box',
2224
+			],
2225
+			$this->_wp_page_slug,
2226
+			'side'
2227
+		);
2228
+	}
2229
+
2230
+
2231
+	/**
2232
+	 * Code for setting up espresso ratings request metabox.
2233
+	 */
2234
+	protected function _espresso_ratings_request()
2235
+	{
2236
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2237
+			return;
2238
+		}
2239
+		$ratings_box_title = apply_filters(
2240
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2241
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2242
+		);
2243
+		add_meta_box(
2244
+			'espresso_ratings_request',
2245
+			$ratings_box_title,
2246
+			[
2247
+				$this,
2248
+				'espresso_ratings_request',
2249
+			],
2250
+			$this->_wp_page_slug,
2251
+			'side'
2252
+		);
2253
+	}
2254
+
2255
+
2256
+	/**
2257
+	 * Code for setting up espresso ratings request metabox content.
2258
+	 *
2259
+	 * @throws DomainException
2260
+	 */
2261
+	public function espresso_ratings_request()
2262
+	{
2263
+		EEH_Template::display_template(
2264
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2265
+			[]
2266
+		);
2267
+	}
2268
+
2269
+
2270
+	public static function cached_rss_display($rss_id, $url)
2271
+	{
2272
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2273
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2274
+					 . '</p><p class="hide-if-js">'
2275
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2276
+					 . '</p>';
2277
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2278
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2279
+		$post      = '</div>' . "\n";
2280
+		$cache_key = 'ee_rss_' . md5($rss_id);
2281
+		$output    = get_transient($cache_key);
2282
+		if ($output !== false) {
2283
+			echo wp_kses($pre . $output . $post, AllowedTags::getWithFormTags());
2284
+			return true;
2285
+		}
2286
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2287
+			echo wp_kses($pre . $loading . $post, AllowedTags::getWithFormTags());
2288
+			return false;
2289
+		}
2290
+		ob_start();
2291
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2292
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2293
+		return true;
2294
+	}
2295
+
2296
+
2297
+	public function espresso_news_post_box()
2298
+	{
2299
+		?>
2300 2300
         <div class="padding">
2301 2301
             <div id="espresso_news_post_box_content" class="infolinks">
2302 2302
                 <?php
2303
-                // Get RSS Feed(s)
2304
-                self::cached_rss_display(
2305
-                    'espresso_news_post_box_content',
2306
-                    esc_url_raw(
2307
-                        apply_filters(
2308
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2309
-                            'https://eventespresso.com/feed/'
2310
-                        )
2311
-                    )
2312
-                );
2313
-                ?>
2303
+				// Get RSS Feed(s)
2304
+				self::cached_rss_display(
2305
+					'espresso_news_post_box_content',
2306
+					esc_url_raw(
2307
+						apply_filters(
2308
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2309
+							'https://eventespresso.com/feed/'
2310
+						)
2311
+					)
2312
+				);
2313
+				?>
2314 2314
             </div>
2315 2315
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2316 2316
         </div>
2317 2317
         <?php
2318
-    }
2319
-
2320
-
2321
-    private function _espresso_links_post_box()
2322
-    {
2323
-        // Hiding until we actually have content to put in here...
2324
-        // 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');
2325
-    }
2326
-
2327
-
2328
-    public function espresso_links_post_box()
2329
-    {
2330
-        // Hiding until we actually have content to put in here...
2331
-        // EEH_Template::display_template(
2332
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2333
-        // );
2334
-    }
2335
-
2336
-
2337
-    protected function _espresso_sponsors_post_box()
2338
-    {
2339
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2340
-            add_meta_box(
2341
-                'espresso_sponsors_post_box',
2342
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2343
-                [$this, 'espresso_sponsors_post_box'],
2344
-                $this->_wp_page_slug,
2345
-                'side'
2346
-            );
2347
-        }
2348
-    }
2349
-
2350
-
2351
-    public function espresso_sponsors_post_box()
2352
-    {
2353
-        EEH_Template::display_template(
2354
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2355
-        );
2356
-    }
2357
-
2358
-
2359
-    private function _publish_post_box()
2360
-    {
2361
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2362
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2363
-        // then we'll use that for the metabox label.
2364
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2365
-        if (! empty($this->_labels['publishbox'])) {
2366
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2367
-                : $this->_labels['publishbox'];
2368
-        } else {
2369
-            $box_label = esc_html__('Publish', 'event_espresso');
2370
-        }
2371
-        $box_label = apply_filters(
2372
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2373
-            $box_label,
2374
-            $this->_req_action,
2375
-            $this
2376
-        );
2377
-        add_meta_box(
2378
-            $meta_box_ref,
2379
-            $box_label,
2380
-            [$this, 'editor_overview'],
2381
-            $this->_current_screen->id,
2382
-            'side',
2383
-            'high'
2384
-        );
2385
-    }
2386
-
2387
-
2388
-    public function editor_overview()
2389
-    {
2390
-        // if we have extra content set let's add it in if not make sure its empty
2391
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2392
-            ? $this->_template_args['publish_box_extra_content']
2393
-            : '';
2394
-        echo EEH_Template::display_template(
2395
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2396
-            $this->_template_args,
2397
-            true
2398
-        );
2399
-    }
2400
-
2401
-
2402
-    /** end of globally available metaboxes section **/
2403
-
2404
-
2405
-    /**
2406
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2407
-     * protected method.
2408
-     *
2409
-     * @param string $name
2410
-     * @param int    $id
2411
-     * @param bool   $delete
2412
-     * @param string $save_close_redirect_URL
2413
-     * @param bool   $both_btns
2414
-     * @throws EE_Error
2415
-     * @throws InvalidArgumentException
2416
-     * @throws InvalidDataTypeException
2417
-     * @throws InvalidInterfaceException
2418
-     * @see   $this->_set_publish_post_box_vars for param details
2419
-     * @since 4.6.0
2420
-     */
2421
-    public function set_publish_post_box_vars(
2422
-        $name = '',
2423
-        $id = 0,
2424
-        $delete = false,
2425
-        $save_close_redirect_URL = '',
2426
-        $both_btns = true
2427
-    ) {
2428
-        $this->_set_publish_post_box_vars(
2429
-            $name,
2430
-            $id,
2431
-            $delete,
2432
-            $save_close_redirect_URL,
2433
-            $both_btns
2434
-        );
2435
-    }
2436
-
2437
-
2438
-    /**
2439
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2440
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2441
-     * save, and save and close buttons to work properly, then you will want to include a
2442
-     * values for the name and id arguments.
2443
-     *
2444
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2445
-     * @param int     $id                         id attached to the item published
2446
-     * @param string  $delete                     page route callback for the delete action
2447
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2448
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2449
-     *                                            the Save button
2450
-     * @throws EE_Error
2451
-     * @throws InvalidArgumentException
2452
-     * @throws InvalidDataTypeException
2453
-     * @throws InvalidInterfaceException
2454
-     * @todo  Add in validation for name/id arguments.
2455
-     */
2456
-    protected function _set_publish_post_box_vars(
2457
-        $name = '',
2458
-        $id = 0,
2459
-        $delete = '',
2460
-        $save_close_redirect_URL = '',
2461
-        $both_btns = true
2462
-    ) {
2463
-        // if Save & Close, use a custom redirect URL or default to the main page?
2464
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2465
-            ? $save_close_redirect_URL
2466
-            : $this->_admin_base_url;
2467
-        // create the Save & Close and Save buttons
2468
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2469
-        // if we have extra content set let's add it in if not make sure its empty
2470
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2471
-            ? $this->_template_args['publish_box_extra_content']
2472
-            : '';
2473
-        if ($delete && ! empty($id)) {
2474
-            // make sure we have a default if just true is sent.
2475
-            $delete           = ! empty($delete) ? $delete : 'delete';
2476
-            $delete_link_args = [$name => $id];
2477
-            $delete           = $this->get_action_link_or_button(
2478
-                $delete,
2479
-                $delete,
2480
-                $delete_link_args,
2481
-                'submitdelete deletion',
2482
-                '',
2483
-                false
2484
-            );
2485
-        }
2486
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2487
-        if (! empty($name) && ! empty($id)) {
2488
-            $hidden_field_arr[ $name ] = [
2489
-                'type'  => 'hidden',
2490
-                'value' => $id,
2491
-            ];
2492
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2493
-        } else {
2494
-            $hf = '';
2495
-        }
2496
-        // add hidden field
2497
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2498
-            ? $hf[ $name ]['field']
2499
-            : $hf;
2500
-    }
2501
-
2502
-
2503
-    /**
2504
-     * displays an error message to ppl who have javascript disabled
2505
-     *
2506
-     * @return void
2507
-     */
2508
-    private function _display_no_javascript_warning()
2509
-    {
2510
-        ?>
2318
+	}
2319
+
2320
+
2321
+	private function _espresso_links_post_box()
2322
+	{
2323
+		// Hiding until we actually have content to put in here...
2324
+		// 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');
2325
+	}
2326
+
2327
+
2328
+	public function espresso_links_post_box()
2329
+	{
2330
+		// Hiding until we actually have content to put in here...
2331
+		// EEH_Template::display_template(
2332
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2333
+		// );
2334
+	}
2335
+
2336
+
2337
+	protected function _espresso_sponsors_post_box()
2338
+	{
2339
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2340
+			add_meta_box(
2341
+				'espresso_sponsors_post_box',
2342
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2343
+				[$this, 'espresso_sponsors_post_box'],
2344
+				$this->_wp_page_slug,
2345
+				'side'
2346
+			);
2347
+		}
2348
+	}
2349
+
2350
+
2351
+	public function espresso_sponsors_post_box()
2352
+	{
2353
+		EEH_Template::display_template(
2354
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2355
+		);
2356
+	}
2357
+
2358
+
2359
+	private function _publish_post_box()
2360
+	{
2361
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2362
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2363
+		// then we'll use that for the metabox label.
2364
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2365
+		if (! empty($this->_labels['publishbox'])) {
2366
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2367
+				: $this->_labels['publishbox'];
2368
+		} else {
2369
+			$box_label = esc_html__('Publish', 'event_espresso');
2370
+		}
2371
+		$box_label = apply_filters(
2372
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2373
+			$box_label,
2374
+			$this->_req_action,
2375
+			$this
2376
+		);
2377
+		add_meta_box(
2378
+			$meta_box_ref,
2379
+			$box_label,
2380
+			[$this, 'editor_overview'],
2381
+			$this->_current_screen->id,
2382
+			'side',
2383
+			'high'
2384
+		);
2385
+	}
2386
+
2387
+
2388
+	public function editor_overview()
2389
+	{
2390
+		// if we have extra content set let's add it in if not make sure its empty
2391
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2392
+			? $this->_template_args['publish_box_extra_content']
2393
+			: '';
2394
+		echo EEH_Template::display_template(
2395
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2396
+			$this->_template_args,
2397
+			true
2398
+		);
2399
+	}
2400
+
2401
+
2402
+	/** end of globally available metaboxes section **/
2403
+
2404
+
2405
+	/**
2406
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2407
+	 * protected method.
2408
+	 *
2409
+	 * @param string $name
2410
+	 * @param int    $id
2411
+	 * @param bool   $delete
2412
+	 * @param string $save_close_redirect_URL
2413
+	 * @param bool   $both_btns
2414
+	 * @throws EE_Error
2415
+	 * @throws InvalidArgumentException
2416
+	 * @throws InvalidDataTypeException
2417
+	 * @throws InvalidInterfaceException
2418
+	 * @see   $this->_set_publish_post_box_vars for param details
2419
+	 * @since 4.6.0
2420
+	 */
2421
+	public function set_publish_post_box_vars(
2422
+		$name = '',
2423
+		$id = 0,
2424
+		$delete = false,
2425
+		$save_close_redirect_URL = '',
2426
+		$both_btns = true
2427
+	) {
2428
+		$this->_set_publish_post_box_vars(
2429
+			$name,
2430
+			$id,
2431
+			$delete,
2432
+			$save_close_redirect_URL,
2433
+			$both_btns
2434
+		);
2435
+	}
2436
+
2437
+
2438
+	/**
2439
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2440
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2441
+	 * save, and save and close buttons to work properly, then you will want to include a
2442
+	 * values for the name and id arguments.
2443
+	 *
2444
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2445
+	 * @param int     $id                         id attached to the item published
2446
+	 * @param string  $delete                     page route callback for the delete action
2447
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2448
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2449
+	 *                                            the Save button
2450
+	 * @throws EE_Error
2451
+	 * @throws InvalidArgumentException
2452
+	 * @throws InvalidDataTypeException
2453
+	 * @throws InvalidInterfaceException
2454
+	 * @todo  Add in validation for name/id arguments.
2455
+	 */
2456
+	protected function _set_publish_post_box_vars(
2457
+		$name = '',
2458
+		$id = 0,
2459
+		$delete = '',
2460
+		$save_close_redirect_URL = '',
2461
+		$both_btns = true
2462
+	) {
2463
+		// if Save & Close, use a custom redirect URL or default to the main page?
2464
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2465
+			? $save_close_redirect_URL
2466
+			: $this->_admin_base_url;
2467
+		// create the Save & Close and Save buttons
2468
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2469
+		// if we have extra content set let's add it in if not make sure its empty
2470
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2471
+			? $this->_template_args['publish_box_extra_content']
2472
+			: '';
2473
+		if ($delete && ! empty($id)) {
2474
+			// make sure we have a default if just true is sent.
2475
+			$delete           = ! empty($delete) ? $delete : 'delete';
2476
+			$delete_link_args = [$name => $id];
2477
+			$delete           = $this->get_action_link_or_button(
2478
+				$delete,
2479
+				$delete,
2480
+				$delete_link_args,
2481
+				'submitdelete deletion',
2482
+				'',
2483
+				false
2484
+			);
2485
+		}
2486
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2487
+		if (! empty($name) && ! empty($id)) {
2488
+			$hidden_field_arr[ $name ] = [
2489
+				'type'  => 'hidden',
2490
+				'value' => $id,
2491
+			];
2492
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2493
+		} else {
2494
+			$hf = '';
2495
+		}
2496
+		// add hidden field
2497
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2498
+			? $hf[ $name ]['field']
2499
+			: $hf;
2500
+	}
2501
+
2502
+
2503
+	/**
2504
+	 * displays an error message to ppl who have javascript disabled
2505
+	 *
2506
+	 * @return void
2507
+	 */
2508
+	private function _display_no_javascript_warning()
2509
+	{
2510
+		?>
2511 2511
         <noscript>
2512 2512
             <div id="no-js-message" class="error">
2513 2513
                 <p style="font-size:1.3em;">
2514 2514
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2515 2515
                     <?php esc_html_e(
2516
-                        '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.',
2517
-                        'event_espresso'
2518
-                    ); ?>
2516
+						'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.',
2517
+						'event_espresso'
2518
+					); ?>
2519 2519
                 </p>
2520 2520
             </div>
2521 2521
         </noscript>
2522 2522
         <?php
2523
-    }
2524
-
2525
-
2526
-    /**
2527
-     * displays espresso success and/or error notices
2528
-     *
2529
-     * @return void
2530
-     */
2531
-    protected function _display_espresso_notices()
2532
-    {
2533
-        $notices = $this->_get_transient(true);
2534
-        echo stripslashes($notices);
2535
-    }
2536
-
2537
-
2538
-    /**
2539
-     * spinny things pacify the masses
2540
-     *
2541
-     * @return void
2542
-     */
2543
-    protected function _add_admin_page_ajax_loading_img()
2544
-    {
2545
-        ?>
2523
+	}
2524
+
2525
+
2526
+	/**
2527
+	 * displays espresso success and/or error notices
2528
+	 *
2529
+	 * @return void
2530
+	 */
2531
+	protected function _display_espresso_notices()
2532
+	{
2533
+		$notices = $this->_get_transient(true);
2534
+		echo stripslashes($notices);
2535
+	}
2536
+
2537
+
2538
+	/**
2539
+	 * spinny things pacify the masses
2540
+	 *
2541
+	 * @return void
2542
+	 */
2543
+	protected function _add_admin_page_ajax_loading_img()
2544
+	{
2545
+		?>
2546 2546
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2547 2547
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2548
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2548
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2549 2549
         </div>
2550 2550
         <?php
2551
-    }
2551
+	}
2552 2552
 
2553 2553
 
2554
-    /**
2555
-     * add admin page overlay for modal boxes
2556
-     *
2557
-     * @return void
2558
-     */
2559
-    protected function _add_admin_page_overlay()
2560
-    {
2561
-        ?>
2554
+	/**
2555
+	 * add admin page overlay for modal boxes
2556
+	 *
2557
+	 * @return void
2558
+	 */
2559
+	protected function _add_admin_page_overlay()
2560
+	{
2561
+		?>
2562 2562
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2563 2563
         <?php
2564
-    }
2565
-
2566
-
2567
-    /**
2568
-     * facade for add_meta_box
2569
-     *
2570
-     * @param string  $action        where the metabox gets displayed
2571
-     * @param string  $title         Title of Metabox (output in metabox header)
2572
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2573
-     *                               instead of the one created in here.
2574
-     * @param array   $callback_args an array of args supplied for the metabox
2575
-     * @param string  $column        what metabox column
2576
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2577
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2578
-     *                               created but just set our own callback for wp's add_meta_box.
2579
-     * @throws DomainException
2580
-     */
2581
-    public function _add_admin_page_meta_box(
2582
-        $action,
2583
-        $title,
2584
-        $callback,
2585
-        $callback_args,
2586
-        $column = 'normal',
2587
-        $priority = 'high',
2588
-        $create_func = true
2589
-    ) {
2590
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2591
-        // 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.
2592
-        if (empty($callback_args) && $create_func) {
2593
-            $callback_args = [
2594
-                'template_path' => $this->_template_path,
2595
-                'template_args' => $this->_template_args,
2596
-            ];
2597
-        }
2598
-        // 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)
2599
-        $call_back_func = $create_func
2600
-            ? function ($post, $metabox) {
2601
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2602
-                echo EEH_Template::display_template(
2603
-                    $metabox['args']['template_path'],
2604
-                    $metabox['args']['template_args'],
2605
-                    true
2606
-                );
2607
-            }
2608
-            : $callback;
2609
-        add_meta_box(
2610
-            str_replace('_', '-', $action) . '-mbox',
2611
-            $title,
2612
-            $call_back_func,
2613
-            $this->_wp_page_slug,
2614
-            $column,
2615
-            $priority,
2616
-            $callback_args
2617
-        );
2618
-    }
2619
-
2620
-
2621
-    /**
2622
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2623
-     *
2624
-     * @throws DomainException
2625
-     * @throws EE_Error
2626
-     */
2627
-    public function display_admin_page_with_metabox_columns()
2628
-    {
2629
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2630
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2631
-            $this->_column_template_path,
2632
-            $this->_template_args,
2633
-            true
2634
-        );
2635
-        // the final wrapper
2636
-        $this->admin_page_wrapper();
2637
-    }
2638
-
2639
-
2640
-    /**
2641
-     * generates  HTML wrapper for an admin details page
2642
-     *
2643
-     * @return void
2644
-     * @throws EE_Error
2645
-     * @throws DomainException
2646
-     */
2647
-    public function display_admin_page_with_sidebar()
2648
-    {
2649
-        $this->_display_admin_page(true);
2650
-    }
2651
-
2652
-
2653
-    /**
2654
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2655
-     *
2656
-     * @return void
2657
-     * @throws EE_Error
2658
-     * @throws DomainException
2659
-     */
2660
-    public function display_admin_page_with_no_sidebar()
2661
-    {
2662
-        $this->_display_admin_page();
2663
-    }
2664
-
2665
-
2666
-    /**
2667
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2668
-     *
2669
-     * @return void
2670
-     * @throws EE_Error
2671
-     * @throws DomainException
2672
-     */
2673
-    public function display_about_admin_page()
2674
-    {
2675
-        $this->_display_admin_page(false, true);
2676
-    }
2677
-
2678
-
2679
-    /**
2680
-     * display_admin_page
2681
-     * contains the code for actually displaying an admin page
2682
-     *
2683
-     * @param boolean $sidebar true with sidebar, false without
2684
-     * @param boolean $about   use the about_admin_wrapper instead of the default.
2685
-     * @return void
2686
-     * @throws DomainException
2687
-     * @throws EE_Error
2688
-     */
2689
-    private function _display_admin_page($sidebar = false, $about = false)
2690
-    {
2691
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2692
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2693
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2694
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2695
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2696
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2697
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2698
-            ? 'poststuff'
2699
-            : 'espresso-default-admin';
2700
-        $template_path                                     = $sidebar
2701
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2702
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2703
-        if ($this->request->isAjax()) {
2704
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2705
-        }
2706
-        $template_path                                     = ! empty($this->_column_template_path)
2707
-            ? $this->_column_template_path : $template_path;
2708
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2709
-            ? $this->_template_args['admin_page_content']
2710
-            : '';
2711
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2712
-            ? $this->_template_args['before_admin_page_content']
2713
-            : '';
2714
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2715
-            ? $this->_template_args['after_admin_page_content']
2716
-            : '';
2717
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2718
-            $template_path,
2719
-            $this->_template_args,
2720
-            true
2721
-        );
2722
-        // the final template wrapper
2723
-        $this->admin_page_wrapper($about);
2724
-    }
2725
-
2726
-
2727
-    /**
2728
-     * This is used to display caf preview pages.
2729
-     *
2730
-     * @param string $utm_campaign_source what is the key used for google analytics link
2731
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2732
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2733
-     * @return void
2734
-     * @throws DomainException
2735
-     * @throws EE_Error
2736
-     * @throws InvalidArgumentException
2737
-     * @throws InvalidDataTypeException
2738
-     * @throws InvalidInterfaceException
2739
-     * @since 4.3.2
2740
-     */
2741
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2742
-    {
2743
-        // let's generate a default preview action button if there isn't one already present.
2744
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2745
-            'Upgrade to Event Espresso 4 Right Now',
2746
-            'event_espresso'
2747
-        );
2748
-        $buy_now_url                                   = add_query_arg(
2749
-            [
2750
-                'ee_ver'       => 'ee4',
2751
-                'utm_source'   => 'ee4_plugin_admin',
2752
-                'utm_medium'   => 'link',
2753
-                'utm_campaign' => $utm_campaign_source,
2754
-                'utm_content'  => 'buy_now_button',
2755
-            ],
2756
-            'https://eventespresso.com/pricing/'
2757
-        );
2758
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2759
-            ? $this->get_action_link_or_button(
2760
-                '',
2761
-                'buy_now',
2762
-                [],
2763
-                'button-primary button-large',
2764
-                esc_url_raw($buy_now_url),
2765
-                true
2766
-            )
2767
-            : $this->_template_args['preview_action_button'];
2768
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2769
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2770
-            $this->_template_args,
2771
-            true
2772
-        );
2773
-        $this->_display_admin_page($display_sidebar);
2774
-    }
2775
-
2776
-
2777
-    /**
2778
-     * display_admin_list_table_page_with_sidebar
2779
-     * generates HTML wrapper for an admin_page with list_table
2780
-     *
2781
-     * @return void
2782
-     * @throws EE_Error
2783
-     * @throws DomainException
2784
-     */
2785
-    public function display_admin_list_table_page_with_sidebar()
2786
-    {
2787
-        $this->_display_admin_list_table_page(true);
2788
-    }
2789
-
2790
-
2791
-    /**
2792
-     * display_admin_list_table_page_with_no_sidebar
2793
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2794
-     *
2795
-     * @return void
2796
-     * @throws EE_Error
2797
-     * @throws DomainException
2798
-     */
2799
-    public function display_admin_list_table_page_with_no_sidebar()
2800
-    {
2801
-        $this->_display_admin_list_table_page();
2802
-    }
2803
-
2804
-
2805
-    /**
2806
-     * generates html wrapper for an admin_list_table page
2807
-     *
2808
-     * @param boolean $sidebar whether to display with sidebar or not.
2809
-     * @return void
2810
-     * @throws DomainException
2811
-     * @throws EE_Error
2812
-     */
2813
-    private function _display_admin_list_table_page($sidebar = false)
2814
-    {
2815
-        // setup search attributes
2816
-        $this->_set_search_attributes();
2817
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
2818
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2819
-        $this->_template_args['table_url']        = $this->request->isAjax()
2820
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2821
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2822
-        $this->_template_args['list_table']       = $this->_list_table_object;
2823
-        $this->_template_args['current_route']    = $this->_req_action;
2824
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2825
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2826
-        if (! empty($ajax_sorting_callback)) {
2827
-            $sortable_list_table_form_fields = wp_nonce_field(
2828
-                $ajax_sorting_callback . '_nonce',
2829
-                $ajax_sorting_callback . '_nonce',
2830
-                false,
2831
-                false
2832
-            );
2833
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2834
-                                                . $this->page_slug
2835
-                                                . '" />';
2836
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2837
-                                                . $ajax_sorting_callback
2838
-                                                . '" />';
2839
-        } else {
2840
-            $sortable_list_table_form_fields = '';
2841
-        }
2842
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2843
-        $hidden_form_fields                                      =
2844
-            isset($this->_template_args['list_table_hidden_fields'])
2845
-                ? $this->_template_args['list_table_hidden_fields']
2846
-                : '';
2847
-        $nonce_ref                                               = $this->_req_action . '_nonce';
2848
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
2849
-                                                                    . $nonce_ref
2850
-                                                                    . '" value="'
2851
-                                                                    . wp_create_nonce($nonce_ref)
2852
-                                                                    . '">';
2853
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2854
-        // display message about search results?
2855
-        $search = $this->request->getRequestParam('s');
2856
-        $this->_template_args['before_list_table'] .= ! empty($search)
2857
-            ? '<p class="ee-search-results">' . sprintf(
2858
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2859
-                trim($search, '%')
2860
-            ) . '</p>'
2861
-            : '';
2862
-        // filter before_list_table template arg
2863
-        $this->_template_args['before_list_table'] = apply_filters(
2864
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2865
-            $this->_template_args['before_list_table'],
2866
-            $this->page_slug,
2867
-            $this->request->requestParams(),
2868
-            $this->_req_action
2869
-        );
2870
-        // convert to array and filter again
2871
-        // arrays are easier to inject new items in a specific location,
2872
-        // but would not be backwards compatible, so we have to add a new filter
2873
-        $this->_template_args['before_list_table'] = implode(
2874
-            " \n",
2875
-            (array) apply_filters(
2876
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2877
-                (array) $this->_template_args['before_list_table'],
2878
-                $this->page_slug,
2879
-                $this->request->requestParams(),
2880
-                $this->_req_action
2881
-            )
2882
-        );
2883
-        // filter after_list_table template arg
2884
-        $this->_template_args['after_list_table'] = apply_filters(
2885
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2886
-            $this->_template_args['after_list_table'],
2887
-            $this->page_slug,
2888
-            $this->request->requestParams(),
2889
-            $this->_req_action
2890
-        );
2891
-        // convert to array and filter again
2892
-        // arrays are easier to inject new items in a specific location,
2893
-        // but would not be backwards compatible, so we have to add a new filter
2894
-        $this->_template_args['after_list_table']   = implode(
2895
-            " \n",
2896
-            (array) apply_filters(
2897
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2898
-                (array) $this->_template_args['after_list_table'],
2899
-                $this->page_slug,
2900
-                $this->request->requestParams(),
2901
-                $this->_req_action
2902
-            )
2903
-        );
2904
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2905
-            $template_path,
2906
-            $this->_template_args,
2907
-            true
2908
-        );
2909
-        // the final template wrapper
2910
-        if ($sidebar) {
2911
-            $this->display_admin_page_with_sidebar();
2912
-        } else {
2913
-            $this->display_admin_page_with_no_sidebar();
2914
-        }
2915
-    }
2916
-
2917
-
2918
-    /**
2919
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2920
-     * html string for the legend.
2921
-     * $items are expected in an array in the following format:
2922
-     * $legend_items = array(
2923
-     *        'item_id' => array(
2924
-     *            'icon' => 'http://url_to_icon_being_described.png',
2925
-     *            'desc' => esc_html__('localized description of item');
2926
-     *        )
2927
-     * );
2928
-     *
2929
-     * @param array $items see above for format of array
2930
-     * @return string html string of legend
2931
-     * @throws DomainException
2932
-     */
2933
-    protected function _display_legend($items)
2934
-    {
2935
-        $this->_template_args['items'] = apply_filters(
2936
-            'FHEE__EE_Admin_Page___display_legend__items',
2937
-            (array) $items,
2938
-            $this
2939
-        );
2940
-        return EEH_Template::display_template(
2941
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2942
-            $this->_template_args,
2943
-            true
2944
-        );
2945
-    }
2946
-
2947
-
2948
-    /**
2949
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2950
-     * The returned json object is created from an array in the following format:
2951
-     * array(
2952
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2953
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
2954
-     *  'notices' => '', // - contains any EE_Error formatted notices
2955
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
2956
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
2957
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
2958
-     *  that might be included in here)
2959
-     * )
2960
-     * The json object is populated by whatever is set in the $_template_args property.
2961
-     *
2962
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
2963
-     *                                 instead of displayed.
2964
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
2965
-     * @return void
2966
-     * @throws EE_Error
2967
-     */
2968
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
2969
-    {
2970
-        // make sure any EE_Error notices have been handled.
2971
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
2972
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
2973
-        unset($this->_template_args['data']);
2974
-        $json = [
2975
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2976
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2977
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2978
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2979
-            'notices'   => EE_Error::get_notices(),
2980
-            'content'   => isset($this->_template_args['admin_page_content'])
2981
-                ? $this->_template_args['admin_page_content'] : '',
2982
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
2983
-            'isEEajax'  => true
2984
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2985
-        ];
2986
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
2987
-        if (null === error_get_last() || ! headers_sent()) {
2988
-            header('Content-Type: application/json; charset=UTF-8');
2989
-        }
2990
-        echo wp_json_encode($json);
2991
-        exit();
2992
-    }
2993
-
2994
-
2995
-    /**
2996
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2997
-     *
2998
-     * @return void
2999
-     * @throws EE_Error
3000
-     */
3001
-    public function return_json()
3002
-    {
3003
-        if ($this->request->isAjax()) {
3004
-            $this->_return_json();
3005
-        } else {
3006
-            throw new EE_Error(
3007
-                sprintf(
3008
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3009
-                    __FUNCTION__
3010
-                )
3011
-            );
3012
-        }
3013
-    }
3014
-
3015
-
3016
-    /**
3017
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3018
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3019
-     *
3020
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3021
-     */
3022
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3023
-    {
3024
-        $this->_hook_obj = $hook_obj;
3025
-    }
3026
-
3027
-
3028
-    /**
3029
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3030
-     *
3031
-     * @param boolean $about whether to use the special about page wrapper or default.
3032
-     * @return void
3033
-     * @throws DomainException
3034
-     * @throws EE_Error
3035
-     */
3036
-    public function admin_page_wrapper($about = false)
3037
-    {
3038
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3039
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3040
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3041
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3042
-
3043
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3044
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3045
-            isset($this->_template_args['before_admin_page_content'])
3046
-                ? $this->_template_args['before_admin_page_content']
3047
-                : ''
3048
-        );
3049
-
3050
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3051
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3052
-            isset($this->_template_args['after_admin_page_content'])
3053
-                ? $this->_template_args['after_admin_page_content']
3054
-                : ''
3055
-        );
3056
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3057
-
3058
-        if ($this->request->isAjax()) {
3059
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3060
-                // $template_path,
3061
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3062
-                $this->_template_args,
3063
-                true
3064
-            );
3065
-            $this->_return_json();
3066
-        }
3067
-        // load settings page wrapper template
3068
-        $template_path = $about
3069
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3070
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3071
-
3072
-        EEH_Template::display_template($template_path, $this->_template_args);
3073
-    }
3074
-
3075
-
3076
-    /**
3077
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3078
-     *
3079
-     * @return string html
3080
-     * @throws EE_Error
3081
-     */
3082
-    protected function _get_main_nav_tabs()
3083
-    {
3084
-        // let's generate the html using the EEH_Tabbed_Content helper.
3085
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3086
-        // (rather than setting in the page_routes array)
3087
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3088
-    }
3089
-
3090
-
3091
-    /**
3092
-     *        sort nav tabs
3093
-     *
3094
-     * @param $a
3095
-     * @param $b
3096
-     * @return int
3097
-     */
3098
-    private function _sort_nav_tabs($a, $b)
3099
-    {
3100
-        if ($a['order'] === $b['order']) {
3101
-            return 0;
3102
-        }
3103
-        return ($a['order'] < $b['order']) ? -1 : 1;
3104
-    }
3105
-
3106
-
3107
-    /**
3108
-     *    generates HTML for the forms used on admin pages
3109
-     *
3110
-     * @param array  $input_vars   - array of input field details
3111
-     * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3112
-     *                             use)
3113
-     * @param bool   $id
3114
-     * @return array|string
3115
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3116
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3117
-     */
3118
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3119
-    {
3120
-        return $generator === 'string'
3121
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3122
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3123
-    }
3124
-
3125
-
3126
-    /**
3127
-     * generates the "Save" and "Save & Close" buttons for edit forms
3128
-     *
3129
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3130
-     *                                   Close" button.
3131
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3132
-     *                                   'Save', [1] => 'save & close')
3133
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3134
-     *                                   via the "name" value in the button).  We can also use this to just dump
3135
-     *                                   default actions by submitting some other value.
3136
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3137
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3138
-     *                                   close (normal form handling).
3139
-     */
3140
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3141
-    {
3142
-        // make sure $text and $actions are in an array
3143
-        $text          = (array) $text;
3144
-        $actions       = (array) $actions;
3145
-        $referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3146
-        $button_text   = ! empty($text)
3147
-            ? $text
3148
-            : [
3149
-                esc_html__('Save', 'event_espresso'),
3150
-                esc_html__('Save and Close', 'event_espresso'),
3151
-            ];
3152
-        $default_names = ['save', 'save_and_close'];
3153
-        $buttons = '';
3154
-        foreach ($button_text as $key => $button) {
3155
-            $ref     = $default_names[ $key ];
3156
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3157
-            $buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3158
-                        . 'value="' . $button . '" name="' . $name . '" '
3159
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3160
-            if (! $both) {
3161
-                break;
3162
-            }
3163
-        }
3164
-        // add in a hidden index for the current page (so save and close redirects properly)
3165
-        $buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3166
-                   . $referrer_url
3167
-                   . '" />';
3168
-        $this->_template_args['save_buttons'] = $buttons;
3169
-    }
3170
-
3171
-
3172
-    /**
3173
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3174
-     *
3175
-     * @param string $route
3176
-     * @param array  $additional_hidden_fields
3177
-     * @see   $this->_set_add_edit_form_tags() for details on params
3178
-     * @since 4.6.0
3179
-     */
3180
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3181
-    {
3182
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3183
-    }
3184
-
3185
-
3186
-    /**
3187
-     * set form open and close tags on add/edit pages.
3188
-     *
3189
-     * @param string $route                    the route you want the form to direct to
3190
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3191
-     * @return void
3192
-     */
3193
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3194
-    {
3195
-        if (empty($route)) {
3196
-            $user_msg = esc_html__(
3197
-                'An error occurred. No action was set for this page\'s form.',
3198
-                'event_espresso'
3199
-            );
3200
-            $dev_msg  = $user_msg . "\n"
3201
-                        . sprintf(
3202
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3203
-                            __FUNCTION__,
3204
-                            __CLASS__
3205
-                        );
3206
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3207
-        }
3208
-        // open form
3209
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3210
-                                                             . $this->_admin_base_url
3211
-                                                             . '" id="'
3212
-                                                             . $route
3213
-                                                             . '_event_form" >';
3214
-        // add nonce
3215
-        $nonce                                             =
3216
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3217
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3218
-        // add REQUIRED form action
3219
-        $hidden_fields = [
3220
-            'action' => ['type' => 'hidden', 'value' => $route],
3221
-        ];
3222
-        // merge arrays
3223
-        $hidden_fields = is_array($additional_hidden_fields)
3224
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3225
-            : $hidden_fields;
3226
-        // generate form fields
3227
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3228
-        // add fields to form
3229
-        foreach ((array) $form_fields as $form_field) {
3230
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3231
-        }
3232
-        // close form
3233
-        $this->_template_args['after_admin_page_content'] = '</form>';
3234
-    }
3235
-
3236
-
3237
-    /**
3238
-     * Public Wrapper for _redirect_after_action() method since its
3239
-     * discovered it would be useful for external code to have access.
3240
-     *
3241
-     * @param bool   $success
3242
-     * @param string $what
3243
-     * @param string $action_desc
3244
-     * @param array  $query_args
3245
-     * @param bool   $override_overwrite
3246
-     * @throws EE_Error
3247
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3248
-     * @since 4.5.0
3249
-     */
3250
-    public function redirect_after_action(
3251
-        $success = false,
3252
-        $what = 'item',
3253
-        $action_desc = 'processed',
3254
-        $query_args = [],
3255
-        $override_overwrite = false
3256
-    ) {
3257
-        $this->_redirect_after_action(
3258
-            $success,
3259
-            $what,
3260
-            $action_desc,
3261
-            $query_args,
3262
-            $override_overwrite
3263
-        );
3264
-    }
3265
-
3266
-
3267
-    /**
3268
-     * Helper method for merging existing request data with the returned redirect url.
3269
-     *
3270
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3271
-     * filters are still applied.
3272
-     *
3273
-     * @param array $new_route_data
3274
-     * @return array
3275
-     */
3276
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3277
-    {
3278
-        foreach ($this->request->requestParams() as $ref => $value) {
3279
-            // unset nonces
3280
-            if (strpos($ref, 'nonce') !== false) {
3281
-                $this->request->unSetRequestParam($ref);
3282
-                continue;
3283
-            }
3284
-            // urlencode values.
3285
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3286
-            $this->request->setRequestParam($ref, $value);
3287
-        }
3288
-        return array_merge($this->request->requestParams(), $new_route_data);
3289
-    }
3290
-
3291
-
3292
-    /**
3293
-     *    _redirect_after_action
3294
-     *
3295
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3296
-     * @param string $what               - what the action was performed on
3297
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3298
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3299
-     *                                   action is completed
3300
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3301
-     *                                   override this so that they show.
3302
-     * @return void
3303
-     * @throws EE_Error
3304
-     */
3305
-    protected function _redirect_after_action(
3306
-        $success = 0,
3307
-        $what = 'item',
3308
-        $action_desc = 'processed',
3309
-        $query_args = [],
3310
-        $override_overwrite = false
3311
-    ) {
3312
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3313
-        // class name for actions/filters.
3314
-        $classname = get_class($this);
3315
-        // set redirect url.
3316
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3317
-        // otherwise we go with whatever is set as the _admin_base_url
3318
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3319
-        $notices      = EE_Error::get_notices(false);
3320
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3321
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3322
-            EE_Error::overwrite_success();
3323
-        }
3324
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3325
-            // how many records affected ? more than one record ? or just one ?
3326
-            if ($success > 1) {
3327
-                // set plural msg
3328
-                EE_Error::add_success(
3329
-                    sprintf(
3330
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3331
-                        $what,
3332
-                        $action_desc
3333
-                    ),
3334
-                    __FILE__,
3335
-                    __FUNCTION__,
3336
-                    __LINE__
3337
-                );
3338
-            } elseif ($success === 1) {
3339
-                // set singular msg
3340
-                EE_Error::add_success(
3341
-                    sprintf(
3342
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3343
-                        $what,
3344
-                        $action_desc
3345
-                    ),
3346
-                    __FILE__,
3347
-                    __FUNCTION__,
3348
-                    __LINE__
3349
-                );
3350
-            }
3351
-        }
3352
-        // check that $query_args isn't something crazy
3353
-        if (! is_array($query_args)) {
3354
-            $query_args = [];
3355
-        }
3356
-        /**
3357
-         * Allow injecting actions before the query_args are modified for possible different
3358
-         * redirections on save and close actions
3359
-         *
3360
-         * @param array $query_args       The original query_args array coming into the
3361
-         *                                method.
3362
-         * @since 4.2.0
3363
-         */
3364
-        do_action(
3365
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3366
-            $query_args
3367
-        );
3368
-        // calculate where we're going (if we have a "save and close" button pushed)
3369
-
3370
-        if (
3371
-            $this->request->requestParamIsSet('save_and_close')
3372
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3373
-        ) {
3374
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3375
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3376
-            // regenerate query args array from referrer URL
3377
-            parse_str($parsed_url['query'], $query_args);
3378
-            // correct page and action will be in the query args now
3379
-            $redirect_url = admin_url('admin.php');
3380
-        }
3381
-        // merge any default query_args set in _default_route_query_args property
3382
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3383
-            $args_to_merge = [];
3384
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3385
-                // is there a wp_referer array in our _default_route_query_args property?
3386
-                if ($query_param === 'wp_referer') {
3387
-                    $query_value = (array) $query_value;
3388
-                    foreach ($query_value as $reference => $value) {
3389
-                        if (strpos($reference, 'nonce') !== false) {
3390
-                            continue;
3391
-                        }
3392
-                        // finally we will override any arguments in the referer with
3393
-                        // what might be set on the _default_route_query_args array.
3394
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3395
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3396
-                        } else {
3397
-                            $args_to_merge[ $reference ] = urlencode($value);
3398
-                        }
3399
-                    }
3400
-                    continue;
3401
-                }
3402
-                $args_to_merge[ $query_param ] = $query_value;
3403
-            }
3404
-            // now let's merge these arguments but override with what was specifically sent in to the
3405
-            // redirect.
3406
-            $query_args = array_merge($args_to_merge, $query_args);
3407
-        }
3408
-        $this->_process_notices($query_args);
3409
-        // generate redirect url
3410
-        // if redirecting to anything other than the main page, add a nonce
3411
-        if (isset($query_args['action'])) {
3412
-            // manually generate wp_nonce and merge that with the query vars
3413
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3414
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3415
-        }
3416
-        // we're adding some hooks and filters in here for processing any things just before redirects
3417
-        // (example: an admin page has done an insert or update and we want to run something after that).
3418
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3419
-        $redirect_url = apply_filters(
3420
-            'FHEE_redirect_' . $classname . $this->_req_action,
3421
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3422
-            $query_args
3423
-        );
3424
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3425
-        if ($this->request->isAjax()) {
3426
-            $default_data                    = [
3427
-                'close'        => true,
3428
-                'redirect_url' => $redirect_url,
3429
-                'where'        => 'main',
3430
-                'what'         => 'append',
3431
-            ];
3432
-            $this->_template_args['success'] = $success;
3433
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3434
-                $default_data,
3435
-                $this->_template_args['data']
3436
-            ) : $default_data;
3437
-            $this->_return_json();
3438
-        }
3439
-        wp_safe_redirect($redirect_url);
3440
-        exit();
3441
-    }
3442
-
3443
-
3444
-    /**
3445
-     * process any notices before redirecting (or returning ajax request)
3446
-     * This method sets the $this->_template_args['notices'] attribute;
3447
-     *
3448
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3449
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3450
-     *                                  page_routes haven't been defined yet.
3451
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3452
-     *                                  still save a transient for the notice.
3453
-     * @return void
3454
-     * @throws EE_Error
3455
-     */
3456
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3457
-    {
3458
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3459
-        if ($this->request->isAjax()) {
3460
-            $notices = EE_Error::get_notices(false);
3461
-            if (empty($this->_template_args['success'])) {
3462
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3463
-            }
3464
-            if (empty($this->_template_args['errors'])) {
3465
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3466
-            }
3467
-            if (empty($this->_template_args['attention'])) {
3468
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3469
-            }
3470
-        }
3471
-        $this->_template_args['notices'] = EE_Error::get_notices();
3472
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3473
-        if (! $this->request->isAjax() || $sticky_notices) {
3474
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3475
-            $this->_add_transient(
3476
-                $route,
3477
-                $this->_template_args['notices'],
3478
-                true,
3479
-                $skip_route_verify
3480
-            );
3481
-        }
3482
-    }
3483
-
3484
-
3485
-    /**
3486
-     * get_action_link_or_button
3487
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3488
-     *
3489
-     * @param string $action        use this to indicate which action the url is generated with.
3490
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3491
-     *                              property.
3492
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3493
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3494
-     * @param string $base_url      If this is not provided
3495
-     *                              the _admin_base_url will be used as the default for the button base_url.
3496
-     *                              Otherwise this value will be used.
3497
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3498
-     * @return string
3499
-     * @throws InvalidArgumentException
3500
-     * @throws InvalidInterfaceException
3501
-     * @throws InvalidDataTypeException
3502
-     * @throws EE_Error
3503
-     */
3504
-    public function get_action_link_or_button(
3505
-        $action,
3506
-        $type = 'add',
3507
-        $extra_request = [],
3508
-        $class = 'button button--primary',
3509
-        $base_url = '',
3510
-        $exclude_nonce = false
3511
-    ) {
3512
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3513
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3514
-            throw new EE_Error(
3515
-                sprintf(
3516
-                    esc_html__(
3517
-                        'There is no page route for given action for the button.  This action was given: %s',
3518
-                        'event_espresso'
3519
-                    ),
3520
-                    $action
3521
-                )
3522
-            );
3523
-        }
3524
-        if (! isset($this->_labels['buttons'][ $type ])) {
3525
-            throw new EE_Error(
3526
-                sprintf(
3527
-                    esc_html__(
3528
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3529
-                        'event_espresso'
3530
-                    ),
3531
-                    $type
3532
-                )
3533
-            );
3534
-        }
3535
-        // finally check user access for this button.
3536
-        $has_access = $this->check_user_access($action, true);
3537
-        if (! $has_access) {
3538
-            return '';
3539
-        }
3540
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3541
-        $query_args = [
3542
-            'action' => $action,
3543
-        ];
3544
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3545
-        if (! empty($extra_request)) {
3546
-            $query_args = array_merge($extra_request, $query_args);
3547
-        }
3548
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3549
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3550
-    }
3551
-
3552
-
3553
-    /**
3554
-     * _per_page_screen_option
3555
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3556
-     *
3557
-     * @return void
3558
-     * @throws InvalidArgumentException
3559
-     * @throws InvalidInterfaceException
3560
-     * @throws InvalidDataTypeException
3561
-     */
3562
-    protected function _per_page_screen_option()
3563
-    {
3564
-        $option = 'per_page';
3565
-        $args   = [
3566
-            'label'   => apply_filters(
3567
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3568
-                $this->_admin_page_title,
3569
-                $this
3570
-            ),
3571
-            'default' => (int) apply_filters(
3572
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3573
-                20
3574
-            ),
3575
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3576
-        ];
3577
-        // ONLY add the screen option if the user has access to it.
3578
-        if ($this->check_user_access($this->_current_view, true)) {
3579
-            add_screen_option($option, $args);
3580
-        }
3581
-    }
3582
-
3583
-
3584
-    /**
3585
-     * set_per_page_screen_option
3586
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3587
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3588
-     * admin_menu.
3589
-     *
3590
-     * @return void
3591
-     */
3592
-    private function _set_per_page_screen_options()
3593
-    {
3594
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3595
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3596
-            if (! $user = wp_get_current_user()) {
3597
-                return;
3598
-            }
3599
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3600
-            if (! $option) {
3601
-                return;
3602
-            }
3603
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3604
-            $map_option = $option;
3605
-            $option     = str_replace('-', '_', $option);
3606
-            switch ($map_option) {
3607
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3608
-                    $max_value = apply_filters(
3609
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3610
-                        999,
3611
-                        $this->_current_page,
3612
-                        $this->_current_view
3613
-                    );
3614
-                    if ($value < 1) {
3615
-                        return;
3616
-                    }
3617
-                    $value = min($value, $max_value);
3618
-                    break;
3619
-                default:
3620
-                    $value = apply_filters(
3621
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3622
-                        false,
3623
-                        $option,
3624
-                        $value
3625
-                    );
3626
-                    if (false === $value) {
3627
-                        return;
3628
-                    }
3629
-                    break;
3630
-            }
3631
-            update_user_meta($user->ID, $option, $value);
3632
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3633
-            exit;
3634
-        }
3635
-    }
3636
-
3637
-
3638
-    /**
3639
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3640
-     *
3641
-     * @param array $data array that will be assigned to template args.
3642
-     */
3643
-    public function set_template_args($data)
3644
-    {
3645
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3646
-    }
3647
-
3648
-
3649
-    /**
3650
-     * This makes available the WP transient system for temporarily moving data between routes
3651
-     *
3652
-     * @param string $route             the route that should receive the transient
3653
-     * @param array  $data              the data that gets sent
3654
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3655
-     *                                  normal route transient.
3656
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3657
-     *                                  when we are adding a transient before page_routes have been defined.
3658
-     * @return void
3659
-     * @throws EE_Error
3660
-     */
3661
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3662
-    {
3663
-        $user_id = get_current_user_id();
3664
-        if (! $skip_route_verify) {
3665
-            $this->_verify_route($route);
3666
-        }
3667
-        // now let's set the string for what kind of transient we're setting
3668
-        $transient = $notices
3669
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3670
-            : 'rte_tx_' . $route . '_' . $user_id;
3671
-        $data      = $notices ? ['notices' => $data] : $data;
3672
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3673
-        $existing = is_multisite() && is_network_admin()
3674
-            ? get_site_transient($transient)
3675
-            : get_transient($transient);
3676
-        if ($existing) {
3677
-            $data = array_merge((array) $data, (array) $existing);
3678
-        }
3679
-        if (is_multisite() && is_network_admin()) {
3680
-            set_site_transient($transient, $data, 8);
3681
-        } else {
3682
-            set_transient($transient, $data, 8);
3683
-        }
3684
-    }
3685
-
3686
-
3687
-    /**
3688
-     * this retrieves the temporary transient that has been set for moving data between routes.
3689
-     *
3690
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3691
-     * @param string $route
3692
-     * @return mixed data
3693
-     */
3694
-    protected function _get_transient($notices = false, $route = '')
3695
-    {
3696
-        $user_id   = get_current_user_id();
3697
-        $route     = ! $route ? $this->_req_action : $route;
3698
-        $transient = $notices
3699
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3700
-            : 'rte_tx_' . $route . '_' . $user_id;
3701
-        $data      = is_multisite() && is_network_admin()
3702
-            ? get_site_transient($transient)
3703
-            : get_transient($transient);
3704
-        // delete transient after retrieval (just in case it hasn't expired);
3705
-        if (is_multisite() && is_network_admin()) {
3706
-            delete_site_transient($transient);
3707
-        } else {
3708
-            delete_transient($transient);
3709
-        }
3710
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3711
-    }
3712
-
3713
-
3714
-    /**
3715
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3716
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3717
-     * default route callback on the EE_Admin page you want it run.)
3718
-     *
3719
-     * @return void
3720
-     */
3721
-    protected function _transient_garbage_collection()
3722
-    {
3723
-        global $wpdb;
3724
-        // retrieve all existing transients
3725
-        $query =
3726
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3727
-        if ($results = $wpdb->get_results($query)) {
3728
-            foreach ($results as $result) {
3729
-                $transient = str_replace('_transient_', '', $result->option_name);
3730
-                get_transient($transient);
3731
-                if (is_multisite() && is_network_admin()) {
3732
-                    get_site_transient($transient);
3733
-                }
3734
-            }
3735
-        }
3736
-    }
3737
-
3738
-
3739
-    /**
3740
-     * get_view
3741
-     *
3742
-     * @return string content of _view property
3743
-     */
3744
-    public function get_view()
3745
-    {
3746
-        return $this->_view;
3747
-    }
3748
-
3749
-
3750
-    /**
3751
-     * getter for the protected $_views property
3752
-     *
3753
-     * @return array
3754
-     */
3755
-    public function get_views()
3756
-    {
3757
-        return $this->_views;
3758
-    }
3759
-
3760
-
3761
-    /**
3762
-     * get_current_page
3763
-     *
3764
-     * @return string _current_page property value
3765
-     */
3766
-    public function get_current_page()
3767
-    {
3768
-        return $this->_current_page;
3769
-    }
3770
-
3771
-
3772
-    /**
3773
-     * get_current_view
3774
-     *
3775
-     * @return string _current_view property value
3776
-     */
3777
-    public function get_current_view()
3778
-    {
3779
-        return $this->_current_view;
3780
-    }
3781
-
3782
-
3783
-    /**
3784
-     * get_current_screen
3785
-     *
3786
-     * @return object The current WP_Screen object
3787
-     */
3788
-    public function get_current_screen()
3789
-    {
3790
-        return $this->_current_screen;
3791
-    }
3792
-
3793
-
3794
-    /**
3795
-     * get_current_page_view_url
3796
-     *
3797
-     * @return string This returns the url for the current_page_view.
3798
-     */
3799
-    public function get_current_page_view_url()
3800
-    {
3801
-        return $this->_current_page_view_url;
3802
-    }
3803
-
3804
-
3805
-    /**
3806
-     * just returns the Request
3807
-     *
3808
-     * @return RequestInterface
3809
-     */
3810
-    public function get_request()
3811
-    {
3812
-        return $this->request;
3813
-    }
3814
-
3815
-
3816
-    /**
3817
-     * just returns the _req_data property
3818
-     *
3819
-     * @return array
3820
-     */
3821
-    public function get_request_data()
3822
-    {
3823
-        return $this->request->requestParams();
3824
-    }
3825
-
3826
-
3827
-    /**
3828
-     * returns the _req_data protected property
3829
-     *
3830
-     * @return string
3831
-     */
3832
-    public function get_req_action()
3833
-    {
3834
-        return $this->_req_action;
3835
-    }
3836
-
3837
-
3838
-    /**
3839
-     * @return bool  value of $_is_caf property
3840
-     */
3841
-    public function is_caf()
3842
-    {
3843
-        return $this->_is_caf;
3844
-    }
3845
-
3846
-
3847
-    /**
3848
-     * @return mixed
3849
-     */
3850
-    public function default_espresso_metaboxes()
3851
-    {
3852
-        return $this->_default_espresso_metaboxes;
3853
-    }
3854
-
3855
-
3856
-    /**
3857
-     * @return mixed
3858
-     */
3859
-    public function admin_base_url()
3860
-    {
3861
-        return $this->_admin_base_url;
3862
-    }
3863
-
3864
-
3865
-    /**
3866
-     * @return mixed
3867
-     */
3868
-    public function wp_page_slug()
3869
-    {
3870
-        return $this->_wp_page_slug;
3871
-    }
3872
-
3873
-
3874
-    /**
3875
-     * updates  espresso configuration settings
3876
-     *
3877
-     * @param string                   $tab
3878
-     * @param EE_Config_Base|EE_Config $config
3879
-     * @param string                   $file file where error occurred
3880
-     * @param string                   $func function  where error occurred
3881
-     * @param string                   $line line no where error occurred
3882
-     * @return boolean
3883
-     */
3884
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3885
-    {
3886
-        // remove any options that are NOT going to be saved with the config settings.
3887
-        if (isset($config->core->ee_ueip_optin)) {
3888
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3889
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3890
-            update_option('ee_ueip_has_notified', true);
3891
-        }
3892
-        // and save it (note we're also doing the network save here)
3893
-        $net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3894
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3895
-        if ($config_saved && $net_saved) {
3896
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3897
-            return true;
3898
-        }
3899
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3900
-        return false;
3901
-    }
3902
-
3903
-
3904
-    /**
3905
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3906
-     *
3907
-     * @return array
3908
-     */
3909
-    public function get_yes_no_values()
3910
-    {
3911
-        return $this->_yes_no_values;
3912
-    }
3913
-
3914
-
3915
-    protected function _get_dir()
3916
-    {
3917
-        $reflector = new ReflectionClass(get_class($this));
3918
-        return dirname($reflector->getFileName());
3919
-    }
3920
-
3921
-
3922
-    /**
3923
-     * A helper for getting a "next link".
3924
-     *
3925
-     * @param string $url   The url to link to
3926
-     * @param string $class The class to use.
3927
-     * @return string
3928
-     */
3929
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3930
-    {
3931
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3932
-    }
3933
-
3934
-
3935
-    /**
3936
-     * A helper for getting a "previous link".
3937
-     *
3938
-     * @param string $url   The url to link to
3939
-     * @param string $class The class to use.
3940
-     * @return string
3941
-     */
3942
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3943
-    {
3944
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3945
-    }
3946
-
3947
-
3948
-
3949
-
3950
-
3951
-
3952
-
3953
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3954
-
3955
-
3956
-    /**
3957
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3958
-     * 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
3959
-     * _req_data array.
3960
-     *
3961
-     * @return bool success/fail
3962
-     * @throws EE_Error
3963
-     * @throws InvalidArgumentException
3964
-     * @throws ReflectionException
3965
-     * @throws InvalidDataTypeException
3966
-     * @throws InvalidInterfaceException
3967
-     */
3968
-    protected function _process_resend_registration()
3969
-    {
3970
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3971
-        do_action(
3972
-            'AHEE__EE_Admin_Page___process_resend_registration',
3973
-            $this->_template_args['success'],
3974
-            $this->request->requestParams()
3975
-        );
3976
-        return $this->_template_args['success'];
3977
-    }
3978
-
3979
-
3980
-    /**
3981
-     * This automatically processes any payment message notifications when manual payment has been applied.
3982
-     *
3983
-     * @param EE_Payment $payment
3984
-     * @return bool success/fail
3985
-     */
3986
-    protected function _process_payment_notification(EE_Payment $payment)
3987
-    {
3988
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3989
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3990
-        $this->_template_args['success'] = apply_filters(
3991
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3992
-            false,
3993
-            $payment
3994
-        );
3995
-        return $this->_template_args['success'];
3996
-    }
3997
-
3998
-
3999
-    /**
4000
-     * @param EEM_Base      $entity_model
4001
-     * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4002
-     * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4003
-     * @param string        $delete_column  name of the field that denotes whether entity is trashed
4004
-     * @param callable|null $callback       called after entity is trashed, restored, or deleted
4005
-     * @return int|float
4006
-     * @throws EE_Error
4007
-     */
4008
-    protected function trashRestoreDeleteEntities(
4009
-        EEM_Base $entity_model,
4010
-        string $entity_PK_name,
4011
-        string $action = EE_Admin_List_Table::ACTION_DELETE,
4012
-        string $delete_column = '',
4013
-        callable $callback = null
4014
-    ) {
4015
-        $entity_PK      = $entity_model->get_primary_key_field();
4016
-        $entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4017
-        $entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4018
-        // grab ID if deleting a single entity
4019
-        if ($this->request->requestParamIsSet($entity_PK_name)) {
4020
-            $ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4021
-            return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4022
-        }
4023
-        // or grab checkbox array if bulk deleting
4024
-        $checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4025
-        if (empty($checkboxes)) {
4026
-            return 0;
4027
-        }
4028
-        $success = 0;
4029
-        $IDs     = array_keys($checkboxes);
4030
-        // cycle thru bulk action checkboxes
4031
-        foreach ($IDs as $ID) {
4032
-            // increment $success
4033
-            if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4034
-                $success++;
4035
-            }
4036
-        }
4037
-        $count = (int) count($checkboxes);
4038
-        // if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4039
-        // otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4040
-        return $success === $count ? $count : $success / $count;
4041
-    }
4042
-
4043
-
4044
-    /**
4045
-     * @param EE_Primary_Key_Field_Base $entity_PK
4046
-     * @return string
4047
-     * @throws EE_Error
4048
-     * @since   4.10.30.p
4049
-     */
4050
-    private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK): string
4051
-    {
4052
-        $entity_PK_type = $entity_PK->getSchemaType();
4053
-        switch ($entity_PK_type) {
4054
-            case 'boolean':
4055
-                return 'bool';
4056
-            case 'integer':
4057
-                return 'int';
4058
-            case 'number':
4059
-                return 'float';
4060
-            case 'string':
4061
-                return 'string';
4062
-        }
4063
-        throw new RuntimeException(
4064
-            sprintf(
4065
-                esc_html__(
4066
-                    '"%1$s" is an invalid schema type for the %2$s primary key.',
4067
-                    'event_espresso'
4068
-                ),
4069
-                $entity_PK_type,
4070
-                $entity_PK->get_name()
4071
-            )
4072
-        );
4073
-    }
4074
-
4075
-
4076
-    /**
4077
-     * @param EEM_Base      $entity_model
4078
-     * @param int|string    $entity_ID
4079
-     * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4080
-     * @param string        $delete_column name of the field that denotes whether entity is trashed
4081
-     * @param callable|null $callback      called after entity is trashed, restored, or deleted
4082
-     * @return bool
4083
-     */
4084
-    protected function trashRestoreDeleteEntity(
4085
-        EEM_Base $entity_model,
4086
-        $entity_ID,
4087
-        string $action,
4088
-        string $delete_column,
4089
-        callable $callback = null
4090
-    ) {
4091
-        $entity_ID = absint($entity_ID);
4092
-        if (! $entity_ID) {
4093
-            $this->trashRestoreDeleteError($action, $entity_model);
4094
-        }
4095
-        $result = 0;
4096
-        try {
4097
-            switch ($action) {
4098
-                case EE_Admin_List_Table::ACTION_DELETE:
4099
-                    $result = (bool) $entity_model->delete_permanently_by_ID($entity_ID);
4100
-                    break;
4101
-                case EE_Admin_List_Table::ACTION_RESTORE:
4102
-                    $this->validateDeleteColumn($entity_model, $delete_column);
4103
-                    $result = $entity_model->update_by_ID([$delete_column => 0], $entity_ID);
4104
-                    break;
4105
-                case EE_Admin_List_Table::ACTION_TRASH:
4106
-                    $this->validateDeleteColumn($entity_model, $delete_column);
4107
-                    $result = $entity_model->update_by_ID([$delete_column => 1], $entity_ID);
4108
-                    break;
4109
-            }
4110
-        } catch (Exception $exception) {
4111
-            $this->trashRestoreDeleteError($action, $entity_model, $exception);
4112
-        }
4113
-        if (is_callable($callback)) {
4114
-            call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4115
-        }
4116
-        return $result;
4117
-    }
4118
-
4119
-
4120
-    /**
4121
-     * @param EEM_Base $entity_model
4122
-     * @param string   $delete_column
4123
-     * @since 4.10.30.p
4124
-     */
4125
-    private function validateDeleteColumn(EEM_Base $entity_model, string $delete_column)
4126
-    {
4127
-        if (empty($delete_column)) {
4128
-            throw new DomainException(
4129
-                sprintf(
4130
-                    esc_html__(
4131
-                        'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4132
-                        'event_espresso'
4133
-                    ),
4134
-                    $entity_model->get_this_model_name()
4135
-                )
4136
-            );
4137
-        }
4138
-        if (! $entity_model->has_field($delete_column)) {
4139
-            throw new DomainException(
4140
-                sprintf(
4141
-                    esc_html__(
4142
-                        'The %1$s field does not exist on the %2$s model.',
4143
-                        'event_espresso'
4144
-                    ),
4145
-                    $delete_column,
4146
-                    $entity_model->get_this_model_name()
4147
-                )
4148
-            );
4149
-        }
4150
-    }
4151
-
4152
-
4153
-    /**
4154
-     * @param EEM_Base       $entity_model
4155
-     * @param Exception|null $exception
4156
-     * @param string         $action
4157
-     * @since 4.10.30.p
4158
-     */
4159
-    private function trashRestoreDeleteError(string $action, EEM_Base $entity_model, ?Exception $exception = null)
4160
-    {
4161
-        if ($exception instanceof Exception) {
4162
-            throw new RuntimeException(
4163
-                sprintf(
4164
-                    esc_html__(
4165
-                        'Could not %1$s the %2$s because the following error occurred: %3$s',
4166
-                        'event_espresso'
4167
-                    ),
4168
-                    $action,
4169
-                    $entity_model->get_this_model_name(),
4170
-                    $exception->getMessage()
4171
-                )
4172
-            );
4173
-        }
4174
-        throw new RuntimeException(
4175
-            sprintf(
4176
-                esc_html__(
4177
-                    'Could not %1$s the %2$s because an invalid ID was received.',
4178
-                    'event_espresso'
4179
-                ),
4180
-                $action,
4181
-                $entity_model->get_this_model_name()
4182
-            )
4183
-        );
4184
-    }
2564
+	}
2565
+
2566
+
2567
+	/**
2568
+	 * facade for add_meta_box
2569
+	 *
2570
+	 * @param string  $action        where the metabox gets displayed
2571
+	 * @param string  $title         Title of Metabox (output in metabox header)
2572
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2573
+	 *                               instead of the one created in here.
2574
+	 * @param array   $callback_args an array of args supplied for the metabox
2575
+	 * @param string  $column        what metabox column
2576
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2577
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2578
+	 *                               created but just set our own callback for wp's add_meta_box.
2579
+	 * @throws DomainException
2580
+	 */
2581
+	public function _add_admin_page_meta_box(
2582
+		$action,
2583
+		$title,
2584
+		$callback,
2585
+		$callback_args,
2586
+		$column = 'normal',
2587
+		$priority = 'high',
2588
+		$create_func = true
2589
+	) {
2590
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2591
+		// 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.
2592
+		if (empty($callback_args) && $create_func) {
2593
+			$callback_args = [
2594
+				'template_path' => $this->_template_path,
2595
+				'template_args' => $this->_template_args,
2596
+			];
2597
+		}
2598
+		// 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)
2599
+		$call_back_func = $create_func
2600
+			? function ($post, $metabox) {
2601
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2602
+				echo EEH_Template::display_template(
2603
+					$metabox['args']['template_path'],
2604
+					$metabox['args']['template_args'],
2605
+					true
2606
+				);
2607
+			}
2608
+			: $callback;
2609
+		add_meta_box(
2610
+			str_replace('_', '-', $action) . '-mbox',
2611
+			$title,
2612
+			$call_back_func,
2613
+			$this->_wp_page_slug,
2614
+			$column,
2615
+			$priority,
2616
+			$callback_args
2617
+		);
2618
+	}
2619
+
2620
+
2621
+	/**
2622
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2623
+	 *
2624
+	 * @throws DomainException
2625
+	 * @throws EE_Error
2626
+	 */
2627
+	public function display_admin_page_with_metabox_columns()
2628
+	{
2629
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2630
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2631
+			$this->_column_template_path,
2632
+			$this->_template_args,
2633
+			true
2634
+		);
2635
+		// the final wrapper
2636
+		$this->admin_page_wrapper();
2637
+	}
2638
+
2639
+
2640
+	/**
2641
+	 * generates  HTML wrapper for an admin details page
2642
+	 *
2643
+	 * @return void
2644
+	 * @throws EE_Error
2645
+	 * @throws DomainException
2646
+	 */
2647
+	public function display_admin_page_with_sidebar()
2648
+	{
2649
+		$this->_display_admin_page(true);
2650
+	}
2651
+
2652
+
2653
+	/**
2654
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2655
+	 *
2656
+	 * @return void
2657
+	 * @throws EE_Error
2658
+	 * @throws DomainException
2659
+	 */
2660
+	public function display_admin_page_with_no_sidebar()
2661
+	{
2662
+		$this->_display_admin_page();
2663
+	}
2664
+
2665
+
2666
+	/**
2667
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2668
+	 *
2669
+	 * @return void
2670
+	 * @throws EE_Error
2671
+	 * @throws DomainException
2672
+	 */
2673
+	public function display_about_admin_page()
2674
+	{
2675
+		$this->_display_admin_page(false, true);
2676
+	}
2677
+
2678
+
2679
+	/**
2680
+	 * display_admin_page
2681
+	 * contains the code for actually displaying an admin page
2682
+	 *
2683
+	 * @param boolean $sidebar true with sidebar, false without
2684
+	 * @param boolean $about   use the about_admin_wrapper instead of the default.
2685
+	 * @return void
2686
+	 * @throws DomainException
2687
+	 * @throws EE_Error
2688
+	 */
2689
+	private function _display_admin_page($sidebar = false, $about = false)
2690
+	{
2691
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2692
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2693
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2694
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2695
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2696
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2697
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2698
+			? 'poststuff'
2699
+			: 'espresso-default-admin';
2700
+		$template_path                                     = $sidebar
2701
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2702
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2703
+		if ($this->request->isAjax()) {
2704
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2705
+		}
2706
+		$template_path                                     = ! empty($this->_column_template_path)
2707
+			? $this->_column_template_path : $template_path;
2708
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2709
+			? $this->_template_args['admin_page_content']
2710
+			: '';
2711
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2712
+			? $this->_template_args['before_admin_page_content']
2713
+			: '';
2714
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2715
+			? $this->_template_args['after_admin_page_content']
2716
+			: '';
2717
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2718
+			$template_path,
2719
+			$this->_template_args,
2720
+			true
2721
+		);
2722
+		// the final template wrapper
2723
+		$this->admin_page_wrapper($about);
2724
+	}
2725
+
2726
+
2727
+	/**
2728
+	 * This is used to display caf preview pages.
2729
+	 *
2730
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2731
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2732
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2733
+	 * @return void
2734
+	 * @throws DomainException
2735
+	 * @throws EE_Error
2736
+	 * @throws InvalidArgumentException
2737
+	 * @throws InvalidDataTypeException
2738
+	 * @throws InvalidInterfaceException
2739
+	 * @since 4.3.2
2740
+	 */
2741
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2742
+	{
2743
+		// let's generate a default preview action button if there isn't one already present.
2744
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2745
+			'Upgrade to Event Espresso 4 Right Now',
2746
+			'event_espresso'
2747
+		);
2748
+		$buy_now_url                                   = add_query_arg(
2749
+			[
2750
+				'ee_ver'       => 'ee4',
2751
+				'utm_source'   => 'ee4_plugin_admin',
2752
+				'utm_medium'   => 'link',
2753
+				'utm_campaign' => $utm_campaign_source,
2754
+				'utm_content'  => 'buy_now_button',
2755
+			],
2756
+			'https://eventespresso.com/pricing/'
2757
+		);
2758
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2759
+			? $this->get_action_link_or_button(
2760
+				'',
2761
+				'buy_now',
2762
+				[],
2763
+				'button-primary button-large',
2764
+				esc_url_raw($buy_now_url),
2765
+				true
2766
+			)
2767
+			: $this->_template_args['preview_action_button'];
2768
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2769
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2770
+			$this->_template_args,
2771
+			true
2772
+		);
2773
+		$this->_display_admin_page($display_sidebar);
2774
+	}
2775
+
2776
+
2777
+	/**
2778
+	 * display_admin_list_table_page_with_sidebar
2779
+	 * generates HTML wrapper for an admin_page with list_table
2780
+	 *
2781
+	 * @return void
2782
+	 * @throws EE_Error
2783
+	 * @throws DomainException
2784
+	 */
2785
+	public function display_admin_list_table_page_with_sidebar()
2786
+	{
2787
+		$this->_display_admin_list_table_page(true);
2788
+	}
2789
+
2790
+
2791
+	/**
2792
+	 * display_admin_list_table_page_with_no_sidebar
2793
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2794
+	 *
2795
+	 * @return void
2796
+	 * @throws EE_Error
2797
+	 * @throws DomainException
2798
+	 */
2799
+	public function display_admin_list_table_page_with_no_sidebar()
2800
+	{
2801
+		$this->_display_admin_list_table_page();
2802
+	}
2803
+
2804
+
2805
+	/**
2806
+	 * generates html wrapper for an admin_list_table page
2807
+	 *
2808
+	 * @param boolean $sidebar whether to display with sidebar or not.
2809
+	 * @return void
2810
+	 * @throws DomainException
2811
+	 * @throws EE_Error
2812
+	 */
2813
+	private function _display_admin_list_table_page($sidebar = false)
2814
+	{
2815
+		// setup search attributes
2816
+		$this->_set_search_attributes();
2817
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
2818
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2819
+		$this->_template_args['table_url']        = $this->request->isAjax()
2820
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2821
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2822
+		$this->_template_args['list_table']       = $this->_list_table_object;
2823
+		$this->_template_args['current_route']    = $this->_req_action;
2824
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2825
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2826
+		if (! empty($ajax_sorting_callback)) {
2827
+			$sortable_list_table_form_fields = wp_nonce_field(
2828
+				$ajax_sorting_callback . '_nonce',
2829
+				$ajax_sorting_callback . '_nonce',
2830
+				false,
2831
+				false
2832
+			);
2833
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2834
+												. $this->page_slug
2835
+												. '" />';
2836
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2837
+												. $ajax_sorting_callback
2838
+												. '" />';
2839
+		} else {
2840
+			$sortable_list_table_form_fields = '';
2841
+		}
2842
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2843
+		$hidden_form_fields                                      =
2844
+			isset($this->_template_args['list_table_hidden_fields'])
2845
+				? $this->_template_args['list_table_hidden_fields']
2846
+				: '';
2847
+		$nonce_ref                                               = $this->_req_action . '_nonce';
2848
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
2849
+																	. $nonce_ref
2850
+																	. '" value="'
2851
+																	. wp_create_nonce($nonce_ref)
2852
+																	. '">';
2853
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2854
+		// display message about search results?
2855
+		$search = $this->request->getRequestParam('s');
2856
+		$this->_template_args['before_list_table'] .= ! empty($search)
2857
+			? '<p class="ee-search-results">' . sprintf(
2858
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2859
+				trim($search, '%')
2860
+			) . '</p>'
2861
+			: '';
2862
+		// filter before_list_table template arg
2863
+		$this->_template_args['before_list_table'] = apply_filters(
2864
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2865
+			$this->_template_args['before_list_table'],
2866
+			$this->page_slug,
2867
+			$this->request->requestParams(),
2868
+			$this->_req_action
2869
+		);
2870
+		// convert to array and filter again
2871
+		// arrays are easier to inject new items in a specific location,
2872
+		// but would not be backwards compatible, so we have to add a new filter
2873
+		$this->_template_args['before_list_table'] = implode(
2874
+			" \n",
2875
+			(array) apply_filters(
2876
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2877
+				(array) $this->_template_args['before_list_table'],
2878
+				$this->page_slug,
2879
+				$this->request->requestParams(),
2880
+				$this->_req_action
2881
+			)
2882
+		);
2883
+		// filter after_list_table template arg
2884
+		$this->_template_args['after_list_table'] = apply_filters(
2885
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2886
+			$this->_template_args['after_list_table'],
2887
+			$this->page_slug,
2888
+			$this->request->requestParams(),
2889
+			$this->_req_action
2890
+		);
2891
+		// convert to array and filter again
2892
+		// arrays are easier to inject new items in a specific location,
2893
+		// but would not be backwards compatible, so we have to add a new filter
2894
+		$this->_template_args['after_list_table']   = implode(
2895
+			" \n",
2896
+			(array) apply_filters(
2897
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2898
+				(array) $this->_template_args['after_list_table'],
2899
+				$this->page_slug,
2900
+				$this->request->requestParams(),
2901
+				$this->_req_action
2902
+			)
2903
+		);
2904
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2905
+			$template_path,
2906
+			$this->_template_args,
2907
+			true
2908
+		);
2909
+		// the final template wrapper
2910
+		if ($sidebar) {
2911
+			$this->display_admin_page_with_sidebar();
2912
+		} else {
2913
+			$this->display_admin_page_with_no_sidebar();
2914
+		}
2915
+	}
2916
+
2917
+
2918
+	/**
2919
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2920
+	 * html string for the legend.
2921
+	 * $items are expected in an array in the following format:
2922
+	 * $legend_items = array(
2923
+	 *        'item_id' => array(
2924
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2925
+	 *            'desc' => esc_html__('localized description of item');
2926
+	 *        )
2927
+	 * );
2928
+	 *
2929
+	 * @param array $items see above for format of array
2930
+	 * @return string html string of legend
2931
+	 * @throws DomainException
2932
+	 */
2933
+	protected function _display_legend($items)
2934
+	{
2935
+		$this->_template_args['items'] = apply_filters(
2936
+			'FHEE__EE_Admin_Page___display_legend__items',
2937
+			(array) $items,
2938
+			$this
2939
+		);
2940
+		return EEH_Template::display_template(
2941
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2942
+			$this->_template_args,
2943
+			true
2944
+		);
2945
+	}
2946
+
2947
+
2948
+	/**
2949
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2950
+	 * The returned json object is created from an array in the following format:
2951
+	 * array(
2952
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2953
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
2954
+	 *  'notices' => '', // - contains any EE_Error formatted notices
2955
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
2956
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
2957
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
2958
+	 *  that might be included in here)
2959
+	 * )
2960
+	 * The json object is populated by whatever is set in the $_template_args property.
2961
+	 *
2962
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
2963
+	 *                                 instead of displayed.
2964
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
2965
+	 * @return void
2966
+	 * @throws EE_Error
2967
+	 */
2968
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
2969
+	{
2970
+		// make sure any EE_Error notices have been handled.
2971
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
2972
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
2973
+		unset($this->_template_args['data']);
2974
+		$json = [
2975
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2976
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2977
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2978
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2979
+			'notices'   => EE_Error::get_notices(),
2980
+			'content'   => isset($this->_template_args['admin_page_content'])
2981
+				? $this->_template_args['admin_page_content'] : '',
2982
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
2983
+			'isEEajax'  => true
2984
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2985
+		];
2986
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
2987
+		if (null === error_get_last() || ! headers_sent()) {
2988
+			header('Content-Type: application/json; charset=UTF-8');
2989
+		}
2990
+		echo wp_json_encode($json);
2991
+		exit();
2992
+	}
2993
+
2994
+
2995
+	/**
2996
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2997
+	 *
2998
+	 * @return void
2999
+	 * @throws EE_Error
3000
+	 */
3001
+	public function return_json()
3002
+	{
3003
+		if ($this->request->isAjax()) {
3004
+			$this->_return_json();
3005
+		} else {
3006
+			throw new EE_Error(
3007
+				sprintf(
3008
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3009
+					__FUNCTION__
3010
+				)
3011
+			);
3012
+		}
3013
+	}
3014
+
3015
+
3016
+	/**
3017
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3018
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3019
+	 *
3020
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3021
+	 */
3022
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3023
+	{
3024
+		$this->_hook_obj = $hook_obj;
3025
+	}
3026
+
3027
+
3028
+	/**
3029
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3030
+	 *
3031
+	 * @param boolean $about whether to use the special about page wrapper or default.
3032
+	 * @return void
3033
+	 * @throws DomainException
3034
+	 * @throws EE_Error
3035
+	 */
3036
+	public function admin_page_wrapper($about = false)
3037
+	{
3038
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3039
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3040
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3041
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3042
+
3043
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3044
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3045
+			isset($this->_template_args['before_admin_page_content'])
3046
+				? $this->_template_args['before_admin_page_content']
3047
+				: ''
3048
+		);
3049
+
3050
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3051
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3052
+			isset($this->_template_args['after_admin_page_content'])
3053
+				? $this->_template_args['after_admin_page_content']
3054
+				: ''
3055
+		);
3056
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3057
+
3058
+		if ($this->request->isAjax()) {
3059
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3060
+				// $template_path,
3061
+				EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3062
+				$this->_template_args,
3063
+				true
3064
+			);
3065
+			$this->_return_json();
3066
+		}
3067
+		// load settings page wrapper template
3068
+		$template_path = $about
3069
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3070
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3071
+
3072
+		EEH_Template::display_template($template_path, $this->_template_args);
3073
+	}
3074
+
3075
+
3076
+	/**
3077
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3078
+	 *
3079
+	 * @return string html
3080
+	 * @throws EE_Error
3081
+	 */
3082
+	protected function _get_main_nav_tabs()
3083
+	{
3084
+		// let's generate the html using the EEH_Tabbed_Content helper.
3085
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3086
+		// (rather than setting in the page_routes array)
3087
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3088
+	}
3089
+
3090
+
3091
+	/**
3092
+	 *        sort nav tabs
3093
+	 *
3094
+	 * @param $a
3095
+	 * @param $b
3096
+	 * @return int
3097
+	 */
3098
+	private function _sort_nav_tabs($a, $b)
3099
+	{
3100
+		if ($a['order'] === $b['order']) {
3101
+			return 0;
3102
+		}
3103
+		return ($a['order'] < $b['order']) ? -1 : 1;
3104
+	}
3105
+
3106
+
3107
+	/**
3108
+	 *    generates HTML for the forms used on admin pages
3109
+	 *
3110
+	 * @param array  $input_vars   - array of input field details
3111
+	 * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3112
+	 *                             use)
3113
+	 * @param bool   $id
3114
+	 * @return array|string
3115
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3116
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3117
+	 */
3118
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3119
+	{
3120
+		return $generator === 'string'
3121
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3122
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3123
+	}
3124
+
3125
+
3126
+	/**
3127
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3128
+	 *
3129
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3130
+	 *                                   Close" button.
3131
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3132
+	 *                                   'Save', [1] => 'save & close')
3133
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3134
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3135
+	 *                                   default actions by submitting some other value.
3136
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3137
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3138
+	 *                                   close (normal form handling).
3139
+	 */
3140
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3141
+	{
3142
+		// make sure $text and $actions are in an array
3143
+		$text          = (array) $text;
3144
+		$actions       = (array) $actions;
3145
+		$referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3146
+		$button_text   = ! empty($text)
3147
+			? $text
3148
+			: [
3149
+				esc_html__('Save', 'event_espresso'),
3150
+				esc_html__('Save and Close', 'event_espresso'),
3151
+			];
3152
+		$default_names = ['save', 'save_and_close'];
3153
+		$buttons = '';
3154
+		foreach ($button_text as $key => $button) {
3155
+			$ref     = $default_names[ $key ];
3156
+			$name    = ! empty($actions) ? $actions[ $key ] : $ref;
3157
+			$buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3158
+						. 'value="' . $button . '" name="' . $name . '" '
3159
+						. 'id="' . $this->_current_view . '_' . $ref . '" />';
3160
+			if (! $both) {
3161
+				break;
3162
+			}
3163
+		}
3164
+		// add in a hidden index for the current page (so save and close redirects properly)
3165
+		$buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3166
+				   . $referrer_url
3167
+				   . '" />';
3168
+		$this->_template_args['save_buttons'] = $buttons;
3169
+	}
3170
+
3171
+
3172
+	/**
3173
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3174
+	 *
3175
+	 * @param string $route
3176
+	 * @param array  $additional_hidden_fields
3177
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3178
+	 * @since 4.6.0
3179
+	 */
3180
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3181
+	{
3182
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3183
+	}
3184
+
3185
+
3186
+	/**
3187
+	 * set form open and close tags on add/edit pages.
3188
+	 *
3189
+	 * @param string $route                    the route you want the form to direct to
3190
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3191
+	 * @return void
3192
+	 */
3193
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3194
+	{
3195
+		if (empty($route)) {
3196
+			$user_msg = esc_html__(
3197
+				'An error occurred. No action was set for this page\'s form.',
3198
+				'event_espresso'
3199
+			);
3200
+			$dev_msg  = $user_msg . "\n"
3201
+						. sprintf(
3202
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3203
+							__FUNCTION__,
3204
+							__CLASS__
3205
+						);
3206
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3207
+		}
3208
+		// open form
3209
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3210
+															 . $this->_admin_base_url
3211
+															 . '" id="'
3212
+															 . $route
3213
+															 . '_event_form" >';
3214
+		// add nonce
3215
+		$nonce                                             =
3216
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3217
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3218
+		// add REQUIRED form action
3219
+		$hidden_fields = [
3220
+			'action' => ['type' => 'hidden', 'value' => $route],
3221
+		];
3222
+		// merge arrays
3223
+		$hidden_fields = is_array($additional_hidden_fields)
3224
+			? array_merge($hidden_fields, $additional_hidden_fields)
3225
+			: $hidden_fields;
3226
+		// generate form fields
3227
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3228
+		// add fields to form
3229
+		foreach ((array) $form_fields as $form_field) {
3230
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3231
+		}
3232
+		// close form
3233
+		$this->_template_args['after_admin_page_content'] = '</form>';
3234
+	}
3235
+
3236
+
3237
+	/**
3238
+	 * Public Wrapper for _redirect_after_action() method since its
3239
+	 * discovered it would be useful for external code to have access.
3240
+	 *
3241
+	 * @param bool   $success
3242
+	 * @param string $what
3243
+	 * @param string $action_desc
3244
+	 * @param array  $query_args
3245
+	 * @param bool   $override_overwrite
3246
+	 * @throws EE_Error
3247
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3248
+	 * @since 4.5.0
3249
+	 */
3250
+	public function redirect_after_action(
3251
+		$success = false,
3252
+		$what = 'item',
3253
+		$action_desc = 'processed',
3254
+		$query_args = [],
3255
+		$override_overwrite = false
3256
+	) {
3257
+		$this->_redirect_after_action(
3258
+			$success,
3259
+			$what,
3260
+			$action_desc,
3261
+			$query_args,
3262
+			$override_overwrite
3263
+		);
3264
+	}
3265
+
3266
+
3267
+	/**
3268
+	 * Helper method for merging existing request data with the returned redirect url.
3269
+	 *
3270
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3271
+	 * filters are still applied.
3272
+	 *
3273
+	 * @param array $new_route_data
3274
+	 * @return array
3275
+	 */
3276
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3277
+	{
3278
+		foreach ($this->request->requestParams() as $ref => $value) {
3279
+			// unset nonces
3280
+			if (strpos($ref, 'nonce') !== false) {
3281
+				$this->request->unSetRequestParam($ref);
3282
+				continue;
3283
+			}
3284
+			// urlencode values.
3285
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3286
+			$this->request->setRequestParam($ref, $value);
3287
+		}
3288
+		return array_merge($this->request->requestParams(), $new_route_data);
3289
+	}
3290
+
3291
+
3292
+	/**
3293
+	 *    _redirect_after_action
3294
+	 *
3295
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3296
+	 * @param string $what               - what the action was performed on
3297
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3298
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3299
+	 *                                   action is completed
3300
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3301
+	 *                                   override this so that they show.
3302
+	 * @return void
3303
+	 * @throws EE_Error
3304
+	 */
3305
+	protected function _redirect_after_action(
3306
+		$success = 0,
3307
+		$what = 'item',
3308
+		$action_desc = 'processed',
3309
+		$query_args = [],
3310
+		$override_overwrite = false
3311
+	) {
3312
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3313
+		// class name for actions/filters.
3314
+		$classname = get_class($this);
3315
+		// set redirect url.
3316
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3317
+		// otherwise we go with whatever is set as the _admin_base_url
3318
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3319
+		$notices      = EE_Error::get_notices(false);
3320
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3321
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3322
+			EE_Error::overwrite_success();
3323
+		}
3324
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3325
+			// how many records affected ? more than one record ? or just one ?
3326
+			if ($success > 1) {
3327
+				// set plural msg
3328
+				EE_Error::add_success(
3329
+					sprintf(
3330
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3331
+						$what,
3332
+						$action_desc
3333
+					),
3334
+					__FILE__,
3335
+					__FUNCTION__,
3336
+					__LINE__
3337
+				);
3338
+			} elseif ($success === 1) {
3339
+				// set singular msg
3340
+				EE_Error::add_success(
3341
+					sprintf(
3342
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3343
+						$what,
3344
+						$action_desc
3345
+					),
3346
+					__FILE__,
3347
+					__FUNCTION__,
3348
+					__LINE__
3349
+				);
3350
+			}
3351
+		}
3352
+		// check that $query_args isn't something crazy
3353
+		if (! is_array($query_args)) {
3354
+			$query_args = [];
3355
+		}
3356
+		/**
3357
+		 * Allow injecting actions before the query_args are modified for possible different
3358
+		 * redirections on save and close actions
3359
+		 *
3360
+		 * @param array $query_args       The original query_args array coming into the
3361
+		 *                                method.
3362
+		 * @since 4.2.0
3363
+		 */
3364
+		do_action(
3365
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3366
+			$query_args
3367
+		);
3368
+		// calculate where we're going (if we have a "save and close" button pushed)
3369
+
3370
+		if (
3371
+			$this->request->requestParamIsSet('save_and_close')
3372
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3373
+		) {
3374
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3375
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3376
+			// regenerate query args array from referrer URL
3377
+			parse_str($parsed_url['query'], $query_args);
3378
+			// correct page and action will be in the query args now
3379
+			$redirect_url = admin_url('admin.php');
3380
+		}
3381
+		// merge any default query_args set in _default_route_query_args property
3382
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3383
+			$args_to_merge = [];
3384
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3385
+				// is there a wp_referer array in our _default_route_query_args property?
3386
+				if ($query_param === 'wp_referer') {
3387
+					$query_value = (array) $query_value;
3388
+					foreach ($query_value as $reference => $value) {
3389
+						if (strpos($reference, 'nonce') !== false) {
3390
+							continue;
3391
+						}
3392
+						// finally we will override any arguments in the referer with
3393
+						// what might be set on the _default_route_query_args array.
3394
+						if (isset($this->_default_route_query_args[ $reference ])) {
3395
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3396
+						} else {
3397
+							$args_to_merge[ $reference ] = urlencode($value);
3398
+						}
3399
+					}
3400
+					continue;
3401
+				}
3402
+				$args_to_merge[ $query_param ] = $query_value;
3403
+			}
3404
+			// now let's merge these arguments but override with what was specifically sent in to the
3405
+			// redirect.
3406
+			$query_args = array_merge($args_to_merge, $query_args);
3407
+		}
3408
+		$this->_process_notices($query_args);
3409
+		// generate redirect url
3410
+		// if redirecting to anything other than the main page, add a nonce
3411
+		if (isset($query_args['action'])) {
3412
+			// manually generate wp_nonce and merge that with the query vars
3413
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3414
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3415
+		}
3416
+		// we're adding some hooks and filters in here for processing any things just before redirects
3417
+		// (example: an admin page has done an insert or update and we want to run something after that).
3418
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3419
+		$redirect_url = apply_filters(
3420
+			'FHEE_redirect_' . $classname . $this->_req_action,
3421
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3422
+			$query_args
3423
+		);
3424
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3425
+		if ($this->request->isAjax()) {
3426
+			$default_data                    = [
3427
+				'close'        => true,
3428
+				'redirect_url' => $redirect_url,
3429
+				'where'        => 'main',
3430
+				'what'         => 'append',
3431
+			];
3432
+			$this->_template_args['success'] = $success;
3433
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3434
+				$default_data,
3435
+				$this->_template_args['data']
3436
+			) : $default_data;
3437
+			$this->_return_json();
3438
+		}
3439
+		wp_safe_redirect($redirect_url);
3440
+		exit();
3441
+	}
3442
+
3443
+
3444
+	/**
3445
+	 * process any notices before redirecting (or returning ajax request)
3446
+	 * This method sets the $this->_template_args['notices'] attribute;
3447
+	 *
3448
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3449
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3450
+	 *                                  page_routes haven't been defined yet.
3451
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3452
+	 *                                  still save a transient for the notice.
3453
+	 * @return void
3454
+	 * @throws EE_Error
3455
+	 */
3456
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3457
+	{
3458
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3459
+		if ($this->request->isAjax()) {
3460
+			$notices = EE_Error::get_notices(false);
3461
+			if (empty($this->_template_args['success'])) {
3462
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3463
+			}
3464
+			if (empty($this->_template_args['errors'])) {
3465
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3466
+			}
3467
+			if (empty($this->_template_args['attention'])) {
3468
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3469
+			}
3470
+		}
3471
+		$this->_template_args['notices'] = EE_Error::get_notices();
3472
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3473
+		if (! $this->request->isAjax() || $sticky_notices) {
3474
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3475
+			$this->_add_transient(
3476
+				$route,
3477
+				$this->_template_args['notices'],
3478
+				true,
3479
+				$skip_route_verify
3480
+			);
3481
+		}
3482
+	}
3483
+
3484
+
3485
+	/**
3486
+	 * get_action_link_or_button
3487
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3488
+	 *
3489
+	 * @param string $action        use this to indicate which action the url is generated with.
3490
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3491
+	 *                              property.
3492
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3493
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3494
+	 * @param string $base_url      If this is not provided
3495
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3496
+	 *                              Otherwise this value will be used.
3497
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3498
+	 * @return string
3499
+	 * @throws InvalidArgumentException
3500
+	 * @throws InvalidInterfaceException
3501
+	 * @throws InvalidDataTypeException
3502
+	 * @throws EE_Error
3503
+	 */
3504
+	public function get_action_link_or_button(
3505
+		$action,
3506
+		$type = 'add',
3507
+		$extra_request = [],
3508
+		$class = 'button button--primary',
3509
+		$base_url = '',
3510
+		$exclude_nonce = false
3511
+	) {
3512
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3513
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3514
+			throw new EE_Error(
3515
+				sprintf(
3516
+					esc_html__(
3517
+						'There is no page route for given action for the button.  This action was given: %s',
3518
+						'event_espresso'
3519
+					),
3520
+					$action
3521
+				)
3522
+			);
3523
+		}
3524
+		if (! isset($this->_labels['buttons'][ $type ])) {
3525
+			throw new EE_Error(
3526
+				sprintf(
3527
+					esc_html__(
3528
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3529
+						'event_espresso'
3530
+					),
3531
+					$type
3532
+				)
3533
+			);
3534
+		}
3535
+		// finally check user access for this button.
3536
+		$has_access = $this->check_user_access($action, true);
3537
+		if (! $has_access) {
3538
+			return '';
3539
+		}
3540
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3541
+		$query_args = [
3542
+			'action' => $action,
3543
+		];
3544
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3545
+		if (! empty($extra_request)) {
3546
+			$query_args = array_merge($extra_request, $query_args);
3547
+		}
3548
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3549
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3550
+	}
3551
+
3552
+
3553
+	/**
3554
+	 * _per_page_screen_option
3555
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3556
+	 *
3557
+	 * @return void
3558
+	 * @throws InvalidArgumentException
3559
+	 * @throws InvalidInterfaceException
3560
+	 * @throws InvalidDataTypeException
3561
+	 */
3562
+	protected function _per_page_screen_option()
3563
+	{
3564
+		$option = 'per_page';
3565
+		$args   = [
3566
+			'label'   => apply_filters(
3567
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3568
+				$this->_admin_page_title,
3569
+				$this
3570
+			),
3571
+			'default' => (int) apply_filters(
3572
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3573
+				20
3574
+			),
3575
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3576
+		];
3577
+		// ONLY add the screen option if the user has access to it.
3578
+		if ($this->check_user_access($this->_current_view, true)) {
3579
+			add_screen_option($option, $args);
3580
+		}
3581
+	}
3582
+
3583
+
3584
+	/**
3585
+	 * set_per_page_screen_option
3586
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3587
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3588
+	 * admin_menu.
3589
+	 *
3590
+	 * @return void
3591
+	 */
3592
+	private function _set_per_page_screen_options()
3593
+	{
3594
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3595
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3596
+			if (! $user = wp_get_current_user()) {
3597
+				return;
3598
+			}
3599
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3600
+			if (! $option) {
3601
+				return;
3602
+			}
3603
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3604
+			$map_option = $option;
3605
+			$option     = str_replace('-', '_', $option);
3606
+			switch ($map_option) {
3607
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3608
+					$max_value = apply_filters(
3609
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3610
+						999,
3611
+						$this->_current_page,
3612
+						$this->_current_view
3613
+					);
3614
+					if ($value < 1) {
3615
+						return;
3616
+					}
3617
+					$value = min($value, $max_value);
3618
+					break;
3619
+				default:
3620
+					$value = apply_filters(
3621
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3622
+						false,
3623
+						$option,
3624
+						$value
3625
+					);
3626
+					if (false === $value) {
3627
+						return;
3628
+					}
3629
+					break;
3630
+			}
3631
+			update_user_meta($user->ID, $option, $value);
3632
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3633
+			exit;
3634
+		}
3635
+	}
3636
+
3637
+
3638
+	/**
3639
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3640
+	 *
3641
+	 * @param array $data array that will be assigned to template args.
3642
+	 */
3643
+	public function set_template_args($data)
3644
+	{
3645
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3646
+	}
3647
+
3648
+
3649
+	/**
3650
+	 * This makes available the WP transient system for temporarily moving data between routes
3651
+	 *
3652
+	 * @param string $route             the route that should receive the transient
3653
+	 * @param array  $data              the data that gets sent
3654
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3655
+	 *                                  normal route transient.
3656
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3657
+	 *                                  when we are adding a transient before page_routes have been defined.
3658
+	 * @return void
3659
+	 * @throws EE_Error
3660
+	 */
3661
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3662
+	{
3663
+		$user_id = get_current_user_id();
3664
+		if (! $skip_route_verify) {
3665
+			$this->_verify_route($route);
3666
+		}
3667
+		// now let's set the string for what kind of transient we're setting
3668
+		$transient = $notices
3669
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3670
+			: 'rte_tx_' . $route . '_' . $user_id;
3671
+		$data      = $notices ? ['notices' => $data] : $data;
3672
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3673
+		$existing = is_multisite() && is_network_admin()
3674
+			? get_site_transient($transient)
3675
+			: get_transient($transient);
3676
+		if ($existing) {
3677
+			$data = array_merge((array) $data, (array) $existing);
3678
+		}
3679
+		if (is_multisite() && is_network_admin()) {
3680
+			set_site_transient($transient, $data, 8);
3681
+		} else {
3682
+			set_transient($transient, $data, 8);
3683
+		}
3684
+	}
3685
+
3686
+
3687
+	/**
3688
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3689
+	 *
3690
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3691
+	 * @param string $route
3692
+	 * @return mixed data
3693
+	 */
3694
+	protected function _get_transient($notices = false, $route = '')
3695
+	{
3696
+		$user_id   = get_current_user_id();
3697
+		$route     = ! $route ? $this->_req_action : $route;
3698
+		$transient = $notices
3699
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3700
+			: 'rte_tx_' . $route . '_' . $user_id;
3701
+		$data      = is_multisite() && is_network_admin()
3702
+			? get_site_transient($transient)
3703
+			: get_transient($transient);
3704
+		// delete transient after retrieval (just in case it hasn't expired);
3705
+		if (is_multisite() && is_network_admin()) {
3706
+			delete_site_transient($transient);
3707
+		} else {
3708
+			delete_transient($transient);
3709
+		}
3710
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3711
+	}
3712
+
3713
+
3714
+	/**
3715
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3716
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3717
+	 * default route callback on the EE_Admin page you want it run.)
3718
+	 *
3719
+	 * @return void
3720
+	 */
3721
+	protected function _transient_garbage_collection()
3722
+	{
3723
+		global $wpdb;
3724
+		// retrieve all existing transients
3725
+		$query =
3726
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3727
+		if ($results = $wpdb->get_results($query)) {
3728
+			foreach ($results as $result) {
3729
+				$transient = str_replace('_transient_', '', $result->option_name);
3730
+				get_transient($transient);
3731
+				if (is_multisite() && is_network_admin()) {
3732
+					get_site_transient($transient);
3733
+				}
3734
+			}
3735
+		}
3736
+	}
3737
+
3738
+
3739
+	/**
3740
+	 * get_view
3741
+	 *
3742
+	 * @return string content of _view property
3743
+	 */
3744
+	public function get_view()
3745
+	{
3746
+		return $this->_view;
3747
+	}
3748
+
3749
+
3750
+	/**
3751
+	 * getter for the protected $_views property
3752
+	 *
3753
+	 * @return array
3754
+	 */
3755
+	public function get_views()
3756
+	{
3757
+		return $this->_views;
3758
+	}
3759
+
3760
+
3761
+	/**
3762
+	 * get_current_page
3763
+	 *
3764
+	 * @return string _current_page property value
3765
+	 */
3766
+	public function get_current_page()
3767
+	{
3768
+		return $this->_current_page;
3769
+	}
3770
+
3771
+
3772
+	/**
3773
+	 * get_current_view
3774
+	 *
3775
+	 * @return string _current_view property value
3776
+	 */
3777
+	public function get_current_view()
3778
+	{
3779
+		return $this->_current_view;
3780
+	}
3781
+
3782
+
3783
+	/**
3784
+	 * get_current_screen
3785
+	 *
3786
+	 * @return object The current WP_Screen object
3787
+	 */
3788
+	public function get_current_screen()
3789
+	{
3790
+		return $this->_current_screen;
3791
+	}
3792
+
3793
+
3794
+	/**
3795
+	 * get_current_page_view_url
3796
+	 *
3797
+	 * @return string This returns the url for the current_page_view.
3798
+	 */
3799
+	public function get_current_page_view_url()
3800
+	{
3801
+		return $this->_current_page_view_url;
3802
+	}
3803
+
3804
+
3805
+	/**
3806
+	 * just returns the Request
3807
+	 *
3808
+	 * @return RequestInterface
3809
+	 */
3810
+	public function get_request()
3811
+	{
3812
+		return $this->request;
3813
+	}
3814
+
3815
+
3816
+	/**
3817
+	 * just returns the _req_data property
3818
+	 *
3819
+	 * @return array
3820
+	 */
3821
+	public function get_request_data()
3822
+	{
3823
+		return $this->request->requestParams();
3824
+	}
3825
+
3826
+
3827
+	/**
3828
+	 * returns the _req_data protected property
3829
+	 *
3830
+	 * @return string
3831
+	 */
3832
+	public function get_req_action()
3833
+	{
3834
+		return $this->_req_action;
3835
+	}
3836
+
3837
+
3838
+	/**
3839
+	 * @return bool  value of $_is_caf property
3840
+	 */
3841
+	public function is_caf()
3842
+	{
3843
+		return $this->_is_caf;
3844
+	}
3845
+
3846
+
3847
+	/**
3848
+	 * @return mixed
3849
+	 */
3850
+	public function default_espresso_metaboxes()
3851
+	{
3852
+		return $this->_default_espresso_metaboxes;
3853
+	}
3854
+
3855
+
3856
+	/**
3857
+	 * @return mixed
3858
+	 */
3859
+	public function admin_base_url()
3860
+	{
3861
+		return $this->_admin_base_url;
3862
+	}
3863
+
3864
+
3865
+	/**
3866
+	 * @return mixed
3867
+	 */
3868
+	public function wp_page_slug()
3869
+	{
3870
+		return $this->_wp_page_slug;
3871
+	}
3872
+
3873
+
3874
+	/**
3875
+	 * updates  espresso configuration settings
3876
+	 *
3877
+	 * @param string                   $tab
3878
+	 * @param EE_Config_Base|EE_Config $config
3879
+	 * @param string                   $file file where error occurred
3880
+	 * @param string                   $func function  where error occurred
3881
+	 * @param string                   $line line no where error occurred
3882
+	 * @return boolean
3883
+	 */
3884
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3885
+	{
3886
+		// remove any options that are NOT going to be saved with the config settings.
3887
+		if (isset($config->core->ee_ueip_optin)) {
3888
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3889
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3890
+			update_option('ee_ueip_has_notified', true);
3891
+		}
3892
+		// and save it (note we're also doing the network save here)
3893
+		$net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3894
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3895
+		if ($config_saved && $net_saved) {
3896
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3897
+			return true;
3898
+		}
3899
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3900
+		return false;
3901
+	}
3902
+
3903
+
3904
+	/**
3905
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3906
+	 *
3907
+	 * @return array
3908
+	 */
3909
+	public function get_yes_no_values()
3910
+	{
3911
+		return $this->_yes_no_values;
3912
+	}
3913
+
3914
+
3915
+	protected function _get_dir()
3916
+	{
3917
+		$reflector = new ReflectionClass(get_class($this));
3918
+		return dirname($reflector->getFileName());
3919
+	}
3920
+
3921
+
3922
+	/**
3923
+	 * A helper for getting a "next link".
3924
+	 *
3925
+	 * @param string $url   The url to link to
3926
+	 * @param string $class The class to use.
3927
+	 * @return string
3928
+	 */
3929
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3930
+	{
3931
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3932
+	}
3933
+
3934
+
3935
+	/**
3936
+	 * A helper for getting a "previous link".
3937
+	 *
3938
+	 * @param string $url   The url to link to
3939
+	 * @param string $class The class to use.
3940
+	 * @return string
3941
+	 */
3942
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3943
+	{
3944
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3945
+	}
3946
+
3947
+
3948
+
3949
+
3950
+
3951
+
3952
+
3953
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3954
+
3955
+
3956
+	/**
3957
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3958
+	 * 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
3959
+	 * _req_data array.
3960
+	 *
3961
+	 * @return bool success/fail
3962
+	 * @throws EE_Error
3963
+	 * @throws InvalidArgumentException
3964
+	 * @throws ReflectionException
3965
+	 * @throws InvalidDataTypeException
3966
+	 * @throws InvalidInterfaceException
3967
+	 */
3968
+	protected function _process_resend_registration()
3969
+	{
3970
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3971
+		do_action(
3972
+			'AHEE__EE_Admin_Page___process_resend_registration',
3973
+			$this->_template_args['success'],
3974
+			$this->request->requestParams()
3975
+		);
3976
+		return $this->_template_args['success'];
3977
+	}
3978
+
3979
+
3980
+	/**
3981
+	 * This automatically processes any payment message notifications when manual payment has been applied.
3982
+	 *
3983
+	 * @param EE_Payment $payment
3984
+	 * @return bool success/fail
3985
+	 */
3986
+	protected function _process_payment_notification(EE_Payment $payment)
3987
+	{
3988
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3989
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3990
+		$this->_template_args['success'] = apply_filters(
3991
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3992
+			false,
3993
+			$payment
3994
+		);
3995
+		return $this->_template_args['success'];
3996
+	}
3997
+
3998
+
3999
+	/**
4000
+	 * @param EEM_Base      $entity_model
4001
+	 * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4002
+	 * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4003
+	 * @param string        $delete_column  name of the field that denotes whether entity is trashed
4004
+	 * @param callable|null $callback       called after entity is trashed, restored, or deleted
4005
+	 * @return int|float
4006
+	 * @throws EE_Error
4007
+	 */
4008
+	protected function trashRestoreDeleteEntities(
4009
+		EEM_Base $entity_model,
4010
+		string $entity_PK_name,
4011
+		string $action = EE_Admin_List_Table::ACTION_DELETE,
4012
+		string $delete_column = '',
4013
+		callable $callback = null
4014
+	) {
4015
+		$entity_PK      = $entity_model->get_primary_key_field();
4016
+		$entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4017
+		$entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4018
+		// grab ID if deleting a single entity
4019
+		if ($this->request->requestParamIsSet($entity_PK_name)) {
4020
+			$ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4021
+			return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4022
+		}
4023
+		// or grab checkbox array if bulk deleting
4024
+		$checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4025
+		if (empty($checkboxes)) {
4026
+			return 0;
4027
+		}
4028
+		$success = 0;
4029
+		$IDs     = array_keys($checkboxes);
4030
+		// cycle thru bulk action checkboxes
4031
+		foreach ($IDs as $ID) {
4032
+			// increment $success
4033
+			if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4034
+				$success++;
4035
+			}
4036
+		}
4037
+		$count = (int) count($checkboxes);
4038
+		// if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4039
+		// otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4040
+		return $success === $count ? $count : $success / $count;
4041
+	}
4042
+
4043
+
4044
+	/**
4045
+	 * @param EE_Primary_Key_Field_Base $entity_PK
4046
+	 * @return string
4047
+	 * @throws EE_Error
4048
+	 * @since   4.10.30.p
4049
+	 */
4050
+	private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK): string
4051
+	{
4052
+		$entity_PK_type = $entity_PK->getSchemaType();
4053
+		switch ($entity_PK_type) {
4054
+			case 'boolean':
4055
+				return 'bool';
4056
+			case 'integer':
4057
+				return 'int';
4058
+			case 'number':
4059
+				return 'float';
4060
+			case 'string':
4061
+				return 'string';
4062
+		}
4063
+		throw new RuntimeException(
4064
+			sprintf(
4065
+				esc_html__(
4066
+					'"%1$s" is an invalid schema type for the %2$s primary key.',
4067
+					'event_espresso'
4068
+				),
4069
+				$entity_PK_type,
4070
+				$entity_PK->get_name()
4071
+			)
4072
+		);
4073
+	}
4074
+
4075
+
4076
+	/**
4077
+	 * @param EEM_Base      $entity_model
4078
+	 * @param int|string    $entity_ID
4079
+	 * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4080
+	 * @param string        $delete_column name of the field that denotes whether entity is trashed
4081
+	 * @param callable|null $callback      called after entity is trashed, restored, or deleted
4082
+	 * @return bool
4083
+	 */
4084
+	protected function trashRestoreDeleteEntity(
4085
+		EEM_Base $entity_model,
4086
+		$entity_ID,
4087
+		string $action,
4088
+		string $delete_column,
4089
+		callable $callback = null
4090
+	) {
4091
+		$entity_ID = absint($entity_ID);
4092
+		if (! $entity_ID) {
4093
+			$this->trashRestoreDeleteError($action, $entity_model);
4094
+		}
4095
+		$result = 0;
4096
+		try {
4097
+			switch ($action) {
4098
+				case EE_Admin_List_Table::ACTION_DELETE:
4099
+					$result = (bool) $entity_model->delete_permanently_by_ID($entity_ID);
4100
+					break;
4101
+				case EE_Admin_List_Table::ACTION_RESTORE:
4102
+					$this->validateDeleteColumn($entity_model, $delete_column);
4103
+					$result = $entity_model->update_by_ID([$delete_column => 0], $entity_ID);
4104
+					break;
4105
+				case EE_Admin_List_Table::ACTION_TRASH:
4106
+					$this->validateDeleteColumn($entity_model, $delete_column);
4107
+					$result = $entity_model->update_by_ID([$delete_column => 1], $entity_ID);
4108
+					break;
4109
+			}
4110
+		} catch (Exception $exception) {
4111
+			$this->trashRestoreDeleteError($action, $entity_model, $exception);
4112
+		}
4113
+		if (is_callable($callback)) {
4114
+			call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4115
+		}
4116
+		return $result;
4117
+	}
4118
+
4119
+
4120
+	/**
4121
+	 * @param EEM_Base $entity_model
4122
+	 * @param string   $delete_column
4123
+	 * @since 4.10.30.p
4124
+	 */
4125
+	private function validateDeleteColumn(EEM_Base $entity_model, string $delete_column)
4126
+	{
4127
+		if (empty($delete_column)) {
4128
+			throw new DomainException(
4129
+				sprintf(
4130
+					esc_html__(
4131
+						'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4132
+						'event_espresso'
4133
+					),
4134
+					$entity_model->get_this_model_name()
4135
+				)
4136
+			);
4137
+		}
4138
+		if (! $entity_model->has_field($delete_column)) {
4139
+			throw new DomainException(
4140
+				sprintf(
4141
+					esc_html__(
4142
+						'The %1$s field does not exist on the %2$s model.',
4143
+						'event_espresso'
4144
+					),
4145
+					$delete_column,
4146
+					$entity_model->get_this_model_name()
4147
+				)
4148
+			);
4149
+		}
4150
+	}
4151
+
4152
+
4153
+	/**
4154
+	 * @param EEM_Base       $entity_model
4155
+	 * @param Exception|null $exception
4156
+	 * @param string         $action
4157
+	 * @since 4.10.30.p
4158
+	 */
4159
+	private function trashRestoreDeleteError(string $action, EEM_Base $entity_model, ?Exception $exception = null)
4160
+	{
4161
+		if ($exception instanceof Exception) {
4162
+			throw new RuntimeException(
4163
+				sprintf(
4164
+					esc_html__(
4165
+						'Could not %1$s the %2$s because the following error occurred: %3$s',
4166
+						'event_espresso'
4167
+					),
4168
+					$action,
4169
+					$entity_model->get_this_model_name(),
4170
+					$exception->getMessage()
4171
+				)
4172
+			);
4173
+		}
4174
+		throw new RuntimeException(
4175
+			sprintf(
4176
+				esc_html__(
4177
+					'Could not %1$s the %2$s because an invalid ID was received.',
4178
+					'event_espresso'
4179
+				),
4180
+				$action,
4181
+				$entity_model->get_this_model_name()
4182
+			)
4183
+		);
4184
+	}
4185 4185
 }
Please login to merge, or discard this patch.
Spacing   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
         $ee_menu_slugs = (array) $ee_menu_slugs;
515 515
         if (
516 516
             ! $this->request->isAjax()
517
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
517
+            && ( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))
518 518
         ) {
519 519
             return;
520 520
         }
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
             : $req_action;
535 535
 
536 536
         $this->_current_view = $this->_req_action;
537
-        $this->_req_nonce    = $this->_req_action . '_nonce';
537
+        $this->_req_nonce    = $this->_req_action.'_nonce';
538 538
         $this->_define_page_props();
539 539
         $this->_current_page_view_url = add_query_arg(
540 540
             ['page' => $this->_current_page, 'action' => $this->_current_view],
@@ -571,21 +571,21 @@  discard block
 block discarded – undo
571 571
         }
572 572
         // filter routes and page_config so addons can add their stuff. Filtering done per class
573 573
         $this->_page_routes = apply_filters(
574
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
574
+            'FHEE__'.get_class($this).'__page_setup__page_routes',
575 575
             $this->_page_routes,
576 576
             $this
577 577
         );
578 578
         $this->_page_config = apply_filters(
579
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
579
+            'FHEE__'.get_class($this).'__page_setup__page_config',
580 580
             $this->_page_config,
581 581
             $this
582 582
         );
583 583
         // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
584 584
         // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
585
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
585
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
586 586
             add_action(
587 587
                 'AHEE__EE_Admin_Page__route_admin_request',
588
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
588
+                [$this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view],
589 589
                 10,
590 590
                 2
591 591
             );
@@ -598,8 +598,8 @@  discard block
 block discarded – undo
598 598
             if ($this->_is_UI_request) {
599 599
                 // admin_init stuff - global, all views for this page class, specific view
600 600
                 add_action('admin_init', [$this, 'admin_init'], 10);
601
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
602
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
601
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
602
+                    add_action('admin_init', [$this, 'admin_init_'.$this->_current_view], 15);
603 603
                 }
604 604
             } else {
605 605
                 // hijack regular WP loading and route admin request immediately
@@ -618,12 +618,12 @@  discard block
 block discarded – undo
618 618
      */
619 619
     private function _do_other_page_hooks()
620 620
     {
621
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
621
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, []);
622 622
         foreach ($registered_pages as $page) {
623 623
             // now let's setup the file name and class that should be present
624 624
             $classname = str_replace('.class.php', '', $page);
625 625
             // autoloaders should take care of loading file
626
-            if (! class_exists($classname)) {
626
+            if ( ! class_exists($classname)) {
627 627
                 $error_msg[] = sprintf(
628 628
                     esc_html__(
629 629
                         'Something went wrong with loading the %s admin hooks page.',
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
                                    ),
641 641
                                    $page,
642 642
                                    '<br />',
643
-                                   '<strong>' . $classname . '</strong>'
643
+                                   '<strong>'.$classname.'</strong>'
644 644
                                );
645 645
                 throw new EE_Error(implode('||', $error_msg));
646 646
             }
@@ -682,13 +682,13 @@  discard block
 block discarded – undo
682 682
         // load admin_notices - global, page class, and view specific
683 683
         add_action('admin_notices', [$this, 'admin_notices_global'], 5);
684 684
         add_action('admin_notices', [$this, 'admin_notices'], 10);
685
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
686
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
685
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
686
+            add_action('admin_notices', [$this, 'admin_notices_'.$this->_current_view], 15);
687 687
         }
688 688
         // load network admin_notices - global, page class, and view specific
689 689
         add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
690
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
691
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
690
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
691
+            add_action('network_admin_notices', [$this, 'network_admin_notices_'.$this->_current_view]);
692 692
         }
693 693
         // this will save any per_page screen options if they are present
694 694
         $this->_set_per_page_screen_options();
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
     protected function _verify_routes()
810 810
     {
811 811
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
812
-        if (! $this->_current_page && ! $this->request->isAjax()) {
812
+        if ( ! $this->_current_page && ! $this->request->isAjax()) {
813 813
             return false;
814 814
         }
815 815
         $this->_route = false;
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
                 $this->_admin_page_title
822 822
             );
823 823
             // developer error msg
824
-            $error_msg .= '||' . $error_msg
824
+            $error_msg .= '||'.$error_msg
825 825
                           . esc_html__(
826 826
                               ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
827 827
                               'event_espresso'
@@ -830,9 +830,9 @@  discard block
 block discarded – undo
830 830
         }
831 831
         // and that the requested page route exists
832 832
         if (array_key_exists($this->_req_action, $this->_page_routes)) {
833
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
834
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
835
-                ? $this->_page_config[ $this->_req_action ]
833
+            $this->_route        = $this->_page_routes[$this->_req_action];
834
+            $this->_route_config = isset($this->_page_config[$this->_req_action])
835
+                ? $this->_page_config[$this->_req_action]
836 836
                 : [];
837 837
         } else {
838 838
             // user error msg
@@ -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
                           . sprintf(
849 849
                               esc_html__(
850 850
                                   ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
             throw new EE_Error($error_msg);
856 856
         }
857 857
         // and that a default route exists
858
-        if (! array_key_exists('default', $this->_page_routes)) {
858
+        if ( ! array_key_exists('default', $this->_page_routes)) {
859 859
             // user error msg
860 860
             $error_msg = sprintf(
861 861
                 esc_html__(
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
                 $this->_admin_page_title
866 866
             );
867 867
             // developer error msg
868
-            $error_msg .= '||' . $error_msg
868
+            $error_msg .= '||'.$error_msg
869 869
                           . esc_html__(
870 870
                               ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
871 871
                               'event_espresso'
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
             $this->_admin_page_title
907 907
         );
908 908
         // developer error msg
909
-        $error_msg .= '||' . $error_msg
909
+        $error_msg .= '||'.$error_msg
910 910
                       . sprintf(
911 911
                           esc_html__(
912 912
                               ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
     protected function _verify_nonce($nonce, $nonce_ref)
932 932
     {
933 933
         // verify nonce against expected value
934
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
934
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
935 935
             // these are not the droids you are looking for !!!
936 936
             $msg = sprintf(
937 937
                 esc_html__('%sNonce Fail.%s', 'event_espresso'),
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
                     __CLASS__
949 949
                 );
950 950
             }
951
-            if (! $this->request->isAjax()) {
951
+            if ( ! $this->request->isAjax()) {
952 952
                 wp_die($msg);
953 953
             }
954 954
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
      */
973 973
     protected function _route_admin_request()
974 974
     {
975
-        if (! $this->_is_UI_request) {
975
+        if ( ! $this->_is_UI_request) {
976 976
             $this->_verify_routes();
977 977
         }
978 978
         $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
         $error_msg = '';
993 993
         // action right before calling route
994 994
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
995
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
995
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
996 996
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
997 997
         }
998 998
         // right before calling the route, let's clean the _wp_http_referer
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
                 wp_unslash($this->request->getServerParam('REQUEST_URI'))
1004 1004
             )
1005 1005
         );
1006
-        if (! empty($func)) {
1006
+        if ( ! empty($func)) {
1007 1007
             if (is_array($func)) {
1008 1008
                 [$class, $method] = $func;
1009 1009
             } elseif (strpos($func, '::') !== false) {
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
                 $class  = $this;
1013 1013
                 $method = $func;
1014 1014
             }
1015
-            if (! (is_object($class) && $class === $this)) {
1015
+            if ( ! (is_object($class) && $class === $this)) {
1016 1016
                 // send along this admin page object for access by addons.
1017 1017
                 $args['admin_page_object'] = $this;
1018 1018
             }
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
                     $method
1054 1054
                 );
1055 1055
             }
1056
-            if (! empty($error_msg)) {
1056
+            if ( ! empty($error_msg)) {
1057 1057
                 throw new EE_Error($error_msg);
1058 1058
             }
1059 1059
         }
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
                 if (strpos($key, 'nonce') !== false) {
1139 1139
                     continue;
1140 1140
                 }
1141
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1141
+                $args['wp_referer['.$key.']'] = is_string($value) ? htmlspecialchars($value) : $value;
1142 1142
             }
1143 1143
         }
1144 1144
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1177,12 +1177,12 @@  discard block
 block discarded – undo
1177 1177
      */
1178 1178
     protected function _add_help_tabs()
1179 1179
     {
1180
-        if (isset($this->_page_config[ $this->_req_action ])) {
1181
-            $config = $this->_page_config[ $this->_req_action ];
1180
+        if (isset($this->_page_config[$this->_req_action])) {
1181
+            $config = $this->_page_config[$this->_req_action];
1182 1182
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1183 1183
             if (is_array($config) && isset($config['help_sidebar'])) {
1184 1184
                 // check that the callback given is valid
1185
-                if (! method_exists($this, $config['help_sidebar'])) {
1185
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1186 1186
                     throw new EE_Error(
1187 1187
                         sprintf(
1188 1188
                             esc_html__(
@@ -1195,18 +1195,18 @@  discard block
 block discarded – undo
1195 1195
                     );
1196 1196
                 }
1197 1197
                 $content = apply_filters(
1198
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1198
+                    'FHEE__'.get_class($this).'__add_help_tabs__help_sidebar',
1199 1199
                     $this->{$config['help_sidebar']}()
1200 1200
                 );
1201 1201
                 $this->_current_screen->set_help_sidebar($content);
1202 1202
             }
1203
-            if (! isset($config['help_tabs'])) {
1203
+            if ( ! isset($config['help_tabs'])) {
1204 1204
                 return;
1205 1205
             } //no help tabs for this route
1206 1206
             foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1207 1207
                 // we're here so there ARE help tabs!
1208 1208
                 // make sure we've got what we need
1209
-                if (! isset($cfg['title'])) {
1209
+                if ( ! isset($cfg['title'])) {
1210 1210
                     throw new EE_Error(
1211 1211
                         esc_html__(
1212 1212
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1214,7 +1214,7 @@  discard block
 block discarded – undo
1214 1214
                         )
1215 1215
                     );
1216 1216
                 }
1217
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1217
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1218 1218
                     throw new EE_Error(
1219 1219
                         esc_html__(
1220 1220
                             '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',
@@ -1223,11 +1223,11 @@  discard block
 block discarded – undo
1223 1223
                     );
1224 1224
                 }
1225 1225
                 // first priority goes to content.
1226
-                if (! empty($cfg['content'])) {
1226
+                if ( ! empty($cfg['content'])) {
1227 1227
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1228 1228
                     // second priority goes to filename
1229
-                } elseif (! empty($cfg['filename'])) {
1230
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1229
+                } elseif ( ! empty($cfg['filename'])) {
1230
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1231 1231
                     // 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)
1232 1232
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1233 1233
                                                              . basename($this->_get_dir())
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
                                                              . $cfg['filename']
1236 1236
                                                              . '.help_tab.php' : $file_path;
1237 1237
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1238
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1238
+                    if ( ! isset($cfg['callback']) && ! is_readable($file_path)) {
1239 1239
                         EE_Error::add_error(
1240 1240
                             sprintf(
1241 1241
                                 esc_html__(
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
                     return;
1284 1284
                 }
1285 1285
                 // setup config array for help tab method
1286
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1286
+                $id  = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1287 1287
                 $_ht = [
1288 1288
                     'id'       => $id,
1289 1289
                     'title'    => $cfg['title'],
@@ -1307,8 +1307,8 @@  discard block
 block discarded – undo
1307 1307
             $qtips = (array) $this->_route_config['qtips'];
1308 1308
             // load qtip loader
1309 1309
             $path = [
1310
-                $this->_get_dir() . '/qtips/',
1311
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1310
+                $this->_get_dir().'/qtips/',
1311
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1312 1312
             ];
1313 1313
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1314 1314
         }
@@ -1330,7 +1330,7 @@  discard block
 block discarded – undo
1330 1330
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1331 1331
         $i = 0;
1332 1332
         foreach ($this->_page_config as $slug => $config) {
1333
-            if (! is_array($config) || empty($config['nav'])) {
1333
+            if ( ! is_array($config) || empty($config['nav'])) {
1334 1334
                 continue;
1335 1335
             }
1336 1336
             // no nav tab for this config
@@ -1339,12 +1339,12 @@  discard block
 block discarded – undo
1339 1339
                 // nav tab is only to appear when route requested.
1340 1340
                 continue;
1341 1341
             }
1342
-            if (! $this->check_user_access($slug, true)) {
1342
+            if ( ! $this->check_user_access($slug, true)) {
1343 1343
                 // no nav tab because current user does not have access.
1344 1344
                 continue;
1345 1345
             }
1346
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1347
-            $this->_nav_tabs[ $slug ] = [
1346
+            $css_class                = isset($config['css_class']) ? $config['css_class'].' ' : '';
1347
+            $this->_nav_tabs[$slug] = [
1348 1348
                 'url'       => isset($config['nav']['url'])
1349 1349
                     ? $config['nav']['url']
1350 1350
                     : self::add_query_args_and_nonce(
@@ -1356,14 +1356,14 @@  discard block
 block discarded – undo
1356 1356
                     : ucwords(
1357 1357
                         str_replace('_', ' ', $slug)
1358 1358
                     ),
1359
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1359
+                'css_class' => $this->_req_action === $slug ? $css_class.'nav-tab-active' : $css_class,
1360 1360
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1361 1361
             ];
1362 1362
             $i++;
1363 1363
         }
1364 1364
         // if $this->_nav_tabs is empty then lets set the default
1365 1365
         if (empty($this->_nav_tabs)) {
1366
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1366
+            $this->_nav_tabs[$this->_default_nav_tab_name] = [
1367 1367
                 'url'       => $this->_admin_base_url,
1368 1368
                 'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1369 1369
                 'css_class' => 'nav-tab-active',
@@ -1388,10 +1388,10 @@  discard block
 block discarded – undo
1388 1388
             foreach ($this->_route_config['labels'] as $label => $text) {
1389 1389
                 if (is_array($text)) {
1390 1390
                     foreach ($text as $sublabel => $subtext) {
1391
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1391
+                        $this->_labels[$label][$sublabel] = $subtext;
1392 1392
                     }
1393 1393
                 } else {
1394
-                    $this->_labels[ $label ] = $text;
1394
+                    $this->_labels[$label] = $text;
1395 1395
                 }
1396 1396
             }
1397 1397
         }
@@ -1413,12 +1413,12 @@  discard block
 block discarded – undo
1413 1413
     {
1414 1414
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1415 1415
         $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1416
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1416
+        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1417 1417
                           && is_array(
1418
-                              $this->_page_routes[ $route_to_check ]
1418
+                              $this->_page_routes[$route_to_check]
1419 1419
                           )
1420
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1421
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1420
+                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1421
+            ? $this->_page_routes[$route_to_check]['capability'] : null;
1422 1422
         if (empty($capability) && empty($route_to_check)) {
1423 1423
             $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1424 1424
                 : $this->_route['capability'];
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
         ';
1539 1539
 
1540 1540
         // current set timezone for timezone js
1541
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1541
+        echo '<span id="current_timezone" class="hidden">'.esc_html(EEH_DTT_Helper::get_timezone()).'</span>';
1542 1542
     }
1543 1543
 
1544 1544
 
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
         // loop through the array and setup content
1573 1573
         foreach ($help_array as $trigger => $help) {
1574 1574
             // make sure the array is setup properly
1575
-            if (! isset($help['title']) || ! isset($help['content'])) {
1575
+            if ( ! isset($help['title']) || ! isset($help['content'])) {
1576 1576
                 throw new EE_Error(
1577 1577
                     esc_html__(
1578 1578
                         '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',
@@ -1586,8 +1586,8 @@  discard block
 block discarded – undo
1586 1586
                 'help_popup_title'   => $help['title'],
1587 1587
                 'help_popup_content' => $help['content'],
1588 1588
             ];
1589
-            $content       .= EEH_Template::display_template(
1590
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1589
+            $content .= EEH_Template::display_template(
1590
+                EE_ADMIN_TEMPLATE.'admin_help_popup.template.php',
1591 1591
                 $template_args,
1592 1592
                 true
1593 1593
             );
@@ -1609,15 +1609,15 @@  discard block
 block discarded – undo
1609 1609
     private function _get_help_content()
1610 1610
     {
1611 1611
         // what is the method we're looking for?
1612
-        $method_name = '_help_popup_content_' . $this->_req_action;
1612
+        $method_name = '_help_popup_content_'.$this->_req_action;
1613 1613
         // if method doesn't exist let's get out.
1614
-        if (! method_exists($this, $method_name)) {
1614
+        if ( ! method_exists($this, $method_name)) {
1615 1615
             return [];
1616 1616
         }
1617 1617
         // k we're good to go let's retrieve the help array
1618 1618
         $help_array = call_user_func([$this, $method_name]);
1619 1619
         // make sure we've got an array!
1620
-        if (! is_array($help_array)) {
1620
+        if ( ! is_array($help_array)) {
1621 1621
             throw new EE_Error(
1622 1622
                 esc_html__(
1623 1623
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1649,15 +1649,15 @@  discard block
 block discarded – undo
1649 1649
         // 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
1650 1650
         $help_array   = $this->_get_help_content();
1651 1651
         $help_content = '';
1652
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1653
-            $help_array[ $trigger_id ] = [
1652
+        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1653
+            $help_array[$trigger_id] = [
1654 1654
                 'title'   => esc_html__('Missing Content', 'event_espresso'),
1655 1655
                 'content' => esc_html__(
1656 1656
                     '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.)',
1657 1657
                     'event_espresso'
1658 1658
                 ),
1659 1659
             ];
1660
-            $help_content              = $this->_set_help_popup_content($help_array);
1660
+            $help_content = $this->_set_help_popup_content($help_array);
1661 1661
         }
1662 1662
         // let's setup the trigger
1663 1663
         $content = '<a class="ee-dialog" href="?height='
@@ -1725,15 +1725,15 @@  discard block
 block discarded – undo
1725 1725
         // register all styles
1726 1726
         wp_register_style(
1727 1727
             'espresso-ui-theme',
1728
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1728
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1729 1729
             [],
1730 1730
             EVENT_ESPRESSO_VERSION
1731 1731
         );
1732
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1732
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1733 1733
         // helpers styles
1734 1734
         wp_register_style(
1735 1735
             'ee-text-links',
1736
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1736
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css',
1737 1737
             [],
1738 1738
             EVENT_ESPRESSO_VERSION
1739 1739
         );
@@ -1741,21 +1741,21 @@  discard block
 block discarded – undo
1741 1741
         // register all scripts
1742 1742
         wp_register_script(
1743 1743
             'ee-dialog',
1744
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1744
+            EE_ADMIN_URL.'assets/ee-dialog-helper.js',
1745 1745
             ['jquery', 'jquery-ui-draggable'],
1746 1746
             EVENT_ESPRESSO_VERSION,
1747 1747
             true
1748 1748
         );
1749 1749
         wp_register_script(
1750 1750
             'ee_admin_js',
1751
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1751
+            EE_ADMIN_URL.'assets/ee-admin-page.js',
1752 1752
             ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1753 1753
             EVENT_ESPRESSO_VERSION,
1754 1754
             true
1755 1755
         );
1756 1756
         wp_register_script(
1757 1757
             'jquery-ui-timepicker-addon',
1758
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1758
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js',
1759 1759
             ['jquery-ui-datepicker', 'jquery-ui-slider'],
1760 1760
             EVENT_ESPRESSO_VERSION,
1761 1761
             true
@@ -1763,7 +1763,7 @@  discard block
 block discarded – undo
1763 1763
         // script for sorting tables
1764 1764
         wp_register_script(
1765 1765
             'espresso_ajax_table_sorting',
1766
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1766
+            EE_ADMIN_URL.'assets/espresso_ajax_table_sorting.js',
1767 1767
             ['ee_admin_js', 'jquery-ui-sortable'],
1768 1768
             EVENT_ESPRESSO_VERSION,
1769 1769
             true
@@ -1771,7 +1771,7 @@  discard block
 block discarded – undo
1771 1771
         // script for parsing uri's
1772 1772
         wp_register_script(
1773 1773
             'ee-parse-uri',
1774
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1774
+            EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js',
1775 1775
             [],
1776 1776
             EVENT_ESPRESSO_VERSION,
1777 1777
             true
@@ -1779,7 +1779,7 @@  discard block
 block discarded – undo
1779 1779
         // and parsing associative serialized form elements
1780 1780
         wp_register_script(
1781 1781
             'ee-serialize-full-array',
1782
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1782
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js',
1783 1783
             ['jquery'],
1784 1784
             EVENT_ESPRESSO_VERSION,
1785 1785
             true
@@ -1787,28 +1787,28 @@  discard block
 block discarded – undo
1787 1787
         // helpers scripts
1788 1788
         wp_register_script(
1789 1789
             'ee-text-links',
1790
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1790
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js',
1791 1791
             ['jquery'],
1792 1792
             EVENT_ESPRESSO_VERSION,
1793 1793
             true
1794 1794
         );
1795 1795
         wp_register_script(
1796 1796
             'ee-moment-core',
1797
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1797
+            EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js',
1798 1798
             [],
1799 1799
             EVENT_ESPRESSO_VERSION,
1800 1800
             true
1801 1801
         );
1802 1802
         wp_register_script(
1803 1803
             'ee-moment',
1804
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1804
+            EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js',
1805 1805
             ['ee-moment-core'],
1806 1806
             EVENT_ESPRESSO_VERSION,
1807 1807
             true
1808 1808
         );
1809 1809
         wp_register_script(
1810 1810
             'ee-datepicker',
1811
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1811
+            EE_ADMIN_URL.'assets/ee-datepicker.js',
1812 1812
             ['jquery-ui-timepicker-addon', 'ee-moment'],
1813 1813
             EVENT_ESPRESSO_VERSION,
1814 1814
             true
@@ -1841,7 +1841,7 @@  discard block
 block discarded – undo
1841 1841
         wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1842 1842
         add_filter(
1843 1843
             'admin_body_class',
1844
-            function ($classes) {
1844
+            function($classes) {
1845 1845
                 if (strpos($classes, 'espresso-admin') === false) {
1846 1846
                     $classes .= ' espresso-admin';
1847 1847
                 }
@@ -1929,12 +1929,12 @@  discard block
 block discarded – undo
1929 1929
     protected function _set_list_table()
1930 1930
     {
1931 1931
         // first is this a list_table view?
1932
-        if (! isset($this->_route_config['list_table'])) {
1932
+        if ( ! isset($this->_route_config['list_table'])) {
1933 1933
             return;
1934 1934
         } //not a list_table view so get out.
1935 1935
         // list table functions are per view specific (because some admin pages might have more than one list table!)
1936
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
1937
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1936
+        $list_table_view = '_set_list_table_views_'.$this->_req_action;
1937
+        if ( ! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1938 1938
             // user error msg
1939 1939
             $error_msg = esc_html__(
1940 1940
                 'An error occurred. The requested list table views could not be found.',
@@ -1954,10 +1954,10 @@  discard block
 block discarded – undo
1954 1954
         }
1955 1955
         // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1956 1956
         $this->_views = apply_filters(
1957
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1957
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
1958 1958
             $this->_views
1959 1959
         );
1960
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1960
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
1961 1961
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1962 1962
         $this->_set_list_table_view();
1963 1963
         $this->_set_list_table_object();
@@ -1992,7 +1992,7 @@  discard block
 block discarded – undo
1992 1992
     protected function _set_list_table_object()
1993 1993
     {
1994 1994
         if (isset($this->_route_config['list_table'])) {
1995
-            if (! class_exists($this->_route_config['list_table'])) {
1995
+            if ( ! class_exists($this->_route_config['list_table'])) {
1996 1996
                 throw new EE_Error(
1997 1997
                     sprintf(
1998 1998
                         esc_html__(
@@ -2030,15 +2030,15 @@  discard block
 block discarded – undo
2030 2030
         foreach ($this->_views as $key => $view) {
2031 2031
             $query_args = [];
2032 2032
             // check for current view
2033
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2033
+            $this->_views[$key]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2034 2034
             $query_args['action']                        = $this->_req_action;
2035
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2035
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2036 2036
             $query_args['status']                        = $view['slug'];
2037 2037
             // merge any other arguments sent in.
2038
-            if (isset($extra_query_args[ $view['slug'] ])) {
2039
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2038
+            if (isset($extra_query_args[$view['slug']])) {
2039
+                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2040 2040
             }
2041
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2041
+            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2042 2042
         }
2043 2043
         return $this->_views;
2044 2044
     }
@@ -2069,14 +2069,14 @@  discard block
 block discarded – undo
2069 2069
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2070 2070
         foreach ($values as $value) {
2071 2071
             if ($value < $max_entries) {
2072
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2072
+                $selected = $value === $per_page ? ' selected="'.$per_page.'"' : '';
2073 2073
                 $entries_per_page_dropdown .= '
2074
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2074
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2075 2075
             }
2076 2076
         }
2077
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2077
+        $selected = $max_entries === $per_page ? ' selected="'.$per_page.'"' : '';
2078 2078
         $entries_per_page_dropdown .= '
2079
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2079
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2080 2080
         $entries_per_page_dropdown .= '
2081 2081
 					</select>
2082 2082
 					entries
@@ -2100,7 +2100,7 @@  discard block
 block discarded – undo
2100 2100
             empty($this->_search_btn_label) ? $this->page_label
2101 2101
                 : $this->_search_btn_label
2102 2102
         );
2103
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2103
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2104 2104
     }
2105 2105
 
2106 2106
 
@@ -2188,7 +2188,7 @@  discard block
 block discarded – undo
2188 2188
             $total_columns                                       = ! empty($screen_columns)
2189 2189
                 ? $screen_columns
2190 2190
                 : $this->_route_config['columns'][1];
2191
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2191
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2192 2192
             $this->_template_args['current_page']                = $this->_wp_page_slug;
2193 2193
             $this->_template_args['screen']                      = $this->_current_screen;
2194 2194
             $this->_column_template_path                         = EE_ADMIN_TEMPLATE
@@ -2233,7 +2233,7 @@  discard block
 block discarded – undo
2233 2233
      */
2234 2234
     protected function _espresso_ratings_request()
2235 2235
     {
2236
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2236
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2237 2237
             return;
2238 2238
         }
2239 2239
         $ratings_box_title = apply_filters(
@@ -2261,7 +2261,7 @@  discard block
 block discarded – undo
2261 2261
     public function espresso_ratings_request()
2262 2262
     {
2263 2263
         EEH_Template::display_template(
2264
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2264
+            EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php',
2265 2265
             []
2266 2266
         );
2267 2267
     }
@@ -2269,22 +2269,22 @@  discard block
 block discarded – undo
2269 2269
 
2270 2270
     public static function cached_rss_display($rss_id, $url)
2271 2271
     {
2272
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2272
+        $loading = '<p class="widget-loading hide-if-no-js">'
2273 2273
                      . esc_html__('Loading&#8230;', 'event_espresso')
2274 2274
                      . '</p><p class="hide-if-js">'
2275 2275
                      . esc_html__('This widget requires JavaScript.', 'event_espresso')
2276 2276
                      . '</p>';
2277
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2278
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2279
-        $post      = '</div>' . "\n";
2280
-        $cache_key = 'ee_rss_' . md5($rss_id);
2277
+        $pre       = '<div class="espresso-rss-display">'."\n\t";
2278
+        $pre .= '<span id="'.esc_attr($rss_id).'_url" class="hidden">'.esc_url_raw($url).'</span>';
2279
+        $post      = '</div>'."\n";
2280
+        $cache_key = 'ee_rss_'.md5($rss_id);
2281 2281
         $output    = get_transient($cache_key);
2282 2282
         if ($output !== false) {
2283
-            echo wp_kses($pre . $output . $post, AllowedTags::getWithFormTags());
2283
+            echo wp_kses($pre.$output.$post, AllowedTags::getWithFormTags());
2284 2284
             return true;
2285 2285
         }
2286
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2287
-            echo wp_kses($pre . $loading . $post, AllowedTags::getWithFormTags());
2286
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
2287
+            echo wp_kses($pre.$loading.$post, AllowedTags::getWithFormTags());
2288 2288
             return false;
2289 2289
         }
2290 2290
         ob_start();
@@ -2351,19 +2351,19 @@  discard block
 block discarded – undo
2351 2351
     public function espresso_sponsors_post_box()
2352 2352
     {
2353 2353
         EEH_Template::display_template(
2354
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2354
+            EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'
2355 2355
         );
2356 2356
     }
2357 2357
 
2358 2358
 
2359 2359
     private function _publish_post_box()
2360 2360
     {
2361
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2361
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2362 2362
         // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2363 2363
         // then we'll use that for the metabox label.
2364 2364
         // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2365
-        if (! empty($this->_labels['publishbox'])) {
2366
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2365
+        if ( ! empty($this->_labels['publishbox'])) {
2366
+            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2367 2367
                 : $this->_labels['publishbox'];
2368 2368
         } else {
2369 2369
             $box_label = esc_html__('Publish', 'event_espresso');
@@ -2392,7 +2392,7 @@  discard block
 block discarded – undo
2392 2392
             ? $this->_template_args['publish_box_extra_content']
2393 2393
             : '';
2394 2394
         echo EEH_Template::display_template(
2395
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2395
+            EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php',
2396 2396
             $this->_template_args,
2397 2397
             true
2398 2398
         );
@@ -2484,18 +2484,18 @@  discard block
 block discarded – undo
2484 2484
             );
2485 2485
         }
2486 2486
         $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2487
-        if (! empty($name) && ! empty($id)) {
2488
-            $hidden_field_arr[ $name ] = [
2487
+        if ( ! empty($name) && ! empty($id)) {
2488
+            $hidden_field_arr[$name] = [
2489 2489
                 'type'  => 'hidden',
2490 2490
                 'value' => $id,
2491 2491
             ];
2492
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2492
+            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2493 2493
         } else {
2494 2494
             $hf = '';
2495 2495
         }
2496 2496
         // add hidden field
2497 2497
         $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2498
-            ? $hf[ $name ]['field']
2498
+            ? $hf[$name]['field']
2499 2499
             : $hf;
2500 2500
     }
2501 2501
 
@@ -2597,7 +2597,7 @@  discard block
 block discarded – undo
2597 2597
         }
2598 2598
         // 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)
2599 2599
         $call_back_func = $create_func
2600
-            ? function ($post, $metabox) {
2600
+            ? function($post, $metabox) {
2601 2601
                 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2602 2602
                 echo EEH_Template::display_template(
2603 2603
                     $metabox['args']['template_path'],
@@ -2607,7 +2607,7 @@  discard block
 block discarded – undo
2607 2607
             }
2608 2608
             : $callback;
2609 2609
         add_meta_box(
2610
-            str_replace('_', '-', $action) . '-mbox',
2610
+            str_replace('_', '-', $action).'-mbox',
2611 2611
             $title,
2612 2612
             $call_back_func,
2613 2613
             $this->_wp_page_slug,
@@ -2699,9 +2699,9 @@  discard block
 block discarded – undo
2699 2699
             : 'espresso-default-admin';
2700 2700
         $template_path                                     = $sidebar
2701 2701
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2702
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2702
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2703 2703
         if ($this->request->isAjax()) {
2704
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2704
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2705 2705
         }
2706 2706
         $template_path                                     = ! empty($this->_column_template_path)
2707 2707
             ? $this->_column_template_path : $template_path;
@@ -2741,11 +2741,11 @@  discard block
 block discarded – undo
2741 2741
     public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2742 2742
     {
2743 2743
         // let's generate a default preview action button if there isn't one already present.
2744
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2744
+        $this->_labels['buttons']['buy_now'] = esc_html__(
2745 2745
             'Upgrade to Event Espresso 4 Right Now',
2746 2746
             'event_espresso'
2747 2747
         );
2748
-        $buy_now_url                                   = add_query_arg(
2748
+        $buy_now_url = add_query_arg(
2749 2749
             [
2750 2750
                 'ee_ver'       => 'ee4',
2751 2751
                 'utm_source'   => 'ee4_plugin_admin',
@@ -2765,8 +2765,8 @@  discard block
 block discarded – undo
2765 2765
                 true
2766 2766
             )
2767 2767
             : $this->_template_args['preview_action_button'];
2768
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2769
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2768
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2769
+            EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php',
2770 2770
             $this->_template_args,
2771 2771
             true
2772 2772
         );
@@ -2815,7 +2815,7 @@  discard block
 block discarded – undo
2815 2815
         // setup search attributes
2816 2816
         $this->_set_search_attributes();
2817 2817
         $this->_template_args['current_page']     = $this->_wp_page_slug;
2818
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2818
+        $template_path                            = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2819 2819
         $this->_template_args['table_url']        = $this->request->isAjax()
2820 2820
             ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2821 2821
             : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
@@ -2823,10 +2823,10 @@  discard block
 block discarded – undo
2823 2823
         $this->_template_args['current_route']    = $this->_req_action;
2824 2824
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2825 2825
         $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2826
-        if (! empty($ajax_sorting_callback)) {
2826
+        if ( ! empty($ajax_sorting_callback)) {
2827 2827
             $sortable_list_table_form_fields = wp_nonce_field(
2828
-                $ajax_sorting_callback . '_nonce',
2829
-                $ajax_sorting_callback . '_nonce',
2828
+                $ajax_sorting_callback.'_nonce',
2829
+                $ajax_sorting_callback.'_nonce',
2830 2830
                 false,
2831 2831
                 false
2832 2832
             );
@@ -2844,20 +2844,20 @@  discard block
 block discarded – undo
2844 2844
             isset($this->_template_args['list_table_hidden_fields'])
2845 2845
                 ? $this->_template_args['list_table_hidden_fields']
2846 2846
                 : '';
2847
-        $nonce_ref                                               = $this->_req_action . '_nonce';
2848
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
2847
+        $nonce_ref = $this->_req_action.'_nonce';
2848
+        $hidden_form_fields .= '<input type="hidden" name="'
2849 2849
                                                                     . $nonce_ref
2850 2850
                                                                     . '" value="'
2851 2851
                                                                     . wp_create_nonce($nonce_ref)
2852 2852
                                                                     . '">';
2853
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2853
+        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2854 2854
         // display message about search results?
2855 2855
         $search = $this->request->getRequestParam('s');
2856 2856
         $this->_template_args['before_list_table'] .= ! empty($search)
2857
-            ? '<p class="ee-search-results">' . sprintf(
2857
+            ? '<p class="ee-search-results">'.sprintf(
2858 2858
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2859 2859
                 trim($search, '%')
2860
-            ) . '</p>'
2860
+            ).'</p>'
2861 2861
             : '';
2862 2862
         // filter before_list_table template arg
2863 2863
         $this->_template_args['before_list_table'] = apply_filters(
@@ -2891,7 +2891,7 @@  discard block
 block discarded – undo
2891 2891
         // convert to array and filter again
2892 2892
         // arrays are easier to inject new items in a specific location,
2893 2893
         // but would not be backwards compatible, so we have to add a new filter
2894
-        $this->_template_args['after_list_table']   = implode(
2894
+        $this->_template_args['after_list_table'] = implode(
2895 2895
             " \n",
2896 2896
             (array) apply_filters(
2897 2897
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
@@ -2938,7 +2938,7 @@  discard block
 block discarded – undo
2938 2938
             $this
2939 2939
         );
2940 2940
         return EEH_Template::display_template(
2941
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2941
+            EE_ADMIN_TEMPLATE.'admin_details_legend.template.php',
2942 2942
             $this->_template_args,
2943 2943
             true
2944 2944
         );
@@ -3047,18 +3047,18 @@  discard block
 block discarded – undo
3047 3047
                 : ''
3048 3048
         );
3049 3049
 
3050
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3050
+        $this->_template_args['after_admin_page_content'] = apply_filters(
3051 3051
             "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3052 3052
             isset($this->_template_args['after_admin_page_content'])
3053 3053
                 ? $this->_template_args['after_admin_page_content']
3054 3054
                 : ''
3055 3055
         );
3056
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3056
+        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3057 3057
 
3058 3058
         if ($this->request->isAjax()) {
3059 3059
             $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3060 3060
                 // $template_path,
3061
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3061
+                EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php',
3062 3062
                 $this->_template_args,
3063 3063
                 true
3064 3064
             );
@@ -3067,7 +3067,7 @@  discard block
 block discarded – undo
3067 3067
         // load settings page wrapper template
3068 3068
         $template_path = $about
3069 3069
             ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3070
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3070
+            : EE_ADMIN_TEMPLATE.'admin_wrapper.template.php';
3071 3071
 
3072 3072
         EEH_Template::display_template($template_path, $this->_template_args);
3073 3073
     }
@@ -3152,12 +3152,12 @@  discard block
 block discarded – undo
3152 3152
         $default_names = ['save', 'save_and_close'];
3153 3153
         $buttons = '';
3154 3154
         foreach ($button_text as $key => $button) {
3155
-            $ref     = $default_names[ $key ];
3156
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3157
-            $buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3158
-                        . 'value="' . $button . '" name="' . $name . '" '
3159
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3160
-            if (! $both) {
3155
+            $ref     = $default_names[$key];
3156
+            $name    = ! empty($actions) ? $actions[$key] : $ref;
3157
+            $buttons .= '<input type="submit" class="button-primary '.$ref.'" '
3158
+                        . 'value="'.$button.'" name="'.$name.'" '
3159
+                        . 'id="'.$this->_current_view.'_'.$ref.'" />';
3160
+            if ( ! $both) {
3161 3161
                 break;
3162 3162
             }
3163 3163
         }
@@ -3197,13 +3197,13 @@  discard block
 block discarded – undo
3197 3197
                 'An error occurred. No action was set for this page\'s form.',
3198 3198
                 'event_espresso'
3199 3199
             );
3200
-            $dev_msg  = $user_msg . "\n"
3200
+            $dev_msg = $user_msg."\n"
3201 3201
                         . sprintf(
3202 3202
                             esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3203 3203
                             __FUNCTION__,
3204 3204
                             __CLASS__
3205 3205
                         );
3206
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3206
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3207 3207
         }
3208 3208
         // open form
3209 3209
         $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
@@ -3212,9 +3212,9 @@  discard block
 block discarded – undo
3212 3212
                                                              . $route
3213 3213
                                                              . '_event_form" >';
3214 3214
         // add nonce
3215
-        $nonce                                             =
3216
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3217
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3215
+        $nonce =
3216
+            wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3217
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3218 3218
         // add REQUIRED form action
3219 3219
         $hidden_fields = [
3220 3220
             'action' => ['type' => 'hidden', 'value' => $route],
@@ -3227,7 +3227,7 @@  discard block
 block discarded – undo
3227 3227
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3228 3228
         // add fields to form
3229 3229
         foreach ((array) $form_fields as $form_field) {
3230
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3230
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3231 3231
         }
3232 3232
         // close form
3233 3233
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3318,10 +3318,10 @@  discard block
 block discarded – undo
3318 3318
         $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3319 3319
         $notices      = EE_Error::get_notices(false);
3320 3320
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3321
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3321
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3322 3322
             EE_Error::overwrite_success();
3323 3323
         }
3324
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3324
+        if ( ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3325 3325
             // how many records affected ? more than one record ? or just one ?
3326 3326
             if ($success > 1) {
3327 3327
                 // set plural msg
@@ -3350,7 +3350,7 @@  discard block
 block discarded – undo
3350 3350
             }
3351 3351
         }
3352 3352
         // check that $query_args isn't something crazy
3353
-        if (! is_array($query_args)) {
3353
+        if ( ! is_array($query_args)) {
3354 3354
             $query_args = [];
3355 3355
         }
3356 3356
         /**
@@ -3379,7 +3379,7 @@  discard block
 block discarded – undo
3379 3379
             $redirect_url = admin_url('admin.php');
3380 3380
         }
3381 3381
         // merge any default query_args set in _default_route_query_args property
3382
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3382
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3383 3383
             $args_to_merge = [];
3384 3384
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3385 3385
                 // is there a wp_referer array in our _default_route_query_args property?
@@ -3391,15 +3391,15 @@  discard block
 block discarded – undo
3391 3391
                         }
3392 3392
                         // finally we will override any arguments in the referer with
3393 3393
                         // what might be set on the _default_route_query_args array.
3394
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3395
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3394
+                        if (isset($this->_default_route_query_args[$reference])) {
3395
+                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3396 3396
                         } else {
3397
-                            $args_to_merge[ $reference ] = urlencode($value);
3397
+                            $args_to_merge[$reference] = urlencode($value);
3398 3398
                         }
3399 3399
                     }
3400 3400
                     continue;
3401 3401
                 }
3402
-                $args_to_merge[ $query_param ] = $query_value;
3402
+                $args_to_merge[$query_param] = $query_value;
3403 3403
             }
3404 3404
             // now let's merge these arguments but override with what was specifically sent in to the
3405 3405
             // redirect.
@@ -3411,19 +3411,19 @@  discard block
 block discarded – undo
3411 3411
         if (isset($query_args['action'])) {
3412 3412
             // manually generate wp_nonce and merge that with the query vars
3413 3413
             // becuz the wp_nonce_url function wrecks havoc on some vars
3414
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3414
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3415 3415
         }
3416 3416
         // we're adding some hooks and filters in here for processing any things just before redirects
3417 3417
         // (example: an admin page has done an insert or update and we want to run something after that).
3418
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3418
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
3419 3419
         $redirect_url = apply_filters(
3420
-            'FHEE_redirect_' . $classname . $this->_req_action,
3420
+            'FHEE_redirect_'.$classname.$this->_req_action,
3421 3421
             self::add_query_args_and_nonce($query_args, $redirect_url),
3422 3422
             $query_args
3423 3423
         );
3424 3424
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3425 3425
         if ($this->request->isAjax()) {
3426
-            $default_data                    = [
3426
+            $default_data = [
3427 3427
                 'close'        => true,
3428 3428
                 'redirect_url' => $redirect_url,
3429 3429
                 'where'        => 'main',
@@ -3470,7 +3470,7 @@  discard block
 block discarded – undo
3470 3470
         }
3471 3471
         $this->_template_args['notices'] = EE_Error::get_notices();
3472 3472
         // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3473
-        if (! $this->request->isAjax() || $sticky_notices) {
3473
+        if ( ! $this->request->isAjax() || $sticky_notices) {
3474 3474
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3475 3475
             $this->_add_transient(
3476 3476
                 $route,
@@ -3510,7 +3510,7 @@  discard block
 block discarded – undo
3510 3510
         $exclude_nonce = false
3511 3511
     ) {
3512 3512
         // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3513
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3513
+        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3514 3514
             throw new EE_Error(
3515 3515
                 sprintf(
3516 3516
                     esc_html__(
@@ -3521,7 +3521,7 @@  discard block
 block discarded – undo
3521 3521
                 )
3522 3522
             );
3523 3523
         }
3524
-        if (! isset($this->_labels['buttons'][ $type ])) {
3524
+        if ( ! isset($this->_labels['buttons'][$type])) {
3525 3525
             throw new EE_Error(
3526 3526
                 sprintf(
3527 3527
                     esc_html__(
@@ -3534,7 +3534,7 @@  discard block
 block discarded – undo
3534 3534
         }
3535 3535
         // finally check user access for this button.
3536 3536
         $has_access = $this->check_user_access($action, true);
3537
-        if (! $has_access) {
3537
+        if ( ! $has_access) {
3538 3538
             return '';
3539 3539
         }
3540 3540
         $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3542,11 +3542,11 @@  discard block
 block discarded – undo
3542 3542
             'action' => $action,
3543 3543
         ];
3544 3544
         // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3545
-        if (! empty($extra_request)) {
3545
+        if ( ! empty($extra_request)) {
3546 3546
             $query_args = array_merge($extra_request, $query_args);
3547 3547
         }
3548 3548
         $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3549
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3549
+        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3550 3550
     }
3551 3551
 
3552 3552
 
@@ -3572,7 +3572,7 @@  discard block
 block discarded – undo
3572 3572
                 'FHEE__EE_Admin_Page___per_page_screen_options__default',
3573 3573
                 20
3574 3574
             ),
3575
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3575
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3576 3576
         ];
3577 3577
         // ONLY add the screen option if the user has access to it.
3578 3578
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3593,18 +3593,18 @@  discard block
 block discarded – undo
3593 3593
     {
3594 3594
         if ($this->request->requestParamIsSet('wp_screen_options')) {
3595 3595
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3596
-            if (! $user = wp_get_current_user()) {
3596
+            if ( ! $user = wp_get_current_user()) {
3597 3597
                 return;
3598 3598
             }
3599 3599
             $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3600
-            if (! $option) {
3600
+            if ( ! $option) {
3601 3601
                 return;
3602 3602
             }
3603
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3603
+            $value = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3604 3604
             $map_option = $option;
3605 3605
             $option     = str_replace('-', '_', $option);
3606 3606
             switch ($map_option) {
3607
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3607
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3608 3608
                     $max_value = apply_filters(
3609 3609
                         'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3610 3610
                         999,
@@ -3661,13 +3661,13 @@  discard block
 block discarded – undo
3661 3661
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3662 3662
     {
3663 3663
         $user_id = get_current_user_id();
3664
-        if (! $skip_route_verify) {
3664
+        if ( ! $skip_route_verify) {
3665 3665
             $this->_verify_route($route);
3666 3666
         }
3667 3667
         // now let's set the string for what kind of transient we're setting
3668 3668
         $transient = $notices
3669
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3670
-            : 'rte_tx_' . $route . '_' . $user_id;
3669
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3670
+            : 'rte_tx_'.$route.'_'.$user_id;
3671 3671
         $data      = $notices ? ['notices' => $data] : $data;
3672 3672
         // is there already a transient for this route?  If there is then let's ADD to that transient
3673 3673
         $existing = is_multisite() && is_network_admin()
@@ -3696,8 +3696,8 @@  discard block
 block discarded – undo
3696 3696
         $user_id   = get_current_user_id();
3697 3697
         $route     = ! $route ? $this->_req_action : $route;
3698 3698
         $transient = $notices
3699
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3700
-            : 'rte_tx_' . $route . '_' . $user_id;
3699
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3700
+            : 'rte_tx_'.$route.'_'.$user_id;
3701 3701
         $data      = is_multisite() && is_network_admin()
3702 3702
             ? get_site_transient($transient)
3703 3703
             : get_transient($transient);
@@ -3928,7 +3928,7 @@  discard block
 block discarded – undo
3928 3928
      */
3929 3929
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3930 3930
     {
3931
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3931
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3932 3932
     }
3933 3933
 
3934 3934
 
@@ -3941,7 +3941,7 @@  discard block
 block discarded – undo
3941 3941
      */
3942 3942
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3943 3943
     {
3944
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3944
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3945 3945
     }
3946 3946
 
3947 3947
 
@@ -4089,7 +4089,7 @@  discard block
 block discarded – undo
4089 4089
         callable $callback = null
4090 4090
     ) {
4091 4091
         $entity_ID = absint($entity_ID);
4092
-        if (! $entity_ID) {
4092
+        if ( ! $entity_ID) {
4093 4093
             $this->trashRestoreDeleteError($action, $entity_model);
4094 4094
         }
4095 4095
         $result = 0;
@@ -4135,7 +4135,7 @@  discard block
 block discarded – undo
4135 4135
                 )
4136 4136
             );
4137 4137
         }
4138
-        if (! $entity_model->has_field($delete_column)) {
4138
+        if ( ! $entity_model->has_field($delete_column)) {
4139 4139
             throw new DomainException(
4140 4140
                 sprintf(
4141 4141
                     esc_html__(
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/RegistrationsReport.php 2 patches
Indentation   +477 added lines, -477 removed lines patch added patch discarded remove patch
@@ -41,502 +41,502 @@
 block discarded – undo
41 41
  */
42 42
 class RegistrationsReport extends JobHandlerFile
43 43
 {
44
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
45
-    // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
46
-    /**
47
-     * Performs any necessary setup for starting the job. This is also a good
48
-     * place to setup the $job_arguments which will be used for subsequent HTTP requests
49
-     * when continue_job will be called
50
-     *
51
-     * @param JobParameters $job_parameters
52
-     * @return JobStepResponse
53
-     * @throws BatchRequestException
54
-     * @throws EE_Error
55
-     * @throws ReflectionException
56
-     */
57
-    public function create_job(JobParameters $job_parameters)
58
-    {
59
-        $event_id = (int) $job_parameters->request_datum('EVT_ID', '0');
60
-        $DTT_ID   = (int) $job_parameters->request_datum('DTT_ID', '0');
61
-        if (! EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
62
-            throw new BatchRequestException(
63
-                esc_html__('You do not have permission to view registrations', 'event_espresso')
64
-            );
65
-        }
66
-        $filepath = $this->create_file_from_job_with_name(
67
-            $job_parameters->job_id(),
68
-            $this->get_filename()
69
-        );
70
-        $job_parameters->add_extra_data('filepath', $filepath);
44
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
45
+	// phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
46
+	/**
47
+	 * Performs any necessary setup for starting the job. This is also a good
48
+	 * place to setup the $job_arguments which will be used for subsequent HTTP requests
49
+	 * when continue_job will be called
50
+	 *
51
+	 * @param JobParameters $job_parameters
52
+	 * @return JobStepResponse
53
+	 * @throws BatchRequestException
54
+	 * @throws EE_Error
55
+	 * @throws ReflectionException
56
+	 */
57
+	public function create_job(JobParameters $job_parameters)
58
+	{
59
+		$event_id = (int) $job_parameters->request_datum('EVT_ID', '0');
60
+		$DTT_ID   = (int) $job_parameters->request_datum('DTT_ID', '0');
61
+		if (! EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
62
+			throw new BatchRequestException(
63
+				esc_html__('You do not have permission to view registrations', 'event_espresso')
64
+			);
65
+		}
66
+		$filepath = $this->create_file_from_job_with_name(
67
+			$job_parameters->job_id(),
68
+			$this->get_filename()
69
+		);
70
+		$job_parameters->add_extra_data('filepath', $filepath);
71 71
 
72 72
 
73
-        $filter_params = maybe_unserialize($job_parameters->request_datum('filters', []));
73
+		$filter_params = maybe_unserialize($job_parameters->request_datum('filters', []));
74 74
 
75
-        $query_params = is_array($filter_params) && ! empty($filter_params)
76
-            ? $filter_params
77
-            : [
78
-                [
79
-                    'OR'                 => [
80
-                        // don't include registrations from failed or abandoned transactions...
81
-                        'Transaction.STS_ID' => [
82
-                            'NOT IN',
83
-                            [
84
-                                EEM_Transaction::failed_status_code,
85
-                                EEM_Transaction::abandoned_status_code,
86
-                            ],
87
-                        ],
88
-                        // unless the registration is approved, in which case include it regardless of transaction status
89
-                        'STS_ID'             => EEM_Registration::status_id_approved,
90
-                    ],
91
-                    'Ticket.TKT_deleted' => ['IN', [true, false]],
92
-                ],
93
-                'order_by'   => ['Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'],
94
-                'force_join' => ['Transaction', 'Ticket', 'Attendee'],
95
-                'caps'       => EEM_Base::caps_read_admin,
96
-            ];
75
+		$query_params = is_array($filter_params) && ! empty($filter_params)
76
+			? $filter_params
77
+			: [
78
+				[
79
+					'OR'                 => [
80
+						// don't include registrations from failed or abandoned transactions...
81
+						'Transaction.STS_ID' => [
82
+							'NOT IN',
83
+							[
84
+								EEM_Transaction::failed_status_code,
85
+								EEM_Transaction::abandoned_status_code,
86
+							],
87
+						],
88
+						// unless the registration is approved, in which case include it regardless of transaction status
89
+						'STS_ID'             => EEM_Registration::status_id_approved,
90
+					],
91
+					'Ticket.TKT_deleted' => ['IN', [true, false]],
92
+				],
93
+				'order_by'   => ['Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'],
94
+				'force_join' => ['Transaction', 'Ticket', 'Attendee'],
95
+				'caps'       => EEM_Base::caps_read_admin,
96
+			];
97 97
 
98
-        if ($event_id) {
99
-            $query_params[0]['EVT_ID'] = $event_id;
100
-        } else {
101
-            $query_params['force_join'][] = 'Event';
102
-        }
103
-        if (! isset($query_params['force_join'])) {
104
-            $query_params['force_join'] = ['Event', 'Transaction', 'Ticket', 'Attendee'];
105
-        }
98
+		if ($event_id) {
99
+			$query_params[0]['EVT_ID'] = $event_id;
100
+		} else {
101
+			$query_params['force_join'][] = 'Event';
102
+		}
103
+		if (! isset($query_params['force_join'])) {
104
+			$query_params['force_join'] = ['Event', 'Transaction', 'Ticket', 'Attendee'];
105
+		}
106 106
 
107
-        $query_params = apply_filters(
108
-            'FHEE__EE_Export__report_registration_for_event',
109
-            $query_params,
110
-            $event_id
111
-        );
107
+		$query_params = apply_filters(
108
+			'FHEE__EE_Export__report_registration_for_event',
109
+			$query_params,
110
+			$event_id
111
+		);
112 112
 
113
-        $job_parameters->add_extra_data('query_params', $query_params);
114
-        $question_labels = $this->_get_question_labels($query_params);
115
-        $job_parameters->add_extra_data('question_labels', $question_labels);
116
-        $job_parameters->set_job_size($this->count_units_to_process($query_params));
117
-        // we should also set the header columns
118
-        $csv_data_for_row = $this->get_csv_data_for(
119
-            $event_id,
120
-            0,
121
-            1,
122
-            $job_parameters->extra_datum('question_labels'),
123
-            $job_parameters->extra_datum('query_params'),
124
-            $DTT_ID
125
-        );
126
-        EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
127
-        // if we actually processed a row there, record it
128
-        if ($job_parameters->job_size()) {
129
-            $job_parameters->mark_processed(1);
130
-        }
131
-        return new JobStepResponse(
132
-            $job_parameters,
133
-            esc_html__('Registrations report started successfully...', 'event_espresso')
134
-        );
135
-    }
113
+		$job_parameters->add_extra_data('query_params', $query_params);
114
+		$question_labels = $this->_get_question_labels($query_params);
115
+		$job_parameters->add_extra_data('question_labels', $question_labels);
116
+		$job_parameters->set_job_size($this->count_units_to_process($query_params));
117
+		// we should also set the header columns
118
+		$csv_data_for_row = $this->get_csv_data_for(
119
+			$event_id,
120
+			0,
121
+			1,
122
+			$job_parameters->extra_datum('question_labels'),
123
+			$job_parameters->extra_datum('query_params'),
124
+			$DTT_ID
125
+		);
126
+		EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
127
+		// if we actually processed a row there, record it
128
+		if ($job_parameters->job_size()) {
129
+			$job_parameters->mark_processed(1);
130
+		}
131
+		return new JobStepResponse(
132
+			$job_parameters,
133
+			esc_html__('Registrations report started successfully...', 'event_espresso')
134
+		);
135
+	}
136 136
 
137 137
 
138
-    /**
139
-     * Gets the filename
140
-     *
141
-     * @return string
142
-     */
143
-    protected function get_filename()
144
-    {
145
-        return apply_filters(
146
-            'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename',
147
-            sprintf(
148
-                "event-espresso-registrations-%s.csv",
149
-                str_replace(array(':', ' '), '-', current_time('mysql'))
150
-            )
151
-        );
152
-    }
138
+	/**
139
+	 * Gets the filename
140
+	 *
141
+	 * @return string
142
+	 */
143
+	protected function get_filename()
144
+	{
145
+		return apply_filters(
146
+			'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename',
147
+			sprintf(
148
+				"event-espresso-registrations-%s.csv",
149
+				str_replace(array(':', ' '), '-', current_time('mysql'))
150
+			)
151
+		);
152
+	}
153 153
 
154 154
 
155
-    /**
156
-     * Gets the questions which are to be used for this report, so they
157
-     * can be remembered for later
158
-     *
159
-     * @param array $registration_query_params
160
-     * @return array question admin labels to be used for this report
161
-     * @throws EE_Error
162
-     */
163
-    protected function _get_question_labels($registration_query_params)
164
-    {
165
-        $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
166
-        $question_query_params = array();
167
-        if ($where !== null) {
168
-            $question_query_params = array(
169
-                $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
170
-            );
171
-        }
172
-        // Make sure it's not a system question
173
-        $question_query_params[0]['OR*not-system-questions'] = [
174
-            'QST_system' => '',
175
-            'QST_system*null' => ['IS_NULL']
176
-        ];
177
-        if (
178
-            apply_filters(
179
-                'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions',
180
-                false,
181
-                $registration_query_params
182
-            )
183
-        ) {
184
-            $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
185
-        }
186
-        $question_query_params['group_by'] = array('QST_ID');
187
-        return array_unique(EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label'));
188
-    }
155
+	/**
156
+	 * Gets the questions which are to be used for this report, so they
157
+	 * can be remembered for later
158
+	 *
159
+	 * @param array $registration_query_params
160
+	 * @return array question admin labels to be used for this report
161
+	 * @throws EE_Error
162
+	 */
163
+	protected function _get_question_labels($registration_query_params)
164
+	{
165
+		$where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
166
+		$question_query_params = array();
167
+		if ($where !== null) {
168
+			$question_query_params = array(
169
+				$this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
170
+			);
171
+		}
172
+		// Make sure it's not a system question
173
+		$question_query_params[0]['OR*not-system-questions'] = [
174
+			'QST_system' => '',
175
+			'QST_system*null' => ['IS_NULL']
176
+		];
177
+		if (
178
+			apply_filters(
179
+				'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions',
180
+				false,
181
+				$registration_query_params
182
+			)
183
+		) {
184
+			$question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
185
+		}
186
+		$question_query_params['group_by'] = array('QST_ID');
187
+		return array_unique(EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label'));
188
+	}
189 189
 
190 190
 
191
-    /**
192
-     * Takes where params meant for registrations and changes them to work for questions
193
-     *
194
-     * @param array $reg_where_params
195
-     * @return array
196
-     * @throws EE_Error
197
-     */
198
-    protected function _change_registration_where_params_to_question_where_params($reg_where_params)
199
-    {
200
-        $question_where_params = array();
201
-        foreach ($reg_where_params as $key => $val) {
202
-            if (EEM_Registration::instance()->is_logic_query_param_key($key)) {
203
-                $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val);
204
-            } else {
205
-                // it's a normal where condition
206
-                $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val;
207
-            }
208
-        }
209
-        return $question_where_params;
210
-    }
191
+	/**
192
+	 * Takes where params meant for registrations and changes them to work for questions
193
+	 *
194
+	 * @param array $reg_where_params
195
+	 * @return array
196
+	 * @throws EE_Error
197
+	 */
198
+	protected function _change_registration_where_params_to_question_where_params($reg_where_params)
199
+	{
200
+		$question_where_params = array();
201
+		foreach ($reg_where_params as $key => $val) {
202
+			if (EEM_Registration::instance()->is_logic_query_param_key($key)) {
203
+				$question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val);
204
+			} else {
205
+				// it's a normal where condition
206
+				$question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val;
207
+			}
208
+		}
209
+		return $question_where_params;
210
+	}
211 211
 
212 212
 
213
-    /**
214
-     * Performs another step of the job
215
-     *
216
-     * @param JobParameters $job_parameters
217
-     * @param int $batch_size
218
-     * @return JobStepResponse
219
-     * @throws EE_Error
220
-     * @throws ReflectionException
221
-     */
222
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
223
-    {
224
-        if ($job_parameters->units_processed() < $job_parameters->job_size()) {
225
-            $csv_data = $this->get_csv_data_for(
226
-                (int) $job_parameters->request_datum('EVT_ID', '0'),
227
-                $job_parameters->units_processed(),
228
-                $batch_size,
229
-                $job_parameters->extra_datum('question_labels'),
230
-                $job_parameters->extra_datum('query_params'),
231
-                (int) $job_parameters->request_datum('DTT_ID', '0')
232
-            );
233
-            EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
234
-            $units_processed = count($csv_data);
235
-        } else {
236
-            $csv_data = array();
237
-            $units_processed = 0;
238
-        }
239
-        $job_parameters->mark_processed($units_processed);
240
-        $extra_response_data = array(
241
-            'file_url' => '',
242
-        );
243
-        if ($units_processed < $batch_size) {
244
-            $job_parameters->set_status(JobParameters::status_complete);
245
-            $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
246
-        }
213
+	/**
214
+	 * Performs another step of the job
215
+	 *
216
+	 * @param JobParameters $job_parameters
217
+	 * @param int $batch_size
218
+	 * @return JobStepResponse
219
+	 * @throws EE_Error
220
+	 * @throws ReflectionException
221
+	 */
222
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
223
+	{
224
+		if ($job_parameters->units_processed() < $job_parameters->job_size()) {
225
+			$csv_data = $this->get_csv_data_for(
226
+				(int) $job_parameters->request_datum('EVT_ID', '0'),
227
+				$job_parameters->units_processed(),
228
+				$batch_size,
229
+				$job_parameters->extra_datum('question_labels'),
230
+				$job_parameters->extra_datum('query_params'),
231
+				(int) $job_parameters->request_datum('DTT_ID', '0')
232
+			);
233
+			EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
234
+			$units_processed = count($csv_data);
235
+		} else {
236
+			$csv_data = array();
237
+			$units_processed = 0;
238
+		}
239
+		$job_parameters->mark_processed($units_processed);
240
+		$extra_response_data = array(
241
+			'file_url' => '',
242
+		);
243
+		if ($units_processed < $batch_size) {
244
+			$job_parameters->set_status(JobParameters::status_complete);
245
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
246
+		}
247 247
 
248
-        return new JobStepResponse(
249
-            $job_parameters,
250
-            sprintf(esc_html__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)),
251
-            $extra_response_data
252
-        );
253
-    }
248
+		return new JobStepResponse(
249
+			$job_parameters,
250
+			sprintf(esc_html__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)),
251
+			$extra_response_data
252
+		);
253
+	}
254 254
 
255 255
 
256
-    /**
257
-     * Gets the csv data for a batch of registrations
258
-     *
259
-     * @param int|null $event_id
260
-     * @param int $offset
261
-     * @param int $limit
262
-     * @param array $question_labels the IDs for all the questions which were answered by someone in this selection
263
-     * @param array $query_params for using where querying the model
264
-     * @param int $DTT_ID
265
-     * @return array top-level keys are numeric, next-level keys are column headers
266
-     * @throws EE_Error
267
-     * @throws ReflectionException
268
-     */
269
-    public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params, $DTT_ID = 0)
270
-    {
271
-        $reg_fields_to_include = [
272
-            'TXN_ID',
273
-            'ATT_ID',
274
-            'REG_date',
275
-            'REG_code',
276
-            'REG_count',
277
-            'REG_final_price',
278
-        ];
279
-        $att_fields_to_include = [
280
-            'ATT_fname',
281
-            'ATT_lname',
282
-            'ATT_email',
283
-            'ATT_address',
284
-            'ATT_address2',
285
-            'ATT_city',
286
-            'STA_ID',
287
-            'CNT_ISO',
288
-            'ATT_zip',
289
-            'ATT_phone',
290
-        ];
291
-        $registrations_csv_ready_array = [];
292
-        $reg_model = EE_Registry::instance()->load_model('Registration');
293
-        $query_params['limit'] = [$offset, $limit];
294
-        $registration_rows = $reg_model->get_all_wpdb_results($query_params);
295
-        foreach ($registration_rows as $reg_row) {
296
-            if (!is_array($reg_row)) {
297
-                continue;
298
-            }
299
-            $reg_csv_array = [];
300
-            // registration Id
301
-            $reg_id_field = $reg_model->field_settings_for('REG_ID');
302
-            $reg_csv_array[ EEH_Export::get_column_name_for_field($reg_id_field) ] = EEH_Export::prepare_value_from_db_for_display(
303
-                $reg_model,
304
-                'REG_ID',
305
-                $reg_row[ $reg_id_field->get_qualified_column() ]
306
-            );
307
-            if (! $event_id) {
308
-                // get the event's name and Id
309
-                $reg_csv_array[ (string) esc_html__('Event', 'event_espresso') ] = sprintf(
310
-                    /* translators: 1: event name, 2: event ID */
311
-                    esc_html__('%1$s (%2$s)', 'event_espresso'),
312
-                    EEH_Export::prepare_value_from_db_for_display(
313
-                        EEM_Event::instance(),
314
-                        'EVT_name',
315
-                        $reg_row['Event_CPT.post_title']
316
-                    ),
317
-                    $reg_row['Event_CPT.ID']
318
-                );
319
-            }
320
-            // add attendee columns
321
-            $reg_csv_array = AttendeeCSV::addAttendeeColumns($att_fields_to_include, $reg_row, $reg_csv_array);
322
-            // add registration columns
323
-            $reg_csv_array = RegistrationCSV::addRegistrationColumns($reg_fields_to_include, $reg_row, $reg_model, $reg_csv_array);
324
-            // get pretty status
325
-            $stati = EEM_Status::instance()->localized_status(
326
-                [
327
-                    $reg_row['Registration.STS_ID']     => esc_html__('unknown', 'event_espresso'),
328
-                    $reg_row['TransactionTable.STS_ID'] => esc_html__('unknown', 'event_espresso'),
329
-                ],
330
-                false,
331
-                'sentence'
332
-            );
333
-            $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
334
-            $reg_csv_array[ (string) esc_html__("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ];
335
-            // get pretty transaction status
336
-            $reg_csv_array[ (string) esc_html__("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ];
337
-            $reg_csv_array[ (string) esc_html__('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg
338
-                ? EEH_Export::prepare_value_from_db_for_display(
339
-                    EEM_Transaction::instance(),
340
-                    'TXN_total',
341
-                    $reg_row['TransactionTable.TXN_total'],
342
-                    'localized_float'
343
-                ) : '0.00';
344
-            $reg_csv_array[ (string) esc_html__('Amount Paid', 'event_espresso') ] = $is_primary_reg
345
-                ? EEH_Export::prepare_value_from_db_for_display(
346
-                    EEM_Transaction::instance(),
347
-                    'TXN_paid',
348
-                    $reg_row['TransactionTable.TXN_paid'],
349
-                    'localized_float'
350
-                ) : '0.00';
351
-            $payment_methods = [];
352
-            $gateway_txn_ids_etc = [];
353
-            $payment_times = [];
354
-            if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
355
-                $payments_info = EEM_Payment::instance()->get_all_wpdb_results(
356
-                    [
357
-                        [
358
-                            'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
359
-                            'STS_ID' => EEM_Payment::status_id_approved,
360
-                        ],
361
-                        'force_join' => ['Payment_Method'],
362
-                    ],
363
-                    ARRAY_A,
364
-                    'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time'
365
-                );
366
-                [$payment_methods, $gateway_txn_ids_etc, $payment_times] = PaymentsInfoCSV::extractPaymentInfo($payments_info);
367
-            }
368
-            $reg_csv_array[ (string) esc_html__('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times);
369
-            $reg_csv_array[ (string) esc_html__('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods);
370
-            $reg_csv_array[ (string) esc_html__('Gateway Transaction ID(s)', 'event_espresso') ] = implode(
371
-                ',',
372
-                $gateway_txn_ids_etc
373
-            );
374
-            // get ticket of registration and its price
375
-            $ticket_model = EE_Registry::instance()->load_model('Ticket');
376
-            if ($reg_row['Ticket.TKT_ID']) {
377
-                $ticket_name = EEH_Export::prepare_value_from_db_for_display(
378
-                    $ticket_model,
379
-                    'TKT_name',
380
-                    $reg_row['Ticket.TKT_name']
381
-                );
382
-                $datetimes_strings = [];
383
-                foreach (
384
-                    EEM_Datetime::instance()->get_all_wpdb_results(
385
-                        [
386
-                            ['Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']],
387
-                            'order_by' => ['DTT_EVT_start' => 'ASC'],
388
-                            'default_where_conditions' => 'none',
389
-                        ]
390
-                    ) as $datetime
391
-                ) {
392
-                    $datetimes_strings[] = EEH_Export::prepare_value_from_db_for_display(
393
-                        EEM_Datetime::instance(),
394
-                        'DTT_EVT_start',
395
-                        $datetime['Datetime.DTT_EVT_start']
396
-                    );
397
-                }
398
-            } else {
399
-                $ticket_name = esc_html__('Unknown', 'event_espresso');
400
-                $datetimes_strings = [esc_html__('Unknown', 'event_espresso')];
401
-            }
402
-            $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name;
403
-            $reg_csv_array[ (string) esc_html__("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings);
404
-            // add answer columns
405
-            $reg_csv_array = AnswersCSV::addAnswerColumns($reg_row, $reg_csv_array, $question_labels);
406
-            // Include check-in data
407
-            if ($event_id && $DTT_ID) {
408
-                // get whether or not the user has checked in
409
-                $reg_csv_array[ (string) esc_html__('Datetime Check-ins #', 'event_espresso') ] = $reg_model->count_related(
410
-                    $reg_row['Registration.REG_ID'],
411
-                    'Checkin',
412
-                    [
413
-                        [
414
-                            'DTT_ID' => $DTT_ID
415
-                        ]
416
-                    ]
417
-                );
418
-                /** @var EE_Datetime $datetime */
419
-                $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
420
-                $checkin_rows = EEM_Checkin::instance()->get_all(
421
-                    [
422
-                        [
423
-                            'REG_ID' => $reg_row['Registration.REG_ID'],
424
-                            'DTT_ID' => $datetime->get('DTT_ID'),
425
-                        ],
426
-                    ]
427
-                );
428
-                $checkins = [];
429
-                foreach ($checkin_rows as $checkin_row) {
430
-                    /** @var EE_Checkin $checkin_row */
431
-                    $checkin_value = CheckinsCSV::getCheckinValue($checkin_row);
432
-                    if ($checkin_value) {
433
-                        $checkins[] = $checkin_value;
434
-                    }
435
-                }
436
-                $datetime_name = CheckinsCSV::getDatetineLabel($datetime);
437
-                $reg_csv_array[ (string) $datetime_name ] = implode(' --- ', $checkins);
438
-            } elseif ($event_id) {
439
-                // get whether or not the user has checked in
440
-                $reg_csv_array[ (string) esc_html__('Event Check-ins #', 'event_espresso') ] = $reg_model->count_related(
441
-                    $reg_row['Registration.REG_ID'],
442
-                    'Checkin'
443
-                );
444
-                $datetimes = EEM_Datetime::instance()->get_all(
445
-                    [
446
-                        [
447
-                            'Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID'],
448
-                        ],
449
-                        'order_by' => ['DTT_EVT_start' => 'ASC'],
450
-                        'default_where_conditions' => 'none',
451
-                    ]
452
-                );
453
-                foreach ($datetimes as $datetime) {
454
-                    /** @var EE_Checkin $checkin_row */
455
-                    $checkin_row = EEM_Checkin::instance()->get_one(
456
-                        [
457
-                            [
458
-                                'REG_ID' => $reg_row['Registration.REG_ID'],
459
-                                'DTT_ID' => $datetime->get('DTT_ID'),
460
-                            ],
461
-                            'limit' => 1,
462
-                            'order_by' => [
463
-                                'CHK_ID' => 'DESC'
464
-                            ]
465
-                        ]
466
-                    );
467
-                    $checkin_value = CheckinsCSV::getCheckinValue($checkin_row);
468
-                    $datetime_name = CheckinsCSV::getDatetineLabel($datetime);
469
-                    $reg_csv_array[ (string) $datetime_name ] = $checkin_value;
470
-                }
471
-            }
472
-            /**
473
-             * Filter to change the contents of each row of the registrations report CSV file.
474
-             * This can be used to add or remote columns from the CSV file, or change their values.
475
-             * Note when using: all rows in the CSV should have the same columns.
476
-             * @param array $reg_csv_array keys are the column names, values are their cell values
477
-             * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results()
478
-             */
479
-            $registrations_csv_ready_array[] = apply_filters(
480
-                'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
481
-                $reg_csv_array,
482
-                $reg_row
483
-            );
484
-        }
485
-        // if we couldn't export anything, we want to at least show the column headers
486
-        if (empty($registrations_csv_ready_array)) {
487
-            $reg_csv_array = [];
488
-            $model_and_fields_to_include = [
489
-                'Registration' => $reg_fields_to_include,
490
-                'Attendee'     => $att_fields_to_include,
491
-            ];
492
-            foreach ($model_and_fields_to_include as $model_name => $field_list) {
493
-                $model = EE_Registry::instance()->load_model($model_name);
494
-                foreach ($field_list as $field_name) {
495
-                    $field = $model->field_settings_for($field_name);
496
-                    $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null;
497
-                }
498
-            }
499
-            $registrations_csv_ready_array[] = $reg_csv_array;
500
-        }
501
-        return $registrations_csv_ready_array;
502
-    }
256
+	/**
257
+	 * Gets the csv data for a batch of registrations
258
+	 *
259
+	 * @param int|null $event_id
260
+	 * @param int $offset
261
+	 * @param int $limit
262
+	 * @param array $question_labels the IDs for all the questions which were answered by someone in this selection
263
+	 * @param array $query_params for using where querying the model
264
+	 * @param int $DTT_ID
265
+	 * @return array top-level keys are numeric, next-level keys are column headers
266
+	 * @throws EE_Error
267
+	 * @throws ReflectionException
268
+	 */
269
+	public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params, $DTT_ID = 0)
270
+	{
271
+		$reg_fields_to_include = [
272
+			'TXN_ID',
273
+			'ATT_ID',
274
+			'REG_date',
275
+			'REG_code',
276
+			'REG_count',
277
+			'REG_final_price',
278
+		];
279
+		$att_fields_to_include = [
280
+			'ATT_fname',
281
+			'ATT_lname',
282
+			'ATT_email',
283
+			'ATT_address',
284
+			'ATT_address2',
285
+			'ATT_city',
286
+			'STA_ID',
287
+			'CNT_ISO',
288
+			'ATT_zip',
289
+			'ATT_phone',
290
+		];
291
+		$registrations_csv_ready_array = [];
292
+		$reg_model = EE_Registry::instance()->load_model('Registration');
293
+		$query_params['limit'] = [$offset, $limit];
294
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
295
+		foreach ($registration_rows as $reg_row) {
296
+			if (!is_array($reg_row)) {
297
+				continue;
298
+			}
299
+			$reg_csv_array = [];
300
+			// registration Id
301
+			$reg_id_field = $reg_model->field_settings_for('REG_ID');
302
+			$reg_csv_array[ EEH_Export::get_column_name_for_field($reg_id_field) ] = EEH_Export::prepare_value_from_db_for_display(
303
+				$reg_model,
304
+				'REG_ID',
305
+				$reg_row[ $reg_id_field->get_qualified_column() ]
306
+			);
307
+			if (! $event_id) {
308
+				// get the event's name and Id
309
+				$reg_csv_array[ (string) esc_html__('Event', 'event_espresso') ] = sprintf(
310
+					/* translators: 1: event name, 2: event ID */
311
+					esc_html__('%1$s (%2$s)', 'event_espresso'),
312
+					EEH_Export::prepare_value_from_db_for_display(
313
+						EEM_Event::instance(),
314
+						'EVT_name',
315
+						$reg_row['Event_CPT.post_title']
316
+					),
317
+					$reg_row['Event_CPT.ID']
318
+				);
319
+			}
320
+			// add attendee columns
321
+			$reg_csv_array = AttendeeCSV::addAttendeeColumns($att_fields_to_include, $reg_row, $reg_csv_array);
322
+			// add registration columns
323
+			$reg_csv_array = RegistrationCSV::addRegistrationColumns($reg_fields_to_include, $reg_row, $reg_model, $reg_csv_array);
324
+			// get pretty status
325
+			$stati = EEM_Status::instance()->localized_status(
326
+				[
327
+					$reg_row['Registration.STS_ID']     => esc_html__('unknown', 'event_espresso'),
328
+					$reg_row['TransactionTable.STS_ID'] => esc_html__('unknown', 'event_espresso'),
329
+				],
330
+				false,
331
+				'sentence'
332
+			);
333
+			$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
334
+			$reg_csv_array[ (string) esc_html__("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ];
335
+			// get pretty transaction status
336
+			$reg_csv_array[ (string) esc_html__("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ];
337
+			$reg_csv_array[ (string) esc_html__('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg
338
+				? EEH_Export::prepare_value_from_db_for_display(
339
+					EEM_Transaction::instance(),
340
+					'TXN_total',
341
+					$reg_row['TransactionTable.TXN_total'],
342
+					'localized_float'
343
+				) : '0.00';
344
+			$reg_csv_array[ (string) esc_html__('Amount Paid', 'event_espresso') ] = $is_primary_reg
345
+				? EEH_Export::prepare_value_from_db_for_display(
346
+					EEM_Transaction::instance(),
347
+					'TXN_paid',
348
+					$reg_row['TransactionTable.TXN_paid'],
349
+					'localized_float'
350
+				) : '0.00';
351
+			$payment_methods = [];
352
+			$gateway_txn_ids_etc = [];
353
+			$payment_times = [];
354
+			if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
355
+				$payments_info = EEM_Payment::instance()->get_all_wpdb_results(
356
+					[
357
+						[
358
+							'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
359
+							'STS_ID' => EEM_Payment::status_id_approved,
360
+						],
361
+						'force_join' => ['Payment_Method'],
362
+					],
363
+					ARRAY_A,
364
+					'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time'
365
+				);
366
+				[$payment_methods, $gateway_txn_ids_etc, $payment_times] = PaymentsInfoCSV::extractPaymentInfo($payments_info);
367
+			}
368
+			$reg_csv_array[ (string) esc_html__('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times);
369
+			$reg_csv_array[ (string) esc_html__('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods);
370
+			$reg_csv_array[ (string) esc_html__('Gateway Transaction ID(s)', 'event_espresso') ] = implode(
371
+				',',
372
+				$gateway_txn_ids_etc
373
+			);
374
+			// get ticket of registration and its price
375
+			$ticket_model = EE_Registry::instance()->load_model('Ticket');
376
+			if ($reg_row['Ticket.TKT_ID']) {
377
+				$ticket_name = EEH_Export::prepare_value_from_db_for_display(
378
+					$ticket_model,
379
+					'TKT_name',
380
+					$reg_row['Ticket.TKT_name']
381
+				);
382
+				$datetimes_strings = [];
383
+				foreach (
384
+					EEM_Datetime::instance()->get_all_wpdb_results(
385
+						[
386
+							['Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']],
387
+							'order_by' => ['DTT_EVT_start' => 'ASC'],
388
+							'default_where_conditions' => 'none',
389
+						]
390
+					) as $datetime
391
+				) {
392
+					$datetimes_strings[] = EEH_Export::prepare_value_from_db_for_display(
393
+						EEM_Datetime::instance(),
394
+						'DTT_EVT_start',
395
+						$datetime['Datetime.DTT_EVT_start']
396
+					);
397
+				}
398
+			} else {
399
+				$ticket_name = esc_html__('Unknown', 'event_espresso');
400
+				$datetimes_strings = [esc_html__('Unknown', 'event_espresso')];
401
+			}
402
+			$reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name;
403
+			$reg_csv_array[ (string) esc_html__("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings);
404
+			// add answer columns
405
+			$reg_csv_array = AnswersCSV::addAnswerColumns($reg_row, $reg_csv_array, $question_labels);
406
+			// Include check-in data
407
+			if ($event_id && $DTT_ID) {
408
+				// get whether or not the user has checked in
409
+				$reg_csv_array[ (string) esc_html__('Datetime Check-ins #', 'event_espresso') ] = $reg_model->count_related(
410
+					$reg_row['Registration.REG_ID'],
411
+					'Checkin',
412
+					[
413
+						[
414
+							'DTT_ID' => $DTT_ID
415
+						]
416
+					]
417
+				);
418
+				/** @var EE_Datetime $datetime */
419
+				$datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
420
+				$checkin_rows = EEM_Checkin::instance()->get_all(
421
+					[
422
+						[
423
+							'REG_ID' => $reg_row['Registration.REG_ID'],
424
+							'DTT_ID' => $datetime->get('DTT_ID'),
425
+						],
426
+					]
427
+				);
428
+				$checkins = [];
429
+				foreach ($checkin_rows as $checkin_row) {
430
+					/** @var EE_Checkin $checkin_row */
431
+					$checkin_value = CheckinsCSV::getCheckinValue($checkin_row);
432
+					if ($checkin_value) {
433
+						$checkins[] = $checkin_value;
434
+					}
435
+				}
436
+				$datetime_name = CheckinsCSV::getDatetineLabel($datetime);
437
+				$reg_csv_array[ (string) $datetime_name ] = implode(' --- ', $checkins);
438
+			} elseif ($event_id) {
439
+				// get whether or not the user has checked in
440
+				$reg_csv_array[ (string) esc_html__('Event Check-ins #', 'event_espresso') ] = $reg_model->count_related(
441
+					$reg_row['Registration.REG_ID'],
442
+					'Checkin'
443
+				);
444
+				$datetimes = EEM_Datetime::instance()->get_all(
445
+					[
446
+						[
447
+							'Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID'],
448
+						],
449
+						'order_by' => ['DTT_EVT_start' => 'ASC'],
450
+						'default_where_conditions' => 'none',
451
+					]
452
+				);
453
+				foreach ($datetimes as $datetime) {
454
+					/** @var EE_Checkin $checkin_row */
455
+					$checkin_row = EEM_Checkin::instance()->get_one(
456
+						[
457
+							[
458
+								'REG_ID' => $reg_row['Registration.REG_ID'],
459
+								'DTT_ID' => $datetime->get('DTT_ID'),
460
+							],
461
+							'limit' => 1,
462
+							'order_by' => [
463
+								'CHK_ID' => 'DESC'
464
+							]
465
+						]
466
+					);
467
+					$checkin_value = CheckinsCSV::getCheckinValue($checkin_row);
468
+					$datetime_name = CheckinsCSV::getDatetineLabel($datetime);
469
+					$reg_csv_array[ (string) $datetime_name ] = $checkin_value;
470
+				}
471
+			}
472
+			/**
473
+			 * Filter to change the contents of each row of the registrations report CSV file.
474
+			 * This can be used to add or remote columns from the CSV file, or change their values.
475
+			 * Note when using: all rows in the CSV should have the same columns.
476
+			 * @param array $reg_csv_array keys are the column names, values are their cell values
477
+			 * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results()
478
+			 */
479
+			$registrations_csv_ready_array[] = apply_filters(
480
+				'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
481
+				$reg_csv_array,
482
+				$reg_row
483
+			);
484
+		}
485
+		// if we couldn't export anything, we want to at least show the column headers
486
+		if (empty($registrations_csv_ready_array)) {
487
+			$reg_csv_array = [];
488
+			$model_and_fields_to_include = [
489
+				'Registration' => $reg_fields_to_include,
490
+				'Attendee'     => $att_fields_to_include,
491
+			];
492
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
493
+				$model = EE_Registry::instance()->load_model($model_name);
494
+				foreach ($field_list as $field_name) {
495
+					$field = $model->field_settings_for($field_name);
496
+					$reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null;
497
+				}
498
+			}
499
+			$registrations_csv_ready_array[] = $reg_csv_array;
500
+		}
501
+		return $registrations_csv_ready_array;
502
+	}
503 503
 
504 504
 
505
-    /**
506
-     * Counts total unit to process
507
-     *
508
-     * @param array $query_params
509
-     * @return int
510
-     * @throws EE_Error
511
-     */
512
-    public function count_units_to_process($query_params)
513
-    {
514
-        return EEM_Registration::instance()->count(
515
-            array_diff_key(
516
-                $query_params,
517
-                array_flip(
518
-                    ['limit']
519
-                )
520
-            )
521
-        );
522
-    }
505
+	/**
506
+	 * Counts total unit to process
507
+	 *
508
+	 * @param array $query_params
509
+	 * @return int
510
+	 * @throws EE_Error
511
+	 */
512
+	public function count_units_to_process($query_params)
513
+	{
514
+		return EEM_Registration::instance()->count(
515
+			array_diff_key(
516
+				$query_params,
517
+				array_flip(
518
+					['limit']
519
+				)
520
+			)
521
+		);
522
+	}
523 523
 
524 524
 
525
-    /**
526
-     * Performs any clean-up logic when we know the job is completed.
527
-     * In this case, we delete the temporary file
528
-     *
529
-     * @param JobParameters $job_parameters
530
-     * @return JobStepResponse
531
-     * @throws EE_Error
532
-     */
533
-    public function cleanup_job(JobParameters $job_parameters)
534
-    {
535
-        $this->_file_helper->delete(
536
-            EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
537
-            true,
538
-            'd'
539
-        );
540
-        return new JobStepResponse($job_parameters, esc_html__('Cleaned up temporary file', 'event_espresso'));
541
-    }
525
+	/**
526
+	 * Performs any clean-up logic when we know the job is completed.
527
+	 * In this case, we delete the temporary file
528
+	 *
529
+	 * @param JobParameters $job_parameters
530
+	 * @return JobStepResponse
531
+	 * @throws EE_Error
532
+	 */
533
+	public function cleanup_job(JobParameters $job_parameters)
534
+	{
535
+		$this->_file_helper->delete(
536
+			EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
537
+			true,
538
+			'd'
539
+		);
540
+		return new JobStepResponse($job_parameters, esc_html__('Cleaned up temporary file', 'event_espresso'));
541
+	}
542 542
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     {
59 59
         $event_id = (int) $job_parameters->request_datum('EVT_ID', '0');
60 60
         $DTT_ID   = (int) $job_parameters->request_datum('DTT_ID', '0');
61
-        if (! EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
61
+        if ( ! EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
62 62
             throw new BatchRequestException(
63 63
                 esc_html__('You do not have permission to view registrations', 'event_espresso')
64 64
             );
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         } else {
101 101
             $query_params['force_join'][] = 'Event';
102 102
         }
103
-        if (! isset($query_params['force_join'])) {
103
+        if ( ! isset($query_params['force_join'])) {
104 104
             $query_params['force_join'] = ['Event', 'Transaction', 'Ticket', 'Attendee'];
105 105
         }
106 106
 
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
         $question_where_params = array();
201 201
         foreach ($reg_where_params as $key => $val) {
202 202
             if (EEM_Registration::instance()->is_logic_query_param_key($key)) {
203
-                $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val);
203
+                $question_where_params[$key] = $this->_change_registration_where_params_to_question_where_params($val);
204 204
             } else {
205 205
                 // it's a normal where condition
206
-                $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val;
206
+                $question_where_params['Question_Group.Event.Registration.'.$key] = $val;
207 207
             }
208 208
         }
209 209
         return $question_where_params;
@@ -293,20 +293,20 @@  discard block
 block discarded – undo
293 293
         $query_params['limit'] = [$offset, $limit];
294 294
         $registration_rows = $reg_model->get_all_wpdb_results($query_params);
295 295
         foreach ($registration_rows as $reg_row) {
296
-            if (!is_array($reg_row)) {
296
+            if ( ! is_array($reg_row)) {
297 297
                 continue;
298 298
             }
299 299
             $reg_csv_array = [];
300 300
             // registration Id
301 301
             $reg_id_field = $reg_model->field_settings_for('REG_ID');
302
-            $reg_csv_array[ EEH_Export::get_column_name_for_field($reg_id_field) ] = EEH_Export::prepare_value_from_db_for_display(
302
+            $reg_csv_array[EEH_Export::get_column_name_for_field($reg_id_field)] = EEH_Export::prepare_value_from_db_for_display(
303 303
                 $reg_model,
304 304
                 'REG_ID',
305
-                $reg_row[ $reg_id_field->get_qualified_column() ]
305
+                $reg_row[$reg_id_field->get_qualified_column()]
306 306
             );
307
-            if (! $event_id) {
307
+            if ( ! $event_id) {
308 308
                 // get the event's name and Id
309
-                $reg_csv_array[ (string) esc_html__('Event', 'event_espresso') ] = sprintf(
309
+                $reg_csv_array[(string) esc_html__('Event', 'event_espresso')] = sprintf(
310 310
                     /* translators: 1: event name, 2: event ID */
311 311
                     esc_html__('%1$s (%2$s)', 'event_espresso'),
312 312
                     EEH_Export::prepare_value_from_db_for_display(
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
                 'sentence'
332 332
             );
333 333
             $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
334
-            $reg_csv_array[ (string) esc_html__("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ];
334
+            $reg_csv_array[(string) esc_html__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
335 335
             // get pretty transaction status
336
-            $reg_csv_array[ (string) esc_html__("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ];
337
-            $reg_csv_array[ (string) esc_html__('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg
336
+            $reg_csv_array[(string) esc_html__("Transaction Status", 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']];
337
+            $reg_csv_array[(string) esc_html__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg
338 338
                 ? EEH_Export::prepare_value_from_db_for_display(
339 339
                     EEM_Transaction::instance(),
340 340
                     'TXN_total',
341 341
                     $reg_row['TransactionTable.TXN_total'],
342 342
                     'localized_float'
343 343
                 ) : '0.00';
344
-            $reg_csv_array[ (string) esc_html__('Amount Paid', 'event_espresso') ] = $is_primary_reg
344
+            $reg_csv_array[(string) esc_html__('Amount Paid', 'event_espresso')] = $is_primary_reg
345 345
                 ? EEH_Export::prepare_value_from_db_for_display(
346 346
                     EEM_Transaction::instance(),
347 347
                     'TXN_paid',
@@ -365,9 +365,9 @@  discard block
 block discarded – undo
365 365
                 );
366 366
                 [$payment_methods, $gateway_txn_ids_etc, $payment_times] = PaymentsInfoCSV::extractPaymentInfo($payments_info);
367 367
             }
368
-            $reg_csv_array[ (string) esc_html__('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times);
369
-            $reg_csv_array[ (string) esc_html__('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods);
370
-            $reg_csv_array[ (string) esc_html__('Gateway Transaction ID(s)', 'event_espresso') ] = implode(
368
+            $reg_csv_array[(string) esc_html__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
369
+            $reg_csv_array[(string) esc_html__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
370
+            $reg_csv_array[(string) esc_html__('Gateway Transaction ID(s)', 'event_espresso')] = implode(
371 371
                 ',',
372 372
                 $gateway_txn_ids_etc
373 373
             );
@@ -399,14 +399,14 @@  discard block
 block discarded – undo
399 399
                 $ticket_name = esc_html__('Unknown', 'event_espresso');
400 400
                 $datetimes_strings = [esc_html__('Unknown', 'event_espresso')];
401 401
             }
402
-            $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name;
403
-            $reg_csv_array[ (string) esc_html__("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings);
402
+            $reg_csv_array[(string) $ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
403
+            $reg_csv_array[(string) esc_html__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
404 404
             // add answer columns
405 405
             $reg_csv_array = AnswersCSV::addAnswerColumns($reg_row, $reg_csv_array, $question_labels);
406 406
             // Include check-in data
407 407
             if ($event_id && $DTT_ID) {
408 408
                 // get whether or not the user has checked in
409
-                $reg_csv_array[ (string) esc_html__('Datetime Check-ins #', 'event_espresso') ] = $reg_model->count_related(
409
+                $reg_csv_array[(string) esc_html__('Datetime Check-ins #', 'event_espresso')] = $reg_model->count_related(
410 410
                     $reg_row['Registration.REG_ID'],
411 411
                     'Checkin',
412 412
                     [
@@ -434,10 +434,10 @@  discard block
 block discarded – undo
434 434
                     }
435 435
                 }
436 436
                 $datetime_name = CheckinsCSV::getDatetineLabel($datetime);
437
-                $reg_csv_array[ (string) $datetime_name ] = implode(' --- ', $checkins);
437
+                $reg_csv_array[(string) $datetime_name] = implode(' --- ', $checkins);
438 438
             } elseif ($event_id) {
439 439
                 // get whether or not the user has checked in
440
-                $reg_csv_array[ (string) esc_html__('Event Check-ins #', 'event_espresso') ] = $reg_model->count_related(
440
+                $reg_csv_array[(string) esc_html__('Event Check-ins #', 'event_espresso')] = $reg_model->count_related(
441 441
                     $reg_row['Registration.REG_ID'],
442 442
                     'Checkin'
443 443
                 );
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
                     );
467 467
                     $checkin_value = CheckinsCSV::getCheckinValue($checkin_row);
468 468
                     $datetime_name = CheckinsCSV::getDatetineLabel($datetime);
469
-                    $reg_csv_array[ (string) $datetime_name ] = $checkin_value;
469
+                    $reg_csv_array[(string) $datetime_name] = $checkin_value;
470 470
                 }
471 471
             }
472 472
             /**
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
                 $model = EE_Registry::instance()->load_model($model_name);
494 494
                 foreach ($field_list as $field_name) {
495 495
                     $field = $model->field_settings_for($field_name);
496
-                    $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null;
496
+                    $reg_csv_array[EEH_Export::get_column_name_for_field($field)] = null;
497 497
                 }
498 498
             }
499 499
             $registrations_csv_ready_array[] = $reg_csv_array;
Please login to merge, or discard this patch.
admin/registrations/list_table/csv_reports/RegistrationsCsvReportParams.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -14,69 +14,69 @@
 block discarded – undo
14 14
  */
15 15
 class RegistrationsCsvReportParams
16 16
 {
17
-    /**
18
-     * @param string $return_url
19
-     * @param array  $request_params
20
-     * @param int    $EVT_ID
21
-     * @param int    $DTT_ID
22
-     * @return array
23
-     */
24
-    public static function getRequestParams(
25
-        string $return_url,
26
-        array $request_params = [],
27
-        int $EVT_ID = 0,
28
-        int $DTT_ID = 0
29
-    ): array {
30
-        if (
31
-            ! EE_Capabilities::instance()->current_user_can(
32
-                'ee_read_registrations',
33
-                'espresso_registrations_registrations_reports',
34
-                $EVT_ID
35
-            )
36
-        ) {
37
-            return [];
38
-        }
39
-        add_action(
40
-            'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
41
-            [RegistrationsCsvReportParams::class, 'csvReportNotice']
42
-        );
17
+	/**
18
+	 * @param string $return_url
19
+	 * @param array  $request_params
20
+	 * @param int    $EVT_ID
21
+	 * @param int    $DTT_ID
22
+	 * @return array
23
+	 */
24
+	public static function getRequestParams(
25
+		string $return_url,
26
+		array $request_params = [],
27
+		int $EVT_ID = 0,
28
+		int $DTT_ID = 0
29
+	): array {
30
+		if (
31
+			! EE_Capabilities::instance()->current_user_can(
32
+				'ee_read_registrations',
33
+				'espresso_registrations_registrations_reports',
34
+				$EVT_ID
35
+			)
36
+		) {
37
+			return [];
38
+		}
39
+		add_action(
40
+			'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',
41
+			[RegistrationsCsvReportParams::class, 'csvReportNotice']
42
+		);
43 43
 
44
-        $route_details = [
45
-            'route'         => 'registrations_report',
46
-            'extra_request' => [ 'return_url' => $return_url ],
47
-        ];
48
-        if (! empty($EVT_ID)) {
49
-            $route_details['extra_request']['EVT_ID'] = $EVT_ID;
50
-        }
51
-        if ($DTT_ID) {
52
-            $route_details['extra_request']['DTT_ID'] = $DTT_ID;
53
-        }
54
-        if (
55
-            isset($request_params['month_range'])
56
-            || isset($request_params['EVT_CAT'])
57
-            || isset($request_params['_reg_status'])
58
-        ) {
59
-            $route_details['extra_request']['filters'] = array_diff_key(
60
-                $request_params,
61
-                [
62
-                    'page'          => '',
63
-                    'action'        => '',
64
-                    'default_nonce' => '',
65
-                ]
66
-            );
67
-        }
68
-        return $route_details;
69
-    }
44
+		$route_details = [
45
+			'route'         => 'registrations_report',
46
+			'extra_request' => [ 'return_url' => $return_url ],
47
+		];
48
+		if (! empty($EVT_ID)) {
49
+			$route_details['extra_request']['EVT_ID'] = $EVT_ID;
50
+		}
51
+		if ($DTT_ID) {
52
+			$route_details['extra_request']['DTT_ID'] = $DTT_ID;
53
+		}
54
+		if (
55
+			isset($request_params['month_range'])
56
+			|| isset($request_params['EVT_CAT'])
57
+			|| isset($request_params['_reg_status'])
58
+		) {
59
+			$route_details['extra_request']['filters'] = array_diff_key(
60
+				$request_params,
61
+				[
62
+					'page'          => '',
63
+					'action'        => '',
64
+					'default_nonce' => '',
65
+				]
66
+			);
67
+		}
68
+		return $route_details;
69
+	}
70 70
 
71 71
 
72
-    public static function csvReportNotice()
73
-    {
74
-        echo '
72
+	public static function csvReportNotice()
73
+	{
74
+		echo '
75 75
     <span class="csv-report-notice__wrapper">
76 76
         <span class="dashicons dashicons-info"></span>
77 77
         <span class="csv-report-notice__text">
78 78
         ' .  esc_html('All Registration CSV Reports are now triggered by the preceding button') . '
79 79
         </span>
80 80
     </span>';
81
-    }
81
+	}
82 82
 }#ebf4f9
83 83
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 
44 44
         $route_details = [
45 45
             'route'         => 'registrations_report',
46
-            'extra_request' => [ 'return_url' => $return_url ],
46
+            'extra_request' => ['return_url' => $return_url],
47 47
         ];
48
-        if (! empty($EVT_ID)) {
48
+        if ( ! empty($EVT_ID)) {
49 49
             $route_details['extra_request']['EVT_ID'] = $EVT_ID;
50 50
         }
51 51
         if ($DTT_ID) {
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     <span class="csv-report-notice__wrapper">
76 76
         <span class="dashicons dashicons-info"></span>
77 77
         <span class="csv-report-notice__text">
78
-        ' .  esc_html('All Registration CSV Reports are now triggered by the preceding button') . '
78
+        ' .  esc_html('All Registration CSV Reports are now triggered by the preceding button').'
79 79
         </span>
80 80
     </span>';
81 81
     }
Please login to merge, or discard this patch.
admin/extend/registrations/EE_Event_Registrations_List_Table.class.php 2 patches
Indentation   +529 added lines, -529 removed lines patch added patch discarded remove patch
@@ -14,538 +14,538 @@
 block discarded – undo
14 14
 class EE_Event_Registrations_List_Table extends EE_Admin_List_Table
15 15
 {
16 16
 
17
-    /**
18
-     * This property will hold the related Datetimes on an event IF the event id is included in the request.
19
-     *
20
-     * @var EE_Datetime[]
21
-     */
22
-    protected $_dtts_for_event = array();
23
-
24
-
25
-    /**
26
-     * The event if one is specified in the request
27
-     *
28
-     * @var EE_Event
29
-     */
30
-    protected $_evt = null;
31
-
32
-
33
-    /**
34
-     * The DTT_ID if the current view has a specified datetime.
35
-     *
36
-     * @var int $_cur_dtt_id
37
-     */
38
-    protected $_cur_dtt_id = 0;
39
-
40
-
41
-    /**
42
-     * EE_Event_Registrations_List_Table constructor.
43
-     *
44
-     * @param Registrations_Admin_Page $admin_page
45
-     */
46
-    public function __construct($admin_page)
47
-    {
48
-        parent::__construct($admin_page);
49
-        $this->_status = $this->_admin_page->get_registration_status_array();
50
-    }
51
-
52
-
53
-    protected function _setup_data()
54
-    {
55
-        $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page)
56
-            : $this->_admin_page->get_event_attendees($this->_per_page, false, true);
57
-        $this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees(
58
-            $this->_per_page,
59
-            true
60
-        ) : $this->_admin_page->get_event_attendees($this->_per_page, true, true);
61
-    }
62
-
63
-
64
-    protected function _set_properties()
65
-    {
66
-        $return_url = $this->getReturnUrl();
67
-
68
-        $EVT_ID = $this->_req_data['event_id'] ?? 0;
69
-        $DTT_ID = $this->_req_data['DTT_ID'] ?? 0;
70
-
71
-        $this->_wp_list_args = array(
72
-            'singular' => esc_html__('registrant', 'event_espresso'),
73
-            'plural'   => esc_html__('registrants', 'event_espresso'),
74
-            'ajax'     => true,
75
-            'screen'   => $this->_admin_page->get_current_screen()->id,
76
-        );
77
-        $columns = array();
78
-        // $columns['_Reg_Status'] = '';
79
-        $this->_columns = array(
80
-            '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
81
-            'ATT_name'            => esc_html__('Registrant', 'event_espresso'),
82
-            'ATT_email'           => esc_html__('Email Address', 'event_espresso'),
83
-            'Event'               => esc_html__('Event', 'event_espresso'),
84
-            'PRC_name'            => esc_html__('TKT Option', 'event_espresso'),
85
-            '_REG_final_price'    => esc_html__('Price', 'event_espresso'),
86
-            'TXN_paid'            => esc_html__('Paid', 'event_espresso'),
87
-            'TXN_total'           => esc_html__('Total', 'event_espresso'),
88
-        );
89
-        // Add/remove columns when an event has been selected
90
-        if (! empty($EVT_ID)) {
91
-            // Render a checkbox column
92
-            $columns['cb'] = '<input type="checkbox" />';
93
-            $this->_has_checkbox_column = true;
94
-            // Remove the 'Event' column
95
-            unset($this->_columns['Event']);
96
-        }
97
-        $this->_columns = array_merge($columns, $this->_columns);
98
-        $this->_primary_column = '_REG_att_checked_in';
99
-
100
-        $csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
101
-        if (! empty($csv_report)) {
102
-            $this->_bottom_buttons['csv_reg_report'] = $csv_report;
103
-        }
104
-
105
-        $this->_sortable_columns = array(
106
-            /**
107
-             * Allows users to change the default sort if they wish.
108
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
109
-             *
110
-             * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
111
-             * change the sorts on any list table involving registration contacts.  If you want to only change the filter
112
-             * for a specific list table you can use the provided reference to this object instance.
113
-             */
114
-            'ATT_name' => array(
115
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
116
-                true,
117
-                $this,
118
-            )
119
-                ? array('ATT_lname' => true)
120
-                : array('ATT_fname' => true),
121
-            'Event'    => array('Event.EVT_name' => false),
122
-        );
123
-        $this->_hidden_columns = array();
124
-        $this->_evt = EEM_Event::instance()->get_one_by_ID($EVT_ID);
125
-        $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array();
126
-    }
127
-
128
-
129
-    /**
130
-     * @param EE_Registration $item
131
-     * @return string
132
-     */
133
-    protected function _get_row_class($item)
134
-    {
135
-        $class = parent::_get_row_class($item);
136
-        // add status class
137
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
138
-        if ($this->_has_checkbox_column) {
139
-            $class .= ' has-checkbox-column';
140
-        }
141
-        return $class;
142
-    }
143
-
144
-
145
-    /**
146
-     * @return array
147
-     * @throws EE_Error
148
-     * @throws ReflectionException
149
-     */
150
-    protected function _get_table_filters()
151
-    {
152
-        $filters = $where = array();
153
-        $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0;
154
-        if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
155
-            // this means we don't have an event so let's setup a filter dropdown for all the events to select
156
-            // note possible capability restrictions
157
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
158
-                $where['status**'] = array('!=', 'private');
159
-            }
160
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
161
-                $where['EVT_wp_user'] = get_current_user_id();
162
-            }
163
-            $events = EEM_Event::instance()->get_all(
164
-                array(
165
-                    $where,
166
-                    'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'),
167
-                )
168
-            );
169
-            $evts[] = array(
170
-                'id'   => 0,
171
-                'text' => esc_html__('To toggle Check-in status, select an event', 'event_espresso'),
172
-            );
173
-            $checked = 'checked';
174
-            /** @var EE_Event $evt */
175
-            foreach ($events as $evt) {
176
-                // any registrations for this event?
177
-                if (! $evt->get_count_of_all_registrations()) {
178
-                    continue;
179
-                }
180
-                $evts[] = array(
181
-                    'id'    => $evt->ID(),
182
-                    'text'  => apply_filters(
183
-                        'FHEE__EE_Event_Registrations___get_table_filters__event_name',
184
-                        $evt->get('EVT_name'),
185
-                        $evt
186
-                    ),
187
-                    'class' => $evt->is_expired() ? 'ee-expired-event' : '',
188
-                );
189
-                if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) {
190
-                    $checked = '';
191
-                }
192
-            }
193
-            $event_filter = '<div class="ee-event-filter">';
194
-            $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID);
195
-            $event_filter .= '<span class="ee-event-filter-toggle">';
196
-            $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> ';
197
-            $event_filter .= esc_html__('Hide Expired Events', 'event_espresso');
198
-            $event_filter .= '</span>';
199
-            $event_filter .= '</div>';
200
-            $filters[] = $event_filter;
201
-        }
202
-        if (! empty($this->_dtts_for_event)) {
203
-            // DTT datetimes filter
204
-            $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
205
-            if (count($this->_dtts_for_event) > 1) {
206
-                $dtts[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso');
207
-                foreach ($this->_dtts_for_event as $dtt) {
208
-                    $datetime_string = $dtt->name();
209
-                    $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
210
-                    $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string;
211
-                    $dtts[ $dtt->ID() ] = $datetime_string;
212
-                }
213
-                $input = new EE_Select_Input(
214
-                    $dtts,
215
-                    array(
216
-                        'html_name' => 'DTT_ID',
217
-                        'html_id'   => 'DTT_ID',
218
-                        'default'   => $this->_cur_dtt_id,
219
-                    )
220
-                );
221
-                $filters[] = $input->get_html_for_input();
222
-                $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
223
-            }
224
-        }
225
-        return $filters;
226
-    }
227
-
228
-
229
-    protected function _add_view_counts()
230
-    {
231
-        $this->_views['all']['count'] = $this->_get_total_event_attendees();
232
-    }
233
-
234
-
235
-    /**
236
-     * @return int
237
-     * @throws EE_Error
238
-     */
239
-    protected function _get_total_event_attendees()
240
-    {
241
-        $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
242
-        $DTT_ID = $this->_cur_dtt_id;
243
-        $query_params = array();
244
-        if ($EVT_ID) {
245
-            $query_params[0]['EVT_ID'] = $EVT_ID;
246
-        }
247
-        // if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
248
-        if ($DTT_ID) {
249
-            $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID;
250
-        }
251
-        $status_ids_array = apply_filters(
252
-            'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
253
-            array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
254
-        );
255
-        $query_params[0]['STS_ID'] = array('IN', $status_ids_array);
256
-        return EEM_Registration::instance()->count($query_params);
257
-    }
258
-
259
-
260
-    /**
261
-     * @param EE_Registration $item
262
-     * @return string
263
-     */
264
-    public function column__Reg_Status(EE_Registration $item)
265
-    {
266
-        return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>';
267
-    }
268
-
269
-
270
-    /**
271
-     * @param EE_Registration $item
272
-     * @return string
273
-     * @throws EE_Error
274
-     */
275
-    public function column_cb($item)
276
-    {
277
-        return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
278
-    }
279
-
280
-
281
-    /**
282
-     * column_REG_att_checked_in
283
-     *
284
-     * @param EE_Registration $item
285
-     * @return string
286
-     * @throws EE_Error
287
-     * @throws InvalidArgumentException
288
-     * @throws InvalidDataTypeException
289
-     * @throws InvalidInterfaceException
290
-     */
291
-    public function column__REG_att_checked_in(EE_Registration $item)
292
-    {
293
-        $attendee = $item->attendee();
294
-        $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
295
-
296
-        if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) {
297
-            $latest_related_datetime = $item->get_latest_related_datetime();
298
-            if ($latest_related_datetime instanceof EE_Datetime) {
299
-                $this->_cur_dtt_id = $latest_related_datetime->ID();
300
-            }
301
-        }
302
-        $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId(
303
-            $item,
304
-            $this->_cur_dtt_id
305
-        );
306
-        $nonce = wp_create_nonce('checkin_nonce');
307
-        $toggle_active = ! empty($this->_cur_dtt_id)
308
-                         && EE_Registry::instance()->CAP->current_user_can(
309
-                             'ee_edit_checkin',
310
-                             'espresso_registrations_toggle_checkin_status',
311
-                             $item->ID()
312
-                         )
313
-            ? ' clickable trigger-checkin'
314
-            : '';
315
-        $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
316
-        return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"'
317
-               . ' data-_regid="' . $item->ID() . '"'
318
-               . ' data-dttid="' . $this->_cur_dtt_id . '"'
319
-               . ' data-nonce="' . $nonce . '">'
320
-               . '</span>'
321
-               . $mobile_view_content;
322
-    }
323
-
324
-
325
-    /**
326
-     * @param EE_Registration $item
327
-     * @return mixed|string|void
328
-     * @throws EE_Error
329
-     */
330
-    public function column_ATT_name(EE_Registration $item)
331
-    {
332
-        $attendee = $item->attendee();
333
-        if (! $attendee instanceof EE_Attendee) {
334
-            return esc_html__('No contact record for this registration.', 'event_espresso');
335
-        }
336
-        // edit attendee link
337
-        $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
338
-            array('action' => 'view_registration', '_REG_ID' => $item->ID()),
339
-            REG_ADMIN_URL
340
-        );
341
-        $name_link = EE_Registry::instance()->CAP->current_user_can(
342
-            'ee_edit_contacts',
343
-            'espresso_registrations_edit_attendee'
344
-        )
345
-            ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
346
-              . $item->attendee()->full_name()
347
-              . '</a>'
348
-            : $item->attendee()->full_name();
349
-        $name_link .= $item->count() === 1
350
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	'
351
-            : '';
352
-        // add group details
353
-        $name_link .= '&nbsp;' . sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
354
-        // add regcode
355
-        $link = EE_Admin_Page::add_query_args_and_nonce(
356
-            array('action' => 'view_registration', '_REG_ID' => $item->ID()),
357
-            REG_ADMIN_URL
358
-        );
359
-        $name_link .= '<br>';
360
-        $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can(
361
-            'ee_read_registration',
362
-            'view_registration',
363
-            $item->ID()
364
-        )
365
-            ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
366
-              . $item->reg_code()
367
-              . '</a>'
368
-            : $item->reg_code();
369
-        // status
370
-        $name_link .= '<br><span class="ee-status-text-small">';
371
-        $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence');
372
-        $name_link .= '</span>';
373
-        $actions = array();
374
-        $DTT_ID = $this->_cur_dtt_id;
375
-        $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration
376
-            ? $item->get_latest_related_datetime()
377
-            : null;
378
-        $DTT_ID = $latest_related_datetime instanceof EE_Datetime
379
-            ? $latest_related_datetime->ID()
380
-            : $DTT_ID;
381
-        if (
382
-            ! empty($DTT_ID)
383
-            && EE_Registry::instance()->CAP->current_user_can(
384
-                'ee_read_checkins',
385
-                'espresso_registrations_registration_checkins'
386
-            )
387
-        ) {
388
-            $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
389
-                array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID),
390
-                REG_ADMIN_URL
391
-            );
392
-            // get the timestamps for this registration's checkins, related to the selected datetime
393
-            $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID)));
394
-            if (! empty($timestamps)) {
395
-                // get the last timestamp
396
-                $last_timestamp = end($timestamps);
397
-                // checked in or checked out?
398
-                $checkin_status = $last_timestamp->get('CHK_in')
399
-                    ? esc_html__('Checked In', 'event_espresso')
400
-                    : esc_html__('Checked Out', 'event_espresso');
401
-                // get timestamp string
402
-                $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp');
403
-                $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="'
404
-                                      . esc_attr__(
405
-                                          'View this registrant\'s check-ins/checkouts for the datetime',
406
-                                          'event_espresso'
407
-                                      ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>';
408
-            }
409
-        }
410
-        return (! empty($DTT_ID) && ! empty($timestamps))
411
-            ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
412
-            : $name_link;
413
-    }
414
-
415
-
416
-    /**
417
-     * @param EE_Registration $item
418
-     * @return string
419
-     */
420
-    public function column_ATT_email(EE_Registration $item)
421
-    {
422
-        $attendee = $item->attendee();
423
-        return $attendee instanceof EE_Attendee ? $attendee->email() : '';
424
-    }
425
-
426
-
427
-    /**
428
-     * @param EE_Registration $item
429
-     * @return bool|string
430
-     * @throws EE_Error
431
-     */
432
-    public function column_Event(EE_Registration $item)
433
-    {
434
-        try {
435
-            $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event();
436
-            $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
437
-                array('action' => 'event_registrations', 'event_id' => $event->ID()),
438
-                REG_ADMIN_URL
439
-            );
440
-            $event_label = EE_Registry::instance()->CAP->current_user_can(
441
-                'ee_read_checkins',
442
-                'espresso_registrations_registration_checkins'
443
-            ) ? '<a href="' . $chkin_lnk_url . '" title="'
444
-                . esc_attr__(
445
-                    'View Checkins for this Event',
446
-                    'event_espresso'
447
-                ) . '">' . $event->name() . '</a>' : $event->name();
448
-        } catch (EntityNotFoundException $e) {
449
-            $event_label = esc_html__('Unknown', 'event_espresso');
450
-        }
451
-        return $event_label;
452
-    }
453
-
454
-
455
-    /**
456
-     * @param EE_Registration $item
457
-     * @return mixed|string|void
458
-     */
459
-    public function column_PRC_name(EE_Registration $item)
460
-    {
461
-        return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : esc_html__("Unknown", "event_espresso");
462
-    }
463
-
464
-
465
-    /**
466
-     * column_REG_final_price
467
-     *
468
-     * @param EE_Registration $item
469
-     * @return string
470
-     */
471
-    public function column__REG_final_price(EE_Registration $item)
472
-    {
473
-        return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
474
-    }
475
-
476
-
477
-    /**
478
-     * column_TXN_paid
479
-     *
480
-     * @param EE_Registration $item
481
-     * @return string
482
-     * @throws EE_Error
483
-     */
484
-    public function column_TXN_paid(EE_Registration $item)
485
-    {
486
-        if ($item->count() === 1) {
487
-            if ($item->transaction()->paid() >= $item->transaction()->total()) {
488
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
489
-            } else {
490
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
491
-                    array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()),
492
-                    TXN_ADMIN_URL
493
-                );
494
-                return EE_Registry::instance()->CAP->current_user_can(
495
-                    'ee_read_transaction',
496
-                    'espresso_transactions_view_transaction'
497
-                ) ? '
17
+	/**
18
+	 * This property will hold the related Datetimes on an event IF the event id is included in the request.
19
+	 *
20
+	 * @var EE_Datetime[]
21
+	 */
22
+	protected $_dtts_for_event = array();
23
+
24
+
25
+	/**
26
+	 * The event if one is specified in the request
27
+	 *
28
+	 * @var EE_Event
29
+	 */
30
+	protected $_evt = null;
31
+
32
+
33
+	/**
34
+	 * The DTT_ID if the current view has a specified datetime.
35
+	 *
36
+	 * @var int $_cur_dtt_id
37
+	 */
38
+	protected $_cur_dtt_id = 0;
39
+
40
+
41
+	/**
42
+	 * EE_Event_Registrations_List_Table constructor.
43
+	 *
44
+	 * @param Registrations_Admin_Page $admin_page
45
+	 */
46
+	public function __construct($admin_page)
47
+	{
48
+		parent::__construct($admin_page);
49
+		$this->_status = $this->_admin_page->get_registration_status_array();
50
+	}
51
+
52
+
53
+	protected function _setup_data()
54
+	{
55
+		$this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page)
56
+			: $this->_admin_page->get_event_attendees($this->_per_page, false, true);
57
+		$this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees(
58
+			$this->_per_page,
59
+			true
60
+		) : $this->_admin_page->get_event_attendees($this->_per_page, true, true);
61
+	}
62
+
63
+
64
+	protected function _set_properties()
65
+	{
66
+		$return_url = $this->getReturnUrl();
67
+
68
+		$EVT_ID = $this->_req_data['event_id'] ?? 0;
69
+		$DTT_ID = $this->_req_data['DTT_ID'] ?? 0;
70
+
71
+		$this->_wp_list_args = array(
72
+			'singular' => esc_html__('registrant', 'event_espresso'),
73
+			'plural'   => esc_html__('registrants', 'event_espresso'),
74
+			'ajax'     => true,
75
+			'screen'   => $this->_admin_page->get_current_screen()->id,
76
+		);
77
+		$columns = array();
78
+		// $columns['_Reg_Status'] = '';
79
+		$this->_columns = array(
80
+			'_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>',
81
+			'ATT_name'            => esc_html__('Registrant', 'event_espresso'),
82
+			'ATT_email'           => esc_html__('Email Address', 'event_espresso'),
83
+			'Event'               => esc_html__('Event', 'event_espresso'),
84
+			'PRC_name'            => esc_html__('TKT Option', 'event_espresso'),
85
+			'_REG_final_price'    => esc_html__('Price', 'event_espresso'),
86
+			'TXN_paid'            => esc_html__('Paid', 'event_espresso'),
87
+			'TXN_total'           => esc_html__('Total', 'event_espresso'),
88
+		);
89
+		// Add/remove columns when an event has been selected
90
+		if (! empty($EVT_ID)) {
91
+			// Render a checkbox column
92
+			$columns['cb'] = '<input type="checkbox" />';
93
+			$this->_has_checkbox_column = true;
94
+			// Remove the 'Event' column
95
+			unset($this->_columns['Event']);
96
+		}
97
+		$this->_columns = array_merge($columns, $this->_columns);
98
+		$this->_primary_column = '_REG_att_checked_in';
99
+
100
+		$csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
101
+		if (! empty($csv_report)) {
102
+			$this->_bottom_buttons['csv_reg_report'] = $csv_report;
103
+		}
104
+
105
+		$this->_sortable_columns = array(
106
+			/**
107
+			 * Allows users to change the default sort if they wish.
108
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name.
109
+			 *
110
+			 * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to
111
+			 * change the sorts on any list table involving registration contacts.  If you want to only change the filter
112
+			 * for a specific list table you can use the provided reference to this object instance.
113
+			 */
114
+			'ATT_name' => array(
115
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
116
+				true,
117
+				$this,
118
+			)
119
+				? array('ATT_lname' => true)
120
+				: array('ATT_fname' => true),
121
+			'Event'    => array('Event.EVT_name' => false),
122
+		);
123
+		$this->_hidden_columns = array();
124
+		$this->_evt = EEM_Event::instance()->get_one_by_ID($EVT_ID);
125
+		$this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array();
126
+	}
127
+
128
+
129
+	/**
130
+	 * @param EE_Registration $item
131
+	 * @return string
132
+	 */
133
+	protected function _get_row_class($item)
134
+	{
135
+		$class = parent::_get_row_class($item);
136
+		// add status class
137
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
138
+		if ($this->_has_checkbox_column) {
139
+			$class .= ' has-checkbox-column';
140
+		}
141
+		return $class;
142
+	}
143
+
144
+
145
+	/**
146
+	 * @return array
147
+	 * @throws EE_Error
148
+	 * @throws ReflectionException
149
+	 */
150
+	protected function _get_table_filters()
151
+	{
152
+		$filters = $where = array();
153
+		$current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0;
154
+		if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
155
+			// this means we don't have an event so let's setup a filter dropdown for all the events to select
156
+			// note possible capability restrictions
157
+			if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
158
+				$where['status**'] = array('!=', 'private');
159
+			}
160
+			if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
161
+				$where['EVT_wp_user'] = get_current_user_id();
162
+			}
163
+			$events = EEM_Event::instance()->get_all(
164
+				array(
165
+					$where,
166
+					'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'),
167
+				)
168
+			);
169
+			$evts[] = array(
170
+				'id'   => 0,
171
+				'text' => esc_html__('To toggle Check-in status, select an event', 'event_espresso'),
172
+			);
173
+			$checked = 'checked';
174
+			/** @var EE_Event $evt */
175
+			foreach ($events as $evt) {
176
+				// any registrations for this event?
177
+				if (! $evt->get_count_of_all_registrations()) {
178
+					continue;
179
+				}
180
+				$evts[] = array(
181
+					'id'    => $evt->ID(),
182
+					'text'  => apply_filters(
183
+						'FHEE__EE_Event_Registrations___get_table_filters__event_name',
184
+						$evt->get('EVT_name'),
185
+						$evt
186
+					),
187
+					'class' => $evt->is_expired() ? 'ee-expired-event' : '',
188
+				);
189
+				if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) {
190
+					$checked = '';
191
+				}
192
+			}
193
+			$event_filter = '<div class="ee-event-filter">';
194
+			$event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID);
195
+			$event_filter .= '<span class="ee-event-filter-toggle">';
196
+			$event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> ';
197
+			$event_filter .= esc_html__('Hide Expired Events', 'event_espresso');
198
+			$event_filter .= '</span>';
199
+			$event_filter .= '</div>';
200
+			$filters[] = $event_filter;
201
+		}
202
+		if (! empty($this->_dtts_for_event)) {
203
+			// DTT datetimes filter
204
+			$this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
205
+			if (count($this->_dtts_for_event) > 1) {
206
+				$dtts[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso');
207
+				foreach ($this->_dtts_for_event as $dtt) {
208
+					$datetime_string = $dtt->name();
209
+					$datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
210
+					$datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string;
211
+					$dtts[ $dtt->ID() ] = $datetime_string;
212
+				}
213
+				$input = new EE_Select_Input(
214
+					$dtts,
215
+					array(
216
+						'html_name' => 'DTT_ID',
217
+						'html_id'   => 'DTT_ID',
218
+						'default'   => $this->_cur_dtt_id,
219
+					)
220
+				);
221
+				$filters[] = $input->get_html_for_input();
222
+				$filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
223
+			}
224
+		}
225
+		return $filters;
226
+	}
227
+
228
+
229
+	protected function _add_view_counts()
230
+	{
231
+		$this->_views['all']['count'] = $this->_get_total_event_attendees();
232
+	}
233
+
234
+
235
+	/**
236
+	 * @return int
237
+	 * @throws EE_Error
238
+	 */
239
+	protected function _get_total_event_attendees()
240
+	{
241
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false;
242
+		$DTT_ID = $this->_cur_dtt_id;
243
+		$query_params = array();
244
+		if ($EVT_ID) {
245
+			$query_params[0]['EVT_ID'] = $EVT_ID;
246
+		}
247
+		// if DTT is included we only show for that datetime.  Otherwise we're showing for all datetimes (the event).
248
+		if ($DTT_ID) {
249
+			$query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID;
250
+		}
251
+		$status_ids_array = apply_filters(
252
+			'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array',
253
+			array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved)
254
+		);
255
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
256
+		return EEM_Registration::instance()->count($query_params);
257
+	}
258
+
259
+
260
+	/**
261
+	 * @param EE_Registration $item
262
+	 * @return string
263
+	 */
264
+	public function column__Reg_Status(EE_Registration $item)
265
+	{
266
+		return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>';
267
+	}
268
+
269
+
270
+	/**
271
+	 * @param EE_Registration $item
272
+	 * @return string
273
+	 * @throws EE_Error
274
+	 */
275
+	public function column_cb($item)
276
+	{
277
+		return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
278
+	}
279
+
280
+
281
+	/**
282
+	 * column_REG_att_checked_in
283
+	 *
284
+	 * @param EE_Registration $item
285
+	 * @return string
286
+	 * @throws EE_Error
287
+	 * @throws InvalidArgumentException
288
+	 * @throws InvalidDataTypeException
289
+	 * @throws InvalidInterfaceException
290
+	 */
291
+	public function column__REG_att_checked_in(EE_Registration $item)
292
+	{
293
+		$attendee = $item->attendee();
294
+		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
295
+
296
+		if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) {
297
+			$latest_related_datetime = $item->get_latest_related_datetime();
298
+			if ($latest_related_datetime instanceof EE_Datetime) {
299
+				$this->_cur_dtt_id = $latest_related_datetime->ID();
300
+			}
301
+		}
302
+		$checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId(
303
+			$item,
304
+			$this->_cur_dtt_id
305
+		);
306
+		$nonce = wp_create_nonce('checkin_nonce');
307
+		$toggle_active = ! empty($this->_cur_dtt_id)
308
+						 && EE_Registry::instance()->CAP->current_user_can(
309
+							 'ee_edit_checkin',
310
+							 'espresso_registrations_toggle_checkin_status',
311
+							 $item->ID()
312
+						 )
313
+			? ' clickable trigger-checkin'
314
+			: '';
315
+		$mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
316
+		return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"'
317
+			   . ' data-_regid="' . $item->ID() . '"'
318
+			   . ' data-dttid="' . $this->_cur_dtt_id . '"'
319
+			   . ' data-nonce="' . $nonce . '">'
320
+			   . '</span>'
321
+			   . $mobile_view_content;
322
+	}
323
+
324
+
325
+	/**
326
+	 * @param EE_Registration $item
327
+	 * @return mixed|string|void
328
+	 * @throws EE_Error
329
+	 */
330
+	public function column_ATT_name(EE_Registration $item)
331
+	{
332
+		$attendee = $item->attendee();
333
+		if (! $attendee instanceof EE_Attendee) {
334
+			return esc_html__('No contact record for this registration.', 'event_espresso');
335
+		}
336
+		// edit attendee link
337
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
338
+			array('action' => 'view_registration', '_REG_ID' => $item->ID()),
339
+			REG_ADMIN_URL
340
+		);
341
+		$name_link = EE_Registry::instance()->CAP->current_user_can(
342
+			'ee_edit_contacts',
343
+			'espresso_registrations_edit_attendee'
344
+		)
345
+			? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
346
+			  . $item->attendee()->full_name()
347
+			  . '</a>'
348
+			: $item->attendee()->full_name();
349
+		$name_link .= $item->count() === 1
350
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	'
351
+			: '';
352
+		// add group details
353
+		$name_link .= '&nbsp;' . sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
354
+		// add regcode
355
+		$link = EE_Admin_Page::add_query_args_and_nonce(
356
+			array('action' => 'view_registration', '_REG_ID' => $item->ID()),
357
+			REG_ADMIN_URL
358
+		);
359
+		$name_link .= '<br>';
360
+		$name_link .= EE_Registry::instance()->instance()->CAP->current_user_can(
361
+			'ee_read_registration',
362
+			'view_registration',
363
+			$item->ID()
364
+		)
365
+			? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
366
+			  . $item->reg_code()
367
+			  . '</a>'
368
+			: $item->reg_code();
369
+		// status
370
+		$name_link .= '<br><span class="ee-status-text-small">';
371
+		$name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence');
372
+		$name_link .= '</span>';
373
+		$actions = array();
374
+		$DTT_ID = $this->_cur_dtt_id;
375
+		$latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration
376
+			? $item->get_latest_related_datetime()
377
+			: null;
378
+		$DTT_ID = $latest_related_datetime instanceof EE_Datetime
379
+			? $latest_related_datetime->ID()
380
+			: $DTT_ID;
381
+		if (
382
+			! empty($DTT_ID)
383
+			&& EE_Registry::instance()->CAP->current_user_can(
384
+				'ee_read_checkins',
385
+				'espresso_registrations_registration_checkins'
386
+			)
387
+		) {
388
+			$checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(
389
+				array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID),
390
+				REG_ADMIN_URL
391
+			);
392
+			// get the timestamps for this registration's checkins, related to the selected datetime
393
+			$timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID)));
394
+			if (! empty($timestamps)) {
395
+				// get the last timestamp
396
+				$last_timestamp = end($timestamps);
397
+				// checked in or checked out?
398
+				$checkin_status = $last_timestamp->get('CHK_in')
399
+					? esc_html__('Checked In', 'event_espresso')
400
+					: esc_html__('Checked Out', 'event_espresso');
401
+				// get timestamp string
402
+				$timestamp_string = $last_timestamp->get_datetime('CHK_timestamp');
403
+				$actions['checkin'] = '<a href="' . $checkin_list_url . '" title="'
404
+									  . esc_attr__(
405
+										  'View this registrant\'s check-ins/checkouts for the datetime',
406
+										  'event_espresso'
407
+									  ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>';
408
+			}
409
+		}
410
+		return (! empty($DTT_ID) && ! empty($timestamps))
411
+			? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
412
+			: $name_link;
413
+	}
414
+
415
+
416
+	/**
417
+	 * @param EE_Registration $item
418
+	 * @return string
419
+	 */
420
+	public function column_ATT_email(EE_Registration $item)
421
+	{
422
+		$attendee = $item->attendee();
423
+		return $attendee instanceof EE_Attendee ? $attendee->email() : '';
424
+	}
425
+
426
+
427
+	/**
428
+	 * @param EE_Registration $item
429
+	 * @return bool|string
430
+	 * @throws EE_Error
431
+	 */
432
+	public function column_Event(EE_Registration $item)
433
+	{
434
+		try {
435
+			$event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event();
436
+			$chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
437
+				array('action' => 'event_registrations', 'event_id' => $event->ID()),
438
+				REG_ADMIN_URL
439
+			);
440
+			$event_label = EE_Registry::instance()->CAP->current_user_can(
441
+				'ee_read_checkins',
442
+				'espresso_registrations_registration_checkins'
443
+			) ? '<a href="' . $chkin_lnk_url . '" title="'
444
+				. esc_attr__(
445
+					'View Checkins for this Event',
446
+					'event_espresso'
447
+				) . '">' . $event->name() . '</a>' : $event->name();
448
+		} catch (EntityNotFoundException $e) {
449
+			$event_label = esc_html__('Unknown', 'event_espresso');
450
+		}
451
+		return $event_label;
452
+	}
453
+
454
+
455
+	/**
456
+	 * @param EE_Registration $item
457
+	 * @return mixed|string|void
458
+	 */
459
+	public function column_PRC_name(EE_Registration $item)
460
+	{
461
+		return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : esc_html__("Unknown", "event_espresso");
462
+	}
463
+
464
+
465
+	/**
466
+	 * column_REG_final_price
467
+	 *
468
+	 * @param EE_Registration $item
469
+	 * @return string
470
+	 */
471
+	public function column__REG_final_price(EE_Registration $item)
472
+	{
473
+		return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
474
+	}
475
+
476
+
477
+	/**
478
+	 * column_TXN_paid
479
+	 *
480
+	 * @param EE_Registration $item
481
+	 * @return string
482
+	 * @throws EE_Error
483
+	 */
484
+	public function column_TXN_paid(EE_Registration $item)
485
+	{
486
+		if ($item->count() === 1) {
487
+			if ($item->transaction()->paid() >= $item->transaction()->total()) {
488
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
489
+			} else {
490
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
491
+					array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()),
492
+					TXN_ADMIN_URL
493
+				);
494
+				return EE_Registry::instance()->CAP->current_user_can(
495
+					'ee_read_transaction',
496
+					'espresso_transactions_view_transaction'
497
+				) ? '
498 498
 				<span class="reg-pad-rght">
499 499
 					<a class="status-'
500
-                    . $item->transaction()->status_ID()
501
-                    . '" href="'
502
-                    . $view_txn_lnk_url
503
-                    . '"  title="'
504
-                    . esc_attr__('View Transaction', 'event_espresso')
505
-                    . '">
500
+					. $item->transaction()->status_ID()
501
+					. '" href="'
502
+					. $view_txn_lnk_url
503
+					. '"  title="'
504
+					. esc_attr__('View Transaction', 'event_espresso')
505
+					. '">
506 506
 						'
507
-                    . $item->transaction()->pretty_paid()
508
-                    . '
507
+					. $item->transaction()->pretty_paid()
508
+					. '
509 509
 					</a>
510 510
 				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
511
-            }
512
-        } else {
513
-            return '<span class="reg-pad-rght"></span>';
514
-        }
515
-    }
516
-
517
-
518
-    /**
519
-     *        column_TXN_total
520
-     *
521
-     * @param EE_Registration $item
522
-     * @return string
523
-     * @throws EE_Error
524
-     */
525
-    public function column_TXN_total(EE_Registration $item)
526
-    {
527
-        $txn = $item->transaction();
528
-        $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL);
529
-        if ($item->get('REG_count') === 1) {
530
-            $line_total_obj = $txn->total_line_item();
531
-            $txn_total = $line_total_obj instanceof EE_Line_Item
532
-                ? $line_total_obj->get_pretty('LIN_total')
533
-                : esc_html__(
534
-                    'View Transaction',
535
-                    'event_espresso'
536
-                );
537
-            return EE_Registry::instance()->CAP->current_user_can(
538
-                'ee_read_transaction',
539
-                'espresso_transactions_view_transaction'
540
-            ) ? '<a href="'
541
-                . $view_txn_url
542
-                . '" title="'
543
-                . esc_attr__('View Transaction', 'event_espresso')
544
-                . '"><span class="reg-pad-rght">'
545
-                . $txn_total
546
-                . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
547
-        } else {
548
-            return '<span class="reg-pad-rght"></span>';
549
-        }
550
-    }
511
+			}
512
+		} else {
513
+			return '<span class="reg-pad-rght"></span>';
514
+		}
515
+	}
516
+
517
+
518
+	/**
519
+	 *        column_TXN_total
520
+	 *
521
+	 * @param EE_Registration $item
522
+	 * @return string
523
+	 * @throws EE_Error
524
+	 */
525
+	public function column_TXN_total(EE_Registration $item)
526
+	{
527
+		$txn = $item->transaction();
528
+		$view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL);
529
+		if ($item->get('REG_count') === 1) {
530
+			$line_total_obj = $txn->total_line_item();
531
+			$txn_total = $line_total_obj instanceof EE_Line_Item
532
+				? $line_total_obj->get_pretty('LIN_total')
533
+				: esc_html__(
534
+					'View Transaction',
535
+					'event_espresso'
536
+				);
537
+			return EE_Registry::instance()->CAP->current_user_can(
538
+				'ee_read_transaction',
539
+				'espresso_transactions_view_transaction'
540
+			) ? '<a href="'
541
+				. $view_txn_url
542
+				. '" title="'
543
+				. esc_attr__('View Transaction', 'event_espresso')
544
+				. '"><span class="reg-pad-rght">'
545
+				. $txn_total
546
+				. '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
547
+		} else {
548
+			return '<span class="reg-pad-rght"></span>';
549
+		}
550
+	}
551 551
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             'TXN_total'           => esc_html__('Total', 'event_espresso'),
88 88
         );
89 89
         // Add/remove columns when an event has been selected
90
-        if (! empty($EVT_ID)) {
90
+        if ( ! empty($EVT_ID)) {
91 91
             // Render a checkbox column
92 92
             $columns['cb'] = '<input type="checkbox" />';
93 93
             $this->_has_checkbox_column = true;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         $this->_primary_column = '_REG_att_checked_in';
99 99
 
100 100
         $csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
101
-        if (! empty($csv_report)) {
101
+        if ( ! empty($csv_report)) {
102 102
             $this->_bottom_buttons['csv_reg_report'] = $csv_report;
103 103
         }
104 104
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     {
135 135
         $class = parent::_get_row_class($item);
136 136
         // add status class
137
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
137
+        $class .= ' ee-status-strip reg-status-'.$item->status_ID();
138 138
         if ($this->_has_checkbox_column) {
139 139
             $class .= ' has-checkbox-column';
140 140
         }
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
         if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) {
155 155
             // this means we don't have an event so let's setup a filter dropdown for all the events to select
156 156
             // note possible capability restrictions
157
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
157
+            if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
158 158
                 $where['status**'] = array('!=', 'private');
159 159
             }
160
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
160
+            if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
161 161
                 $where['EVT_wp_user'] = get_current_user_id();
162 162
             }
163 163
             $events = EEM_Event::instance()->get_all(
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             /** @var EE_Event $evt */
175 175
             foreach ($events as $evt) {
176 176
                 // any registrations for this event?
177
-                if (! $evt->get_count_of_all_registrations()) {
177
+                if ( ! $evt->get_count_of_all_registrations()) {
178 178
                     continue;
179 179
                 }
180 180
                 $evts[] = array(
@@ -193,22 +193,22 @@  discard block
 block discarded – undo
193 193
             $event_filter = '<div class="ee-event-filter">';
194 194
             $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID);
195 195
             $event_filter .= '<span class="ee-event-filter-toggle">';
196
-            $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> ';
196
+            $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" '.$checked.'> ';
197 197
             $event_filter .= esc_html__('Hide Expired Events', 'event_espresso');
198 198
             $event_filter .= '</span>';
199 199
             $event_filter .= '</div>';
200 200
             $filters[] = $event_filter;
201 201
         }
202
-        if (! empty($this->_dtts_for_event)) {
202
+        if ( ! empty($this->_dtts_for_event)) {
203 203
             // DTT datetimes filter
204 204
             $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
205 205
             if (count($this->_dtts_for_event) > 1) {
206 206
                 $dtts[0] = esc_html__('To toggle check-in status, select a datetime.', 'event_espresso');
207 207
                 foreach ($this->_dtts_for_event as $dtt) {
208 208
                     $datetime_string = $dtt->name();
209
-                    $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : '';
210
-                    $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string;
211
-                    $dtts[ $dtt->ID() ] = $datetime_string;
209
+                    $datetime_string = ! empty($datetime_string) ? ' ('.$datetime_string.')' : '';
210
+                    $datetime_string = $dtt->start_date_and_time().' - '.$dtt->end_date_and_time().$datetime_string;
211
+                    $dtts[$dtt->ID()] = $datetime_string;
212 212
                 }
213 213
                 $input = new EE_Select_Input(
214 214
                     $dtts,
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
                     )
220 220
                 );
221 221
                 $filters[] = $input->get_html_for_input();
222
-                $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">';
222
+                $filters[] = '<input type="hidden" name="event_id" value="'.$current_EVT_ID.'">';
223 223
             }
224 224
         }
225 225
         return $filters;
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
      */
264 264
     public function column__Reg_Status(EE_Registration $item)
265 265
     {
266
-        return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>';
266
+        return '<span class="ee-status-strip ee-status-strip-td reg-status-'.$item->status_ID().'"></span>';
267 267
     }
268 268
 
269 269
 
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
                          )
313 313
             ? ' clickable trigger-checkin'
314 314
             : '';
315
-        $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
316
-        return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"'
317
-               . ' data-_regid="' . $item->ID() . '"'
318
-               . ' data-dttid="' . $this->_cur_dtt_id . '"'
319
-               . ' data-nonce="' . $nonce . '">'
315
+        $mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>';
316
+        return '<span class="'.$checkin_status_dashicon->cssClasses().$toggle_active.'"'
317
+               . ' data-_regid="'.$item->ID().'"'
318
+               . ' data-dttid="'.$this->_cur_dtt_id.'"'
319
+               . ' data-nonce="'.$nonce.'">'
320 320
                . '</span>'
321 321
                . $mobile_view_content;
322 322
     }
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
     public function column_ATT_name(EE_Registration $item)
331 331
     {
332 332
         $attendee = $item->attendee();
333
-        if (! $attendee instanceof EE_Attendee) {
333
+        if ( ! $attendee instanceof EE_Attendee) {
334 334
             return esc_html__('No contact record for this registration.', 'event_espresso');
335 335
         }
336 336
         // edit attendee link
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
             'ee_edit_contacts',
343 343
             'espresso_registrations_edit_attendee'
344 344
         )
345
-            ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
345
+            ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
346 346
               . $item->attendee()->full_name()
347 347
               . '</a>'
348 348
             : $item->attendee()->full_name();
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	'
351 351
             : '';
352 352
         // add group details
353
-        $name_link .= '&nbsp;' . sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
353
+        $name_link .= '&nbsp;'.sprintf(esc_html__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
354 354
         // add regcode
355 355
         $link = EE_Admin_Page::add_query_args_and_nonce(
356 356
             array('action' => 'view_registration', '_REG_ID' => $item->ID()),
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
             'view_registration',
363 363
             $item->ID()
364 364
         )
365
-            ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
365
+            ? '<a href="'.$link.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
366 366
               . $item->reg_code()
367 367
               . '</a>'
368 368
             : $item->reg_code();
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
             );
392 392
             // get the timestamps for this registration's checkins, related to the selected datetime
393 393
             $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID)));
394
-            if (! empty($timestamps)) {
394
+            if ( ! empty($timestamps)) {
395 395
                 // get the last timestamp
396 396
                 $last_timestamp = end($timestamps);
397 397
                 // checked in or checked out?
@@ -400,14 +400,14 @@  discard block
 block discarded – undo
400 400
                     : esc_html__('Checked Out', 'event_espresso');
401 401
                 // get timestamp string
402 402
                 $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp');
403
-                $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="'
403
+                $actions['checkin'] = '<a href="'.$checkin_list_url.'" title="'
404 404
                                       . esc_attr__(
405 405
                                           'View this registrant\'s check-ins/checkouts for the datetime',
406 406
                                           'event_espresso'
407
-                                      ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>';
407
+                                      ).'">'.$checkin_status.': '.$timestamp_string.'</a>';
408 408
             }
409 409
         }
410
-        return (! empty($DTT_ID) && ! empty($timestamps))
410
+        return ( ! empty($DTT_ID) && ! empty($timestamps))
411 411
             ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true))
412 412
             : $name_link;
413 413
     }
@@ -440,11 +440,11 @@  discard block
 block discarded – undo
440 440
             $event_label = EE_Registry::instance()->CAP->current_user_can(
441 441
                 'ee_read_checkins',
442 442
                 'espresso_registrations_registration_checkins'
443
-            ) ? '<a href="' . $chkin_lnk_url . '" title="'
443
+            ) ? '<a href="'.$chkin_lnk_url.'" title="'
444 444
                 . esc_attr__(
445 445
                     'View Checkins for this Event',
446 446
                     'event_espresso'
447
-                ) . '">' . $event->name() . '</a>' : $event->name();
447
+                ).'">'.$event->name().'</a>' : $event->name();
448 448
         } catch (EntityNotFoundException $e) {
449 449
             $event_label = esc_html__('Unknown', 'event_espresso');
450 450
         }
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
      */
471 471
     public function column__REG_final_price(EE_Registration $item)
472 472
     {
473
-        return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>';
473
+        return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>';
474 474
     }
475 475
 
476 476
 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
                     . $item->transaction()->pretty_paid()
508 508
                     . '
509 509
 					</a>
510
-				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
510
+				<span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
511 511
             }
512 512
         } else {
513 513
             return '<span class="reg-pad-rght"></span>';
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
                 . esc_attr__('View Transaction', 'event_espresso')
544 544
                 . '"><span class="reg-pad-rght">'
545 545
                 . $txn_total
546
-                . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
546
+                . '</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>';
547 547
         } else {
548 548
             return '<span class="reg-pad-rght"></span>';
549 549
         }
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 1 patch
Indentation   +1414 added lines, -1414 removed lines patch added patch discarded remove patch
@@ -20,1429 +20,1429 @@
 block discarded – undo
20 20
 class General_Settings_Admin_Page extends EE_Admin_Page
21 21
 {
22 22
 
23
-    /**
24
-     * @var EE_Core_Config
25
-     */
26
-    public $core_config;
27
-
28
-
29
-    /**
30
-     * Initialize basic properties.
31
-     */
32
-    protected function _init_page_props()
33
-    {
34
-        $this->page_slug        = GEN_SET_PG_SLUG;
35
-        $this->page_label       = GEN_SET_LABEL;
36
-        $this->_admin_base_url  = GEN_SET_ADMIN_URL;
37
-        $this->_admin_base_path = GEN_SET_ADMIN;
38
-    }
39
-
40
-
41
-    /**
42
-     * Set ajax hooks
43
-     */
44
-    protected function _ajax_hooks()
45
-    {
46
-        add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
47
-        add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
48
-        add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
49
-        add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
50
-    }
51
-
52
-
53
-    /**
54
-     * More page properties initialization.
55
-     */
56
-    protected function _define_page_props()
57
-    {
58
-        $this->_admin_page_title = GEN_SET_LABEL;
59
-        $this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
60
-    }
61
-
62
-
63
-    /**
64
-     * Set page routes property.
65
-     */
66
-    protected function _set_page_routes()
67
-    {
68
-        $this->_page_routes = [
69
-            'critical_pages'                => [
70
-                'func'       => '_espresso_page_settings',
71
-                'capability' => 'manage_options',
72
-            ],
73
-            'update_espresso_page_settings' => [
74
-                'func'       => '_update_espresso_page_settings',
75
-                'capability' => 'manage_options',
76
-                'noheader'   => true,
77
-            ],
78
-            'default'                       => [
79
-                'func'       => '_your_organization_settings',
80
-                'capability' => 'manage_options',
81
-            ],
82
-
83
-            'update_your_organization_settings' => [
84
-                'func'       => '_update_your_organization_settings',
85
-                'capability' => 'manage_options',
86
-                'noheader'   => true,
87
-            ],
88
-
89
-            'admin_option_settings' => [
90
-                'func'       => '_admin_option_settings',
91
-                'capability' => 'manage_options',
92
-            ],
93
-
94
-            'update_admin_option_settings' => [
95
-                'func'       => '_update_admin_option_settings',
96
-                'capability' => 'manage_options',
97
-                'noheader'   => true,
98
-            ],
99
-
100
-            'country_settings' => [
101
-                'func'       => '_country_settings',
102
-                'capability' => 'manage_options',
103
-            ],
104
-
105
-            'update_country_settings' => [
106
-                'func'       => '_update_country_settings',
107
-                'capability' => 'manage_options',
108
-                'noheader'   => true,
109
-            ],
110
-
111
-            'display_country_settings' => [
112
-                'func'       => 'display_country_settings',
113
-                'capability' => 'manage_options',
114
-                'noheader'   => true,
115
-            ],
116
-
117
-            'add_new_state' => [
118
-                'func'       => 'add_new_state',
119
-                'capability' => 'manage_options',
120
-                'noheader'   => true,
121
-            ],
122
-
123
-            'delete_state'            => [
124
-                'func'       => 'delete_state',
125
-                'capability' => 'manage_options',
126
-                'noheader'   => true,
127
-            ],
128
-            'privacy_settings'        => [
129
-                'func'       => 'privacySettings',
130
-                'capability' => 'manage_options',
131
-            ],
132
-            'update_privacy_settings' => [
133
-                'func'               => 'updatePrivacySettings',
134
-                'capability'         => 'manage_options',
135
-                'noheader'           => true,
136
-                'headers_sent_route' => 'privacy_settings',
137
-            ],
138
-        ];
139
-    }
140
-
141
-
142
-    /**
143
-     * Set page configuration property
144
-     */
145
-    protected function _set_page_config()
146
-    {
147
-        $this->_page_config = [
148
-            'critical_pages'        => [
149
-                'nav'           => [
150
-                    'label' => esc_html__('Critical Pages', 'event_espresso'),
151
-                    'order' => 50,
152
-                ],
153
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
154
-                'help_tabs'     => [
155
-                    'general_settings_critical_pages_help_tab' => [
156
-                        'title'    => esc_html__('Critical Pages', 'event_espresso'),
157
-                        'filename' => 'general_settings_critical_pages',
158
-                    ],
159
-                ],
160
-                'require_nonce' => false,
161
-            ],
162
-            'default'               => [
163
-                'nav'           => [
164
-                    'label' => esc_html__('Your Organization', 'event_espresso'),
165
-                    'order' => 20,
166
-                ],
167
-                'help_tabs'     => [
168
-                    'general_settings_your_organization_help_tab' => [
169
-                        'title'    => esc_html__('Your Organization', 'event_espresso'),
170
-                        'filename' => 'general_settings_your_organization',
171
-                    ],
172
-                ],
173
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
174
-                'require_nonce' => false,
175
-            ],
176
-            'admin_option_settings' => [
177
-                'nav'           => [
178
-                    'label' => esc_html__('Admin Options', 'event_espresso'),
179
-                    'order' => 60,
180
-                ],
181
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
182
-                'help_tabs'     => [
183
-                    'general_settings_admin_options_help_tab' => [
184
-                        'title'    => esc_html__('Admin Options', 'event_espresso'),
185
-                        'filename' => 'general_settings_admin_options',
186
-                    ],
187
-                ],
188
-                'require_nonce' => false,
189
-            ],
190
-            'country_settings'      => [
191
-                'nav'           => [
192
-                    'label' => esc_html__('Countries', 'event_espresso'),
193
-                    'order' => 70,
194
-                ],
195
-                'help_tabs'     => [
196
-                    'general_settings_countries_help_tab' => [
197
-                        'title'    => esc_html__('Countries', 'event_espresso'),
198
-                        'filename' => 'general_settings_countries',
199
-                    ],
200
-                ],
201
-                'require_nonce' => false,
202
-            ],
203
-            'privacy_settings'      => [
204
-                'nav'           => [
205
-                    'label' => esc_html__('Privacy', 'event_espresso'),
206
-                    'order' => 80,
207
-                ],
208
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
209
-                'require_nonce' => false,
210
-            ],
211
-        ];
212
-    }
213
-
214
-
215
-    protected function _add_screen_options()
216
-    {
217
-    }
218
-
219
-
220
-    protected function _add_feature_pointers()
221
-    {
222
-    }
223
-
224
-
225
-    /**
226
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
227
-     */
228
-    public function load_scripts_styles()
229
-    {
230
-        // styles
231
-        wp_enqueue_style('espresso-ui-theme');
232
-        // scripts
233
-        wp_enqueue_script('ee_admin_js');
234
-    }
235
-
236
-
237
-    /**
238
-     * Execute logic running on `admin_init`
239
-     */
240
-    public function admin_init()
241
-    {
242
-        $this->core_config = EE_Registry::instance()->CFG->core;
243
-
244
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
245
-            esc_html__(
246
-                'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
247
-                'event_espresso'
248
-            )
249
-        );
250
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
251
-            esc_html__(
252
-                'An error occurred! Please refresh the page and try again.',
253
-                'event_espresso'
254
-            )
255
-        );
256
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
257
-            esc_html__(
258
-                'Are you sure you want to delete this State / Province?',
259
-                'event_espresso'
260
-            )
261
-        );
262
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
263
-            'admin-ajax.php?page=espresso_general_settings',
264
-            is_ssl() ? 'https://' : 'http://'
265
-        );
266
-    }
267
-
268
-
269
-    public function admin_notices()
270
-    {
271
-    }
272
-
273
-
274
-    public function admin_footer_scripts()
275
-    {
276
-    }
277
-
278
-
279
-    /**
280
-     * Enqueue scripts and styles for the default route.
281
-     */
282
-    public function load_scripts_styles_default()
283
-    {
284
-        // styles
285
-        wp_enqueue_style('thickbox');
286
-        // scripts
287
-        wp_enqueue_script('media-upload');
288
-        wp_enqueue_script('thickbox');
289
-        wp_register_script(
290
-            'organization_settings',
291
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
292
-            ['jquery', 'media-upload', 'thickbox'],
293
-            EVENT_ESPRESSO_VERSION,
294
-            true
295
-        );
296
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
297
-        wp_enqueue_script('organization_settings');
298
-        wp_enqueue_style('organization-css');
299
-        $confirm_image_delete = [
300
-            'text' => wp_strip_all_tags(
301
-                esc_html__(
302
-                    'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
303
-                    'event_espresso'
304
-                )
305
-            ),
306
-        ];
307
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
308
-    }
309
-
310
-
311
-    /**
312
-     * Enqueue scripts and styles for the country settings route.
313
-     */
314
-    public function load_scripts_styles_country_settings()
315
-    {
316
-        // scripts
317
-        wp_register_script(
318
-            'gen_settings_countries',
319
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
320
-            ['ee_admin_js'],
321
-            EVENT_ESPRESSO_VERSION,
322
-            true
323
-        );
324
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
325
-        wp_enqueue_script('gen_settings_countries');
326
-        wp_enqueue_style('organization-css');
327
-    }
328
-
329
-
330
-    /*************        Espresso Pages        *************/
331
-    /**
332
-     * _espresso_page_settings
333
-     *
334
-     * @throws EE_Error
335
-     * @throws DomainException
336
-     * @throws DomainException
337
-     * @throws InvalidDataTypeException
338
-     * @throws InvalidArgumentException
339
-     */
340
-    protected function _espresso_page_settings()
341
-    {
342
-        // Check to make sure all of the main pages are set up properly,
343
-        // if not create the default pages and display an admin notice
344
-        EEH_Activation::verify_default_pages_exist();
345
-        $this->_transient_garbage_collection();
346
-
347
-        $this->_template_args['values'] = $this->_yes_no_values;
348
-
349
-        $this->_template_args['reg_page_id']  = $this->core_config->reg_page_id ?? null;
350
-        $this->_template_args['reg_page_obj'] = isset($this->core_config->reg_page_id)
351
-            ? get_post($this->core_config->reg_page_id)
352
-            : false;
353
-
354
-        $this->_template_args['txn_page_id']  = $this->core_config->txn_page_id ?? null;
355
-        $this->_template_args['txn_page_obj'] = isset($this->core_config->txn_page_id)
356
-            ? get_post($this->core_config->txn_page_id)
357
-            : false;
358
-
359
-        $this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
360
-        $this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
361
-            ? get_post($this->core_config->thank_you_page_id)
362
-            : false;
363
-
364
-        $this->_template_args['cancel_page_id']  = $this->core_config->cancel_page_id ?? null;
365
-        $this->_template_args['cancel_page_obj'] = isset($this->core_config->cancel_page_id)
366
-            ? get_post($this->core_config->cancel_page_id)
367
-            : false;
368
-
369
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
370
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
371
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
372
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
373
-            $this->_template_args,
374
-            true
375
-        );
376
-        $this->display_admin_page_with_sidebar();
377
-    }
378
-
379
-
380
-    /**
381
-     * Handler for updating espresso page settings.
382
-     *
383
-     * @throws EE_Error
384
-     */
385
-    protected function _update_espresso_page_settings()
386
-    {
387
-        // capture incoming request data && set page IDs
388
-        $this->core_config->reg_page_id       = $this->request->getRequestParam(
389
-            'reg_page_id',
390
-            $this->core_config->reg_page_id,
391
-            DataType::INT
392
-        );
393
-        $this->core_config->txn_page_id       = $this->request->getRequestParam(
394
-            'txn_page_id',
395
-            $this->core_config->txn_page_id,
396
-            DataType::INT
397
-        );
398
-        $this->core_config->thank_you_page_id = $this->request->getRequestParam(
399
-            'thank_you_page_id',
400
-            $this->core_config->thank_you_page_id,
401
-            DataType::INT
402
-        );
403
-        $this->core_config->cancel_page_id    = $this->request->getRequestParam(
404
-            'cancel_page_id',
405
-            $this->core_config->cancel_page_id,
406
-            DataType::INT
407
-        );
408
-
409
-        $this->core_config = apply_filters(
410
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
411
-            $this->core_config,
412
-            $this->request->requestParams()
413
-        );
414
-
415
-        $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
416
-        $this->_redirect_after_action(
417
-            $this->_update_espresso_configuration(
418
-                $what,
419
-                $this->core_config,
420
-                __FILE__,
421
-                __FUNCTION__,
422
-                __LINE__
423
-            ),
424
-            $what,
425
-            '',
426
-            [
427
-                'action' => 'critical_pages',
428
-            ],
429
-            true
430
-        );
431
-    }
432
-
433
-
434
-    /*************        Your Organization        *************/
435
-
436
-
437
-    /**
438
-     * @throws DomainException
439
-     * @throws EE_Error
440
-     * @throws InvalidArgumentException
441
-     * @throws InvalidDataTypeException
442
-     * @throws InvalidInterfaceException
443
-     */
444
-    protected function _your_organization_settings()
445
-    {
446
-        $this->_template_args['admin_page_content'] = '';
447
-        try {
448
-            /** @var OrganizationSettings $organization_settings_form */
449
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
450
-
451
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
452
-                $organization_settings_form->display(),
453
-                '',
454
-                'padding'
455
-            );
456
-        } catch (Exception $e) {
457
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
458
-        }
459
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
460
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
461
-        $this->display_admin_page_with_sidebar();
462
-    }
463
-
464
-
465
-    /**
466
-     * Handler for updating organization settings.
467
-     *
468
-     * @throws EE_Error
469
-     */
470
-    protected function _update_your_organization_settings()
471
-    {
472
-        try {
473
-            /** @var OrganizationSettings $organization_settings_form */
474
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
475
-
476
-            $success = $organization_settings_form->process($this->request->requestParams());
477
-
478
-            EE_Registry::instance()->CFG = apply_filters(
479
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
480
-                EE_Registry::instance()->CFG
481
-            );
482
-        } catch (Exception $e) {
483
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
484
-            $success = false;
485
-        }
486
-
487
-        if ($success) {
488
-            $success = $this->_update_espresso_configuration(
489
-                esc_html__('Your Organization Settings', 'event_espresso'),
490
-                EE_Registry::instance()->CFG,
491
-                __FILE__,
492
-                __FUNCTION__,
493
-                __LINE__
494
-            );
495
-        }
496
-
497
-        $this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
498
-    }
499
-
500
-
501
-
502
-    /*************        Admin Options        *************/
503
-
504
-
505
-    /**
506
-     * _admin_option_settings
507
-     *
508
-     * @throws EE_Error
509
-     * @throws LogicException
510
-     */
511
-    protected function _admin_option_settings()
512
-    {
513
-        $this->_template_args['admin_page_content'] = '';
514
-        try {
515
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
516
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
517
-            $this->_template_args['values'] = $this->_yes_no_values;
518
-            // also need to account for the do_action that was in the old template
519
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
520
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
521
-        } catch (Exception $e) {
522
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
523
-        }
524
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
525
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
526
-        $this->display_admin_page_with_sidebar();
527
-    }
528
-
529
-
530
-    /**
531
-     * _update_admin_option_settings
532
-     *
533
-     * @throws EE_Error
534
-     * @throws InvalidDataTypeException
535
-     * @throws InvalidFormSubmissionException
536
-     * @throws InvalidArgumentException
537
-     * @throws LogicException
538
-     */
539
-    protected function _update_admin_option_settings()
540
-    {
541
-        try {
542
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
543
-            $admin_options_settings_form->process(
544
-                $this->request->getRequestParam(
545
-                    $admin_options_settings_form->slug(),
546
-                    [],
547
-                    DataType::OBJECT // need to change this to ARRAY after min PHP version gets bumped to 7+
548
-                )
549
-            );
550
-            EE_Registry::instance()->CFG->admin = apply_filters(
551
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
552
-                EE_Registry::instance()->CFG->admin
553
-            );
554
-        } catch (Exception $e) {
555
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
556
-        }
557
-        $this->_redirect_after_action(
558
-            apply_filters(
559
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
560
-                $this->_update_espresso_configuration(
561
-                    esc_html__('Admin Options', 'event_espresso'),
562
-                    EE_Registry::instance()->CFG->admin,
563
-                    __FILE__,
564
-                    __FUNCTION__,
565
-                    __LINE__
566
-                )
567
-            ),
568
-            esc_html__('Admin Options', 'event_espresso'),
569
-            'updated',
570
-            ['action' => 'admin_option_settings']
571
-        );
572
-    }
573
-
574
-
575
-    /*************        Countries        *************/
576
-
577
-
578
-    /**
579
-     * @param string|null $default
580
-     * @return string
581
-     */
582
-    protected function getCountryISO(?string $default = null): string
583
-    {
584
-        $default = $default ?? $this->getCountryIsoForSite();
585
-        $CNT_ISO = $this->request->getRequestParam('country', $default);
586
-        $CNT_ISO = $this->request->getRequestParam('CNT_ISO', $CNT_ISO);
587
-        return strtoupper($CNT_ISO);
588
-    }
589
-
590
-
591
-    /**
592
-     * @return string
593
-     */
594
-    protected function getCountryIsoForSite(): string
595
-    {
596
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
597
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
598
-            : 'US';
599
-    }
600
-
601
-
602
-    /**
603
-     * @param string          $CNT_ISO
604
-     * @param EE_Country|null $country
605
-     * @return EE_Base_Class|EE_Country
606
-     * @throws EE_Error
607
-     * @throws InvalidArgumentException
608
-     * @throws InvalidDataTypeException
609
-     * @throws InvalidInterfaceException
610
-     * @throws ReflectionException
611
-     */
612
-    protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
613
-    {
614
-        /** @var EE_Country $country */
615
-        return $country instanceof EE_Country && $country->ID() === $CNT_ISO
616
-            ? $country
617
-            : EEM_Country::instance()->get_one_by_ID($CNT_ISO);
618
-    }
619
-
620
-
621
-    /**
622
-     * Output Country Settings view.
623
-     *
624
-     * @throws DomainException
625
-     * @throws EE_Error
626
-     * @throws InvalidArgumentException
627
-     * @throws InvalidDataTypeException
628
-     * @throws InvalidInterfaceException
629
-     * @throws ReflectionException
630
-     */
631
-    protected function _country_settings()
632
-    {
633
-        $CNT_ISO = $this->getCountryISO();
634
-
635
-        $this->_template_args['values']    = $this->_yes_no_values;
636
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
637
-            EE_Question::new_instance(
638
-                [
639
-                    'QST_ID'           => 0,
640
-                    'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
641
-                    'QST_system'       => 'admin-country',
642
-                ]
643
-            ),
644
-            EE_Answer::new_instance(
645
-                [
646
-                    'ANS_ID'    => 0,
647
-                    'ANS_value' => $CNT_ISO,
648
-                ]
649
-            ),
650
-            [
651
-                'input_id'       => 'country',
652
-                'input_name'     => 'country',
653
-                'input_prefix'   => '',
654
-                'append_qstn_id' => false,
655
-            ]
656
-        );
657
-
658
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
659
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
660
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
661
-        $this->_template_args['country_details_settings'] = $this->display_country_settings(
662
-            $country->ID(),
663
-            $country
664
-        );
665
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
666
-            $country->ID(),
667
-            $country
668
-        );
669
-        $this->_template_args['CNT_name_for_site']        = $country->name();
670
-
671
-        $this->_set_add_edit_form_tags('update_country_settings');
672
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
673
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
674
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
675
-            $this->_template_args,
676
-            true
677
-        );
678
-        $this->display_admin_page_with_no_sidebar();
679
-    }
680
-
681
-
682
-    /**
683
-     * @param string          $CNT_ISO
684
-     * @param EE_Country|null $country
685
-     * @return string
686
-     * @throws DomainException
687
-     * @throws EE_Error
688
-     * @throws InvalidArgumentException
689
-     * @throws InvalidDataTypeException
690
-     * @throws InvalidInterfaceException
691
-     * @throws ReflectionException
692
-     */
693
-    public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
694
-    {
695
-        $CNT_ISO          = $this->getCountryISO($CNT_ISO);
696
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
697
-
698
-        if (! $CNT_ISO) {
699
-            return '';
700
-        }
701
-
702
-        // for ajax
703
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
704
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
705
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
706
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
707
-        $country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
708
-        $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
709
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
710
-
711
-        $country_input_types            = [
712
-            'CNT_active'      => [
713
-                'type'             => 'RADIO_BTN',
714
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
715
-                'class'            => '',
716
-                'options'          => $this->_yes_no_values,
717
-                'use_desc_4_label' => true,
718
-            ],
719
-            'CNT_ISO'         => [
720
-                'type'       => 'TEXT',
721
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
722
-                'class'      => 'small-text',
723
-            ],
724
-            'CNT_ISO3'        => [
725
-                'type'       => 'TEXT',
726
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
727
-                'class'      => 'small-text',
728
-            ],
729
-            // 'RGN_ID'          => [
730
-            //     'type'       => 'TEXT',
731
-            //     'input_name' => 'cntry[' . $CNT_ISO . ']',
732
-            //     'class'      => 'ee-input-size--small',
733
-            // ],
734
-            'CNT_name'        => [
735
-                'type'       => 'TEXT',
736
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
737
-                'class'      => 'regular-text',
738
-            ],
739
-            'CNT_cur_code'    => [
740
-                'type'       => 'TEXT',
741
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
742
-                'class'      => 'small-text',
743
-                'disabled'   => $CNT_cur_disabled,
744
-            ],
745
-            'CNT_cur_single'  => [
746
-                'type'       => 'TEXT',
747
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
748
-                'class'      => 'medium-text',
749
-                'disabled'   => $CNT_cur_disabled,
750
-            ],
751
-            'CNT_cur_plural'  => [
752
-                'type'       => 'TEXT',
753
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
754
-                'class'      => 'medium-text',
755
-                'disabled'   => $CNT_cur_disabled,
756
-            ],
757
-            'CNT_cur_sign'    => [
758
-                'type'         => 'TEXT',
759
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
760
-                'class'        => 'small-text',
761
-                'htmlentities' => false,
762
-                'disabled'     => $CNT_cur_disabled,
763
-            ],
764
-            'CNT_cur_sign_b4' => [
765
-                'type'             => 'RADIO_BTN',
766
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
767
-                'class'            => '',
768
-                'options'          => $this->_yes_no_values,
769
-                'use_desc_4_label' => true,
770
-                'disabled'         => $CNT_cur_disabled,
771
-            ],
772
-            'CNT_cur_dec_plc' => [
773
-                'type'       => 'RADIO_BTN',
774
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
775
-                'class'      => '',
776
-                'options'    => [
777
-                    ['id' => 0, 'text' => ''],
778
-                    ['id' => 1, 'text' => ''],
779
-                    ['id' => 2, 'text' => ''],
780
-                    ['id' => 3, 'text' => ''],
781
-                ],
782
-                'disabled'   => $CNT_cur_disabled,
783
-            ],
784
-            'CNT_cur_dec_mrk' => [
785
-                'type'             => 'RADIO_BTN',
786
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
787
-                'class'            => '',
788
-                'options'          => [
789
-                    [
790
-                        'id'   => ',',
791
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
792
-                    ],
793
-                    ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
794
-                ],
795
-                'use_desc_4_label' => true,
796
-                'disabled'         => $CNT_cur_disabled,
797
-            ],
798
-            'CNT_cur_thsnds'  => [
799
-                'type'             => 'RADIO_BTN',
800
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
801
-                'class'            => '',
802
-                'options'          => [
803
-                    [
804
-                        'id'   => ',',
805
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
806
-                    ],
807
-                    [
808
-                        'id'   => '.',
809
-                        'text' => esc_html__('. (decimal)', 'event_espresso'),
810
-                    ],
811
-                    [
812
-                        'id'   => '&nbsp;',
813
-                        'text' => esc_html__('(space)', 'event_espresso'),
814
-                    ],
815
-                ],
816
-                'use_desc_4_label' => true,
817
-                'disabled'         => $CNT_cur_disabled,
818
-            ],
819
-            'CNT_tel_code'    => [
820
-                'type'       => 'TEXT',
821
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
822
-                'class'      => 'small-text',
823
-            ],
824
-            'CNT_is_EU'       => [
825
-                'type'             => 'RADIO_BTN',
826
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
827
-                'class'            => '',
828
-                'options'          => $this->_yes_no_values,
829
-                'use_desc_4_label' => true,
830
-            ],
831
-        ];
832
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
833
-            $country,
834
-            $country_input_types
835
-        );
836
-        $country_details_settings       = EEH_Template::display_template(
837
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
838
-            $this->_template_args,
839
-            true
840
-        );
841
-
842
-        if (defined('DOING_AJAX')) {
843
-            $notices = EE_Error::get_notices(false, false, false);
844
-            echo wp_json_encode(
845
-                [
846
-                    'return_data' => $country_details_settings,
847
-                    'success'     => $notices['success'],
848
-                    'errors'      => $notices['errors'],
849
-                ]
850
-            );
851
-            die();
852
-        }
853
-        return $country_details_settings;
854
-    }
855
-
856
-
857
-    /**
858
-     * @param string          $CNT_ISO
859
-     * @param EE_Country|null $country
860
-     * @return string
861
-     * @throws DomainException
862
-     * @throws EE_Error
863
-     * @throws InvalidArgumentException
864
-     * @throws InvalidDataTypeException
865
-     * @throws InvalidInterfaceException
866
-     * @throws ReflectionException
867
-     */
868
-    public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
869
-    {
870
-        $CNT_ISO = $this->getCountryISO($CNT_ISO);
871
-        if (! $CNT_ISO) {
872
-            return '';
873
-        }
874
-        // for ajax
875
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
876
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
877
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
878
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
879
-        $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
880
-        if (empty($states)) {
881
-            /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
882
-            $countrySubRegionDao = $this->loader->getShared(
883
-                'EventEspresso\core\services\address\CountrySubRegionDao'
884
-            );
885
-            if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
886
-                $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
887
-                if ($countrySubRegionDao->saveCountrySubRegions($country)) {
888
-                    $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
889
-                }
890
-            }
891
-        }
892
-        if (is_array($states)) {
893
-            foreach ($states as $STA_ID => $state) {
894
-                if ($state instanceof EE_State) {
895
-                    $inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
896
-                        $state,
897
-                        [
898
-                            'STA_abbrev' => [
899
-                                'type'             => 'TEXT',
900
-                                'label'            => esc_html__('Code', 'event_espresso'),
901
-                                'input_name'       => 'states[' . $STA_ID . ']',
902
-                                'class'            => 'small-text',
903
-                                'add_mobile_label' => true,
904
-                            ],
905
-                            'STA_name'   => [
906
-                                'type'             => 'TEXT',
907
-                                'label'            => esc_html__('Name', 'event_espresso'),
908
-                                'input_name'       => 'states[' . $STA_ID . ']',
909
-                                'class'            => 'regular-text',
910
-                                'add_mobile_label' => true,
911
-                            ],
912
-                            'STA_active' => [
913
-                                'type'             => 'RADIO_BTN',
914
-                                'label'            => esc_html__(
915
-                                    'State Appears in Dropdown Select Lists',
916
-                                    'event_espresso'
917
-                                ),
918
-                                'input_name'       => 'states[' . $STA_ID . ']',
919
-                                'options'          => $this->_yes_no_values,
920
-                                'use_desc_4_label' => true,
921
-                                'add_mobile_label' => true,
922
-                            ],
923
-                        ]
924
-                    );
925
-
926
-                    $delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
927
-                        [
928
-                            'action'     => 'delete_state',
929
-                            'STA_ID'     => $STA_ID,
930
-                            'CNT_ISO'    => $CNT_ISO,
931
-                            'STA_abbrev' => $state->abbrev(),
932
-                        ],
933
-                        GEN_SET_ADMIN_URL
934
-                    );
935
-
936
-                    $this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
937
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
938
-                }
939
-            }
940
-        } else {
941
-            $this->_template_args['states'] = false;
942
-        }
943
-
944
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
945
-            ['action' => 'add_new_state'],
946
-            GEN_SET_ADMIN_URL
947
-        );
948
-
949
-        $state_details_settings = EEH_Template::display_template(
950
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
951
-            $this->_template_args,
952
-            true
953
-        );
954
-
955
-        if (defined('DOING_AJAX')) {
956
-            $notices = EE_Error::get_notices(false, false, false);
957
-            echo wp_json_encode(
958
-                [
959
-                    'return_data' => $state_details_settings,
960
-                    'success'     => $notices['success'],
961
-                    'errors'      => $notices['errors'],
962
-                ]
963
-            );
964
-            die();
965
-        }
966
-        return $state_details_settings;
967
-    }
968
-
969
-
970
-    /**
971
-     * @return void
972
-     * @throws EE_Error
973
-     * @throws InvalidArgumentException
974
-     * @throws InvalidDataTypeException
975
-     * @throws InvalidInterfaceException
976
-     * @throws ReflectionException
977
-     */
978
-    public function add_new_state()
979
-    {
980
-        $success = true;
981
-        $CNT_ISO = $this->getCountryISO('');
982
-        if (! $CNT_ISO) {
983
-            EE_Error::add_error(
984
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
985
-                __FILE__,
986
-                __FUNCTION__,
987
-                __LINE__
988
-            );
989
-            $success = false;
990
-        }
991
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
992
-        if (! $STA_abbrev) {
993
-            EE_Error::add_error(
994
-                esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
995
-                __FILE__,
996
-                __FUNCTION__,
997
-                __LINE__
998
-            );
999
-            $success = false;
1000
-        }
1001
-        $STA_name = $this->request->getRequestParam('STA_name');
1002
-        if (! $STA_name) {
1003
-            EE_Error::add_error(
1004
-                esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1005
-                __FILE__,
1006
-                __FUNCTION__,
1007
-                __LINE__
1008
-            );
1009
-            $success = false;
1010
-        }
1011
-
1012
-        if ($success) {
1013
-            $cols_n_values = [
1014
-                'CNT_ISO'    => $CNT_ISO,
1015
-                'STA_abbrev' => $STA_abbrev,
1016
-                'STA_name'   => $STA_name,
1017
-                'STA_active' => true,
1018
-            ];
1019
-            $success       = EEM_State::instance()->insert($cols_n_values);
1020
-            EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1021
-        }
1022
-
1023
-        if (defined('DOING_AJAX')) {
1024
-            $notices = EE_Error::get_notices(false, false, false);
1025
-            echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1026
-            die();
1027
-        } else {
1028
-            $this->_redirect_after_action(
1029
-                $success,
1030
-                esc_html__('State', 'event_espresso'),
1031
-                'added',
1032
-                ['action' => 'country_settings']
1033
-            );
1034
-        }
1035
-    }
1036
-
1037
-
1038
-    /**
1039
-     * @return void
1040
-     * @throws EE_Error
1041
-     * @throws InvalidArgumentException
1042
-     * @throws InvalidDataTypeException
1043
-     * @throws InvalidInterfaceException
1044
-     * @throws ReflectionException
1045
-     */
1046
-    public function delete_state()
1047
-    {
1048
-        $CNT_ISO    = $this->getCountryISO();
1049
-        $STA_ID     = $this->request->getRequestParam('STA_ID');
1050
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1051
-
1052
-        if (! $STA_ID) {
1053
-            EE_Error::add_error(
1054
-                esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1055
-                __FILE__,
1056
-                __FUNCTION__,
1057
-                __LINE__
1058
-            );
1059
-            return;
1060
-        }
1061
-
1062
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1063
-        if ($success !== false) {
1064
-            do_action(
1065
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1066
-                $CNT_ISO,
1067
-                $STA_ID,
1068
-                ['STA_abbrev' => $STA_abbrev]
1069
-            );
1070
-            EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1071
-        }
1072
-        if (defined('DOING_AJAX')) {
1073
-            $notices                = EE_Error::get_notices(false);
1074
-            $notices['return_data'] = true;
1075
-            echo wp_json_encode($notices);
1076
-            die();
1077
-        } else {
1078
-            $this->_redirect_after_action(
1079
-                $success,
1080
-                esc_html__('State', 'event_espresso'),
1081
-                'deleted',
1082
-                ['action' => 'country_settings']
1083
-            );
1084
-        }
1085
-    }
1086
-
1087
-
1088
-    /**
1089
-     *        _update_country_settings
1090
-     *
1091
-     * @return void
1092
-     * @throws EE_Error
1093
-     * @throws InvalidArgumentException
1094
-     * @throws InvalidDataTypeException
1095
-     * @throws InvalidInterfaceException
1096
-     * @throws ReflectionException
1097
-     */
1098
-    protected function _update_country_settings()
1099
-    {
1100
-        $CNT_ISO = $this->getCountryISO();
1101
-        if (! $CNT_ISO) {
1102
-            EE_Error::add_error(
1103
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1104
-                __FILE__,
1105
-                __FUNCTION__,
1106
-                __LINE__
1107
-            );
1108
-            return;
1109
-        }
1110
-
1111
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1112
-
1113
-        $cols_n_values                    = [];
1114
-        $cols_n_values['CNT_ISO3']        = strtoupper(
1115
-            $this->request->getRequestParam('cntry', $country->ISO3())
1116
-        );
1117
-        $cols_n_values['CNT_name']        = $this->request->getRequestParam(
1118
-            "cntry[$CNT_ISO][CNT_name]",
1119
-            $country->name()
1120
-        );
1121
-        $cols_n_values['CNT_cur_code']    = strtoupper(
1122
-            $this->request->getRequestParam(
1123
-                "cntry[$CNT_ISO][CNT_cur_code]",
1124
-                $country->currency_code()
1125
-            )
1126
-        );
1127
-        $cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1128
-            "cntry[$CNT_ISO][CNT_cur_single]",
1129
-            $country->currency_name_single()
1130
-        );
1131
-        $cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1132
-            "cntry[$CNT_ISO][CNT_cur_plural]",
1133
-            $country->currency_name_plural()
1134
-        );
1135
-        $cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1136
-            "cntry[$CNT_ISO][CNT_cur_sign]",
1137
-            $country->currency_sign()
1138
-        );
1139
-        $cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1140
-            "cntry[$CNT_ISO][CNT_cur_sign_b4]",
1141
-            $country->currency_sign_before(),
1142
-            DataType::BOOL
1143
-        );
1144
-        $cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1145
-            "cntry[$CNT_ISO][CNT_cur_dec_plc]",
1146
-            $country->currency_decimal_places()
1147
-        );
1148
-        $cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1149
-            "cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1150
-            $country->currency_decimal_mark()
1151
-        );
1152
-        $cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1153
-            "cntry[$CNT_ISO][CNT_cur_thsnds]",
1154
-            $country->currency_thousands_separator()
1155
-        );
1156
-        $cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1157
-            "cntry[$CNT_ISO][CNT_tel_code]",
1158
-            $country->telephoneCode()
1159
-        );
1160
-        $cols_n_values['CNT_active']      = $this->request->getRequestParam(
1161
-            "cntry[$CNT_ISO][CNT_active]",
1162
-            $country->isActive(),
1163
-            DataType::BOOL
1164
-        );
1165
-
1166
-        // allow filtering of country data
1167
-        $cols_n_values = apply_filters(
1168
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1169
-            $cols_n_values
1170
-        );
1171
-
1172
-        // where values
1173
-        $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1174
-        // run the update
1175
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1176
-
1177
-        // allow filtering of states data
1178
-        $states = apply_filters(
1179
-            'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1180
-            $this->request->getRequestParam('states', [], DataType::STRING, true)
1181
-        );
1182
-
1183
-        if (! empty($states) && $success !== false) {
1184
-            // loop thru state data ( looks like : states[75][STA_name] )
1185
-            foreach ($states as $STA_ID => $state) {
1186
-                $cols_n_values = [
1187
-                    'CNT_ISO'    => $CNT_ISO,
1188
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1189
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1190
-                    'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1191
-                ];
1192
-                // where values
1193
-                $where_cols_n_values = [['STA_ID' => $STA_ID]];
1194
-                // run the update
1195
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1196
-                if ($success !== false) {
1197
-                    do_action(
1198
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1199
-                        $CNT_ISO,
1200
-                        $STA_ID,
1201
-                        $cols_n_values
1202
-                    );
1203
-                }
1204
-            }
1205
-        }
1206
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1207
-        if (
1208
-            isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1209
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1210
-        ) {
1211
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1212
-            EE_Registry::instance()->CFG->update_espresso_config();
1213
-        }
1214
-
1215
-        if ($success !== false) {
1216
-            EE_Error::add_success(
1217
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1218
-            );
1219
-        }
1220
-        $this->_redirect_after_action(
1221
-            $success,
1222
-            '',
1223
-            '',
1224
-            ['action' => 'country_settings', 'country' => $CNT_ISO],
1225
-            true
1226
-        );
1227
-    }
1228
-
1229
-
1230
-    /**
1231
-     * form_form_field_label_wrap
1232
-     *
1233
-     * @param string $label
1234
-     * @return string
1235
-     */
1236
-    public function country_form_field_label_wrap(string $label): string
1237
-    {
1238
-        return '
23
+	/**
24
+	 * @var EE_Core_Config
25
+	 */
26
+	public $core_config;
27
+
28
+
29
+	/**
30
+	 * Initialize basic properties.
31
+	 */
32
+	protected function _init_page_props()
33
+	{
34
+		$this->page_slug        = GEN_SET_PG_SLUG;
35
+		$this->page_label       = GEN_SET_LABEL;
36
+		$this->_admin_base_url  = GEN_SET_ADMIN_URL;
37
+		$this->_admin_base_path = GEN_SET_ADMIN;
38
+	}
39
+
40
+
41
+	/**
42
+	 * Set ajax hooks
43
+	 */
44
+	protected function _ajax_hooks()
45
+	{
46
+		add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
47
+		add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
48
+		add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
49
+		add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
50
+	}
51
+
52
+
53
+	/**
54
+	 * More page properties initialization.
55
+	 */
56
+	protected function _define_page_props()
57
+	{
58
+		$this->_admin_page_title = GEN_SET_LABEL;
59
+		$this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
60
+	}
61
+
62
+
63
+	/**
64
+	 * Set page routes property.
65
+	 */
66
+	protected function _set_page_routes()
67
+	{
68
+		$this->_page_routes = [
69
+			'critical_pages'                => [
70
+				'func'       => '_espresso_page_settings',
71
+				'capability' => 'manage_options',
72
+			],
73
+			'update_espresso_page_settings' => [
74
+				'func'       => '_update_espresso_page_settings',
75
+				'capability' => 'manage_options',
76
+				'noheader'   => true,
77
+			],
78
+			'default'                       => [
79
+				'func'       => '_your_organization_settings',
80
+				'capability' => 'manage_options',
81
+			],
82
+
83
+			'update_your_organization_settings' => [
84
+				'func'       => '_update_your_organization_settings',
85
+				'capability' => 'manage_options',
86
+				'noheader'   => true,
87
+			],
88
+
89
+			'admin_option_settings' => [
90
+				'func'       => '_admin_option_settings',
91
+				'capability' => 'manage_options',
92
+			],
93
+
94
+			'update_admin_option_settings' => [
95
+				'func'       => '_update_admin_option_settings',
96
+				'capability' => 'manage_options',
97
+				'noheader'   => true,
98
+			],
99
+
100
+			'country_settings' => [
101
+				'func'       => '_country_settings',
102
+				'capability' => 'manage_options',
103
+			],
104
+
105
+			'update_country_settings' => [
106
+				'func'       => '_update_country_settings',
107
+				'capability' => 'manage_options',
108
+				'noheader'   => true,
109
+			],
110
+
111
+			'display_country_settings' => [
112
+				'func'       => 'display_country_settings',
113
+				'capability' => 'manage_options',
114
+				'noheader'   => true,
115
+			],
116
+
117
+			'add_new_state' => [
118
+				'func'       => 'add_new_state',
119
+				'capability' => 'manage_options',
120
+				'noheader'   => true,
121
+			],
122
+
123
+			'delete_state'            => [
124
+				'func'       => 'delete_state',
125
+				'capability' => 'manage_options',
126
+				'noheader'   => true,
127
+			],
128
+			'privacy_settings'        => [
129
+				'func'       => 'privacySettings',
130
+				'capability' => 'manage_options',
131
+			],
132
+			'update_privacy_settings' => [
133
+				'func'               => 'updatePrivacySettings',
134
+				'capability'         => 'manage_options',
135
+				'noheader'           => true,
136
+				'headers_sent_route' => 'privacy_settings',
137
+			],
138
+		];
139
+	}
140
+
141
+
142
+	/**
143
+	 * Set page configuration property
144
+	 */
145
+	protected function _set_page_config()
146
+	{
147
+		$this->_page_config = [
148
+			'critical_pages'        => [
149
+				'nav'           => [
150
+					'label' => esc_html__('Critical Pages', 'event_espresso'),
151
+					'order' => 50,
152
+				],
153
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
154
+				'help_tabs'     => [
155
+					'general_settings_critical_pages_help_tab' => [
156
+						'title'    => esc_html__('Critical Pages', 'event_espresso'),
157
+						'filename' => 'general_settings_critical_pages',
158
+					],
159
+				],
160
+				'require_nonce' => false,
161
+			],
162
+			'default'               => [
163
+				'nav'           => [
164
+					'label' => esc_html__('Your Organization', 'event_espresso'),
165
+					'order' => 20,
166
+				],
167
+				'help_tabs'     => [
168
+					'general_settings_your_organization_help_tab' => [
169
+						'title'    => esc_html__('Your Organization', 'event_espresso'),
170
+						'filename' => 'general_settings_your_organization',
171
+					],
172
+				],
173
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
174
+				'require_nonce' => false,
175
+			],
176
+			'admin_option_settings' => [
177
+				'nav'           => [
178
+					'label' => esc_html__('Admin Options', 'event_espresso'),
179
+					'order' => 60,
180
+				],
181
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
182
+				'help_tabs'     => [
183
+					'general_settings_admin_options_help_tab' => [
184
+						'title'    => esc_html__('Admin Options', 'event_espresso'),
185
+						'filename' => 'general_settings_admin_options',
186
+					],
187
+				],
188
+				'require_nonce' => false,
189
+			],
190
+			'country_settings'      => [
191
+				'nav'           => [
192
+					'label' => esc_html__('Countries', 'event_espresso'),
193
+					'order' => 70,
194
+				],
195
+				'help_tabs'     => [
196
+					'general_settings_countries_help_tab' => [
197
+						'title'    => esc_html__('Countries', 'event_espresso'),
198
+						'filename' => 'general_settings_countries',
199
+					],
200
+				],
201
+				'require_nonce' => false,
202
+			],
203
+			'privacy_settings'      => [
204
+				'nav'           => [
205
+					'label' => esc_html__('Privacy', 'event_espresso'),
206
+					'order' => 80,
207
+				],
208
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
209
+				'require_nonce' => false,
210
+			],
211
+		];
212
+	}
213
+
214
+
215
+	protected function _add_screen_options()
216
+	{
217
+	}
218
+
219
+
220
+	protected function _add_feature_pointers()
221
+	{
222
+	}
223
+
224
+
225
+	/**
226
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
227
+	 */
228
+	public function load_scripts_styles()
229
+	{
230
+		// styles
231
+		wp_enqueue_style('espresso-ui-theme');
232
+		// scripts
233
+		wp_enqueue_script('ee_admin_js');
234
+	}
235
+
236
+
237
+	/**
238
+	 * Execute logic running on `admin_init`
239
+	 */
240
+	public function admin_init()
241
+	{
242
+		$this->core_config = EE_Registry::instance()->CFG->core;
243
+
244
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
245
+			esc_html__(
246
+				'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
247
+				'event_espresso'
248
+			)
249
+		);
250
+		EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
251
+			esc_html__(
252
+				'An error occurred! Please refresh the page and try again.',
253
+				'event_espresso'
254
+			)
255
+		);
256
+		EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
257
+			esc_html__(
258
+				'Are you sure you want to delete this State / Province?',
259
+				'event_espresso'
260
+			)
261
+		);
262
+		EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
263
+			'admin-ajax.php?page=espresso_general_settings',
264
+			is_ssl() ? 'https://' : 'http://'
265
+		);
266
+	}
267
+
268
+
269
+	public function admin_notices()
270
+	{
271
+	}
272
+
273
+
274
+	public function admin_footer_scripts()
275
+	{
276
+	}
277
+
278
+
279
+	/**
280
+	 * Enqueue scripts and styles for the default route.
281
+	 */
282
+	public function load_scripts_styles_default()
283
+	{
284
+		// styles
285
+		wp_enqueue_style('thickbox');
286
+		// scripts
287
+		wp_enqueue_script('media-upload');
288
+		wp_enqueue_script('thickbox');
289
+		wp_register_script(
290
+			'organization_settings',
291
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
292
+			['jquery', 'media-upload', 'thickbox'],
293
+			EVENT_ESPRESSO_VERSION,
294
+			true
295
+		);
296
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
297
+		wp_enqueue_script('organization_settings');
298
+		wp_enqueue_style('organization-css');
299
+		$confirm_image_delete = [
300
+			'text' => wp_strip_all_tags(
301
+				esc_html__(
302
+					'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
303
+					'event_espresso'
304
+				)
305
+			),
306
+		];
307
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
308
+	}
309
+
310
+
311
+	/**
312
+	 * Enqueue scripts and styles for the country settings route.
313
+	 */
314
+	public function load_scripts_styles_country_settings()
315
+	{
316
+		// scripts
317
+		wp_register_script(
318
+			'gen_settings_countries',
319
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
320
+			['ee_admin_js'],
321
+			EVENT_ESPRESSO_VERSION,
322
+			true
323
+		);
324
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
325
+		wp_enqueue_script('gen_settings_countries');
326
+		wp_enqueue_style('organization-css');
327
+	}
328
+
329
+
330
+	/*************        Espresso Pages        *************/
331
+	/**
332
+	 * _espresso_page_settings
333
+	 *
334
+	 * @throws EE_Error
335
+	 * @throws DomainException
336
+	 * @throws DomainException
337
+	 * @throws InvalidDataTypeException
338
+	 * @throws InvalidArgumentException
339
+	 */
340
+	protected function _espresso_page_settings()
341
+	{
342
+		// Check to make sure all of the main pages are set up properly,
343
+		// if not create the default pages and display an admin notice
344
+		EEH_Activation::verify_default_pages_exist();
345
+		$this->_transient_garbage_collection();
346
+
347
+		$this->_template_args['values'] = $this->_yes_no_values;
348
+
349
+		$this->_template_args['reg_page_id']  = $this->core_config->reg_page_id ?? null;
350
+		$this->_template_args['reg_page_obj'] = isset($this->core_config->reg_page_id)
351
+			? get_post($this->core_config->reg_page_id)
352
+			: false;
353
+
354
+		$this->_template_args['txn_page_id']  = $this->core_config->txn_page_id ?? null;
355
+		$this->_template_args['txn_page_obj'] = isset($this->core_config->txn_page_id)
356
+			? get_post($this->core_config->txn_page_id)
357
+			: false;
358
+
359
+		$this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
360
+		$this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
361
+			? get_post($this->core_config->thank_you_page_id)
362
+			: false;
363
+
364
+		$this->_template_args['cancel_page_id']  = $this->core_config->cancel_page_id ?? null;
365
+		$this->_template_args['cancel_page_obj'] = isset($this->core_config->cancel_page_id)
366
+			? get_post($this->core_config->cancel_page_id)
367
+			: false;
368
+
369
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
370
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
371
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
372
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
373
+			$this->_template_args,
374
+			true
375
+		);
376
+		$this->display_admin_page_with_sidebar();
377
+	}
378
+
379
+
380
+	/**
381
+	 * Handler for updating espresso page settings.
382
+	 *
383
+	 * @throws EE_Error
384
+	 */
385
+	protected function _update_espresso_page_settings()
386
+	{
387
+		// capture incoming request data && set page IDs
388
+		$this->core_config->reg_page_id       = $this->request->getRequestParam(
389
+			'reg_page_id',
390
+			$this->core_config->reg_page_id,
391
+			DataType::INT
392
+		);
393
+		$this->core_config->txn_page_id       = $this->request->getRequestParam(
394
+			'txn_page_id',
395
+			$this->core_config->txn_page_id,
396
+			DataType::INT
397
+		);
398
+		$this->core_config->thank_you_page_id = $this->request->getRequestParam(
399
+			'thank_you_page_id',
400
+			$this->core_config->thank_you_page_id,
401
+			DataType::INT
402
+		);
403
+		$this->core_config->cancel_page_id    = $this->request->getRequestParam(
404
+			'cancel_page_id',
405
+			$this->core_config->cancel_page_id,
406
+			DataType::INT
407
+		);
408
+
409
+		$this->core_config = apply_filters(
410
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
411
+			$this->core_config,
412
+			$this->request->requestParams()
413
+		);
414
+
415
+		$what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
416
+		$this->_redirect_after_action(
417
+			$this->_update_espresso_configuration(
418
+				$what,
419
+				$this->core_config,
420
+				__FILE__,
421
+				__FUNCTION__,
422
+				__LINE__
423
+			),
424
+			$what,
425
+			'',
426
+			[
427
+				'action' => 'critical_pages',
428
+			],
429
+			true
430
+		);
431
+	}
432
+
433
+
434
+	/*************        Your Organization        *************/
435
+
436
+
437
+	/**
438
+	 * @throws DomainException
439
+	 * @throws EE_Error
440
+	 * @throws InvalidArgumentException
441
+	 * @throws InvalidDataTypeException
442
+	 * @throws InvalidInterfaceException
443
+	 */
444
+	protected function _your_organization_settings()
445
+	{
446
+		$this->_template_args['admin_page_content'] = '';
447
+		try {
448
+			/** @var OrganizationSettings $organization_settings_form */
449
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
450
+
451
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
452
+				$organization_settings_form->display(),
453
+				'',
454
+				'padding'
455
+			);
456
+		} catch (Exception $e) {
457
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
458
+		}
459
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
460
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
461
+		$this->display_admin_page_with_sidebar();
462
+	}
463
+
464
+
465
+	/**
466
+	 * Handler for updating organization settings.
467
+	 *
468
+	 * @throws EE_Error
469
+	 */
470
+	protected function _update_your_organization_settings()
471
+	{
472
+		try {
473
+			/** @var OrganizationSettings $organization_settings_form */
474
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
475
+
476
+			$success = $organization_settings_form->process($this->request->requestParams());
477
+
478
+			EE_Registry::instance()->CFG = apply_filters(
479
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
480
+				EE_Registry::instance()->CFG
481
+			);
482
+		} catch (Exception $e) {
483
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
484
+			$success = false;
485
+		}
486
+
487
+		if ($success) {
488
+			$success = $this->_update_espresso_configuration(
489
+				esc_html__('Your Organization Settings', 'event_espresso'),
490
+				EE_Registry::instance()->CFG,
491
+				__FILE__,
492
+				__FUNCTION__,
493
+				__LINE__
494
+			);
495
+		}
496
+
497
+		$this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
498
+	}
499
+
500
+
501
+
502
+	/*************        Admin Options        *************/
503
+
504
+
505
+	/**
506
+	 * _admin_option_settings
507
+	 *
508
+	 * @throws EE_Error
509
+	 * @throws LogicException
510
+	 */
511
+	protected function _admin_option_settings()
512
+	{
513
+		$this->_template_args['admin_page_content'] = '';
514
+		try {
515
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
516
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
517
+			$this->_template_args['values'] = $this->_yes_no_values;
518
+			// also need to account for the do_action that was in the old template
519
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
520
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
521
+		} catch (Exception $e) {
522
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
523
+		}
524
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
525
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
526
+		$this->display_admin_page_with_sidebar();
527
+	}
528
+
529
+
530
+	/**
531
+	 * _update_admin_option_settings
532
+	 *
533
+	 * @throws EE_Error
534
+	 * @throws InvalidDataTypeException
535
+	 * @throws InvalidFormSubmissionException
536
+	 * @throws InvalidArgumentException
537
+	 * @throws LogicException
538
+	 */
539
+	protected function _update_admin_option_settings()
540
+	{
541
+		try {
542
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
543
+			$admin_options_settings_form->process(
544
+				$this->request->getRequestParam(
545
+					$admin_options_settings_form->slug(),
546
+					[],
547
+					DataType::OBJECT // need to change this to ARRAY after min PHP version gets bumped to 7+
548
+				)
549
+			);
550
+			EE_Registry::instance()->CFG->admin = apply_filters(
551
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
552
+				EE_Registry::instance()->CFG->admin
553
+			);
554
+		} catch (Exception $e) {
555
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
556
+		}
557
+		$this->_redirect_after_action(
558
+			apply_filters(
559
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
560
+				$this->_update_espresso_configuration(
561
+					esc_html__('Admin Options', 'event_espresso'),
562
+					EE_Registry::instance()->CFG->admin,
563
+					__FILE__,
564
+					__FUNCTION__,
565
+					__LINE__
566
+				)
567
+			),
568
+			esc_html__('Admin Options', 'event_espresso'),
569
+			'updated',
570
+			['action' => 'admin_option_settings']
571
+		);
572
+	}
573
+
574
+
575
+	/*************        Countries        *************/
576
+
577
+
578
+	/**
579
+	 * @param string|null $default
580
+	 * @return string
581
+	 */
582
+	protected function getCountryISO(?string $default = null): string
583
+	{
584
+		$default = $default ?? $this->getCountryIsoForSite();
585
+		$CNT_ISO = $this->request->getRequestParam('country', $default);
586
+		$CNT_ISO = $this->request->getRequestParam('CNT_ISO', $CNT_ISO);
587
+		return strtoupper($CNT_ISO);
588
+	}
589
+
590
+
591
+	/**
592
+	 * @return string
593
+	 */
594
+	protected function getCountryIsoForSite(): string
595
+	{
596
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
597
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
598
+			: 'US';
599
+	}
600
+
601
+
602
+	/**
603
+	 * @param string          $CNT_ISO
604
+	 * @param EE_Country|null $country
605
+	 * @return EE_Base_Class|EE_Country
606
+	 * @throws EE_Error
607
+	 * @throws InvalidArgumentException
608
+	 * @throws InvalidDataTypeException
609
+	 * @throws InvalidInterfaceException
610
+	 * @throws ReflectionException
611
+	 */
612
+	protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
613
+	{
614
+		/** @var EE_Country $country */
615
+		return $country instanceof EE_Country && $country->ID() === $CNT_ISO
616
+			? $country
617
+			: EEM_Country::instance()->get_one_by_ID($CNT_ISO);
618
+	}
619
+
620
+
621
+	/**
622
+	 * Output Country Settings view.
623
+	 *
624
+	 * @throws DomainException
625
+	 * @throws EE_Error
626
+	 * @throws InvalidArgumentException
627
+	 * @throws InvalidDataTypeException
628
+	 * @throws InvalidInterfaceException
629
+	 * @throws ReflectionException
630
+	 */
631
+	protected function _country_settings()
632
+	{
633
+		$CNT_ISO = $this->getCountryISO();
634
+
635
+		$this->_template_args['values']    = $this->_yes_no_values;
636
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
637
+			EE_Question::new_instance(
638
+				[
639
+					'QST_ID'           => 0,
640
+					'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
641
+					'QST_system'       => 'admin-country',
642
+				]
643
+			),
644
+			EE_Answer::new_instance(
645
+				[
646
+					'ANS_ID'    => 0,
647
+					'ANS_value' => $CNT_ISO,
648
+				]
649
+			),
650
+			[
651
+				'input_id'       => 'country',
652
+				'input_name'     => 'country',
653
+				'input_prefix'   => '',
654
+				'append_qstn_id' => false,
655
+			]
656
+		);
657
+
658
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
659
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
660
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
661
+		$this->_template_args['country_details_settings'] = $this->display_country_settings(
662
+			$country->ID(),
663
+			$country
664
+		);
665
+		$this->_template_args['country_states_settings']  = $this->display_country_states(
666
+			$country->ID(),
667
+			$country
668
+		);
669
+		$this->_template_args['CNT_name_for_site']        = $country->name();
670
+
671
+		$this->_set_add_edit_form_tags('update_country_settings');
672
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
673
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
674
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
675
+			$this->_template_args,
676
+			true
677
+		);
678
+		$this->display_admin_page_with_no_sidebar();
679
+	}
680
+
681
+
682
+	/**
683
+	 * @param string          $CNT_ISO
684
+	 * @param EE_Country|null $country
685
+	 * @return string
686
+	 * @throws DomainException
687
+	 * @throws EE_Error
688
+	 * @throws InvalidArgumentException
689
+	 * @throws InvalidDataTypeException
690
+	 * @throws InvalidInterfaceException
691
+	 * @throws ReflectionException
692
+	 */
693
+	public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
694
+	{
695
+		$CNT_ISO          = $this->getCountryISO($CNT_ISO);
696
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
697
+
698
+		if (! $CNT_ISO) {
699
+			return '';
700
+		}
701
+
702
+		// for ajax
703
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
704
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
705
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
706
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
707
+		$country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
708
+		$CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
709
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
710
+
711
+		$country_input_types            = [
712
+			'CNT_active'      => [
713
+				'type'             => 'RADIO_BTN',
714
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
715
+				'class'            => '',
716
+				'options'          => $this->_yes_no_values,
717
+				'use_desc_4_label' => true,
718
+			],
719
+			'CNT_ISO'         => [
720
+				'type'       => 'TEXT',
721
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
722
+				'class'      => 'small-text',
723
+			],
724
+			'CNT_ISO3'        => [
725
+				'type'       => 'TEXT',
726
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
727
+				'class'      => 'small-text',
728
+			],
729
+			// 'RGN_ID'          => [
730
+			//     'type'       => 'TEXT',
731
+			//     'input_name' => 'cntry[' . $CNT_ISO . ']',
732
+			//     'class'      => 'ee-input-size--small',
733
+			// ],
734
+			'CNT_name'        => [
735
+				'type'       => 'TEXT',
736
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
737
+				'class'      => 'regular-text',
738
+			],
739
+			'CNT_cur_code'    => [
740
+				'type'       => 'TEXT',
741
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
742
+				'class'      => 'small-text',
743
+				'disabled'   => $CNT_cur_disabled,
744
+			],
745
+			'CNT_cur_single'  => [
746
+				'type'       => 'TEXT',
747
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
748
+				'class'      => 'medium-text',
749
+				'disabled'   => $CNT_cur_disabled,
750
+			],
751
+			'CNT_cur_plural'  => [
752
+				'type'       => 'TEXT',
753
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
754
+				'class'      => 'medium-text',
755
+				'disabled'   => $CNT_cur_disabled,
756
+			],
757
+			'CNT_cur_sign'    => [
758
+				'type'         => 'TEXT',
759
+				'input_name'   => 'cntry[' . $CNT_ISO . ']',
760
+				'class'        => 'small-text',
761
+				'htmlentities' => false,
762
+				'disabled'     => $CNT_cur_disabled,
763
+			],
764
+			'CNT_cur_sign_b4' => [
765
+				'type'             => 'RADIO_BTN',
766
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
767
+				'class'            => '',
768
+				'options'          => $this->_yes_no_values,
769
+				'use_desc_4_label' => true,
770
+				'disabled'         => $CNT_cur_disabled,
771
+			],
772
+			'CNT_cur_dec_plc' => [
773
+				'type'       => 'RADIO_BTN',
774
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
775
+				'class'      => '',
776
+				'options'    => [
777
+					['id' => 0, 'text' => ''],
778
+					['id' => 1, 'text' => ''],
779
+					['id' => 2, 'text' => ''],
780
+					['id' => 3, 'text' => ''],
781
+				],
782
+				'disabled'   => $CNT_cur_disabled,
783
+			],
784
+			'CNT_cur_dec_mrk' => [
785
+				'type'             => 'RADIO_BTN',
786
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
787
+				'class'            => '',
788
+				'options'          => [
789
+					[
790
+						'id'   => ',',
791
+						'text' => esc_html__(', (comma)', 'event_espresso'),
792
+					],
793
+					['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
794
+				],
795
+				'use_desc_4_label' => true,
796
+				'disabled'         => $CNT_cur_disabled,
797
+			],
798
+			'CNT_cur_thsnds'  => [
799
+				'type'             => 'RADIO_BTN',
800
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
801
+				'class'            => '',
802
+				'options'          => [
803
+					[
804
+						'id'   => ',',
805
+						'text' => esc_html__(', (comma)', 'event_espresso'),
806
+					],
807
+					[
808
+						'id'   => '.',
809
+						'text' => esc_html__('. (decimal)', 'event_espresso'),
810
+					],
811
+					[
812
+						'id'   => '&nbsp;',
813
+						'text' => esc_html__('(space)', 'event_espresso'),
814
+					],
815
+				],
816
+				'use_desc_4_label' => true,
817
+				'disabled'         => $CNT_cur_disabled,
818
+			],
819
+			'CNT_tel_code'    => [
820
+				'type'       => 'TEXT',
821
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
822
+				'class'      => 'small-text',
823
+			],
824
+			'CNT_is_EU'       => [
825
+				'type'             => 'RADIO_BTN',
826
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
827
+				'class'            => '',
828
+				'options'          => $this->_yes_no_values,
829
+				'use_desc_4_label' => true,
830
+			],
831
+		];
832
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
833
+			$country,
834
+			$country_input_types
835
+		);
836
+		$country_details_settings       = EEH_Template::display_template(
837
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
838
+			$this->_template_args,
839
+			true
840
+		);
841
+
842
+		if (defined('DOING_AJAX')) {
843
+			$notices = EE_Error::get_notices(false, false, false);
844
+			echo wp_json_encode(
845
+				[
846
+					'return_data' => $country_details_settings,
847
+					'success'     => $notices['success'],
848
+					'errors'      => $notices['errors'],
849
+				]
850
+			);
851
+			die();
852
+		}
853
+		return $country_details_settings;
854
+	}
855
+
856
+
857
+	/**
858
+	 * @param string          $CNT_ISO
859
+	 * @param EE_Country|null $country
860
+	 * @return string
861
+	 * @throws DomainException
862
+	 * @throws EE_Error
863
+	 * @throws InvalidArgumentException
864
+	 * @throws InvalidDataTypeException
865
+	 * @throws InvalidInterfaceException
866
+	 * @throws ReflectionException
867
+	 */
868
+	public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
869
+	{
870
+		$CNT_ISO = $this->getCountryISO($CNT_ISO);
871
+		if (! $CNT_ISO) {
872
+			return '';
873
+		}
874
+		// for ajax
875
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
876
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
877
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
878
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
879
+		$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
880
+		if (empty($states)) {
881
+			/** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
882
+			$countrySubRegionDao = $this->loader->getShared(
883
+				'EventEspresso\core\services\address\CountrySubRegionDao'
884
+			);
885
+			if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
886
+				$country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
887
+				if ($countrySubRegionDao->saveCountrySubRegions($country)) {
888
+					$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
889
+				}
890
+			}
891
+		}
892
+		if (is_array($states)) {
893
+			foreach ($states as $STA_ID => $state) {
894
+				if ($state instanceof EE_State) {
895
+					$inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
896
+						$state,
897
+						[
898
+							'STA_abbrev' => [
899
+								'type'             => 'TEXT',
900
+								'label'            => esc_html__('Code', 'event_espresso'),
901
+								'input_name'       => 'states[' . $STA_ID . ']',
902
+								'class'            => 'small-text',
903
+								'add_mobile_label' => true,
904
+							],
905
+							'STA_name'   => [
906
+								'type'             => 'TEXT',
907
+								'label'            => esc_html__('Name', 'event_espresso'),
908
+								'input_name'       => 'states[' . $STA_ID . ']',
909
+								'class'            => 'regular-text',
910
+								'add_mobile_label' => true,
911
+							],
912
+							'STA_active' => [
913
+								'type'             => 'RADIO_BTN',
914
+								'label'            => esc_html__(
915
+									'State Appears in Dropdown Select Lists',
916
+									'event_espresso'
917
+								),
918
+								'input_name'       => 'states[' . $STA_ID . ']',
919
+								'options'          => $this->_yes_no_values,
920
+								'use_desc_4_label' => true,
921
+								'add_mobile_label' => true,
922
+							],
923
+						]
924
+					);
925
+
926
+					$delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
927
+						[
928
+							'action'     => 'delete_state',
929
+							'STA_ID'     => $STA_ID,
930
+							'CNT_ISO'    => $CNT_ISO,
931
+							'STA_abbrev' => $state->abbrev(),
932
+						],
933
+						GEN_SET_ADMIN_URL
934
+					);
935
+
936
+					$this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
937
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
938
+				}
939
+			}
940
+		} else {
941
+			$this->_template_args['states'] = false;
942
+		}
943
+
944
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
945
+			['action' => 'add_new_state'],
946
+			GEN_SET_ADMIN_URL
947
+		);
948
+
949
+		$state_details_settings = EEH_Template::display_template(
950
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
951
+			$this->_template_args,
952
+			true
953
+		);
954
+
955
+		if (defined('DOING_AJAX')) {
956
+			$notices = EE_Error::get_notices(false, false, false);
957
+			echo wp_json_encode(
958
+				[
959
+					'return_data' => $state_details_settings,
960
+					'success'     => $notices['success'],
961
+					'errors'      => $notices['errors'],
962
+				]
963
+			);
964
+			die();
965
+		}
966
+		return $state_details_settings;
967
+	}
968
+
969
+
970
+	/**
971
+	 * @return void
972
+	 * @throws EE_Error
973
+	 * @throws InvalidArgumentException
974
+	 * @throws InvalidDataTypeException
975
+	 * @throws InvalidInterfaceException
976
+	 * @throws ReflectionException
977
+	 */
978
+	public function add_new_state()
979
+	{
980
+		$success = true;
981
+		$CNT_ISO = $this->getCountryISO('');
982
+		if (! $CNT_ISO) {
983
+			EE_Error::add_error(
984
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
985
+				__FILE__,
986
+				__FUNCTION__,
987
+				__LINE__
988
+			);
989
+			$success = false;
990
+		}
991
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
992
+		if (! $STA_abbrev) {
993
+			EE_Error::add_error(
994
+				esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
995
+				__FILE__,
996
+				__FUNCTION__,
997
+				__LINE__
998
+			);
999
+			$success = false;
1000
+		}
1001
+		$STA_name = $this->request->getRequestParam('STA_name');
1002
+		if (! $STA_name) {
1003
+			EE_Error::add_error(
1004
+				esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1005
+				__FILE__,
1006
+				__FUNCTION__,
1007
+				__LINE__
1008
+			);
1009
+			$success = false;
1010
+		}
1011
+
1012
+		if ($success) {
1013
+			$cols_n_values = [
1014
+				'CNT_ISO'    => $CNT_ISO,
1015
+				'STA_abbrev' => $STA_abbrev,
1016
+				'STA_name'   => $STA_name,
1017
+				'STA_active' => true,
1018
+			];
1019
+			$success       = EEM_State::instance()->insert($cols_n_values);
1020
+			EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1021
+		}
1022
+
1023
+		if (defined('DOING_AJAX')) {
1024
+			$notices = EE_Error::get_notices(false, false, false);
1025
+			echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1026
+			die();
1027
+		} else {
1028
+			$this->_redirect_after_action(
1029
+				$success,
1030
+				esc_html__('State', 'event_espresso'),
1031
+				'added',
1032
+				['action' => 'country_settings']
1033
+			);
1034
+		}
1035
+	}
1036
+
1037
+
1038
+	/**
1039
+	 * @return void
1040
+	 * @throws EE_Error
1041
+	 * @throws InvalidArgumentException
1042
+	 * @throws InvalidDataTypeException
1043
+	 * @throws InvalidInterfaceException
1044
+	 * @throws ReflectionException
1045
+	 */
1046
+	public function delete_state()
1047
+	{
1048
+		$CNT_ISO    = $this->getCountryISO();
1049
+		$STA_ID     = $this->request->getRequestParam('STA_ID');
1050
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1051
+
1052
+		if (! $STA_ID) {
1053
+			EE_Error::add_error(
1054
+				esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1055
+				__FILE__,
1056
+				__FUNCTION__,
1057
+				__LINE__
1058
+			);
1059
+			return;
1060
+		}
1061
+
1062
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1063
+		if ($success !== false) {
1064
+			do_action(
1065
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1066
+				$CNT_ISO,
1067
+				$STA_ID,
1068
+				['STA_abbrev' => $STA_abbrev]
1069
+			);
1070
+			EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1071
+		}
1072
+		if (defined('DOING_AJAX')) {
1073
+			$notices                = EE_Error::get_notices(false);
1074
+			$notices['return_data'] = true;
1075
+			echo wp_json_encode($notices);
1076
+			die();
1077
+		} else {
1078
+			$this->_redirect_after_action(
1079
+				$success,
1080
+				esc_html__('State', 'event_espresso'),
1081
+				'deleted',
1082
+				['action' => 'country_settings']
1083
+			);
1084
+		}
1085
+	}
1086
+
1087
+
1088
+	/**
1089
+	 *        _update_country_settings
1090
+	 *
1091
+	 * @return void
1092
+	 * @throws EE_Error
1093
+	 * @throws InvalidArgumentException
1094
+	 * @throws InvalidDataTypeException
1095
+	 * @throws InvalidInterfaceException
1096
+	 * @throws ReflectionException
1097
+	 */
1098
+	protected function _update_country_settings()
1099
+	{
1100
+		$CNT_ISO = $this->getCountryISO();
1101
+		if (! $CNT_ISO) {
1102
+			EE_Error::add_error(
1103
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1104
+				__FILE__,
1105
+				__FUNCTION__,
1106
+				__LINE__
1107
+			);
1108
+			return;
1109
+		}
1110
+
1111
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1112
+
1113
+		$cols_n_values                    = [];
1114
+		$cols_n_values['CNT_ISO3']        = strtoupper(
1115
+			$this->request->getRequestParam('cntry', $country->ISO3())
1116
+		);
1117
+		$cols_n_values['CNT_name']        = $this->request->getRequestParam(
1118
+			"cntry[$CNT_ISO][CNT_name]",
1119
+			$country->name()
1120
+		);
1121
+		$cols_n_values['CNT_cur_code']    = strtoupper(
1122
+			$this->request->getRequestParam(
1123
+				"cntry[$CNT_ISO][CNT_cur_code]",
1124
+				$country->currency_code()
1125
+			)
1126
+		);
1127
+		$cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1128
+			"cntry[$CNT_ISO][CNT_cur_single]",
1129
+			$country->currency_name_single()
1130
+		);
1131
+		$cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1132
+			"cntry[$CNT_ISO][CNT_cur_plural]",
1133
+			$country->currency_name_plural()
1134
+		);
1135
+		$cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1136
+			"cntry[$CNT_ISO][CNT_cur_sign]",
1137
+			$country->currency_sign()
1138
+		);
1139
+		$cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1140
+			"cntry[$CNT_ISO][CNT_cur_sign_b4]",
1141
+			$country->currency_sign_before(),
1142
+			DataType::BOOL
1143
+		);
1144
+		$cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1145
+			"cntry[$CNT_ISO][CNT_cur_dec_plc]",
1146
+			$country->currency_decimal_places()
1147
+		);
1148
+		$cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1149
+			"cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1150
+			$country->currency_decimal_mark()
1151
+		);
1152
+		$cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1153
+			"cntry[$CNT_ISO][CNT_cur_thsnds]",
1154
+			$country->currency_thousands_separator()
1155
+		);
1156
+		$cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1157
+			"cntry[$CNT_ISO][CNT_tel_code]",
1158
+			$country->telephoneCode()
1159
+		);
1160
+		$cols_n_values['CNT_active']      = $this->request->getRequestParam(
1161
+			"cntry[$CNT_ISO][CNT_active]",
1162
+			$country->isActive(),
1163
+			DataType::BOOL
1164
+		);
1165
+
1166
+		// allow filtering of country data
1167
+		$cols_n_values = apply_filters(
1168
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1169
+			$cols_n_values
1170
+		);
1171
+
1172
+		// where values
1173
+		$where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1174
+		// run the update
1175
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1176
+
1177
+		// allow filtering of states data
1178
+		$states = apply_filters(
1179
+			'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1180
+			$this->request->getRequestParam('states', [], DataType::STRING, true)
1181
+		);
1182
+
1183
+		if (! empty($states) && $success !== false) {
1184
+			// loop thru state data ( looks like : states[75][STA_name] )
1185
+			foreach ($states as $STA_ID => $state) {
1186
+				$cols_n_values = [
1187
+					'CNT_ISO'    => $CNT_ISO,
1188
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1189
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1190
+					'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1191
+				];
1192
+				// where values
1193
+				$where_cols_n_values = [['STA_ID' => $STA_ID]];
1194
+				// run the update
1195
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1196
+				if ($success !== false) {
1197
+					do_action(
1198
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1199
+						$CNT_ISO,
1200
+						$STA_ID,
1201
+						$cols_n_values
1202
+					);
1203
+				}
1204
+			}
1205
+		}
1206
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1207
+		if (
1208
+			isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1209
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1210
+		) {
1211
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1212
+			EE_Registry::instance()->CFG->update_espresso_config();
1213
+		}
1214
+
1215
+		if ($success !== false) {
1216
+			EE_Error::add_success(
1217
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1218
+			);
1219
+		}
1220
+		$this->_redirect_after_action(
1221
+			$success,
1222
+			'',
1223
+			'',
1224
+			['action' => 'country_settings', 'country' => $CNT_ISO],
1225
+			true
1226
+		);
1227
+	}
1228
+
1229
+
1230
+	/**
1231
+	 * form_form_field_label_wrap
1232
+	 *
1233
+	 * @param string $label
1234
+	 * @return string
1235
+	 */
1236
+	public function country_form_field_label_wrap(string $label): string
1237
+	{
1238
+		return '
1239 1239
 			<tr>
1240 1240
 				<th>
1241 1241
 					' . $label . '
1242 1242
 				</th>';
1243
-    }
1244
-
1245
-
1246
-    /**
1247
-     * form_form_field_input__wrap
1248
-     *
1249
-     * @param string $input
1250
-     * @return string
1251
-     */
1252
-    public function country_form_field_input__wrap(string $input): string
1253
-    {
1254
-        return '
1243
+	}
1244
+
1245
+
1246
+	/**
1247
+	 * form_form_field_input__wrap
1248
+	 *
1249
+	 * @param string $input
1250
+	 * @return string
1251
+	 */
1252
+	public function country_form_field_input__wrap(string $input): string
1253
+	{
1254
+		return '
1255 1255
 				<td class="general-settings-country-input-td">
1256 1256
 					' . $input . '
1257 1257
 				</td>
1258 1258
 			</tr>';
1259
-    }
1260
-
1261
-
1262
-    /**
1263
-     * form_form_field_label_wrap
1264
-     *
1265
-     * @param string $label
1266
-     * @param string $required_text
1267
-     * @return string
1268
-     */
1269
-    public function state_form_field_label_wrap(string $label, string $required_text): string
1270
-    {
1271
-        return $required_text;
1272
-    }
1273
-
1274
-
1275
-    /**
1276
-     * form_form_field_input__wrap
1277
-     *
1278
-     * @param string $input
1279
-     * @return string
1280
-     */
1281
-    public function state_form_field_input__wrap(string $input): string
1282
-    {
1283
-        return '
1259
+	}
1260
+
1261
+
1262
+	/**
1263
+	 * form_form_field_label_wrap
1264
+	 *
1265
+	 * @param string $label
1266
+	 * @param string $required_text
1267
+	 * @return string
1268
+	 */
1269
+	public function state_form_field_label_wrap(string $label, string $required_text): string
1270
+	{
1271
+		return $required_text;
1272
+	}
1273
+
1274
+
1275
+	/**
1276
+	 * form_form_field_input__wrap
1277
+	 *
1278
+	 * @param string $input
1279
+	 * @return string
1280
+	 */
1281
+	public function state_form_field_input__wrap(string $input): string
1282
+	{
1283
+		return '
1284 1284
 				<td class="general-settings-country-state-input-td">
1285 1285
 					' . $input . '
1286 1286
 				</td>';
1287
-    }
1288
-
1289
-
1290
-    /***********/
1291
-
1292
-
1293
-    /**
1294
-     * displays edit and view links for critical EE pages
1295
-     *
1296
-     * @param int $ee_page_id
1297
-     * @return string
1298
-     */
1299
-    public static function edit_view_links(int $ee_page_id): string
1300
-    {
1301
-        $edit_url = add_query_arg(
1302
-            ['post' => $ee_page_id, 'action' => 'edit'],
1303
-            admin_url('post.php')
1304
-        );
1305
-        $links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1306
-        $links    .= ' &nbsp;|&nbsp; ';
1307
-        $links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1308
-
1309
-        return $links;
1310
-    }
1311
-
1312
-
1313
-    /**
1314
-     * displays page and shortcode status for critical EE pages
1315
-     *
1316
-     * @param WP_Post $ee_page
1317
-     * @param string  $shortcode
1318
-     * @return string
1319
-     */
1320
-    public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1321
-    {
1322
-        // page status
1323
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1324
-            $pg_colour = 'green';
1325
-            $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1326
-        } else {
1327
-            $pg_colour = 'red';
1328
-            $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1329
-        }
1330
-
1331
-        // shortcode status
1332
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1333
-            $sc_colour = 'green';
1334
-            $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1335
-        } else {
1336
-            $sc_colour = 'red';
1337
-            $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1338
-        }
1339
-
1340
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1341
-               . $pg_status
1342
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1343
-    }
1344
-
1345
-
1346
-    /**
1347
-     * generates a dropdown of all parent pages - copied from WP core
1348
-     *
1349
-     * @param int  $default
1350
-     * @param int  $parent
1351
-     * @param int  $level
1352
-     * @param bool $echo
1353
-     * @return string;
1354
-     */
1355
-    public static function page_settings_dropdown(
1356
-        int $default = 0,
1357
-        int $parent = 0,
1358
-        int $level = 0,
1359
-        bool $echo = true
1360
-    ): string {
1361
-        global $wpdb;
1362
-        $items  = $wpdb->get_results(
1363
-            $wpdb->prepare(
1364
-                "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1365
-                $parent
1366
-            )
1367
-        );
1368
-        $output = '';
1369
-
1370
-        if ($items) {
1371
-            $level = absint($level);
1372
-            foreach ($items as $item) {
1373
-                $ID         = absint($item->ID);
1374
-                $post_title = wp_strip_all_tags($item->post_title);
1375
-                $pad        = str_repeat('&nbsp;', $level * 3);
1376
-                $option     = "\n\t";
1377
-                $option     .= '<option class="level-' . $level . '" ';
1378
-                $option     .= 'value="' . $ID . '" ';
1379
-                $option     .= $ID === absint($default) ? ' selected' : '';
1380
-                $option     .= '>';
1381
-                $option     .= "$pad {$post_title}";
1382
-                $option     .= '</option>';
1383
-                $output     .= $option;
1384
-                ob_start();
1385
-                parent_dropdown($default, $item->ID, $level + 1);
1386
-                $output .= ob_get_clean();
1387
-            }
1388
-        }
1389
-        if ($echo) {
1390
-            echo wp_kses($output, AllowedTags::getAllowedTags());
1391
-            return '';
1392
-        }
1393
-        return $output;
1394
-    }
1395
-
1396
-
1397
-    /**
1398
-     * Loads the scripts for the privacy settings form
1399
-     */
1400
-    public function load_scripts_styles_privacy_settings()
1401
-    {
1402
-        $form_handler = $this->loader->getShared(
1403
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1404
-        );
1405
-        $form_handler->enqueueStylesAndScripts();
1406
-    }
1407
-
1408
-
1409
-    /**
1410
-     * display the privacy settings form
1411
-     *
1412
-     * @throws EE_Error
1413
-     */
1414
-    public function privacySettings()
1415
-    {
1416
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1417
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1418
-        $form_handler                               = $this->loader->getShared(
1419
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1420
-        );
1421
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
1422
-            $form_handler->display(),
1423
-            '',
1424
-            'padding'
1425
-        );
1426
-        $this->display_admin_page_with_sidebar();
1427
-    }
1428
-
1429
-
1430
-    /**
1431
-     * Update the privacy settings from form data
1432
-     *
1433
-     * @throws EE_Error
1434
-     */
1435
-    public function updatePrivacySettings()
1436
-    {
1437
-        $form_handler = $this->loader->getShared(
1438
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1439
-        );
1440
-        $success      = $form_handler->process($this->get_request_data());
1441
-        $this->_redirect_after_action(
1442
-            $success,
1443
-            esc_html__('Registration Form Options', 'event_espresso'),
1444
-            'updated',
1445
-            ['action' => 'privacy_settings']
1446
-        );
1447
-    }
1287
+	}
1288
+
1289
+
1290
+	/***********/
1291
+
1292
+
1293
+	/**
1294
+	 * displays edit and view links for critical EE pages
1295
+	 *
1296
+	 * @param int $ee_page_id
1297
+	 * @return string
1298
+	 */
1299
+	public static function edit_view_links(int $ee_page_id): string
1300
+	{
1301
+		$edit_url = add_query_arg(
1302
+			['post' => $ee_page_id, 'action' => 'edit'],
1303
+			admin_url('post.php')
1304
+		);
1305
+		$links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1306
+		$links    .= ' &nbsp;|&nbsp; ';
1307
+		$links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1308
+
1309
+		return $links;
1310
+	}
1311
+
1312
+
1313
+	/**
1314
+	 * displays page and shortcode status for critical EE pages
1315
+	 *
1316
+	 * @param WP_Post $ee_page
1317
+	 * @param string  $shortcode
1318
+	 * @return string
1319
+	 */
1320
+	public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1321
+	{
1322
+		// page status
1323
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1324
+			$pg_colour = 'green';
1325
+			$pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1326
+		} else {
1327
+			$pg_colour = 'red';
1328
+			$pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1329
+		}
1330
+
1331
+		// shortcode status
1332
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1333
+			$sc_colour = 'green';
1334
+			$sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1335
+		} else {
1336
+			$sc_colour = 'red';
1337
+			$sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1338
+		}
1339
+
1340
+		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1341
+			   . $pg_status
1342
+			   . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1343
+	}
1344
+
1345
+
1346
+	/**
1347
+	 * generates a dropdown of all parent pages - copied from WP core
1348
+	 *
1349
+	 * @param int  $default
1350
+	 * @param int  $parent
1351
+	 * @param int  $level
1352
+	 * @param bool $echo
1353
+	 * @return string;
1354
+	 */
1355
+	public static function page_settings_dropdown(
1356
+		int $default = 0,
1357
+		int $parent = 0,
1358
+		int $level = 0,
1359
+		bool $echo = true
1360
+	): string {
1361
+		global $wpdb;
1362
+		$items  = $wpdb->get_results(
1363
+			$wpdb->prepare(
1364
+				"SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1365
+				$parent
1366
+			)
1367
+		);
1368
+		$output = '';
1369
+
1370
+		if ($items) {
1371
+			$level = absint($level);
1372
+			foreach ($items as $item) {
1373
+				$ID         = absint($item->ID);
1374
+				$post_title = wp_strip_all_tags($item->post_title);
1375
+				$pad        = str_repeat('&nbsp;', $level * 3);
1376
+				$option     = "\n\t";
1377
+				$option     .= '<option class="level-' . $level . '" ';
1378
+				$option     .= 'value="' . $ID . '" ';
1379
+				$option     .= $ID === absint($default) ? ' selected' : '';
1380
+				$option     .= '>';
1381
+				$option     .= "$pad {$post_title}";
1382
+				$option     .= '</option>';
1383
+				$output     .= $option;
1384
+				ob_start();
1385
+				parent_dropdown($default, $item->ID, $level + 1);
1386
+				$output .= ob_get_clean();
1387
+			}
1388
+		}
1389
+		if ($echo) {
1390
+			echo wp_kses($output, AllowedTags::getAllowedTags());
1391
+			return '';
1392
+		}
1393
+		return $output;
1394
+	}
1395
+
1396
+
1397
+	/**
1398
+	 * Loads the scripts for the privacy settings form
1399
+	 */
1400
+	public function load_scripts_styles_privacy_settings()
1401
+	{
1402
+		$form_handler = $this->loader->getShared(
1403
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1404
+		);
1405
+		$form_handler->enqueueStylesAndScripts();
1406
+	}
1407
+
1408
+
1409
+	/**
1410
+	 * display the privacy settings form
1411
+	 *
1412
+	 * @throws EE_Error
1413
+	 */
1414
+	public function privacySettings()
1415
+	{
1416
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1417
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1418
+		$form_handler                               = $this->loader->getShared(
1419
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1420
+		);
1421
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
1422
+			$form_handler->display(),
1423
+			'',
1424
+			'padding'
1425
+		);
1426
+		$this->display_admin_page_with_sidebar();
1427
+	}
1428
+
1429
+
1430
+	/**
1431
+	 * Update the privacy settings from form data
1432
+	 *
1433
+	 * @throws EE_Error
1434
+	 */
1435
+	public function updatePrivacySettings()
1436
+	{
1437
+		$form_handler = $this->loader->getShared(
1438
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1439
+		);
1440
+		$success      = $form_handler->process($this->get_request_data());
1441
+		$this->_redirect_after_action(
1442
+			$success,
1443
+			esc_html__('Registration Form Options', 'event_espresso'),
1444
+			'updated',
1445
+			['action' => 'privacy_settings']
1446
+		);
1447
+	}
1448 1448
 }
Please login to merge, or discard this patch.
admin_pages/registrations/EE_Registrations_List_Table.class.php 2 patches
Indentation   +999 added lines, -999 removed lines patch added patch discarded remove patch
@@ -16,1033 +16,1033 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * @var Registrations_Admin_Page
21
-     */
22
-    protected $_admin_page;
23
-
24
-    /**
25
-     * @var array
26
-     */
27
-    private $_status;
28
-
29
-    /**
30
-     * An array of transaction details for the related transaction to the registration being processed.
31
-     * This is set via the _set_related_details method.
32
-     *
33
-     * @var array
34
-     */
35
-    protected $_transaction_details = [];
36
-
37
-    /**
38
-     * An array of event details for the related event to the registration being processed.
39
-     * This is set via the _set_related_details method.
40
-     *
41
-     * @var array
42
-     */
43
-    protected $_event_details = [];
44
-
45
-
46
-    /**
47
-     * @param Registrations_Admin_Page $admin_page
48
-     */
49
-    public function __construct(Registrations_Admin_Page $admin_page)
50
-    {
51
-        $req_data = $admin_page->get_request_data();
52
-        if (! empty($req_data['event_id'])) {
53
-            $extra_query_args = [];
54
-            foreach ($admin_page->get_views() as $view_details) {
55
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
56
-            }
57
-            $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
58
-        }
59
-        parent::__construct($admin_page);
60
-        $this->_status = $this->_admin_page->get_registration_status_array();
61
-    }
62
-
63
-
64
-    /**
65
-     * @return void
66
-     * @throws EE_Error
67
-     */
68
-    protected function _setup_data()
69
-    {
70
-        $this->_data           = $this->_admin_page->get_registrations($this->_per_page);
71
-        $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
72
-    }
73
-
74
-
75
-    /**
76
-     * @return void
77
-     */
78
-    protected function _set_properties()
79
-    {
80
-        $return_url          = $this->getReturnUrl();
81
-        $this->_wp_list_args = [
82
-            'singular' => esc_html__('registration', 'event_espresso'),
83
-            'plural'   => esc_html__('registrations', 'event_espresso'),
84
-            'ajax'     => true,
85
-            'screen'   => $this->_admin_page->get_current_screen()->id,
86
-        ];
87
-        $ID_column_name      = esc_html__('ID', 'event_espresso');
88
-        $ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
89
-        $ID_column_name      .= esc_html__('Registrant Name', 'event_espresso');
90
-        $ID_column_name      .= '</span> ';
91
-
92
-        $EVT_ID = $this->_req_data['event_id'] ?? 0;
93
-        $DTT_ID = $this->_req_data['DTT_ID'] ?? 0;
94
-
95
-        if ($EVT_ID) {
96
-            $this->_columns        = [
97
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
98
-                '_REG_ID'          => $ID_column_name,
99
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
100
-                'ATT_email'        => esc_html__('Email', 'event_espresso'),
101
-                '_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
102
-                'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
103
-                '_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
104
-                'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
105
-                'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
106
-                'actions'          => esc_html__('Actions', 'event_espresso'),
107
-            ];
108
-        } else {
109
-            $this->_columns        = [
110
-                'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
111
-                '_REG_ID'          => $ID_column_name,
112
-                'ATT_fname'        => esc_html__('Name', 'event_espresso'),
113
-                '_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
114
-                'event_name'       => esc_html__('Event', 'event_espresso'),
115
-                'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
116
-                '_REG_final_price' => esc_html__('Price', 'event_espresso'),
117
-                '_REG_paid'        => esc_html__('Paid', 'event_espresso'),
118
-                'actions'          => esc_html__('Actions', 'event_espresso'),
119
-            ];
120
-        }
121
-
122
-        $csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
123
-        if (! empty($csv_report)) {
124
-            $this->_bottom_buttons['csv_reg_report'] = $csv_report;
125
-        }
126
-
127
-        $this->_primary_column   = '_REG_ID';
128
-        $this->_sortable_columns = [
129
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
130
-            /**
131
-             * Allows users to change the default sort if they wish.
132
-             * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
133
-             * name.
134
-             */
135
-            'ATT_fname'     => [
136
-                'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
137
-                true,
138
-                $this,
139
-            ]
140
-                ? ['ATT_lname' => false]
141
-                : ['ATT_fname' => false],
142
-            'event_name'    => ['event_name' => false],
143
-            'DTT_EVT_start' => ['DTT_EVT_start' => false],
144
-            '_REG_ID'       => ['_REG_ID' => false],
145
-        ];
146
-        $this->_hidden_columns   = [];
147
-    }
148
-
149
-
150
-    /**
151
-     * This simply sets up the row class for the table rows.
152
-     * Allows for easier overriding of child methods for setting up sorting.
153
-     *
154
-     * @param EE_Registration $item the current item
155
-     * @return string
156
-     */
157
-    protected function _get_row_class($item)
158
-    {
159
-        $class = parent::_get_row_class($item);
160
-        // add status class
161
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
162
-        if ($this->_has_checkbox_column) {
163
-            $class .= ' has-checkbox-column';
164
-        }
165
-        return $class;
166
-    }
167
-
168
-
169
-    /**
170
-     * Set the $_transaction_details property if not set yet.
171
-     *
172
-     * @param EE_Registration $registration
173
-     * @throws EE_Error
174
-     * @throws InvalidArgumentException
175
-     * @throws ReflectionException
176
-     * @throws InvalidDataTypeException
177
-     * @throws InvalidInterfaceException
178
-     */
179
-    protected function _set_related_details(EE_Registration $registration)
180
-    {
181
-        $transaction                = $registration->get_first_related('Transaction');
182
-        $status                     = $transaction instanceof EE_Transaction
183
-            ? $transaction->status_ID()
184
-            : EEM_Transaction::failed_status_code;
185
-        $this->_transaction_details = [
186
-            'transaction' => $transaction,
187
-            'status'      => $status,
188
-            'id'          => $transaction instanceof EE_Transaction
189
-                ? $transaction->ID()
190
-                : 0,
191
-            'title_attr'  => sprintf(
192
-                esc_html__('View Transaction Details (%s)', 'event_espresso'),
193
-                EEH_Template::pretty_status($status, false, 'sentence')
194
-            ),
195
-        ];
196
-        try {
197
-            $event = $registration->event();
198
-        } catch (EntityNotFoundException $e) {
199
-            $event = null;
200
-        }
201
-        $status               = $event instanceof EE_Event
202
-            ? $event->get_active_status()
203
-            : EE_Datetime::inactive;
204
-        $this->_event_details = [
205
-            'event'      => $event,
206
-            'status'     => $status,
207
-            'id'         => $event instanceof EE_Event
208
-                ? $event->ID()
209
-                : 0,
210
-            'title_attr' => sprintf(
211
-                esc_html__('Edit Event (%s)', 'event_espresso'),
212
-                EEH_Template::pretty_status($status, false, 'sentence')
213
-            ),
214
-        ];
215
-    }
216
-
217
-
218
-    /**
219
-     *    _get_table_filters
220
-     *
221
-     * @return array
222
-     */
223
-    protected function _get_table_filters()
224
-    {
225
-        $filters = [];
226
-        // todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
227
-        // methods.
228
-        $cur_date     = isset($this->_req_data['month_range'])
229
-            ? $this->_req_data['month_range']
230
-            : '';
231
-        $cur_category = isset($this->_req_data['EVT_CAT'])
232
-            ? $this->_req_data['EVT_CAT']
233
-            : -1;
234
-        $reg_status   = isset($this->_req_data['_reg_status'])
235
-            ? $this->_req_data['_reg_status']
236
-            : '';
237
-        $filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
238
-        $filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
239
-        $status       = [];
240
-        $status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
241
-        foreach ($this->_status as $key => $value) {
242
-            $status[] = ['id' => $key, 'text' => $value];
243
-        }
244
-        if ($this->_view !== 'incomplete') {
245
-            $filters[] = EEH_Form_Fields::select_input(
246
-                '_reg_status',
247
-                $status,
248
-                isset($this->_req_data['_reg_status'])
249
-                    ? strtoupper(sanitize_key($this->_req_data['_reg_status']))
250
-                    : ''
251
-            );
252
-        }
253
-        if (isset($this->_req_data['event_id'])) {
254
-            $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
255
-        }
256
-        return $filters;
257
-    }
258
-
259
-
260
-    /**
261
-     * @return void
262
-     * @throws EE_Error
263
-     * @throws InvalidArgumentException
264
-     * @throws InvalidDataTypeException
265
-     * @throws InvalidInterfaceException
266
-     */
267
-    protected function _add_view_counts()
268
-    {
269
-        $this->_views['all']['count']   = $this->_total_registrations();
270
-        $this->_views['month']['count'] = $this->_total_registrations_this_month();
271
-        $this->_views['today']['count'] = $this->_total_registrations_today();
272
-        if (
273
-            EE_Registry::instance()->CAP->current_user_can(
274
-                'ee_delete_registrations',
275
-                'espresso_registrations_trash_registrations'
276
-            )
277
-        ) {
278
-            $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
279
-            $this->_views['trash']['count']      = $this->_total_registrations('trash');
280
-        }
281
-    }
282
-
283
-
284
-    /**
285
-     * @param string $view
286
-     * @return int
287
-     * @throws EE_Error
288
-     * @throws InvalidArgumentException
289
-     * @throws InvalidDataTypeException
290
-     * @throws InvalidInterfaceException
291
-     */
292
-    protected function _total_registrations($view = '')
293
-    {
294
-        $_where = [];
295
-        $EVT_ID = isset($this->_req_data['event_id'])
296
-            ? absint($this->_req_data['event_id'])
297
-            : false;
298
-        if ($EVT_ID) {
299
-            $_where['EVT_ID'] = $EVT_ID;
300
-        }
301
-        switch ($view) {
302
-            case 'trash':
303
-                return EEM_Registration::instance()->count_deleted([$_where]);
304
-            case 'incomplete':
305
-                $_where['STS_ID'] = EEM_Registration::status_id_incomplete;
306
-                break;
307
-            default:
308
-                $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
309
-        }
310
-        return EEM_Registration::instance()->count([$_where]);
311
-    }
312
-
313
-
314
-    /**
315
-     * @return int
316
-     * @throws EE_Error
317
-     * @throws InvalidArgumentException
318
-     * @throws InvalidDataTypeException
319
-     * @throws InvalidInterfaceException
320
-     */
321
-    protected function _total_registrations_this_month()
322
-    {
323
-        $EVT_ID          = isset($this->_req_data['event_id'])
324
-            ? absint($this->_req_data['event_id'])
325
-            : false;
326
-        $_where          = $EVT_ID
327
-            ? ['EVT_ID' => $EVT_ID]
328
-            : [];
329
-        $this_year_r     = date('Y', current_time('timestamp'));
330
-        $time_start      = ' 00:00:00';
331
-        $time_end        = ' 23:59:59';
332
-        $this_month_r    = date('m', current_time('timestamp'));
333
-        $days_this_month = date('t', current_time('timestamp'));
334
-        // setup date query.
335
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
336
-            'REG_date',
337
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
338
-            'Y-m-d H:i:s'
339
-        );
340
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
341
-            'REG_date',
342
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
343
-            'Y-m-d H:i:s'
344
-        );
345
-        $_where['REG_date'] = [
346
-            'BETWEEN',
347
-            [
348
-                $beginning_string,
349
-                $end_string,
350
-            ],
351
-        ];
352
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
353
-        return EEM_Registration::instance()->count([$_where]);
354
-    }
355
-
356
-
357
-    /**
358
-     * @return int
359
-     * @throws EE_Error
360
-     * @throws InvalidArgumentException
361
-     * @throws InvalidDataTypeException
362
-     * @throws InvalidInterfaceException
363
-     */
364
-    protected function _total_registrations_today()
365
-    {
366
-        $EVT_ID             = isset($this->_req_data['event_id'])
367
-            ? absint($this->_req_data['event_id'])
368
-            : false;
369
-        $_where             = $EVT_ID
370
-            ? ['EVT_ID' => $EVT_ID]
371
-            : [];
372
-        $current_date       = date('Y-m-d', current_time('timestamp'));
373
-        $time_start         = ' 00:00:00';
374
-        $time_end           = ' 23:59:59';
375
-        $_where['REG_date'] = [
376
-            'BETWEEN',
377
-            [
378
-                EEM_Registration::instance()->convert_datetime_for_query(
379
-                    'REG_date',
380
-                    $current_date . $time_start,
381
-                    'Y-m-d H:i:s'
382
-                ),
383
-                EEM_Registration::instance()->convert_datetime_for_query(
384
-                    'REG_date',
385
-                    $current_date . $time_end,
386
-                    'Y-m-d H:i:s'
387
-                ),
388
-            ],
389
-        ];
390
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
391
-        return EEM_Registration::instance()->count([$_where]);
392
-    }
393
-
394
-
395
-    /**
396
-     * @param EE_Registration $item
397
-     * @return string
398
-     * @throws EE_Error
399
-     * @throws InvalidArgumentException
400
-     * @throws InvalidDataTypeException
401
-     * @throws InvalidInterfaceException
402
-     * @throws ReflectionException
403
-     */
404
-    public function column_cb($item)
405
-    {
406
-        /** checkbox/lock **/
407
-        $transaction   = $item->get_first_related('Transaction');
408
-        $payment_count = $transaction instanceof EE_Transaction
409
-            ? $transaction->count_related('Payment')
410
-            : 0;
411
-        return $payment_count > 0 || ! EE_Registry::instance()->CAP->current_user_can(
412
-            'ee_edit_registration',
413
-            'registration_list_table_checkbox_input',
414
-            $item->ID()
415
-        )
416
-            ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID())
417
-              . '<span class="ee-lock-icon"></span>'
418
-            : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID());
419
-    }
420
-
421
-
422
-    /**
423
-     * @param EE_Registration $item
424
-     * @return string
425
-     * @throws EE_Error
426
-     * @throws InvalidArgumentException
427
-     * @throws InvalidDataTypeException
428
-     * @throws InvalidInterfaceException
429
-     * @throws ReflectionException
430
-     */
431
-    public function column__REG_ID(EE_Registration $item)
432
-    {
433
-        $attendee = $item->attendee();
434
-        $content  = $item->ID();
435
-        $content  .= '<div class="show-on-mobile-view-only">';
436
-        $content  .= '<br>';
437
-        $content  .= $attendee instanceof EE_Attendee
438
-            ? $attendee->full_name()
439
-            : '';
440
-        $content  .= '&nbsp;';
441
-        $content  .= sprintf(
442
-            esc_html__('(%1$s / %2$s)', 'event_espresso'),
443
-            $item->count(),
444
-            $item->group_size()
445
-        );
446
-        $content  .= '<br>';
447
-        $content  .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
448
-        $content  .= '</div>';
449
-        return $content;
450
-    }
451
-
452
-
453
-    /**
454
-     * @param EE_Registration $item
455
-     * @return string
456
-     * @throws EE_Error
457
-     * @throws InvalidArgumentException
458
-     * @throws InvalidDataTypeException
459
-     * @throws InvalidInterfaceException
460
-     * @throws ReflectionException
461
-     */
462
-    public function column__REG_date(EE_Registration $item)
463
-    {
464
-        $this->_set_related_details($item);
465
-        // Build row actions
466
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
467
-            [
468
-                'action' => 'view_transaction',
469
-                'TXN_ID' => $this->_transaction_details['id'],
470
-            ],
471
-            TXN_ADMIN_URL
472
-        );
473
-        $view_link    = EE_Registry::instance()->CAP->current_user_can(
474
-            'ee_read_transaction',
475
-            'espresso_transactions_view_transaction'
476
-        )
477
-            ? '<a class="ee-status-color-'
478
-              . $this->_transaction_details['status']
479
-              . '" href="'
480
-              . $view_lnk_url
481
-              . '" title="'
482
-              . esc_attr($this->_transaction_details['title_attr'])
483
-              . '">'
484
-              . $item->get_i18n_datetime('REG_date')
485
-              . '</a>'
486
-            : $item->get_i18n_datetime('REG_date');
487
-        $view_link    .= '<br><span class="ee-status-text-small">'
488
-                         . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
489
-                         . '</span>';
490
-        return $view_link;
491
-    }
492
-
493
-
494
-    /**
495
-     * @param EE_Registration $item
496
-     * @return string
497
-     * @throws EE_Error
498
-     * @throws InvalidArgumentException
499
-     * @throws InvalidDataTypeException
500
-     * @throws InvalidInterfaceException
501
-     * @throws ReflectionException
502
-     */
503
-    public function column_event_name(EE_Registration $item)
504
-    {
505
-        $this->_set_related_details($item);
506
-        // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
507
-        $EVT_ID     = $item->event_ID();
508
-        $event_name = $item->event_name();
509
-        $event_name =
510
-            $event_name
511
-                ?: esc_html__("No Associated Event", 'event_espresso');
512
-        $event_name = wp_trim_words($event_name, 30, '...');
513
-        if ($EVT_ID) {
514
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
515
-                ['action' => 'edit', 'post' => $EVT_ID],
516
-                EVENTS_ADMIN_URL
517
-            );
518
-            $edit_event              =
519
-                EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
520
-                    ? '<a class="ee-status-color-'
521
-                      . $this->_event_details['status']
522
-                      . '" href="'
523
-                      . $edit_event_url
524
-                      . '" title="'
525
-                      . esc_attr($this->_event_details['title_attr'])
526
-                      . '">'
527
-                      . $event_name
528
-                      . '</a>'
529
-                    : $event_name;
530
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
531
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
532
-            $actions['event_filter'] .= sprintf(
533
-                esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
534
-                $event_name
535
-            );
536
-            $actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
537
-        } else {
538
-            $edit_event              = $event_name;
539
-            $actions['event_filter'] = '';
540
-        }
541
-        return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
542
-    }
543
-
544
-
545
-    /**
546
-     * @param EE_Registration $item
547
-     * @return string
548
-     * @throws EE_Error
549
-     * @throws InvalidArgumentException
550
-     * @throws InvalidDataTypeException
551
-     * @throws InvalidInterfaceException
552
-     * @throws ReflectionException
553
-     */
554
-    public function column_DTT_EVT_start(EE_Registration $item)
555
-    {
556
-        $datetime_strings = [];
557
-        $ticket           = $item->ticket();
558
-        if ($ticket instanceof EE_Ticket) {
559
-            $remove_defaults = ['default_where_conditions' => 'none'];
560
-            $datetimes       = $ticket->datetimes($remove_defaults);
561
-            foreach ($datetimes as $datetime) {
562
-                $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
563
-            }
564
-            return $this->generateDisplayForDatetimes($datetime_strings);
565
-        }
566
-        return esc_html__('There is no ticket on this registration', 'event_espresso');
567
-    }
568
-
569
-
570
-    /**
571
-     * Receives an array of datetime strings to display and converts them to the html container for the column.
572
-     *
573
-     * @param array $datetime_strings
574
-     * @return string
575
-     */
576
-    public function generateDisplayForDateTimes(array $datetime_strings)
577
-    {
578
-        $content       = '<div class="ee-registration-event-datetimes-container">';
579
-        $expand_toggle = count($datetime_strings) > 1
580
-            ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
581
-              . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
582
-            : '';
583
-        // get first item for initial visibility
584
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
585
-        $content .= $expand_toggle;
586
-        if ($datetime_strings) {
587
-            $content .= '<div style="clear:both"></div>';
588
-            $content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
589
-            $content .= implode("<br />", $datetime_strings);
590
-            $content .= '</div>';
591
-        }
592
-        $content .= '</div>';
593
-        return $content;
594
-    }
595
-
596
-
597
-    /**
598
-     * @param EE_Registration $item
599
-     * @return string
600
-     * @throws EE_Error
601
-     * @throws InvalidArgumentException
602
-     * @throws InvalidDataTypeException
603
-     * @throws InvalidInterfaceException
604
-     * @throws ReflectionException
605
-     */
606
-    public function column_ATT_fname(EE_Registration $item)
607
-    {
608
-        $attendee      = $item->attendee();
609
-        $edit_lnk_url  = EE_Admin_Page::add_query_args_and_nonce(
610
-            [
611
-                'action'  => 'view_registration',
612
-                '_REG_ID' => $item->ID(),
613
-            ],
614
-            REG_ADMIN_URL
615
-        );
616
-        $attendee_name = $attendee instanceof EE_Attendee
617
-            ? $attendee->full_name()
618
-            : '';
619
-        $link          = EE_Registry::instance()->CAP->current_user_can(
620
-            'ee_read_registration',
621
-            'espresso_registrations_view_registration',
622
-            $item->ID()
623
-        )
624
-            ? '<a href="'
625
-              . $edit_lnk_url
626
-              . '" title="'
627
-              . esc_attr__('View Registration Details', 'event_espresso')
628
-              . '">'
629
-              . $attendee_name
630
-              . '</a>'
631
-            : $attendee_name;
632
-        $link          .= $item->count() === 1
633
-            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>'
634
-            : '';
635
-        $t             = $item->get_first_related('Transaction');
636
-        $payment_count = $t instanceof EE_Transaction
637
-            ? $t->count_related('Payment')
638
-            : 0;
639
-        // append group count to name
640
-        $link .= '&nbsp;' . sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
641
-        // append reg_code
642
-        $link .= '<br>' . sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
643
-        // reg status text for accessibility
644
-        $link   .= '<br><span class="ee-status-text-small">'
645
-                   . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
646
-                   . '</span>';
647
-        $action = ['_REG_ID' => $item->ID()];
648
-        if (isset($this->_req_data['event_id'])) {
649
-            $action['event_id'] = $item->event_ID();
650
-        }
651
-        // trash/restore/delete actions
652
-        $actions = [];
653
-        if (
654
-            $this->_view !== 'trash'
655
-            && $payment_count === 0
656
-            && EE_Registry::instance()->CAP->current_user_can(
657
-                'ee_delete_registration',
658
-                'espresso_registrations_trash_registrations',
659
-                $item->ID()
660
-            )
661
-        ) {
662
-            $action['action'] = 'trash_registrations';
663
-            $trash_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
664
-                $action,
665
-                REG_ADMIN_URL
666
-            );
667
-            $actions['trash'] = '<a href="'
668
-                                . $trash_lnk_url
669
-                                . '" title="'
670
-                                . esc_attr__('Trash Registration', 'event_espresso')
671
-                                . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
672
-        } elseif ($this->_view === 'trash') {
673
-            // restore registration link
674
-            if (
675
-                EE_Registry::instance()->CAP->current_user_can(
676
-                    'ee_delete_registration',
677
-                    'espresso_registrations_restore_registrations',
678
-                    $item->ID()
679
-                )
680
-            ) {
681
-                $action['action']   = 'restore_registrations';
682
-                $restore_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
683
-                    $action,
684
-                    REG_ADMIN_URL
685
-                );
686
-                $actions['restore'] = '<a href="'
687
-                                      . $restore_lnk_url
688
-                                      . '" title="'
689
-                                      . esc_attr__('Restore Registration', 'event_espresso') . '">'
690
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
691
-            }
692
-            if (
693
-                EE_Registry::instance()->CAP->current_user_can(
694
-                    'ee_delete_registration',
695
-                    'espresso_registrations_ee_delete_registrations',
696
-                    $item->ID()
697
-                )
698
-            ) {
699
-                $action['action']  = 'delete_registrations';
700
-                $delete_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
701
-                    $action,
702
-                    REG_ADMIN_URL
703
-                );
704
-                $actions['delete'] = '<a href="'
705
-                                     . $delete_lnk_url
706
-                                     . '" title="'
707
-                                     . esc_attr__('Delete Registration Permanently', 'event_espresso')
708
-                                     . '">'
709
-                                     . esc_html__('Delete', 'event_espresso')
710
-                                     . '</a>';
711
-            }
712
-        }
713
-        return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
714
-    }
715
-
716
-
717
-    /**
718
-     * @param EE_Registration $item
719
-     * @return string
720
-     * @throws EE_Error
721
-     * @throws InvalidArgumentException
722
-     * @throws InvalidDataTypeException
723
-     * @throws InvalidInterfaceException
724
-     * @throws ReflectionException
725
-     */
726
-    public function column_ATT_email(EE_Registration $item)
727
-    {
728
-        $attendee = $item->get_first_related('Attendee');
729
-        return ! $attendee instanceof EE_Attendee
730
-            ? esc_html__('No attached contact record.', 'event_espresso')
731
-            : $attendee->email();
732
-    }
733
-
734
-
735
-    /**
736
-     * @param EE_Registration $item
737
-     * @return string
738
-     */
739
-    public function column__REG_count(EE_Registration $item)
740
-    {
741
-        return sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
742
-    }
743
-
744
-
745
-    /**
746
-     * @param EE_Registration $item
747
-     * @return string
748
-     * @throws EE_Error
749
-     * @throws ReflectionException
750
-     */
751
-    public function column_PRC_amount(EE_Registration $item)
752
-    {
753
-        $ticket   = $item->ticket();
754
-        $req_data = $this->_admin_page->get_request_data();
755
-        $content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
756
-            ? '<span class="TKT_name">' . $ticket->name() . '</span><br />'
757
-            : '';
758
-        if ($item->final_price() > 0) {
759
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
760
-        } else {
761
-            // free event
762
-            $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
763
-                        . esc_html__('free', 'event_espresso')
764
-                        . '</span>';
765
-        }
766
-        return $content;
767
-    }
768
-
769
-
770
-    /**
771
-     * @param EE_Registration $item
772
-     * @return string
773
-     * @throws EE_Error
774
-     * @throws ReflectionException
775
-     */
776
-    public function column__REG_final_price(EE_Registration $item)
777
-    {
778
-        $ticket   = $item->ticket();
779
-        $req_data = $this->_admin_page->get_request_data();
780
-        $content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
781
-            ? ''
782
-            : '<span class="TKT_name">' . $ticket->name() . '</span><br />';
783
-        $content  .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
784
-        return $content;
785
-    }
786
-
787
-
788
-    /**
789
-     * @param EE_Registration $item
790
-     * @return string
791
-     * @throws EE_Error
792
-     */
793
-    public function column__REG_paid(EE_Registration $item)
794
-    {
795
-        $payment_method      = $item->payment_method();
796
-        $payment_method_name = $payment_method instanceof EE_Payment_Method
797
-            ? $payment_method->admin_name()
798
-            : esc_html__('Unknown', 'event_espresso');
799
-        $content             = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
800
-        if ($item->paid() > 0) {
801
-            $content .= '<br><span class="ee-status-text-small">'
802
-                        . sprintf(
803
-                            esc_html__('...via %s', 'event_espresso'),
804
-                            $payment_method_name
805
-                        )
806
-                        . '</span>';
807
-        }
808
-        return $content;
809
-    }
810
-
811
-
812
-    /**
813
-     * @param EE_Registration $item
814
-     * @return string
815
-     * @throws EE_Error
816
-     * @throws EntityNotFoundException
817
-     * @throws InvalidArgumentException
818
-     * @throws InvalidDataTypeException
819
-     * @throws InvalidInterfaceException
820
-     * @throws ReflectionException
821
-     */
822
-    public function column_TXN_total(EE_Registration $item)
823
-    {
824
-        if ($item->transaction()) {
825
-            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
826
-                [
827
-                    'action' => 'view_transaction',
828
-                    'TXN_ID' => $item->transaction_ID(),
829
-                ],
830
-                TXN_ADMIN_URL
831
-            );
832
-            return EE_Registry::instance()->CAP->current_user_can(
833
-                'ee_read_transaction',
834
-                'espresso_transactions_view_transaction',
835
-                $item->transaction_ID()
836
-            )
837
-                ? '<span class="reg-pad-rght"><a class="status-'
838
-                  . $item->transaction()->status_ID()
839
-                  . '" href="'
840
-                  . $view_txn_lnk_url
841
-                  . '"  title="'
842
-                  . esc_attr__('View Transaction', 'event_espresso')
843
-                  . '">'
844
-                  . $item->transaction()->pretty_total()
845
-                  . '</a></span>'
846
-                : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
847
-        } else {
848
-            return esc_html__("None", "event_espresso");
849
-        }
850
-    }
851
-
852
-
853
-    /**
854
-     * @param EE_Registration $item
855
-     * @return string
856
-     * @throws EE_Error
857
-     * @throws EntityNotFoundException
858
-     * @throws InvalidArgumentException
859
-     * @throws InvalidDataTypeException
860
-     * @throws InvalidInterfaceException
861
-     * @throws ReflectionException
862
-     */
863
-    public function column_TXN_paid(EE_Registration $item)
864
-    {
865
-        if ($item->count() === 1) {
866
-            $transaction = $item->transaction()
867
-                ? $item->transaction()
868
-                : EE_Transaction::new_instance();
869
-            if ($transaction->paid() >= $transaction->total()) {
870
-                return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
871
-            } else {
872
-                $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
873
-                    [
874
-                        'action' => 'view_transaction',
875
-                        'TXN_ID' => $item->transaction_ID(),
876
-                    ],
877
-                    TXN_ADMIN_URL
878
-                );
879
-                return EE_Registry::instance()->CAP->current_user_can(
880
-                    'ee_read_transaction',
881
-                    'espresso_transactions_view_transaction',
882
-                    $item->transaction_ID()
883
-                )
884
-                    ? '<span class="reg-pad-rght"><a class="status-'
885
-                      . $transaction->status_ID()
886
-                      . '" href="'
887
-                      . $view_txn_lnk_url
888
-                      . '"  title="'
889
-                      . esc_attr__('View Transaction', 'event_espresso')
890
-                      . '">'
891
-                      . $item->transaction()->pretty_paid()
892
-                      . '</a><span>'
893
-                    : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
894
-            }
895
-        }
896
-        return '&nbsp;';
897
-    }
898
-
899
-
900
-    /**
901
-     * column_actions
902
-     *
903
-     * @param EE_Registration $item
904
-     * @return string
905
-     * @throws EE_Error
906
-     * @throws InvalidArgumentException
907
-     * @throws InvalidDataTypeException
908
-     * @throws InvalidInterfaceException
909
-     * @throws ReflectionException
910
-     */
911
-    public function column_actions(EE_Registration $item)
912
-    {
913
-        $actions  = [];
914
-        $attendee = $item->attendee();
915
-        $this->_set_related_details($item);
916
-
917
-        // Build row actions
918
-        if (
919
-            EE_Registry::instance()->CAP->current_user_can(
920
-                'ee_read_registration',
921
-                'espresso_registrations_view_registration',
922
-                $item->ID()
923
-            )
924
-        ) {
925
-            $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
926
-                [
927
-                    'action'  => 'view_registration',
928
-                    '_REG_ID' => $item->ID(),
929
-                ],
930
-                REG_ADMIN_URL
931
-            );
932
-            $actions['view_lnk'] = '
19
+	/**
20
+	 * @var Registrations_Admin_Page
21
+	 */
22
+	protected $_admin_page;
23
+
24
+	/**
25
+	 * @var array
26
+	 */
27
+	private $_status;
28
+
29
+	/**
30
+	 * An array of transaction details for the related transaction to the registration being processed.
31
+	 * This is set via the _set_related_details method.
32
+	 *
33
+	 * @var array
34
+	 */
35
+	protected $_transaction_details = [];
36
+
37
+	/**
38
+	 * An array of event details for the related event to the registration being processed.
39
+	 * This is set via the _set_related_details method.
40
+	 *
41
+	 * @var array
42
+	 */
43
+	protected $_event_details = [];
44
+
45
+
46
+	/**
47
+	 * @param Registrations_Admin_Page $admin_page
48
+	 */
49
+	public function __construct(Registrations_Admin_Page $admin_page)
50
+	{
51
+		$req_data = $admin_page->get_request_data();
52
+		if (! empty($req_data['event_id'])) {
53
+			$extra_query_args = [];
54
+			foreach ($admin_page->get_views() as $view_details) {
55
+				$extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
56
+			}
57
+			$this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
58
+		}
59
+		parent::__construct($admin_page);
60
+		$this->_status = $this->_admin_page->get_registration_status_array();
61
+	}
62
+
63
+
64
+	/**
65
+	 * @return void
66
+	 * @throws EE_Error
67
+	 */
68
+	protected function _setup_data()
69
+	{
70
+		$this->_data           = $this->_admin_page->get_registrations($this->_per_page);
71
+		$this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true);
72
+	}
73
+
74
+
75
+	/**
76
+	 * @return void
77
+	 */
78
+	protected function _set_properties()
79
+	{
80
+		$return_url          = $this->getReturnUrl();
81
+		$this->_wp_list_args = [
82
+			'singular' => esc_html__('registration', 'event_espresso'),
83
+			'plural'   => esc_html__('registrations', 'event_espresso'),
84
+			'ajax'     => true,
85
+			'screen'   => $this->_admin_page->get_current_screen()->id,
86
+		];
87
+		$ID_column_name      = esc_html__('ID', 'event_espresso');
88
+		$ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
89
+		$ID_column_name      .= esc_html__('Registrant Name', 'event_espresso');
90
+		$ID_column_name      .= '</span> ';
91
+
92
+		$EVT_ID = $this->_req_data['event_id'] ?? 0;
93
+		$DTT_ID = $this->_req_data['DTT_ID'] ?? 0;
94
+
95
+		if ($EVT_ID) {
96
+			$this->_columns        = [
97
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
98
+				'_REG_ID'          => $ID_column_name,
99
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
100
+				'ATT_email'        => esc_html__('Email', 'event_espresso'),
101
+				'_REG_date'        => esc_html__('Reg Date', 'event_espresso'),
102
+				'PRC_amount'       => esc_html__('TKT Price', 'event_espresso'),
103
+				'_REG_final_price' => esc_html__('Final Price', 'event_espresso'),
104
+				'TXN_total'        => esc_html__('Total Txn', 'event_espresso'),
105
+				'TXN_paid'         => esc_html__('Paid', 'event_espresso'),
106
+				'actions'          => esc_html__('Actions', 'event_espresso'),
107
+			];
108
+		} else {
109
+			$this->_columns        = [
110
+				'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
111
+				'_REG_ID'          => $ID_column_name,
112
+				'ATT_fname'        => esc_html__('Name', 'event_espresso'),
113
+				'_REG_date'        => esc_html__('TXN Date', 'event_espresso'),
114
+				'event_name'       => esc_html__('Event', 'event_espresso'),
115
+				'DTT_EVT_start'    => esc_html__('Event Date', 'event_espresso'),
116
+				'_REG_final_price' => esc_html__('Price', 'event_espresso'),
117
+				'_REG_paid'        => esc_html__('Paid', 'event_espresso'),
118
+				'actions'          => esc_html__('Actions', 'event_espresso'),
119
+			];
120
+		}
121
+
122
+		$csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
123
+		if (! empty($csv_report)) {
124
+			$this->_bottom_buttons['csv_reg_report'] = $csv_report;
125
+		}
126
+
127
+		$this->_primary_column   = '_REG_ID';
128
+		$this->_sortable_columns = [
129
+			'_REG_date'     => ['_REG_date' => true],   // true means its already sorted
130
+			/**
131
+			 * Allows users to change the default sort if they wish.
132
+			 * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
133
+			 * name.
134
+			 */
135
+			'ATT_fname'     => [
136
+				'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name',
137
+				true,
138
+				$this,
139
+			]
140
+				? ['ATT_lname' => false]
141
+				: ['ATT_fname' => false],
142
+			'event_name'    => ['event_name' => false],
143
+			'DTT_EVT_start' => ['DTT_EVT_start' => false],
144
+			'_REG_ID'       => ['_REG_ID' => false],
145
+		];
146
+		$this->_hidden_columns   = [];
147
+	}
148
+
149
+
150
+	/**
151
+	 * This simply sets up the row class for the table rows.
152
+	 * Allows for easier overriding of child methods for setting up sorting.
153
+	 *
154
+	 * @param EE_Registration $item the current item
155
+	 * @return string
156
+	 */
157
+	protected function _get_row_class($item)
158
+	{
159
+		$class = parent::_get_row_class($item);
160
+		// add status class
161
+		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
162
+		if ($this->_has_checkbox_column) {
163
+			$class .= ' has-checkbox-column';
164
+		}
165
+		return $class;
166
+	}
167
+
168
+
169
+	/**
170
+	 * Set the $_transaction_details property if not set yet.
171
+	 *
172
+	 * @param EE_Registration $registration
173
+	 * @throws EE_Error
174
+	 * @throws InvalidArgumentException
175
+	 * @throws ReflectionException
176
+	 * @throws InvalidDataTypeException
177
+	 * @throws InvalidInterfaceException
178
+	 */
179
+	protected function _set_related_details(EE_Registration $registration)
180
+	{
181
+		$transaction                = $registration->get_first_related('Transaction');
182
+		$status                     = $transaction instanceof EE_Transaction
183
+			? $transaction->status_ID()
184
+			: EEM_Transaction::failed_status_code;
185
+		$this->_transaction_details = [
186
+			'transaction' => $transaction,
187
+			'status'      => $status,
188
+			'id'          => $transaction instanceof EE_Transaction
189
+				? $transaction->ID()
190
+				: 0,
191
+			'title_attr'  => sprintf(
192
+				esc_html__('View Transaction Details (%s)', 'event_espresso'),
193
+				EEH_Template::pretty_status($status, false, 'sentence')
194
+			),
195
+		];
196
+		try {
197
+			$event = $registration->event();
198
+		} catch (EntityNotFoundException $e) {
199
+			$event = null;
200
+		}
201
+		$status               = $event instanceof EE_Event
202
+			? $event->get_active_status()
203
+			: EE_Datetime::inactive;
204
+		$this->_event_details = [
205
+			'event'      => $event,
206
+			'status'     => $status,
207
+			'id'         => $event instanceof EE_Event
208
+				? $event->ID()
209
+				: 0,
210
+			'title_attr' => sprintf(
211
+				esc_html__('Edit Event (%s)', 'event_espresso'),
212
+				EEH_Template::pretty_status($status, false, 'sentence')
213
+			),
214
+		];
215
+	}
216
+
217
+
218
+	/**
219
+	 *    _get_table_filters
220
+	 *
221
+	 * @return array
222
+	 */
223
+	protected function _get_table_filters()
224
+	{
225
+		$filters = [];
226
+		// todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as
227
+		// methods.
228
+		$cur_date     = isset($this->_req_data['month_range'])
229
+			? $this->_req_data['month_range']
230
+			: '';
231
+		$cur_category = isset($this->_req_data['EVT_CAT'])
232
+			? $this->_req_data['EVT_CAT']
233
+			: -1;
234
+		$reg_status   = isset($this->_req_data['_reg_status'])
235
+			? $this->_req_data['_reg_status']
236
+			: '';
237
+		$filters[]    = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category);
238
+		$filters[]    = EEH_Form_Fields::generate_event_category_dropdown($cur_category);
239
+		$status       = [];
240
+		$status[]     = ['id' => 0, 'text' => esc_html__('Select Status', 'event_espresso')];
241
+		foreach ($this->_status as $key => $value) {
242
+			$status[] = ['id' => $key, 'text' => $value];
243
+		}
244
+		if ($this->_view !== 'incomplete') {
245
+			$filters[] = EEH_Form_Fields::select_input(
246
+				'_reg_status',
247
+				$status,
248
+				isset($this->_req_data['_reg_status'])
249
+					? strtoupper(sanitize_key($this->_req_data['_reg_status']))
250
+					: ''
251
+			);
252
+		}
253
+		if (isset($this->_req_data['event_id'])) {
254
+			$filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id');
255
+		}
256
+		return $filters;
257
+	}
258
+
259
+
260
+	/**
261
+	 * @return void
262
+	 * @throws EE_Error
263
+	 * @throws InvalidArgumentException
264
+	 * @throws InvalidDataTypeException
265
+	 * @throws InvalidInterfaceException
266
+	 */
267
+	protected function _add_view_counts()
268
+	{
269
+		$this->_views['all']['count']   = $this->_total_registrations();
270
+		$this->_views['month']['count'] = $this->_total_registrations_this_month();
271
+		$this->_views['today']['count'] = $this->_total_registrations_today();
272
+		if (
273
+			EE_Registry::instance()->CAP->current_user_can(
274
+				'ee_delete_registrations',
275
+				'espresso_registrations_trash_registrations'
276
+			)
277
+		) {
278
+			$this->_views['incomplete']['count'] = $this->_total_registrations('incomplete');
279
+			$this->_views['trash']['count']      = $this->_total_registrations('trash');
280
+		}
281
+	}
282
+
283
+
284
+	/**
285
+	 * @param string $view
286
+	 * @return int
287
+	 * @throws EE_Error
288
+	 * @throws InvalidArgumentException
289
+	 * @throws InvalidDataTypeException
290
+	 * @throws InvalidInterfaceException
291
+	 */
292
+	protected function _total_registrations($view = '')
293
+	{
294
+		$_where = [];
295
+		$EVT_ID = isset($this->_req_data['event_id'])
296
+			? absint($this->_req_data['event_id'])
297
+			: false;
298
+		if ($EVT_ID) {
299
+			$_where['EVT_ID'] = $EVT_ID;
300
+		}
301
+		switch ($view) {
302
+			case 'trash':
303
+				return EEM_Registration::instance()->count_deleted([$_where]);
304
+			case 'incomplete':
305
+				$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
306
+				break;
307
+			default:
308
+				$_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
309
+		}
310
+		return EEM_Registration::instance()->count([$_where]);
311
+	}
312
+
313
+
314
+	/**
315
+	 * @return int
316
+	 * @throws EE_Error
317
+	 * @throws InvalidArgumentException
318
+	 * @throws InvalidDataTypeException
319
+	 * @throws InvalidInterfaceException
320
+	 */
321
+	protected function _total_registrations_this_month()
322
+	{
323
+		$EVT_ID          = isset($this->_req_data['event_id'])
324
+			? absint($this->_req_data['event_id'])
325
+			: false;
326
+		$_where          = $EVT_ID
327
+			? ['EVT_ID' => $EVT_ID]
328
+			: [];
329
+		$this_year_r     = date('Y', current_time('timestamp'));
330
+		$time_start      = ' 00:00:00';
331
+		$time_end        = ' 23:59:59';
332
+		$this_month_r    = date('m', current_time('timestamp'));
333
+		$days_this_month = date('t', current_time('timestamp'));
334
+		// setup date query.
335
+		$beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
336
+			'REG_date',
337
+			$this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
338
+			'Y-m-d H:i:s'
339
+		);
340
+		$end_string         = EEM_Registration::instance()->convert_datetime_for_query(
341
+			'REG_date',
342
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
343
+			'Y-m-d H:i:s'
344
+		);
345
+		$_where['REG_date'] = [
346
+			'BETWEEN',
347
+			[
348
+				$beginning_string,
349
+				$end_string,
350
+			],
351
+		];
352
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
353
+		return EEM_Registration::instance()->count([$_where]);
354
+	}
355
+
356
+
357
+	/**
358
+	 * @return int
359
+	 * @throws EE_Error
360
+	 * @throws InvalidArgumentException
361
+	 * @throws InvalidDataTypeException
362
+	 * @throws InvalidInterfaceException
363
+	 */
364
+	protected function _total_registrations_today()
365
+	{
366
+		$EVT_ID             = isset($this->_req_data['event_id'])
367
+			? absint($this->_req_data['event_id'])
368
+			: false;
369
+		$_where             = $EVT_ID
370
+			? ['EVT_ID' => $EVT_ID]
371
+			: [];
372
+		$current_date       = date('Y-m-d', current_time('timestamp'));
373
+		$time_start         = ' 00:00:00';
374
+		$time_end           = ' 23:59:59';
375
+		$_where['REG_date'] = [
376
+			'BETWEEN',
377
+			[
378
+				EEM_Registration::instance()->convert_datetime_for_query(
379
+					'REG_date',
380
+					$current_date . $time_start,
381
+					'Y-m-d H:i:s'
382
+				),
383
+				EEM_Registration::instance()->convert_datetime_for_query(
384
+					'REG_date',
385
+					$current_date . $time_end,
386
+					'Y-m-d H:i:s'
387
+				),
388
+			],
389
+		];
390
+		$_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
391
+		return EEM_Registration::instance()->count([$_where]);
392
+	}
393
+
394
+
395
+	/**
396
+	 * @param EE_Registration $item
397
+	 * @return string
398
+	 * @throws EE_Error
399
+	 * @throws InvalidArgumentException
400
+	 * @throws InvalidDataTypeException
401
+	 * @throws InvalidInterfaceException
402
+	 * @throws ReflectionException
403
+	 */
404
+	public function column_cb($item)
405
+	{
406
+		/** checkbox/lock **/
407
+		$transaction   = $item->get_first_related('Transaction');
408
+		$payment_count = $transaction instanceof EE_Transaction
409
+			? $transaction->count_related('Payment')
410
+			: 0;
411
+		return $payment_count > 0 || ! EE_Registry::instance()->CAP->current_user_can(
412
+			'ee_edit_registration',
413
+			'registration_list_table_checkbox_input',
414
+			$item->ID()
415
+		)
416
+			? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID())
417
+			  . '<span class="ee-lock-icon"></span>'
418
+			: sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$d" />', $item->ID());
419
+	}
420
+
421
+
422
+	/**
423
+	 * @param EE_Registration $item
424
+	 * @return string
425
+	 * @throws EE_Error
426
+	 * @throws InvalidArgumentException
427
+	 * @throws InvalidDataTypeException
428
+	 * @throws InvalidInterfaceException
429
+	 * @throws ReflectionException
430
+	 */
431
+	public function column__REG_ID(EE_Registration $item)
432
+	{
433
+		$attendee = $item->attendee();
434
+		$content  = $item->ID();
435
+		$content  .= '<div class="show-on-mobile-view-only">';
436
+		$content  .= '<br>';
437
+		$content  .= $attendee instanceof EE_Attendee
438
+			? $attendee->full_name()
439
+			: '';
440
+		$content  .= '&nbsp;';
441
+		$content  .= sprintf(
442
+			esc_html__('(%1$s / %2$s)', 'event_espresso'),
443
+			$item->count(),
444
+			$item->group_size()
445
+		);
446
+		$content  .= '<br>';
447
+		$content  .= sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
448
+		$content  .= '</div>';
449
+		return $content;
450
+	}
451
+
452
+
453
+	/**
454
+	 * @param EE_Registration $item
455
+	 * @return string
456
+	 * @throws EE_Error
457
+	 * @throws InvalidArgumentException
458
+	 * @throws InvalidDataTypeException
459
+	 * @throws InvalidInterfaceException
460
+	 * @throws ReflectionException
461
+	 */
462
+	public function column__REG_date(EE_Registration $item)
463
+	{
464
+		$this->_set_related_details($item);
465
+		// Build row actions
466
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
467
+			[
468
+				'action' => 'view_transaction',
469
+				'TXN_ID' => $this->_transaction_details['id'],
470
+			],
471
+			TXN_ADMIN_URL
472
+		);
473
+		$view_link    = EE_Registry::instance()->CAP->current_user_can(
474
+			'ee_read_transaction',
475
+			'espresso_transactions_view_transaction'
476
+		)
477
+			? '<a class="ee-status-color-'
478
+			  . $this->_transaction_details['status']
479
+			  . '" href="'
480
+			  . $view_lnk_url
481
+			  . '" title="'
482
+			  . esc_attr($this->_transaction_details['title_attr'])
483
+			  . '">'
484
+			  . $item->get_i18n_datetime('REG_date')
485
+			  . '</a>'
486
+			: $item->get_i18n_datetime('REG_date');
487
+		$view_link    .= '<br><span class="ee-status-text-small">'
488
+						 . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
489
+						 . '</span>';
490
+		return $view_link;
491
+	}
492
+
493
+
494
+	/**
495
+	 * @param EE_Registration $item
496
+	 * @return string
497
+	 * @throws EE_Error
498
+	 * @throws InvalidArgumentException
499
+	 * @throws InvalidDataTypeException
500
+	 * @throws InvalidInterfaceException
501
+	 * @throws ReflectionException
502
+	 */
503
+	public function column_event_name(EE_Registration $item)
504
+	{
505
+		$this->_set_related_details($item);
506
+		// page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62
507
+		$EVT_ID     = $item->event_ID();
508
+		$event_name = $item->event_name();
509
+		$event_name =
510
+			$event_name
511
+				?: esc_html__("No Associated Event", 'event_espresso');
512
+		$event_name = wp_trim_words($event_name, 30, '...');
513
+		if ($EVT_ID) {
514
+			$edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
515
+				['action' => 'edit', 'post' => $EVT_ID],
516
+				EVENTS_ADMIN_URL
517
+			);
518
+			$edit_event              =
519
+				EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
520
+					? '<a class="ee-status-color-'
521
+					  . $this->_event_details['status']
522
+					  . '" href="'
523
+					  . $edit_event_url
524
+					  . '" title="'
525
+					  . esc_attr($this->_event_details['title_attr'])
526
+					  . '">'
527
+					  . $event_name
528
+					  . '</a>'
529
+					: $event_name;
530
+			$edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
531
+			$actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
532
+			$actions['event_filter'] .= sprintf(
533
+				esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
534
+				$event_name
535
+			);
536
+			$actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
537
+		} else {
538
+			$edit_event              = $event_name;
539
+			$actions['event_filter'] = '';
540
+		}
541
+		return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions));
542
+	}
543
+
544
+
545
+	/**
546
+	 * @param EE_Registration $item
547
+	 * @return string
548
+	 * @throws EE_Error
549
+	 * @throws InvalidArgumentException
550
+	 * @throws InvalidDataTypeException
551
+	 * @throws InvalidInterfaceException
552
+	 * @throws ReflectionException
553
+	 */
554
+	public function column_DTT_EVT_start(EE_Registration $item)
555
+	{
556
+		$datetime_strings = [];
557
+		$ticket           = $item->ticket();
558
+		if ($ticket instanceof EE_Ticket) {
559
+			$remove_defaults = ['default_where_conditions' => 'none'];
560
+			$datetimes       = $ticket->datetimes($remove_defaults);
561
+			foreach ($datetimes as $datetime) {
562
+				$datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start');
563
+			}
564
+			return $this->generateDisplayForDatetimes($datetime_strings);
565
+		}
566
+		return esc_html__('There is no ticket on this registration', 'event_espresso');
567
+	}
568
+
569
+
570
+	/**
571
+	 * Receives an array of datetime strings to display and converts them to the html container for the column.
572
+	 *
573
+	 * @param array $datetime_strings
574
+	 * @return string
575
+	 */
576
+	public function generateDisplayForDateTimes(array $datetime_strings)
577
+	{
578
+		$content       = '<div class="ee-registration-event-datetimes-container">';
579
+		$expand_toggle = count($datetime_strings) > 1
580
+			? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
581
+			  . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
582
+			: '';
583
+		// get first item for initial visibility
584
+		$content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
585
+		$content .= $expand_toggle;
586
+		if ($datetime_strings) {
587
+			$content .= '<div style="clear:both"></div>';
588
+			$content .= '<div class="ee-registration-event-datetimes-container more-items hidden">';
589
+			$content .= implode("<br />", $datetime_strings);
590
+			$content .= '</div>';
591
+		}
592
+		$content .= '</div>';
593
+		return $content;
594
+	}
595
+
596
+
597
+	/**
598
+	 * @param EE_Registration $item
599
+	 * @return string
600
+	 * @throws EE_Error
601
+	 * @throws InvalidArgumentException
602
+	 * @throws InvalidDataTypeException
603
+	 * @throws InvalidInterfaceException
604
+	 * @throws ReflectionException
605
+	 */
606
+	public function column_ATT_fname(EE_Registration $item)
607
+	{
608
+		$attendee      = $item->attendee();
609
+		$edit_lnk_url  = EE_Admin_Page::add_query_args_and_nonce(
610
+			[
611
+				'action'  => 'view_registration',
612
+				'_REG_ID' => $item->ID(),
613
+			],
614
+			REG_ADMIN_URL
615
+		);
616
+		$attendee_name = $attendee instanceof EE_Attendee
617
+			? $attendee->full_name()
618
+			: '';
619
+		$link          = EE_Registry::instance()->CAP->current_user_can(
620
+			'ee_read_registration',
621
+			'espresso_registrations_view_registration',
622
+			$item->ID()
623
+		)
624
+			? '<a href="'
625
+			  . $edit_lnk_url
626
+			  . '" title="'
627
+			  . esc_attr__('View Registration Details', 'event_espresso')
628
+			  . '">'
629
+			  . $attendee_name
630
+			  . '</a>'
631
+			: $attendee_name;
632
+		$link          .= $item->count() === 1
633
+			? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>'
634
+			: '';
635
+		$t             = $item->get_first_related('Transaction');
636
+		$payment_count = $t instanceof EE_Transaction
637
+			? $t->count_related('Payment')
638
+			: 0;
639
+		// append group count to name
640
+		$link .= '&nbsp;' . sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
641
+		// append reg_code
642
+		$link .= '<br>' . sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
643
+		// reg status text for accessibility
644
+		$link   .= '<br><span class="ee-status-text-small">'
645
+				   . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
646
+				   . '</span>';
647
+		$action = ['_REG_ID' => $item->ID()];
648
+		if (isset($this->_req_data['event_id'])) {
649
+			$action['event_id'] = $item->event_ID();
650
+		}
651
+		// trash/restore/delete actions
652
+		$actions = [];
653
+		if (
654
+			$this->_view !== 'trash'
655
+			&& $payment_count === 0
656
+			&& EE_Registry::instance()->CAP->current_user_can(
657
+				'ee_delete_registration',
658
+				'espresso_registrations_trash_registrations',
659
+				$item->ID()
660
+			)
661
+		) {
662
+			$action['action'] = 'trash_registrations';
663
+			$trash_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
664
+				$action,
665
+				REG_ADMIN_URL
666
+			);
667
+			$actions['trash'] = '<a href="'
668
+								. $trash_lnk_url
669
+								. '" title="'
670
+								. esc_attr__('Trash Registration', 'event_espresso')
671
+								. '">' . esc_html__('Trash', 'event_espresso') . '</a>';
672
+		} elseif ($this->_view === 'trash') {
673
+			// restore registration link
674
+			if (
675
+				EE_Registry::instance()->CAP->current_user_can(
676
+					'ee_delete_registration',
677
+					'espresso_registrations_restore_registrations',
678
+					$item->ID()
679
+				)
680
+			) {
681
+				$action['action']   = 'restore_registrations';
682
+				$restore_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
683
+					$action,
684
+					REG_ADMIN_URL
685
+				);
686
+				$actions['restore'] = '<a href="'
687
+									  . $restore_lnk_url
688
+									  . '" title="'
689
+									  . esc_attr__('Restore Registration', 'event_espresso') . '">'
690
+									  . esc_html__('Restore', 'event_espresso') . '</a>';
691
+			}
692
+			if (
693
+				EE_Registry::instance()->CAP->current_user_can(
694
+					'ee_delete_registration',
695
+					'espresso_registrations_ee_delete_registrations',
696
+					$item->ID()
697
+				)
698
+			) {
699
+				$action['action']  = 'delete_registrations';
700
+				$delete_lnk_url    = EE_Admin_Page::add_query_args_and_nonce(
701
+					$action,
702
+					REG_ADMIN_URL
703
+				);
704
+				$actions['delete'] = '<a href="'
705
+									 . $delete_lnk_url
706
+									 . '" title="'
707
+									 . esc_attr__('Delete Registration Permanently', 'event_espresso')
708
+									 . '">'
709
+									 . esc_html__('Delete', 'event_espresso')
710
+									 . '</a>';
711
+			}
712
+		}
713
+		return sprintf('%1$s %2$s', $link, $this->row_actions($actions));
714
+	}
715
+
716
+
717
+	/**
718
+	 * @param EE_Registration $item
719
+	 * @return string
720
+	 * @throws EE_Error
721
+	 * @throws InvalidArgumentException
722
+	 * @throws InvalidDataTypeException
723
+	 * @throws InvalidInterfaceException
724
+	 * @throws ReflectionException
725
+	 */
726
+	public function column_ATT_email(EE_Registration $item)
727
+	{
728
+		$attendee = $item->get_first_related('Attendee');
729
+		return ! $attendee instanceof EE_Attendee
730
+			? esc_html__('No attached contact record.', 'event_espresso')
731
+			: $attendee->email();
732
+	}
733
+
734
+
735
+	/**
736
+	 * @param EE_Registration $item
737
+	 * @return string
738
+	 */
739
+	public function column__REG_count(EE_Registration $item)
740
+	{
741
+		return sprintf(esc_html__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size());
742
+	}
743
+
744
+
745
+	/**
746
+	 * @param EE_Registration $item
747
+	 * @return string
748
+	 * @throws EE_Error
749
+	 * @throws ReflectionException
750
+	 */
751
+	public function column_PRC_amount(EE_Registration $item)
752
+	{
753
+		$ticket   = $item->ticket();
754
+		$req_data = $this->_admin_page->get_request_data();
755
+		$content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
756
+			? '<span class="TKT_name">' . $ticket->name() . '</span><br />'
757
+			: '';
758
+		if ($item->final_price() > 0) {
759
+			$content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
760
+		} else {
761
+			// free event
762
+			$content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
763
+						. esc_html__('free', 'event_espresso')
764
+						. '</span>';
765
+		}
766
+		return $content;
767
+	}
768
+
769
+
770
+	/**
771
+	 * @param EE_Registration $item
772
+	 * @return string
773
+	 * @throws EE_Error
774
+	 * @throws ReflectionException
775
+	 */
776
+	public function column__REG_final_price(EE_Registration $item)
777
+	{
778
+		$ticket   = $item->ticket();
779
+		$req_data = $this->_admin_page->get_request_data();
780
+		$content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
781
+			? ''
782
+			: '<span class="TKT_name">' . $ticket->name() . '</span><br />';
783
+		$content  .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
784
+		return $content;
785
+	}
786
+
787
+
788
+	/**
789
+	 * @param EE_Registration $item
790
+	 * @return string
791
+	 * @throws EE_Error
792
+	 */
793
+	public function column__REG_paid(EE_Registration $item)
794
+	{
795
+		$payment_method      = $item->payment_method();
796
+		$payment_method_name = $payment_method instanceof EE_Payment_Method
797
+			? $payment_method->admin_name()
798
+			: esc_html__('Unknown', 'event_espresso');
799
+		$content             = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
800
+		if ($item->paid() > 0) {
801
+			$content .= '<br><span class="ee-status-text-small">'
802
+						. sprintf(
803
+							esc_html__('...via %s', 'event_espresso'),
804
+							$payment_method_name
805
+						)
806
+						. '</span>';
807
+		}
808
+		return $content;
809
+	}
810
+
811
+
812
+	/**
813
+	 * @param EE_Registration $item
814
+	 * @return string
815
+	 * @throws EE_Error
816
+	 * @throws EntityNotFoundException
817
+	 * @throws InvalidArgumentException
818
+	 * @throws InvalidDataTypeException
819
+	 * @throws InvalidInterfaceException
820
+	 * @throws ReflectionException
821
+	 */
822
+	public function column_TXN_total(EE_Registration $item)
823
+	{
824
+		if ($item->transaction()) {
825
+			$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
826
+				[
827
+					'action' => 'view_transaction',
828
+					'TXN_ID' => $item->transaction_ID(),
829
+				],
830
+				TXN_ADMIN_URL
831
+			);
832
+			return EE_Registry::instance()->CAP->current_user_can(
833
+				'ee_read_transaction',
834
+				'espresso_transactions_view_transaction',
835
+				$item->transaction_ID()
836
+			)
837
+				? '<span class="reg-pad-rght"><a class="status-'
838
+				  . $item->transaction()->status_ID()
839
+				  . '" href="'
840
+				  . $view_txn_lnk_url
841
+				  . '"  title="'
842
+				  . esc_attr__('View Transaction', 'event_espresso')
843
+				  . '">'
844
+				  . $item->transaction()->pretty_total()
845
+				  . '</a></span>'
846
+				: '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
847
+		} else {
848
+			return esc_html__("None", "event_espresso");
849
+		}
850
+	}
851
+
852
+
853
+	/**
854
+	 * @param EE_Registration $item
855
+	 * @return string
856
+	 * @throws EE_Error
857
+	 * @throws EntityNotFoundException
858
+	 * @throws InvalidArgumentException
859
+	 * @throws InvalidDataTypeException
860
+	 * @throws InvalidInterfaceException
861
+	 * @throws ReflectionException
862
+	 */
863
+	public function column_TXN_paid(EE_Registration $item)
864
+	{
865
+		if ($item->count() === 1) {
866
+			$transaction = $item->transaction()
867
+				? $item->transaction()
868
+				: EE_Transaction::new_instance();
869
+			if ($transaction->paid() >= $transaction->total()) {
870
+				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
871
+			} else {
872
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
873
+					[
874
+						'action' => 'view_transaction',
875
+						'TXN_ID' => $item->transaction_ID(),
876
+					],
877
+					TXN_ADMIN_URL
878
+				);
879
+				return EE_Registry::instance()->CAP->current_user_can(
880
+					'ee_read_transaction',
881
+					'espresso_transactions_view_transaction',
882
+					$item->transaction_ID()
883
+				)
884
+					? '<span class="reg-pad-rght"><a class="status-'
885
+					  . $transaction->status_ID()
886
+					  . '" href="'
887
+					  . $view_txn_lnk_url
888
+					  . '"  title="'
889
+					  . esc_attr__('View Transaction', 'event_espresso')
890
+					  . '">'
891
+					  . $item->transaction()->pretty_paid()
892
+					  . '</a><span>'
893
+					: '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
894
+			}
895
+		}
896
+		return '&nbsp;';
897
+	}
898
+
899
+
900
+	/**
901
+	 * column_actions
902
+	 *
903
+	 * @param EE_Registration $item
904
+	 * @return string
905
+	 * @throws EE_Error
906
+	 * @throws InvalidArgumentException
907
+	 * @throws InvalidDataTypeException
908
+	 * @throws InvalidInterfaceException
909
+	 * @throws ReflectionException
910
+	 */
911
+	public function column_actions(EE_Registration $item)
912
+	{
913
+		$actions  = [];
914
+		$attendee = $item->attendee();
915
+		$this->_set_related_details($item);
916
+
917
+		// Build row actions
918
+		if (
919
+			EE_Registry::instance()->CAP->current_user_can(
920
+				'ee_read_registration',
921
+				'espresso_registrations_view_registration',
922
+				$item->ID()
923
+			)
924
+		) {
925
+			$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
926
+				[
927
+					'action'  => 'view_registration',
928
+					'_REG_ID' => $item->ID(),
929
+				],
930
+				REG_ADMIN_URL
931
+			);
932
+			$actions['view_lnk'] = '
933 933
             <li>
934 934
                 <a href="' . $view_lnk_url . '" title="'
935
-                . esc_attr__('View Registration Details', 'event_espresso')
936
-                . '" class="tiny-text">
935
+				. esc_attr__('View Registration Details', 'event_espresso')
936
+				. '" class="tiny-text">
937 937
 				    <div class="dashicons dashicons-clipboard"></div>
938 938
 			    </a>
939 939
 			</li>';
940
-        }
941
-
942
-        if (
943
-            $attendee instanceof EE_Attendee
944
-            && EE_Registry::instance()->CAP->current_user_can(
945
-                'ee_edit_contacts',
946
-                'espresso_registrations_edit_attendee'
947
-            )
948
-        ) {
949
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
950
-                [
951
-                    'action' => 'edit_attendee',
952
-                    'post'   => $item->attendee_ID(),
953
-                ],
954
-                REG_ADMIN_URL
955
-            );
956
-            $actions['edit_lnk'] = '
940
+		}
941
+
942
+		if (
943
+			$attendee instanceof EE_Attendee
944
+			&& EE_Registry::instance()->CAP->current_user_can(
945
+				'ee_edit_contacts',
946
+				'espresso_registrations_edit_attendee'
947
+			)
948
+		) {
949
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
950
+				[
951
+					'action' => 'edit_attendee',
952
+					'post'   => $item->attendee_ID(),
953
+				],
954
+				REG_ADMIN_URL
955
+			);
956
+			$actions['edit_lnk'] = '
957 957
 			<li>
958 958
                 <a href="' . $edit_lnk_url . '" title="'
959
-                . esc_attr__('Edit Contact Details', 'event_espresso')
960
-                . '" class="tiny-text">
959
+				. esc_attr__('Edit Contact Details', 'event_espresso')
960
+				. '" class="tiny-text">
961 961
                     <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
962 962
                 </a>
963 963
 			</li>';
964
-        }
965
-
966
-        if (
967
-            $attendee instanceof EE_Attendee
968
-            && EE_Registry::instance()->CAP->current_user_can(
969
-                'ee_send_message',
970
-                'espresso_registrations_resend_registration',
971
-                $item->ID()
972
-            )
973
-        ) {
974
-            $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
975
-                [
976
-                    'action'  => 'resend_registration',
977
-                    '_REG_ID' => $item->ID(),
978
-                ],
979
-                REG_ADMIN_URL,
980
-                true
981
-            );
982
-            $actions['resend_reg_lnk'] = '
964
+		}
965
+
966
+		if (
967
+			$attendee instanceof EE_Attendee
968
+			&& EE_Registry::instance()->CAP->current_user_can(
969
+				'ee_send_message',
970
+				'espresso_registrations_resend_registration',
971
+				$item->ID()
972
+			)
973
+		) {
974
+			$resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
975
+				[
976
+					'action'  => 'resend_registration',
977
+					'_REG_ID' => $item->ID(),
978
+				],
979
+				REG_ADMIN_URL,
980
+				true
981
+			);
982
+			$actions['resend_reg_lnk'] = '
983 983
 			<li>
984 984
 			    <a href="' . $resend_reg_lnk_url . '" title="'
985
-                . esc_attr__('Resend Registration Details', 'event_espresso')
986
-                . '" class="tiny-text">
985
+				. esc_attr__('Resend Registration Details', 'event_espresso')
986
+				. '" class="tiny-text">
987 987
 			        <div class="dashicons dashicons-email-alt"></div>
988 988
 			    </a>
989 989
             </li>';
990
-        }
991
-
992
-        if (
993
-            EE_Registry::instance()->CAP->current_user_can(
994
-                'ee_read_transaction',
995
-                'espresso_transactions_view_transaction',
996
-                $this->_transaction_details['id']
997
-            )
998
-        ) {
999
-            $view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
1000
-                [
1001
-                    'action' => 'view_transaction',
1002
-                    'TXN_ID' => $this->_transaction_details['id'],
1003
-                ],
1004
-                TXN_ADMIN_URL
1005
-            );
1006
-            $actions['view_txn_lnk'] = '
990
+		}
991
+
992
+		if (
993
+			EE_Registry::instance()->CAP->current_user_can(
994
+				'ee_read_transaction',
995
+				'espresso_transactions_view_transaction',
996
+				$this->_transaction_details['id']
997
+			)
998
+		) {
999
+			$view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
1000
+				[
1001
+					'action' => 'view_transaction',
1002
+					'TXN_ID' => $this->_transaction_details['id'],
1003
+				],
1004
+				TXN_ADMIN_URL
1005
+			);
1006
+			$actions['view_txn_lnk'] = '
1007 1007
 			<li>
1008 1008
                 <a class="ee-status-color-' . $this->_transaction_details['status']
1009
-                . ' tiny-text" href="' . $view_txn_lnk_url
1010
-                . '"  title="' . $this->_transaction_details['title_attr'] . '">
1009
+				. ' tiny-text" href="' . $view_txn_lnk_url
1010
+				. '"  title="' . $this->_transaction_details['title_attr'] . '">
1011 1011
                     <div class="dashicons dashicons-cart"></div>
1012 1012
                 </a>
1013 1013
 			</li>';
1014
-        }
1015
-
1016
-        // only show invoice link if message type is active.
1017
-        if (
1018
-            $attendee instanceof EE_Attendee
1019
-            && $item->is_primary_registrant()
1020
-            && EEH_MSG_Template::is_mt_active('invoice')
1021
-        ) {
1022
-            $actions['dl_invoice_lnk'] = '
1014
+		}
1015
+
1016
+		// only show invoice link if message type is active.
1017
+		if (
1018
+			$attendee instanceof EE_Attendee
1019
+			&& $item->is_primary_registrant()
1020
+			&& EEH_MSG_Template::is_mt_active('invoice')
1021
+		) {
1022
+			$actions['dl_invoice_lnk'] = '
1023 1023
             <li>
1024 1024
                 <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso')
1025
-                . '" target="_blank" href="' . $item->invoice_url() . '" class="tiny-text">
1025
+				. '" target="_blank" href="' . $item->invoice_url() . '" class="tiny-text">
1026 1026
                     <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
1027 1027
                 </a>
1028 1028
             </li>';
1029
-        }
1029
+		}
1030 1030
 
1031
-        // message list table link (filtered by REG_ID
1032
-        if (
1033
-            EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')
1034
-        ) {
1035
-            $actions['filtered_messages_link'] = '
1031
+		// message list table link (filtered by REG_ID
1032
+		if (
1033
+			EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')
1034
+		) {
1035
+			$actions['filtered_messages_link'] = '
1036 1036
             <li>
1037 1037
                 ' . EEH_MSG_Template::get_message_action_link(
1038
-                'see_notifications_for',
1039
-                null,
1040
-                ['_REG_ID' => $item->ID()]
1041
-            ) . '
1038
+				'see_notifications_for',
1039
+				null,
1040
+				['_REG_ID' => $item->ID()]
1041
+			) . '
1042 1042
             </li>';
1043
-        }
1043
+		}
1044 1044
 
1045
-        $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1046
-        return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
1047
-    }
1045
+		$actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this);
1046
+		return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul');
1047
+	}
1048 1048
 }
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
     public function __construct(Registrations_Admin_Page $admin_page)
50 50
     {
51 51
         $req_data = $admin_page->get_request_data();
52
-        if (! empty($req_data['event_id'])) {
52
+        if ( ! empty($req_data['event_id'])) {
53 53
             $extra_query_args = [];
54 54
             foreach ($admin_page->get_views() as $view_details) {
55
-                $extra_query_args[ $view_details['slug'] ] = ['event_id' => $req_data['event_id']];
55
+                $extra_query_args[$view_details['slug']] = ['event_id' => $req_data['event_id']];
56 56
             }
57 57
             $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args);
58 58
         }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             'ajax'     => true,
85 85
             'screen'   => $this->_admin_page->get_current_screen()->id,
86 86
         ];
87
-        $ID_column_name      = esc_html__('ID', 'event_espresso');
87
+        $ID_column_name = esc_html__('ID', 'event_espresso');
88 88
         $ID_column_name      .= ' : <span class="show-on-mobile-view-only" style="float:none">';
89 89
         $ID_column_name      .= esc_html__('Registrant Name', 'event_espresso');
90 90
         $ID_column_name      .= '</span> ';
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
         $DTT_ID = $this->_req_data['DTT_ID'] ?? 0;
94 94
 
95 95
         if ($EVT_ID) {
96
-            $this->_columns        = [
96
+            $this->_columns = [
97 97
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
98 98
                 '_REG_ID'          => $ID_column_name,
99 99
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                 'actions'          => esc_html__('Actions', 'event_espresso'),
107 107
             ];
108 108
         } else {
109
-            $this->_columns        = [
109
+            $this->_columns = [
110 110
                 'cb'               => '<input type="checkbox" />', // Render a checkbox instead of text
111 111
                 '_REG_ID'          => $ID_column_name,
112 112
                 'ATT_fname'        => esc_html__('Name', 'event_espresso'),
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
         }
121 121
 
122 122
         $csv_report = RegistrationsCsvReportParams::getRequestParams($return_url, $this->_req_data, $EVT_ID, $DTT_ID);
123
-        if (! empty($csv_report)) {
123
+        if ( ! empty($csv_report)) {
124 124
             $this->_bottom_buttons['csv_reg_report'] = $csv_report;
125 125
         }
126 126
 
127 127
         $this->_primary_column   = '_REG_ID';
128 128
         $this->_sortable_columns = [
129
-            '_REG_date'     => ['_REG_date' => true],   // true means its already sorted
129
+            '_REG_date'     => ['_REG_date' => true], // true means its already sorted
130 130
             /**
131 131
              * Allows users to change the default sort if they wish.
132 132
              * Returning a falsey on this filter will result in the default sort to be by firstname rather than last
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
             'DTT_EVT_start' => ['DTT_EVT_start' => false],
144 144
             '_REG_ID'       => ['_REG_ID' => false],
145 145
         ];
146
-        $this->_hidden_columns   = [];
146
+        $this->_hidden_columns = [];
147 147
     }
148 148
 
149 149
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     {
159 159
         $class = parent::_get_row_class($item);
160 160
         // add status class
161
-        $class .= ' ee-status-strip reg-status-' . $item->status_ID();
161
+        $class .= ' ee-status-strip reg-status-'.$item->status_ID();
162 162
         if ($this->_has_checkbox_column) {
163 163
             $class .= ' has-checkbox-column';
164 164
         }
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
         $this_month_r    = date('m', current_time('timestamp'));
333 333
         $days_this_month = date('t', current_time('timestamp'));
334 334
         // setup date query.
335
-        $beginning_string   = EEM_Registration::instance()->convert_datetime_for_query(
335
+        $beginning_string = EEM_Registration::instance()->convert_datetime_for_query(
336 336
             'REG_date',
337
-            $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start,
337
+            $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start,
338 338
             'Y-m-d H:i:s'
339 339
         );
340
-        $end_string         = EEM_Registration::instance()->convert_datetime_for_query(
340
+        $end_string = EEM_Registration::instance()->convert_datetime_for_query(
341 341
             'REG_date',
342
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end,
342
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end,
343 343
             'Y-m-d H:i:s'
344 344
         );
345 345
         $_where['REG_date'] = [
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
                 $end_string,
350 350
             ],
351 351
         ];
352
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
352
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
353 353
         return EEM_Registration::instance()->count([$_where]);
354 354
     }
355 355
 
@@ -377,17 +377,17 @@  discard block
 block discarded – undo
377 377
             [
378 378
                 EEM_Registration::instance()->convert_datetime_for_query(
379 379
                     'REG_date',
380
-                    $current_date . $time_start,
380
+                    $current_date.$time_start,
381 381
                     'Y-m-d H:i:s'
382 382
                 ),
383 383
                 EEM_Registration::instance()->convert_datetime_for_query(
384 384
                     'REG_date',
385
-                    $current_date . $time_end,
385
+                    $current_date.$time_end,
386 386
                     'Y-m-d H:i:s'
387 387
                 ),
388 388
             ],
389 389
         ];
390
-        $_where['STS_ID']   = ['!=', EEM_Registration::status_id_incomplete];
390
+        $_where['STS_ID'] = ['!=', EEM_Registration::status_id_incomplete];
391 391
         return EEM_Registration::instance()->count([$_where]);
392 392
     }
393 393
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
             ],
471 471
             TXN_ADMIN_URL
472 472
         );
473
-        $view_link    = EE_Registry::instance()->CAP->current_user_can(
473
+        $view_link = EE_Registry::instance()->CAP->current_user_can(
474 474
             'ee_read_transaction',
475 475
             'espresso_transactions_view_transaction'
476 476
         )
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
               . $item->get_i18n_datetime('REG_date')
485 485
               . '</a>'
486 486
             : $item->get_i18n_datetime('REG_date');
487
-        $view_link    .= '<br><span class="ee-status-text-small">'
487
+        $view_link .= '<br><span class="ee-status-text-small">'
488 488
                          . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence')
489 489
                          . '</span>';
490 490
         return $view_link;
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
                 ?: esc_html__("No Associated Event", 'event_espresso');
512 512
         $event_name = wp_trim_words($event_name, 30, '...');
513 513
         if ($EVT_ID) {
514
-            $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(
514
+            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
515 515
                 ['action' => 'edit', 'post' => $EVT_ID],
516 516
                 EVENTS_ADMIN_URL
517 517
             );
518
-            $edit_event              =
518
+            $edit_event =
519 519
                 EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID)
520 520
                     ? '<a class="ee-status-color-'
521 521
                       . $this->_event_details['status']
@@ -528,12 +528,12 @@  discard block
 block discarded – undo
528 528
                       . '</a>'
529 529
                     : $event_name;
530 530
             $edit_event_url          = EE_Admin_Page::add_query_args_and_nonce(['event_id' => $EVT_ID], REG_ADMIN_URL);
531
-            $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="';
531
+            $actions['event_filter'] = '<a href="'.$edit_event_url.'" title="';
532 532
             $actions['event_filter'] .= sprintf(
533 533
                 esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'),
534 534
                 $event_name
535 535
             );
536
-            $actions['event_filter'] .= '">' . esc_html__('View Registrations', 'event_espresso') . '</a>';
536
+            $actions['event_filter'] .= '">'.esc_html__('View Registrations', 'event_espresso').'</a>';
537 537
         } else {
538 538
             $edit_event              = $event_name;
539 539
             $actions['event_filter'] = '';
@@ -577,11 +577,11 @@  discard block
 block discarded – undo
577 577
     {
578 578
         $content       = '<div class="ee-registration-event-datetimes-container">';
579 579
         $expand_toggle = count($datetime_strings) > 1
580
-            ? ' <span title="' . esc_attr__('Click to view all dates', 'event_espresso')
580
+            ? ' <span title="'.esc_attr__('Click to view all dates', 'event_espresso')
581 581
               . '" class="ee-js ee-more-datetimes-toggle dashicons dashicons-plus"></span>'
582 582
             : '';
583 583
         // get first item for initial visibility
584
-        $content .= '<div class="left">' . array_shift($datetime_strings) . '</div>';
584
+        $content .= '<div class="left">'.array_shift($datetime_strings).'</div>';
585 585
         $content .= $expand_toggle;
586 586
         if ($datetime_strings) {
587 587
             $content .= '<div style="clear:both"></div>';
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
               . $attendee_name
630 630
               . '</a>'
631 631
             : $attendee_name;
632
-        $link          .= $item->count() === 1
632
+        $link .= $item->count() === 1
633 633
             ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>'
634 634
             : '';
635 635
         $t             = $item->get_first_related('Transaction');
@@ -637,11 +637,11 @@  discard block
 block discarded – undo
637 637
             ? $t->count_related('Payment')
638 638
             : 0;
639 639
         // append group count to name
640
-        $link .= '&nbsp;' . sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
640
+        $link .= '&nbsp;'.sprintf(esc_html__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size());
641 641
         // append reg_code
642
-        $link .= '<br>' . sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
642
+        $link .= '<br>'.sprintf(esc_html__('Reg Code: %s', 'event_espresso'), $item->get('REG_code'));
643 643
         // reg status text for accessibility
644
-        $link   .= '<br><span class="ee-status-text-small">'
644
+        $link .= '<br><span class="ee-status-text-small">'
645 645
                    . EEH_Template::pretty_status($item->status_ID(), false, 'sentence')
646 646
                    . '</span>';
647 647
         $action = ['_REG_ID' => $item->ID()];
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
                                 . $trash_lnk_url
669 669
                                 . '" title="'
670 670
                                 . esc_attr__('Trash Registration', 'event_espresso')
671
-                                . '">' . esc_html__('Trash', 'event_espresso') . '</a>';
671
+                                . '">'.esc_html__('Trash', 'event_espresso').'</a>';
672 672
         } elseif ($this->_view === 'trash') {
673 673
             // restore registration link
674 674
             if (
@@ -686,8 +686,8 @@  discard block
 block discarded – undo
686 686
                 $actions['restore'] = '<a href="'
687 687
                                       . $restore_lnk_url
688 688
                                       . '" title="'
689
-                                      . esc_attr__('Restore Registration', 'event_espresso') . '">'
690
-                                      . esc_html__('Restore', 'event_espresso') . '</a>';
689
+                                      . esc_attr__('Restore Registration', 'event_espresso').'">'
690
+                                      . esc_html__('Restore', 'event_espresso').'</a>';
691 691
             }
692 692
             if (
693 693
                 EE_Registry::instance()->CAP->current_user_can(
@@ -753,10 +753,10 @@  discard block
 block discarded – undo
753 753
         $ticket   = $item->ticket();
754 754
         $req_data = $this->_admin_page->get_request_data();
755 755
         $content  = isset($req_data['event_id']) && $ticket instanceof EE_Ticket
756
-            ? '<span class="TKT_name">' . $ticket->name() . '</span><br />'
756
+            ? '<span class="TKT_name">'.$ticket->name().'</span><br />'
757 757
             : '';
758 758
         if ($item->final_price() > 0) {
759
-            $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
759
+            $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
760 760
         } else {
761 761
             // free event
762 762
             $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'
@@ -779,8 +779,8 @@  discard block
 block discarded – undo
779 779
         $req_data = $this->_admin_page->get_request_data();
780 780
         $content  = isset($req_data['event_id']) || ! $ticket instanceof EE_Ticket
781 781
             ? ''
782
-            : '<span class="TKT_name">' . $ticket->name() . '</span><br />';
783
-        $content  .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>';
782
+            : '<span class="TKT_name">'.$ticket->name().'</span><br />';
783
+        $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>';
784 784
         return $content;
785 785
     }
786 786
 
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
         $payment_method_name = $payment_method instanceof EE_Payment_Method
797 797
             ? $payment_method->admin_name()
798 798
             : esc_html__('Unknown', 'event_espresso');
799
-        $content             = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>';
799
+        $content             = '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>';
800 800
         if ($item->paid() > 0) {
801 801
             $content .= '<br><span class="ee-status-text-small">'
802 802
                         . sprintf(
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
                   . '">'
844 844
                   . $item->transaction()->pretty_total()
845 845
                   . '</a></span>'
846
-                : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>';
846
+                : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>';
847 847
         } else {
848 848
             return esc_html__("None", "event_espresso");
849 849
         }
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
                       . '">'
891 891
                       . $item->transaction()->pretty_paid()
892 892
                       . '</a><span>'
893
-                    : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
893
+                    : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
894 894
             }
895 895
         }
896 896
         return '&nbsp;';
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
             );
932 932
             $actions['view_lnk'] = '
933 933
             <li>
934
-                <a href="' . $view_lnk_url . '" title="'
934
+                <a href="' . $view_lnk_url.'" title="'
935 935
                 . esc_attr__('View Registration Details', 'event_espresso')
936 936
                 . '" class="tiny-text">
937 937
 				    <div class="dashicons dashicons-clipboard"></div>
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
             );
956 956
             $actions['edit_lnk'] = '
957 957
 			<li>
958
-                <a href="' . $edit_lnk_url . '" title="'
958
+                <a href="' . $edit_lnk_url.'" title="'
959 959
                 . esc_attr__('Edit Contact Details', 'event_espresso')
960 960
                 . '" class="tiny-text">
961 961
                     <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div>
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
             );
982 982
             $actions['resend_reg_lnk'] = '
983 983
 			<li>
984
-			    <a href="' . $resend_reg_lnk_url . '" title="'
984
+			    <a href="' . $resend_reg_lnk_url.'" title="'
985 985
                 . esc_attr__('Resend Registration Details', 'event_espresso')
986 986
                 . '" class="tiny-text">
987 987
 			        <div class="dashicons dashicons-email-alt"></div>
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
                 $this->_transaction_details['id']
997 997
             )
998 998
         ) {
999
-            $view_txn_lnk_url        = EE_Admin_Page::add_query_args_and_nonce(
999
+            $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
1000 1000
                 [
1001 1001
                     'action' => 'view_transaction',
1002 1002
                     'TXN_ID' => $this->_transaction_details['id'],
@@ -1006,8 +1006,8 @@  discard block
 block discarded – undo
1006 1006
             $actions['view_txn_lnk'] = '
1007 1007
 			<li>
1008 1008
                 <a class="ee-status-color-' . $this->_transaction_details['status']
1009
-                . ' tiny-text" href="' . $view_txn_lnk_url
1010
-                . '"  title="' . $this->_transaction_details['title_attr'] . '">
1009
+                . ' tiny-text" href="'.$view_txn_lnk_url
1010
+                . '"  title="'.$this->_transaction_details['title_attr'].'">
1011 1011
                     <div class="dashicons dashicons-cart"></div>
1012 1012
                 </a>
1013 1013
 			</li>';
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
             $actions['dl_invoice_lnk'] = '
1023 1023
             <li>
1024 1024
                 <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso')
1025
-                . '" target="_blank" href="' . $item->invoice_url() . '" class="tiny-text">
1025
+                . '" target="_blank" href="'.$item->invoice_url().'" class="tiny-text">
1026 1026
                     <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
1027 1027
                 </a>
1028 1028
             </li>';
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
                 'see_notifications_for',
1039 1039
                 null,
1040 1040
                 ['_REG_ID' => $item->ID()]
1041
-            ) . '
1041
+            ).'
1042 1042
             </li>';
1043 1043
         }
1044 1044
 
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 2 patches
Indentation   +3686 added lines, -3686 removed lines patch added patch discarded remove patch
@@ -20,2225 +20,2225 @@  discard block
 block discarded – undo
20 20
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
21 21
 {
22 22
 
23
-    /**
24
-     * @var EE_Registration
25
-     */
26
-    private $_registration;
27
-
28
-    /**
29
-     * @var EE_Event
30
-     */
31
-    private $_reg_event;
32
-
33
-    /**
34
-     * @var EE_Session
35
-     */
36
-    private $_session;
37
-
38
-    /**
39
-     * @var array
40
-     */
41
-    private static $_reg_status;
42
-
43
-    /**
44
-     * Form for displaying the custom questions for this registration.
45
-     * This gets used a few times throughout the request so its best to cache it
46
-     *
47
-     * @var EE_Registration_Custom_Questions_Form
48
-     */
49
-    protected $_reg_custom_questions_form = null;
50
-
51
-    /**
52
-     * @var EEM_Registration $registration_model
53
-     */
54
-    private $registration_model;
55
-
56
-    /**
57
-     * @var EEM_Attendee $attendee_model
58
-     */
59
-    private $attendee_model;
60
-
61
-    /**
62
-     * @var EEM_Event $event_model
63
-     */
64
-    private $event_model;
65
-
66
-    /**
67
-     * @var EEM_Status $status_model
68
-     */
69
-    private $status_model;
70
-
71
-
72
-    /**
73
-     * @param bool $routing
74
-     * @throws EE_Error
75
-     * @throws InvalidArgumentException
76
-     * @throws InvalidDataTypeException
77
-     * @throws InvalidInterfaceException
78
-     * @throws ReflectionException
79
-     */
80
-    public function __construct($routing = true)
81
-    {
82
-        parent::__construct($routing);
83
-        add_action('wp_loaded', [$this, 'wp_loaded']);
84
-    }
85
-
86
-
87
-    /**
88
-     * @return EEM_Registration
89
-     * @throws InvalidArgumentException
90
-     * @throws InvalidDataTypeException
91
-     * @throws InvalidInterfaceException
92
-     * @since 4.10.2.p
93
-     */
94
-    protected function getRegistrationModel()
95
-    {
96
-        if (! $this->registration_model instanceof EEM_Registration) {
97
-            $this->registration_model = $this->getLoader()->getShared('EEM_Registration');
98
-        }
99
-        return $this->registration_model;
100
-    }
101
-
102
-
103
-    /**
104
-     * @return EEM_Attendee
105
-     * @throws InvalidArgumentException
106
-     * @throws InvalidDataTypeException
107
-     * @throws InvalidInterfaceException
108
-     * @since 4.10.2.p
109
-     */
110
-    protected function getAttendeeModel()
111
-    {
112
-        if (! $this->attendee_model instanceof EEM_Attendee) {
113
-            $this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
114
-        }
115
-        return $this->attendee_model;
116
-    }
117
-
118
-
119
-    /**
120
-     * @return EEM_Event
121
-     * @throws InvalidArgumentException
122
-     * @throws InvalidDataTypeException
123
-     * @throws InvalidInterfaceException
124
-     * @since 4.10.2.p
125
-     */
126
-    protected function getEventModel()
127
-    {
128
-        if (! $this->event_model instanceof EEM_Event) {
129
-            $this->event_model = $this->getLoader()->getShared('EEM_Event');
130
-        }
131
-        return $this->event_model;
132
-    }
133
-
134
-
135
-    /**
136
-     * @return EEM_Status
137
-     * @throws InvalidArgumentException
138
-     * @throws InvalidDataTypeException
139
-     * @throws InvalidInterfaceException
140
-     * @since 4.10.2.p
141
-     */
142
-    protected function getStatusModel()
143
-    {
144
-        if (! $this->status_model instanceof EEM_Status) {
145
-            $this->status_model = $this->getLoader()->getShared('EEM_Status');
146
-        }
147
-        return $this->status_model;
148
-    }
149
-
150
-
151
-    public function wp_loaded()
152
-    {
153
-        // when adding a new registration...
154
-        $action = $this->request->getRequestParam('action');
155
-        if ($action === 'new_registration') {
156
-            EE_System::do_not_cache();
157
-            if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
158
-                // and it's NOT the attendee information reg step
159
-                // force cookie expiration by setting time to last week
160
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
161
-                // and update the global
162
-                $_COOKIE['ee_registration_added'] = 0;
163
-            }
164
-        }
165
-    }
166
-
167
-
168
-    protected function _init_page_props()
169
-    {
170
-        $this->page_slug        = REG_PG_SLUG;
171
-        $this->_admin_base_url  = REG_ADMIN_URL;
172
-        $this->_admin_base_path = REG_ADMIN;
173
-        $this->page_label       = esc_html__('Registrations', 'event_espresso');
174
-        $this->_cpt_routes      = [
175
-            'add_new_attendee' => 'espresso_attendees',
176
-            'edit_attendee'    => 'espresso_attendees',
177
-            'insert_attendee'  => 'espresso_attendees',
178
-            'update_attendee'  => 'espresso_attendees',
179
-        ];
180
-        $this->_cpt_model_names = [
181
-            'add_new_attendee' => 'EEM_Attendee',
182
-            'edit_attendee'    => 'EEM_Attendee',
183
-        ];
184
-        $this->_cpt_edit_routes = [
185
-            'espresso_attendees' => 'edit_attendee',
186
-        ];
187
-        $this->_pagenow_map     = [
188
-            'add_new_attendee' => 'post-new.php',
189
-            'edit_attendee'    => 'post.php',
190
-            'trash'            => 'post.php',
191
-        ];
192
-        add_action('edit_form_after_title', [$this, 'after_title_form_fields'], 10);
193
-        // add filters so that the comment urls don't take users to a confusing 404 page
194
-        add_filter('get_comment_link', [$this, 'clear_comment_link'], 10, 2);
195
-    }
196
-
197
-
198
-    /**
199
-     * @param string     $link    The comment permalink with '#comment-$id' appended.
200
-     * @param WP_Comment $comment The current comment object.
201
-     * @return string
202
-     */
203
-    public function clear_comment_link($link, WP_Comment $comment)
204
-    {
205
-        // gotta make sure this only happens on this route
206
-        $post_type = get_post_type($comment->comment_post_ID);
207
-        if ($post_type === 'espresso_attendees') {
208
-            return '#commentsdiv';
209
-        }
210
-        return $link;
211
-    }
212
-
213
-
214
-    protected function _ajax_hooks()
215
-    {
216
-        // todo: all hooks for registrations ajax goes in here
217
-        add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']);
218
-    }
219
-
220
-
221
-    protected function _define_page_props()
222
-    {
223
-        $this->_admin_page_title = $this->page_label;
224
-        $this->_labels           = [
225
-            'buttons'                      => [
226
-                'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
227
-                'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
228
-                'edit'                => esc_html__('Edit Contact', 'event_espresso'),
229
-                'csv_reg_report'      => esc_html__('Registrations CSV Report', 'event_espresso'),
230
-                'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
231
-                'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
232
-            ],
233
-            'publishbox'                   => [
234
-                'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
235
-                'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
236
-            ],
237
-            'hide_add_button_on_cpt_route' => [
238
-                'edit_attendee' => true,
239
-            ],
240
-        ];
241
-    }
242
-
243
-
244
-    /**
245
-     * grab url requests and route them
246
-     *
247
-     * @return void
248
-     * @throws EE_Error
249
-     */
250
-    public function _set_page_routes()
251
-    {
252
-        $this->_get_registration_status_array();
253
-        $REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
254
-        $REG_ID             = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
255
-        $ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
256
-        $ATT_ID             = $this->request->getRequestParam('post', $ATT_ID, 'int');
257
-        $this->_page_routes = [
258
-            'default'                             => [
259
-                'func'       => '_registrations_overview_list_table',
260
-                'capability' => 'ee_read_registrations',
261
-            ],
262
-            'view_registration'                   => [
263
-                'func'       => '_registration_details',
264
-                'capability' => 'ee_read_registration',
265
-                'obj_id'     => $REG_ID,
266
-            ],
267
-            'edit_registration'                   => [
268
-                'func'               => '_update_attendee_registration_form',
269
-                'noheader'           => true,
270
-                'headers_sent_route' => 'view_registration',
271
-                'capability'         => 'ee_edit_registration',
272
-                'obj_id'             => $REG_ID,
273
-                '_REG_ID'            => $REG_ID,
274
-            ],
275
-            'trash_registrations'                 => [
276
-                'func'       => '_trash_or_restore_registrations',
277
-                'args'       => ['trash' => true],
278
-                'noheader'   => true,
279
-                'capability' => 'ee_delete_registrations',
280
-            ],
281
-            'restore_registrations'               => [
282
-                'func'       => '_trash_or_restore_registrations',
283
-                'args'       => ['trash' => false],
284
-                'noheader'   => true,
285
-                'capability' => 'ee_delete_registrations',
286
-            ],
287
-            'delete_registrations'                => [
288
-                'func'       => '_delete_registrations',
289
-                'noheader'   => true,
290
-                'capability' => 'ee_delete_registrations',
291
-            ],
292
-            'new_registration'                    => [
293
-                'func'       => 'new_registration',
294
-                'capability' => 'ee_edit_registrations',
295
-            ],
296
-            'process_reg_step'                    => [
297
-                'func'       => 'process_reg_step',
298
-                'noheader'   => true,
299
-                'capability' => 'ee_edit_registrations',
300
-            ],
301
-            'redirect_to_txn'                     => [
302
-                'func'       => 'redirect_to_txn',
303
-                'noheader'   => true,
304
-                'capability' => 'ee_edit_registrations',
305
-            ],
306
-            'change_reg_status'                   => [
307
-                'func'       => '_change_reg_status',
308
-                'noheader'   => true,
309
-                'capability' => 'ee_edit_registration',
310
-                'obj_id'     => $REG_ID,
311
-            ],
312
-            'approve_registration'                => [
313
-                'func'       => 'approve_registration',
314
-                'noheader'   => true,
315
-                'capability' => 'ee_edit_registration',
316
-                'obj_id'     => $REG_ID,
317
-            ],
318
-            'approve_and_notify_registration'     => [
319
-                'func'       => 'approve_registration',
320
-                'noheader'   => true,
321
-                'args'       => [true],
322
-                'capability' => 'ee_edit_registration',
323
-                'obj_id'     => $REG_ID,
324
-            ],
325
-            'approve_registrations'               => [
326
-                'func'       => 'bulk_action_on_registrations',
327
-                'noheader'   => true,
328
-                'capability' => 'ee_edit_registrations',
329
-                'args'       => ['approve'],
330
-            ],
331
-            'approve_and_notify_registrations'    => [
332
-                'func'       => 'bulk_action_on_registrations',
333
-                'noheader'   => true,
334
-                'capability' => 'ee_edit_registrations',
335
-                'args'       => ['approve', true],
336
-            ],
337
-            'decline_registration'                => [
338
-                'func'       => 'decline_registration',
339
-                'noheader'   => true,
340
-                'capability' => 'ee_edit_registration',
341
-                'obj_id'     => $REG_ID,
342
-            ],
343
-            'decline_and_notify_registration'     => [
344
-                'func'       => 'decline_registration',
345
-                'noheader'   => true,
346
-                'args'       => [true],
347
-                'capability' => 'ee_edit_registration',
348
-                'obj_id'     => $REG_ID,
349
-            ],
350
-            'decline_registrations'               => [
351
-                'func'       => 'bulk_action_on_registrations',
352
-                'noheader'   => true,
353
-                'capability' => 'ee_edit_registrations',
354
-                'args'       => ['decline'],
355
-            ],
356
-            'decline_and_notify_registrations'    => [
357
-                'func'       => 'bulk_action_on_registrations',
358
-                'noheader'   => true,
359
-                'capability' => 'ee_edit_registrations',
360
-                'args'       => ['decline', true],
361
-            ],
362
-            'pending_registration'                => [
363
-                'func'       => 'pending_registration',
364
-                'noheader'   => true,
365
-                'capability' => 'ee_edit_registration',
366
-                'obj_id'     => $REG_ID,
367
-            ],
368
-            'pending_and_notify_registration'     => [
369
-                'func'       => 'pending_registration',
370
-                'noheader'   => true,
371
-                'args'       => [true],
372
-                'capability' => 'ee_edit_registration',
373
-                'obj_id'     => $REG_ID,
374
-            ],
375
-            'pending_registrations'               => [
376
-                'func'       => 'bulk_action_on_registrations',
377
-                'noheader'   => true,
378
-                'capability' => 'ee_edit_registrations',
379
-                'args'       => ['pending'],
380
-            ],
381
-            'pending_and_notify_registrations'    => [
382
-                'func'       => 'bulk_action_on_registrations',
383
-                'noheader'   => true,
384
-                'capability' => 'ee_edit_registrations',
385
-                'args'       => ['pending', true],
386
-            ],
387
-            'no_approve_registration'             => [
388
-                'func'       => 'not_approve_registration',
389
-                'noheader'   => true,
390
-                'capability' => 'ee_edit_registration',
391
-                'obj_id'     => $REG_ID,
392
-            ],
393
-            'no_approve_and_notify_registration'  => [
394
-                'func'       => 'not_approve_registration',
395
-                'noheader'   => true,
396
-                'args'       => [true],
397
-                'capability' => 'ee_edit_registration',
398
-                'obj_id'     => $REG_ID,
399
-            ],
400
-            'no_approve_registrations'            => [
401
-                'func'       => 'bulk_action_on_registrations',
402
-                'noheader'   => true,
403
-                'capability' => 'ee_edit_registrations',
404
-                'args'       => ['not_approve'],
405
-            ],
406
-            'no_approve_and_notify_registrations' => [
407
-                'func'       => 'bulk_action_on_registrations',
408
-                'noheader'   => true,
409
-                'capability' => 'ee_edit_registrations',
410
-                'args'       => ['not_approve', true],
411
-            ],
412
-            'cancel_registration'                 => [
413
-                'func'       => 'cancel_registration',
414
-                'noheader'   => true,
415
-                'capability' => 'ee_edit_registration',
416
-                'obj_id'     => $REG_ID,
417
-            ],
418
-            'cancel_and_notify_registration'      => [
419
-                'func'       => 'cancel_registration',
420
-                'noheader'   => true,
421
-                'args'       => [true],
422
-                'capability' => 'ee_edit_registration',
423
-                'obj_id'     => $REG_ID,
424
-            ],
425
-            'cancel_registrations'                => [
426
-                'func'       => 'bulk_action_on_registrations',
427
-                'noheader'   => true,
428
-                'capability' => 'ee_edit_registrations',
429
-                'args'       => ['cancel'],
430
-            ],
431
-            'cancel_and_notify_registrations'     => [
432
-                'func'       => 'bulk_action_on_registrations',
433
-                'noheader'   => true,
434
-                'capability' => 'ee_edit_registrations',
435
-                'args'       => ['cancel', true],
436
-            ],
437
-            'wait_list_registration'              => [
438
-                'func'       => 'wait_list_registration',
439
-                'noheader'   => true,
440
-                'capability' => 'ee_edit_registration',
441
-                'obj_id'     => $REG_ID,
442
-            ],
443
-            'wait_list_and_notify_registration'   => [
444
-                'func'       => 'wait_list_registration',
445
-                'noheader'   => true,
446
-                'args'       => [true],
447
-                'capability' => 'ee_edit_registration',
448
-                'obj_id'     => $REG_ID,
449
-            ],
450
-            'contact_list'                        => [
451
-                'func'       => '_attendee_contact_list_table',
452
-                'capability' => 'ee_read_contacts',
453
-            ],
454
-            'add_new_attendee'                    => [
455
-                'func' => '_create_new_cpt_item',
456
-                'args' => [
457
-                    'new_attendee' => true,
458
-                    'capability'   => 'ee_edit_contacts',
459
-                ],
460
-            ],
461
-            'edit_attendee'                       => [
462
-                'func'       => '_edit_cpt_item',
463
-                'capability' => 'ee_edit_contacts',
464
-                'obj_id'     => $ATT_ID,
465
-            ],
466
-            'duplicate_attendee'                  => [
467
-                'func'       => '_duplicate_attendee',
468
-                'noheader'   => true,
469
-                'capability' => 'ee_edit_contacts',
470
-                'obj_id'     => $ATT_ID,
471
-            ],
472
-            'insert_attendee'                     => [
473
-                'func'       => '_insert_or_update_attendee',
474
-                'args'       => [
475
-                    'new_attendee' => true,
476
-                ],
477
-                'noheader'   => true,
478
-                'capability' => 'ee_edit_contacts',
479
-            ],
480
-            'update_attendee'                     => [
481
-                'func'       => '_insert_or_update_attendee',
482
-                'args'       => [
483
-                    'new_attendee' => false,
484
-                ],
485
-                'noheader'   => true,
486
-                'capability' => 'ee_edit_contacts',
487
-                'obj_id'     => $ATT_ID,
488
-            ],
489
-            'trash_attendees'                     => [
490
-                'func'       => '_trash_or_restore_attendees',
491
-                'args'       => [
492
-                    'trash' => 'true',
493
-                ],
494
-                'noheader'   => true,
495
-                'capability' => 'ee_delete_contacts',
496
-            ],
497
-            'trash_attendee'                      => [
498
-                'func'       => '_trash_or_restore_attendees',
499
-                'args'       => [
500
-                    'trash' => true,
501
-                ],
502
-                'noheader'   => true,
503
-                'capability' => 'ee_delete_contacts',
504
-                'obj_id'     => $ATT_ID,
505
-            ],
506
-            'restore_attendees'                   => [
507
-                'func'       => '_trash_or_restore_attendees',
508
-                'args'       => [
509
-                    'trash' => false,
510
-                ],
511
-                'noheader'   => true,
512
-                'capability' => 'ee_delete_contacts',
513
-                'obj_id'     => $ATT_ID,
514
-            ],
515
-            'resend_registration'                 => [
516
-                'func'       => '_resend_registration',
517
-                'noheader'   => true,
518
-                'capability' => 'ee_send_message',
519
-            ],
520
-            'registrations_report'                => [
521
-                'func'       => '_registrations_report',
522
-                'noheader'   => true,
523
-                'capability' => 'ee_read_registrations',
524
-            ],
525
-            'contact_list_export'                 => [
526
-                'func'       => '_contact_list_export',
527
-                'noheader'   => true,
528
-                'capability' => 'export',
529
-            ],
530
-            'contact_list_report'                 => [
531
-                'func'       => '_contact_list_report',
532
-                'noheader'   => true,
533
-                'capability' => 'ee_read_contacts',
534
-            ],
535
-        ];
536
-    }
537
-
538
-
539
-    protected function _set_page_config()
540
-    {
541
-        $REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
542
-        $ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
543
-        $this->_page_config = [
544
-            'default'           => [
545
-                'nav'           => [
546
-                    'label' => esc_html__('Overview', 'event_espresso'),
547
-                    'order' => 5,
548
-                ],
549
-                'help_tabs'     => [
550
-                    'registrations_overview_help_tab'                       => [
551
-                        'title'    => esc_html__('Registrations Overview', 'event_espresso'),
552
-                        'filename' => 'registrations_overview',
553
-                    ],
554
-                    'registrations_overview_table_column_headings_help_tab' => [
555
-                        'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
556
-                        'filename' => 'registrations_overview_table_column_headings',
557
-                    ],
558
-                    'registrations_overview_filters_help_tab'               => [
559
-                        'title'    => esc_html__('Registration Filters', 'event_espresso'),
560
-                        'filename' => 'registrations_overview_filters',
561
-                    ],
562
-                    'registrations_overview_views_help_tab'                 => [
563
-                        'title'    => esc_html__('Registration Views', 'event_espresso'),
564
-                        'filename' => 'registrations_overview_views',
565
-                    ],
566
-                    'registrations_regoverview_other_help_tab'              => [
567
-                        'title'    => esc_html__('Registrations Other', 'event_espresso'),
568
-                        'filename' => 'registrations_overview_other',
569
-                    ],
570
-                ],
571
-                'qtips'         => ['Registration_List_Table_Tips'],
572
-                'list_table'    => 'EE_Registrations_List_Table',
573
-                'require_nonce' => false,
574
-            ],
575
-            'view_registration' => [
576
-                'nav'           => [
577
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
578
-                    'order'      => 15,
579
-                    'url'        => $REG_ID
580
-                        ? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
581
-                        : $this->_admin_base_url,
582
-                    'persistent' => false,
583
-                ],
584
-                'help_tabs'     => [
585
-                    'registrations_details_help_tab'                    => [
586
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
587
-                        'filename' => 'registrations_details',
588
-                    ],
589
-                    'registrations_details_table_help_tab'              => [
590
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
591
-                        'filename' => 'registrations_details_table',
592
-                    ],
593
-                    'registrations_details_form_answers_help_tab'       => [
594
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
595
-                        'filename' => 'registrations_details_form_answers',
596
-                    ],
597
-                    'registrations_details_registrant_details_help_tab' => [
598
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
599
-                        'filename' => 'registrations_details_registrant_details',
600
-                    ],
601
-                ],
602
-                'metaboxes'     => array_merge(
603
-                    $this->_default_espresso_metaboxes,
604
-                    ['_registration_details_metaboxes']
605
-                ),
606
-                'require_nonce' => false,
607
-            ],
608
-            'new_registration'  => [
609
-                'nav'           => [
610
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
611
-                    'url'        => '#',
612
-                    'order'      => 15,
613
-                    'persistent' => false,
614
-                ],
615
-                'metaboxes'     => $this->_default_espresso_metaboxes,
616
-                'labels'        => [
617
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
618
-                ],
619
-                'require_nonce' => false,
620
-            ],
621
-            'add_new_attendee'  => [
622
-                'nav'           => [
623
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
624
-                    'order'      => 15,
625
-                    'persistent' => false,
626
-                ],
627
-                'metaboxes'     => array_merge(
628
-                    $this->_default_espresso_metaboxes,
629
-                    ['_publish_post_box', 'attendee_editor_metaboxes']
630
-                ),
631
-                'require_nonce' => false,
632
-            ],
633
-            'edit_attendee'     => [
634
-                'nav'           => [
635
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
636
-                    'order'      => 15,
637
-                    'persistent' => false,
638
-                    'url'        => $ATT_ID
639
-                        ? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
640
-                        : $this->_admin_base_url,
641
-                ],
642
-                'metaboxes'     => ['attendee_editor_metaboxes'],
643
-                'require_nonce' => false,
644
-            ],
645
-            'contact_list'      => [
646
-                'nav'           => [
647
-                    'label' => esc_html__('Contact List', 'event_espresso'),
648
-                    'order' => 20,
649
-                ],
650
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
651
-                'help_tabs'     => [
652
-                    'registrations_contact_list_help_tab'                       => [
653
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
654
-                        'filename' => 'registrations_contact_list',
655
-                    ],
656
-                    'registrations_contact-list_table_column_headings_help_tab' => [
657
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
658
-                        'filename' => 'registrations_contact_list_table_column_headings',
659
-                    ],
660
-                    'registrations_contact_list_views_help_tab'                 => [
661
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
662
-                        'filename' => 'registrations_contact_list_views',
663
-                    ],
664
-                    'registrations_contact_list_other_help_tab'                 => [
665
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
666
-                        'filename' => 'registrations_contact_list_other',
667
-                    ],
668
-                ],
669
-                'metaboxes'     => [],
670
-                'require_nonce' => false,
671
-            ],
672
-            // override default cpt routes
673
-            'create_new'        => '',
674
-            'edit'              => '',
675
-        ];
676
-    }
677
-
678
-
679
-    /**
680
-     * The below methods aren't used by this class currently
681
-     */
682
-    protected function _add_screen_options()
683
-    {
684
-    }
685
-
686
-
687
-    protected function _add_feature_pointers()
688
-    {
689
-    }
690
-
691
-
692
-    public function admin_init()
693
-    {
694
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
695
-            'click "Update Registration Questions" to save your changes',
696
-            'event_espresso'
697
-        );
698
-    }
699
-
700
-
701
-    public function admin_notices()
702
-    {
703
-    }
704
-
705
-
706
-    public function admin_footer_scripts()
707
-    {
708
-    }
709
-
710
-
711
-    /**
712
-     * get list of registration statuses
713
-     *
714
-     * @return void
715
-     * @throws EE_Error
716
-     */
717
-    private function _get_registration_status_array()
718
-    {
719
-        self::$_reg_status = EEM_Registration::reg_status_array([], true);
720
-    }
721
-
722
-
723
-    /**
724
-     * @throws InvalidArgumentException
725
-     * @throws InvalidDataTypeException
726
-     * @throws InvalidInterfaceException
727
-     * @since 4.10.2.p
728
-     */
729
-    protected function _add_screen_options_default()
730
-    {
731
-        $this->_per_page_screen_option();
732
-    }
733
-
734
-
735
-    /**
736
-     * @throws InvalidArgumentException
737
-     * @throws InvalidDataTypeException
738
-     * @throws InvalidInterfaceException
739
-     * @since 4.10.2.p
740
-     */
741
-    protected function _add_screen_options_contact_list()
742
-    {
743
-        $page_title              = $this->_admin_page_title;
744
-        $this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
745
-        $this->_per_page_screen_option();
746
-        $this->_admin_page_title = $page_title;
747
-    }
748
-
749
-
750
-    public function load_scripts_styles()
751
-    {
752
-        // style
753
-        wp_register_style(
754
-            'espresso_reg',
755
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
756
-            ['ee-admin-css'],
757
-            EVENT_ESPRESSO_VERSION
758
-        );
759
-        wp_enqueue_style('espresso_reg');
760
-        // script
761
-        wp_register_script(
762
-            'espresso_reg',
763
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
764
-            ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
765
-            EVENT_ESPRESSO_VERSION,
766
-            true
767
-        );
768
-        wp_enqueue_script('espresso_reg');
769
-    }
770
-
771
-
772
-    /**
773
-     * @throws EE_Error
774
-     * @throws InvalidArgumentException
775
-     * @throws InvalidDataTypeException
776
-     * @throws InvalidInterfaceException
777
-     * @throws ReflectionException
778
-     * @since 4.10.2.p
779
-     */
780
-    public function load_scripts_styles_edit_attendee()
781
-    {
782
-        // stuff to only show up on our attendee edit details page.
783
-        $attendee_details_translations = [
784
-            'att_publish_text' => sprintf(
785
-            /* translators: The date and time */
786
-                wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
787
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
788
-            ),
789
-        ];
790
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
791
-        wp_enqueue_script('jquery-validate');
792
-    }
793
-
794
-
795
-    /**
796
-     * @throws EE_Error
797
-     * @throws InvalidArgumentException
798
-     * @throws InvalidDataTypeException
799
-     * @throws InvalidInterfaceException
800
-     * @throws ReflectionException
801
-     * @since 4.10.2.p
802
-     */
803
-    public function load_scripts_styles_view_registration()
804
-    {
805
-        // styles
806
-        wp_enqueue_style('espresso-ui-theme');
807
-        // scripts
808
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
809
-        $this->_reg_custom_questions_form->wp_enqueue_scripts();
810
-    }
811
-
812
-
813
-    public function load_scripts_styles_contact_list()
814
-    {
815
-        wp_dequeue_style('espresso_reg');
816
-        wp_register_style(
817
-            'espresso_att',
818
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
819
-            ['ee-admin-css'],
820
-            EVENT_ESPRESSO_VERSION
821
-        );
822
-        wp_enqueue_style('espresso_att');
823
-    }
824
-
825
-
826
-    public function load_scripts_styles_new_registration()
827
-    {
828
-        wp_register_script(
829
-            'ee-spco-for-admin',
830
-            REG_ASSETS_URL . 'spco_for_admin.js',
831
-            ['underscore', 'jquery'],
832
-            EVENT_ESPRESSO_VERSION,
833
-            true
834
-        );
835
-        wp_enqueue_script('ee-spco-for-admin');
836
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
837
-        EE_Form_Section_Proper::wp_enqueue_scripts();
838
-        EED_Ticket_Selector::load_tckt_slctr_assets();
839
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
840
-    }
841
-
842
-
843
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
844
-    {
845
-        add_filter('FHEE_load_EE_messages', '__return_true');
846
-    }
847
-
848
-
849
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
850
-    {
851
-        add_filter('FHEE_load_EE_messages', '__return_true');
852
-    }
853
-
854
-
855
-    /**
856
-     * @throws EE_Error
857
-     * @throws InvalidArgumentException
858
-     * @throws InvalidDataTypeException
859
-     * @throws InvalidInterfaceException
860
-     * @throws ReflectionException
861
-     * @since 4.10.2.p
862
-     */
863
-    protected function _set_list_table_views_default()
864
-    {
865
-        // for notification related bulk actions we need to make sure only active messengers have an option.
866
-        EED_Messages::set_autoloaders();
867
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
868
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
869
-        $active_mts               = $message_resource_manager->list_of_active_message_types();
870
-        // key= bulk_action_slug, value= message type.
871
-        $match_array = [
872
-            'approve_registrations'    => 'registration',
873
-            'decline_registrations'    => 'declined_registration',
874
-            'pending_registrations'    => 'pending_approval',
875
-            'no_approve_registrations' => 'not_approved_registration',
876
-            'cancel_registrations'     => 'cancelled_registration',
877
-        ];
878
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
879
-            'ee_send_message',
880
-            'batch_send_messages'
881
-        );
882
-        /** setup reg status bulk actions **/
883
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
884
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
885
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
886
-                'Approve and Notify Registrations',
887
-                'event_espresso'
888
-            );
889
-        }
890
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
891
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
892
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
893
-                'Decline and Notify Registrations',
894
-                'event_espresso'
895
-            );
896
-        }
897
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
898
-            'Set Registrations to Pending Payment',
899
-            'event_espresso'
900
-        );
901
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
902
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
903
-                'Set Registrations to Pending Payment and Notify',
904
-                'event_espresso'
905
-            );
906
-        }
907
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
908
-            'Set Registrations to Not Approved',
909
-            'event_espresso'
910
-        );
911
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
912
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
913
-                'Set Registrations to Not Approved and Notify',
914
-                'event_espresso'
915
-            );
916
-        }
917
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
918
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
919
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
920
-                'Cancel Registrations and Notify',
921
-                'event_espresso'
922
-            );
923
-        }
924
-        $def_reg_status_actions = apply_filters(
925
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
926
-            $def_reg_status_actions,
927
-            $active_mts,
928
-            $can_send
929
-        );
930
-
931
-        $this->_views = [
932
-            'all'   => [
933
-                'slug'        => 'all',
934
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
935
-                'count'       => 0,
936
-                'bulk_action' => array_merge(
937
-                    $def_reg_status_actions,
938
-                    [
939
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
940
-                    ]
941
-                ),
942
-            ],
943
-            'month' => [
944
-                'slug'        => 'month',
945
-                'label'       => esc_html__('This Month', 'event_espresso'),
946
-                'count'       => 0,
947
-                'bulk_action' => array_merge(
948
-                    $def_reg_status_actions,
949
-                    [
950
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
951
-                    ]
952
-                ),
953
-            ],
954
-            'today' => [
955
-                'slug'        => 'today',
956
-                'label'       => sprintf(
957
-                    esc_html__('Today - %s', 'event_espresso'),
958
-                    date('M d, Y', current_time('timestamp'))
959
-                ),
960
-                'count'       => 0,
961
-                'bulk_action' => array_merge(
962
-                    $def_reg_status_actions,
963
-                    [
964
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
965
-                    ]
966
-                ),
967
-            ],
968
-        ];
969
-        if (
970
-            EE_Registry::instance()->CAP->current_user_can(
971
-                'ee_delete_registrations',
972
-                'espresso_registrations_delete_registration'
973
-            )
974
-        ) {
975
-            $this->_views['incomplete'] = [
976
-                'slug'        => 'incomplete',
977
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
978
-                'count'       => 0,
979
-                'bulk_action' => [
980
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
981
-                ],
982
-            ];
983
-            $this->_views['trash']      = [
984
-                'slug'        => 'trash',
985
-                'label'       => esc_html__('Trash', 'event_espresso'),
986
-                'count'       => 0,
987
-                'bulk_action' => [
988
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
989
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
990
-                ],
991
-            ];
992
-        }
993
-    }
994
-
995
-
996
-    protected function _set_list_table_views_contact_list()
997
-    {
998
-        $this->_views = [
999
-            'in_use' => [
1000
-                'slug'        => 'in_use',
1001
-                'label'       => esc_html__('In Use', 'event_espresso'),
1002
-                'count'       => 0,
1003
-                'bulk_action' => [
1004
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1005
-                ],
1006
-            ],
1007
-        ];
1008
-        if (
1009
-            EE_Registry::instance()->CAP->current_user_can(
1010
-                'ee_delete_contacts',
1011
-                'espresso_registrations_trash_attendees'
1012
-            )
1013
-        ) {
1014
-            $this->_views['trash'] = [
1015
-                'slug'        => 'trash',
1016
-                'label'       => esc_html__('Trash', 'event_espresso'),
1017
-                'count'       => 0,
1018
-                'bulk_action' => [
1019
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1020
-                ],
1021
-            ];
1022
-        }
1023
-    }
1024
-
1025
-
1026
-    /**
1027
-     * @return array
1028
-     * @throws EE_Error
1029
-     */
1030
-    protected function _registration_legend_items()
1031
-    {
1032
-        $fc_items = [
1033
-            'star-icon'        => [
1034
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1035
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1036
-            ],
1037
-            'view_details'     => [
1038
-                'class' => 'dashicons dashicons-clipboard',
1039
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1040
-            ],
1041
-            'edit_attendee'    => [
1042
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1043
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1044
-            ],
1045
-            'view_transaction' => [
1046
-                'class' => 'dashicons dashicons-cart',
1047
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1048
-            ],
1049
-            'view_invoice'     => [
1050
-                'class' => 'dashicons dashicons-media-spreadsheet',
1051
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1052
-            ],
1053
-        ];
1054
-        if (
1055
-            EE_Registry::instance()->CAP->current_user_can(
1056
-                'ee_send_message',
1057
-                'espresso_registrations_resend_registration'
1058
-            )
1059
-        ) {
1060
-            $fc_items['resend_registration'] = [
1061
-                'class' => 'dashicons dashicons-email-alt',
1062
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1063
-            ];
1064
-        } else {
1065
-            $fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1066
-        }
1067
-        if (
1068
-            EE_Registry::instance()->CAP->current_user_can(
1069
-                'ee_read_global_messages',
1070
-                'view_filtered_messages'
1071
-            )
1072
-        ) {
1073
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1074
-            if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1075
-                $fc_items['view_related_messages'] = [
1076
-                    'class' => $related_for_icon['css_class'],
1077
-                    'desc'  => $related_for_icon['label'],
1078
-                ];
1079
-            }
1080
-        }
1081
-        $sc_items = [
1082
-            'approved_status'   => [
1083
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1084
-                'desc'  => EEH_Template::pretty_status(
1085
-                    EEM_Registration::status_id_approved,
1086
-                    false,
1087
-                    'sentence'
1088
-                ),
1089
-            ],
1090
-            'pending_status'    => [
1091
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1092
-                'desc'  => EEH_Template::pretty_status(
1093
-                    EEM_Registration::status_id_pending_payment,
1094
-                    false,
1095
-                    'sentence'
1096
-                ),
1097
-            ],
1098
-            'wait_list'         => [
1099
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1100
-                'desc'  => EEH_Template::pretty_status(
1101
-                    EEM_Registration::status_id_wait_list,
1102
-                    false,
1103
-                    'sentence'
1104
-                ),
1105
-            ],
1106
-            'incomplete_status' => [
1107
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1108
-                'desc'  => EEH_Template::pretty_status(
1109
-                    EEM_Registration::status_id_incomplete,
1110
-                    false,
1111
-                    'sentence'
1112
-                ),
1113
-            ],
1114
-            'not_approved'      => [
1115
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1116
-                'desc'  => EEH_Template::pretty_status(
1117
-                    EEM_Registration::status_id_not_approved,
1118
-                    false,
1119
-                    'sentence'
1120
-                ),
1121
-            ],
1122
-            'declined_status'   => [
1123
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1124
-                'desc'  => EEH_Template::pretty_status(
1125
-                    EEM_Registration::status_id_declined,
1126
-                    false,
1127
-                    'sentence'
1128
-                ),
1129
-            ],
1130
-            'cancelled_status'  => [
1131
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1132
-                'desc'  => EEH_Template::pretty_status(
1133
-                    EEM_Registration::status_id_cancelled,
1134
-                    false,
1135
-                    'sentence'
1136
-                ),
1137
-            ],
1138
-        ];
1139
-        return array_merge($fc_items, $sc_items);
1140
-    }
1141
-
1142
-
1143
-
1144
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1145
-
1146
-
1147
-    /**
1148
-     * @throws DomainException
1149
-     * @throws EE_Error
1150
-     * @throws InvalidArgumentException
1151
-     * @throws InvalidDataTypeException
1152
-     * @throws InvalidInterfaceException
1153
-     */
1154
-    protected function _registrations_overview_list_table()
1155
-    {
1156
-        $this->appendAddNewRegistrationButtonToPageTitle();
1157
-        $header_text                  = '';
1158
-        $admin_page_header_decorators = [
1159
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1160
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1161
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1162
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1163
-        ];
1164
-        foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1165
-            $filter_header_decorator = $this->getLoader()->getNew($admin_page_header_decorator);
1166
-            $header_text             = $filter_header_decorator->getHeaderText($header_text);
1167
-        }
1168
-        $this->_template_args['admin_page_header'] = $header_text;
1169
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1170
-        $this->display_admin_list_table_page_with_no_sidebar();
1171
-    }
1172
-
1173
-
1174
-    /**
1175
-     * @throws EE_Error
1176
-     * @throws InvalidArgumentException
1177
-     * @throws InvalidDataTypeException
1178
-     * @throws InvalidInterfaceException
1179
-     */
1180
-    private function appendAddNewRegistrationButtonToPageTitle()
1181
-    {
1182
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1183
-        if (
1184
-            $EVT_ID
1185
-            && EE_Registry::instance()->CAP->current_user_can(
1186
-                'ee_edit_registrations',
1187
-                'espresso_registrations_new_registration',
1188
-                $EVT_ID
1189
-            )
1190
-        ) {
1191
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1192
-                'new_registration',
1193
-                'add-registrant',
1194
-                ['event_id' => $EVT_ID],
1195
-                'add-new-h2'
1196
-            );
1197
-        }
1198
-    }
1199
-
1200
-
1201
-    /**
1202
-     * This sets the _registration property for the registration details screen
1203
-     *
1204
-     * @return void
1205
-     * @throws EE_Error
1206
-     * @throws InvalidArgumentException
1207
-     * @throws InvalidDataTypeException
1208
-     * @throws InvalidInterfaceException
1209
-     */
1210
-    private function _set_registration_object()
1211
-    {
1212
-        // get out if we've already set the object
1213
-        if ($this->_registration instanceof EE_Registration) {
1214
-            return;
1215
-        }
1216
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1217
-        if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1218
-            return;
1219
-        }
1220
-        $error_msg = sprintf(
1221
-            esc_html__(
1222
-                'An error occurred and the details for Registration ID #%s could not be retrieved.',
1223
-                'event_espresso'
1224
-            ),
1225
-            $REG_ID
1226
-        );
1227
-        EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1228
-        $this->_registration = null;
1229
-    }
1230
-
1231
-
1232
-    /**
1233
-     * Used to retrieve registrations for the list table.
1234
-     *
1235
-     * @param int  $per_page
1236
-     * @param bool $count
1237
-     * @param bool $this_month
1238
-     * @param bool $today
1239
-     * @return EE_Registration[]|int
1240
-     * @throws EE_Error
1241
-     * @throws InvalidArgumentException
1242
-     * @throws InvalidDataTypeException
1243
-     * @throws InvalidInterfaceException
1244
-     */
1245
-    public function get_registrations(
1246
-        $per_page = 10,
1247
-        $count = false,
1248
-        $this_month = false,
1249
-        $today = false
1250
-    ) {
1251
-        if ($this_month) {
1252
-            $this->request->setRequestParam('status', 'month');
1253
-        }
1254
-        if ($today) {
1255
-            $this->request->setRequestParam('status', 'today');
1256
-        }
1257
-        $query_params = $this->_get_registration_query_parameters($this->request->requestParams(), $per_page, $count);
1258
-        /**
1259
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1260
-         *
1261
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1262
-         * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1263
-         *                      or if you have the development copy of EE you can view this at the path:
1264
-         *                      /docs/G--Model-System/model-query-params.md
1265
-         */
1266
-        $query_params['group_by'] = '';
1267
-
1268
-        return $count
1269
-            ? $this->getRegistrationModel()->count($query_params)
1270
-            /** @type EE_Registration[] */
1271
-            : $this->getRegistrationModel()->get_all($query_params);
1272
-    }
1273
-
1274
-
1275
-    /**
1276
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1277
-     * Note: this listens to values on the request for some of the query parameters.
1278
-     *
1279
-     * @param array $request
1280
-     * @param int   $per_page
1281
-     * @param bool  $count
1282
-     * @return array
1283
-     * @throws EE_Error
1284
-     * @throws InvalidArgumentException
1285
-     * @throws InvalidDataTypeException
1286
-     * @throws InvalidInterfaceException
1287
-     */
1288
-    protected function _get_registration_query_parameters(
1289
-        $request = [],
1290
-        $per_page = 10,
1291
-        $count = false
1292
-    ) {
1293
-        /** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1294
-        $list_table_query_builder = $this->getLoader()->getNew(
1295
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1296
-            [null, null, $request]
1297
-        );
1298
-        return $list_table_query_builder->getQueryParams($per_page, $count);
1299
-    }
1300
-
1301
-
1302
-    public function get_registration_status_array()
1303
-    {
1304
-        return self::$_reg_status;
1305
-    }
1306
-
1307
-
1308
-
1309
-
1310
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1311
-    /**
1312
-     * generates HTML for the View Registration Details Admin page
1313
-     *
1314
-     * @return void
1315
-     * @throws DomainException
1316
-     * @throws EE_Error
1317
-     * @throws InvalidArgumentException
1318
-     * @throws InvalidDataTypeException
1319
-     * @throws InvalidInterfaceException
1320
-     * @throws EntityNotFoundException
1321
-     * @throws ReflectionException
1322
-     */
1323
-    protected function _registration_details()
1324
-    {
1325
-        $this->_template_args = [];
1326
-        $this->_set_registration_object();
1327
-        if (is_object($this->_registration)) {
1328
-            $transaction                                   = $this->_registration->transaction()
1329
-                ? $this->_registration->transaction()
1330
-                : EE_Transaction::new_instance();
1331
-            $this->_session                                = $transaction->session_data();
1332
-            $event_id                                      = $this->_registration->event_ID();
1333
-            $this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1334
-            $this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1335
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1336
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1337
-            $this->_template_args['grand_total']           = $transaction->total();
1338
-            $this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1339
-            // link back to overview
1340
-            $this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1341
-            $this->_template_args['registration']                = $this->_registration;
1342
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1343
-                [
1344
-                    'action'   => 'default',
1345
-                    'event_id' => $event_id,
1346
-                ],
1347
-                REG_ADMIN_URL
1348
-            );
1349
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1350
-                [
1351
-                    'action' => 'default',
1352
-                    'EVT_ID' => $event_id,
1353
-                    'page'   => 'espresso_transactions',
1354
-                ],
1355
-                admin_url('admin.php')
1356
-            );
1357
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1358
-                [
1359
-                    'page'   => 'espresso_events',
1360
-                    'action' => 'edit',
1361
-                    'post'   => $event_id,
1362
-                ],
1363
-                admin_url('admin.php')
1364
-            );
1365
-            // next and previous links
1366
-            $next_reg                                      = $this->_registration->next(
1367
-                null,
1368
-                [],
1369
-                'REG_ID'
1370
-            );
1371
-            $this->_template_args['next_registration']     = $next_reg
1372
-                ? $this->_next_link(
1373
-                    EE_Admin_Page::add_query_args_and_nonce(
1374
-                        [
1375
-                            'action'  => 'view_registration',
1376
-                            '_REG_ID' => $next_reg['REG_ID'],
1377
-                        ],
1378
-                        REG_ADMIN_URL
1379
-                    ),
1380
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1381
-                )
1382
-                : '';
1383
-            $previous_reg                                  = $this->_registration->previous(
1384
-                null,
1385
-                [],
1386
-                'REG_ID'
1387
-            );
1388
-            $this->_template_args['previous_registration'] = $previous_reg
1389
-                ? $this->_previous_link(
1390
-                    EE_Admin_Page::add_query_args_and_nonce(
1391
-                        [
1392
-                            'action'  => 'view_registration',
1393
-                            '_REG_ID' => $previous_reg['REG_ID'],
1394
-                        ],
1395
-                        REG_ADMIN_URL
1396
-                    ),
1397
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1398
-                )
1399
-                : '';
1400
-            // grab header
1401
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1402
-            $this->_template_args['REG_ID']            = $this->_registration->ID();
1403
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1404
-                $template_path,
1405
-                $this->_template_args,
1406
-                true
1407
-            );
1408
-        } else {
1409
-            $this->_template_args['admin_page_header'] = '';
1410
-            $this->_display_espresso_notices();
1411
-        }
1412
-        // the details template wrapper
1413
-        $this->display_admin_page_with_sidebar();
1414
-    }
1415
-
1416
-
1417
-    /**
1418
-     * @throws EE_Error
1419
-     * @throws InvalidArgumentException
1420
-     * @throws InvalidDataTypeException
1421
-     * @throws InvalidInterfaceException
1422
-     * @throws ReflectionException
1423
-     * @since 4.10.2.p
1424
-     */
1425
-    protected function _registration_details_metaboxes()
1426
-    {
1427
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1428
-        $this->_set_registration_object();
1429
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1430
-        add_meta_box(
1431
-            'edit-reg-status-mbox',
1432
-            esc_html__('Registration Status', 'event_espresso'),
1433
-            [$this, 'set_reg_status_buttons_metabox'],
1434
-            $this->_wp_page_slug,
1435
-            'normal',
1436
-            'high'
1437
-        );
1438
-        add_meta_box(
1439
-            'edit-reg-details-mbox',
1440
-            esc_html__('Registration Details', 'event_espresso'),
1441
-            [$this, '_reg_details_meta_box'],
1442
-            $this->_wp_page_slug,
1443
-            'normal',
1444
-            'high'
1445
-        );
1446
-        if (
1447
-            $attendee instanceof EE_Attendee
1448
-            && EE_Registry::instance()->CAP->current_user_can(
1449
-                'ee_read_registration',
1450
-                'edit-reg-questions-mbox',
1451
-                $this->_registration->ID()
1452
-            )
1453
-        ) {
1454
-            add_meta_box(
1455
-                'edit-reg-questions-mbox',
1456
-                esc_html__('Registration Form Answers', 'event_espresso'),
1457
-                [$this, '_reg_questions_meta_box'],
1458
-                $this->_wp_page_slug,
1459
-                'normal',
1460
-                'high'
1461
-            );
1462
-        }
1463
-        add_meta_box(
1464
-            'edit-reg-registrant-mbox',
1465
-            esc_html__('Contact Details', 'event_espresso'),
1466
-            [$this, '_reg_registrant_side_meta_box'],
1467
-            $this->_wp_page_slug,
1468
-            'side',
1469
-            'high'
1470
-        );
1471
-        if ($this->_registration->group_size() > 1) {
1472
-            add_meta_box(
1473
-                'edit-reg-attendees-mbox',
1474
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1475
-                [$this, '_reg_attendees_meta_box'],
1476
-                $this->_wp_page_slug,
1477
-                'normal',
1478
-                'high'
1479
-            );
1480
-        }
1481
-    }
1482
-
1483
-
1484
-    /**
1485
-     * set_reg_status_buttons_metabox
1486
-     *
1487
-     * @return void
1488
-     * @throws EE_Error
1489
-     * @throws EntityNotFoundException
1490
-     * @throws InvalidArgumentException
1491
-     * @throws InvalidDataTypeException
1492
-     * @throws InvalidInterfaceException
1493
-     * @throws ReflectionException
1494
-     */
1495
-    public function set_reg_status_buttons_metabox()
1496
-    {
1497
-        $this->_set_registration_object();
1498
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1499
-        $output                 = $change_reg_status_form->form_open(
1500
-            self::add_query_args_and_nonce(
1501
-                [
1502
-                    'action' => 'change_reg_status',
1503
-                ],
1504
-                REG_ADMIN_URL
1505
-            )
1506
-        );
1507
-        $output                 .= $change_reg_status_form->get_html();
1508
-        $output                 .= $change_reg_status_form->form_close();
1509
-        echo wp_kses($output, AllowedTags::getWithFormTags());
1510
-    }
1511
-
1512
-
1513
-    /**
1514
-     * @return EE_Form_Section_Proper
1515
-     * @throws EE_Error
1516
-     * @throws InvalidArgumentException
1517
-     * @throws InvalidDataTypeException
1518
-     * @throws InvalidInterfaceException
1519
-     * @throws EntityNotFoundException
1520
-     * @throws ReflectionException
1521
-     */
1522
-    protected function _generate_reg_status_change_form()
1523
-    {
1524
-        $reg_status_change_form_array = [
1525
-            'name'            => 'reg_status_change_form',
1526
-            'html_id'         => 'reg-status-change-form',
1527
-            'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1528
-            'subsections'     => [
1529
-                'return'         => new EE_Hidden_Input(
1530
-                    [
1531
-                        'name'    => 'return',
1532
-                        'default' => 'view_registration',
1533
-                    ]
1534
-                ),
1535
-                'REG_ID'         => new EE_Hidden_Input(
1536
-                    [
1537
-                        'name'    => 'REG_ID',
1538
-                        'default' => $this->_registration->ID(),
1539
-                    ]
1540
-                ),
1541
-                'current_status' => new EE_Form_Section_HTML(
1542
-                    EEH_HTML::table(
1543
-                        EEH_HTML::tr(
1544
-                            EEH_HTML::th(
1545
-                                EEH_HTML::label(
1546
-                                    EEH_HTML::strong(
1547
-                                        esc_html__('Current Registration Status', 'event_espresso')
1548
-                                    )
1549
-                                )
1550
-                            )
1551
-                            . EEH_HTML::td(
1552
-                                EEH_HTML::strong(
1553
-                                    $this->_registration->pretty_status(),
1554
-                                    '',
1555
-                                    'status-' . $this->_registration->status_ID(),
1556
-                                    'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1557
-                                )
1558
-                            )
1559
-                        )
1560
-                    )
1561
-                ),
1562
-            ],
1563
-        ];
1564
-        if (
1565
-            EE_Registry::instance()->CAP->current_user_can(
1566
-                'ee_edit_registration',
1567
-                'toggle_registration_status',
1568
-                $this->_registration->ID()
1569
-            )
1570
-        ) {
1571
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1572
-                $this->_get_reg_statuses(),
1573
-                [
1574
-                    'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1575
-                    'default'         => $this->_registration->status_ID(),
1576
-                ]
1577
-            );
1578
-            $reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1579
-                [
1580
-                    'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1581
-                    'default'         => false,
1582
-                    'html_help_text'  => esc_html__(
1583
-                        'If set to "Yes", then the related messages will be sent to the registrant.',
1584
-                        'event_espresso'
1585
-                    ),
1586
-                ]
1587
-            );
1588
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1589
-                [
1590
-                    'html_class'      => 'button-primary',
1591
-                    'html_label_text' => '&nbsp;',
1592
-                    'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1593
-                ]
1594
-            );
1595
-        }
1596
-        return new EE_Form_Section_Proper($reg_status_change_form_array);
1597
-    }
1598
-
1599
-
1600
-    /**
1601
-     * Returns an array of all the buttons for the various statuses and switch status actions
1602
-     *
1603
-     * @return array
1604
-     * @throws EE_Error
1605
-     * @throws InvalidArgumentException
1606
-     * @throws InvalidDataTypeException
1607
-     * @throws InvalidInterfaceException
1608
-     * @throws EntityNotFoundException
1609
-     */
1610
-    protected function _get_reg_statuses()
1611
-    {
1612
-        $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1613
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1614
-        // get current reg status
1615
-        $current_status = $this->_registration->status_ID();
1616
-        // is registration for free event? This will determine whether to display the pending payment option
1617
-        if (
1618
-            $current_status !== EEM_Registration::status_id_pending_payment
1619
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1620
-        ) {
1621
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1622
-        }
1623
-        return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1624
-    }
1625
-
1626
-
1627
-    /**
1628
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1629
-     *
1630
-     * @param bool $status REG status given for changing registrations to.
1631
-     * @param bool $notify Whether to send messages notifications or not.
1632
-     * @return array (array with reg_id(s) updated and whether update was successful.
1633
-     * @throws DomainException
1634
-     * @throws EE_Error
1635
-     * @throws EntityNotFoundException
1636
-     * @throws InvalidArgumentException
1637
-     * @throws InvalidDataTypeException
1638
-     * @throws InvalidInterfaceException
1639
-     * @throws ReflectionException
1640
-     * @throws RuntimeException
1641
-     */
1642
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1643
-    {
1644
-        $REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1645
-            ? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1646
-            : $this->request->getRequestParam('_REG_ID', [], 'int', true);
1647
-
1648
-        // sanitize $REG_IDs
1649
-        $REG_IDs = array_map('absint', $REG_IDs);
1650
-        // and remove empty entries
1651
-        $REG_IDs = array_filter($REG_IDs);
1652
-
1653
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1654
-
1655
-        /**
1656
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1657
-         * Currently this value is used downstream by the _process_resend_registration method.
1658
-         *
1659
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1660
-         * @param bool                     $status           The status registrations were changed to.
1661
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1662
-         * @param Registrations_Admin_Page $admin_page_object
1663
-         */
1664
-        $REG_ID = apply_filters(
1665
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1666
-            $result['REG_ID'],
1667
-            $status,
1668
-            $result['success'],
1669
-            $this
1670
-        );
1671
-        $this->request->setRequestParam('_REG_ID', $REG_ID);
1672
-
1673
-        // notify?
1674
-        if (
1675
-            $notify
1676
-            && $result['success']
1677
-            && ! empty($REG_ID)
1678
-            && EE_Registry::instance()->CAP->current_user_can(
1679
-                'ee_send_message',
1680
-                'espresso_registrations_resend_registration'
1681
-            )
1682
-        ) {
1683
-            $this->_process_resend_registration();
1684
-        }
1685
-        return $result;
1686
-    }
1687
-
1688
-
1689
-    /**
1690
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1691
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1692
-     *
1693
-     * @param array  $REG_IDs
1694
-     * @param string $status
1695
-     * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1696
-     *                       slug sent with setting the registration status.
1697
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1698
-     * @throws EE_Error
1699
-     * @throws InvalidArgumentException
1700
-     * @throws InvalidDataTypeException
1701
-     * @throws InvalidInterfaceException
1702
-     * @throws ReflectionException
1703
-     * @throws RuntimeException
1704
-     * @throws EntityNotFoundException
1705
-     * @throws DomainException
1706
-     */
1707
-    protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1708
-    {
1709
-        $success = false;
1710
-        // typecast $REG_IDs
1711
-        $REG_IDs = (array) $REG_IDs;
1712
-        if (! empty($REG_IDs)) {
1713
-            $success = true;
1714
-            // set default status if none is passed
1715
-            $status         = $status ?: EEM_Registration::status_id_pending_payment;
1716
-            $status_context = $notify
1717
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1718
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1719
-            // loop through REG_ID's and change status
1720
-            foreach ($REG_IDs as $REG_ID) {
1721
-                $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1722
-                if ($registration instanceof EE_Registration) {
1723
-                    $registration->set_status(
1724
-                        $status,
1725
-                        false,
1726
-                        new Context(
1727
-                            $status_context,
1728
-                            esc_html__(
1729
-                                'Manually triggered status change on a Registration Admin Page route.',
1730
-                                'event_espresso'
1731
-                            )
1732
-                        )
1733
-                    );
1734
-                    $result = $registration->save();
1735
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1736
-                    $success = $result !== false ? $success : false;
1737
-                }
1738
-            }
1739
-        }
1740
-
1741
-        // return $success and processed registrations
1742
-        return ['REG_ID' => $REG_IDs, 'success' => $success];
1743
-    }
1744
-
1745
-
1746
-    /**
1747
-     * Common logic for setting up success message and redirecting to appropriate route
1748
-     *
1749
-     * @param string $STS_ID status id for the registration changed to
1750
-     * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1751
-     * @return void
1752
-     * @throws DomainException
1753
-     * @throws EE_Error
1754
-     * @throws EntityNotFoundException
1755
-     * @throws InvalidArgumentException
1756
-     * @throws InvalidDataTypeException
1757
-     * @throws InvalidInterfaceException
1758
-     * @throws ReflectionException
1759
-     * @throws RuntimeException
1760
-     */
1761
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1762
-    {
1763
-        $result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1764
-            : ['success' => false];
1765
-        $success = isset($result['success']) && $result['success'];
1766
-        // setup success message
1767
-        if ($success) {
1768
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1769
-                $msg = sprintf(
1770
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1771
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1772
-                );
1773
-            } else {
1774
-                $msg = sprintf(
1775
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
1776
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1777
-                );
1778
-            }
1779
-            EE_Error::add_success($msg);
1780
-        } else {
1781
-            EE_Error::add_error(
1782
-                esc_html__(
1783
-                    'Something went wrong, and the status was not changed',
1784
-                    'event_espresso'
1785
-                ),
1786
-                __FILE__,
1787
-                __LINE__,
1788
-                __FUNCTION__
1789
-            );
1790
-        }
1791
-        $return = $this->request->getRequestParam('return');
1792
-        $route  = $return === 'view_registration'
1793
-            ? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1794
-            : ['action' => 'default'];
1795
-        $route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1796
-        $this->_redirect_after_action($success, '', '', $route, true);
1797
-    }
1798
-
1799
-
1800
-    /**
1801
-     * incoming reg status change from reg details page.
1802
-     *
1803
-     * @return void
1804
-     * @throws EE_Error
1805
-     * @throws EntityNotFoundException
1806
-     * @throws InvalidArgumentException
1807
-     * @throws InvalidDataTypeException
1808
-     * @throws InvalidInterfaceException
1809
-     * @throws ReflectionException
1810
-     * @throws RuntimeException
1811
-     * @throws DomainException
1812
-     */
1813
-    protected function _change_reg_status()
1814
-    {
1815
-        $this->request->setRequestParam('return', 'view_registration');
1816
-        // set notify based on whether the send notifications toggle is set or not
1817
-        $notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1818
-        $reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1819
-        $this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1820
-        switch ($reg_status) {
1821
-            case EEM_Registration::status_id_approved:
1822
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1823
-                $this->approve_registration($notify);
1824
-                break;
1825
-            case EEM_Registration::status_id_pending_payment:
1826
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1827
-                $this->pending_registration($notify);
1828
-                break;
1829
-            case EEM_Registration::status_id_not_approved:
1830
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1831
-                $this->not_approve_registration($notify);
1832
-                break;
1833
-            case EEM_Registration::status_id_declined:
1834
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1835
-                $this->decline_registration($notify);
1836
-                break;
1837
-            case EEM_Registration::status_id_cancelled:
1838
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1839
-                $this->cancel_registration($notify);
1840
-                break;
1841
-            case EEM_Registration::status_id_wait_list:
1842
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1843
-                $this->wait_list_registration($notify);
1844
-                break;
1845
-            case EEM_Registration::status_id_incomplete:
1846
-            default:
1847
-                $this->request->unSetRequestParam('return');
1848
-                $this->_reg_status_change_return('');
1849
-                break;
1850
-        }
1851
-    }
1852
-
1853
-
1854
-    /**
1855
-     * Callback for bulk action routes.
1856
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1857
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
1858
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1859
-     * when an action is happening on just a single registration).
1860
-     *
1861
-     * @param      $action
1862
-     * @param bool $notify
1863
-     */
1864
-    protected function bulk_action_on_registrations($action, $notify = false)
1865
-    {
1866
-        do_action(
1867
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1868
-            $this,
1869
-            $action,
1870
-            $notify
1871
-        );
1872
-        $method = $action . '_registration';
1873
-        if (method_exists($this, $method)) {
1874
-            $this->$method($notify);
1875
-        }
1876
-    }
1877
-
1878
-
1879
-    /**
1880
-     * approve_registration
1881
-     *
1882
-     * @param bool $notify whether or not to notify the registrant about their approval.
1883
-     * @return void
1884
-     * @throws EE_Error
1885
-     * @throws EntityNotFoundException
1886
-     * @throws InvalidArgumentException
1887
-     * @throws InvalidDataTypeException
1888
-     * @throws InvalidInterfaceException
1889
-     * @throws ReflectionException
1890
-     * @throws RuntimeException
1891
-     * @throws DomainException
1892
-     */
1893
-    protected function approve_registration($notify = false)
1894
-    {
1895
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1896
-    }
1897
-
1898
-
1899
-    /**
1900
-     * decline_registration
1901
-     *
1902
-     * @param bool $notify whether or not to notify the registrant about their status change.
1903
-     * @return void
1904
-     * @throws EE_Error
1905
-     * @throws EntityNotFoundException
1906
-     * @throws InvalidArgumentException
1907
-     * @throws InvalidDataTypeException
1908
-     * @throws InvalidInterfaceException
1909
-     * @throws ReflectionException
1910
-     * @throws RuntimeException
1911
-     * @throws DomainException
1912
-     */
1913
-    protected function decline_registration($notify = false)
1914
-    {
1915
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1916
-    }
1917
-
1918
-
1919
-    /**
1920
-     * cancel_registration
1921
-     *
1922
-     * @param bool $notify whether or not to notify the registrant about their status change.
1923
-     * @return void
1924
-     * @throws EE_Error
1925
-     * @throws EntityNotFoundException
1926
-     * @throws InvalidArgumentException
1927
-     * @throws InvalidDataTypeException
1928
-     * @throws InvalidInterfaceException
1929
-     * @throws ReflectionException
1930
-     * @throws RuntimeException
1931
-     * @throws DomainException
1932
-     */
1933
-    protected function cancel_registration($notify = false)
1934
-    {
1935
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1936
-    }
1937
-
1938
-
1939
-    /**
1940
-     * not_approve_registration
1941
-     *
1942
-     * @param bool $notify whether or not to notify the registrant about their status change.
1943
-     * @return void
1944
-     * @throws EE_Error
1945
-     * @throws EntityNotFoundException
1946
-     * @throws InvalidArgumentException
1947
-     * @throws InvalidDataTypeException
1948
-     * @throws InvalidInterfaceException
1949
-     * @throws ReflectionException
1950
-     * @throws RuntimeException
1951
-     * @throws DomainException
1952
-     */
1953
-    protected function not_approve_registration($notify = false)
1954
-    {
1955
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1956
-    }
1957
-
1958
-
1959
-    /**
1960
-     * decline_registration
1961
-     *
1962
-     * @param bool $notify whether or not to notify the registrant about their status change.
1963
-     * @return void
1964
-     * @throws EE_Error
1965
-     * @throws EntityNotFoundException
1966
-     * @throws InvalidArgumentException
1967
-     * @throws InvalidDataTypeException
1968
-     * @throws InvalidInterfaceException
1969
-     * @throws ReflectionException
1970
-     * @throws RuntimeException
1971
-     * @throws DomainException
1972
-     */
1973
-    protected function pending_registration($notify = false)
1974
-    {
1975
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1976
-    }
1977
-
1978
-
1979
-    /**
1980
-     * waitlist_registration
1981
-     *
1982
-     * @param bool $notify whether or not to notify the registrant about their status change.
1983
-     * @return void
1984
-     * @throws EE_Error
1985
-     * @throws EntityNotFoundException
1986
-     * @throws InvalidArgumentException
1987
-     * @throws InvalidDataTypeException
1988
-     * @throws InvalidInterfaceException
1989
-     * @throws ReflectionException
1990
-     * @throws RuntimeException
1991
-     * @throws DomainException
1992
-     */
1993
-    protected function wait_list_registration($notify = false)
1994
-    {
1995
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1996
-    }
1997
-
1998
-
1999
-    /**
2000
-     * generates HTML for the Registration main meta box
2001
-     *
2002
-     * @return void
2003
-     * @throws DomainException
2004
-     * @throws EE_Error
2005
-     * @throws InvalidArgumentException
2006
-     * @throws InvalidDataTypeException
2007
-     * @throws InvalidInterfaceException
2008
-     * @throws ReflectionException
2009
-     * @throws EntityNotFoundException
2010
-     */
2011
-    public function _reg_details_meta_box()
2012
-    {
2013
-        EEH_Autoloader::register_line_item_display_autoloaders();
2014
-        EEH_Autoloader::register_line_item_filter_autoloaders();
2015
-        EE_Registry::instance()->load_helper('Line_Item');
2016
-        $transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
2017
-            : EE_Transaction::new_instance();
2018
-        $this->_session = $transaction->session_data();
2019
-        $filters        = new EE_Line_Item_Filter_Collection();
2020
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2021
-        $filters->add(new EE_Non_Zero_Line_Item_Filter());
2022
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2023
-            $filters,
2024
-            $transaction->total_line_item()
2025
-        );
2026
-        $filtered_line_item_tree                 = $line_item_filter_processor->process();
2027
-        $line_item_display                       = new EE_Line_Item_Display(
2028
-            'reg_admin_table',
2029
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2030
-        );
2031
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2032
-            $filtered_line_item_tree,
2033
-            ['EE_Registration' => $this->_registration]
2034
-        );
2035
-        $attendee                                = $this->_registration->attendee();
2036
-        if (
2037
-            EE_Registry::instance()->CAP->current_user_can(
2038
-                'ee_read_transaction',
2039
-                'espresso_transactions_view_transaction'
2040
-            )
2041
-        ) {
2042
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2043
-                EE_Admin_Page::add_query_args_and_nonce(
2044
-                    [
2045
-                        'action' => 'view_transaction',
2046
-                        'TXN_ID' => $transaction->ID(),
2047
-                    ],
2048
-                    TXN_ADMIN_URL
2049
-                ),
2050
-                esc_html__(' View Transaction', 'event_espresso'),
2051
-                'button secondary-button right',
2052
-                'dashicons dashicons-cart'
2053
-            );
2054
-        } else {
2055
-            $this->_template_args['view_transaction_button'] = '';
2056
-        }
2057
-        if (
2058
-            $attendee instanceof EE_Attendee
2059
-            && EE_Registry::instance()->CAP->current_user_can(
2060
-                'ee_send_message',
2061
-                'espresso_registrations_resend_registration'
2062
-            )
2063
-        ) {
2064
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2065
-                EE_Admin_Page::add_query_args_and_nonce(
2066
-                    [
2067
-                        'action'      => 'resend_registration',
2068
-                        '_REG_ID'     => $this->_registration->ID(),
2069
-                        'redirect_to' => 'view_registration',
2070
-                    ],
2071
-                    REG_ADMIN_URL
2072
-                ),
2073
-                esc_html__(' Resend Registration', 'event_espresso'),
2074
-                'button secondary-button right',
2075
-                'dashicons dashicons-email-alt'
2076
-            );
2077
-        } else {
2078
-            $this->_template_args['resend_registration_button'] = '';
2079
-        }
2080
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2081
-        $payment                               = $transaction->get_first_related('Payment');
2082
-        $payment                               = ! $payment instanceof EE_Payment
2083
-            ? EE_Payment::new_instance()
2084
-            : $payment;
2085
-        $payment_method                        = $payment->get_first_related('Payment_Method');
2086
-        $payment_method                        = ! $payment_method instanceof EE_Payment_Method
2087
-            ? EE_Payment_Method::new_instance()
2088
-            : $payment_method;
2089
-        $reg_details                           = [
2090
-            'payment_method'       => $payment_method->name(),
2091
-            'response_msg'         => $payment->gateway_response(),
2092
-            'registration_id'      => $this->_registration->get('REG_code'),
2093
-            'registration_session' => $this->_registration->session_ID(),
2094
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2095
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2096
-        ];
2097
-        if (isset($reg_details['registration_id'])) {
2098
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2099
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2100
-                'Registration ID',
2101
-                'event_espresso'
2102
-            );
2103
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2104
-        }
2105
-        if (isset($reg_details['payment_method'])) {
2106
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2107
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2108
-                'Most Recent Payment Method',
2109
-                'event_espresso'
2110
-            );
2111
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2112
-            $this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2113
-            $this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2114
-                'Payment method response',
2115
-                'event_espresso'
2116
-            );
2117
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2118
-        }
2119
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2120
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2121
-            'Registration Session',
2122
-            'event_espresso'
2123
-        );
2124
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2125
-        $this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2126
-        $this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2127
-            'Registration placed from IP',
2128
-            'event_espresso'
2129
-        );
2130
-        $this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2131
-        $this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2132
-        $this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2133
-            'Registrant User Agent',
2134
-            'event_espresso'
2135
-        );
2136
-        $this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2137
-        $this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2138
-            [
2139
-                'action'   => 'default',
2140
-                'event_id' => $this->_registration->event_ID(),
2141
-            ],
2142
-            REG_ADMIN_URL
2143
-        );
2144
-        $this->_template_args['REG_ID']                                       = $this->_registration->ID();
2145
-        $this->_template_args['event_id']                                     = $this->_registration->event_ID();
2146
-        $template_path                                                        =
2147
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2148
-        EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2149
-    }
2150
-
2151
-
2152
-    /**
2153
-     * generates HTML for the Registration Questions meta box.
2154
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2155
-     * otherwise uses new forms system
2156
-     *
2157
-     * @return void
2158
-     * @throws DomainException
2159
-     * @throws EE_Error
2160
-     * @throws InvalidArgumentException
2161
-     * @throws InvalidDataTypeException
2162
-     * @throws InvalidInterfaceException
2163
-     * @throws ReflectionException
2164
-     */
2165
-    public function _reg_questions_meta_box()
2166
-    {
2167
-        // allow someone to override this method entirely
2168
-        if (
2169
-            apply_filters(
2170
-                'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2171
-                true,
2172
-                $this,
2173
-                $this->_registration
2174
-            )
2175
-        ) {
2176
-            $form                                              = $this->_get_reg_custom_questions_form(
2177
-                $this->_registration->ID()
2178
-            );
2179
-            $this->_template_args['att_questions']             = count($form->subforms()) > 0
2180
-                ? $form->get_html_and_js()
2181
-                : '';
2182
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2183
-            $this->_template_args['REG_ID']                    = $this->_registration->ID();
2184
-            $template_path                                     =
2185
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2186
-            EEH_Template::display_template($template_path, $this->_template_args);
2187
-        }
2188
-    }
2189
-
2190
-
2191
-    /**
2192
-     * form_before_question_group
2193
-     *
2194
-     * @param string $output
2195
-     * @return        string
2196
-     * @deprecated    as of 4.8.32.rc.000
2197
-     */
2198
-    public function form_before_question_group($output)
2199
-    {
2200
-        EE_Error::doing_it_wrong(
2201
-            __CLASS__ . '::' . __FUNCTION__,
2202
-            esc_html__(
2203
-                '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.',
2204
-                'event_espresso'
2205
-            ),
2206
-            '4.8.32.rc.000'
2207
-        );
2208
-        return '
23
+	/**
24
+	 * @var EE_Registration
25
+	 */
26
+	private $_registration;
27
+
28
+	/**
29
+	 * @var EE_Event
30
+	 */
31
+	private $_reg_event;
32
+
33
+	/**
34
+	 * @var EE_Session
35
+	 */
36
+	private $_session;
37
+
38
+	/**
39
+	 * @var array
40
+	 */
41
+	private static $_reg_status;
42
+
43
+	/**
44
+	 * Form for displaying the custom questions for this registration.
45
+	 * This gets used a few times throughout the request so its best to cache it
46
+	 *
47
+	 * @var EE_Registration_Custom_Questions_Form
48
+	 */
49
+	protected $_reg_custom_questions_form = null;
50
+
51
+	/**
52
+	 * @var EEM_Registration $registration_model
53
+	 */
54
+	private $registration_model;
55
+
56
+	/**
57
+	 * @var EEM_Attendee $attendee_model
58
+	 */
59
+	private $attendee_model;
60
+
61
+	/**
62
+	 * @var EEM_Event $event_model
63
+	 */
64
+	private $event_model;
65
+
66
+	/**
67
+	 * @var EEM_Status $status_model
68
+	 */
69
+	private $status_model;
70
+
71
+
72
+	/**
73
+	 * @param bool $routing
74
+	 * @throws EE_Error
75
+	 * @throws InvalidArgumentException
76
+	 * @throws InvalidDataTypeException
77
+	 * @throws InvalidInterfaceException
78
+	 * @throws ReflectionException
79
+	 */
80
+	public function __construct($routing = true)
81
+	{
82
+		parent::__construct($routing);
83
+		add_action('wp_loaded', [$this, 'wp_loaded']);
84
+	}
85
+
86
+
87
+	/**
88
+	 * @return EEM_Registration
89
+	 * @throws InvalidArgumentException
90
+	 * @throws InvalidDataTypeException
91
+	 * @throws InvalidInterfaceException
92
+	 * @since 4.10.2.p
93
+	 */
94
+	protected function getRegistrationModel()
95
+	{
96
+		if (! $this->registration_model instanceof EEM_Registration) {
97
+			$this->registration_model = $this->getLoader()->getShared('EEM_Registration');
98
+		}
99
+		return $this->registration_model;
100
+	}
101
+
102
+
103
+	/**
104
+	 * @return EEM_Attendee
105
+	 * @throws InvalidArgumentException
106
+	 * @throws InvalidDataTypeException
107
+	 * @throws InvalidInterfaceException
108
+	 * @since 4.10.2.p
109
+	 */
110
+	protected function getAttendeeModel()
111
+	{
112
+		if (! $this->attendee_model instanceof EEM_Attendee) {
113
+			$this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
114
+		}
115
+		return $this->attendee_model;
116
+	}
117
+
118
+
119
+	/**
120
+	 * @return EEM_Event
121
+	 * @throws InvalidArgumentException
122
+	 * @throws InvalidDataTypeException
123
+	 * @throws InvalidInterfaceException
124
+	 * @since 4.10.2.p
125
+	 */
126
+	protected function getEventModel()
127
+	{
128
+		if (! $this->event_model instanceof EEM_Event) {
129
+			$this->event_model = $this->getLoader()->getShared('EEM_Event');
130
+		}
131
+		return $this->event_model;
132
+	}
133
+
134
+
135
+	/**
136
+	 * @return EEM_Status
137
+	 * @throws InvalidArgumentException
138
+	 * @throws InvalidDataTypeException
139
+	 * @throws InvalidInterfaceException
140
+	 * @since 4.10.2.p
141
+	 */
142
+	protected function getStatusModel()
143
+	{
144
+		if (! $this->status_model instanceof EEM_Status) {
145
+			$this->status_model = $this->getLoader()->getShared('EEM_Status');
146
+		}
147
+		return $this->status_model;
148
+	}
149
+
150
+
151
+	public function wp_loaded()
152
+	{
153
+		// when adding a new registration...
154
+		$action = $this->request->getRequestParam('action');
155
+		if ($action === 'new_registration') {
156
+			EE_System::do_not_cache();
157
+			if ($this->request->getRequestParam('processing_registration', 0, 'int') !== 1) {
158
+				// and it's NOT the attendee information reg step
159
+				// force cookie expiration by setting time to last week
160
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
161
+				// and update the global
162
+				$_COOKIE['ee_registration_added'] = 0;
163
+			}
164
+		}
165
+	}
166
+
167
+
168
+	protected function _init_page_props()
169
+	{
170
+		$this->page_slug        = REG_PG_SLUG;
171
+		$this->_admin_base_url  = REG_ADMIN_URL;
172
+		$this->_admin_base_path = REG_ADMIN;
173
+		$this->page_label       = esc_html__('Registrations', 'event_espresso');
174
+		$this->_cpt_routes      = [
175
+			'add_new_attendee' => 'espresso_attendees',
176
+			'edit_attendee'    => 'espresso_attendees',
177
+			'insert_attendee'  => 'espresso_attendees',
178
+			'update_attendee'  => 'espresso_attendees',
179
+		];
180
+		$this->_cpt_model_names = [
181
+			'add_new_attendee' => 'EEM_Attendee',
182
+			'edit_attendee'    => 'EEM_Attendee',
183
+		];
184
+		$this->_cpt_edit_routes = [
185
+			'espresso_attendees' => 'edit_attendee',
186
+		];
187
+		$this->_pagenow_map     = [
188
+			'add_new_attendee' => 'post-new.php',
189
+			'edit_attendee'    => 'post.php',
190
+			'trash'            => 'post.php',
191
+		];
192
+		add_action('edit_form_after_title', [$this, 'after_title_form_fields'], 10);
193
+		// add filters so that the comment urls don't take users to a confusing 404 page
194
+		add_filter('get_comment_link', [$this, 'clear_comment_link'], 10, 2);
195
+	}
196
+
197
+
198
+	/**
199
+	 * @param string     $link    The comment permalink with '#comment-$id' appended.
200
+	 * @param WP_Comment $comment The current comment object.
201
+	 * @return string
202
+	 */
203
+	public function clear_comment_link($link, WP_Comment $comment)
204
+	{
205
+		// gotta make sure this only happens on this route
206
+		$post_type = get_post_type($comment->comment_post_ID);
207
+		if ($post_type === 'espresso_attendees') {
208
+			return '#commentsdiv';
209
+		}
210
+		return $link;
211
+	}
212
+
213
+
214
+	protected function _ajax_hooks()
215
+	{
216
+		// todo: all hooks for registrations ajax goes in here
217
+		add_action('wp_ajax_toggle_checkin_status', [$this, 'toggle_checkin_status']);
218
+	}
219
+
220
+
221
+	protected function _define_page_props()
222
+	{
223
+		$this->_admin_page_title = $this->page_label;
224
+		$this->_labels           = [
225
+			'buttons'                      => [
226
+				'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
227
+				'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
228
+				'edit'                => esc_html__('Edit Contact', 'event_espresso'),
229
+				'csv_reg_report'      => esc_html__('Registrations CSV Report', 'event_espresso'),
230
+				'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
231
+				'contact_list_export' => esc_html__('Export Data', 'event_espresso'),
232
+			],
233
+			'publishbox'                   => [
234
+				'add_new_attendee' => esc_html__('Add Contact Record', 'event_espresso'),
235
+				'edit_attendee'    => esc_html__('Update Contact Record', 'event_espresso'),
236
+			],
237
+			'hide_add_button_on_cpt_route' => [
238
+				'edit_attendee' => true,
239
+			],
240
+		];
241
+	}
242
+
243
+
244
+	/**
245
+	 * grab url requests and route them
246
+	 *
247
+	 * @return void
248
+	 * @throws EE_Error
249
+	 */
250
+	public function _set_page_routes()
251
+	{
252
+		$this->_get_registration_status_array();
253
+		$REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
254
+		$REG_ID             = $this->request->getRequestParam('reg_status_change_form[REG_ID]', $REG_ID, 'int');
255
+		$ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
256
+		$ATT_ID             = $this->request->getRequestParam('post', $ATT_ID, 'int');
257
+		$this->_page_routes = [
258
+			'default'                             => [
259
+				'func'       => '_registrations_overview_list_table',
260
+				'capability' => 'ee_read_registrations',
261
+			],
262
+			'view_registration'                   => [
263
+				'func'       => '_registration_details',
264
+				'capability' => 'ee_read_registration',
265
+				'obj_id'     => $REG_ID,
266
+			],
267
+			'edit_registration'                   => [
268
+				'func'               => '_update_attendee_registration_form',
269
+				'noheader'           => true,
270
+				'headers_sent_route' => 'view_registration',
271
+				'capability'         => 'ee_edit_registration',
272
+				'obj_id'             => $REG_ID,
273
+				'_REG_ID'            => $REG_ID,
274
+			],
275
+			'trash_registrations'                 => [
276
+				'func'       => '_trash_or_restore_registrations',
277
+				'args'       => ['trash' => true],
278
+				'noheader'   => true,
279
+				'capability' => 'ee_delete_registrations',
280
+			],
281
+			'restore_registrations'               => [
282
+				'func'       => '_trash_or_restore_registrations',
283
+				'args'       => ['trash' => false],
284
+				'noheader'   => true,
285
+				'capability' => 'ee_delete_registrations',
286
+			],
287
+			'delete_registrations'                => [
288
+				'func'       => '_delete_registrations',
289
+				'noheader'   => true,
290
+				'capability' => 'ee_delete_registrations',
291
+			],
292
+			'new_registration'                    => [
293
+				'func'       => 'new_registration',
294
+				'capability' => 'ee_edit_registrations',
295
+			],
296
+			'process_reg_step'                    => [
297
+				'func'       => 'process_reg_step',
298
+				'noheader'   => true,
299
+				'capability' => 'ee_edit_registrations',
300
+			],
301
+			'redirect_to_txn'                     => [
302
+				'func'       => 'redirect_to_txn',
303
+				'noheader'   => true,
304
+				'capability' => 'ee_edit_registrations',
305
+			],
306
+			'change_reg_status'                   => [
307
+				'func'       => '_change_reg_status',
308
+				'noheader'   => true,
309
+				'capability' => 'ee_edit_registration',
310
+				'obj_id'     => $REG_ID,
311
+			],
312
+			'approve_registration'                => [
313
+				'func'       => 'approve_registration',
314
+				'noheader'   => true,
315
+				'capability' => 'ee_edit_registration',
316
+				'obj_id'     => $REG_ID,
317
+			],
318
+			'approve_and_notify_registration'     => [
319
+				'func'       => 'approve_registration',
320
+				'noheader'   => true,
321
+				'args'       => [true],
322
+				'capability' => 'ee_edit_registration',
323
+				'obj_id'     => $REG_ID,
324
+			],
325
+			'approve_registrations'               => [
326
+				'func'       => 'bulk_action_on_registrations',
327
+				'noheader'   => true,
328
+				'capability' => 'ee_edit_registrations',
329
+				'args'       => ['approve'],
330
+			],
331
+			'approve_and_notify_registrations'    => [
332
+				'func'       => 'bulk_action_on_registrations',
333
+				'noheader'   => true,
334
+				'capability' => 'ee_edit_registrations',
335
+				'args'       => ['approve', true],
336
+			],
337
+			'decline_registration'                => [
338
+				'func'       => 'decline_registration',
339
+				'noheader'   => true,
340
+				'capability' => 'ee_edit_registration',
341
+				'obj_id'     => $REG_ID,
342
+			],
343
+			'decline_and_notify_registration'     => [
344
+				'func'       => 'decline_registration',
345
+				'noheader'   => true,
346
+				'args'       => [true],
347
+				'capability' => 'ee_edit_registration',
348
+				'obj_id'     => $REG_ID,
349
+			],
350
+			'decline_registrations'               => [
351
+				'func'       => 'bulk_action_on_registrations',
352
+				'noheader'   => true,
353
+				'capability' => 'ee_edit_registrations',
354
+				'args'       => ['decline'],
355
+			],
356
+			'decline_and_notify_registrations'    => [
357
+				'func'       => 'bulk_action_on_registrations',
358
+				'noheader'   => true,
359
+				'capability' => 'ee_edit_registrations',
360
+				'args'       => ['decline', true],
361
+			],
362
+			'pending_registration'                => [
363
+				'func'       => 'pending_registration',
364
+				'noheader'   => true,
365
+				'capability' => 'ee_edit_registration',
366
+				'obj_id'     => $REG_ID,
367
+			],
368
+			'pending_and_notify_registration'     => [
369
+				'func'       => 'pending_registration',
370
+				'noheader'   => true,
371
+				'args'       => [true],
372
+				'capability' => 'ee_edit_registration',
373
+				'obj_id'     => $REG_ID,
374
+			],
375
+			'pending_registrations'               => [
376
+				'func'       => 'bulk_action_on_registrations',
377
+				'noheader'   => true,
378
+				'capability' => 'ee_edit_registrations',
379
+				'args'       => ['pending'],
380
+			],
381
+			'pending_and_notify_registrations'    => [
382
+				'func'       => 'bulk_action_on_registrations',
383
+				'noheader'   => true,
384
+				'capability' => 'ee_edit_registrations',
385
+				'args'       => ['pending', true],
386
+			],
387
+			'no_approve_registration'             => [
388
+				'func'       => 'not_approve_registration',
389
+				'noheader'   => true,
390
+				'capability' => 'ee_edit_registration',
391
+				'obj_id'     => $REG_ID,
392
+			],
393
+			'no_approve_and_notify_registration'  => [
394
+				'func'       => 'not_approve_registration',
395
+				'noheader'   => true,
396
+				'args'       => [true],
397
+				'capability' => 'ee_edit_registration',
398
+				'obj_id'     => $REG_ID,
399
+			],
400
+			'no_approve_registrations'            => [
401
+				'func'       => 'bulk_action_on_registrations',
402
+				'noheader'   => true,
403
+				'capability' => 'ee_edit_registrations',
404
+				'args'       => ['not_approve'],
405
+			],
406
+			'no_approve_and_notify_registrations' => [
407
+				'func'       => 'bulk_action_on_registrations',
408
+				'noheader'   => true,
409
+				'capability' => 'ee_edit_registrations',
410
+				'args'       => ['not_approve', true],
411
+			],
412
+			'cancel_registration'                 => [
413
+				'func'       => 'cancel_registration',
414
+				'noheader'   => true,
415
+				'capability' => 'ee_edit_registration',
416
+				'obj_id'     => $REG_ID,
417
+			],
418
+			'cancel_and_notify_registration'      => [
419
+				'func'       => 'cancel_registration',
420
+				'noheader'   => true,
421
+				'args'       => [true],
422
+				'capability' => 'ee_edit_registration',
423
+				'obj_id'     => $REG_ID,
424
+			],
425
+			'cancel_registrations'                => [
426
+				'func'       => 'bulk_action_on_registrations',
427
+				'noheader'   => true,
428
+				'capability' => 'ee_edit_registrations',
429
+				'args'       => ['cancel'],
430
+			],
431
+			'cancel_and_notify_registrations'     => [
432
+				'func'       => 'bulk_action_on_registrations',
433
+				'noheader'   => true,
434
+				'capability' => 'ee_edit_registrations',
435
+				'args'       => ['cancel', true],
436
+			],
437
+			'wait_list_registration'              => [
438
+				'func'       => 'wait_list_registration',
439
+				'noheader'   => true,
440
+				'capability' => 'ee_edit_registration',
441
+				'obj_id'     => $REG_ID,
442
+			],
443
+			'wait_list_and_notify_registration'   => [
444
+				'func'       => 'wait_list_registration',
445
+				'noheader'   => true,
446
+				'args'       => [true],
447
+				'capability' => 'ee_edit_registration',
448
+				'obj_id'     => $REG_ID,
449
+			],
450
+			'contact_list'                        => [
451
+				'func'       => '_attendee_contact_list_table',
452
+				'capability' => 'ee_read_contacts',
453
+			],
454
+			'add_new_attendee'                    => [
455
+				'func' => '_create_new_cpt_item',
456
+				'args' => [
457
+					'new_attendee' => true,
458
+					'capability'   => 'ee_edit_contacts',
459
+				],
460
+			],
461
+			'edit_attendee'                       => [
462
+				'func'       => '_edit_cpt_item',
463
+				'capability' => 'ee_edit_contacts',
464
+				'obj_id'     => $ATT_ID,
465
+			],
466
+			'duplicate_attendee'                  => [
467
+				'func'       => '_duplicate_attendee',
468
+				'noheader'   => true,
469
+				'capability' => 'ee_edit_contacts',
470
+				'obj_id'     => $ATT_ID,
471
+			],
472
+			'insert_attendee'                     => [
473
+				'func'       => '_insert_or_update_attendee',
474
+				'args'       => [
475
+					'new_attendee' => true,
476
+				],
477
+				'noheader'   => true,
478
+				'capability' => 'ee_edit_contacts',
479
+			],
480
+			'update_attendee'                     => [
481
+				'func'       => '_insert_or_update_attendee',
482
+				'args'       => [
483
+					'new_attendee' => false,
484
+				],
485
+				'noheader'   => true,
486
+				'capability' => 'ee_edit_contacts',
487
+				'obj_id'     => $ATT_ID,
488
+			],
489
+			'trash_attendees'                     => [
490
+				'func'       => '_trash_or_restore_attendees',
491
+				'args'       => [
492
+					'trash' => 'true',
493
+				],
494
+				'noheader'   => true,
495
+				'capability' => 'ee_delete_contacts',
496
+			],
497
+			'trash_attendee'                      => [
498
+				'func'       => '_trash_or_restore_attendees',
499
+				'args'       => [
500
+					'trash' => true,
501
+				],
502
+				'noheader'   => true,
503
+				'capability' => 'ee_delete_contacts',
504
+				'obj_id'     => $ATT_ID,
505
+			],
506
+			'restore_attendees'                   => [
507
+				'func'       => '_trash_or_restore_attendees',
508
+				'args'       => [
509
+					'trash' => false,
510
+				],
511
+				'noheader'   => true,
512
+				'capability' => 'ee_delete_contacts',
513
+				'obj_id'     => $ATT_ID,
514
+			],
515
+			'resend_registration'                 => [
516
+				'func'       => '_resend_registration',
517
+				'noheader'   => true,
518
+				'capability' => 'ee_send_message',
519
+			],
520
+			'registrations_report'                => [
521
+				'func'       => '_registrations_report',
522
+				'noheader'   => true,
523
+				'capability' => 'ee_read_registrations',
524
+			],
525
+			'contact_list_export'                 => [
526
+				'func'       => '_contact_list_export',
527
+				'noheader'   => true,
528
+				'capability' => 'export',
529
+			],
530
+			'contact_list_report'                 => [
531
+				'func'       => '_contact_list_report',
532
+				'noheader'   => true,
533
+				'capability' => 'ee_read_contacts',
534
+			],
535
+		];
536
+	}
537
+
538
+
539
+	protected function _set_page_config()
540
+	{
541
+		$REG_ID             = $this->request->getRequestParam('_REG_ID', 0, 'int');
542
+		$ATT_ID             = $this->request->getRequestParam('ATT_ID', 0, 'int');
543
+		$this->_page_config = [
544
+			'default'           => [
545
+				'nav'           => [
546
+					'label' => esc_html__('Overview', 'event_espresso'),
547
+					'order' => 5,
548
+				],
549
+				'help_tabs'     => [
550
+					'registrations_overview_help_tab'                       => [
551
+						'title'    => esc_html__('Registrations Overview', 'event_espresso'),
552
+						'filename' => 'registrations_overview',
553
+					],
554
+					'registrations_overview_table_column_headings_help_tab' => [
555
+						'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
556
+						'filename' => 'registrations_overview_table_column_headings',
557
+					],
558
+					'registrations_overview_filters_help_tab'               => [
559
+						'title'    => esc_html__('Registration Filters', 'event_espresso'),
560
+						'filename' => 'registrations_overview_filters',
561
+					],
562
+					'registrations_overview_views_help_tab'                 => [
563
+						'title'    => esc_html__('Registration Views', 'event_espresso'),
564
+						'filename' => 'registrations_overview_views',
565
+					],
566
+					'registrations_regoverview_other_help_tab'              => [
567
+						'title'    => esc_html__('Registrations Other', 'event_espresso'),
568
+						'filename' => 'registrations_overview_other',
569
+					],
570
+				],
571
+				'qtips'         => ['Registration_List_Table_Tips'],
572
+				'list_table'    => 'EE_Registrations_List_Table',
573
+				'require_nonce' => false,
574
+			],
575
+			'view_registration' => [
576
+				'nav'           => [
577
+					'label'      => esc_html__('REG Details', 'event_espresso'),
578
+					'order'      => 15,
579
+					'url'        => $REG_ID
580
+						? add_query_arg(['_REG_ID' => $REG_ID], $this->_current_page_view_url)
581
+						: $this->_admin_base_url,
582
+					'persistent' => false,
583
+				],
584
+				'help_tabs'     => [
585
+					'registrations_details_help_tab'                    => [
586
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
587
+						'filename' => 'registrations_details',
588
+					],
589
+					'registrations_details_table_help_tab'              => [
590
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
591
+						'filename' => 'registrations_details_table',
592
+					],
593
+					'registrations_details_form_answers_help_tab'       => [
594
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
595
+						'filename' => 'registrations_details_form_answers',
596
+					],
597
+					'registrations_details_registrant_details_help_tab' => [
598
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
599
+						'filename' => 'registrations_details_registrant_details',
600
+					],
601
+				],
602
+				'metaboxes'     => array_merge(
603
+					$this->_default_espresso_metaboxes,
604
+					['_registration_details_metaboxes']
605
+				),
606
+				'require_nonce' => false,
607
+			],
608
+			'new_registration'  => [
609
+				'nav'           => [
610
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
611
+					'url'        => '#',
612
+					'order'      => 15,
613
+					'persistent' => false,
614
+				],
615
+				'metaboxes'     => $this->_default_espresso_metaboxes,
616
+				'labels'        => [
617
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
618
+				],
619
+				'require_nonce' => false,
620
+			],
621
+			'add_new_attendee'  => [
622
+				'nav'           => [
623
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
624
+					'order'      => 15,
625
+					'persistent' => false,
626
+				],
627
+				'metaboxes'     => array_merge(
628
+					$this->_default_espresso_metaboxes,
629
+					['_publish_post_box', 'attendee_editor_metaboxes']
630
+				),
631
+				'require_nonce' => false,
632
+			],
633
+			'edit_attendee'     => [
634
+				'nav'           => [
635
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
636
+					'order'      => 15,
637
+					'persistent' => false,
638
+					'url'        => $ATT_ID
639
+						? add_query_arg(['ATT_ID' => $ATT_ID], $this->_current_page_view_url)
640
+						: $this->_admin_base_url,
641
+				],
642
+				'metaboxes'     => ['attendee_editor_metaboxes'],
643
+				'require_nonce' => false,
644
+			],
645
+			'contact_list'      => [
646
+				'nav'           => [
647
+					'label' => esc_html__('Contact List', 'event_espresso'),
648
+					'order' => 20,
649
+				],
650
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
651
+				'help_tabs'     => [
652
+					'registrations_contact_list_help_tab'                       => [
653
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
654
+						'filename' => 'registrations_contact_list',
655
+					],
656
+					'registrations_contact-list_table_column_headings_help_tab' => [
657
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
658
+						'filename' => 'registrations_contact_list_table_column_headings',
659
+					],
660
+					'registrations_contact_list_views_help_tab'                 => [
661
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
662
+						'filename' => 'registrations_contact_list_views',
663
+					],
664
+					'registrations_contact_list_other_help_tab'                 => [
665
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
666
+						'filename' => 'registrations_contact_list_other',
667
+					],
668
+				],
669
+				'metaboxes'     => [],
670
+				'require_nonce' => false,
671
+			],
672
+			// override default cpt routes
673
+			'create_new'        => '',
674
+			'edit'              => '',
675
+		];
676
+	}
677
+
678
+
679
+	/**
680
+	 * The below methods aren't used by this class currently
681
+	 */
682
+	protected function _add_screen_options()
683
+	{
684
+	}
685
+
686
+
687
+	protected function _add_feature_pointers()
688
+	{
689
+	}
690
+
691
+
692
+	public function admin_init()
693
+	{
694
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
695
+			'click "Update Registration Questions" to save your changes',
696
+			'event_espresso'
697
+		);
698
+	}
699
+
700
+
701
+	public function admin_notices()
702
+	{
703
+	}
704
+
705
+
706
+	public function admin_footer_scripts()
707
+	{
708
+	}
709
+
710
+
711
+	/**
712
+	 * get list of registration statuses
713
+	 *
714
+	 * @return void
715
+	 * @throws EE_Error
716
+	 */
717
+	private function _get_registration_status_array()
718
+	{
719
+		self::$_reg_status = EEM_Registration::reg_status_array([], true);
720
+	}
721
+
722
+
723
+	/**
724
+	 * @throws InvalidArgumentException
725
+	 * @throws InvalidDataTypeException
726
+	 * @throws InvalidInterfaceException
727
+	 * @since 4.10.2.p
728
+	 */
729
+	protected function _add_screen_options_default()
730
+	{
731
+		$this->_per_page_screen_option();
732
+	}
733
+
734
+
735
+	/**
736
+	 * @throws InvalidArgumentException
737
+	 * @throws InvalidDataTypeException
738
+	 * @throws InvalidInterfaceException
739
+	 * @since 4.10.2.p
740
+	 */
741
+	protected function _add_screen_options_contact_list()
742
+	{
743
+		$page_title              = $this->_admin_page_title;
744
+		$this->_admin_page_title = esc_html__('Contacts', 'event_espresso');
745
+		$this->_per_page_screen_option();
746
+		$this->_admin_page_title = $page_title;
747
+	}
748
+
749
+
750
+	public function load_scripts_styles()
751
+	{
752
+		// style
753
+		wp_register_style(
754
+			'espresso_reg',
755
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
756
+			['ee-admin-css'],
757
+			EVENT_ESPRESSO_VERSION
758
+		);
759
+		wp_enqueue_style('espresso_reg');
760
+		// script
761
+		wp_register_script(
762
+			'espresso_reg',
763
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
764
+			['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
765
+			EVENT_ESPRESSO_VERSION,
766
+			true
767
+		);
768
+		wp_enqueue_script('espresso_reg');
769
+	}
770
+
771
+
772
+	/**
773
+	 * @throws EE_Error
774
+	 * @throws InvalidArgumentException
775
+	 * @throws InvalidDataTypeException
776
+	 * @throws InvalidInterfaceException
777
+	 * @throws ReflectionException
778
+	 * @since 4.10.2.p
779
+	 */
780
+	public function load_scripts_styles_edit_attendee()
781
+	{
782
+		// stuff to only show up on our attendee edit details page.
783
+		$attendee_details_translations = [
784
+			'att_publish_text' => sprintf(
785
+			/* translators: The date and time */
786
+				wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
787
+				'<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
788
+			),
789
+		];
790
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
791
+		wp_enqueue_script('jquery-validate');
792
+	}
793
+
794
+
795
+	/**
796
+	 * @throws EE_Error
797
+	 * @throws InvalidArgumentException
798
+	 * @throws InvalidDataTypeException
799
+	 * @throws InvalidInterfaceException
800
+	 * @throws ReflectionException
801
+	 * @since 4.10.2.p
802
+	 */
803
+	public function load_scripts_styles_view_registration()
804
+	{
805
+		// styles
806
+		wp_enqueue_style('espresso-ui-theme');
807
+		// scripts
808
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
809
+		$this->_reg_custom_questions_form->wp_enqueue_scripts();
810
+	}
811
+
812
+
813
+	public function load_scripts_styles_contact_list()
814
+	{
815
+		wp_dequeue_style('espresso_reg');
816
+		wp_register_style(
817
+			'espresso_att',
818
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
819
+			['ee-admin-css'],
820
+			EVENT_ESPRESSO_VERSION
821
+		);
822
+		wp_enqueue_style('espresso_att');
823
+	}
824
+
825
+
826
+	public function load_scripts_styles_new_registration()
827
+	{
828
+		wp_register_script(
829
+			'ee-spco-for-admin',
830
+			REG_ASSETS_URL . 'spco_for_admin.js',
831
+			['underscore', 'jquery'],
832
+			EVENT_ESPRESSO_VERSION,
833
+			true
834
+		);
835
+		wp_enqueue_script('ee-spco-for-admin');
836
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
837
+		EE_Form_Section_Proper::wp_enqueue_scripts();
838
+		EED_Ticket_Selector::load_tckt_slctr_assets();
839
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
840
+	}
841
+
842
+
843
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
844
+	{
845
+		add_filter('FHEE_load_EE_messages', '__return_true');
846
+	}
847
+
848
+
849
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
850
+	{
851
+		add_filter('FHEE_load_EE_messages', '__return_true');
852
+	}
853
+
854
+
855
+	/**
856
+	 * @throws EE_Error
857
+	 * @throws InvalidArgumentException
858
+	 * @throws InvalidDataTypeException
859
+	 * @throws InvalidInterfaceException
860
+	 * @throws ReflectionException
861
+	 * @since 4.10.2.p
862
+	 */
863
+	protected function _set_list_table_views_default()
864
+	{
865
+		// for notification related bulk actions we need to make sure only active messengers have an option.
866
+		EED_Messages::set_autoloaders();
867
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
868
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
869
+		$active_mts               = $message_resource_manager->list_of_active_message_types();
870
+		// key= bulk_action_slug, value= message type.
871
+		$match_array = [
872
+			'approve_registrations'    => 'registration',
873
+			'decline_registrations'    => 'declined_registration',
874
+			'pending_registrations'    => 'pending_approval',
875
+			'no_approve_registrations' => 'not_approved_registration',
876
+			'cancel_registrations'     => 'cancelled_registration',
877
+		];
878
+		$can_send    = EE_Registry::instance()->CAP->current_user_can(
879
+			'ee_send_message',
880
+			'batch_send_messages'
881
+		);
882
+		/** setup reg status bulk actions **/
883
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
884
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
885
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
886
+				'Approve and Notify Registrations',
887
+				'event_espresso'
888
+			);
889
+		}
890
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
891
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
892
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
893
+				'Decline and Notify Registrations',
894
+				'event_espresso'
895
+			);
896
+		}
897
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
898
+			'Set Registrations to Pending Payment',
899
+			'event_espresso'
900
+		);
901
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
902
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
903
+				'Set Registrations to Pending Payment and Notify',
904
+				'event_espresso'
905
+			);
906
+		}
907
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
908
+			'Set Registrations to Not Approved',
909
+			'event_espresso'
910
+		);
911
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
912
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
913
+				'Set Registrations to Not Approved and Notify',
914
+				'event_espresso'
915
+			);
916
+		}
917
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
918
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
919
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
920
+				'Cancel Registrations and Notify',
921
+				'event_espresso'
922
+			);
923
+		}
924
+		$def_reg_status_actions = apply_filters(
925
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
926
+			$def_reg_status_actions,
927
+			$active_mts,
928
+			$can_send
929
+		);
930
+
931
+		$this->_views = [
932
+			'all'   => [
933
+				'slug'        => 'all',
934
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
935
+				'count'       => 0,
936
+				'bulk_action' => array_merge(
937
+					$def_reg_status_actions,
938
+					[
939
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
940
+					]
941
+				),
942
+			],
943
+			'month' => [
944
+				'slug'        => 'month',
945
+				'label'       => esc_html__('This Month', 'event_espresso'),
946
+				'count'       => 0,
947
+				'bulk_action' => array_merge(
948
+					$def_reg_status_actions,
949
+					[
950
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
951
+					]
952
+				),
953
+			],
954
+			'today' => [
955
+				'slug'        => 'today',
956
+				'label'       => sprintf(
957
+					esc_html__('Today - %s', 'event_espresso'),
958
+					date('M d, Y', current_time('timestamp'))
959
+				),
960
+				'count'       => 0,
961
+				'bulk_action' => array_merge(
962
+					$def_reg_status_actions,
963
+					[
964
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
965
+					]
966
+				),
967
+			],
968
+		];
969
+		if (
970
+			EE_Registry::instance()->CAP->current_user_can(
971
+				'ee_delete_registrations',
972
+				'espresso_registrations_delete_registration'
973
+			)
974
+		) {
975
+			$this->_views['incomplete'] = [
976
+				'slug'        => 'incomplete',
977
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
978
+				'count'       => 0,
979
+				'bulk_action' => [
980
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
981
+				],
982
+			];
983
+			$this->_views['trash']      = [
984
+				'slug'        => 'trash',
985
+				'label'       => esc_html__('Trash', 'event_espresso'),
986
+				'count'       => 0,
987
+				'bulk_action' => [
988
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
989
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
990
+				],
991
+			];
992
+		}
993
+	}
994
+
995
+
996
+	protected function _set_list_table_views_contact_list()
997
+	{
998
+		$this->_views = [
999
+			'in_use' => [
1000
+				'slug'        => 'in_use',
1001
+				'label'       => esc_html__('In Use', 'event_espresso'),
1002
+				'count'       => 0,
1003
+				'bulk_action' => [
1004
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
1005
+				],
1006
+			],
1007
+		];
1008
+		if (
1009
+			EE_Registry::instance()->CAP->current_user_can(
1010
+				'ee_delete_contacts',
1011
+				'espresso_registrations_trash_attendees'
1012
+			)
1013
+		) {
1014
+			$this->_views['trash'] = [
1015
+				'slug'        => 'trash',
1016
+				'label'       => esc_html__('Trash', 'event_espresso'),
1017
+				'count'       => 0,
1018
+				'bulk_action' => [
1019
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
1020
+				],
1021
+			];
1022
+		}
1023
+	}
1024
+
1025
+
1026
+	/**
1027
+	 * @return array
1028
+	 * @throws EE_Error
1029
+	 */
1030
+	protected function _registration_legend_items()
1031
+	{
1032
+		$fc_items = [
1033
+			'star-icon'        => [
1034
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
1035
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
1036
+			],
1037
+			'view_details'     => [
1038
+				'class' => 'dashicons dashicons-clipboard',
1039
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
1040
+			],
1041
+			'edit_attendee'    => [
1042
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
1043
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
1044
+			],
1045
+			'view_transaction' => [
1046
+				'class' => 'dashicons dashicons-cart',
1047
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
1048
+			],
1049
+			'view_invoice'     => [
1050
+				'class' => 'dashicons dashicons-media-spreadsheet',
1051
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
1052
+			],
1053
+		];
1054
+		if (
1055
+			EE_Registry::instance()->CAP->current_user_can(
1056
+				'ee_send_message',
1057
+				'espresso_registrations_resend_registration'
1058
+			)
1059
+		) {
1060
+			$fc_items['resend_registration'] = [
1061
+				'class' => 'dashicons dashicons-email-alt',
1062
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
1063
+			];
1064
+		} else {
1065
+			$fc_items['blank'] = ['class' => 'blank', 'desc' => ''];
1066
+		}
1067
+		if (
1068
+			EE_Registry::instance()->CAP->current_user_can(
1069
+				'ee_read_global_messages',
1070
+				'view_filtered_messages'
1071
+			)
1072
+		) {
1073
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
1074
+			if (is_array($related_for_icon) && isset($related_for_icon['css_class'], $related_for_icon['label'])) {
1075
+				$fc_items['view_related_messages'] = [
1076
+					'class' => $related_for_icon['css_class'],
1077
+					'desc'  => $related_for_icon['label'],
1078
+				];
1079
+			}
1080
+		}
1081
+		$sc_items = [
1082
+			'approved_status'   => [
1083
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1084
+				'desc'  => EEH_Template::pretty_status(
1085
+					EEM_Registration::status_id_approved,
1086
+					false,
1087
+					'sentence'
1088
+				),
1089
+			],
1090
+			'pending_status'    => [
1091
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1092
+				'desc'  => EEH_Template::pretty_status(
1093
+					EEM_Registration::status_id_pending_payment,
1094
+					false,
1095
+					'sentence'
1096
+				),
1097
+			],
1098
+			'wait_list'         => [
1099
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1100
+				'desc'  => EEH_Template::pretty_status(
1101
+					EEM_Registration::status_id_wait_list,
1102
+					false,
1103
+					'sentence'
1104
+				),
1105
+			],
1106
+			'incomplete_status' => [
1107
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1108
+				'desc'  => EEH_Template::pretty_status(
1109
+					EEM_Registration::status_id_incomplete,
1110
+					false,
1111
+					'sentence'
1112
+				),
1113
+			],
1114
+			'not_approved'      => [
1115
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1116
+				'desc'  => EEH_Template::pretty_status(
1117
+					EEM_Registration::status_id_not_approved,
1118
+					false,
1119
+					'sentence'
1120
+				),
1121
+			],
1122
+			'declined_status'   => [
1123
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1124
+				'desc'  => EEH_Template::pretty_status(
1125
+					EEM_Registration::status_id_declined,
1126
+					false,
1127
+					'sentence'
1128
+				),
1129
+			],
1130
+			'cancelled_status'  => [
1131
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1132
+				'desc'  => EEH_Template::pretty_status(
1133
+					EEM_Registration::status_id_cancelled,
1134
+					false,
1135
+					'sentence'
1136
+				),
1137
+			],
1138
+		];
1139
+		return array_merge($fc_items, $sc_items);
1140
+	}
1141
+
1142
+
1143
+
1144
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1145
+
1146
+
1147
+	/**
1148
+	 * @throws DomainException
1149
+	 * @throws EE_Error
1150
+	 * @throws InvalidArgumentException
1151
+	 * @throws InvalidDataTypeException
1152
+	 * @throws InvalidInterfaceException
1153
+	 */
1154
+	protected function _registrations_overview_list_table()
1155
+	{
1156
+		$this->appendAddNewRegistrationButtonToPageTitle();
1157
+		$header_text                  = '';
1158
+		$admin_page_header_decorators = [
1159
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader',
1160
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader',
1161
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader',
1162
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader',
1163
+		];
1164
+		foreach ($admin_page_header_decorators as $admin_page_header_decorator) {
1165
+			$filter_header_decorator = $this->getLoader()->getNew($admin_page_header_decorator);
1166
+			$header_text             = $filter_header_decorator->getHeaderText($header_text);
1167
+		}
1168
+		$this->_template_args['admin_page_header'] = $header_text;
1169
+		$this->_template_args['after_list_table']  = $this->_display_legend($this->_registration_legend_items());
1170
+		$this->display_admin_list_table_page_with_no_sidebar();
1171
+	}
1172
+
1173
+
1174
+	/**
1175
+	 * @throws EE_Error
1176
+	 * @throws InvalidArgumentException
1177
+	 * @throws InvalidDataTypeException
1178
+	 * @throws InvalidInterfaceException
1179
+	 */
1180
+	private function appendAddNewRegistrationButtonToPageTitle()
1181
+	{
1182
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
1183
+		if (
1184
+			$EVT_ID
1185
+			&& EE_Registry::instance()->CAP->current_user_can(
1186
+				'ee_edit_registrations',
1187
+				'espresso_registrations_new_registration',
1188
+				$EVT_ID
1189
+			)
1190
+		) {
1191
+			$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1192
+				'new_registration',
1193
+				'add-registrant',
1194
+				['event_id' => $EVT_ID],
1195
+				'add-new-h2'
1196
+			);
1197
+		}
1198
+	}
1199
+
1200
+
1201
+	/**
1202
+	 * This sets the _registration property for the registration details screen
1203
+	 *
1204
+	 * @return void
1205
+	 * @throws EE_Error
1206
+	 * @throws InvalidArgumentException
1207
+	 * @throws InvalidDataTypeException
1208
+	 * @throws InvalidInterfaceException
1209
+	 */
1210
+	private function _set_registration_object()
1211
+	{
1212
+		// get out if we've already set the object
1213
+		if ($this->_registration instanceof EE_Registration) {
1214
+			return;
1215
+		}
1216
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
1217
+		if ($this->_registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID)) {
1218
+			return;
1219
+		}
1220
+		$error_msg = sprintf(
1221
+			esc_html__(
1222
+				'An error occurred and the details for Registration ID #%s could not be retrieved.',
1223
+				'event_espresso'
1224
+			),
1225
+			$REG_ID
1226
+		);
1227
+		EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1228
+		$this->_registration = null;
1229
+	}
1230
+
1231
+
1232
+	/**
1233
+	 * Used to retrieve registrations for the list table.
1234
+	 *
1235
+	 * @param int  $per_page
1236
+	 * @param bool $count
1237
+	 * @param bool $this_month
1238
+	 * @param bool $today
1239
+	 * @return EE_Registration[]|int
1240
+	 * @throws EE_Error
1241
+	 * @throws InvalidArgumentException
1242
+	 * @throws InvalidDataTypeException
1243
+	 * @throws InvalidInterfaceException
1244
+	 */
1245
+	public function get_registrations(
1246
+		$per_page = 10,
1247
+		$count = false,
1248
+		$this_month = false,
1249
+		$today = false
1250
+	) {
1251
+		if ($this_month) {
1252
+			$this->request->setRequestParam('status', 'month');
1253
+		}
1254
+		if ($today) {
1255
+			$this->request->setRequestParam('status', 'today');
1256
+		}
1257
+		$query_params = $this->_get_registration_query_parameters($this->request->requestParams(), $per_page, $count);
1258
+		/**
1259
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1260
+		 *
1261
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1262
+		 * @see  https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1263
+		 *                      or if you have the development copy of EE you can view this at the path:
1264
+		 *                      /docs/G--Model-System/model-query-params.md
1265
+		 */
1266
+		$query_params['group_by'] = '';
1267
+
1268
+		return $count
1269
+			? $this->getRegistrationModel()->count($query_params)
1270
+			/** @type EE_Registration[] */
1271
+			: $this->getRegistrationModel()->get_all($query_params);
1272
+	}
1273
+
1274
+
1275
+	/**
1276
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1277
+	 * Note: this listens to values on the request for some of the query parameters.
1278
+	 *
1279
+	 * @param array $request
1280
+	 * @param int   $per_page
1281
+	 * @param bool  $count
1282
+	 * @return array
1283
+	 * @throws EE_Error
1284
+	 * @throws InvalidArgumentException
1285
+	 * @throws InvalidDataTypeException
1286
+	 * @throws InvalidInterfaceException
1287
+	 */
1288
+	protected function _get_registration_query_parameters(
1289
+		$request = [],
1290
+		$per_page = 10,
1291
+		$count = false
1292
+	) {
1293
+		/** @var EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder $list_table_query_builder */
1294
+		$list_table_query_builder = $this->getLoader()->getNew(
1295
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder',
1296
+			[null, null, $request]
1297
+		);
1298
+		return $list_table_query_builder->getQueryParams($per_page, $count);
1299
+	}
1300
+
1301
+
1302
+	public function get_registration_status_array()
1303
+	{
1304
+		return self::$_reg_status;
1305
+	}
1306
+
1307
+
1308
+
1309
+
1310
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1311
+	/**
1312
+	 * generates HTML for the View Registration Details Admin page
1313
+	 *
1314
+	 * @return void
1315
+	 * @throws DomainException
1316
+	 * @throws EE_Error
1317
+	 * @throws InvalidArgumentException
1318
+	 * @throws InvalidDataTypeException
1319
+	 * @throws InvalidInterfaceException
1320
+	 * @throws EntityNotFoundException
1321
+	 * @throws ReflectionException
1322
+	 */
1323
+	protected function _registration_details()
1324
+	{
1325
+		$this->_template_args = [];
1326
+		$this->_set_registration_object();
1327
+		if (is_object($this->_registration)) {
1328
+			$transaction                                   = $this->_registration->transaction()
1329
+				? $this->_registration->transaction()
1330
+				: EE_Transaction::new_instance();
1331
+			$this->_session                                = $transaction->session_data();
1332
+			$event_id                                      = $this->_registration->event_ID();
1333
+			$this->_template_args['reg_nmbr']['value']     = $this->_registration->ID();
1334
+			$this->_template_args['reg_nmbr']['label']     = esc_html__('Registration Number', 'event_espresso');
1335
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1336
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1337
+			$this->_template_args['grand_total']           = $transaction->total();
1338
+			$this->_template_args['currency_sign']         = EE_Registry::instance()->CFG->currency->sign;
1339
+			// link back to overview
1340
+			$this->_template_args['reg_overview_url']            = REG_ADMIN_URL;
1341
+			$this->_template_args['registration']                = $this->_registration;
1342
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1343
+				[
1344
+					'action'   => 'default',
1345
+					'event_id' => $event_id,
1346
+				],
1347
+				REG_ADMIN_URL
1348
+			);
1349
+			$this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1350
+				[
1351
+					'action' => 'default',
1352
+					'EVT_ID' => $event_id,
1353
+					'page'   => 'espresso_transactions',
1354
+				],
1355
+				admin_url('admin.php')
1356
+			);
1357
+			$this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1358
+				[
1359
+					'page'   => 'espresso_events',
1360
+					'action' => 'edit',
1361
+					'post'   => $event_id,
1362
+				],
1363
+				admin_url('admin.php')
1364
+			);
1365
+			// next and previous links
1366
+			$next_reg                                      = $this->_registration->next(
1367
+				null,
1368
+				[],
1369
+				'REG_ID'
1370
+			);
1371
+			$this->_template_args['next_registration']     = $next_reg
1372
+				? $this->_next_link(
1373
+					EE_Admin_Page::add_query_args_and_nonce(
1374
+						[
1375
+							'action'  => 'view_registration',
1376
+							'_REG_ID' => $next_reg['REG_ID'],
1377
+						],
1378
+						REG_ADMIN_URL
1379
+					),
1380
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1381
+				)
1382
+				: '';
1383
+			$previous_reg                                  = $this->_registration->previous(
1384
+				null,
1385
+				[],
1386
+				'REG_ID'
1387
+			);
1388
+			$this->_template_args['previous_registration'] = $previous_reg
1389
+				? $this->_previous_link(
1390
+					EE_Admin_Page::add_query_args_and_nonce(
1391
+						[
1392
+							'action'  => 'view_registration',
1393
+							'_REG_ID' => $previous_reg['REG_ID'],
1394
+						],
1395
+						REG_ADMIN_URL
1396
+					),
1397
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1398
+				)
1399
+				: '';
1400
+			// grab header
1401
+			$template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1402
+			$this->_template_args['REG_ID']            = $this->_registration->ID();
1403
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1404
+				$template_path,
1405
+				$this->_template_args,
1406
+				true
1407
+			);
1408
+		} else {
1409
+			$this->_template_args['admin_page_header'] = '';
1410
+			$this->_display_espresso_notices();
1411
+		}
1412
+		// the details template wrapper
1413
+		$this->display_admin_page_with_sidebar();
1414
+	}
1415
+
1416
+
1417
+	/**
1418
+	 * @throws EE_Error
1419
+	 * @throws InvalidArgumentException
1420
+	 * @throws InvalidDataTypeException
1421
+	 * @throws InvalidInterfaceException
1422
+	 * @throws ReflectionException
1423
+	 * @since 4.10.2.p
1424
+	 */
1425
+	protected function _registration_details_metaboxes()
1426
+	{
1427
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1428
+		$this->_set_registration_object();
1429
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1430
+		add_meta_box(
1431
+			'edit-reg-status-mbox',
1432
+			esc_html__('Registration Status', 'event_espresso'),
1433
+			[$this, 'set_reg_status_buttons_metabox'],
1434
+			$this->_wp_page_slug,
1435
+			'normal',
1436
+			'high'
1437
+		);
1438
+		add_meta_box(
1439
+			'edit-reg-details-mbox',
1440
+			esc_html__('Registration Details', 'event_espresso'),
1441
+			[$this, '_reg_details_meta_box'],
1442
+			$this->_wp_page_slug,
1443
+			'normal',
1444
+			'high'
1445
+		);
1446
+		if (
1447
+			$attendee instanceof EE_Attendee
1448
+			&& EE_Registry::instance()->CAP->current_user_can(
1449
+				'ee_read_registration',
1450
+				'edit-reg-questions-mbox',
1451
+				$this->_registration->ID()
1452
+			)
1453
+		) {
1454
+			add_meta_box(
1455
+				'edit-reg-questions-mbox',
1456
+				esc_html__('Registration Form Answers', 'event_espresso'),
1457
+				[$this, '_reg_questions_meta_box'],
1458
+				$this->_wp_page_slug,
1459
+				'normal',
1460
+				'high'
1461
+			);
1462
+		}
1463
+		add_meta_box(
1464
+			'edit-reg-registrant-mbox',
1465
+			esc_html__('Contact Details', 'event_espresso'),
1466
+			[$this, '_reg_registrant_side_meta_box'],
1467
+			$this->_wp_page_slug,
1468
+			'side',
1469
+			'high'
1470
+		);
1471
+		if ($this->_registration->group_size() > 1) {
1472
+			add_meta_box(
1473
+				'edit-reg-attendees-mbox',
1474
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1475
+				[$this, '_reg_attendees_meta_box'],
1476
+				$this->_wp_page_slug,
1477
+				'normal',
1478
+				'high'
1479
+			);
1480
+		}
1481
+	}
1482
+
1483
+
1484
+	/**
1485
+	 * set_reg_status_buttons_metabox
1486
+	 *
1487
+	 * @return void
1488
+	 * @throws EE_Error
1489
+	 * @throws EntityNotFoundException
1490
+	 * @throws InvalidArgumentException
1491
+	 * @throws InvalidDataTypeException
1492
+	 * @throws InvalidInterfaceException
1493
+	 * @throws ReflectionException
1494
+	 */
1495
+	public function set_reg_status_buttons_metabox()
1496
+	{
1497
+		$this->_set_registration_object();
1498
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1499
+		$output                 = $change_reg_status_form->form_open(
1500
+			self::add_query_args_and_nonce(
1501
+				[
1502
+					'action' => 'change_reg_status',
1503
+				],
1504
+				REG_ADMIN_URL
1505
+			)
1506
+		);
1507
+		$output                 .= $change_reg_status_form->get_html();
1508
+		$output                 .= $change_reg_status_form->form_close();
1509
+		echo wp_kses($output, AllowedTags::getWithFormTags());
1510
+	}
1511
+
1512
+
1513
+	/**
1514
+	 * @return EE_Form_Section_Proper
1515
+	 * @throws EE_Error
1516
+	 * @throws InvalidArgumentException
1517
+	 * @throws InvalidDataTypeException
1518
+	 * @throws InvalidInterfaceException
1519
+	 * @throws EntityNotFoundException
1520
+	 * @throws ReflectionException
1521
+	 */
1522
+	protected function _generate_reg_status_change_form()
1523
+	{
1524
+		$reg_status_change_form_array = [
1525
+			'name'            => 'reg_status_change_form',
1526
+			'html_id'         => 'reg-status-change-form',
1527
+			'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1528
+			'subsections'     => [
1529
+				'return'         => new EE_Hidden_Input(
1530
+					[
1531
+						'name'    => 'return',
1532
+						'default' => 'view_registration',
1533
+					]
1534
+				),
1535
+				'REG_ID'         => new EE_Hidden_Input(
1536
+					[
1537
+						'name'    => 'REG_ID',
1538
+						'default' => $this->_registration->ID(),
1539
+					]
1540
+				),
1541
+				'current_status' => new EE_Form_Section_HTML(
1542
+					EEH_HTML::table(
1543
+						EEH_HTML::tr(
1544
+							EEH_HTML::th(
1545
+								EEH_HTML::label(
1546
+									EEH_HTML::strong(
1547
+										esc_html__('Current Registration Status', 'event_espresso')
1548
+									)
1549
+								)
1550
+							)
1551
+							. EEH_HTML::td(
1552
+								EEH_HTML::strong(
1553
+									$this->_registration->pretty_status(),
1554
+									'',
1555
+									'status-' . $this->_registration->status_ID(),
1556
+									'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1557
+								)
1558
+							)
1559
+						)
1560
+					)
1561
+				),
1562
+			],
1563
+		];
1564
+		if (
1565
+			EE_Registry::instance()->CAP->current_user_can(
1566
+				'ee_edit_registration',
1567
+				'toggle_registration_status',
1568
+				$this->_registration->ID()
1569
+			)
1570
+		) {
1571
+			$reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1572
+				$this->_get_reg_statuses(),
1573
+				[
1574
+					'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1575
+					'default'         => $this->_registration->status_ID(),
1576
+				]
1577
+			);
1578
+			$reg_status_change_form_array['subsections']['send_notifications'] = new EE_Yes_No_Input(
1579
+				[
1580
+					'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1581
+					'default'         => false,
1582
+					'html_help_text'  => esc_html__(
1583
+						'If set to "Yes", then the related messages will be sent to the registrant.',
1584
+						'event_espresso'
1585
+					),
1586
+				]
1587
+			);
1588
+			$reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1589
+				[
1590
+					'html_class'      => 'button-primary',
1591
+					'html_label_text' => '&nbsp;',
1592
+					'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1593
+				]
1594
+			);
1595
+		}
1596
+		return new EE_Form_Section_Proper($reg_status_change_form_array);
1597
+	}
1598
+
1599
+
1600
+	/**
1601
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1602
+	 *
1603
+	 * @return array
1604
+	 * @throws EE_Error
1605
+	 * @throws InvalidArgumentException
1606
+	 * @throws InvalidDataTypeException
1607
+	 * @throws InvalidInterfaceException
1608
+	 * @throws EntityNotFoundException
1609
+	 */
1610
+	protected function _get_reg_statuses()
1611
+	{
1612
+		$reg_status_array = $this->getRegistrationModel()->reg_status_array();
1613
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1614
+		// get current reg status
1615
+		$current_status = $this->_registration->status_ID();
1616
+		// is registration for free event? This will determine whether to display the pending payment option
1617
+		if (
1618
+			$current_status !== EEM_Registration::status_id_pending_payment
1619
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1620
+		) {
1621
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1622
+		}
1623
+		return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1624
+	}
1625
+
1626
+
1627
+	/**
1628
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1629
+	 *
1630
+	 * @param bool $status REG status given for changing registrations to.
1631
+	 * @param bool $notify Whether to send messages notifications or not.
1632
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1633
+	 * @throws DomainException
1634
+	 * @throws EE_Error
1635
+	 * @throws EntityNotFoundException
1636
+	 * @throws InvalidArgumentException
1637
+	 * @throws InvalidDataTypeException
1638
+	 * @throws InvalidInterfaceException
1639
+	 * @throws ReflectionException
1640
+	 * @throws RuntimeException
1641
+	 */
1642
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1643
+	{
1644
+		$REG_IDs = $this->request->requestParamIsSet('reg_status_change_form')
1645
+			? $this->request->getRequestParam('reg_status_change_form[REG_ID]', [], 'int', true)
1646
+			: $this->request->getRequestParam('_REG_ID', [], 'int', true);
1647
+
1648
+		// sanitize $REG_IDs
1649
+		$REG_IDs = array_map('absint', $REG_IDs);
1650
+		// and remove empty entries
1651
+		$REG_IDs = array_filter($REG_IDs);
1652
+
1653
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1654
+
1655
+		/**
1656
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1657
+		 * Currently this value is used downstream by the _process_resend_registration method.
1658
+		 *
1659
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1660
+		 * @param bool                     $status           The status registrations were changed to.
1661
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1662
+		 * @param Registrations_Admin_Page $admin_page_object
1663
+		 */
1664
+		$REG_ID = apply_filters(
1665
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1666
+			$result['REG_ID'],
1667
+			$status,
1668
+			$result['success'],
1669
+			$this
1670
+		);
1671
+		$this->request->setRequestParam('_REG_ID', $REG_ID);
1672
+
1673
+		// notify?
1674
+		if (
1675
+			$notify
1676
+			&& $result['success']
1677
+			&& ! empty($REG_ID)
1678
+			&& EE_Registry::instance()->CAP->current_user_can(
1679
+				'ee_send_message',
1680
+				'espresso_registrations_resend_registration'
1681
+			)
1682
+		) {
1683
+			$this->_process_resend_registration();
1684
+		}
1685
+		return $result;
1686
+	}
1687
+
1688
+
1689
+	/**
1690
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1691
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1692
+	 *
1693
+	 * @param array  $REG_IDs
1694
+	 * @param string $status
1695
+	 * @param bool   $notify Used to indicate whether notification was requested or not.  This determines the context
1696
+	 *                       slug sent with setting the registration status.
1697
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1698
+	 * @throws EE_Error
1699
+	 * @throws InvalidArgumentException
1700
+	 * @throws InvalidDataTypeException
1701
+	 * @throws InvalidInterfaceException
1702
+	 * @throws ReflectionException
1703
+	 * @throws RuntimeException
1704
+	 * @throws EntityNotFoundException
1705
+	 * @throws DomainException
1706
+	 */
1707
+	protected function _set_registration_status($REG_IDs = [], $status = '', $notify = false)
1708
+	{
1709
+		$success = false;
1710
+		// typecast $REG_IDs
1711
+		$REG_IDs = (array) $REG_IDs;
1712
+		if (! empty($REG_IDs)) {
1713
+			$success = true;
1714
+			// set default status if none is passed
1715
+			$status         = $status ?: EEM_Registration::status_id_pending_payment;
1716
+			$status_context = $notify
1717
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1718
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1719
+			// loop through REG_ID's and change status
1720
+			foreach ($REG_IDs as $REG_ID) {
1721
+				$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
1722
+				if ($registration instanceof EE_Registration) {
1723
+					$registration->set_status(
1724
+						$status,
1725
+						false,
1726
+						new Context(
1727
+							$status_context,
1728
+							esc_html__(
1729
+								'Manually triggered status change on a Registration Admin Page route.',
1730
+								'event_espresso'
1731
+							)
1732
+						)
1733
+					);
1734
+					$result = $registration->save();
1735
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1736
+					$success = $result !== false ? $success : false;
1737
+				}
1738
+			}
1739
+		}
1740
+
1741
+		// return $success and processed registrations
1742
+		return ['REG_ID' => $REG_IDs, 'success' => $success];
1743
+	}
1744
+
1745
+
1746
+	/**
1747
+	 * Common logic for setting up success message and redirecting to appropriate route
1748
+	 *
1749
+	 * @param string $STS_ID status id for the registration changed to
1750
+	 * @param bool   $notify indicates whether the _set_registration_status_from_request does notifications or not.
1751
+	 * @return void
1752
+	 * @throws DomainException
1753
+	 * @throws EE_Error
1754
+	 * @throws EntityNotFoundException
1755
+	 * @throws InvalidArgumentException
1756
+	 * @throws InvalidDataTypeException
1757
+	 * @throws InvalidInterfaceException
1758
+	 * @throws ReflectionException
1759
+	 * @throws RuntimeException
1760
+	 */
1761
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1762
+	{
1763
+		$result  = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1764
+			: ['success' => false];
1765
+		$success = isset($result['success']) && $result['success'];
1766
+		// setup success message
1767
+		if ($success) {
1768
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1769
+				$msg = sprintf(
1770
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1771
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1772
+				);
1773
+			} else {
1774
+				$msg = sprintf(
1775
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
1776
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1777
+				);
1778
+			}
1779
+			EE_Error::add_success($msg);
1780
+		} else {
1781
+			EE_Error::add_error(
1782
+				esc_html__(
1783
+					'Something went wrong, and the status was not changed',
1784
+					'event_espresso'
1785
+				),
1786
+				__FILE__,
1787
+				__LINE__,
1788
+				__FUNCTION__
1789
+			);
1790
+		}
1791
+		$return = $this->request->getRequestParam('return');
1792
+		$route  = $return === 'view_registration'
1793
+			? ['action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])]
1794
+			: ['action' => 'default'];
1795
+		$route  = $this->mergeExistingRequestParamsWithRedirectArgs($route);
1796
+		$this->_redirect_after_action($success, '', '', $route, true);
1797
+	}
1798
+
1799
+
1800
+	/**
1801
+	 * incoming reg status change from reg details page.
1802
+	 *
1803
+	 * @return void
1804
+	 * @throws EE_Error
1805
+	 * @throws EntityNotFoundException
1806
+	 * @throws InvalidArgumentException
1807
+	 * @throws InvalidDataTypeException
1808
+	 * @throws InvalidInterfaceException
1809
+	 * @throws ReflectionException
1810
+	 * @throws RuntimeException
1811
+	 * @throws DomainException
1812
+	 */
1813
+	protected function _change_reg_status()
1814
+	{
1815
+		$this->request->setRequestParam('return', 'view_registration');
1816
+		// set notify based on whether the send notifications toggle is set or not
1817
+		$notify     = $this->request->getRequestParam('reg_status_change_form[send_notifications]', false, 'bool');
1818
+		$reg_status = $this->request->getRequestParam('reg_status_change_form[reg_status]', '');
1819
+		$this->request->setRequestParam('reg_status_change_form[reg_status]', $reg_status);
1820
+		switch ($reg_status) {
1821
+			case EEM_Registration::status_id_approved:
1822
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
1823
+				$this->approve_registration($notify);
1824
+				break;
1825
+			case EEM_Registration::status_id_pending_payment:
1826
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
1827
+				$this->pending_registration($notify);
1828
+				break;
1829
+			case EEM_Registration::status_id_not_approved:
1830
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
1831
+				$this->not_approve_registration($notify);
1832
+				break;
1833
+			case EEM_Registration::status_id_declined:
1834
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
1835
+				$this->decline_registration($notify);
1836
+				break;
1837
+			case EEM_Registration::status_id_cancelled:
1838
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
1839
+				$this->cancel_registration($notify);
1840
+				break;
1841
+			case EEM_Registration::status_id_wait_list:
1842
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
1843
+				$this->wait_list_registration($notify);
1844
+				break;
1845
+			case EEM_Registration::status_id_incomplete:
1846
+			default:
1847
+				$this->request->unSetRequestParam('return');
1848
+				$this->_reg_status_change_return('');
1849
+				break;
1850
+		}
1851
+	}
1852
+
1853
+
1854
+	/**
1855
+	 * Callback for bulk action routes.
1856
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
1857
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
1858
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
1859
+	 * when an action is happening on just a single registration).
1860
+	 *
1861
+	 * @param      $action
1862
+	 * @param bool $notify
1863
+	 */
1864
+	protected function bulk_action_on_registrations($action, $notify = false)
1865
+	{
1866
+		do_action(
1867
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
1868
+			$this,
1869
+			$action,
1870
+			$notify
1871
+		);
1872
+		$method = $action . '_registration';
1873
+		if (method_exists($this, $method)) {
1874
+			$this->$method($notify);
1875
+		}
1876
+	}
1877
+
1878
+
1879
+	/**
1880
+	 * approve_registration
1881
+	 *
1882
+	 * @param bool $notify whether or not to notify the registrant about their approval.
1883
+	 * @return void
1884
+	 * @throws EE_Error
1885
+	 * @throws EntityNotFoundException
1886
+	 * @throws InvalidArgumentException
1887
+	 * @throws InvalidDataTypeException
1888
+	 * @throws InvalidInterfaceException
1889
+	 * @throws ReflectionException
1890
+	 * @throws RuntimeException
1891
+	 * @throws DomainException
1892
+	 */
1893
+	protected function approve_registration($notify = false)
1894
+	{
1895
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1896
+	}
1897
+
1898
+
1899
+	/**
1900
+	 * decline_registration
1901
+	 *
1902
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1903
+	 * @return void
1904
+	 * @throws EE_Error
1905
+	 * @throws EntityNotFoundException
1906
+	 * @throws InvalidArgumentException
1907
+	 * @throws InvalidDataTypeException
1908
+	 * @throws InvalidInterfaceException
1909
+	 * @throws ReflectionException
1910
+	 * @throws RuntimeException
1911
+	 * @throws DomainException
1912
+	 */
1913
+	protected function decline_registration($notify = false)
1914
+	{
1915
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1916
+	}
1917
+
1918
+
1919
+	/**
1920
+	 * cancel_registration
1921
+	 *
1922
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1923
+	 * @return void
1924
+	 * @throws EE_Error
1925
+	 * @throws EntityNotFoundException
1926
+	 * @throws InvalidArgumentException
1927
+	 * @throws InvalidDataTypeException
1928
+	 * @throws InvalidInterfaceException
1929
+	 * @throws ReflectionException
1930
+	 * @throws RuntimeException
1931
+	 * @throws DomainException
1932
+	 */
1933
+	protected function cancel_registration($notify = false)
1934
+	{
1935
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1936
+	}
1937
+
1938
+
1939
+	/**
1940
+	 * not_approve_registration
1941
+	 *
1942
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1943
+	 * @return void
1944
+	 * @throws EE_Error
1945
+	 * @throws EntityNotFoundException
1946
+	 * @throws InvalidArgumentException
1947
+	 * @throws InvalidDataTypeException
1948
+	 * @throws InvalidInterfaceException
1949
+	 * @throws ReflectionException
1950
+	 * @throws RuntimeException
1951
+	 * @throws DomainException
1952
+	 */
1953
+	protected function not_approve_registration($notify = false)
1954
+	{
1955
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1956
+	}
1957
+
1958
+
1959
+	/**
1960
+	 * decline_registration
1961
+	 *
1962
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1963
+	 * @return void
1964
+	 * @throws EE_Error
1965
+	 * @throws EntityNotFoundException
1966
+	 * @throws InvalidArgumentException
1967
+	 * @throws InvalidDataTypeException
1968
+	 * @throws InvalidInterfaceException
1969
+	 * @throws ReflectionException
1970
+	 * @throws RuntimeException
1971
+	 * @throws DomainException
1972
+	 */
1973
+	protected function pending_registration($notify = false)
1974
+	{
1975
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1976
+	}
1977
+
1978
+
1979
+	/**
1980
+	 * waitlist_registration
1981
+	 *
1982
+	 * @param bool $notify whether or not to notify the registrant about their status change.
1983
+	 * @return void
1984
+	 * @throws EE_Error
1985
+	 * @throws EntityNotFoundException
1986
+	 * @throws InvalidArgumentException
1987
+	 * @throws InvalidDataTypeException
1988
+	 * @throws InvalidInterfaceException
1989
+	 * @throws ReflectionException
1990
+	 * @throws RuntimeException
1991
+	 * @throws DomainException
1992
+	 */
1993
+	protected function wait_list_registration($notify = false)
1994
+	{
1995
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
1996
+	}
1997
+
1998
+
1999
+	/**
2000
+	 * generates HTML for the Registration main meta box
2001
+	 *
2002
+	 * @return void
2003
+	 * @throws DomainException
2004
+	 * @throws EE_Error
2005
+	 * @throws InvalidArgumentException
2006
+	 * @throws InvalidDataTypeException
2007
+	 * @throws InvalidInterfaceException
2008
+	 * @throws ReflectionException
2009
+	 * @throws EntityNotFoundException
2010
+	 */
2011
+	public function _reg_details_meta_box()
2012
+	{
2013
+		EEH_Autoloader::register_line_item_display_autoloaders();
2014
+		EEH_Autoloader::register_line_item_filter_autoloaders();
2015
+		EE_Registry::instance()->load_helper('Line_Item');
2016
+		$transaction    = $this->_registration->transaction() ? $this->_registration->transaction()
2017
+			: EE_Transaction::new_instance();
2018
+		$this->_session = $transaction->session_data();
2019
+		$filters        = new EE_Line_Item_Filter_Collection();
2020
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2021
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
2022
+		$line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2023
+			$filters,
2024
+			$transaction->total_line_item()
2025
+		);
2026
+		$filtered_line_item_tree                 = $line_item_filter_processor->process();
2027
+		$line_item_display                       = new EE_Line_Item_Display(
2028
+			'reg_admin_table',
2029
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2030
+		);
2031
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2032
+			$filtered_line_item_tree,
2033
+			['EE_Registration' => $this->_registration]
2034
+		);
2035
+		$attendee                                = $this->_registration->attendee();
2036
+		if (
2037
+			EE_Registry::instance()->CAP->current_user_can(
2038
+				'ee_read_transaction',
2039
+				'espresso_transactions_view_transaction'
2040
+			)
2041
+		) {
2042
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2043
+				EE_Admin_Page::add_query_args_and_nonce(
2044
+					[
2045
+						'action' => 'view_transaction',
2046
+						'TXN_ID' => $transaction->ID(),
2047
+					],
2048
+					TXN_ADMIN_URL
2049
+				),
2050
+				esc_html__(' View Transaction', 'event_espresso'),
2051
+				'button secondary-button right',
2052
+				'dashicons dashicons-cart'
2053
+			);
2054
+		} else {
2055
+			$this->_template_args['view_transaction_button'] = '';
2056
+		}
2057
+		if (
2058
+			$attendee instanceof EE_Attendee
2059
+			&& EE_Registry::instance()->CAP->current_user_can(
2060
+				'ee_send_message',
2061
+				'espresso_registrations_resend_registration'
2062
+			)
2063
+		) {
2064
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2065
+				EE_Admin_Page::add_query_args_and_nonce(
2066
+					[
2067
+						'action'      => 'resend_registration',
2068
+						'_REG_ID'     => $this->_registration->ID(),
2069
+						'redirect_to' => 'view_registration',
2070
+					],
2071
+					REG_ADMIN_URL
2072
+				),
2073
+				esc_html__(' Resend Registration', 'event_espresso'),
2074
+				'button secondary-button right',
2075
+				'dashicons dashicons-email-alt'
2076
+			);
2077
+		} else {
2078
+			$this->_template_args['resend_registration_button'] = '';
2079
+		}
2080
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2081
+		$payment                               = $transaction->get_first_related('Payment');
2082
+		$payment                               = ! $payment instanceof EE_Payment
2083
+			? EE_Payment::new_instance()
2084
+			: $payment;
2085
+		$payment_method                        = $payment->get_first_related('Payment_Method');
2086
+		$payment_method                        = ! $payment_method instanceof EE_Payment_Method
2087
+			? EE_Payment_Method::new_instance()
2088
+			: $payment_method;
2089
+		$reg_details                           = [
2090
+			'payment_method'       => $payment_method->name(),
2091
+			'response_msg'         => $payment->gateway_response(),
2092
+			'registration_id'      => $this->_registration->get('REG_code'),
2093
+			'registration_session' => $this->_registration->session_ID(),
2094
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2095
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2096
+		];
2097
+		if (isset($reg_details['registration_id'])) {
2098
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2099
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2100
+				'Registration ID',
2101
+				'event_espresso'
2102
+			);
2103
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2104
+		}
2105
+		if (isset($reg_details['payment_method'])) {
2106
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2107
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2108
+				'Most Recent Payment Method',
2109
+				'event_espresso'
2110
+			);
2111
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2112
+			$this->_template_args['reg_details']['response_msg']['value']   = $reg_details['response_msg'];
2113
+			$this->_template_args['reg_details']['response_msg']['label']   = esc_html__(
2114
+				'Payment method response',
2115
+				'event_espresso'
2116
+			);
2117
+			$this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2118
+		}
2119
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2120
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2121
+			'Registration Session',
2122
+			'event_espresso'
2123
+		);
2124
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2125
+		$this->_template_args['reg_details']['ip_address']['value']           = $reg_details['ip_address'];
2126
+		$this->_template_args['reg_details']['ip_address']['label']           = esc_html__(
2127
+			'Registration placed from IP',
2128
+			'event_espresso'
2129
+		);
2130
+		$this->_template_args['reg_details']['ip_address']['class']           = 'regular-text';
2131
+		$this->_template_args['reg_details']['user_agent']['value']           = $reg_details['user_agent'];
2132
+		$this->_template_args['reg_details']['user_agent']['label']           = esc_html__(
2133
+			'Registrant User Agent',
2134
+			'event_espresso'
2135
+		);
2136
+		$this->_template_args['reg_details']['user_agent']['class']           = 'large-text';
2137
+		$this->_template_args['event_link']                                   = EE_Admin_Page::add_query_args_and_nonce(
2138
+			[
2139
+				'action'   => 'default',
2140
+				'event_id' => $this->_registration->event_ID(),
2141
+			],
2142
+			REG_ADMIN_URL
2143
+		);
2144
+		$this->_template_args['REG_ID']                                       = $this->_registration->ID();
2145
+		$this->_template_args['event_id']                                     = $this->_registration->event_ID();
2146
+		$template_path                                                        =
2147
+			REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2148
+		EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2149
+	}
2150
+
2151
+
2152
+	/**
2153
+	 * generates HTML for the Registration Questions meta box.
2154
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2155
+	 * otherwise uses new forms system
2156
+	 *
2157
+	 * @return void
2158
+	 * @throws DomainException
2159
+	 * @throws EE_Error
2160
+	 * @throws InvalidArgumentException
2161
+	 * @throws InvalidDataTypeException
2162
+	 * @throws InvalidInterfaceException
2163
+	 * @throws ReflectionException
2164
+	 */
2165
+	public function _reg_questions_meta_box()
2166
+	{
2167
+		// allow someone to override this method entirely
2168
+		if (
2169
+			apply_filters(
2170
+				'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2171
+				true,
2172
+				$this,
2173
+				$this->_registration
2174
+			)
2175
+		) {
2176
+			$form                                              = $this->_get_reg_custom_questions_form(
2177
+				$this->_registration->ID()
2178
+			);
2179
+			$this->_template_args['att_questions']             = count($form->subforms()) > 0
2180
+				? $form->get_html_and_js()
2181
+				: '';
2182
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2183
+			$this->_template_args['REG_ID']                    = $this->_registration->ID();
2184
+			$template_path                                     =
2185
+				REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2186
+			EEH_Template::display_template($template_path, $this->_template_args);
2187
+		}
2188
+	}
2189
+
2190
+
2191
+	/**
2192
+	 * form_before_question_group
2193
+	 *
2194
+	 * @param string $output
2195
+	 * @return        string
2196
+	 * @deprecated    as of 4.8.32.rc.000
2197
+	 */
2198
+	public function form_before_question_group($output)
2199
+	{
2200
+		EE_Error::doing_it_wrong(
2201
+			__CLASS__ . '::' . __FUNCTION__,
2202
+			esc_html__(
2203
+				'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.',
2204
+				'event_espresso'
2205
+			),
2206
+			'4.8.32.rc.000'
2207
+		);
2208
+		return '
2209 2209
 	<table class="form-table ee-width-100">
2210 2210
 		<tbody>
2211 2211
 			';
2212
-    }
2213
-
2214
-
2215
-    /**
2216
-     * form_after_question_group
2217
-     *
2218
-     * @param string $output
2219
-     * @return        string
2220
-     * @deprecated    as of 4.8.32.rc.000
2221
-     */
2222
-    public function form_after_question_group($output)
2223
-    {
2224
-        EE_Error::doing_it_wrong(
2225
-            __CLASS__ . '::' . __FUNCTION__,
2226
-            esc_html__(
2227
-                '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.',
2228
-                'event_espresso'
2229
-            ),
2230
-            '4.8.32.rc.000'
2231
-        );
2232
-        return '
2212
+	}
2213
+
2214
+
2215
+	/**
2216
+	 * form_after_question_group
2217
+	 *
2218
+	 * @param string $output
2219
+	 * @return        string
2220
+	 * @deprecated    as of 4.8.32.rc.000
2221
+	 */
2222
+	public function form_after_question_group($output)
2223
+	{
2224
+		EE_Error::doing_it_wrong(
2225
+			__CLASS__ . '::' . __FUNCTION__,
2226
+			esc_html__(
2227
+				'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.',
2228
+				'event_espresso'
2229
+			),
2230
+			'4.8.32.rc.000'
2231
+		);
2232
+		return '
2233 2233
 			<tr class="hide-if-no-js">
2234 2234
 				<th> </th>
2235 2235
 				<td class="reg-admin-edit-attendee-question-td">
2236 2236
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2237
-               . esc_attr__('click to edit question', 'event_espresso')
2238
-               . '">
2237
+			   . esc_attr__('click to edit question', 'event_espresso')
2238
+			   . '">
2239 2239
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2240
-               . esc_html__('edit the above question group', 'event_espresso')
2241
-               . '</span>
2240
+			   . esc_html__('edit the above question group', 'event_espresso')
2241
+			   . '</span>
2242 2242
 						<div class="dashicons dashicons-edit"></div>
2243 2243
 					</a>
2244 2244
 				</td>
@@ -2246,637 +2246,637 @@  discard block
 block discarded – undo
2246 2246
 		</tbody>
2247 2247
 	</table>
2248 2248
 ';
2249
-    }
2250
-
2251
-
2252
-    /**
2253
-     * form_form_field_label_wrap
2254
-     *
2255
-     * @param string $label
2256
-     * @return        string
2257
-     * @deprecated    as of 4.8.32.rc.000
2258
-     */
2259
-    public function form_form_field_label_wrap($label)
2260
-    {
2261
-        EE_Error::doing_it_wrong(
2262
-            __CLASS__ . '::' . __FUNCTION__,
2263
-            esc_html__(
2264
-                '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.',
2265
-                'event_espresso'
2266
-            ),
2267
-            '4.8.32.rc.000'
2268
-        );
2269
-        return '
2249
+	}
2250
+
2251
+
2252
+	/**
2253
+	 * form_form_field_label_wrap
2254
+	 *
2255
+	 * @param string $label
2256
+	 * @return        string
2257
+	 * @deprecated    as of 4.8.32.rc.000
2258
+	 */
2259
+	public function form_form_field_label_wrap($label)
2260
+	{
2261
+		EE_Error::doing_it_wrong(
2262
+			__CLASS__ . '::' . __FUNCTION__,
2263
+			esc_html__(
2264
+				'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.',
2265
+				'event_espresso'
2266
+			),
2267
+			'4.8.32.rc.000'
2268
+		);
2269
+		return '
2270 2270
 			<tr>
2271 2271
 				<th>
2272 2272
 					' . $label . '
2273 2273
 				</th>';
2274
-    }
2275
-
2276
-
2277
-    /**
2278
-     * form_form_field_input__wrap
2279
-     *
2280
-     * @param string $input
2281
-     * @return        string
2282
-     * @deprecated    as of 4.8.32.rc.000
2283
-     */
2284
-    public function form_form_field_input__wrap($input)
2285
-    {
2286
-        EE_Error::doing_it_wrong(
2287
-            __CLASS__ . '::' . __FUNCTION__,
2288
-            esc_html__(
2289
-                '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.',
2290
-                'event_espresso'
2291
-            ),
2292
-            '4.8.32.rc.000'
2293
-        );
2294
-        return '
2274
+	}
2275
+
2276
+
2277
+	/**
2278
+	 * form_form_field_input__wrap
2279
+	 *
2280
+	 * @param string $input
2281
+	 * @return        string
2282
+	 * @deprecated    as of 4.8.32.rc.000
2283
+	 */
2284
+	public function form_form_field_input__wrap($input)
2285
+	{
2286
+		EE_Error::doing_it_wrong(
2287
+			__CLASS__ . '::' . __FUNCTION__,
2288
+			esc_html__(
2289
+				'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.',
2290
+				'event_espresso'
2291
+			),
2292
+			'4.8.32.rc.000'
2293
+		);
2294
+		return '
2295 2295
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2296 2296
 					' . $input . '
2297 2297
 				</td>
2298 2298
 			</tr>';
2299
-    }
2300
-
2301
-
2302
-    /**
2303
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2304
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2305
-     * to display the page
2306
-     *
2307
-     * @return void
2308
-     * @throws EE_Error
2309
-     * @throws InvalidArgumentException
2310
-     * @throws InvalidDataTypeException
2311
-     * @throws InvalidInterfaceException
2312
-     * @throws ReflectionException
2313
-     */
2314
-    protected function _update_attendee_registration_form()
2315
-    {
2316
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2317
-        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2318
-            $REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2319
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2320
-            if ($success) {
2321
-                $what  = esc_html__('Registration Form', 'event_espresso');
2322
-                $route = $REG_ID
2323
-                    ? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2324
-                    : ['action' => 'default'];
2325
-                $this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2326
-            }
2327
-        }
2328
-    }
2329
-
2330
-
2331
-    /**
2332
-     * Gets the form for saving registrations custom questions (if done
2333
-     * previously retrieves the cached form object, which may have validation errors in it)
2334
-     *
2335
-     * @param int $REG_ID
2336
-     * @return EE_Registration_Custom_Questions_Form
2337
-     * @throws EE_Error
2338
-     * @throws InvalidArgumentException
2339
-     * @throws InvalidDataTypeException
2340
-     * @throws InvalidInterfaceException
2341
-     * @throws ReflectionException
2342
-     */
2343
-    protected function _get_reg_custom_questions_form($REG_ID)
2344
-    {
2345
-        if (! $this->_reg_custom_questions_form) {
2346
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2347
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2348
-                $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2349
-            );
2350
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2351
-        }
2352
-        return $this->_reg_custom_questions_form;
2353
-    }
2354
-
2355
-
2356
-    /**
2357
-     * Saves
2358
-     *
2359
-     * @param bool $REG_ID
2360
-     * @return bool
2361
-     * @throws EE_Error
2362
-     * @throws InvalidArgumentException
2363
-     * @throws InvalidDataTypeException
2364
-     * @throws InvalidInterfaceException
2365
-     * @throws ReflectionException
2366
-     */
2367
-    private function _save_reg_custom_questions_form($REG_ID = 0)
2368
-    {
2369
-        if (! $REG_ID) {
2370
-            EE_Error::add_error(
2371
-                esc_html__(
2372
-                    'An error occurred. No registration ID was received.',
2373
-                    'event_espresso'
2374
-                ),
2375
-                __FILE__,
2376
-                __FUNCTION__,
2377
-                __LINE__
2378
-            );
2379
-        }
2380
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2381
-        $form->receive_form_submission($this->request->requestParams());
2382
-        $success = false;
2383
-        if ($form->is_valid()) {
2384
-            foreach ($form->subforms() as $question_group_form) {
2385
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2386
-                    $where_conditions    = [
2387
-                        'QST_ID' => $question_id,
2388
-                        'REG_ID' => $REG_ID,
2389
-                    ];
2390
-                    $possibly_new_values = [
2391
-                        'ANS_value' => $input->normalized_value(),
2392
-                    ];
2393
-                    $answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2394
-                    if ($answer instanceof EE_Answer) {
2395
-                        $success = $answer->save($possibly_new_values);
2396
-                    } else {
2397
-                        // insert it then
2398
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2399
-                        $answer      = EE_Answer::new_instance($cols_n_vals);
2400
-                        $success     = $answer->save();
2401
-                    }
2402
-                }
2403
-            }
2404
-        } else {
2405
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2406
-        }
2407
-        return $success;
2408
-    }
2409
-
2410
-
2411
-    /**
2412
-     * generates HTML for the Registration main meta box
2413
-     *
2414
-     * @return void
2415
-     * @throws DomainException
2416
-     * @throws EE_Error
2417
-     * @throws InvalidArgumentException
2418
-     * @throws InvalidDataTypeException
2419
-     * @throws InvalidInterfaceException
2420
-     * @throws ReflectionException
2421
-     */
2422
-    public function _reg_attendees_meta_box()
2423
-    {
2424
-        $REG = $this->getRegistrationModel();
2425
-        // get all other registrations on this transaction, and cache
2426
-        // the attendees for them so we don't have to run another query using force_join
2427
-        $registrations                           = $REG->get_all(
2428
-            [
2429
-                [
2430
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2431
-                    'REG_ID' => ['!=', $this->_registration->ID()],
2432
-                ],
2433
-                'force_join'               => ['Attendee'],
2434
-                'default_where_conditions' => 'other_models_only',
2435
-            ]
2436
-        );
2437
-        $this->_template_args['attendees']       = [];
2438
-        $this->_template_args['attendee_notice'] = '';
2439
-        if (
2440
-            empty($registrations)
2441
-            || (is_array($registrations)
2442
-                && ! EEH_Array::get_one_item_from_array($registrations))
2443
-        ) {
2444
-            EE_Error::add_error(
2445
-                esc_html__(
2446
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2447
-                    'event_espresso'
2448
-                ),
2449
-                __FILE__,
2450
-                __FUNCTION__,
2451
-                __LINE__
2452
-            );
2453
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2454
-        } else {
2455
-            $att_nmbr = 1;
2456
-            foreach ($registrations as $registration) {
2457
-                /* @var $registration EE_Registration */
2458
-                $attendee                                                      = $registration->attendee()
2459
-                    ? $registration->attendee()
2460
-                    : $this->getAttendeeModel()->create_default_object();
2461
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2462
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2463
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2464
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2465
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2466
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2467
-                    ', ',
2468
-                    $attendee->full_address_as_array()
2469
-                );
2470
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2471
-                    [
2472
-                        'action' => 'edit_attendee',
2473
-                        'post'   => $attendee->ID(),
2474
-                    ],
2475
-                    REG_ADMIN_URL
2476
-                );
2477
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2478
-                    $registration->event_obj() instanceof EE_Event
2479
-                        ? $registration->event_obj()->name()
2480
-                        : '';
2481
-                $att_nmbr++;
2482
-            }
2483
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2484
-        }
2485
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2486
-        EEH_Template::display_template($template_path, $this->_template_args);
2487
-    }
2488
-
2489
-
2490
-    /**
2491
-     * generates HTML for the Edit Registration side meta box
2492
-     *
2493
-     * @return void
2494
-     * @throws DomainException
2495
-     * @throws EE_Error
2496
-     * @throws InvalidArgumentException
2497
-     * @throws InvalidDataTypeException
2498
-     * @throws InvalidInterfaceException
2499
-     * @throws ReflectionException
2500
-     */
2501
-    public function _reg_registrant_side_meta_box()
2502
-    {
2503
-        /*@var $attendee EE_Attendee */
2504
-        $att_check = $this->_registration->attendee();
2505
-        $attendee  = $att_check instanceof EE_Attendee
2506
-            ? $att_check
2507
-            : $this->getAttendeeModel()->create_default_object();
2508
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2509
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2510
-        // primary registration object (that way we know if we need to show create button or not)
2511
-        if (! $this->_registration->is_primary_registrant()) {
2512
-            $primary_registration = $this->_registration->get_primary_registration();
2513
-            $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2514
-                : null;
2515
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2516
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2517
-                // custom attendee object so let's not worry about the primary reg.
2518
-                $primary_registration = null;
2519
-            }
2520
-        } else {
2521
-            $primary_registration = null;
2522
-        }
2523
-        $this->_template_args['ATT_ID']            = $attendee->ID();
2524
-        $this->_template_args['fname']             = $attendee->fname();
2525
-        $this->_template_args['lname']             = $attendee->lname();
2526
-        $this->_template_args['email']             = $attendee->email();
2527
-        $this->_template_args['phone']             = $attendee->phone();
2528
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2529
-        // edit link
2530
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2531
-            [
2532
-                'action' => 'edit_attendee',
2533
-                'post'   => $attendee->ID(),
2534
-            ],
2535
-            REG_ADMIN_URL
2536
-        );
2537
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2538
-        // create link
2539
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2540
-            ? EE_Admin_Page::add_query_args_and_nonce(
2541
-                [
2542
-                    'action'  => 'duplicate_attendee',
2543
-                    '_REG_ID' => $this->_registration->ID(),
2544
-                ],
2545
-                REG_ADMIN_URL
2546
-            ) : '';
2547
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2548
-        $this->_template_args['att_check']    = $att_check;
2549
-        $template_path                        =
2550
-            REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2551
-        EEH_Template::display_template($template_path, $this->_template_args);
2552
-    }
2553
-
2554
-
2555
-    /**
2556
-     * trash or restore registrations
2557
-     *
2558
-     * @param boolean $trash whether to archive or restore
2559
-     * @return void
2560
-     * @throws EE_Error
2561
-     * @throws InvalidArgumentException
2562
-     * @throws InvalidDataTypeException
2563
-     * @throws InvalidInterfaceException
2564
-     * @throws RuntimeException
2565
-     */
2566
-    protected function _trash_or_restore_registrations($trash = true)
2567
-    {
2568
-        // if empty _REG_ID then get out because there's nothing to do
2569
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2570
-        if (empty($REG_IDs)) {
2571
-            EE_Error::add_error(
2572
-                sprintf(
2573
-                    esc_html__(
2574
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2575
-                        'event_espresso'
2576
-                    ),
2577
-                    $trash ? 'trash' : 'restore'
2578
-                ),
2579
-                __FILE__,
2580
-                __LINE__,
2581
-                __FUNCTION__
2582
-            );
2583
-            $this->_redirect_after_action(false, '', '', [], true);
2584
-        }
2585
-        $success        = 0;
2586
-        $overwrite_msgs = false;
2587
-        // Checkboxes
2588
-        $reg_count = count($REG_IDs);
2589
-        // cycle thru checkboxes
2590
-        foreach ($REG_IDs as $REG_ID) {
2591
-            /** @var EE_Registration $REG */
2592
-            $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2593
-            $payments = $REG->registration_payments();
2594
-            if (! empty($payments)) {
2595
-                $name           = $REG->attendee() instanceof EE_Attendee
2596
-                    ? $REG->attendee()->full_name()
2597
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2598
-                $overwrite_msgs = true;
2599
-                EE_Error::add_error(
2600
-                    sprintf(
2601
-                        esc_html__(
2602
-                            '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.',
2603
-                            'event_espresso'
2604
-                        ),
2605
-                        $name
2606
-                    ),
2607
-                    __FILE__,
2608
-                    __FUNCTION__,
2609
-                    __LINE__
2610
-                );
2611
-                // can't trash this registration because it has payments.
2612
-                continue;
2613
-            }
2614
-            $updated = $trash ? $REG->delete() : $REG->restore();
2615
-            if ($updated) {
2616
-                $success++;
2617
-            }
2618
-        }
2619
-        $this->_redirect_after_action(
2620
-            $success === $reg_count, // were ALL registrations affected?
2621
-            $success > 1
2622
-                ? esc_html__('Registrations', 'event_espresso')
2623
-                : esc_html__('Registration', 'event_espresso'),
2624
-            $trash
2625
-                ? esc_html__('moved to the trash', 'event_espresso')
2626
-                : esc_html__('restored', 'event_espresso'),
2627
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2628
-            $overwrite_msgs
2629
-        );
2630
-    }
2631
-
2632
-
2633
-    /**
2634
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2635
-     * registration but also.
2636
-     * 1. Removing relations to EE_Attendee
2637
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2638
-     * ALSO trashed.
2639
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2640
-     * 4. Removing relationships between all tickets and the related registrations
2641
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2642
-     * 6. Deleting permanently any related Checkins.
2643
-     *
2644
-     * @return void
2645
-     * @throws EE_Error
2646
-     * @throws InvalidArgumentException
2647
-     * @throws InvalidDataTypeException
2648
-     * @throws InvalidInterfaceException
2649
-     * @throws ReflectionException
2650
-     */
2651
-    protected function _delete_registrations()
2652
-    {
2653
-        $REG_MDL = $this->getRegistrationModel();
2654
-        $success = 0;
2655
-        // Checkboxes
2656
-        $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2657
-
2658
-        if (! empty($REG_IDs)) {
2659
-            // if array has more than one element than success message should be plural
2660
-            $success = count($REG_IDs) > 1 ? 2 : 1;
2661
-            // cycle thru checkboxes
2662
-            foreach ($REG_IDs as $REG_ID) {
2663
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2664
-                if (! $REG instanceof EE_Registration) {
2665
-                    continue;
2666
-                }
2667
-                $deleted = $this->_delete_registration($REG);
2668
-                if (! $deleted) {
2669
-                    $success = 0;
2670
-                }
2671
-            }
2672
-        }
2673
-
2674
-        $what        = $success > 1
2675
-            ? esc_html__('Registrations', 'event_espresso')
2676
-            : esc_html__('Registration', 'event_espresso');
2677
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2678
-        $this->_redirect_after_action(
2679
-            $success,
2680
-            $what,
2681
-            $action_desc,
2682
-            $this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2683
-            true
2684
-        );
2685
-    }
2686
-
2687
-
2688
-    /**
2689
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2690
-     * models get affected.
2691
-     *
2692
-     * @param EE_Registration $REG registration to be deleted permanently
2693
-     * @return bool true = successful deletion, false = fail.
2694
-     * @throws EE_Error
2695
-     * @throws InvalidArgumentException
2696
-     * @throws InvalidDataTypeException
2697
-     * @throws InvalidInterfaceException
2698
-     * @throws ReflectionException
2699
-     */
2700
-    protected function _delete_registration(EE_Registration $REG)
2701
-    {
2702
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2703
-        // registrations on the transaction that are NOT trashed.
2704
-        $TXN = $REG->get_first_related('Transaction');
2705
-        if (! $TXN instanceof EE_Transaction) {
2706
-            EE_Error::add_error(
2707
-                sprintf(
2708
-                    esc_html__(
2709
-                        '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.',
2710
-                        'event_espresso'
2711
-                    ),
2712
-                    $REG->id()
2713
-                ),
2714
-                __FILE__,
2715
-                __FUNCTION__,
2716
-                __LINE__
2717
-            );
2718
-            return false;
2719
-        }
2720
-        $REGS        = $TXN->get_many_related('Registration');
2721
-        $all_trashed = true;
2722
-        foreach ($REGS as $registration) {
2723
-            if (! $registration->get('REG_deleted')) {
2724
-                $all_trashed = false;
2725
-            }
2726
-        }
2727
-        if (! $all_trashed) {
2728
-            EE_Error::add_error(
2729
-                esc_html__(
2730
-                    '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.',
2731
-                    'event_espresso'
2732
-                ),
2733
-                __FILE__,
2734
-                __FUNCTION__,
2735
-                __LINE__
2736
-            );
2737
-            return false;
2738
-        }
2739
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2740
-        // separately from THIS one).
2741
-        foreach ($REGS as $registration) {
2742
-            // delete related answers
2743
-            $registration->delete_related_permanently('Answer');
2744
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2745
-            $attendee = $registration->get_first_related('Attendee');
2746
-            if ($attendee instanceof EE_Attendee) {
2747
-                $registration->_remove_relation_to($attendee, 'Attendee');
2748
-            }
2749
-            // now remove relationships to tickets on this registration.
2750
-            $registration->_remove_relations('Ticket');
2751
-            // now delete permanently the checkins related to this registration.
2752
-            $registration->delete_related_permanently('Checkin');
2753
-            if ($registration->ID() === $REG->ID()) {
2754
-                continue;
2755
-            } //we don't want to delete permanently the existing registration just yet.
2756
-            // remove relation to transaction for these registrations if NOT the existing registrations
2757
-            $registration->_remove_relations('Transaction');
2758
-            // delete permanently any related messages.
2759
-            $registration->delete_related_permanently('Message');
2760
-            // now delete this registration permanently
2761
-            $registration->delete_permanently();
2762
-        }
2763
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2764
-        // (the transaction and line items should be all that's left).
2765
-        // delete the line items related to the transaction for this registration.
2766
-        $TXN->delete_related_permanently('Line_Item');
2767
-        // we need to remove all the relationships on the transaction
2768
-        $TXN->delete_related_permanently('Payment');
2769
-        $TXN->delete_related_permanently('Extra_Meta');
2770
-        $TXN->delete_related_permanently('Message');
2771
-        // now we can delete this REG permanently (and the transaction of course)
2772
-        $REG->delete_related_permanently('Transaction');
2773
-        return $REG->delete_permanently();
2774
-    }
2775
-
2776
-
2777
-    /**
2778
-     *    generates HTML for the Register New Attendee Admin page
2779
-     *
2780
-     * @throws DomainException
2781
-     * @throws EE_Error
2782
-     * @throws InvalidArgumentException
2783
-     * @throws InvalidDataTypeException
2784
-     * @throws InvalidInterfaceException
2785
-     * @throws ReflectionException
2786
-     */
2787
-    public function new_registration()
2788
-    {
2789
-        if (! $this->_set_reg_event()) {
2790
-            throw new EE_Error(
2791
-                esc_html__(
2792
-                    'Unable to continue with registering because there is no Event ID in the request',
2793
-                    'event_espresso'
2794
-                )
2795
-            );
2796
-        }
2797
-        /** @var CurrentPage $current_page */
2798
-        $current_page = $this->loader->getShared(CurrentPage::class);
2799
-        $current_page->setEspressoPage(true);
2800
-        // gotta start with a clean slate if we're not coming here via ajax
2801
-        if (
2802
-            ! $this->request->isAjax()
2803
-            && (
2804
-                ! $this->request->requestParamIsSet('processing_registration')
2805
-                || $this->request->requestParamIsSet('step_error')
2806
-            )
2807
-        ) {
2808
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2809
-        }
2810
-        $this->_template_args['event_name'] = '';
2811
-        // event name
2812
-        if ($this->_reg_event) {
2813
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2814
-            $edit_event_url                     = self::add_query_args_and_nonce(
2815
-                [
2816
-                    'action' => 'edit',
2817
-                    'post'   => $this->_reg_event->ID(),
2818
-                ],
2819
-                EVENTS_ADMIN_URL
2820
-            );
2821
-            $edit_event_lnk                     = '<a href="'
2822
-                                                  . $edit_event_url
2823
-                                                  . '" title="'
2824
-                                                  . esc_attr__('Edit ', 'event_espresso')
2825
-                                                  . $this->_reg_event->name()
2826
-                                                  . '">'
2827
-                                                  . esc_html__('Edit Event', 'event_espresso')
2828
-                                                  . '</a>';
2829
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2830
-                                                   . $edit_event_lnk
2831
-                                                   . '</span>';
2832
-        }
2833
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2834
-        if ($this->request->isAjax()) {
2835
-            $this->_return_json();
2836
-        }
2837
-        // grab header
2838
-        $template_path                              =
2839
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2840
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2841
-            $template_path,
2842
-            $this->_template_args,
2843
-            true
2844
-        );
2845
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2846
-        // the details template wrapper
2847
-        $this->display_admin_page_with_sidebar();
2848
-    }
2849
-
2850
-
2851
-    /**
2852
-     * This returns the content for a registration step
2853
-     *
2854
-     * @return string html
2855
-     * @throws DomainException
2856
-     * @throws EE_Error
2857
-     * @throws InvalidArgumentException
2858
-     * @throws InvalidDataTypeException
2859
-     * @throws InvalidInterfaceException
2860
-     * @throws ReflectionException
2861
-     */
2862
-    protected function _get_registration_step_content()
2863
-    {
2864
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2865
-            $warning_msg = sprintf(
2866
-                esc_html__(
2867
-                    '%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',
2868
-                    'event_espresso'
2869
-                ),
2870
-                '<br />',
2871
-                '<h3 class="important-notice">',
2872
-                '</h3>',
2873
-                '<div class="float-right">',
2874
-                '<span id="redirect_timer" class="important-notice">30</span>',
2875
-                '</div>',
2876
-                '<b>',
2877
-                '</b>'
2878
-            );
2879
-            return '
2299
+	}
2300
+
2301
+
2302
+	/**
2303
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2304
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2305
+	 * to display the page
2306
+	 *
2307
+	 * @return void
2308
+	 * @throws EE_Error
2309
+	 * @throws InvalidArgumentException
2310
+	 * @throws InvalidDataTypeException
2311
+	 * @throws InvalidInterfaceException
2312
+	 * @throws ReflectionException
2313
+	 */
2314
+	protected function _update_attendee_registration_form()
2315
+	{
2316
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2317
+		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2318
+			$REG_ID  = $this->request->getRequestParam('_REG_ID', 0, 'int');
2319
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2320
+			if ($success) {
2321
+				$what  = esc_html__('Registration Form', 'event_espresso');
2322
+				$route = $REG_ID
2323
+					? ['action' => 'view_registration', '_REG_ID' => $REG_ID]
2324
+					: ['action' => 'default'];
2325
+				$this->_redirect_after_action(true, $what, esc_html__('updated', 'event_espresso'), $route);
2326
+			}
2327
+		}
2328
+	}
2329
+
2330
+
2331
+	/**
2332
+	 * Gets the form for saving registrations custom questions (if done
2333
+	 * previously retrieves the cached form object, which may have validation errors in it)
2334
+	 *
2335
+	 * @param int $REG_ID
2336
+	 * @return EE_Registration_Custom_Questions_Form
2337
+	 * @throws EE_Error
2338
+	 * @throws InvalidArgumentException
2339
+	 * @throws InvalidDataTypeException
2340
+	 * @throws InvalidInterfaceException
2341
+	 * @throws ReflectionException
2342
+	 */
2343
+	protected function _get_reg_custom_questions_form($REG_ID)
2344
+	{
2345
+		if (! $this->_reg_custom_questions_form) {
2346
+			require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2347
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2348
+				$this->getRegistrationModel()->get_one_by_ID($REG_ID)
2349
+			);
2350
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2351
+		}
2352
+		return $this->_reg_custom_questions_form;
2353
+	}
2354
+
2355
+
2356
+	/**
2357
+	 * Saves
2358
+	 *
2359
+	 * @param bool $REG_ID
2360
+	 * @return bool
2361
+	 * @throws EE_Error
2362
+	 * @throws InvalidArgumentException
2363
+	 * @throws InvalidDataTypeException
2364
+	 * @throws InvalidInterfaceException
2365
+	 * @throws ReflectionException
2366
+	 */
2367
+	private function _save_reg_custom_questions_form($REG_ID = 0)
2368
+	{
2369
+		if (! $REG_ID) {
2370
+			EE_Error::add_error(
2371
+				esc_html__(
2372
+					'An error occurred. No registration ID was received.',
2373
+					'event_espresso'
2374
+				),
2375
+				__FILE__,
2376
+				__FUNCTION__,
2377
+				__LINE__
2378
+			);
2379
+		}
2380
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2381
+		$form->receive_form_submission($this->request->requestParams());
2382
+		$success = false;
2383
+		if ($form->is_valid()) {
2384
+			foreach ($form->subforms() as $question_group_form) {
2385
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2386
+					$where_conditions    = [
2387
+						'QST_ID' => $question_id,
2388
+						'REG_ID' => $REG_ID,
2389
+					];
2390
+					$possibly_new_values = [
2391
+						'ANS_value' => $input->normalized_value(),
2392
+					];
2393
+					$answer              = EEM_Answer::instance()->get_one([$where_conditions]);
2394
+					if ($answer instanceof EE_Answer) {
2395
+						$success = $answer->save($possibly_new_values);
2396
+					} else {
2397
+						// insert it then
2398
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2399
+						$answer      = EE_Answer::new_instance($cols_n_vals);
2400
+						$success     = $answer->save();
2401
+					}
2402
+				}
2403
+			}
2404
+		} else {
2405
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2406
+		}
2407
+		return $success;
2408
+	}
2409
+
2410
+
2411
+	/**
2412
+	 * generates HTML for the Registration main meta box
2413
+	 *
2414
+	 * @return void
2415
+	 * @throws DomainException
2416
+	 * @throws EE_Error
2417
+	 * @throws InvalidArgumentException
2418
+	 * @throws InvalidDataTypeException
2419
+	 * @throws InvalidInterfaceException
2420
+	 * @throws ReflectionException
2421
+	 */
2422
+	public function _reg_attendees_meta_box()
2423
+	{
2424
+		$REG = $this->getRegistrationModel();
2425
+		// get all other registrations on this transaction, and cache
2426
+		// the attendees for them so we don't have to run another query using force_join
2427
+		$registrations                           = $REG->get_all(
2428
+			[
2429
+				[
2430
+					'TXN_ID' => $this->_registration->transaction_ID(),
2431
+					'REG_ID' => ['!=', $this->_registration->ID()],
2432
+				],
2433
+				'force_join'               => ['Attendee'],
2434
+				'default_where_conditions' => 'other_models_only',
2435
+			]
2436
+		);
2437
+		$this->_template_args['attendees']       = [];
2438
+		$this->_template_args['attendee_notice'] = '';
2439
+		if (
2440
+			empty($registrations)
2441
+			|| (is_array($registrations)
2442
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2443
+		) {
2444
+			EE_Error::add_error(
2445
+				esc_html__(
2446
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2447
+					'event_espresso'
2448
+				),
2449
+				__FILE__,
2450
+				__FUNCTION__,
2451
+				__LINE__
2452
+			);
2453
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2454
+		} else {
2455
+			$att_nmbr = 1;
2456
+			foreach ($registrations as $registration) {
2457
+				/* @var $registration EE_Registration */
2458
+				$attendee                                                      = $registration->attendee()
2459
+					? $registration->attendee()
2460
+					: $this->getAttendeeModel()->create_default_object();
2461
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2462
+				$this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2463
+				$this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2464
+				$this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2465
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2466
+				$this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2467
+					', ',
2468
+					$attendee->full_address_as_array()
2469
+				);
2470
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2471
+					[
2472
+						'action' => 'edit_attendee',
2473
+						'post'   => $attendee->ID(),
2474
+					],
2475
+					REG_ADMIN_URL
2476
+				);
2477
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2478
+					$registration->event_obj() instanceof EE_Event
2479
+						? $registration->event_obj()->name()
2480
+						: '';
2481
+				$att_nmbr++;
2482
+			}
2483
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2484
+		}
2485
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2486
+		EEH_Template::display_template($template_path, $this->_template_args);
2487
+	}
2488
+
2489
+
2490
+	/**
2491
+	 * generates HTML for the Edit Registration side meta box
2492
+	 *
2493
+	 * @return void
2494
+	 * @throws DomainException
2495
+	 * @throws EE_Error
2496
+	 * @throws InvalidArgumentException
2497
+	 * @throws InvalidDataTypeException
2498
+	 * @throws InvalidInterfaceException
2499
+	 * @throws ReflectionException
2500
+	 */
2501
+	public function _reg_registrant_side_meta_box()
2502
+	{
2503
+		/*@var $attendee EE_Attendee */
2504
+		$att_check = $this->_registration->attendee();
2505
+		$attendee  = $att_check instanceof EE_Attendee
2506
+			? $att_check
2507
+			: $this->getAttendeeModel()->create_default_object();
2508
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2509
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2510
+		// primary registration object (that way we know if we need to show create button or not)
2511
+		if (! $this->_registration->is_primary_registrant()) {
2512
+			$primary_registration = $this->_registration->get_primary_registration();
2513
+			$primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2514
+				: null;
2515
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2516
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2517
+				// custom attendee object so let's not worry about the primary reg.
2518
+				$primary_registration = null;
2519
+			}
2520
+		} else {
2521
+			$primary_registration = null;
2522
+		}
2523
+		$this->_template_args['ATT_ID']            = $attendee->ID();
2524
+		$this->_template_args['fname']             = $attendee->fname();
2525
+		$this->_template_args['lname']             = $attendee->lname();
2526
+		$this->_template_args['email']             = $attendee->email();
2527
+		$this->_template_args['phone']             = $attendee->phone();
2528
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2529
+		// edit link
2530
+		$this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2531
+			[
2532
+				'action' => 'edit_attendee',
2533
+				'post'   => $attendee->ID(),
2534
+			],
2535
+			REG_ADMIN_URL
2536
+		);
2537
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2538
+		// create link
2539
+		$this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2540
+			? EE_Admin_Page::add_query_args_and_nonce(
2541
+				[
2542
+					'action'  => 'duplicate_attendee',
2543
+					'_REG_ID' => $this->_registration->ID(),
2544
+				],
2545
+				REG_ADMIN_URL
2546
+			) : '';
2547
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2548
+		$this->_template_args['att_check']    = $att_check;
2549
+		$template_path                        =
2550
+			REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2551
+		EEH_Template::display_template($template_path, $this->_template_args);
2552
+	}
2553
+
2554
+
2555
+	/**
2556
+	 * trash or restore registrations
2557
+	 *
2558
+	 * @param boolean $trash whether to archive or restore
2559
+	 * @return void
2560
+	 * @throws EE_Error
2561
+	 * @throws InvalidArgumentException
2562
+	 * @throws InvalidDataTypeException
2563
+	 * @throws InvalidInterfaceException
2564
+	 * @throws RuntimeException
2565
+	 */
2566
+	protected function _trash_or_restore_registrations($trash = true)
2567
+	{
2568
+		// if empty _REG_ID then get out because there's nothing to do
2569
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2570
+		if (empty($REG_IDs)) {
2571
+			EE_Error::add_error(
2572
+				sprintf(
2573
+					esc_html__(
2574
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2575
+						'event_espresso'
2576
+					),
2577
+					$trash ? 'trash' : 'restore'
2578
+				),
2579
+				__FILE__,
2580
+				__LINE__,
2581
+				__FUNCTION__
2582
+			);
2583
+			$this->_redirect_after_action(false, '', '', [], true);
2584
+		}
2585
+		$success        = 0;
2586
+		$overwrite_msgs = false;
2587
+		// Checkboxes
2588
+		$reg_count = count($REG_IDs);
2589
+		// cycle thru checkboxes
2590
+		foreach ($REG_IDs as $REG_ID) {
2591
+			/** @var EE_Registration $REG */
2592
+			$REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2593
+			$payments = $REG->registration_payments();
2594
+			if (! empty($payments)) {
2595
+				$name           = $REG->attendee() instanceof EE_Attendee
2596
+					? $REG->attendee()->full_name()
2597
+					: esc_html__('Unknown Attendee', 'event_espresso');
2598
+				$overwrite_msgs = true;
2599
+				EE_Error::add_error(
2600
+					sprintf(
2601
+						esc_html__(
2602
+							'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.',
2603
+							'event_espresso'
2604
+						),
2605
+						$name
2606
+					),
2607
+					__FILE__,
2608
+					__FUNCTION__,
2609
+					__LINE__
2610
+				);
2611
+				// can't trash this registration because it has payments.
2612
+				continue;
2613
+			}
2614
+			$updated = $trash ? $REG->delete() : $REG->restore();
2615
+			if ($updated) {
2616
+				$success++;
2617
+			}
2618
+		}
2619
+		$this->_redirect_after_action(
2620
+			$success === $reg_count, // were ALL registrations affected?
2621
+			$success > 1
2622
+				? esc_html__('Registrations', 'event_espresso')
2623
+				: esc_html__('Registration', 'event_espresso'),
2624
+			$trash
2625
+				? esc_html__('moved to the trash', 'event_espresso')
2626
+				: esc_html__('restored', 'event_espresso'),
2627
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2628
+			$overwrite_msgs
2629
+		);
2630
+	}
2631
+
2632
+
2633
+	/**
2634
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2635
+	 * registration but also.
2636
+	 * 1. Removing relations to EE_Attendee
2637
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2638
+	 * ALSO trashed.
2639
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2640
+	 * 4. Removing relationships between all tickets and the related registrations
2641
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2642
+	 * 6. Deleting permanently any related Checkins.
2643
+	 *
2644
+	 * @return void
2645
+	 * @throws EE_Error
2646
+	 * @throws InvalidArgumentException
2647
+	 * @throws InvalidDataTypeException
2648
+	 * @throws InvalidInterfaceException
2649
+	 * @throws ReflectionException
2650
+	 */
2651
+	protected function _delete_registrations()
2652
+	{
2653
+		$REG_MDL = $this->getRegistrationModel();
2654
+		$success = 0;
2655
+		// Checkboxes
2656
+		$REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2657
+
2658
+		if (! empty($REG_IDs)) {
2659
+			// if array has more than one element than success message should be plural
2660
+			$success = count($REG_IDs) > 1 ? 2 : 1;
2661
+			// cycle thru checkboxes
2662
+			foreach ($REG_IDs as $REG_ID) {
2663
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2664
+				if (! $REG instanceof EE_Registration) {
2665
+					continue;
2666
+				}
2667
+				$deleted = $this->_delete_registration($REG);
2668
+				if (! $deleted) {
2669
+					$success = 0;
2670
+				}
2671
+			}
2672
+		}
2673
+
2674
+		$what        = $success > 1
2675
+			? esc_html__('Registrations', 'event_espresso')
2676
+			: esc_html__('Registration', 'event_espresso');
2677
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2678
+		$this->_redirect_after_action(
2679
+			$success,
2680
+			$what,
2681
+			$action_desc,
2682
+			$this->mergeExistingRequestParamsWithRedirectArgs(['action' => 'default']),
2683
+			true
2684
+		);
2685
+	}
2686
+
2687
+
2688
+	/**
2689
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2690
+	 * models get affected.
2691
+	 *
2692
+	 * @param EE_Registration $REG registration to be deleted permanently
2693
+	 * @return bool true = successful deletion, false = fail.
2694
+	 * @throws EE_Error
2695
+	 * @throws InvalidArgumentException
2696
+	 * @throws InvalidDataTypeException
2697
+	 * @throws InvalidInterfaceException
2698
+	 * @throws ReflectionException
2699
+	 */
2700
+	protected function _delete_registration(EE_Registration $REG)
2701
+	{
2702
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2703
+		// registrations on the transaction that are NOT trashed.
2704
+		$TXN = $REG->get_first_related('Transaction');
2705
+		if (! $TXN instanceof EE_Transaction) {
2706
+			EE_Error::add_error(
2707
+				sprintf(
2708
+					esc_html__(
2709
+						'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.',
2710
+						'event_espresso'
2711
+					),
2712
+					$REG->id()
2713
+				),
2714
+				__FILE__,
2715
+				__FUNCTION__,
2716
+				__LINE__
2717
+			);
2718
+			return false;
2719
+		}
2720
+		$REGS        = $TXN->get_many_related('Registration');
2721
+		$all_trashed = true;
2722
+		foreach ($REGS as $registration) {
2723
+			if (! $registration->get('REG_deleted')) {
2724
+				$all_trashed = false;
2725
+			}
2726
+		}
2727
+		if (! $all_trashed) {
2728
+			EE_Error::add_error(
2729
+				esc_html__(
2730
+					'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.',
2731
+					'event_espresso'
2732
+				),
2733
+				__FILE__,
2734
+				__FUNCTION__,
2735
+				__LINE__
2736
+			);
2737
+			return false;
2738
+		}
2739
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2740
+		// separately from THIS one).
2741
+		foreach ($REGS as $registration) {
2742
+			// delete related answers
2743
+			$registration->delete_related_permanently('Answer');
2744
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2745
+			$attendee = $registration->get_first_related('Attendee');
2746
+			if ($attendee instanceof EE_Attendee) {
2747
+				$registration->_remove_relation_to($attendee, 'Attendee');
2748
+			}
2749
+			// now remove relationships to tickets on this registration.
2750
+			$registration->_remove_relations('Ticket');
2751
+			// now delete permanently the checkins related to this registration.
2752
+			$registration->delete_related_permanently('Checkin');
2753
+			if ($registration->ID() === $REG->ID()) {
2754
+				continue;
2755
+			} //we don't want to delete permanently the existing registration just yet.
2756
+			// remove relation to transaction for these registrations if NOT the existing registrations
2757
+			$registration->_remove_relations('Transaction');
2758
+			// delete permanently any related messages.
2759
+			$registration->delete_related_permanently('Message');
2760
+			// now delete this registration permanently
2761
+			$registration->delete_permanently();
2762
+		}
2763
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2764
+		// (the transaction and line items should be all that's left).
2765
+		// delete the line items related to the transaction for this registration.
2766
+		$TXN->delete_related_permanently('Line_Item');
2767
+		// we need to remove all the relationships on the transaction
2768
+		$TXN->delete_related_permanently('Payment');
2769
+		$TXN->delete_related_permanently('Extra_Meta');
2770
+		$TXN->delete_related_permanently('Message');
2771
+		// now we can delete this REG permanently (and the transaction of course)
2772
+		$REG->delete_related_permanently('Transaction');
2773
+		return $REG->delete_permanently();
2774
+	}
2775
+
2776
+
2777
+	/**
2778
+	 *    generates HTML for the Register New Attendee Admin page
2779
+	 *
2780
+	 * @throws DomainException
2781
+	 * @throws EE_Error
2782
+	 * @throws InvalidArgumentException
2783
+	 * @throws InvalidDataTypeException
2784
+	 * @throws InvalidInterfaceException
2785
+	 * @throws ReflectionException
2786
+	 */
2787
+	public function new_registration()
2788
+	{
2789
+		if (! $this->_set_reg_event()) {
2790
+			throw new EE_Error(
2791
+				esc_html__(
2792
+					'Unable to continue with registering because there is no Event ID in the request',
2793
+					'event_espresso'
2794
+				)
2795
+			);
2796
+		}
2797
+		/** @var CurrentPage $current_page */
2798
+		$current_page = $this->loader->getShared(CurrentPage::class);
2799
+		$current_page->setEspressoPage(true);
2800
+		// gotta start with a clean slate if we're not coming here via ajax
2801
+		if (
2802
+			! $this->request->isAjax()
2803
+			&& (
2804
+				! $this->request->requestParamIsSet('processing_registration')
2805
+				|| $this->request->requestParamIsSet('step_error')
2806
+			)
2807
+		) {
2808
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2809
+		}
2810
+		$this->_template_args['event_name'] = '';
2811
+		// event name
2812
+		if ($this->_reg_event) {
2813
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2814
+			$edit_event_url                     = self::add_query_args_and_nonce(
2815
+				[
2816
+					'action' => 'edit',
2817
+					'post'   => $this->_reg_event->ID(),
2818
+				],
2819
+				EVENTS_ADMIN_URL
2820
+			);
2821
+			$edit_event_lnk                     = '<a href="'
2822
+												  . $edit_event_url
2823
+												  . '" title="'
2824
+												  . esc_attr__('Edit ', 'event_espresso')
2825
+												  . $this->_reg_event->name()
2826
+												  . '">'
2827
+												  . esc_html__('Edit Event', 'event_espresso')
2828
+												  . '</a>';
2829
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2830
+												   . $edit_event_lnk
2831
+												   . '</span>';
2832
+		}
2833
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2834
+		if ($this->request->isAjax()) {
2835
+			$this->_return_json();
2836
+		}
2837
+		// grab header
2838
+		$template_path                              =
2839
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2840
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2841
+			$template_path,
2842
+			$this->_template_args,
2843
+			true
2844
+		);
2845
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2846
+		// the details template wrapper
2847
+		$this->display_admin_page_with_sidebar();
2848
+	}
2849
+
2850
+
2851
+	/**
2852
+	 * This returns the content for a registration step
2853
+	 *
2854
+	 * @return string html
2855
+	 * @throws DomainException
2856
+	 * @throws EE_Error
2857
+	 * @throws InvalidArgumentException
2858
+	 * @throws InvalidDataTypeException
2859
+	 * @throws InvalidInterfaceException
2860
+	 * @throws ReflectionException
2861
+	 */
2862
+	protected function _get_registration_step_content()
2863
+	{
2864
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
2865
+			$warning_msg = sprintf(
2866
+				esc_html__(
2867
+					'%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',
2868
+					'event_espresso'
2869
+				),
2870
+				'<br />',
2871
+				'<h3 class="important-notice">',
2872
+				'</h3>',
2873
+				'<div class="float-right">',
2874
+				'<span id="redirect_timer" class="important-notice">30</span>',
2875
+				'</div>',
2876
+				'<b>',
2877
+				'</b>'
2878
+			);
2879
+			return '
2880 2880
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2881 2881
 	<script >
2882 2882
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -2889,856 +2889,856 @@  discard block
 block discarded – undo
2889 2889
 	        }
2890 2890
 	    }, 800 );
2891 2891
 	</script >';
2892
-        }
2893
-        $template_args = [
2894
-            'title'                    => '',
2895
-            'content'                  => '',
2896
-            'step_button_text'         => '',
2897
-            'show_notification_toggle' => false,
2898
-        ];
2899
-        // to indicate we're processing a new registration
2900
-        $hidden_fields = [
2901
-            'processing_registration' => [
2902
-                'type'  => 'hidden',
2903
-                'value' => 0,
2904
-            ],
2905
-            'event_id'                => [
2906
-                'type'  => 'hidden',
2907
-                'value' => $this->_reg_event->ID(),
2908
-            ],
2909
-        ];
2910
-        // if the cart is empty then we know we're at step one, so we'll display the ticket selector
2911
-        $cart = EE_Registry::instance()->SSN->cart();
2912
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2913
-        switch ($step) {
2914
-            case 'ticket':
2915
-                $hidden_fields['processing_registration']['value'] = 1;
2916
-                $template_args['title']                            = esc_html__(
2917
-                    'Step One: Select the Ticket for this registration',
2918
-                    'event_espresso'
2919
-                );
2920
-                $template_args['content']                          =
2921
-                    EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2922
-                $template_args['content']                          .= '</div>';
2923
-                $template_args['step_button_text']                 = esc_html__(
2924
-                    'Add Tickets and Continue to Registrant Details',
2925
-                    'event_espresso'
2926
-                );
2927
-                $template_args['show_notification_toggle']         = false;
2928
-                break;
2929
-            case 'questions':
2930
-                $hidden_fields['processing_registration']['value'] = 2;
2931
-                $template_args['title']                            = esc_html__(
2932
-                    'Step Two: Add Registrant Details for this Registration',
2933
-                    'event_espresso'
2934
-                );
2935
-                // in theory, we should be able to run EED_SPCO at this point
2936
-                // because the cart should have been set up properly by the first process_reg_step run.
2937
-                $template_args['content']                  =
2938
-                    EED_Single_Page_Checkout::registration_checkout_for_admin();
2939
-                $template_args['step_button_text']         = esc_html__(
2940
-                    'Save Registration and Continue to Details',
2941
-                    'event_espresso'
2942
-                );
2943
-                $template_args['show_notification_toggle'] = true;
2944
-                break;
2945
-        }
2946
-        // we come back to the process_registration_step route.
2947
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2948
-        return EEH_Template::display_template(
2949
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2950
-            $template_args,
2951
-            true
2952
-        );
2953
-    }
2954
-
2955
-
2956
-    /**
2957
-     * set_reg_event
2958
-     *
2959
-     * @return bool
2960
-     * @throws EE_Error
2961
-     * @throws InvalidArgumentException
2962
-     * @throws InvalidDataTypeException
2963
-     * @throws InvalidInterfaceException
2964
-     */
2965
-    private function _set_reg_event()
2966
-    {
2967
-        if (is_object($this->_reg_event)) {
2968
-            return true;
2969
-        }
2970
-
2971
-        $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2972
-        if (! $EVT_ID) {
2973
-            return false;
2974
-        }
2975
-        $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2976
-        return true;
2977
-    }
2978
-
2979
-
2980
-    /**
2981
-     * process_reg_step
2982
-     *
2983
-     * @return void
2984
-     * @throws DomainException
2985
-     * @throws EE_Error
2986
-     * @throws InvalidArgumentException
2987
-     * @throws InvalidDataTypeException
2988
-     * @throws InvalidInterfaceException
2989
-     * @throws ReflectionException
2990
-     * @throws RuntimeException
2991
-     */
2992
-    public function process_reg_step()
2993
-    {
2994
-        EE_System::do_not_cache();
2995
-        $this->_set_reg_event();
2996
-        /** @var CurrentPage $current_page */
2997
-        $current_page = $this->loader->getShared(CurrentPage::class);
2998
-        $current_page->setEspressoPage(true);
2999
-        $this->request->setRequestParam('uts', time());
3000
-        // what step are we on?
3001
-        $cart = EE_Registry::instance()->SSN->cart();
3002
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3003
-        // if doing ajax then we need to verify the nonce
3004
-        if ($this->request->isAjax()) {
3005
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
3006
-            $this->_verify_nonce($nonce, $this->_req_nonce);
3007
-        }
3008
-        switch ($step) {
3009
-            case 'ticket':
3010
-                // process ticket selection
3011
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
3012
-                if ($success) {
3013
-                    EE_Error::add_success(
3014
-                        esc_html__(
3015
-                            'Tickets Selected. Now complete the registration.',
3016
-                            'event_espresso'
3017
-                        )
3018
-                    );
3019
-                } else {
3020
-                    $this->request->setRequestParam('step_error', true);
3021
-                    $query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3022
-                }
3023
-                if ($this->request->isAjax()) {
3024
-                    $this->new_registration(); // display next step
3025
-                } else {
3026
-                    $query_args = [
3027
-                        'action'                  => 'new_registration',
3028
-                        'processing_registration' => 1,
3029
-                        'event_id'                => $this->_reg_event->ID(),
3030
-                        'uts'                     => time(),
3031
-                    ];
3032
-                    $this->_redirect_after_action(
3033
-                        false,
3034
-                        '',
3035
-                        '',
3036
-                        $query_args,
3037
-                        true
3038
-                    );
3039
-                }
3040
-                break;
3041
-            case 'questions':
3042
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3043
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3044
-                }
3045
-                // process registration
3046
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3047
-                if ($cart instanceof EE_Cart) {
3048
-                    $grand_total = $cart->get_grand_total();
3049
-                    if ($grand_total instanceof EE_Line_Item) {
3050
-                        $grand_total->save_this_and_descendants_to_txn();
3051
-                    }
3052
-                }
3053
-                if (! $transaction instanceof EE_Transaction) {
3054
-                    $query_args = [
3055
-                        'action'                  => 'new_registration',
3056
-                        'processing_registration' => 2,
3057
-                        'event_id'                => $this->_reg_event->ID(),
3058
-                        'uts'                     => time(),
3059
-                    ];
3060
-                    if ($this->request->isAjax()) {
3061
-                        // display registration form again because there are errors (maybe validation?)
3062
-                        $this->new_registration();
3063
-                        return;
3064
-                    }
3065
-                    $this->_redirect_after_action(
3066
-                        false,
3067
-                        '',
3068
-                        '',
3069
-                        $query_args,
3070
-                        true
3071
-                    );
3072
-                    return;
3073
-                }
3074
-                // maybe update status, and make sure to save transaction if not done already
3075
-                if (! $transaction->update_status_based_on_total_paid()) {
3076
-                    $transaction->save();
3077
-                }
3078
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3079
-                $query_args = [
3080
-                    'action'        => 'redirect_to_txn',
3081
-                    'TXN_ID'        => $transaction->ID(),
3082
-                    'EVT_ID'        => $this->_reg_event->ID(),
3083
-                    'event_name'    => urlencode($this->_reg_event->name()),
3084
-                    'redirect_from' => 'new_registration',
3085
-                ];
3086
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3087
-                break;
3088
-        }
3089
-        // what are you looking here for?  Should be nothing to do at this point.
3090
-    }
3091
-
3092
-
3093
-    /**
3094
-     * redirect_to_txn
3095
-     *
3096
-     * @return void
3097
-     * @throws EE_Error
3098
-     * @throws InvalidArgumentException
3099
-     * @throws InvalidDataTypeException
3100
-     * @throws InvalidInterfaceException
3101
-     * @throws ReflectionException
3102
-     */
3103
-    public function redirect_to_txn()
3104
-    {
3105
-        EE_System::do_not_cache();
3106
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3107
-        $query_args = [
3108
-            'action' => 'view_transaction',
3109
-            'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3110
-            'page'   => 'espresso_transactions',
3111
-        ];
3112
-        if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3113
-            $query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3114
-            $query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3115
-            $query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3116
-        }
3117
-        EE_Error::add_success(
3118
-            esc_html__(
3119
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3120
-                'event_espresso'
3121
-            )
3122
-        );
3123
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3124
-    }
3125
-
3126
-
3127
-    /**
3128
-     * generates HTML for the Attendee Contact List
3129
-     *
3130
-     * @return void
3131
-     * @throws DomainException
3132
-     * @throws EE_Error
3133
-     */
3134
-    protected function _attendee_contact_list_table()
3135
-    {
3136
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3137
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3138
-        $this->display_admin_list_table_page_with_no_sidebar();
3139
-    }
3140
-
3141
-
3142
-    /**
3143
-     * get_attendees
3144
-     *
3145
-     * @param      $per_page
3146
-     * @param bool $count whether to return count or data.
3147
-     * @param bool $trash
3148
-     * @return array|int
3149
-     * @throws EE_Error
3150
-     * @throws InvalidArgumentException
3151
-     * @throws InvalidDataTypeException
3152
-     * @throws InvalidInterfaceException
3153
-     */
3154
-    public function get_attendees($per_page, $count = false, $trash = false)
3155
-    {
3156
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3157
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3158
-        $orderby = $this->request->getRequestParam('orderby');
3159
-        switch ($orderby) {
3160
-            case 'ATT_ID':
3161
-            case 'ATT_fname':
3162
-            case 'ATT_email':
3163
-            case 'ATT_city':
3164
-            case 'STA_ID':
3165
-            case 'CNT_ID':
3166
-                break;
3167
-            case 'Registration_Count':
3168
-                $orderby = 'Registration_Count';
3169
-                break;
3170
-            default:
3171
-                $orderby = 'ATT_lname';
3172
-        }
3173
-        $sort         = $this->request->getRequestParam('order', 'ASC');
3174
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
3175
-        $per_page     = absint($per_page) ? $per_page : 10;
3176
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3177
-        $_where       = [];
3178
-        $search_term  = $this->request->getRequestParam('s');
3179
-        if ($search_term) {
3180
-            $search_term  = '%' . $search_term . '%';
3181
-            $_where['OR'] = [
3182
-                'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3183
-                'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3184
-                'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3185
-                'ATT_fname'                         => ['LIKE', $search_term],
3186
-                'ATT_lname'                         => ['LIKE', $search_term],
3187
-                'ATT_short_bio'                     => ['LIKE', $search_term],
3188
-                'ATT_email'                         => ['LIKE', $search_term],
3189
-                'ATT_address'                       => ['LIKE', $search_term],
3190
-                'ATT_address2'                      => ['LIKE', $search_term],
3191
-                'ATT_city'                          => ['LIKE', $search_term],
3192
-                'Country.CNT_name'                  => ['LIKE', $search_term],
3193
-                'State.STA_name'                    => ['LIKE', $search_term],
3194
-                'ATT_phone'                         => ['LIKE', $search_term],
3195
-                'Registration.REG_final_price'      => ['LIKE', $search_term],
3196
-                'Registration.REG_code'             => ['LIKE', $search_term],
3197
-                'Registration.REG_group_size'       => ['LIKE', $search_term],
3198
-            ];
3199
-        }
3200
-        $offset     = ($current_page - 1) * $per_page;
3201
-        $limit      = $count ? null : [$offset, $per_page];
3202
-        $query_args = [
3203
-            $_where,
3204
-            'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3205
-            'limit'         => $limit,
3206
-        ];
3207
-        if (! $count) {
3208
-            $query_args['order_by'] = [$orderby => $sort];
3209
-        }
3210
-        $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3211
-        return $count
3212
-            ? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3213
-            : $this->getAttendeeModel()->get_all($query_args);
3214
-    }
3215
-
3216
-
3217
-    /**
3218
-     * This is just taking care of resending the registration confirmation
3219
-     *
3220
-     * @return void
3221
-     * @throws EE_Error
3222
-     * @throws InvalidArgumentException
3223
-     * @throws InvalidDataTypeException
3224
-     * @throws InvalidInterfaceException
3225
-     * @throws ReflectionException
3226
-     */
3227
-    protected function _resend_registration()
3228
-    {
3229
-        $this->_process_resend_registration();
3230
-        $REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3231
-        $redirect_to = $this->request->getRequestParam('redirect_to');
3232
-        $query_args  = $redirect_to
3233
-            ? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3234
-            : ['action' => 'default'];
3235
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3236
-    }
3237
-
3238
-
3239
-    /**
3240
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3241
-     * to use when selecting registrations
3242
-     *
3243
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3244
-     *                                                     the query parameters from the request
3245
-     * @return void ends the request with a redirect or download
3246
-     */
3247
-    public function _registrations_report_base($method_name_for_getting_query_params)
3248
-    {
3249
-        $EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3250
-            ? $this->request->getRequestParam('EVT_ID', 0, 'int')
3251
-            : null;
3252
-        \EEH_Debug_Tools::printr(
3253
-            $method_name_for_getting_query_params,
3254
-            '$method_name_for_getting_query_params',
3255
-            __FILE__,
3256
-            __LINE__
3257
-        );
3258
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3259
-            $request_params = $this->request->requestParams();
3260
-            wp_redirect(
3261
-                EE_Admin_Page::add_query_args_and_nonce(
3262
-                    [
3263
-                        'page'        => 'espresso_batch',
3264
-                        'batch'       => 'file',
3265
-                        'EVT_ID'      => $EVT_ID,
3266
-                        'filters'     => urlencode(
3267
-                            serialize(
3268
-                                $this->$method_name_for_getting_query_params(
3269
-                                    EEH_Array::is_set($request_params, 'filters', [])
3270
-                                )
3271
-                            )
3272
-                        ),
3273
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3274
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3275
-                    ]
3276
-                )
3277
-            );
3278
-        } else {
3279
-            // Pull the current request params
3280
-            $request_args = $this->request->requestParams();
3281
-            // Set the required request_args to be passed to the export
3282
-            $required_request_args = [
3283
-                'export' => 'report',
3284
-                'action' => 'registrations_report_for_event',
3285
-                'EVT_ID' => $EVT_ID,
3286
-            ];
3287
-            // Merge required request args, overriding any currently set
3288
-            $request_args = array_merge($request_args, $required_request_args);
3289
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3290
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3291
-                $EE_Export = EE_Export::instance($request_args);
3292
-                $EE_Export->export();
3293
-            }
3294
-        }
3295
-    }
3296
-
3297
-
3298
-    /**
3299
-     * Creates a registration report using only query parameters in the request
3300
-     *
3301
-     * @return void
3302
-     */
3303
-    public function _registrations_report()
3304
-    {
3305
-        $this->_registrations_report_base('_get_registration_query_parameters');
3306
-    }
3307
-
3308
-
3309
-    public function _contact_list_export()
3310
-    {
3311
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3312
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3313
-            $EE_Export = EE_Export::instance($this->request->requestParams());
3314
-            $EE_Export->export_attendees();
3315
-        }
3316
-    }
3317
-
3318
-
3319
-    public function _contact_list_report()
3320
-    {
3321
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3322
-            wp_redirect(
3323
-                EE_Admin_Page::add_query_args_and_nonce(
3324
-                    [
3325
-                        'page'        => 'espresso_batch',
3326
-                        'batch'       => 'file',
3327
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3328
-                        'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3329
-                    ]
3330
-                )
3331
-            );
3332
-        } else {
3333
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3334
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3335
-                $EE_Export = EE_Export::instance($this->request->requestParams());
3336
-                $EE_Export->report_attendees();
3337
-            }
3338
-        }
3339
-    }
3340
-
3341
-
3342
-
3343
-
3344
-
3345
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3346
-    /**
3347
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3348
-     *
3349
-     * @return void
3350
-     * @throws EE_Error
3351
-     * @throws InvalidArgumentException
3352
-     * @throws InvalidDataTypeException
3353
-     * @throws InvalidInterfaceException
3354
-     * @throws ReflectionException
3355
-     */
3356
-    protected function _duplicate_attendee()
3357
-    {
3358
-        $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3359
-        $action = $this->request->getRequestParam('return', 'default');
3360
-        // verify we have necessary info
3361
-        if (! $REG_ID) {
3362
-            EE_Error::add_error(
3363
-                esc_html__(
3364
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3365
-                    'event_espresso'
3366
-                ),
3367
-                __FILE__,
3368
-                __LINE__,
3369
-                __FUNCTION__
3370
-            );
3371
-            $query_args = ['action' => $action];
3372
-            $this->_redirect_after_action('', '', '', $query_args, true);
3373
-        }
3374
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3375
-        $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3376
-        if (! $registration instanceof EE_Registration) {
3377
-            throw new RuntimeException(
3378
-                sprintf(
3379
-                    esc_html__(
3380
-                        'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3381
-                        'event_espresso'
3382
-                    ),
3383
-                    $REG_ID
3384
-                )
3385
-            );
3386
-        }
3387
-        $attendee = $registration->attendee();
3388
-        // remove relation of existing attendee on registration
3389
-        $registration->_remove_relation_to($attendee, 'Attendee');
3390
-        // new attendee
3391
-        $new_attendee = clone $attendee;
3392
-        $new_attendee->set('ATT_ID', 0);
3393
-        $new_attendee->save();
3394
-        // add new attendee to reg
3395
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3396
-        EE_Error::add_success(
3397
-            esc_html__(
3398
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3399
-                'event_espresso'
3400
-            )
3401
-        );
3402
-        // redirect to edit page for attendee
3403
-        $query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3404
-        $this->_redirect_after_action('', '', '', $query_args, true);
3405
-    }
3406
-
3407
-
3408
-    /**
3409
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3410
-     *
3411
-     * @param int     $post_id
3412
-     * @param WP_Post $post
3413
-     * @throws DomainException
3414
-     * @throws EE_Error
3415
-     * @throws InvalidArgumentException
3416
-     * @throws InvalidDataTypeException
3417
-     * @throws InvalidInterfaceException
3418
-     * @throws LogicException
3419
-     * @throws InvalidFormSubmissionException
3420
-     * @throws ReflectionException
3421
-     */
3422
-    protected function _insert_update_cpt_item($post_id, $post)
3423
-    {
3424
-        $success  = true;
3425
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3426
-            ? $this->getAttendeeModel()->get_one_by_ID($post_id)
3427
-            : null;
3428
-        // for attendee updates
3429
-        if ($attendee instanceof EE_Attendee) {
3430
-            // note we should only be UPDATING attendees at this point.
3431
-            $fname          = $this->request->getRequestParam('ATT_fname', '');
3432
-            $lname          = $this->request->getRequestParam('ATT_lname', '');
3433
-            $updated_fields = [
3434
-                'ATT_fname'     => $fname,
3435
-                'ATT_lname'     => $lname,
3436
-                'ATT_full_name' => "{$fname} {$lname}",
3437
-                'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3438
-                'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3439
-                'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3440
-                'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3441
-                'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3442
-                'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3443
-            ];
3444
-            foreach ($updated_fields as $field => $value) {
3445
-                $attendee->set($field, $value);
3446
-            }
3447
-
3448
-            // process contact details metabox form handler (which will also save the attendee)
3449
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3450
-            $success              = $contact_details_form->process($this->request->requestParams());
3451
-
3452
-            $attendee_update_callbacks = apply_filters(
3453
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3454
-                []
3455
-            );
3456
-            foreach ($attendee_update_callbacks as $a_callback) {
3457
-                if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3458
-                    throw new EE_Error(
3459
-                        sprintf(
3460
-                            esc_html__(
3461
-                                '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.',
3462
-                                'event_espresso'
3463
-                            ),
3464
-                            $a_callback
3465
-                        )
3466
-                    );
3467
-                }
3468
-            }
3469
-        }
3470
-
3471
-        if ($success === false) {
3472
-            EE_Error::add_error(
3473
-                esc_html__(
3474
-                    'Something went wrong with updating the meta table data for the registration.',
3475
-                    'event_espresso'
3476
-                ),
3477
-                __FILE__,
3478
-                __FUNCTION__,
3479
-                __LINE__
3480
-            );
3481
-        }
3482
-    }
3483
-
3484
-
3485
-    public function trash_cpt_item($post_id)
3486
-    {
3487
-    }
3488
-
3489
-
3490
-    public function delete_cpt_item($post_id)
3491
-    {
3492
-    }
3493
-
3494
-
3495
-    public function restore_cpt_item($post_id)
3496
-    {
3497
-    }
3498
-
3499
-
3500
-    protected function _restore_cpt_item($post_id, $revision_id)
3501
-    {
3502
-    }
3503
-
3504
-
3505
-    /**
3506
-     * @throws EE_Error
3507
-     * @throws ReflectionException
3508
-     * @since 4.10.2.p
3509
-     */
3510
-    public function attendee_editor_metaboxes()
3511
-    {
3512
-        $this->verify_cpt_object();
3513
-        remove_meta_box(
3514
-            'postexcerpt',
3515
-            $this->_cpt_routes[ $this->_req_action ],
3516
-            'normal'
3517
-        );
3518
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3519
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3520
-            add_meta_box(
3521
-                'postexcerpt',
3522
-                esc_html__('Short Biography', 'event_espresso'),
3523
-                'post_excerpt_meta_box',
3524
-                $this->_cpt_routes[ $this->_req_action ],
3525
-                'normal'
3526
-            );
3527
-        }
3528
-        if (post_type_supports('espresso_attendees', 'comments')) {
3529
-            add_meta_box(
3530
-                'commentsdiv',
3531
-                esc_html__('Notes on the Contact', 'event_espresso'),
3532
-                'post_comment_meta_box',
3533
-                $this->_cpt_routes[ $this->_req_action ],
3534
-                'normal',
3535
-                'core'
3536
-            );
3537
-        }
3538
-        add_meta_box(
3539
-            'attendee_contact_info',
3540
-            esc_html__('Contact Info', 'event_espresso'),
3541
-            [$this, 'attendee_contact_info'],
3542
-            $this->_cpt_routes[ $this->_req_action ],
3543
-            'side',
3544
-            'core'
3545
-        );
3546
-        add_meta_box(
3547
-            'attendee_details_address',
3548
-            esc_html__('Address Details', 'event_espresso'),
3549
-            [$this, 'attendee_address_details'],
3550
-            $this->_cpt_routes[ $this->_req_action ],
3551
-            'normal',
3552
-            'core'
3553
-        );
3554
-        add_meta_box(
3555
-            'attendee_registrations',
3556
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3557
-            [$this, 'attendee_registrations_meta_box'],
3558
-            $this->_cpt_routes[ $this->_req_action ],
3559
-            'normal',
3560
-            'high'
3561
-        );
3562
-    }
3563
-
3564
-
3565
-    /**
3566
-     * Metabox for attendee contact info
3567
-     *
3568
-     * @param WP_Post $post wp post object
3569
-     * @return void attendee contact info ( and form )
3570
-     * @throws EE_Error
3571
-     * @throws InvalidArgumentException
3572
-     * @throws InvalidDataTypeException
3573
-     * @throws InvalidInterfaceException
3574
-     * @throws LogicException
3575
-     * @throws DomainException
3576
-     */
3577
-    public function attendee_contact_info($post)
3578
-    {
3579
-        // get attendee object ( should already have it )
3580
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3581
-        $form->enqueueStylesAndScripts();
3582
-        echo wp_kses($form->display(), AllowedTags::getWithFormTags());
3583
-    }
3584
-
3585
-
3586
-    /**
3587
-     * Return form handler for the contact details metabox
3588
-     *
3589
-     * @param EE_Attendee $attendee
3590
-     * @return AttendeeContactDetailsMetaboxFormHandler
3591
-     * @throws DomainException
3592
-     * @throws InvalidArgumentException
3593
-     * @throws InvalidDataTypeException
3594
-     * @throws InvalidInterfaceException
3595
-     */
3596
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3597
-    {
3598
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3599
-    }
3600
-
3601
-
3602
-    /**
3603
-     * Metabox for attendee details
3604
-     *
3605
-     * @param WP_Post $post wp post object
3606
-     * @throws EE_Error
3607
-     * @throws ReflectionException
3608
-     */
3609
-    public function attendee_address_details($post)
3610
-    {
3611
-        // get attendee object (should already have it)
3612
-        $this->_template_args['attendee']     = $this->_cpt_model_obj;
3613
-        $this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3614
-            new EE_Question_Form_Input(
3615
-                EE_Question::new_instance(
3616
-                    [
3617
-                        'QST_ID'           => 0,
3618
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3619
-                        'QST_system'       => 'admin-state',
3620
-                    ]
3621
-                ),
3622
-                EE_Answer::new_instance(
3623
-                    [
3624
-                        'ANS_ID'    => 0,
3625
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3626
-                    ]
3627
-                ),
3628
-                [
3629
-                    'input_id'       => 'STA_ID',
3630
-                    'input_name'     => 'STA_ID',
3631
-                    'input_prefix'   => '',
3632
-                    'append_qstn_id' => false,
3633
-                ]
3634
-            )
3635
-        );
3636
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3637
-            new EE_Question_Form_Input(
3638
-                EE_Question::new_instance(
3639
-                    [
3640
-                        'QST_ID'           => 0,
3641
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3642
-                        'QST_system'       => 'admin-country',
3643
-                    ]
3644
-                ),
3645
-                EE_Answer::new_instance(
3646
-                    [
3647
-                        'ANS_ID'    => 0,
3648
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3649
-                    ]
3650
-                ),
3651
-                [
3652
-                    'input_id'       => 'CNT_ISO',
3653
-                    'input_name'     => 'CNT_ISO',
3654
-                    'input_prefix'   => '',
3655
-                    'append_qstn_id' => false,
3656
-                ]
3657
-            )
3658
-        );
3659
-        $template                             =
3660
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3661
-        EEH_Template::display_template($template, $this->_template_args);
3662
-    }
3663
-
3664
-
3665
-    /**
3666
-     * _attendee_details
3667
-     *
3668
-     * @param $post
3669
-     * @return void
3670
-     * @throws DomainException
3671
-     * @throws EE_Error
3672
-     * @throws InvalidArgumentException
3673
-     * @throws InvalidDataTypeException
3674
-     * @throws InvalidInterfaceException
3675
-     * @throws ReflectionException
3676
-     */
3677
-    public function attendee_registrations_meta_box($post)
3678
-    {
3679
-        $this->_template_args['attendee']      = $this->_cpt_model_obj;
3680
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3681
-        $template                              =
3682
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3683
-        EEH_Template::display_template($template, $this->_template_args);
3684
-    }
3685
-
3686
-
3687
-    /**
3688
-     * add in the form fields for the attendee edit
3689
-     *
3690
-     * @param WP_Post $post wp post object
3691
-     * @return void echos html for new form.
3692
-     * @throws DomainException
3693
-     */
3694
-    public function after_title_form_fields($post)
3695
-    {
3696
-        if ($post->post_type === 'espresso_attendees') {
3697
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3698
-            $template_args['attendee'] = $this->_cpt_model_obj;
3699
-            EEH_Template::display_template($template, $template_args);
3700
-        }
3701
-    }
3702
-
3703
-
3704
-    /**
3705
-     * _trash_or_restore_attendee
3706
-     *
3707
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3708
-     * @return void
3709
-     * @throws EE_Error
3710
-     * @throws InvalidArgumentException
3711
-     * @throws InvalidDataTypeException
3712
-     * @throws InvalidInterfaceException
3713
-     */
3714
-    protected function _trash_or_restore_attendees($trash = true)
3715
-    {
3716
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3717
-        $status = $trash ? 'trash' : 'publish';
3718
-        // Checkboxes
3719
-        if ($this->request->requestParamIsSet('checkbox')) {
3720
-            $ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3721
-            // if array has more than one element than success message should be plural
3722
-            $success = count($ATT_IDs) > 1 ? 2 : 1;
3723
-            // cycle thru checkboxes
3724
-            foreach ($ATT_IDs as $ATT_ID) {
3725
-                $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3726
-                if (! $updated) {
3727
-                    $success = 0;
3728
-                }
3729
-            }
3730
-        } else {
3731
-            // grab single id and delete
3732
-            $ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3733
-            // update attendee
3734
-            $success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3735
-        }
3736
-        $what        = $success > 1
3737
-            ? esc_html__('Contacts', 'event_espresso')
3738
-            : esc_html__('Contact', 'event_espresso');
3739
-        $action_desc = $trash
3740
-            ? esc_html__('moved to the trash', 'event_espresso')
3741
-            : esc_html__('restored', 'event_espresso');
3742
-        $this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3743
-    }
2892
+		}
2893
+		$template_args = [
2894
+			'title'                    => '',
2895
+			'content'                  => '',
2896
+			'step_button_text'         => '',
2897
+			'show_notification_toggle' => false,
2898
+		];
2899
+		// to indicate we're processing a new registration
2900
+		$hidden_fields = [
2901
+			'processing_registration' => [
2902
+				'type'  => 'hidden',
2903
+				'value' => 0,
2904
+			],
2905
+			'event_id'                => [
2906
+				'type'  => 'hidden',
2907
+				'value' => $this->_reg_event->ID(),
2908
+			],
2909
+		];
2910
+		// if the cart is empty then we know we're at step one, so we'll display the ticket selector
2911
+		$cart = EE_Registry::instance()->SSN->cart();
2912
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
2913
+		switch ($step) {
2914
+			case 'ticket':
2915
+				$hidden_fields['processing_registration']['value'] = 1;
2916
+				$template_args['title']                            = esc_html__(
2917
+					'Step One: Select the Ticket for this registration',
2918
+					'event_espresso'
2919
+				);
2920
+				$template_args['content']                          =
2921
+					EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2922
+				$template_args['content']                          .= '</div>';
2923
+				$template_args['step_button_text']                 = esc_html__(
2924
+					'Add Tickets and Continue to Registrant Details',
2925
+					'event_espresso'
2926
+				);
2927
+				$template_args['show_notification_toggle']         = false;
2928
+				break;
2929
+			case 'questions':
2930
+				$hidden_fields['processing_registration']['value'] = 2;
2931
+				$template_args['title']                            = esc_html__(
2932
+					'Step Two: Add Registrant Details for this Registration',
2933
+					'event_espresso'
2934
+				);
2935
+				// in theory, we should be able to run EED_SPCO at this point
2936
+				// because the cart should have been set up properly by the first process_reg_step run.
2937
+				$template_args['content']                  =
2938
+					EED_Single_Page_Checkout::registration_checkout_for_admin();
2939
+				$template_args['step_button_text']         = esc_html__(
2940
+					'Save Registration and Continue to Details',
2941
+					'event_espresso'
2942
+				);
2943
+				$template_args['show_notification_toggle'] = true;
2944
+				break;
2945
+		}
2946
+		// we come back to the process_registration_step route.
2947
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2948
+		return EEH_Template::display_template(
2949
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2950
+			$template_args,
2951
+			true
2952
+		);
2953
+	}
2954
+
2955
+
2956
+	/**
2957
+	 * set_reg_event
2958
+	 *
2959
+	 * @return bool
2960
+	 * @throws EE_Error
2961
+	 * @throws InvalidArgumentException
2962
+	 * @throws InvalidDataTypeException
2963
+	 * @throws InvalidInterfaceException
2964
+	 */
2965
+	private function _set_reg_event()
2966
+	{
2967
+		if (is_object($this->_reg_event)) {
2968
+			return true;
2969
+		}
2970
+
2971
+		$EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2972
+		if (! $EVT_ID) {
2973
+			return false;
2974
+		}
2975
+		$this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
2976
+		return true;
2977
+	}
2978
+
2979
+
2980
+	/**
2981
+	 * process_reg_step
2982
+	 *
2983
+	 * @return void
2984
+	 * @throws DomainException
2985
+	 * @throws EE_Error
2986
+	 * @throws InvalidArgumentException
2987
+	 * @throws InvalidDataTypeException
2988
+	 * @throws InvalidInterfaceException
2989
+	 * @throws ReflectionException
2990
+	 * @throws RuntimeException
2991
+	 */
2992
+	public function process_reg_step()
2993
+	{
2994
+		EE_System::do_not_cache();
2995
+		$this->_set_reg_event();
2996
+		/** @var CurrentPage $current_page */
2997
+		$current_page = $this->loader->getShared(CurrentPage::class);
2998
+		$current_page->setEspressoPage(true);
2999
+		$this->request->setRequestParam('uts', time());
3000
+		// what step are we on?
3001
+		$cart = EE_Registry::instance()->SSN->cart();
3002
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3003
+		// if doing ajax then we need to verify the nonce
3004
+		if ($this->request->isAjax()) {
3005
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
3006
+			$this->_verify_nonce($nonce, $this->_req_nonce);
3007
+		}
3008
+		switch ($step) {
3009
+			case 'ticket':
3010
+				// process ticket selection
3011
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
3012
+				if ($success) {
3013
+					EE_Error::add_success(
3014
+						esc_html__(
3015
+							'Tickets Selected. Now complete the registration.',
3016
+							'event_espresso'
3017
+						)
3018
+					);
3019
+				} else {
3020
+					$this->request->setRequestParam('step_error', true);
3021
+					$query_args['step_error'] = $this->request->getRequestParam('step_error', true, 'bool');
3022
+				}
3023
+				if ($this->request->isAjax()) {
3024
+					$this->new_registration(); // display next step
3025
+				} else {
3026
+					$query_args = [
3027
+						'action'                  => 'new_registration',
3028
+						'processing_registration' => 1,
3029
+						'event_id'                => $this->_reg_event->ID(),
3030
+						'uts'                     => time(),
3031
+					];
3032
+					$this->_redirect_after_action(
3033
+						false,
3034
+						'',
3035
+						'',
3036
+						$query_args,
3037
+						true
3038
+					);
3039
+				}
3040
+				break;
3041
+			case 'questions':
3042
+				if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3043
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3044
+				}
3045
+				// process registration
3046
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3047
+				if ($cart instanceof EE_Cart) {
3048
+					$grand_total = $cart->get_grand_total();
3049
+					if ($grand_total instanceof EE_Line_Item) {
3050
+						$grand_total->save_this_and_descendants_to_txn();
3051
+					}
3052
+				}
3053
+				if (! $transaction instanceof EE_Transaction) {
3054
+					$query_args = [
3055
+						'action'                  => 'new_registration',
3056
+						'processing_registration' => 2,
3057
+						'event_id'                => $this->_reg_event->ID(),
3058
+						'uts'                     => time(),
3059
+					];
3060
+					if ($this->request->isAjax()) {
3061
+						// display registration form again because there are errors (maybe validation?)
3062
+						$this->new_registration();
3063
+						return;
3064
+					}
3065
+					$this->_redirect_after_action(
3066
+						false,
3067
+						'',
3068
+						'',
3069
+						$query_args,
3070
+						true
3071
+					);
3072
+					return;
3073
+				}
3074
+				// maybe update status, and make sure to save transaction if not done already
3075
+				if (! $transaction->update_status_based_on_total_paid()) {
3076
+					$transaction->save();
3077
+				}
3078
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3079
+				$query_args = [
3080
+					'action'        => 'redirect_to_txn',
3081
+					'TXN_ID'        => $transaction->ID(),
3082
+					'EVT_ID'        => $this->_reg_event->ID(),
3083
+					'event_name'    => urlencode($this->_reg_event->name()),
3084
+					'redirect_from' => 'new_registration',
3085
+				];
3086
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3087
+				break;
3088
+		}
3089
+		// what are you looking here for?  Should be nothing to do at this point.
3090
+	}
3091
+
3092
+
3093
+	/**
3094
+	 * redirect_to_txn
3095
+	 *
3096
+	 * @return void
3097
+	 * @throws EE_Error
3098
+	 * @throws InvalidArgumentException
3099
+	 * @throws InvalidDataTypeException
3100
+	 * @throws InvalidInterfaceException
3101
+	 * @throws ReflectionException
3102
+	 */
3103
+	public function redirect_to_txn()
3104
+	{
3105
+		EE_System::do_not_cache();
3106
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3107
+		$query_args = [
3108
+			'action' => 'view_transaction',
3109
+			'TXN_ID' => $this->request->getRequestParam('TXN_ID', 0, 'int'),
3110
+			'page'   => 'espresso_transactions',
3111
+		];
3112
+		if ($this->request->requestParamIsSet('EVT_ID') && $this->request->requestParamIsSet('redirect_from')) {
3113
+			$query_args['EVT_ID']        = $this->request->getRequestParam('EVT_ID', 0, 'int');
3114
+			$query_args['event_name']    = urlencode($this->request->getRequestParam('event_name'));
3115
+			$query_args['redirect_from'] = $this->request->getRequestParam('redirect_from');
3116
+		}
3117
+		EE_Error::add_success(
3118
+			esc_html__(
3119
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3120
+				'event_espresso'
3121
+			)
3122
+		);
3123
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3124
+	}
3125
+
3126
+
3127
+	/**
3128
+	 * generates HTML for the Attendee Contact List
3129
+	 *
3130
+	 * @return void
3131
+	 * @throws DomainException
3132
+	 * @throws EE_Error
3133
+	 */
3134
+	protected function _attendee_contact_list_table()
3135
+	{
3136
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3137
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3138
+		$this->display_admin_list_table_page_with_no_sidebar();
3139
+	}
3140
+
3141
+
3142
+	/**
3143
+	 * get_attendees
3144
+	 *
3145
+	 * @param      $per_page
3146
+	 * @param bool $count whether to return count or data.
3147
+	 * @param bool $trash
3148
+	 * @return array|int
3149
+	 * @throws EE_Error
3150
+	 * @throws InvalidArgumentException
3151
+	 * @throws InvalidDataTypeException
3152
+	 * @throws InvalidInterfaceException
3153
+	 */
3154
+	public function get_attendees($per_page, $count = false, $trash = false)
3155
+	{
3156
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3157
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3158
+		$orderby = $this->request->getRequestParam('orderby');
3159
+		switch ($orderby) {
3160
+			case 'ATT_ID':
3161
+			case 'ATT_fname':
3162
+			case 'ATT_email':
3163
+			case 'ATT_city':
3164
+			case 'STA_ID':
3165
+			case 'CNT_ID':
3166
+				break;
3167
+			case 'Registration_Count':
3168
+				$orderby = 'Registration_Count';
3169
+				break;
3170
+			default:
3171
+				$orderby = 'ATT_lname';
3172
+		}
3173
+		$sort         = $this->request->getRequestParam('order', 'ASC');
3174
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
3175
+		$per_page     = absint($per_page) ? $per_page : 10;
3176
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
3177
+		$_where       = [];
3178
+		$search_term  = $this->request->getRequestParam('s');
3179
+		if ($search_term) {
3180
+			$search_term  = '%' . $search_term . '%';
3181
+			$_where['OR'] = [
3182
+				'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3183
+				'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
3184
+				'Registration.Event.EVT_short_desc' => ['LIKE', $search_term],
3185
+				'ATT_fname'                         => ['LIKE', $search_term],
3186
+				'ATT_lname'                         => ['LIKE', $search_term],
3187
+				'ATT_short_bio'                     => ['LIKE', $search_term],
3188
+				'ATT_email'                         => ['LIKE', $search_term],
3189
+				'ATT_address'                       => ['LIKE', $search_term],
3190
+				'ATT_address2'                      => ['LIKE', $search_term],
3191
+				'ATT_city'                          => ['LIKE', $search_term],
3192
+				'Country.CNT_name'                  => ['LIKE', $search_term],
3193
+				'State.STA_name'                    => ['LIKE', $search_term],
3194
+				'ATT_phone'                         => ['LIKE', $search_term],
3195
+				'Registration.REG_final_price'      => ['LIKE', $search_term],
3196
+				'Registration.REG_code'             => ['LIKE', $search_term],
3197
+				'Registration.REG_group_size'       => ['LIKE', $search_term],
3198
+			];
3199
+		}
3200
+		$offset     = ($current_page - 1) * $per_page;
3201
+		$limit      = $count ? null : [$offset, $per_page];
3202
+		$query_args = [
3203
+			$_where,
3204
+			'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3205
+			'limit'         => $limit,
3206
+		];
3207
+		if (! $count) {
3208
+			$query_args['order_by'] = [$orderby => $sort];
3209
+		}
3210
+		$query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
3211
+		return $count
3212
+			? $this->getAttendeeModel()->count($query_args, 'ATT_ID', true)
3213
+			: $this->getAttendeeModel()->get_all($query_args);
3214
+	}
3215
+
3216
+
3217
+	/**
3218
+	 * This is just taking care of resending the registration confirmation
3219
+	 *
3220
+	 * @return void
3221
+	 * @throws EE_Error
3222
+	 * @throws InvalidArgumentException
3223
+	 * @throws InvalidDataTypeException
3224
+	 * @throws InvalidInterfaceException
3225
+	 * @throws ReflectionException
3226
+	 */
3227
+	protected function _resend_registration()
3228
+	{
3229
+		$this->_process_resend_registration();
3230
+		$REG_ID      = $this->request->getRequestParam('_REG_ID', 0, 'int');
3231
+		$redirect_to = $this->request->getRequestParam('redirect_to');
3232
+		$query_args  = $redirect_to
3233
+			? ['action' => $redirect_to, '_REG_ID' => $REG_ID]
3234
+			: ['action' => 'default'];
3235
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3236
+	}
3237
+
3238
+
3239
+	/**
3240
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3241
+	 * to use when selecting registrations
3242
+	 *
3243
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3244
+	 *                                                     the query parameters from the request
3245
+	 * @return void ends the request with a redirect or download
3246
+	 */
3247
+	public function _registrations_report_base($method_name_for_getting_query_params)
3248
+	{
3249
+		$EVT_ID = $this->request->requestParamIsSet('EVT_ID')
3250
+			? $this->request->getRequestParam('EVT_ID', 0, 'int')
3251
+			: null;
3252
+		\EEH_Debug_Tools::printr(
3253
+			$method_name_for_getting_query_params,
3254
+			'$method_name_for_getting_query_params',
3255
+			__FILE__,
3256
+			__LINE__
3257
+		);
3258
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3259
+			$request_params = $this->request->requestParams();
3260
+			wp_redirect(
3261
+				EE_Admin_Page::add_query_args_and_nonce(
3262
+					[
3263
+						'page'        => 'espresso_batch',
3264
+						'batch'       => 'file',
3265
+						'EVT_ID'      => $EVT_ID,
3266
+						'filters'     => urlencode(
3267
+							serialize(
3268
+								$this->$method_name_for_getting_query_params(
3269
+									EEH_Array::is_set($request_params, 'filters', [])
3270
+								)
3271
+							)
3272
+						),
3273
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3274
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3275
+					]
3276
+				)
3277
+			);
3278
+		} else {
3279
+			// Pull the current request params
3280
+			$request_args = $this->request->requestParams();
3281
+			// Set the required request_args to be passed to the export
3282
+			$required_request_args = [
3283
+				'export' => 'report',
3284
+				'action' => 'registrations_report_for_event',
3285
+				'EVT_ID' => $EVT_ID,
3286
+			];
3287
+			// Merge required request args, overriding any currently set
3288
+			$request_args = array_merge($request_args, $required_request_args);
3289
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3290
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3291
+				$EE_Export = EE_Export::instance($request_args);
3292
+				$EE_Export->export();
3293
+			}
3294
+		}
3295
+	}
3296
+
3297
+
3298
+	/**
3299
+	 * Creates a registration report using only query parameters in the request
3300
+	 *
3301
+	 * @return void
3302
+	 */
3303
+	public function _registrations_report()
3304
+	{
3305
+		$this->_registrations_report_base('_get_registration_query_parameters');
3306
+	}
3307
+
3308
+
3309
+	public function _contact_list_export()
3310
+	{
3311
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3312
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3313
+			$EE_Export = EE_Export::instance($this->request->requestParams());
3314
+			$EE_Export->export_attendees();
3315
+		}
3316
+	}
3317
+
3318
+
3319
+	public function _contact_list_report()
3320
+	{
3321
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3322
+			wp_redirect(
3323
+				EE_Admin_Page::add_query_args_and_nonce(
3324
+					[
3325
+						'page'        => 'espresso_batch',
3326
+						'batch'       => 'file',
3327
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3328
+						'return_url'  => urlencode($this->request->getRequestParam('return_url', '', 'url')),
3329
+					]
3330
+				)
3331
+			);
3332
+		} else {
3333
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3334
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3335
+				$EE_Export = EE_Export::instance($this->request->requestParams());
3336
+				$EE_Export->report_attendees();
3337
+			}
3338
+		}
3339
+	}
3340
+
3341
+
3342
+
3343
+
3344
+
3345
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3346
+	/**
3347
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3348
+	 *
3349
+	 * @return void
3350
+	 * @throws EE_Error
3351
+	 * @throws InvalidArgumentException
3352
+	 * @throws InvalidDataTypeException
3353
+	 * @throws InvalidInterfaceException
3354
+	 * @throws ReflectionException
3355
+	 */
3356
+	protected function _duplicate_attendee()
3357
+	{
3358
+		$REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3359
+		$action = $this->request->getRequestParam('return', 'default');
3360
+		// verify we have necessary info
3361
+		if (! $REG_ID) {
3362
+			EE_Error::add_error(
3363
+				esc_html__(
3364
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3365
+					'event_espresso'
3366
+				),
3367
+				__FILE__,
3368
+				__LINE__,
3369
+				__FUNCTION__
3370
+			);
3371
+			$query_args = ['action' => $action];
3372
+			$this->_redirect_after_action('', '', '', $query_args, true);
3373
+		}
3374
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3375
+		$registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3376
+		if (! $registration instanceof EE_Registration) {
3377
+			throw new RuntimeException(
3378
+				sprintf(
3379
+					esc_html__(
3380
+						'Unable to create the contact because a valid registration could not be retrieved for REG ID: %1$d',
3381
+						'event_espresso'
3382
+					),
3383
+					$REG_ID
3384
+				)
3385
+			);
3386
+		}
3387
+		$attendee = $registration->attendee();
3388
+		// remove relation of existing attendee on registration
3389
+		$registration->_remove_relation_to($attendee, 'Attendee');
3390
+		// new attendee
3391
+		$new_attendee = clone $attendee;
3392
+		$new_attendee->set('ATT_ID', 0);
3393
+		$new_attendee->save();
3394
+		// add new attendee to reg
3395
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3396
+		EE_Error::add_success(
3397
+			esc_html__(
3398
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3399
+				'event_espresso'
3400
+			)
3401
+		);
3402
+		// redirect to edit page for attendee
3403
+		$query_args = ['post' => $new_attendee->ID(), 'action' => 'edit_attendee'];
3404
+		$this->_redirect_after_action('', '', '', $query_args, true);
3405
+	}
3406
+
3407
+
3408
+	/**
3409
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3410
+	 *
3411
+	 * @param int     $post_id
3412
+	 * @param WP_Post $post
3413
+	 * @throws DomainException
3414
+	 * @throws EE_Error
3415
+	 * @throws InvalidArgumentException
3416
+	 * @throws InvalidDataTypeException
3417
+	 * @throws InvalidInterfaceException
3418
+	 * @throws LogicException
3419
+	 * @throws InvalidFormSubmissionException
3420
+	 * @throws ReflectionException
3421
+	 */
3422
+	protected function _insert_update_cpt_item($post_id, $post)
3423
+	{
3424
+		$success  = true;
3425
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3426
+			? $this->getAttendeeModel()->get_one_by_ID($post_id)
3427
+			: null;
3428
+		// for attendee updates
3429
+		if ($attendee instanceof EE_Attendee) {
3430
+			// note we should only be UPDATING attendees at this point.
3431
+			$fname          = $this->request->getRequestParam('ATT_fname', '');
3432
+			$lname          = $this->request->getRequestParam('ATT_lname', '');
3433
+			$updated_fields = [
3434
+				'ATT_fname'     => $fname,
3435
+				'ATT_lname'     => $lname,
3436
+				'ATT_full_name' => "{$fname} {$lname}",
3437
+				'ATT_address'   => $this->request->getRequestParam('ATT_address', ''),
3438
+				'ATT_address2'  => $this->request->getRequestParam('ATT_address2', ''),
3439
+				'ATT_city'      => $this->request->getRequestParam('ATT_city', ''),
3440
+				'STA_ID'        => $this->request->getRequestParam('STA_ID', ''),
3441
+				'CNT_ISO'       => $this->request->getRequestParam('CNT_ISO', ''),
3442
+				'ATT_zip'       => $this->request->getRequestParam('ATT_zip', ''),
3443
+			];
3444
+			foreach ($updated_fields as $field => $value) {
3445
+				$attendee->set($field, $value);
3446
+			}
3447
+
3448
+			// process contact details metabox form handler (which will also save the attendee)
3449
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3450
+			$success              = $contact_details_form->process($this->request->requestParams());
3451
+
3452
+			$attendee_update_callbacks = apply_filters(
3453
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3454
+				[]
3455
+			);
3456
+			foreach ($attendee_update_callbacks as $a_callback) {
3457
+				if (false === call_user_func_array($a_callback, [$attendee, $this->request->requestParams()])) {
3458
+					throw new EE_Error(
3459
+						sprintf(
3460
+							esc_html__(
3461
+								'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.',
3462
+								'event_espresso'
3463
+							),
3464
+							$a_callback
3465
+						)
3466
+					);
3467
+				}
3468
+			}
3469
+		}
3470
+
3471
+		if ($success === false) {
3472
+			EE_Error::add_error(
3473
+				esc_html__(
3474
+					'Something went wrong with updating the meta table data for the registration.',
3475
+					'event_espresso'
3476
+				),
3477
+				__FILE__,
3478
+				__FUNCTION__,
3479
+				__LINE__
3480
+			);
3481
+		}
3482
+	}
3483
+
3484
+
3485
+	public function trash_cpt_item($post_id)
3486
+	{
3487
+	}
3488
+
3489
+
3490
+	public function delete_cpt_item($post_id)
3491
+	{
3492
+	}
3493
+
3494
+
3495
+	public function restore_cpt_item($post_id)
3496
+	{
3497
+	}
3498
+
3499
+
3500
+	protected function _restore_cpt_item($post_id, $revision_id)
3501
+	{
3502
+	}
3503
+
3504
+
3505
+	/**
3506
+	 * @throws EE_Error
3507
+	 * @throws ReflectionException
3508
+	 * @since 4.10.2.p
3509
+	 */
3510
+	public function attendee_editor_metaboxes()
3511
+	{
3512
+		$this->verify_cpt_object();
3513
+		remove_meta_box(
3514
+			'postexcerpt',
3515
+			$this->_cpt_routes[ $this->_req_action ],
3516
+			'normal'
3517
+		);
3518
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3519
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3520
+			add_meta_box(
3521
+				'postexcerpt',
3522
+				esc_html__('Short Biography', 'event_espresso'),
3523
+				'post_excerpt_meta_box',
3524
+				$this->_cpt_routes[ $this->_req_action ],
3525
+				'normal'
3526
+			);
3527
+		}
3528
+		if (post_type_supports('espresso_attendees', 'comments')) {
3529
+			add_meta_box(
3530
+				'commentsdiv',
3531
+				esc_html__('Notes on the Contact', 'event_espresso'),
3532
+				'post_comment_meta_box',
3533
+				$this->_cpt_routes[ $this->_req_action ],
3534
+				'normal',
3535
+				'core'
3536
+			);
3537
+		}
3538
+		add_meta_box(
3539
+			'attendee_contact_info',
3540
+			esc_html__('Contact Info', 'event_espresso'),
3541
+			[$this, 'attendee_contact_info'],
3542
+			$this->_cpt_routes[ $this->_req_action ],
3543
+			'side',
3544
+			'core'
3545
+		);
3546
+		add_meta_box(
3547
+			'attendee_details_address',
3548
+			esc_html__('Address Details', 'event_espresso'),
3549
+			[$this, 'attendee_address_details'],
3550
+			$this->_cpt_routes[ $this->_req_action ],
3551
+			'normal',
3552
+			'core'
3553
+		);
3554
+		add_meta_box(
3555
+			'attendee_registrations',
3556
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3557
+			[$this, 'attendee_registrations_meta_box'],
3558
+			$this->_cpt_routes[ $this->_req_action ],
3559
+			'normal',
3560
+			'high'
3561
+		);
3562
+	}
3563
+
3564
+
3565
+	/**
3566
+	 * Metabox for attendee contact info
3567
+	 *
3568
+	 * @param WP_Post $post wp post object
3569
+	 * @return void attendee contact info ( and form )
3570
+	 * @throws EE_Error
3571
+	 * @throws InvalidArgumentException
3572
+	 * @throws InvalidDataTypeException
3573
+	 * @throws InvalidInterfaceException
3574
+	 * @throws LogicException
3575
+	 * @throws DomainException
3576
+	 */
3577
+	public function attendee_contact_info($post)
3578
+	{
3579
+		// get attendee object ( should already have it )
3580
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3581
+		$form->enqueueStylesAndScripts();
3582
+		echo wp_kses($form->display(), AllowedTags::getWithFormTags());
3583
+	}
3584
+
3585
+
3586
+	/**
3587
+	 * Return form handler for the contact details metabox
3588
+	 *
3589
+	 * @param EE_Attendee $attendee
3590
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3591
+	 * @throws DomainException
3592
+	 * @throws InvalidArgumentException
3593
+	 * @throws InvalidDataTypeException
3594
+	 * @throws InvalidInterfaceException
3595
+	 */
3596
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3597
+	{
3598
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3599
+	}
3600
+
3601
+
3602
+	/**
3603
+	 * Metabox for attendee details
3604
+	 *
3605
+	 * @param WP_Post $post wp post object
3606
+	 * @throws EE_Error
3607
+	 * @throws ReflectionException
3608
+	 */
3609
+	public function attendee_address_details($post)
3610
+	{
3611
+		// get attendee object (should already have it)
3612
+		$this->_template_args['attendee']     = $this->_cpt_model_obj;
3613
+		$this->_template_args['state_html']   = EEH_Form_Fields::generate_form_input(
3614
+			new EE_Question_Form_Input(
3615
+				EE_Question::new_instance(
3616
+					[
3617
+						'QST_ID'           => 0,
3618
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3619
+						'QST_system'       => 'admin-state',
3620
+					]
3621
+				),
3622
+				EE_Answer::new_instance(
3623
+					[
3624
+						'ANS_ID'    => 0,
3625
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3626
+					]
3627
+				),
3628
+				[
3629
+					'input_id'       => 'STA_ID',
3630
+					'input_name'     => 'STA_ID',
3631
+					'input_prefix'   => '',
3632
+					'append_qstn_id' => false,
3633
+				]
3634
+			)
3635
+		);
3636
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3637
+			new EE_Question_Form_Input(
3638
+				EE_Question::new_instance(
3639
+					[
3640
+						'QST_ID'           => 0,
3641
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3642
+						'QST_system'       => 'admin-country',
3643
+					]
3644
+				),
3645
+				EE_Answer::new_instance(
3646
+					[
3647
+						'ANS_ID'    => 0,
3648
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3649
+					]
3650
+				),
3651
+				[
3652
+					'input_id'       => 'CNT_ISO',
3653
+					'input_name'     => 'CNT_ISO',
3654
+					'input_prefix'   => '',
3655
+					'append_qstn_id' => false,
3656
+				]
3657
+			)
3658
+		);
3659
+		$template                             =
3660
+			REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3661
+		EEH_Template::display_template($template, $this->_template_args);
3662
+	}
3663
+
3664
+
3665
+	/**
3666
+	 * _attendee_details
3667
+	 *
3668
+	 * @param $post
3669
+	 * @return void
3670
+	 * @throws DomainException
3671
+	 * @throws EE_Error
3672
+	 * @throws InvalidArgumentException
3673
+	 * @throws InvalidDataTypeException
3674
+	 * @throws InvalidInterfaceException
3675
+	 * @throws ReflectionException
3676
+	 */
3677
+	public function attendee_registrations_meta_box($post)
3678
+	{
3679
+		$this->_template_args['attendee']      = $this->_cpt_model_obj;
3680
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3681
+		$template                              =
3682
+			REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3683
+		EEH_Template::display_template($template, $this->_template_args);
3684
+	}
3685
+
3686
+
3687
+	/**
3688
+	 * add in the form fields for the attendee edit
3689
+	 *
3690
+	 * @param WP_Post $post wp post object
3691
+	 * @return void echos html for new form.
3692
+	 * @throws DomainException
3693
+	 */
3694
+	public function after_title_form_fields($post)
3695
+	{
3696
+		if ($post->post_type === 'espresso_attendees') {
3697
+			$template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3698
+			$template_args['attendee'] = $this->_cpt_model_obj;
3699
+			EEH_Template::display_template($template, $template_args);
3700
+		}
3701
+	}
3702
+
3703
+
3704
+	/**
3705
+	 * _trash_or_restore_attendee
3706
+	 *
3707
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3708
+	 * @return void
3709
+	 * @throws EE_Error
3710
+	 * @throws InvalidArgumentException
3711
+	 * @throws InvalidDataTypeException
3712
+	 * @throws InvalidInterfaceException
3713
+	 */
3714
+	protected function _trash_or_restore_attendees($trash = true)
3715
+	{
3716
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3717
+		$status = $trash ? 'trash' : 'publish';
3718
+		// Checkboxes
3719
+		if ($this->request->requestParamIsSet('checkbox')) {
3720
+			$ATT_IDs = $this->request->getRequestParam('checkbox', [], 'int', true);
3721
+			// if array has more than one element than success message should be plural
3722
+			$success = count($ATT_IDs) > 1 ? 2 : 1;
3723
+			// cycle thru checkboxes
3724
+			foreach ($ATT_IDs as $ATT_ID) {
3725
+				$updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3726
+				if (! $updated) {
3727
+					$success = 0;
3728
+				}
3729
+			}
3730
+		} else {
3731
+			// grab single id and delete
3732
+			$ATT_ID = $this->request->getRequestParam('ATT_ID', 0, 'int');
3733
+			// update attendee
3734
+			$success = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID) ? 1 : 0;
3735
+		}
3736
+		$what        = $success > 1
3737
+			? esc_html__('Contacts', 'event_espresso')
3738
+			: esc_html__('Contact', 'event_espresso');
3739
+		$action_desc = $trash
3740
+			? esc_html__('moved to the trash', 'event_espresso')
3741
+			: esc_html__('restored', 'event_espresso');
3742
+		$this->_redirect_after_action($success, $what, $action_desc, ['action' => 'contact_list']);
3743
+	}
3744 3744
 }
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     protected function getRegistrationModel()
95 95
     {
96
-        if (! $this->registration_model instanceof EEM_Registration) {
96
+        if ( ! $this->registration_model instanceof EEM_Registration) {
97 97
             $this->registration_model = $this->getLoader()->getShared('EEM_Registration');
98 98
         }
99 99
         return $this->registration_model;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     protected function getAttendeeModel()
111 111
     {
112
-        if (! $this->attendee_model instanceof EEM_Attendee) {
112
+        if ( ! $this->attendee_model instanceof EEM_Attendee) {
113 113
             $this->attendee_model = $this->getLoader()->getShared('EEM_Attendee');
114 114
         }
115 115
         return $this->attendee_model;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      */
126 126
     protected function getEventModel()
127 127
     {
128
-        if (! $this->event_model instanceof EEM_Event) {
128
+        if ( ! $this->event_model instanceof EEM_Event) {
129 129
             $this->event_model = $this->getLoader()->getShared('EEM_Event');
130 130
         }
131 131
         return $this->event_model;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     protected function getStatusModel()
143 143
     {
144
-        if (! $this->status_model instanceof EEM_Status) {
144
+        if ( ! $this->status_model instanceof EEM_Status) {
145 145
             $this->status_model = $this->getLoader()->getShared('EEM_Status');
146 146
         }
147 147
         return $this->status_model;
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
         // style
753 753
         wp_register_style(
754 754
             'espresso_reg',
755
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
755
+            REG_ASSETS_URL.'espresso_registrations_admin.css',
756 756
             ['ee-admin-css'],
757 757
             EVENT_ESPRESSO_VERSION
758 758
         );
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
         // script
761 761
         wp_register_script(
762 762
             'espresso_reg',
763
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
763
+            REG_ASSETS_URL.'espresso_registrations_admin.js',
764 764
             ['jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'],
765 765
             EVENT_ESPRESSO_VERSION,
766 766
             true
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
             'att_publish_text' => sprintf(
785 785
             /* translators: The date and time */
786 786
                 wp_strip_all_tags(__('Created on: %s', 'event_espresso')),
787
-                '<b>' . $this->_cpt_model_obj->get_datetime('ATT_created') . '</b>'
787
+                '<b>'.$this->_cpt_model_obj->get_datetime('ATT_created').'</b>'
788 788
             ),
789 789
         ];
790 790
         wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
         wp_dequeue_style('espresso_reg');
816 816
         wp_register_style(
817 817
             'espresso_att',
818
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
818
+            REG_ASSETS_URL.'espresso_attendees_admin.css',
819 819
             ['ee-admin-css'],
820 820
             EVENT_ESPRESSO_VERSION
821 821
         );
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
     {
828 828
         wp_register_script(
829 829
             'ee-spco-for-admin',
830
-            REG_ASSETS_URL . 'spco_for_admin.js',
830
+            REG_ASSETS_URL.'spco_for_admin.js',
831 831
             ['underscore', 'jquery'],
832 832
             EVENT_ESPRESSO_VERSION,
833 833
             true
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
             'no_approve_registrations' => 'not_approved_registration',
876 876
             'cancel_registrations'     => 'cancelled_registration',
877 877
         ];
878
-        $can_send    = EE_Registry::instance()->CAP->current_user_can(
878
+        $can_send = EE_Registry::instance()->CAP->current_user_can(
879 879
             'ee_send_message',
880 880
             'batch_send_messages'
881 881
         );
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
                     'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
981 981
                 ],
982 982
             ];
983
-            $this->_views['trash']      = [
983
+            $this->_views['trash'] = [
984 984
                 'slug'        => 'trash',
985 985
                 'label'       => esc_html__('Trash', 'event_espresso'),
986 986
                 'count'       => 0,
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
         }
1081 1081
         $sc_items = [
1082 1082
             'approved_status'   => [
1083
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
1083
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
1084 1084
                 'desc'  => EEH_Template::pretty_status(
1085 1085
                     EEM_Registration::status_id_approved,
1086 1086
                     false,
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
                 ),
1089 1089
             ],
1090 1090
             'pending_status'    => [
1091
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
1091
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
1092 1092
                 'desc'  => EEH_Template::pretty_status(
1093 1093
                     EEM_Registration::status_id_pending_payment,
1094 1094
                     false,
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
                 ),
1097 1097
             ],
1098 1098
             'wait_list'         => [
1099
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
1099
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list,
1100 1100
                 'desc'  => EEH_Template::pretty_status(
1101 1101
                     EEM_Registration::status_id_wait_list,
1102 1102
                     false,
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
                 ),
1105 1105
             ],
1106 1106
             'incomplete_status' => [
1107
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
1107
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete,
1108 1108
                 'desc'  => EEH_Template::pretty_status(
1109 1109
                     EEM_Registration::status_id_incomplete,
1110 1110
                     false,
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
                 ),
1113 1113
             ],
1114 1114
             'not_approved'      => [
1115
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
1115
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
1116 1116
                 'desc'  => EEH_Template::pretty_status(
1117 1117
                     EEM_Registration::status_id_not_approved,
1118 1118
                     false,
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
                 ),
1121 1121
             ],
1122 1122
             'declined_status'   => [
1123
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
1123
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
1124 1124
                 'desc'  => EEH_Template::pretty_status(
1125 1125
                     EEM_Registration::status_id_declined,
1126 1126
                     false,
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
                 ),
1129 1129
             ],
1130 1130
             'cancelled_status'  => [
1131
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1131
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
1132 1132
                 'desc'  => EEH_Template::pretty_status(
1133 1133
                     EEM_Registration::status_id_cancelled,
1134 1134
                     false,
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
                 $EVT_ID
1189 1189
             )
1190 1190
         ) {
1191
-            $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1191
+            $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
1192 1192
                 'new_registration',
1193 1193
                 'add-registrant',
1194 1194
                 ['event_id' => $EVT_ID],
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
                 ],
1347 1347
                 REG_ADMIN_URL
1348 1348
             );
1349
-            $this->_template_args['filtered_transactions_link']  = EE_Admin_Page::add_query_args_and_nonce(
1349
+            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1350 1350
                 [
1351 1351
                     'action' => 'default',
1352 1352
                     'EVT_ID' => $event_id,
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
                 ],
1355 1355
                 admin_url('admin.php')
1356 1356
             );
1357
-            $this->_template_args['event_link']                  = EE_Admin_Page::add_query_args_and_nonce(
1357
+            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1358 1358
                 [
1359 1359
                     'page'   => 'espresso_events',
1360 1360
                     'action' => 'edit',
@@ -1363,12 +1363,12 @@  discard block
 block discarded – undo
1363 1363
                 admin_url('admin.php')
1364 1364
             );
1365 1365
             // next and previous links
1366
-            $next_reg                                      = $this->_registration->next(
1366
+            $next_reg = $this->_registration->next(
1367 1367
                 null,
1368 1368
                 [],
1369 1369
                 'REG_ID'
1370 1370
             );
1371
-            $this->_template_args['next_registration']     = $next_reg
1371
+            $this->_template_args['next_registration'] = $next_reg
1372 1372
                 ? $this->_next_link(
1373 1373
                     EE_Admin_Page::add_query_args_and_nonce(
1374 1374
                         [
@@ -1380,7 +1380,7 @@  discard block
 block discarded – undo
1380 1380
                     'dashicons dashicons-arrow-right ee-icon-size-22'
1381 1381
                 )
1382 1382
                 : '';
1383
-            $previous_reg                                  = $this->_registration->previous(
1383
+            $previous_reg = $this->_registration->previous(
1384 1384
                 null,
1385 1385
                 [],
1386 1386
                 'REG_ID'
@@ -1398,7 +1398,7 @@  discard block
 block discarded – undo
1398 1398
                 )
1399 1399
                 : '';
1400 1400
             // grab header
1401
-            $template_path                             = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1401
+            $template_path                             = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1402 1402
             $this->_template_args['REG_ID']            = $this->_registration->ID();
1403 1403
             $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1404 1404
                 $template_path,
@@ -1552,7 +1552,7 @@  discard block
 block discarded – undo
1552 1552
                                 EEH_HTML::strong(
1553 1553
                                     $this->_registration->pretty_status(),
1554 1554
                                     '',
1555
-                                    'status-' . $this->_registration->status_ID(),
1555
+                                    'status-'.$this->_registration->status_ID(),
1556 1556
                                     'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1557 1557
                                 )
1558 1558
                             )
@@ -1568,7 +1568,7 @@  discard block
 block discarded – undo
1568 1568
                 $this->_registration->ID()
1569 1569
             )
1570 1570
         ) {
1571
-            $reg_status_change_form_array['subsections']['reg_status']         = new EE_Select_Input(
1571
+            $reg_status_change_form_array['subsections']['reg_status'] = new EE_Select_Input(
1572 1572
                 $this->_get_reg_statuses(),
1573 1573
                 [
1574 1574
                     'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
                     ),
1586 1586
                 ]
1587 1587
             );
1588
-            $reg_status_change_form_array['subsections']['submit']             = new EE_Submit_Input(
1588
+            $reg_status_change_form_array['subsections']['submit'] = new EE_Submit_Input(
1589 1589
                 [
1590 1590
                     'html_class'      => 'button-primary',
1591 1591
                     'html_label_text' => '&nbsp;',
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
     protected function _get_reg_statuses()
1611 1611
     {
1612 1612
         $reg_status_array = $this->getRegistrationModel()->reg_status_array();
1613
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1613
+        unset($reg_status_array[EEM_Registration::status_id_incomplete]);
1614 1614
         // get current reg status
1615 1615
         $current_status = $this->_registration->status_ID();
1616 1616
         // is registration for free event? This will determine whether to display the pending payment option
@@ -1618,7 +1618,7 @@  discard block
 block discarded – undo
1618 1618
             $current_status !== EEM_Registration::status_id_pending_payment
1619 1619
             && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1620 1620
         ) {
1621
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1621
+            unset($reg_status_array[EEM_Registration::status_id_pending_payment]);
1622 1622
         }
1623 1623
         return $this->getStatusModel()->localized_status($reg_status_array, false, 'sentence');
1624 1624
     }
@@ -1709,7 +1709,7 @@  discard block
 block discarded – undo
1709 1709
         $success = false;
1710 1710
         // typecast $REG_IDs
1711 1711
         $REG_IDs = (array) $REG_IDs;
1712
-        if (! empty($REG_IDs)) {
1712
+        if ( ! empty($REG_IDs)) {
1713 1713
             $success = true;
1714 1714
             // set default status if none is passed
1715 1715
             $status         = $status ?: EEM_Registration::status_id_pending_payment;
@@ -1869,7 +1869,7 @@  discard block
 block discarded – undo
1869 1869
             $action,
1870 1870
             $notify
1871 1871
         );
1872
-        $method = $action . '_registration';
1872
+        $method = $action.'_registration';
1873 1873
         if (method_exists($this, $method)) {
1874 1874
             $this->$method($notify);
1875 1875
         }
@@ -2019,7 +2019,7 @@  discard block
 block discarded – undo
2019 2019
         $filters        = new EE_Line_Item_Filter_Collection();
2020 2020
         $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2021 2021
         $filters->add(new EE_Non_Zero_Line_Item_Filter());
2022
-        $line_item_filter_processor              = new EE_Line_Item_Filter_Processor(
2022
+        $line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2023 2023
             $filters,
2024 2024
             $transaction->total_line_item()
2025 2025
         );
@@ -2032,7 +2032,7 @@  discard block
 block discarded – undo
2032 2032
             $filtered_line_item_tree,
2033 2033
             ['EE_Registration' => $this->_registration]
2034 2034
         );
2035
-        $attendee                                = $this->_registration->attendee();
2035
+        $attendee = $this->_registration->attendee();
2036 2036
         if (
2037 2037
             EE_Registry::instance()->CAP->current_user_can(
2038 2038
                 'ee_read_transaction',
@@ -2114,7 +2114,7 @@  discard block
 block discarded – undo
2114 2114
                 'Payment method response',
2115 2115
                 'event_espresso'
2116 2116
             );
2117
-            $this->_template_args['reg_details']['response_msg']['class']   = 'regular-text';
2117
+            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2118 2118
         }
2119 2119
         $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2120 2120
         $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
         $this->_template_args['REG_ID']                                       = $this->_registration->ID();
2145 2145
         $this->_template_args['event_id']                                     = $this->_registration->event_ID();
2146 2146
         $template_path                                                        =
2147
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2147
+            REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
2148 2148
         EEH_Template::display_template($template_path, $this->_template_args); // already escaped
2149 2149
     }
2150 2150
 
@@ -2182,7 +2182,7 @@  discard block
 block discarded – undo
2182 2182
             $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2183 2183
             $this->_template_args['REG_ID']                    = $this->_registration->ID();
2184 2184
             $template_path                                     =
2185
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2185
+                REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
2186 2186
             EEH_Template::display_template($template_path, $this->_template_args);
2187 2187
         }
2188 2188
     }
@@ -2198,7 +2198,7 @@  discard block
 block discarded – undo
2198 2198
     public function form_before_question_group($output)
2199 2199
     {
2200 2200
         EE_Error::doing_it_wrong(
2201
-            __CLASS__ . '::' . __FUNCTION__,
2201
+            __CLASS__.'::'.__FUNCTION__,
2202 2202
             esc_html__(
2203 2203
                 '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.',
2204 2204
                 'event_espresso'
@@ -2222,7 +2222,7 @@  discard block
 block discarded – undo
2222 2222
     public function form_after_question_group($output)
2223 2223
     {
2224 2224
         EE_Error::doing_it_wrong(
2225
-            __CLASS__ . '::' . __FUNCTION__,
2225
+            __CLASS__.'::'.__FUNCTION__,
2226 2226
             esc_html__(
2227 2227
                 '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.',
2228 2228
                 'event_espresso'
@@ -2259,7 +2259,7 @@  discard block
 block discarded – undo
2259 2259
     public function form_form_field_label_wrap($label)
2260 2260
     {
2261 2261
         EE_Error::doing_it_wrong(
2262
-            __CLASS__ . '::' . __FUNCTION__,
2262
+            __CLASS__.'::'.__FUNCTION__,
2263 2263
             esc_html__(
2264 2264
                 '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.',
2265 2265
                 'event_espresso'
@@ -2269,7 +2269,7 @@  discard block
 block discarded – undo
2269 2269
         return '
2270 2270
 			<tr>
2271 2271
 				<th>
2272
-					' . $label . '
2272
+					' . $label.'
2273 2273
 				</th>';
2274 2274
     }
2275 2275
 
@@ -2284,7 +2284,7 @@  discard block
 block discarded – undo
2284 2284
     public function form_form_field_input__wrap($input)
2285 2285
     {
2286 2286
         EE_Error::doing_it_wrong(
2287
-            __CLASS__ . '::' . __FUNCTION__,
2287
+            __CLASS__.'::'.__FUNCTION__,
2288 2288
             esc_html__(
2289 2289
                 '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.',
2290 2290
                 'event_espresso'
@@ -2293,7 +2293,7 @@  discard block
 block discarded – undo
2293 2293
         );
2294 2294
         return '
2295 2295
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2296
-					' . $input . '
2296
+					' . $input.'
2297 2297
 				</td>
2298 2298
 			</tr>';
2299 2299
     }
@@ -2342,8 +2342,8 @@  discard block
 block discarded – undo
2342 2342
      */
2343 2343
     protected function _get_reg_custom_questions_form($REG_ID)
2344 2344
     {
2345
-        if (! $this->_reg_custom_questions_form) {
2346
-            require_once(REG_ADMIN . 'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2345
+        if ( ! $this->_reg_custom_questions_form) {
2346
+            require_once(REG_ADMIN.'form_sections/EE_Registration_Custom_Questions_Form.form.php');
2347 2347
             $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2348 2348
                 $this->getRegistrationModel()->get_one_by_ID($REG_ID)
2349 2349
             );
@@ -2366,7 +2366,7 @@  discard block
 block discarded – undo
2366 2366
      */
2367 2367
     private function _save_reg_custom_questions_form($REG_ID = 0)
2368 2368
     {
2369
-        if (! $REG_ID) {
2369
+        if ( ! $REG_ID) {
2370 2370
             EE_Error::add_error(
2371 2371
                 esc_html__(
2372 2372
                     'An error occurred. No registration ID was received.',
@@ -2383,7 +2383,7 @@  discard block
 block discarded – undo
2383 2383
         if ($form->is_valid()) {
2384 2384
             foreach ($form->subforms() as $question_group_form) {
2385 2385
                 foreach ($question_group_form->inputs() as $question_id => $input) {
2386
-                    $where_conditions    = [
2386
+                    $where_conditions = [
2387 2387
                         'QST_ID' => $question_id,
2388 2388
                         'REG_ID' => $REG_ID,
2389 2389
                     ];
@@ -2424,7 +2424,7 @@  discard block
 block discarded – undo
2424 2424
         $REG = $this->getRegistrationModel();
2425 2425
         // get all other registrations on this transaction, and cache
2426 2426
         // the attendees for them so we don't have to run another query using force_join
2427
-        $registrations                           = $REG->get_all(
2427
+        $registrations = $REG->get_all(
2428 2428
             [
2429 2429
                 [
2430 2430
                     'TXN_ID' => $this->_registration->transaction_ID(),
@@ -2458,23 +2458,23 @@  discard block
 block discarded – undo
2458 2458
                 $attendee                                                      = $registration->attendee()
2459 2459
                     ? $registration->attendee()
2460 2460
                     : $this->getAttendeeModel()->create_default_object();
2461
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID']      = $registration->status_ID();
2462
-                $this->_template_args['attendees'][ $att_nmbr ]['fname']       = $attendee->fname();
2463
-                $this->_template_args['attendees'][ $att_nmbr ]['lname']       = $attendee->lname();
2464
-                $this->_template_args['attendees'][ $att_nmbr ]['email']       = $attendee->email();
2465
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2466
-                $this->_template_args['attendees'][ $att_nmbr ]['address']     = implode(
2461
+                $this->_template_args['attendees'][$att_nmbr]['STS_ID']      = $registration->status_ID();
2462
+                $this->_template_args['attendees'][$att_nmbr]['fname']       = $attendee->fname();
2463
+                $this->_template_args['attendees'][$att_nmbr]['lname']       = $attendee->lname();
2464
+                $this->_template_args['attendees'][$att_nmbr]['email']       = $attendee->email();
2465
+                $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price();
2466
+                $this->_template_args['attendees'][$att_nmbr]['address']     = implode(
2467 2467
                     ', ',
2468 2468
                     $attendee->full_address_as_array()
2469 2469
                 );
2470
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link']    = self::add_query_args_and_nonce(
2470
+                $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(
2471 2471
                     [
2472 2472
                         'action' => 'edit_attendee',
2473 2473
                         'post'   => $attendee->ID(),
2474 2474
                     ],
2475 2475
                     REG_ADMIN_URL
2476 2476
                 );
2477
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name']  =
2477
+                $this->_template_args['attendees'][$att_nmbr]['event_name'] =
2478 2478
                     $registration->event_obj() instanceof EE_Event
2479 2479
                         ? $registration->event_obj()->name()
2480 2480
                         : '';
@@ -2482,7 +2482,7 @@  discard block
 block discarded – undo
2482 2482
             }
2483 2483
             $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2484 2484
         }
2485
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2485
+        $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
2486 2486
         EEH_Template::display_template($template_path, $this->_template_args);
2487 2487
     }
2488 2488
 
@@ -2508,11 +2508,11 @@  discard block
 block discarded – undo
2508 2508
         // now let's determine if this is not the primary registration.  If it isn't then we set the
2509 2509
         // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2510 2510
         // primary registration object (that way we know if we need to show create button or not)
2511
-        if (! $this->_registration->is_primary_registrant()) {
2511
+        if ( ! $this->_registration->is_primary_registrant()) {
2512 2512
             $primary_registration = $this->_registration->get_primary_registration();
2513 2513
             $primary_attendee     = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2514 2514
                 : null;
2515
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2515
+            if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2516 2516
                 // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2517 2517
                 // custom attendee object so let's not worry about the primary reg.
2518 2518
                 $primary_registration = null;
@@ -2527,7 +2527,7 @@  discard block
 block discarded – undo
2527 2527
         $this->_template_args['phone']             = $attendee->phone();
2528 2528
         $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2529 2529
         // edit link
2530
-        $this->_template_args['att_edit_link']  = EE_Admin_Page::add_query_args_and_nonce(
2530
+        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2531 2531
             [
2532 2532
                 'action' => 'edit_attendee',
2533 2533
                 'post'   => $attendee->ID(),
@@ -2536,7 +2536,7 @@  discard block
 block discarded – undo
2536 2536
         );
2537 2537
         $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2538 2538
         // create link
2539
-        $this->_template_args['create_link']  = $primary_registration instanceof EE_Registration
2539
+        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2540 2540
             ? EE_Admin_Page::add_query_args_and_nonce(
2541 2541
                 [
2542 2542
                     'action'  => 'duplicate_attendee',
@@ -2547,7 +2547,7 @@  discard block
 block discarded – undo
2547 2547
         $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2548 2548
         $this->_template_args['att_check']    = $att_check;
2549 2549
         $template_path                        =
2550
-            REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2550
+            REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
2551 2551
         EEH_Template::display_template($template_path, $this->_template_args);
2552 2552
     }
2553 2553
 
@@ -2591,7 +2591,7 @@  discard block
 block discarded – undo
2591 2591
             /** @var EE_Registration $REG */
2592 2592
             $REG      = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
2593 2593
             $payments = $REG->registration_payments();
2594
-            if (! empty($payments)) {
2594
+            if ( ! empty($payments)) {
2595 2595
                 $name           = $REG->attendee() instanceof EE_Attendee
2596 2596
                     ? $REG->attendee()->full_name()
2597 2597
                     : esc_html__('Unknown Attendee', 'event_espresso');
@@ -2655,17 +2655,17 @@  discard block
 block discarded – undo
2655 2655
         // Checkboxes
2656 2656
         $REG_IDs = $this->request->getRequestParam('_REG_ID', [], 'int', true);
2657 2657
 
2658
-        if (! empty($REG_IDs)) {
2658
+        if ( ! empty($REG_IDs)) {
2659 2659
             // if array has more than one element than success message should be plural
2660 2660
             $success = count($REG_IDs) > 1 ? 2 : 1;
2661 2661
             // cycle thru checkboxes
2662 2662
             foreach ($REG_IDs as $REG_ID) {
2663 2663
                 $REG = $REG_MDL->get_one_by_ID($REG_ID);
2664
-                if (! $REG instanceof EE_Registration) {
2664
+                if ( ! $REG instanceof EE_Registration) {
2665 2665
                     continue;
2666 2666
                 }
2667 2667
                 $deleted = $this->_delete_registration($REG);
2668
-                if (! $deleted) {
2668
+                if ( ! $deleted) {
2669 2669
                     $success = 0;
2670 2670
                 }
2671 2671
             }
@@ -2702,7 +2702,7 @@  discard block
 block discarded – undo
2702 2702
         // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2703 2703
         // registrations on the transaction that are NOT trashed.
2704 2704
         $TXN = $REG->get_first_related('Transaction');
2705
-        if (! $TXN instanceof EE_Transaction) {
2705
+        if ( ! $TXN instanceof EE_Transaction) {
2706 2706
             EE_Error::add_error(
2707 2707
                 sprintf(
2708 2708
                     esc_html__(
@@ -2720,11 +2720,11 @@  discard block
 block discarded – undo
2720 2720
         $REGS        = $TXN->get_many_related('Registration');
2721 2721
         $all_trashed = true;
2722 2722
         foreach ($REGS as $registration) {
2723
-            if (! $registration->get('REG_deleted')) {
2723
+            if ( ! $registration->get('REG_deleted')) {
2724 2724
                 $all_trashed = false;
2725 2725
             }
2726 2726
         }
2727
-        if (! $all_trashed) {
2727
+        if ( ! $all_trashed) {
2728 2728
             EE_Error::add_error(
2729 2729
                 esc_html__(
2730 2730
                     '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.',
@@ -2786,7 +2786,7 @@  discard block
 block discarded – undo
2786 2786
      */
2787 2787
     public function new_registration()
2788 2788
     {
2789
-        if (! $this->_set_reg_event()) {
2789
+        if ( ! $this->_set_reg_event()) {
2790 2790
             throw new EE_Error(
2791 2791
                 esc_html__(
2792 2792
                     'Unable to continue with registering because there is no Event ID in the request',
@@ -2818,7 +2818,7 @@  discard block
 block discarded – undo
2818 2818
                 ],
2819 2819
                 EVENTS_ADMIN_URL
2820 2820
             );
2821
-            $edit_event_lnk                     = '<a href="'
2821
+            $edit_event_lnk = '<a href="'
2822 2822
                                                   . $edit_event_url
2823 2823
                                                   . '" title="'
2824 2824
                                                   . esc_attr__('Edit ', 'event_espresso')
@@ -2836,7 +2836,7 @@  discard block
 block discarded – undo
2836 2836
         }
2837 2837
         // grab header
2838 2838
         $template_path                              =
2839
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2839
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2840 2840
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2841 2841
             $template_path,
2842 2842
             $this->_template_args,
@@ -2877,7 +2877,7 @@  discard block
 block discarded – undo
2877 2877
                 '</b>'
2878 2878
             );
2879 2879
             return '
2880
-	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
2880
+	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div>
2881 2881
 	<script >
2882 2882
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
2883 2883
 		// after just adding a new registration... we gotta try to put a stop to that !!!
@@ -2919,7 +2919,7 @@  discard block
 block discarded – undo
2919 2919
                 );
2920 2920
                 $template_args['content']                          =
2921 2921
                     EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2922
-                $template_args['content']                          .= '</div>';
2922
+                $template_args['content'] .= '</div>';
2923 2923
                 $template_args['step_button_text']                 = esc_html__(
2924 2924
                     'Add Tickets and Continue to Registrant Details',
2925 2925
                     'event_espresso'
@@ -2946,7 +2946,7 @@  discard block
 block discarded – undo
2946 2946
         // we come back to the process_registration_step route.
2947 2947
         $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
2948 2948
         return EEH_Template::display_template(
2949
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
2949
+            REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php',
2950 2950
             $template_args,
2951 2951
             true
2952 2952
         );
@@ -2969,7 +2969,7 @@  discard block
 block discarded – undo
2969 2969
         }
2970 2970
 
2971 2971
         $EVT_ID = $this->request->getRequestParam('event_id', 0, 'int');
2972
-        if (! $EVT_ID) {
2972
+        if ( ! $EVT_ID) {
2973 2973
             return false;
2974 2974
         }
2975 2975
         $this->_reg_event = $this->getEventModel()->get_one_by_ID($EVT_ID);
@@ -3039,7 +3039,7 @@  discard block
 block discarded – undo
3039 3039
                 }
3040 3040
                 break;
3041 3041
             case 'questions':
3042
-                if (! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3042
+                if ( ! $this->request->requestParamIsSet('txn_reg_status_change[send_notifications]')) {
3043 3043
                     add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3044 3044
                 }
3045 3045
                 // process registration
@@ -3050,7 +3050,7 @@  discard block
 block discarded – undo
3050 3050
                         $grand_total->save_this_and_descendants_to_txn();
3051 3051
                     }
3052 3052
                 }
3053
-                if (! $transaction instanceof EE_Transaction) {
3053
+                if ( ! $transaction instanceof EE_Transaction) {
3054 3054
                     $query_args = [
3055 3055
                         'action'                  => 'new_registration',
3056 3056
                         'processing_registration' => 2,
@@ -3072,7 +3072,7 @@  discard block
 block discarded – undo
3072 3072
                     return;
3073 3073
                 }
3074 3074
                 // maybe update status, and make sure to save transaction if not done already
3075
-                if (! $transaction->update_status_based_on_total_paid()) {
3075
+                if ( ! $transaction->update_status_based_on_total_paid()) {
3076 3076
                     $transaction->save();
3077 3077
                 }
3078 3078
                 EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
@@ -3154,7 +3154,7 @@  discard block
 block discarded – undo
3154 3154
     public function get_attendees($per_page, $count = false, $trash = false)
3155 3155
     {
3156 3156
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3157
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3157
+        require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
3158 3158
         $orderby = $this->request->getRequestParam('orderby');
3159 3159
         switch ($orderby) {
3160 3160
             case 'ATT_ID':
@@ -3177,7 +3177,7 @@  discard block
 block discarded – undo
3177 3177
         $_where       = [];
3178 3178
         $search_term  = $this->request->getRequestParam('s');
3179 3179
         if ($search_term) {
3180
-            $search_term  = '%' . $search_term . '%';
3180
+            $search_term  = '%'.$search_term.'%';
3181 3181
             $_where['OR'] = [
3182 3182
                 'Registration.Event.EVT_name'       => ['LIKE', $search_term],
3183 3183
                 'Registration.Event.EVT_desc'       => ['LIKE', $search_term],
@@ -3204,7 +3204,7 @@  discard block
 block discarded – undo
3204 3204
             'extra_selects' => ['Registration_Count' => ['Registration.REG_ID', 'count', '%d']],
3205 3205
             'limit'         => $limit,
3206 3206
         ];
3207
-        if (! $count) {
3207
+        if ( ! $count) {
3208 3208
             $query_args['order_by'] = [$orderby => $sort];
3209 3209
         }
3210 3210
         $query_args[0]['status'] = $trash ? ['!=', 'publish'] : ['IN', ['publish']];
@@ -3255,7 +3255,7 @@  discard block
 block discarded – undo
3255 3255
             __FILE__,
3256 3256
             __LINE__
3257 3257
         );
3258
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3258
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3259 3259
             $request_params = $this->request->requestParams();
3260 3260
             wp_redirect(
3261 3261
                 EE_Admin_Page::add_query_args_and_nonce(
@@ -3286,8 +3286,8 @@  discard block
 block discarded – undo
3286 3286
             ];
3287 3287
             // Merge required request args, overriding any currently set
3288 3288
             $request_args = array_merge($request_args, $required_request_args);
3289
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3290
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3289
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3290
+                require_once(EE_CLASSES.'EE_Export.class.php');
3291 3291
                 $EE_Export = EE_Export::instance($request_args);
3292 3292
                 $EE_Export->export();
3293 3293
             }
@@ -3308,8 +3308,8 @@  discard block
 block discarded – undo
3308 3308
 
3309 3309
     public function _contact_list_export()
3310 3310
     {
3311
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3312
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3311
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3312
+            require_once(EE_CLASSES.'EE_Export.class.php');
3313 3313
             $EE_Export = EE_Export::instance($this->request->requestParams());
3314 3314
             $EE_Export->export_attendees();
3315 3315
         }
@@ -3318,7 +3318,7 @@  discard block
 block discarded – undo
3318 3318
 
3319 3319
     public function _contact_list_report()
3320 3320
     {
3321
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3321
+        if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3322 3322
             wp_redirect(
3323 3323
                 EE_Admin_Page::add_query_args_and_nonce(
3324 3324
                     [
@@ -3330,8 +3330,8 @@  discard block
 block discarded – undo
3330 3330
                 )
3331 3331
             );
3332 3332
         } else {
3333
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3334
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3333
+            if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
3334
+                require_once(EE_CLASSES.'EE_Export.class.php');
3335 3335
                 $EE_Export = EE_Export::instance($this->request->requestParams());
3336 3336
                 $EE_Export->report_attendees();
3337 3337
             }
@@ -3358,7 +3358,7 @@  discard block
 block discarded – undo
3358 3358
         $REG_ID = $this->request->getRequestParam('_REG_ID', 0, 'int');
3359 3359
         $action = $this->request->getRequestParam('return', 'default');
3360 3360
         // verify we have necessary info
3361
-        if (! $REG_ID) {
3361
+        if ( ! $REG_ID) {
3362 3362
             EE_Error::add_error(
3363 3363
                 esc_html__(
3364 3364
                     'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
@@ -3373,7 +3373,7 @@  discard block
 block discarded – undo
3373 3373
         }
3374 3374
         // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3375 3375
         $registration = $this->getRegistrationModel()->get_one_by_ID($REG_ID);
3376
-        if (! $registration instanceof EE_Registration) {
3376
+        if ( ! $registration instanceof EE_Registration) {
3377 3377
             throw new RuntimeException(
3378 3378
                 sprintf(
3379 3379
                     esc_html__(
@@ -3512,16 +3512,16 @@  discard block
 block discarded – undo
3512 3512
         $this->verify_cpt_object();
3513 3513
         remove_meta_box(
3514 3514
             'postexcerpt',
3515
-            $this->_cpt_routes[ $this->_req_action ],
3515
+            $this->_cpt_routes[$this->_req_action],
3516 3516
             'normal'
3517 3517
         );
3518
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal');
3518
+        remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal');
3519 3519
         if (post_type_supports('espresso_attendees', 'excerpt')) {
3520 3520
             add_meta_box(
3521 3521
                 'postexcerpt',
3522 3522
                 esc_html__('Short Biography', 'event_espresso'),
3523 3523
                 'post_excerpt_meta_box',
3524
-                $this->_cpt_routes[ $this->_req_action ],
3524
+                $this->_cpt_routes[$this->_req_action],
3525 3525
                 'normal'
3526 3526
             );
3527 3527
         }
@@ -3530,7 +3530,7 @@  discard block
 block discarded – undo
3530 3530
                 'commentsdiv',
3531 3531
                 esc_html__('Notes on the Contact', 'event_espresso'),
3532 3532
                 'post_comment_meta_box',
3533
-                $this->_cpt_routes[ $this->_req_action ],
3533
+                $this->_cpt_routes[$this->_req_action],
3534 3534
                 'normal',
3535 3535
                 'core'
3536 3536
             );
@@ -3539,7 +3539,7 @@  discard block
 block discarded – undo
3539 3539
             'attendee_contact_info',
3540 3540
             esc_html__('Contact Info', 'event_espresso'),
3541 3541
             [$this, 'attendee_contact_info'],
3542
-            $this->_cpt_routes[ $this->_req_action ],
3542
+            $this->_cpt_routes[$this->_req_action],
3543 3543
             'side',
3544 3544
             'core'
3545 3545
         );
@@ -3547,7 +3547,7 @@  discard block
 block discarded – undo
3547 3547
             'attendee_details_address',
3548 3548
             esc_html__('Address Details', 'event_espresso'),
3549 3549
             [$this, 'attendee_address_details'],
3550
-            $this->_cpt_routes[ $this->_req_action ],
3550
+            $this->_cpt_routes[$this->_req_action],
3551 3551
             'normal',
3552 3552
             'core'
3553 3553
         );
@@ -3555,7 +3555,7 @@  discard block
 block discarded – undo
3555 3555
             'attendee_registrations',
3556 3556
             esc_html__('Registrations for this Contact', 'event_espresso'),
3557 3557
             [$this, 'attendee_registrations_meta_box'],
3558
-            $this->_cpt_routes[ $this->_req_action ],
3558
+            $this->_cpt_routes[$this->_req_action],
3559 3559
             'normal',
3560 3560
             'high'
3561 3561
         );
@@ -3656,8 +3656,8 @@  discard block
 block discarded – undo
3656 3656
                 ]
3657 3657
             )
3658 3658
         );
3659
-        $template                             =
3660
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3659
+        $template =
3660
+            REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
3661 3661
         EEH_Template::display_template($template, $this->_template_args);
3662 3662
     }
3663 3663
 
@@ -3679,7 +3679,7 @@  discard block
 block discarded – undo
3679 3679
         $this->_template_args['attendee']      = $this->_cpt_model_obj;
3680 3680
         $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3681 3681
         $template                              =
3682
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3682
+            REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
3683 3683
         EEH_Template::display_template($template, $this->_template_args);
3684 3684
     }
3685 3685
 
@@ -3694,7 +3694,7 @@  discard block
 block discarded – undo
3694 3694
     public function after_title_form_fields($post)
3695 3695
     {
3696 3696
         if ($post->post_type === 'espresso_attendees') {
3697
-            $template                  = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3697
+            $template                  = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
3698 3698
             $template_args['attendee'] = $this->_cpt_model_obj;
3699 3699
             EEH_Template::display_template($template, $template_args);
3700 3700
         }
@@ -3723,7 +3723,7 @@  discard block
 block discarded – undo
3723 3723
             // cycle thru checkboxes
3724 3724
             foreach ($ATT_IDs as $ATT_ID) {
3725 3725
                 $updated = $this->getAttendeeModel()->update_by_ID(['status' => $status], $ATT_ID);
3726
-                if (! $updated) {
3726
+                if ( ! $updated) {
3727 3727
                     $success = 0;
3728 3728
                 }
3729 3729
             }
Please login to merge, or discard this patch.