Completed
Branch fix/remove-help-tours (9cc8eb)
by
unknown
08:22 queued 06:39
created
core/helpers/EEH_Template.helper.php 2 patches
Indentation   +926 added lines, -926 removed lines patch added patch discarded remove patch
@@ -6,36 +6,36 @@  discard block
 block discarded – undo
6 6
 use EventEspresso\core\services\request\RequestInterface;
7 7
 
8 8
 if (! function_exists('espresso_get_template_part')) {
9
-    /**
10
-     * espresso_get_template_part
11
-     * 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
12
-     * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
13
-     *
14
-     * @param string $slug The slug name for the generic template.
15
-     * @param string $name The name of the specialised template.
16
-     */
17
-    function espresso_get_template_part($slug = null, $name = null)
18
-    {
19
-        EEH_Template::get_template_part($slug, $name);
20
-    }
9
+	/**
10
+	 * espresso_get_template_part
11
+	 * 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
12
+	 * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
13
+	 *
14
+	 * @param string $slug The slug name for the generic template.
15
+	 * @param string $name The name of the specialised template.
16
+	 */
17
+	function espresso_get_template_part($slug = null, $name = null)
18
+	{
19
+		EEH_Template::get_template_part($slug, $name);
20
+	}
21 21
 }
22 22
 
23 23
 
24 24
 if (! function_exists('espresso_get_object_css_class')) {
25
-    /**
26
-     * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
27
-     *
28
-     * @param EE_Base_Class $object the EE object the css class is being generated for
29
-     * @param string        $prefix added to the beginning of the generated class
30
-     * @param string        $suffix added to the end of the generated class
31
-     * @return string
32
-     * @throws EE_Error
33
-     * @throws ReflectionException
34
-     */
35
-    function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
36
-    {
37
-        return EEH_Template::get_object_css_class($object, $prefix, $suffix);
38
-    }
25
+	/**
26
+	 * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
27
+	 *
28
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
29
+	 * @param string        $prefix added to the beginning of the generated class
30
+	 * @param string        $suffix added to the end of the generated class
31
+	 * @return string
32
+	 * @throws EE_Error
33
+	 * @throws ReflectionException
34
+	 */
35
+	function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
36
+	{
37
+		return EEH_Template::get_object_css_class($object, $prefix, $suffix);
38
+	}
39 39
 }
40 40
 
41 41
 
@@ -50,640 +50,640 @@  discard block
 block discarded – undo
50 50
 class EEH_Template
51 51
 {
52 52
 
53
-    private static $_espresso_themes = [];
54
-
55
-
56
-    /**
57
-     *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
58
-     *
59
-     * @return boolean
60
-     */
61
-    public static function is_espresso_theme()
62
-    {
63
-        return wp_get_theme()->get('TextDomain') === 'event_espresso';
64
-    }
65
-
66
-
67
-    /**
68
-     *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
69
-     *    load its functions.php file ( if not already loaded )
70
-     *
71
-     * @return void
72
-     */
73
-    public static function load_espresso_theme_functions()
74
-    {
75
-        if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
77
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
78
-            }
79
-        }
80
-    }
81
-
82
-
83
-    /**
84
-     *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
85
-     *
86
-     * @return array
87
-     */
88
-    public static function get_espresso_themes()
89
-    {
90
-        if (empty(EEH_Template::$_espresso_themes)) {
91
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
92
-            if (empty($espresso_themes)) {
93
-                return [];
94
-            }
95
-            if (($key = array_search('global_assets', $espresso_themes)) !== false) {
96
-                unset($espresso_themes[ $key ]);
97
-            }
98
-            EEH_Template::$_espresso_themes = [];
99
-            foreach ($espresso_themes as $espresso_theme) {
100
-                EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
101
-            }
102
-        }
103
-        return EEH_Template::$_espresso_themes;
104
-    }
105
-
106
-
107
-    /**
108
-     * EEH_Template::get_template_part
109
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
110
-     * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
111
-     * filtering based off of the entire template part name
112
-     *
113
-     * @param string $slug The slug name for the generic template.
114
-     * @param string $name The name of the specialised template.
115
-     * @param array  $template_args
116
-     * @param bool   $return_string
117
-     * @return string        the html output for the formatted money value
118
-     */
119
-    public static function get_template_part(
120
-        $slug = null,
121
-        $name = null,
122
-        $template_args = [],
123
-        $return_string = false
124
-    ) {
125
-        do_action("get_template_part_{$slug}-{$name}", $slug, $name);
126
-        $templates = [];
127
-        $name      = (string) $name;
128
-        if ($name != '') {
129
-            $templates[] = "{$slug}-{$name}.php";
130
-        }
131
-        // allow template parts to be turned off via something like:
132
-        // add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
133
-        if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
134
-            return EEH_Template::locate_template($templates, $template_args, true, $return_string);
135
-        }
136
-        return '';
137
-    }
138
-
139
-
140
-    /**
141
-     *    locate_template
142
-     *    locate a template file by looking in the following places, in the following order:
143
-     *        <server path up to>/wp-content/themes/<current active WordPress theme>/
144
-     *        <assumed full absolute server path>
145
-     *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
146
-     *        <server path up to>/wp-content/uploads/espresso/templates/
147
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
148
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
149
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/
150
-     *    as soon as the template is found in one of these locations, it will be returned or loaded
151
-     *        Example:
152
-     *          You are using the WordPress Twenty Sixteen theme,
153
-     *        and you want to customize the "some-event.template.php" template,
154
-     *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
155
-     *          Assuming WP is installed on your server in the "/home/public_html/" folder,
156
-     *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
157
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
158
-     *        /relative/path/to/some-event.template.php
159
-     *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
160
-     *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
161
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
162
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
163
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
164
-     *          Had you passed an absolute path to your template that was in some other location,
165
-     *        ie: "/absolute/path/to/some-event.template.php"
166
-     *          then the search would have been :
167
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
168
-     *        /absolute/path/to/some-event.template.php
169
-     *          and stopped there upon finding it in the second location
170
-     *
171
-     * @param array|string $templates       array of template file names including extension (or just a single string)
172
-     * @param array        $template_args   an array of arguments to be extracted for use in the template
173
-     * @param boolean      $load            whether to pass the located template path on to the
174
-     *                                      EEH_Template::display_template() method or simply return it
175
-     * @param boolean      $return_string   whether to send output immediately to screen, or capture and return as a
176
-     *                                      string
177
-     * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
178
-     *                                      generate a custom template or not. Used in places where you don't actually
179
-     *                                      load the template, you just want to know if there's a custom version of it.
180
-     * @return mixed
181
-     * @throws DomainException
182
-     * @throws InvalidArgumentException
183
-     * @throws InvalidDataTypeException
184
-     * @throws InvalidInterfaceException
185
-     */
186
-    public static function locate_template(
187
-        $templates = [],
188
-        $template_args = [],
189
-        $load = true,
190
-        $return_string = true,
191
-        $check_if_custom = false
192
-    ) {
193
-        // first use WP locate_template to check for template in the current theme folder
194
-        $template_path = locate_template($templates);
195
-
196
-        if ($check_if_custom && ! empty($template_path)) {
197
-            return true;
198
-        }
199
-
200
-        // not in the theme
201
-        if (empty($template_path)) {
202
-            // not even a template to look for ?
203
-            if (empty($templates)) {
204
-                $loader = LoaderFactory::getLoader();
205
-                /** @var RequestInterface $request */
206
-                $request = $loader->getShared(RequestInterface::class);
207
-                // get post_type
208
-                $post_type = $request->getRequestParam('post_type');
209
-                /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
210
-                $custom_post_types = $loader->getShared(
211
-                    'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
212
-                );
213
-                // get array of EE Custom Post Types
214
-                $EE_CPTs = $custom_post_types->getDefinitions();
215
-                // build template name based on request
216
-                if (isset($EE_CPTs[ $post_type ])) {
217
-                    $archive_or_single = is_archive() ? 'archive' : '';
218
-                    $archive_or_single = is_single() ? 'single' : $archive_or_single;
219
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
220
-                }
221
-            }
222
-            // currently active EE template theme
223
-            $current_theme = EE_Config::get_current_theme();
224
-
225
-            // array of paths to folders that may contain templates
226
-            $template_folder_paths = [
227
-                // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
228
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
229
-                // then in the root of the /wp-content/uploads/espresso/templates/ folder
230
-                EVENT_ESPRESSO_TEMPLATE_DIR,
231
-            ];
232
-
233
-            // add core plugin folders for checking only if we're not $check_if_custom
234
-            if (! $check_if_custom) {
235
-                $core_paths            = [
236
-                    // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
237
-                    EE_PUBLIC . $current_theme,
238
-                    // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
239
-                    EE_TEMPLATES . $current_theme,
240
-                    // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
241
-                    EE_PLUGIN_DIR_PATH,
242
-                ];
243
-                $template_folder_paths = array_merge($template_folder_paths, $core_paths);
244
-            }
245
-
246
-            // now filter that array
247
-            $template_folder_paths = apply_filters(
248
-                'FHEE__EEH_Template__locate_template__template_folder_paths',
249
-                $template_folder_paths
250
-            );
251
-            $templates             = is_array($templates) ? $templates : [$templates];
252
-            $template_folder_paths =
253
-                is_array($template_folder_paths) ? $template_folder_paths : [$template_folder_paths];
254
-            // array to hold all possible template paths
255
-            $full_template_paths = [];
256
-            $file_name           = '';
257
-
258
-            // loop through $templates
259
-            foreach ($templates as $template) {
260
-                // normalize directory separators
261
-                $template                      = EEH_File::standardise_directory_separators($template);
262
-                $file_name                     = basename($template);
263
-                $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
264
-                // while looping through all template folder paths
265
-                foreach ($template_folder_paths as $template_folder_path) {
266
-                    // normalize directory separators
267
-                    $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
268
-                    // determine if any common base path exists between the two paths
269
-                    $common_base_path = EEH_Template::_find_common_base_path(
270
-                        [$template_folder_path, $template_path_minus_file_name]
271
-                    );
272
-                    if ($common_base_path !== '') {
273
-                        // both paths have a common base, so just tack the filename onto our search path
274
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
275
-                    } else {
276
-                        // no common base path, so let's just concatenate
277
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
278
-                    }
279
-                    // build up our template locations array by adding our resolved paths
280
-                    $full_template_paths[] = $resolved_path;
281
-                }
282
-                // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
283
-                array_unshift($full_template_paths, $template);
284
-                // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
285
-                array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
286
-            }
287
-            // filter final array of full template paths
288
-            $full_template_paths = apply_filters(
289
-                'FHEE__EEH_Template__locate_template__full_template_paths',
290
-                $full_template_paths,
291
-                $file_name
292
-            );
293
-            // now loop through our final array of template location paths and check each location
294
-            foreach ((array) $full_template_paths as $full_template_path) {
295
-                if (is_readable($full_template_path)) {
296
-                    $template_path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $full_template_path);
297
-                    break;
298
-                }
299
-            }
300
-        }
301
-
302
-        // hook that can be used to display the full template path that will be used
303
-        do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
304
-
305
-        // if we got it and you want to see it...
306
-        if ($template_path && $load && ! $check_if_custom) {
307
-            if ($return_string) {
308
-                return EEH_Template::display_template($template_path, $template_args, true);
309
-            }
310
-            EEH_Template::display_template($template_path, $template_args);
311
-        }
312
-        return $check_if_custom && ! empty($template_path) ? true : $template_path;
313
-    }
314
-
315
-
316
-    /**
317
-     * _find_common_base_path
318
-     * given two paths, this determines if there is a common base path between the two
319
-     *
320
-     * @param array $paths
321
-     * @return string
322
-     */
323
-    protected static function _find_common_base_path($paths)
324
-    {
325
-        $last_offset      = 0;
326
-        $common_base_path = '';
327
-        while (($index = strpos($paths[0], '/', $last_offset)) !== false) {
328
-            $dir_length = $index - $last_offset + 1;
329
-            $directory  = substr($paths[0], $last_offset, $dir_length);
330
-            foreach ($paths as $path) {
331
-                if (substr($path, $last_offset, $dir_length) != $directory) {
332
-                    return $common_base_path;
333
-                }
334
-            }
335
-            $common_base_path .= $directory;
336
-            $last_offset      = $index + 1;
337
-        }
338
-        return substr($common_base_path, 0, -1);
339
-    }
340
-
341
-
342
-    /**
343
-     * load and display a template
344
-     *
345
-     * @param bool|string $template_path    server path to the file to be loaded, including file name and extension
346
-     * @param array       $template_args    an array of arguments to be extracted for use in the template
347
-     * @param boolean     $return_string    whether to send output immediately to screen, or capture and return as a
348
-     *                                      string
349
-     * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
350
-     *                                      not found or is not readable
351
-     * @return string
352
-     * @throws DomainException
353
-     */
354
-    public static function display_template(
355
-        $template_path = false,
356
-        $template_args = [],
357
-        $return_string = false,
358
-        $throw_exceptions = false
359
-    ) {
360
-
361
-        /**
362
-         * These two filters are intended for last minute changes to templates being loaded and/or template arg
363
-         * modifications.  NOTE... modifying these things can cause breakage as most templates running through
364
-         * the display_template method are templates we DON'T want modified (usually because of js
365
-         * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
366
-         * using this.
367
-         *
368
-         * @since 4.6.0
369
-         */
370
-        $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
371
-        $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
372
-
373
-        // you gimme nuttin - YOU GET NUTTIN !!
374
-        if (! $template_path || ! is_readable($template_path)) {
375
-            // ignore whether template is accessible ?
376
-            if ($throw_exceptions) {
377
-                throw new DomainException(
378
-                    esc_html__('Invalid, unreadable, or missing file.', 'event_espresso')
379
-                );
380
-            }
381
-            return '';
382
-        }
383
-        // if $template_args are not in an array, then make it so
384
-        if (! is_array($template_args) && ! is_object($template_args)) {
385
-            $template_args = [$template_args];
386
-        }
387
-        extract($template_args, EXTR_SKIP);
388
-
389
-        if ($return_string) {
390
-            // because we want to return a string, we are going to capture the output
391
-            ob_start();
392
-            include($template_path);
393
-            return ob_get_clean();
394
-        }
395
-        include($template_path);
396
-        return '';
397
-    }
398
-
399
-
400
-    /**
401
-     * get_object_css_class - attempts to generate a css class based on the type of EE object passed
402
-     *
403
-     * @param EE_Base_Class $object the EE object the css class is being generated for
404
-     * @param string        $prefix added to the beginning of the generated class
405
-     * @param string        $suffix added to the end of the generated class
406
-     * @return string
407
-     * @throws EE_Error
408
-     * @throws ReflectionException
409
-     */
410
-    public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
411
-    {
412
-        // in the beginning...
413
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
414
-        // da muddle
415
-        $class = '';
416
-        // the end
417
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
418
-        // is the passed object an EE object ?
419
-        if ($object instanceof EE_Base_Class) {
420
-            // grab the exact type of object
421
-            $obj_class = get_class($object);
422
-            // depending on the type of object...
423
-            switch ($obj_class) {
424
-                // no specifics just yet...
425
-                default:
426
-                    $class = strtolower(str_replace('_', '-', $obj_class));
427
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
428
-            }
429
-        }
430
-        return $prefix . $class . $suffix;
431
-    }
432
-
433
-
434
-    /**
435
-     * EEH_Template::format_currency
436
-     * This helper takes a raw float value and formats it according to the default config country currency settings, or
437
-     * the country currency settings from the supplied country ISO code
438
-     *
439
-     * @param float   $amount       raw money value
440
-     * @param boolean $return_raw   whether to return the formatted float value only with no currency sign or code
441
-     * @param boolean $display_code whether to display the country code (USD). Default = TRUE
442
-     * @param string  $CNT_ISO      2 letter ISO code for a country
443
-     * @param string  $cur_code_span_class
444
-     * @return string        the html output for the formatted money value
445
-     */
446
-    public static function format_currency(
447
-        $amount = null,
448
-        $return_raw = false,
449
-        $display_code = true,
450
-        $CNT_ISO = '',
451
-        $cur_code_span_class = 'currency-code'
452
-    ) {
453
-        // ensure amount was received
454
-        if ($amount === null) {
455
-            $msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso');
456
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
457
-            return '';
458
-        }
459
-        // ensure amount is float
460
-        $amount  = (float) apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
461
-        $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
462
-        // filter raw amount (allows 0.00 to be changed to "free" for example)
463
-        $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
464
-        // still a number, or was amount converted to a string like "free" ?
465
-        if (! is_float($amount_formatted)) {
466
-            return esc_html($amount_formatted);
467
-        }
468
-        try {
469
-            // was a country ISO code passed ? if so generate currency config object for that country
470
-            $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
471
-        } catch (Exception $e) {
472
-            // eat exception
473
-            $mny = null;
474
-        }
475
-        // verify results
476
-        if (! $mny instanceof EE_Currency_Config) {
477
-            // set default config country currency settings
478
-            $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
479
-                ? EE_Registry::instance()->CFG->currency
480
-                : new EE_Currency_Config();
481
-        }
482
-        // format float
483
-        $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
484
-        // add formatting ?
485
-        if (! $return_raw) {
486
-            // add currency sign
487
-            if ($mny->sign_b4) {
488
-                if ($amount >= 0) {
489
-                    $amount_formatted = $mny->sign . $amount_formatted;
490
-                } else {
491
-                    $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
492
-                }
493
-            } else {
494
-                $amount_formatted = $amount_formatted . $mny->sign;
495
-            }
496
-
497
-            // filter to allow global setting of display_code
498
-            $display_code = (bool) apply_filters(
499
-                'FHEE__EEH_Template__format_currency__display_code',
500
-                $display_code
501
-            );
502
-
503
-            // add currency code ?
504
-            $amount_formatted = $display_code
505
-                ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
506
-                : $amount_formatted;
507
-        }
508
-        // filter results
509
-        $amount_formatted = apply_filters(
510
-            'FHEE__EEH_Template__format_currency__amount_formatted',
511
-            $amount_formatted,
512
-            $mny,
513
-            $return_raw
514
-        );
515
-        // clean up vars
516
-        unset($mny);
517
-        // return formatted currency amount
518
-        return $amount_formatted;
519
-    }
520
-
521
-
522
-    /**
523
-     * This function is used for outputting the localized label for a given status id in the schema requested (and
524
-     * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
525
-     * related status model or model object (i.e. in documentation etc.)
526
-     *
527
-     * @param string  $status_id  Status ID matching a registered status in the esp_status table.  If there is no
528
-     *                            match, then 'Unknown' will be returned.
529
-     * @param boolean $plural     Whether to return plural or not
530
-     * @param string  $schema     'UPPER', 'lower', or 'Sentence'
531
-     * @return string             The localized label for the status id.
532
-     * @throws EE_Error
533
-     */
534
-    public static function pretty_status($status_id, $plural = false, $schema = 'upper')
535
-    {
536
-        $status = EEM_Status::instance()->localized_status(
537
-            [$status_id => esc_html__('unknown', 'event_espresso')],
538
-            $plural,
539
-            $schema
540
-        );
541
-        return $status[ $status_id ];
542
-    }
543
-
544
-
545
-    /**
546
-     * This helper just returns a button or link for the given parameters
547
-     *
548
-     * @param string $url   the url for the link, note that `esc_url` will be called on it
549
-     * @param string $label What is the label you want displayed for the button
550
-     * @param string $class what class is used for the button (defaults to 'button-primary')
551
-     * @param string $icon
552
-     * @param string $title
553
-     * @return string the html output for the button
554
-     */
555
-    public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
556
-    {
557
-        $icon_html = '';
558
-        if (! empty($icon)) {
559
-            $dashicons = preg_split("(ee-icon |dashicons )", $icon);
560
-            $dashicons = array_filter($dashicons);
561
-            $count     = count($dashicons);
562
-            $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
563
-            foreach ($dashicons as $dashicon) {
564
-                $type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
566
-            }
567
-            $icon_html .= $count > 1 ? '</span>' : '';
568
-        }
569
-        // sanitize & escape
570
-        $id    = sanitize_title_with_dashes($label);
571
-        $url   = esc_url_raw($url);
572
-        $class = esc_attr($class);
573
-        $title = esc_attr($title);
574
-        $label = esc_html($label);
575
-        return "<a id='{$id}' href='{$url}' class='{$class}' title='{$title}'>{$icon_html}{$label}</a>";
576
-    }
577
-
578
-
579
-    /**
580
-     * This returns a generated link that will load the related help tab on admin pages.
581
-     *
582
-     * @param string      $help_tab_id the id for the connected help tab
583
-     * @param bool|string $page        The page identifier for the page the help tab is on
584
-     * @param bool|string $action      The action (route) for the admin page the help tab is on.
585
-     * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
586
-     * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
587
-     * @return string              generated link
588
-     */
589
-    public static function get_help_tab_link(
590
-        $help_tab_id,
591
-        $page = false,
592
-        $action = false,
593
-        $icon_style = false,
594
-        $help_text = false
595
-    ) {
596
-        global $allowedtags;
597
-        /** @var RequestInterface $request */
598
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
599
-        $page    = $page ?: $request->getRequestParam('page', '', 'key');
600
-        $action  = $action ?: $request->getRequestParam('action', 'default', 'key');
601
-
602
-
603
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
604
-        $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
605
-        $help_text    = ! $help_text ? '' : $help_text;
606
-        return '<a id="'
607
-               . esc_attr($help_tab_lnk)
608
-               . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'
609
-               . esc_attr($icon)
610
-               . '" title="'
611
-               . esc_attr__(
612
-                   'Click to open the \'Help\' tab for more information about this feature.',
613
-                   'event_espresso'
614
-               )
615
-               . '" > '
616
-               . wp_kses($help_text, $allowedtags)
617
-               . ' </a>';
618
-    }
619
-
620
-
621
-    /**
622
-     * This is a helper method to generate a status legend for a given status array.
623
-     * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
624
-     * status_array.
625
-     *
626
-     * @param array  $status_array   array of statuses that will make up the legend. In format:
627
-     *                               array(
628
-     *                               'status_item' => 'status_name'
629
-     *                               )
630
-     * @param string $active_status  This is used to indicate what the active status is IF that is to be highlighted in
631
-     *                               the legend.
632
-     * @return string               html structure for status.
633
-     * @throws EE_Error
634
-     */
635
-    public static function status_legend($status_array, $active_status = '')
636
-    {
637
-        if (! is_array($status_array)) {
638
-            throw new EE_Error(
639
-                esc_html__(
640
-                    'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
641
-                    'event_espresso'
642
-                )
643
-            );
644
-        }
645
-
646
-        $content = '
53
+	private static $_espresso_themes = [];
54
+
55
+
56
+	/**
57
+	 *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
58
+	 *
59
+	 * @return boolean
60
+	 */
61
+	public static function is_espresso_theme()
62
+	{
63
+		return wp_get_theme()->get('TextDomain') === 'event_espresso';
64
+	}
65
+
66
+
67
+	/**
68
+	 *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
69
+	 *    load its functions.php file ( if not already loaded )
70
+	 *
71
+	 * @return void
72
+	 */
73
+	public static function load_espresso_theme_functions()
74
+	{
75
+		if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
+			if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
77
+				require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
78
+			}
79
+		}
80
+	}
81
+
82
+
83
+	/**
84
+	 *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
85
+	 *
86
+	 * @return array
87
+	 */
88
+	public static function get_espresso_themes()
89
+	{
90
+		if (empty(EEH_Template::$_espresso_themes)) {
91
+			$espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
92
+			if (empty($espresso_themes)) {
93
+				return [];
94
+			}
95
+			if (($key = array_search('global_assets', $espresso_themes)) !== false) {
96
+				unset($espresso_themes[ $key ]);
97
+			}
98
+			EEH_Template::$_espresso_themes = [];
99
+			foreach ($espresso_themes as $espresso_theme) {
100
+				EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
101
+			}
102
+		}
103
+		return EEH_Template::$_espresso_themes;
104
+	}
105
+
106
+
107
+	/**
108
+	 * EEH_Template::get_template_part
109
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
110
+	 * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
111
+	 * filtering based off of the entire template part name
112
+	 *
113
+	 * @param string $slug The slug name for the generic template.
114
+	 * @param string $name The name of the specialised template.
115
+	 * @param array  $template_args
116
+	 * @param bool   $return_string
117
+	 * @return string        the html output for the formatted money value
118
+	 */
119
+	public static function get_template_part(
120
+		$slug = null,
121
+		$name = null,
122
+		$template_args = [],
123
+		$return_string = false
124
+	) {
125
+		do_action("get_template_part_{$slug}-{$name}", $slug, $name);
126
+		$templates = [];
127
+		$name      = (string) $name;
128
+		if ($name != '') {
129
+			$templates[] = "{$slug}-{$name}.php";
130
+		}
131
+		// allow template parts to be turned off via something like:
132
+		// add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
133
+		if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
134
+			return EEH_Template::locate_template($templates, $template_args, true, $return_string);
135
+		}
136
+		return '';
137
+	}
138
+
139
+
140
+	/**
141
+	 *    locate_template
142
+	 *    locate a template file by looking in the following places, in the following order:
143
+	 *        <server path up to>/wp-content/themes/<current active WordPress theme>/
144
+	 *        <assumed full absolute server path>
145
+	 *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
146
+	 *        <server path up to>/wp-content/uploads/espresso/templates/
147
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
148
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
149
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/
150
+	 *    as soon as the template is found in one of these locations, it will be returned or loaded
151
+	 *        Example:
152
+	 *          You are using the WordPress Twenty Sixteen theme,
153
+	 *        and you want to customize the "some-event.template.php" template,
154
+	 *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
155
+	 *          Assuming WP is installed on your server in the "/home/public_html/" folder,
156
+	 *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
157
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
158
+	 *        /relative/path/to/some-event.template.php
159
+	 *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
160
+	 *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
161
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
162
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
163
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
164
+	 *          Had you passed an absolute path to your template that was in some other location,
165
+	 *        ie: "/absolute/path/to/some-event.template.php"
166
+	 *          then the search would have been :
167
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
168
+	 *        /absolute/path/to/some-event.template.php
169
+	 *          and stopped there upon finding it in the second location
170
+	 *
171
+	 * @param array|string $templates       array of template file names including extension (or just a single string)
172
+	 * @param array        $template_args   an array of arguments to be extracted for use in the template
173
+	 * @param boolean      $load            whether to pass the located template path on to the
174
+	 *                                      EEH_Template::display_template() method or simply return it
175
+	 * @param boolean      $return_string   whether to send output immediately to screen, or capture and return as a
176
+	 *                                      string
177
+	 * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
178
+	 *                                      generate a custom template or not. Used in places where you don't actually
179
+	 *                                      load the template, you just want to know if there's a custom version of it.
180
+	 * @return mixed
181
+	 * @throws DomainException
182
+	 * @throws InvalidArgumentException
183
+	 * @throws InvalidDataTypeException
184
+	 * @throws InvalidInterfaceException
185
+	 */
186
+	public static function locate_template(
187
+		$templates = [],
188
+		$template_args = [],
189
+		$load = true,
190
+		$return_string = true,
191
+		$check_if_custom = false
192
+	) {
193
+		// first use WP locate_template to check for template in the current theme folder
194
+		$template_path = locate_template($templates);
195
+
196
+		if ($check_if_custom && ! empty($template_path)) {
197
+			return true;
198
+		}
199
+
200
+		// not in the theme
201
+		if (empty($template_path)) {
202
+			// not even a template to look for ?
203
+			if (empty($templates)) {
204
+				$loader = LoaderFactory::getLoader();
205
+				/** @var RequestInterface $request */
206
+				$request = $loader->getShared(RequestInterface::class);
207
+				// get post_type
208
+				$post_type = $request->getRequestParam('post_type');
209
+				/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
210
+				$custom_post_types = $loader->getShared(
211
+					'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
212
+				);
213
+				// get array of EE Custom Post Types
214
+				$EE_CPTs = $custom_post_types->getDefinitions();
215
+				// build template name based on request
216
+				if (isset($EE_CPTs[ $post_type ])) {
217
+					$archive_or_single = is_archive() ? 'archive' : '';
218
+					$archive_or_single = is_single() ? 'single' : $archive_or_single;
219
+					$templates         = $archive_or_single . '-' . $post_type . '.php';
220
+				}
221
+			}
222
+			// currently active EE template theme
223
+			$current_theme = EE_Config::get_current_theme();
224
+
225
+			// array of paths to folders that may contain templates
226
+			$template_folder_paths = [
227
+				// first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
228
+				EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
229
+				// then in the root of the /wp-content/uploads/espresso/templates/ folder
230
+				EVENT_ESPRESSO_TEMPLATE_DIR,
231
+			];
232
+
233
+			// add core plugin folders for checking only if we're not $check_if_custom
234
+			if (! $check_if_custom) {
235
+				$core_paths            = [
236
+					// in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
237
+					EE_PUBLIC . $current_theme,
238
+					// in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
239
+					EE_TEMPLATES . $current_theme,
240
+					// or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
241
+					EE_PLUGIN_DIR_PATH,
242
+				];
243
+				$template_folder_paths = array_merge($template_folder_paths, $core_paths);
244
+			}
245
+
246
+			// now filter that array
247
+			$template_folder_paths = apply_filters(
248
+				'FHEE__EEH_Template__locate_template__template_folder_paths',
249
+				$template_folder_paths
250
+			);
251
+			$templates             = is_array($templates) ? $templates : [$templates];
252
+			$template_folder_paths =
253
+				is_array($template_folder_paths) ? $template_folder_paths : [$template_folder_paths];
254
+			// array to hold all possible template paths
255
+			$full_template_paths = [];
256
+			$file_name           = '';
257
+
258
+			// loop through $templates
259
+			foreach ($templates as $template) {
260
+				// normalize directory separators
261
+				$template                      = EEH_File::standardise_directory_separators($template);
262
+				$file_name                     = basename($template);
263
+				$template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
264
+				// while looping through all template folder paths
265
+				foreach ($template_folder_paths as $template_folder_path) {
266
+					// normalize directory separators
267
+					$template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
268
+					// determine if any common base path exists between the two paths
269
+					$common_base_path = EEH_Template::_find_common_base_path(
270
+						[$template_folder_path, $template_path_minus_file_name]
271
+					);
272
+					if ($common_base_path !== '') {
273
+						// both paths have a common base, so just tack the filename onto our search path
274
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
275
+					} else {
276
+						// no common base path, so let's just concatenate
277
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
278
+					}
279
+					// build up our template locations array by adding our resolved paths
280
+					$full_template_paths[] = $resolved_path;
281
+				}
282
+				// if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
283
+				array_unshift($full_template_paths, $template);
284
+				// path to the directory of the current theme: /wp-content/themes/(current WP theme)/
285
+				array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
286
+			}
287
+			// filter final array of full template paths
288
+			$full_template_paths = apply_filters(
289
+				'FHEE__EEH_Template__locate_template__full_template_paths',
290
+				$full_template_paths,
291
+				$file_name
292
+			);
293
+			// now loop through our final array of template location paths and check each location
294
+			foreach ((array) $full_template_paths as $full_template_path) {
295
+				if (is_readable($full_template_path)) {
296
+					$template_path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $full_template_path);
297
+					break;
298
+				}
299
+			}
300
+		}
301
+
302
+		// hook that can be used to display the full template path that will be used
303
+		do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
304
+
305
+		// if we got it and you want to see it...
306
+		if ($template_path && $load && ! $check_if_custom) {
307
+			if ($return_string) {
308
+				return EEH_Template::display_template($template_path, $template_args, true);
309
+			}
310
+			EEH_Template::display_template($template_path, $template_args);
311
+		}
312
+		return $check_if_custom && ! empty($template_path) ? true : $template_path;
313
+	}
314
+
315
+
316
+	/**
317
+	 * _find_common_base_path
318
+	 * given two paths, this determines if there is a common base path between the two
319
+	 *
320
+	 * @param array $paths
321
+	 * @return string
322
+	 */
323
+	protected static function _find_common_base_path($paths)
324
+	{
325
+		$last_offset      = 0;
326
+		$common_base_path = '';
327
+		while (($index = strpos($paths[0], '/', $last_offset)) !== false) {
328
+			$dir_length = $index - $last_offset + 1;
329
+			$directory  = substr($paths[0], $last_offset, $dir_length);
330
+			foreach ($paths as $path) {
331
+				if (substr($path, $last_offset, $dir_length) != $directory) {
332
+					return $common_base_path;
333
+				}
334
+			}
335
+			$common_base_path .= $directory;
336
+			$last_offset      = $index + 1;
337
+		}
338
+		return substr($common_base_path, 0, -1);
339
+	}
340
+
341
+
342
+	/**
343
+	 * load and display a template
344
+	 *
345
+	 * @param bool|string $template_path    server path to the file to be loaded, including file name and extension
346
+	 * @param array       $template_args    an array of arguments to be extracted for use in the template
347
+	 * @param boolean     $return_string    whether to send output immediately to screen, or capture and return as a
348
+	 *                                      string
349
+	 * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
350
+	 *                                      not found or is not readable
351
+	 * @return string
352
+	 * @throws DomainException
353
+	 */
354
+	public static function display_template(
355
+		$template_path = false,
356
+		$template_args = [],
357
+		$return_string = false,
358
+		$throw_exceptions = false
359
+	) {
360
+
361
+		/**
362
+		 * These two filters are intended for last minute changes to templates being loaded and/or template arg
363
+		 * modifications.  NOTE... modifying these things can cause breakage as most templates running through
364
+		 * the display_template method are templates we DON'T want modified (usually because of js
365
+		 * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
366
+		 * using this.
367
+		 *
368
+		 * @since 4.6.0
369
+		 */
370
+		$template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
371
+		$template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
372
+
373
+		// you gimme nuttin - YOU GET NUTTIN !!
374
+		if (! $template_path || ! is_readable($template_path)) {
375
+			// ignore whether template is accessible ?
376
+			if ($throw_exceptions) {
377
+				throw new DomainException(
378
+					esc_html__('Invalid, unreadable, or missing file.', 'event_espresso')
379
+				);
380
+			}
381
+			return '';
382
+		}
383
+		// if $template_args are not in an array, then make it so
384
+		if (! is_array($template_args) && ! is_object($template_args)) {
385
+			$template_args = [$template_args];
386
+		}
387
+		extract($template_args, EXTR_SKIP);
388
+
389
+		if ($return_string) {
390
+			// because we want to return a string, we are going to capture the output
391
+			ob_start();
392
+			include($template_path);
393
+			return ob_get_clean();
394
+		}
395
+		include($template_path);
396
+		return '';
397
+	}
398
+
399
+
400
+	/**
401
+	 * get_object_css_class - attempts to generate a css class based on the type of EE object passed
402
+	 *
403
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
404
+	 * @param string        $prefix added to the beginning of the generated class
405
+	 * @param string        $suffix added to the end of the generated class
406
+	 * @return string
407
+	 * @throws EE_Error
408
+	 * @throws ReflectionException
409
+	 */
410
+	public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
411
+	{
412
+		// in the beginning...
413
+		$prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
414
+		// da muddle
415
+		$class = '';
416
+		// the end
417
+		$suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
418
+		// is the passed object an EE object ?
419
+		if ($object instanceof EE_Base_Class) {
420
+			// grab the exact type of object
421
+			$obj_class = get_class($object);
422
+			// depending on the type of object...
423
+			switch ($obj_class) {
424
+				// no specifics just yet...
425
+				default:
426
+					$class = strtolower(str_replace('_', '-', $obj_class));
427
+					$class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
428
+			}
429
+		}
430
+		return $prefix . $class . $suffix;
431
+	}
432
+
433
+
434
+	/**
435
+	 * EEH_Template::format_currency
436
+	 * This helper takes a raw float value and formats it according to the default config country currency settings, or
437
+	 * the country currency settings from the supplied country ISO code
438
+	 *
439
+	 * @param float   $amount       raw money value
440
+	 * @param boolean $return_raw   whether to return the formatted float value only with no currency sign or code
441
+	 * @param boolean $display_code whether to display the country code (USD). Default = TRUE
442
+	 * @param string  $CNT_ISO      2 letter ISO code for a country
443
+	 * @param string  $cur_code_span_class
444
+	 * @return string        the html output for the formatted money value
445
+	 */
446
+	public static function format_currency(
447
+		$amount = null,
448
+		$return_raw = false,
449
+		$display_code = true,
450
+		$CNT_ISO = '',
451
+		$cur_code_span_class = 'currency-code'
452
+	) {
453
+		// ensure amount was received
454
+		if ($amount === null) {
455
+			$msg = esc_html__('In order to format currency, an amount needs to be passed.', 'event_espresso');
456
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
457
+			return '';
458
+		}
459
+		// ensure amount is float
460
+		$amount  = (float) apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
461
+		$CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
462
+		// filter raw amount (allows 0.00 to be changed to "free" for example)
463
+		$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
464
+		// still a number, or was amount converted to a string like "free" ?
465
+		if (! is_float($amount_formatted)) {
466
+			return esc_html($amount_formatted);
467
+		}
468
+		try {
469
+			// was a country ISO code passed ? if so generate currency config object for that country
470
+			$mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
471
+		} catch (Exception $e) {
472
+			// eat exception
473
+			$mny = null;
474
+		}
475
+		// verify results
476
+		if (! $mny instanceof EE_Currency_Config) {
477
+			// set default config country currency settings
478
+			$mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
479
+				? EE_Registry::instance()->CFG->currency
480
+				: new EE_Currency_Config();
481
+		}
482
+		// format float
483
+		$amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
484
+		// add formatting ?
485
+		if (! $return_raw) {
486
+			// add currency sign
487
+			if ($mny->sign_b4) {
488
+				if ($amount >= 0) {
489
+					$amount_formatted = $mny->sign . $amount_formatted;
490
+				} else {
491
+					$amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
492
+				}
493
+			} else {
494
+				$amount_formatted = $amount_formatted . $mny->sign;
495
+			}
496
+
497
+			// filter to allow global setting of display_code
498
+			$display_code = (bool) apply_filters(
499
+				'FHEE__EEH_Template__format_currency__display_code',
500
+				$display_code
501
+			);
502
+
503
+			// add currency code ?
504
+			$amount_formatted = $display_code
505
+				? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
506
+				: $amount_formatted;
507
+		}
508
+		// filter results
509
+		$amount_formatted = apply_filters(
510
+			'FHEE__EEH_Template__format_currency__amount_formatted',
511
+			$amount_formatted,
512
+			$mny,
513
+			$return_raw
514
+		);
515
+		// clean up vars
516
+		unset($mny);
517
+		// return formatted currency amount
518
+		return $amount_formatted;
519
+	}
520
+
521
+
522
+	/**
523
+	 * This function is used for outputting the localized label for a given status id in the schema requested (and
524
+	 * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
525
+	 * related status model or model object (i.e. in documentation etc.)
526
+	 *
527
+	 * @param string  $status_id  Status ID matching a registered status in the esp_status table.  If there is no
528
+	 *                            match, then 'Unknown' will be returned.
529
+	 * @param boolean $plural     Whether to return plural or not
530
+	 * @param string  $schema     'UPPER', 'lower', or 'Sentence'
531
+	 * @return string             The localized label for the status id.
532
+	 * @throws EE_Error
533
+	 */
534
+	public static function pretty_status($status_id, $plural = false, $schema = 'upper')
535
+	{
536
+		$status = EEM_Status::instance()->localized_status(
537
+			[$status_id => esc_html__('unknown', 'event_espresso')],
538
+			$plural,
539
+			$schema
540
+		);
541
+		return $status[ $status_id ];
542
+	}
543
+
544
+
545
+	/**
546
+	 * This helper just returns a button or link for the given parameters
547
+	 *
548
+	 * @param string $url   the url for the link, note that `esc_url` will be called on it
549
+	 * @param string $label What is the label you want displayed for the button
550
+	 * @param string $class what class is used for the button (defaults to 'button-primary')
551
+	 * @param string $icon
552
+	 * @param string $title
553
+	 * @return string the html output for the button
554
+	 */
555
+	public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
556
+	{
557
+		$icon_html = '';
558
+		if (! empty($icon)) {
559
+			$dashicons = preg_split("(ee-icon |dashicons )", $icon);
560
+			$dashicons = array_filter($dashicons);
561
+			$count     = count($dashicons);
562
+			$icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
563
+			foreach ($dashicons as $dashicon) {
564
+				$type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
+				$icon_html .= '<span class="' . $type . $dashicon . '"></span>';
566
+			}
567
+			$icon_html .= $count > 1 ? '</span>' : '';
568
+		}
569
+		// sanitize & escape
570
+		$id    = sanitize_title_with_dashes($label);
571
+		$url   = esc_url_raw($url);
572
+		$class = esc_attr($class);
573
+		$title = esc_attr($title);
574
+		$label = esc_html($label);
575
+		return "<a id='{$id}' href='{$url}' class='{$class}' title='{$title}'>{$icon_html}{$label}</a>";
576
+	}
577
+
578
+
579
+	/**
580
+	 * This returns a generated link that will load the related help tab on admin pages.
581
+	 *
582
+	 * @param string      $help_tab_id the id for the connected help tab
583
+	 * @param bool|string $page        The page identifier for the page the help tab is on
584
+	 * @param bool|string $action      The action (route) for the admin page the help tab is on.
585
+	 * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
586
+	 * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
587
+	 * @return string              generated link
588
+	 */
589
+	public static function get_help_tab_link(
590
+		$help_tab_id,
591
+		$page = false,
592
+		$action = false,
593
+		$icon_style = false,
594
+		$help_text = false
595
+	) {
596
+		global $allowedtags;
597
+		/** @var RequestInterface $request */
598
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
599
+		$page    = $page ?: $request->getRequestParam('page', '', 'key');
600
+		$action  = $action ?: $request->getRequestParam('action', 'default', 'key');
601
+
602
+
603
+		$help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
604
+		$icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
605
+		$help_text    = ! $help_text ? '' : $help_text;
606
+		return '<a id="'
607
+			   . esc_attr($help_tab_lnk)
608
+			   . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'
609
+			   . esc_attr($icon)
610
+			   . '" title="'
611
+			   . esc_attr__(
612
+				   'Click to open the \'Help\' tab for more information about this feature.',
613
+				   'event_espresso'
614
+			   )
615
+			   . '" > '
616
+			   . wp_kses($help_text, $allowedtags)
617
+			   . ' </a>';
618
+	}
619
+
620
+
621
+	/**
622
+	 * This is a helper method to generate a status legend for a given status array.
623
+	 * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
624
+	 * status_array.
625
+	 *
626
+	 * @param array  $status_array   array of statuses that will make up the legend. In format:
627
+	 *                               array(
628
+	 *                               'status_item' => 'status_name'
629
+	 *                               )
630
+	 * @param string $active_status  This is used to indicate what the active status is IF that is to be highlighted in
631
+	 *                               the legend.
632
+	 * @return string               html structure for status.
633
+	 * @throws EE_Error
634
+	 */
635
+	public static function status_legend($status_array, $active_status = '')
636
+	{
637
+		if (! is_array($status_array)) {
638
+			throw new EE_Error(
639
+				esc_html__(
640
+					'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
641
+					'event_espresso'
642
+				)
643
+			);
644
+		}
645
+
646
+		$content = '
647 647
             <div class="ee-list-table-legend-container">
648 648
                 <h4 class="status-legend-title">
649 649
                     ' . esc_html__('Status Legend', 'event_espresso') . '
650 650
                 </h4>
651 651
                 <dl class="ee-list-table-legend">';
652 652
 
653
-        foreach ($status_array as $item => $status) {
654
-            $active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
655
-            $content      .= '
653
+		foreach ($status_array as $item => $status) {
654
+			$active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
655
+			$content      .= '
656 656
                     <dt id="' . esc_attr('ee-legend-item-tooltip-' . $item) . '" ' . $active_class . '>
657 657
                         <span class="' . esc_attr('ee-status-legend ee-status-legend-' . $status) . '"></span>
658 658
                         <span class="ee-legend-description">
659 659
                             ' . EEH_Template::pretty_status($status, false, 'sentence') . '
660 660
                         </span>
661 661
                     </dt>';
662
-        }
662
+		}
663 663
 
664
-        $content .= '
664
+		$content .= '
665 665
                 </dl>
666 666
             </div>
667 667
 ';
668
-        return $content;
669
-    }
670
-
671
-
672
-    /**
673
-     * Gets HTML for laying out a deeply-nested array (and objects) in a format
674
-     * that's nice for presenting in the wp admin
675
-     *
676
-     * @param mixed $data
677
-     * @return string
678
-     */
679
-    public static function layout_array_as_table($data)
680
-    {
681
-        if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
682
-            $data = (array) $data;
683
-        }
684
-        ob_start();
685
-        if (is_array($data)) {
686
-            if (EEH_Array::is_associative_array($data)) { ?>
668
+		return $content;
669
+	}
670
+
671
+
672
+	/**
673
+	 * Gets HTML for laying out a deeply-nested array (and objects) in a format
674
+	 * that's nice for presenting in the wp admin
675
+	 *
676
+	 * @param mixed $data
677
+	 * @return string
678
+	 */
679
+	public static function layout_array_as_table($data)
680
+	{
681
+		if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
682
+			$data = (array) $data;
683
+		}
684
+		ob_start();
685
+		if (is_array($data)) {
686
+			if (EEH_Array::is_associative_array($data)) { ?>
687 687
                 <table class="widefat">
688 688
                     <tbody>
689 689
                     <?php foreach ($data as $data_key => $data_values) { ?>
@@ -701,292 +701,292 @@  discard block
 block discarded – undo
701 701
             <?php } else { ?>
702 702
                 <ul>
703 703
                     <?php
704
-                    foreach ($data as $datum) {
705
-                        echo "<li>";
706
-                        echo self::layout_array_as_table($datum);
707
-                        echo "</li>";
708
-                    } ?>
704
+					foreach ($data as $datum) {
705
+						echo "<li>";
706
+						echo self::layout_array_as_table($datum);
707
+						echo "</li>";
708
+					} ?>
709 709
                 </ul>
710 710
             <?php }
711
-        } else {
712
-            // simple value
713
-            echo esc_html($data);
714
-        }
715
-        return ob_get_clean();
716
-    }
717
-
718
-
719
-    /**
720
-     * wrapper for self::get_paging_html() that simply echos the generated paging html
721
-     *
722
-     * @param        $total_items
723
-     * @param        $current
724
-     * @param        $per_page
725
-     * @param        $url
726
-     * @param bool   $show_num_field
727
-     * @param string $paged_arg_name
728
-     * @param array  $items_label
729
-     * @see   self:get_paging_html() for argument docs.
730
-     * @since 4.4.0
731
-     */
732
-    public static function paging_html(
733
-        $total_items,
734
-        $current,
735
-        $per_page,
736
-        $url,
737
-        $show_num_field = true,
738
-        $paged_arg_name = 'paged',
739
-        $items_label = []
740
-    ) {
741
-        echo self::get_paging_html(
742
-            $total_items,
743
-            $current,
744
-            $per_page,
745
-            $url,
746
-            $show_num_field,
747
-            $paged_arg_name,
748
-            $items_label
749
-        );
750
-    }
751
-
752
-
753
-    /**
754
-     * A method for generating paging similar to WP_List_Table
755
-     *
756
-     * @param integer $total_items      How many total items there are to page.
757
-     * @param integer $current          What the current page is.
758
-     * @param integer $per_page         How many items per page.
759
-     * @param string  $url              What the base url for page links is.
760
-     * @param boolean $show_num_field   Whether to show the input for changing page number.
761
-     * @param string  $paged_arg_name   The name of the key for the paged query argument.
762
-     * @param array   $items_label      An array of singular/plural values for the items label:
763
-     *                                  array(
764
-     *                                  'single' => 'item',
765
-     *                                  'plural' => 'items'
766
-     *                                  )
767
-     * @return  string
768
-     * @since    4.4.0
769
-     * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
770
-     */
771
-    public static function get_paging_html(
772
-        $total_items,
773
-        $current,
774
-        $per_page,
775
-        $url,
776
-        $show_num_field = true,
777
-        $paged_arg_name = 'paged',
778
-        $items_label = []
779
-    ) {
780
-        $page_links     = [];
781
-        $disable_first  = $disable_last = '';
782
-        $total_items    = (int) $total_items;
783
-        $per_page       = (int) $per_page;
784
-        $current        = (int) $current;
785
-        $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
786
-
787
-        // filter items_label
788
-        $items_label = apply_filters(
789
-            'FHEE__EEH_Template__get_paging_html__items_label',
790
-            $items_label
791
-        );
792
-
793
-        if (
794
-            empty($items_label)
795
-            || ! is_array($items_label)
796
-            || ! isset($items_label['single'])
797
-            || ! isset($items_label['plural'])
798
-        ) {
799
-            $items_label = [
800
-                'single' => esc_html__('1 item', 'event_espresso'),
801
-                'plural' => esc_html__('%s items', 'event_espresso'),
802
-            ];
803
-        } else {
804
-            $items_label = [
805
-                'single' => '1 ' . esc_html($items_label['single']),
806
-                'plural' => '%s ' . esc_html($items_label['plural']),
807
-            ];
808
-        }
809
-
810
-        $total_pages = ceil($total_items / $per_page);
811
-
812
-        if ($total_pages <= 1) {
813
-            return '';
814
-        }
815
-
816
-        $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
817
-
818
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
819
-
820
-        if ($current === 1) {
821
-            $disable_first = ' disabled';
822
-        }
823
-        if ($current == $total_pages) {
824
-            $disable_last = ' disabled';
825
-        }
826
-
827
-        $page_links[] = sprintf(
828
-            "<a class='%s' title='%s' href='%s'>%s</a>",
829
-            'first-page' . $disable_first,
830
-            esc_attr__('Go to the first page', 'event_espresso'),
831
-            esc_url_raw(remove_query_arg($paged_arg_name, $url)),
832
-            '&laquo;'
833
-        );
834
-
835
-        $page_links[] = sprintf(
836
-            '<a class="%s" title="%s" href="%s">%s</a>',
837
-            'prev-page' . $disable_first,
838
-            esc_attr__('Go to the previous page', 'event_espresso'),
839
-            esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
840
-            '&lsaquo;'
841
-        );
842
-
843
-        if (! $show_num_field) {
844
-            $html_current_page = $current;
845
-        } else {
846
-            $html_current_page = sprintf(
847
-                "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
848
-                esc_attr__('Current page', 'event_espresso'),
849
-                esc_attr($current),
850
-                strlen($total_pages)
851
-            );
852
-        }
853
-
854
-        $html_total_pages = sprintf(
855
-            '<span class="total-pages">%s</span>',
856
-            number_format_i18n($total_pages)
857
-        );
858
-        $page_links[]     = sprintf(
859
-            _x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
860
-            $html_current_page,
861
-            $html_total_pages,
862
-            '<span class="paging-input">',
863
-            '</span>'
864
-        );
865
-
866
-        $page_links[] = sprintf(
867
-            '<a class="%s" title="%s" href="%s">%s</a>',
868
-            'next-page' . $disable_last,
869
-            esc_attr__('Go to the next page', 'event_espresso'),
870
-            esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
871
-            '&rsaquo;'
872
-        );
873
-
874
-        $page_links[] = sprintf(
875
-            '<a class="%s" title="%s" href="%s">%s</a>',
876
-            'last-page' . $disable_last,
877
-            esc_attr__('Go to the last page', 'event_espresso'),
878
-            esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
879
-            '&raquo;'
880
-        );
881
-
882
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
883
-        // set page class
884
-        if ($total_pages) {
885
-            $page_class = $total_pages < 2 ? ' one-page' : '';
886
-        } else {
887
-            $page_class = ' no-pages';
888
-        }
889
-
890
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
891
-    }
892
-
893
-
894
-    /**
895
-     * @param string $wrap_class
896
-     * @param string $wrap_id
897
-     * @return string
898
-     */
899
-    public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = [])
900
-    {
901
-        $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
902
-        if (
903
-            ! $admin
904
-            && ! apply_filters(
905
-                'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
906
-                EE_Registry::instance()->CFG->admin->show_reg_footer
907
-            )
908
-        ) {
909
-            return '';
910
-        }
911
-        $tag        = $admin ? 'span' : 'div';
912
-        $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
913
-        $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
914
-        $attributes .= ! empty($wrap_class)
915
-            ? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
916
-            : ' class="powered-by-event-espresso-credit"';
917
-        $query_args = array_merge(
918
-            [
919
-                'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
920
-                'utm_source'   => 'powered_by_event_espresso',
921
-                'utm_medium'   => 'link',
922
-                'utm_campaign' => 'powered_by',
923
-            ],
924
-            $query_args
925
-        );
926
-        $powered_by = apply_filters(
927
-            'FHEE__EEH_Template__powered_by_event_espresso_text',
928
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
929
-        );
930
-        $url        = add_query_arg($query_args, 'https://eventespresso.com/');
931
-        $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
932
-        return (string) apply_filters(
933
-            'FHEE__EEH_Template__powered_by_event_espresso__html',
934
-            sprintf(
935
-                esc_html_x(
936
-                    '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
937
-                    'Online event registration and ticketing powered by [link to eventespresso.com]',
938
-                    'event_espresso'
939
-                ),
940
-                "<{$tag}{$attributes}>",
941
-                "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
942
-                $admin ? '' : '<br />'
943
-            ),
944
-            $wrap_class,
945
-            $wrap_id
946
-        );
947
-    }
948
-
949
-
950
-    /**
951
-     * @param string $image_name
952
-     * @return string|null
953
-     * @since   4.10.14.p
954
-     */
955
-    public static function getScreenshotUrl($image_name)
956
-    {
957
-        return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
958
-    }
711
+		} else {
712
+			// simple value
713
+			echo esc_html($data);
714
+		}
715
+		return ob_get_clean();
716
+	}
717
+
718
+
719
+	/**
720
+	 * wrapper for self::get_paging_html() that simply echos the generated paging html
721
+	 *
722
+	 * @param        $total_items
723
+	 * @param        $current
724
+	 * @param        $per_page
725
+	 * @param        $url
726
+	 * @param bool   $show_num_field
727
+	 * @param string $paged_arg_name
728
+	 * @param array  $items_label
729
+	 * @see   self:get_paging_html() for argument docs.
730
+	 * @since 4.4.0
731
+	 */
732
+	public static function paging_html(
733
+		$total_items,
734
+		$current,
735
+		$per_page,
736
+		$url,
737
+		$show_num_field = true,
738
+		$paged_arg_name = 'paged',
739
+		$items_label = []
740
+	) {
741
+		echo self::get_paging_html(
742
+			$total_items,
743
+			$current,
744
+			$per_page,
745
+			$url,
746
+			$show_num_field,
747
+			$paged_arg_name,
748
+			$items_label
749
+		);
750
+	}
751
+
752
+
753
+	/**
754
+	 * A method for generating paging similar to WP_List_Table
755
+	 *
756
+	 * @param integer $total_items      How many total items there are to page.
757
+	 * @param integer $current          What the current page is.
758
+	 * @param integer $per_page         How many items per page.
759
+	 * @param string  $url              What the base url for page links is.
760
+	 * @param boolean $show_num_field   Whether to show the input for changing page number.
761
+	 * @param string  $paged_arg_name   The name of the key for the paged query argument.
762
+	 * @param array   $items_label      An array of singular/plural values for the items label:
763
+	 *                                  array(
764
+	 *                                  'single' => 'item',
765
+	 *                                  'plural' => 'items'
766
+	 *                                  )
767
+	 * @return  string
768
+	 * @since    4.4.0
769
+	 * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
770
+	 */
771
+	public static function get_paging_html(
772
+		$total_items,
773
+		$current,
774
+		$per_page,
775
+		$url,
776
+		$show_num_field = true,
777
+		$paged_arg_name = 'paged',
778
+		$items_label = []
779
+	) {
780
+		$page_links     = [];
781
+		$disable_first  = $disable_last = '';
782
+		$total_items    = (int) $total_items;
783
+		$per_page       = (int) $per_page;
784
+		$current        = (int) $current;
785
+		$paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
786
+
787
+		// filter items_label
788
+		$items_label = apply_filters(
789
+			'FHEE__EEH_Template__get_paging_html__items_label',
790
+			$items_label
791
+		);
792
+
793
+		if (
794
+			empty($items_label)
795
+			|| ! is_array($items_label)
796
+			|| ! isset($items_label['single'])
797
+			|| ! isset($items_label['plural'])
798
+		) {
799
+			$items_label = [
800
+				'single' => esc_html__('1 item', 'event_espresso'),
801
+				'plural' => esc_html__('%s items', 'event_espresso'),
802
+			];
803
+		} else {
804
+			$items_label = [
805
+				'single' => '1 ' . esc_html($items_label['single']),
806
+				'plural' => '%s ' . esc_html($items_label['plural']),
807
+			];
808
+		}
809
+
810
+		$total_pages = ceil($total_items / $per_page);
811
+
812
+		if ($total_pages <= 1) {
813
+			return '';
814
+		}
815
+
816
+		$item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
817
+
818
+		$output = '<span class="displaying-num">' . $item_label . '</span>';
819
+
820
+		if ($current === 1) {
821
+			$disable_first = ' disabled';
822
+		}
823
+		if ($current == $total_pages) {
824
+			$disable_last = ' disabled';
825
+		}
826
+
827
+		$page_links[] = sprintf(
828
+			"<a class='%s' title='%s' href='%s'>%s</a>",
829
+			'first-page' . $disable_first,
830
+			esc_attr__('Go to the first page', 'event_espresso'),
831
+			esc_url_raw(remove_query_arg($paged_arg_name, $url)),
832
+			'&laquo;'
833
+		);
834
+
835
+		$page_links[] = sprintf(
836
+			'<a class="%s" title="%s" href="%s">%s</a>',
837
+			'prev-page' . $disable_first,
838
+			esc_attr__('Go to the previous page', 'event_espresso'),
839
+			esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
840
+			'&lsaquo;'
841
+		);
842
+
843
+		if (! $show_num_field) {
844
+			$html_current_page = $current;
845
+		} else {
846
+			$html_current_page = sprintf(
847
+				"<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
848
+				esc_attr__('Current page', 'event_espresso'),
849
+				esc_attr($current),
850
+				strlen($total_pages)
851
+			);
852
+		}
853
+
854
+		$html_total_pages = sprintf(
855
+			'<span class="total-pages">%s</span>',
856
+			number_format_i18n($total_pages)
857
+		);
858
+		$page_links[]     = sprintf(
859
+			_x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
860
+			$html_current_page,
861
+			$html_total_pages,
862
+			'<span class="paging-input">',
863
+			'</span>'
864
+		);
865
+
866
+		$page_links[] = sprintf(
867
+			'<a class="%s" title="%s" href="%s">%s</a>',
868
+			'next-page' . $disable_last,
869
+			esc_attr__('Go to the next page', 'event_espresso'),
870
+			esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
871
+			'&rsaquo;'
872
+		);
873
+
874
+		$page_links[] = sprintf(
875
+			'<a class="%s" title="%s" href="%s">%s</a>',
876
+			'last-page' . $disable_last,
877
+			esc_attr__('Go to the last page', 'event_espresso'),
878
+			esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
879
+			'&raquo;'
880
+		);
881
+
882
+		$output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
883
+		// set page class
884
+		if ($total_pages) {
885
+			$page_class = $total_pages < 2 ? ' one-page' : '';
886
+		} else {
887
+			$page_class = ' no-pages';
888
+		}
889
+
890
+		return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
891
+	}
892
+
893
+
894
+	/**
895
+	 * @param string $wrap_class
896
+	 * @param string $wrap_id
897
+	 * @return string
898
+	 */
899
+	public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = [])
900
+	{
901
+		$admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
902
+		if (
903
+			! $admin
904
+			&& ! apply_filters(
905
+				'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
906
+				EE_Registry::instance()->CFG->admin->show_reg_footer
907
+			)
908
+		) {
909
+			return '';
910
+		}
911
+		$tag        = $admin ? 'span' : 'div';
912
+		$attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
913
+		$wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
914
+		$attributes .= ! empty($wrap_class)
915
+			? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
916
+			: ' class="powered-by-event-espresso-credit"';
917
+		$query_args = array_merge(
918
+			[
919
+				'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
920
+				'utm_source'   => 'powered_by_event_espresso',
921
+				'utm_medium'   => 'link',
922
+				'utm_campaign' => 'powered_by',
923
+			],
924
+			$query_args
925
+		);
926
+		$powered_by = apply_filters(
927
+			'FHEE__EEH_Template__powered_by_event_espresso_text',
928
+			$admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
929
+		);
930
+		$url        = add_query_arg($query_args, 'https://eventespresso.com/');
931
+		$url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
932
+		return (string) apply_filters(
933
+			'FHEE__EEH_Template__powered_by_event_espresso__html',
934
+			sprintf(
935
+				esc_html_x(
936
+					'%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
937
+					'Online event registration and ticketing powered by [link to eventespresso.com]',
938
+					'event_espresso'
939
+				),
940
+				"<{$tag}{$attributes}>",
941
+				"<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
942
+				$admin ? '' : '<br />'
943
+			),
944
+			$wrap_class,
945
+			$wrap_id
946
+		);
947
+	}
948
+
949
+
950
+	/**
951
+	 * @param string $image_name
952
+	 * @return string|null
953
+	 * @since   4.10.14.p
954
+	 */
955
+	public static function getScreenshotUrl($image_name)
956
+	{
957
+		return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
958
+	}
959 959
 }
960 960
 
961 961
 
962 962
 if (! function_exists('espresso_pagination')) {
963
-    /**
964
-     *    espresso_pagination
965
-     *
966
-     * @access    public
967
-     * @return    void
968
-     */
969
-    function espresso_pagination()
970
-    {
971
-        global $wp_query;
972
-        $big        = 999999999; // need an unlikely integer
973
-        $pagination = paginate_links(
974
-            [
975
-                'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
976
-                'format'       => '?paged=%#%',
977
-                'current'      => max(1, get_query_var('paged')),
978
-                'total'        => $wp_query->max_num_pages,
979
-                'show_all'     => true,
980
-                'end_size'     => 10,
981
-                'mid_size'     => 6,
982
-                'prev_next'    => true,
983
-                'prev_text'    => esc_html__('&lsaquo; PREV', 'event_espresso'),
984
-                'next_text'    => esc_html__('NEXT &rsaquo;', 'event_espresso'),
985
-                'type'         => 'plain',
986
-                'add_args'     => false,
987
-                'add_fragment' => '',
988
-            ]
989
-        );
990
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
991
-    }
963
+	/**
964
+	 *    espresso_pagination
965
+	 *
966
+	 * @access    public
967
+	 * @return    void
968
+	 */
969
+	function espresso_pagination()
970
+	{
971
+		global $wp_query;
972
+		$big        = 999999999; // need an unlikely integer
973
+		$pagination = paginate_links(
974
+			[
975
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
976
+				'format'       => '?paged=%#%',
977
+				'current'      => max(1, get_query_var('paged')),
978
+				'total'        => $wp_query->max_num_pages,
979
+				'show_all'     => true,
980
+				'end_size'     => 10,
981
+				'mid_size'     => 6,
982
+				'prev_next'    => true,
983
+				'prev_text'    => esc_html__('&lsaquo; PREV', 'event_espresso'),
984
+				'next_text'    => esc_html__('NEXT &rsaquo;', 'event_espresso'),
985
+				'type'         => 'plain',
986
+				'add_args'     => false,
987
+				'add_fragment' => '',
988
+			]
989
+		);
990
+		echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
991
+	}
992 992
 }
993 993
\ 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
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use EventEspresso\core\services\loaders\LoaderFactory;
6 6
 use EventEspresso\core\services\request\RequestInterface;
7 7
 
8
-if (! function_exists('espresso_get_template_part')) {
8
+if ( ! function_exists('espresso_get_template_part')) {
9 9
     /**
10 10
      * espresso_get_template_part
11 11
      * 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
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 }
22 22
 
23 23
 
24
-if (! function_exists('espresso_get_object_css_class')) {
24
+if ( ! function_exists('espresso_get_object_css_class')) {
25 25
     /**
26 26
      * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
27 27
      *
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public static function load_espresso_theme_functions()
74 74
     {
75
-        if (! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php')) {
77
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . '/functions.php');
75
+        if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
76
+            if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().'/functions.php')) {
77
+                require_once(EE_PUBLIC.EE_Config::get_current_theme().'/functions.php');
78 78
             }
79 79
         }
80 80
     }
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
     public static function get_espresso_themes()
89 89
     {
90 90
         if (empty(EEH_Template::$_espresso_themes)) {
91
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
91
+            $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR);
92 92
             if (empty($espresso_themes)) {
93 93
                 return [];
94 94
             }
95 95
             if (($key = array_search('global_assets', $espresso_themes)) !== false) {
96
-                unset($espresso_themes[ $key ]);
96
+                unset($espresso_themes[$key]);
97 97
             }
98 98
             EEH_Template::$_espresso_themes = [];
99 99
             foreach ($espresso_themes as $espresso_theme) {
100
-                EEH_Template::$_espresso_themes[ basename($espresso_theme) ] = $espresso_theme;
100
+                EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
101 101
             }
102 102
         }
103 103
         return EEH_Template::$_espresso_themes;
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
                 // get array of EE Custom Post Types
214 214
                 $EE_CPTs = $custom_post_types->getDefinitions();
215 215
                 // build template name based on request
216
-                if (isset($EE_CPTs[ $post_type ])) {
216
+                if (isset($EE_CPTs[$post_type])) {
217 217
                     $archive_or_single = is_archive() ? 'archive' : '';
218 218
                     $archive_or_single = is_single() ? 'single' : $archive_or_single;
219
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
219
+                    $templates         = $archive_or_single.'-'.$post_type.'.php';
220 220
                 }
221 221
             }
222 222
             // currently active EE template theme
@@ -225,18 +225,18 @@  discard block
 block discarded – undo
225 225
             // array of paths to folders that may contain templates
226 226
             $template_folder_paths = [
227 227
                 // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
228
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
228
+                EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme,
229 229
                 // then in the root of the /wp-content/uploads/espresso/templates/ folder
230 230
                 EVENT_ESPRESSO_TEMPLATE_DIR,
231 231
             ];
232 232
 
233 233
             // add core plugin folders for checking only if we're not $check_if_custom
234
-            if (! $check_if_custom) {
235
-                $core_paths            = [
234
+            if ( ! $check_if_custom) {
235
+                $core_paths = [
236 236
                     // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
237
-                    EE_PUBLIC . $current_theme,
237
+                    EE_PUBLIC.$current_theme,
238 238
                     // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
239
-                    EE_TEMPLATES . $current_theme,
239
+                    EE_TEMPLATES.$current_theme,
240 240
                     // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
241 241
                     EE_PLUGIN_DIR_PATH,
242 242
                 ];
@@ -271,10 +271,10 @@  discard block
 block discarded – undo
271 271
                     );
272 272
                     if ($common_base_path !== '') {
273 273
                         // both paths have a common base, so just tack the filename onto our search path
274
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
274
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name;
275 275
                     } else {
276 276
                         // no common base path, so let's just concatenate
277
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
277
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template;
278 278
                     }
279 279
                     // build up our template locations array by adding our resolved paths
280 280
                     $full_template_paths[] = $resolved_path;
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                 // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
283 283
                 array_unshift($full_template_paths, $template);
284 284
                 // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
285
-                array_unshift($full_template_paths, get_stylesheet_directory() . '/' . $file_name);
285
+                array_unshift($full_template_paths, get_stylesheet_directory().'/'.$file_name);
286 286
             }
287 287
             // filter final array of full template paths
288 288
             $full_template_paths = apply_filters(
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
                 }
334 334
             }
335 335
             $common_base_path .= $directory;
336
-            $last_offset      = $index + 1;
336
+            $last_offset = $index + 1;
337 337
         }
338 338
         return substr($common_base_path, 0, -1);
339 339
     }
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
372 372
 
373 373
         // you gimme nuttin - YOU GET NUTTIN !!
374
-        if (! $template_path || ! is_readable($template_path)) {
374
+        if ( ! $template_path || ! is_readable($template_path)) {
375 375
             // ignore whether template is accessible ?
376 376
             if ($throw_exceptions) {
377 377
                 throw new DomainException(
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             return '';
382 382
         }
383 383
         // if $template_args are not in an array, then make it so
384
-        if (! is_array($template_args) && ! is_object($template_args)) {
384
+        if ( ! is_array($template_args) && ! is_object($template_args)) {
385 385
             $template_args = [$template_args];
386 386
         }
387 387
         extract($template_args, EXTR_SKIP);
@@ -410,11 +410,11 @@  discard block
 block discarded – undo
410 410
     public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
411 411
     {
412 412
         // in the beginning...
413
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
413
+        $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : '';
414 414
         // da muddle
415 415
         $class = '';
416 416
         // the end
417
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
417
+        $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : '';
418 418
         // is the passed object an EE object ?
419 419
         if ($object instanceof EE_Base_Class) {
420 420
             // grab the exact type of object
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
                 // no specifics just yet...
425 425
                 default:
426 426
                     $class = strtolower(str_replace('_', '-', $obj_class));
427
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
427
+                    $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : '';
428 428
             }
429 429
         }
430
-        return $prefix . $class . $suffix;
430
+        return $prefix.$class.$suffix;
431 431
     }
432 432
 
433 433
 
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
         // filter raw amount (allows 0.00 to be changed to "free" for example)
463 463
         $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
464 464
         // still a number, or was amount converted to a string like "free" ?
465
-        if (! is_float($amount_formatted)) {
465
+        if ( ! is_float($amount_formatted)) {
466 466
             return esc_html($amount_formatted);
467 467
         }
468 468
         try {
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
             $mny = null;
474 474
         }
475 475
         // verify results
476
-        if (! $mny instanceof EE_Currency_Config) {
476
+        if ( ! $mny instanceof EE_Currency_Config) {
477 477
             // set default config country currency settings
478 478
             $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
479 479
                 ? EE_Registry::instance()->CFG->currency
@@ -482,16 +482,16 @@  discard block
 block discarded – undo
482 482
         // format float
483 483
         $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
484 484
         // add formatting ?
485
-        if (! $return_raw) {
485
+        if ( ! $return_raw) {
486 486
             // add currency sign
487 487
             if ($mny->sign_b4) {
488 488
                 if ($amount >= 0) {
489
-                    $amount_formatted = $mny->sign . $amount_formatted;
489
+                    $amount_formatted = $mny->sign.$amount_formatted;
490 490
                 } else {
491
-                    $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
491
+                    $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted);
492 492
                 }
493 493
             } else {
494
-                $amount_formatted = $amount_formatted . $mny->sign;
494
+                $amount_formatted = $amount_formatted.$mny->sign;
495 495
             }
496 496
 
497 497
             // filter to allow global setting of display_code
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 
503 503
             // add currency code ?
504 504
             $amount_formatted = $display_code
505
-                ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>'
505
+                ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>'
506 506
                 : $amount_formatted;
507 507
         }
508 508
         // filter results
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
             $plural,
539 539
             $schema
540 540
         );
541
-        return $status[ $status_id ];
541
+        return $status[$status_id];
542 542
     }
543 543
 
544 544
 
@@ -555,14 +555,14 @@  discard block
 block discarded – undo
555 555
     public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
556 556
     {
557 557
         $icon_html = '';
558
-        if (! empty($icon)) {
558
+        if ( ! empty($icon)) {
559 559
             $dashicons = preg_split("(ee-icon |dashicons )", $icon);
560 560
             $dashicons = array_filter($dashicons);
561 561
             $count     = count($dashicons);
562 562
             $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
563 563
             foreach ($dashicons as $dashicon) {
564
-                $type      = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
564
+                $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
565
+                $icon_html .= '<span class="'.$type.$dashicon.'"></span>';
566 566
             }
567 567
             $icon_html .= $count > 1 ? '</span>' : '';
568 568
         }
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
         $action  = $action ?: $request->getRequestParam('action', 'default', 'key');
601 601
 
602 602
 
603
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
603
+        $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id;
604 604
         $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
605 605
         $help_text    = ! $help_text ? '' : $help_text;
606 606
         return '<a id="'
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
      */
635 635
     public static function status_legend($status_array, $active_status = '')
636 636
     {
637
-        if (! is_array($status_array)) {
637
+        if ( ! is_array($status_array)) {
638 638
             throw new EE_Error(
639 639
                 esc_html__(
640 640
                     'The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
@@ -646,17 +646,17 @@  discard block
 block discarded – undo
646 646
         $content = '
647 647
             <div class="ee-list-table-legend-container">
648 648
                 <h4 class="status-legend-title">
649
-                    ' . esc_html__('Status Legend', 'event_espresso') . '
649
+                    ' . esc_html__('Status Legend', 'event_espresso').'
650 650
                 </h4>
651 651
                 <dl class="ee-list-table-legend">';
652 652
 
653 653
         foreach ($status_array as $item => $status) {
654 654
             $active_class = $active_status == $status ? 'class="ee-is-active-status"' : '';
655
-            $content      .= '
656
-                    <dt id="' . esc_attr('ee-legend-item-tooltip-' . $item) . '" ' . $active_class . '>
657
-                        <span class="' . esc_attr('ee-status-legend ee-status-legend-' . $status) . '"></span>
655
+            $content .= '
656
+                    <dt id="' . esc_attr('ee-legend-item-tooltip-'.$item).'" '.$active_class.'>
657
+                        <span class="' . esc_attr('ee-status-legend ee-status-legend-'.$status).'"></span>
658 658
                         <span class="ee-legend-description">
659
-                            ' . EEH_Template::pretty_status($status, false, 'sentence') . '
659
+                            ' . EEH_Template::pretty_status($status, false, 'sentence').'
660 660
                         </span>
661 661
                     </dt>';
662 662
         }
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
             ];
803 803
         } else {
804 804
             $items_label = [
805
-                'single' => '1 ' . esc_html($items_label['single']),
806
-                'plural' => '%s ' . esc_html($items_label['plural']),
805
+                'single' => '1 '.esc_html($items_label['single']),
806
+                'plural' => '%s '.esc_html($items_label['plural']),
807 807
             ];
808 808
         }
809 809
 
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 
816 816
         $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
817 817
 
818
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
818
+        $output = '<span class="displaying-num">'.$item_label.'</span>';
819 819
 
820 820
         if ($current === 1) {
821 821
             $disable_first = ' disabled';
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 
827 827
         $page_links[] = sprintf(
828 828
             "<a class='%s' title='%s' href='%s'>%s</a>",
829
-            'first-page' . $disable_first,
829
+            'first-page'.$disable_first,
830 830
             esc_attr__('Go to the first page', 'event_espresso'),
831 831
             esc_url_raw(remove_query_arg($paged_arg_name, $url)),
832 832
             '&laquo;'
@@ -834,13 +834,13 @@  discard block
 block discarded – undo
834 834
 
835 835
         $page_links[] = sprintf(
836 836
             '<a class="%s" title="%s" href="%s">%s</a>',
837
-            'prev-page' . $disable_first,
837
+            'prev-page'.$disable_first,
838 838
             esc_attr__('Go to the previous page', 'event_espresso'),
839 839
             esc_url_raw(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
840 840
             '&lsaquo;'
841 841
         );
842 842
 
843
-        if (! $show_num_field) {
843
+        if ( ! $show_num_field) {
844 844
             $html_current_page = $current;
845 845
         } else {
846 846
             $html_current_page = sprintf(
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
             '<span class="total-pages">%s</span>',
856 856
             number_format_i18n($total_pages)
857 857
         );
858
-        $page_links[]     = sprintf(
858
+        $page_links[] = sprintf(
859 859
             _x('%3$s%1$s of %2$s%4$s', 'paging', 'event_espresso'),
860 860
             $html_current_page,
861 861
             $html_total_pages,
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 
866 866
         $page_links[] = sprintf(
867 867
             '<a class="%s" title="%s" href="%s">%s</a>',
868
-            'next-page' . $disable_last,
868
+            'next-page'.$disable_last,
869 869
             esc_attr__('Go to the next page', 'event_espresso'),
870 870
             esc_url_raw(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
871 871
             '&rsaquo;'
@@ -873,13 +873,13 @@  discard block
 block discarded – undo
873 873
 
874 874
         $page_links[] = sprintf(
875 875
             '<a class="%s" title="%s" href="%s">%s</a>',
876
-            'last-page' . $disable_last,
876
+            'last-page'.$disable_last,
877 877
             esc_attr__('Go to the last page', 'event_espresso'),
878 878
             esc_url_raw(add_query_arg($paged_arg_name, $total_pages, $url)),
879 879
             '&raquo;'
880 880
         );
881 881
 
882
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
882
+        $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>';
883 883
         // set page class
884 884
         if ($total_pages) {
885 885
             $page_class = $total_pages < 2 ? ' one-page' : '';
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
             $page_class = ' no-pages';
888 888
         }
889 889
 
890
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
890
+        return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>';
891 891
     }
892 892
 
893 893
 
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
         );
926 926
         $powered_by = apply_filters(
927 927
             'FHEE__EEH_Template__powered_by_event_espresso_text',
928
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'
928
+            $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso'
929 929
         );
930 930
         $url        = add_query_arg($query_args, 'https://eventespresso.com/');
931 931
         $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
@@ -954,12 +954,12 @@  discard block
 block discarded – undo
954 954
      */
955 955
     public static function getScreenshotUrl($image_name)
956 956
     {
957
-        return esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/screenshots/' . $image_name . '.jpg');
957
+        return esc_url_raw(EE_GLOBAL_ASSETS_URL.'images/screenshots/'.$image_name.'.jpg');
958 958
     }
959 959
 }
960 960
 
961 961
 
962
-if (! function_exists('espresso_pagination')) {
962
+if ( ! function_exists('espresso_pagination')) {
963 963
     /**
964 964
      *    espresso_pagination
965 965
      *
@@ -987,6 +987,6 @@  discard block
 block discarded – undo
987 987
                 'add_fragment' => '',
988 988
             ]
989 989
         );
990
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
990
+        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : '';
991 991
     }
992 992
 }
993 993
\ No newline at end of file
Please login to merge, or discard this patch.
core/EE_Config.core.php 1 patch
Indentation   +3178 added lines, -3178 removed lines patch added patch discarded remove patch
@@ -19,2546 +19,2546 @@  discard block
 block discarded – undo
19 19
 final class EE_Config implements ResettableInterface
20 20
 {
21 21
 
22
-    const OPTION_NAME = 'ee_config';
23
-
24
-    const LOG_NAME = 'ee_config_log';
25
-
26
-    const LOG_LENGTH = 100;
27
-
28
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
29
-
30
-    /**
31
-     *    instance of the EE_Config object
32
-     *
33
-     * @var    EE_Config $_instance
34
-     * @access    private
35
-     */
36
-    private static $_instance;
37
-
38
-    /**
39
-     * @var boolean $_logging_enabled
40
-     */
41
-    private static $_logging_enabled = false;
42
-
43
-    /**
44
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
45
-     */
46
-    private $legacy_shortcodes_manager;
47
-
48
-    /**
49
-     * An StdClass whose property names are addon slugs,
50
-     * and values are their config classes
51
-     *
52
-     * @var StdClass
53
-     */
54
-    public $addons;
55
-
56
-    /**
57
-     * @var EE_Admin_Config
58
-     */
59
-    public $admin;
60
-
61
-    /**
62
-     * @var EE_Core_Config
63
-     */
64
-    public $core;
65
-
66
-    /**
67
-     * @var EE_Currency_Config
68
-     */
69
-    public $currency;
70
-
71
-    /**
72
-     * @var EE_Organization_Config
73
-     */
74
-    public $organization;
75
-
76
-    /**
77
-     * @var EE_Registration_Config
78
-     */
79
-    public $registration;
80
-
81
-    /**
82
-     * @var EE_Template_Config
83
-     */
84
-    public $template_settings;
85
-
86
-    /**
87
-     * Holds EE environment values.
88
-     *
89
-     * @var EE_Environment_Config
90
-     */
91
-    public $environment;
92
-
93
-    /**
94
-     * settings pertaining to Google maps
95
-     *
96
-     * @var EE_Map_Config
97
-     */
98
-    public $map_settings;
99
-
100
-    /**
101
-     * settings pertaining to Taxes
102
-     *
103
-     * @var EE_Tax_Config
104
-     */
105
-    public $tax_settings;
106
-
107
-    /**
108
-     * Settings pertaining to global messages settings.
109
-     *
110
-     * @var EE_Messages_Config
111
-     */
112
-    public $messages;
113
-
114
-    /**
115
-     * @deprecated
116
-     * @var EE_Gateway_Config
117
-     */
118
-    public $gateway;
119
-
120
-    /**
121
-     * @var    array $_addon_option_names
122
-     * @access    private
123
-     */
124
-    private $_addon_option_names = array();
125
-
126
-    /**
127
-     * @var    array $_module_route_map
128
-     * @access    private
129
-     */
130
-    private static $_module_route_map = array();
131
-
132
-    /**
133
-     * @var    array $_module_forward_map
134
-     * @access    private
135
-     */
136
-    private static $_module_forward_map = array();
137
-
138
-    /**
139
-     * @var    array $_module_view_map
140
-     * @access    private
141
-     */
142
-    private static $_module_view_map = array();
143
-
144
-
145
-    /**
146
-     * @singleton method used to instantiate class object
147
-     * @access    public
148
-     * @return EE_Config instance
149
-     */
150
-    public static function instance()
151
-    {
152
-        // check if class object is instantiated, and instantiated properly
153
-        if (! self::$_instance instanceof EE_Config) {
154
-            self::$_instance = new self();
155
-        }
156
-        return self::$_instance;
157
-    }
158
-
159
-
160
-    /**
161
-     * Resets the config
162
-     *
163
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
164
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
165
-     *                               reflect its state in the database
166
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
167
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
168
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
169
-     *                               site was put into maintenance mode)
170
-     * @return EE_Config
171
-     */
172
-    public static function reset($hard_reset = false, $reinstantiate = true)
173
-    {
174
-        if (self::$_instance instanceof EE_Config) {
175
-            if ($hard_reset) {
176
-                self::$_instance->legacy_shortcodes_manager = null;
177
-                self::$_instance->_addon_option_names = array();
178
-                self::$_instance->_initialize_config();
179
-                self::$_instance->update_espresso_config();
180
-            }
181
-            self::$_instance->update_addon_option_names();
182
-        }
183
-        self::$_instance = null;
184
-        // we don't need to reset the static properties imo because those should
185
-        // only change when a module is added or removed. Currently we don't
186
-        // support removing a module during a request when it previously existed
187
-        if ($reinstantiate) {
188
-            return self::instance();
189
-        } else {
190
-            return null;
191
-        }
192
-    }
193
-
194
-
195
-    /**
196
-     *    class constructor
197
-     *
198
-     * @access    private
199
-     */
200
-    private function __construct()
201
-    {
202
-        do_action('AHEE__EE_Config__construct__begin', $this);
203
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
204
-        // setup empty config classes
205
-        $this->_initialize_config();
206
-        // load existing EE site settings
207
-        $this->_load_core_config();
208
-        // confirm everything loaded correctly and set filtered defaults if not
209
-        $this->_verify_config();
210
-        //  register shortcodes and modules
211
-        add_action(
212
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
213
-            array($this, 'register_shortcodes_and_modules'),
214
-            999
215
-        );
216
-        //  initialize shortcodes and modules
217
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
218
-        // register widgets
219
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
220
-        // shutdown
221
-        add_action('shutdown', array($this, 'shutdown'), 10);
222
-        // construct__end hook
223
-        do_action('AHEE__EE_Config__construct__end', $this);
224
-        // hardcoded hack
225
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
226
-    }
227
-
228
-
229
-    /**
230
-     * @return boolean
231
-     */
232
-    public static function logging_enabled()
233
-    {
234
-        return self::$_logging_enabled;
235
-    }
236
-
237
-
238
-    /**
239
-     * use to get the current theme if needed from static context
240
-     *
241
-     * @return string current theme set.
242
-     */
243
-    public static function get_current_theme()
244
-    {
245
-        return isset(self::$_instance->template_settings->current_espresso_theme)
246
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
247
-    }
248
-
249
-
250
-    /**
251
-     *        _initialize_config
252
-     *
253
-     * @access private
254
-     * @return void
255
-     */
256
-    private function _initialize_config()
257
-    {
258
-        EE_Config::trim_log();
259
-        // set defaults
260
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
261
-        $this->addons = new stdClass();
262
-        // set _module_route_map
263
-        EE_Config::$_module_route_map = array();
264
-        // set _module_forward_map
265
-        EE_Config::$_module_forward_map = array();
266
-        // set _module_view_map
267
-        EE_Config::$_module_view_map = array();
268
-    }
269
-
270
-
271
-    /**
272
-     *        load core plugin configuration
273
-     *
274
-     * @access private
275
-     * @return void
276
-     */
277
-    private function _load_core_config()
278
-    {
279
-        // load_core_config__start hook
280
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
281
-        $espresso_config = $this->get_espresso_config();
282
-        foreach ($espresso_config as $config => $settings) {
283
-            // load_core_config__start hook
284
-            $settings = apply_filters(
285
-                'FHEE__EE_Config___load_core_config__config_settings',
286
-                $settings,
287
-                $config,
288
-                $this
289
-            );
290
-            if (is_object($settings) && property_exists($this, $config)) {
291
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
292
-                // call configs populate method to ensure any defaults are set for empty values.
293
-                if (method_exists($settings, 'populate')) {
294
-                    $this->{$config}->populate();
295
-                }
296
-                if (method_exists($settings, 'do_hooks')) {
297
-                    $this->{$config}->do_hooks();
298
-                }
299
-            }
300
-        }
301
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
302
-            $this->update_espresso_config();
303
-        }
304
-        // load_core_config__end hook
305
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
306
-    }
307
-
308
-
309
-    /**
310
-     *    _verify_config
311
-     *
312
-     * @access    protected
313
-     * @return    void
314
-     */
315
-    protected function _verify_config()
316
-    {
317
-        $this->core = $this->core instanceof EE_Core_Config
318
-            ? $this->core
319
-            : new EE_Core_Config();
320
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
321
-        $this->organization = $this->organization instanceof EE_Organization_Config
322
-            ? $this->organization
323
-            : new EE_Organization_Config();
324
-        $this->organization = apply_filters(
325
-            'FHEE__EE_Config___initialize_config__organization',
326
-            $this->organization
327
-        );
328
-        $this->currency = $this->currency instanceof EE_Currency_Config
329
-            ? $this->currency
330
-            : new EE_Currency_Config();
331
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
332
-        $this->registration = $this->registration instanceof EE_Registration_Config
333
-            ? $this->registration
334
-            : new EE_Registration_Config();
335
-        $this->registration = apply_filters(
336
-            'FHEE__EE_Config___initialize_config__registration',
337
-            $this->registration
338
-        );
339
-        $this->admin = $this->admin instanceof EE_Admin_Config
340
-            ? $this->admin
341
-            : new EE_Admin_Config();
342
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
343
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
344
-            ? $this->template_settings
345
-            : new EE_Template_Config();
346
-        $this->template_settings = apply_filters(
347
-            'FHEE__EE_Config___initialize_config__template_settings',
348
-            $this->template_settings
349
-        );
350
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
351
-            ? $this->map_settings
352
-            : new EE_Map_Config();
353
-        $this->map_settings = apply_filters(
354
-            'FHEE__EE_Config___initialize_config__map_settings',
355
-            $this->map_settings
356
-        );
357
-        $this->environment = $this->environment instanceof EE_Environment_Config
358
-            ? $this->environment
359
-            : new EE_Environment_Config();
360
-        $this->environment = apply_filters(
361
-            'FHEE__EE_Config___initialize_config__environment',
362
-            $this->environment
363
-        );
364
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
365
-            ? $this->tax_settings
366
-            : new EE_Tax_Config();
367
-        $this->tax_settings = apply_filters(
368
-            'FHEE__EE_Config___initialize_config__tax_settings',
369
-            $this->tax_settings
370
-        );
371
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
372
-        $this->messages = $this->messages instanceof EE_Messages_Config
373
-            ? $this->messages
374
-            : new EE_Messages_Config();
375
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
376
-            ? $this->gateway
377
-            : new EE_Gateway_Config();
378
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
379
-        $this->legacy_shortcodes_manager = null;
380
-    }
381
-
382
-
383
-    /**
384
-     *    get_espresso_config
385
-     *
386
-     * @access    public
387
-     * @return    array of espresso config stuff
388
-     */
389
-    public function get_espresso_config()
390
-    {
391
-        // grab espresso configuration
392
-        return apply_filters(
393
-            'FHEE__EE_Config__get_espresso_config__CFG',
394
-            get_option(EE_Config::OPTION_NAME, array())
395
-        );
396
-    }
397
-
398
-
399
-    /**
400
-     *    double_check_config_comparison
401
-     *
402
-     * @access    public
403
-     * @param string $option
404
-     * @param        $old_value
405
-     * @param        $value
406
-     */
407
-    public function double_check_config_comparison($option = '', $old_value, $value)
408
-    {
409
-        // make sure we're checking the ee config
410
-        if ($option === EE_Config::OPTION_NAME) {
411
-            // run a loose comparison of the old value against the new value for type and properties,
412
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
413
-            if ($value != $old_value) {
414
-                // if they are NOT the same, then remove the hook,
415
-                // which means the subsequent update results will be based solely on the update query results
416
-                // the reason we do this is because, as stated above,
417
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
418
-                // this happens PRIOR to serialization and any subsequent update.
419
-                // If values are found to match their previous old value,
420
-                // then WP bails before performing any update.
421
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
422
-                // it just pulled from the db, with the one being passed to it (which will not match).
423
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
424
-                // MySQL MAY ALSO NOT perform the update because
425
-                // the string it sees in the db looks the same as the new one it has been passed!!!
426
-                // This results in the query returning an "affected rows" value of ZERO,
427
-                // which gets returned immediately by WP update_option and looks like an error.
428
-                remove_action('update_option', array($this, 'check_config_updated'));
429
-            }
430
-        }
431
-    }
432
-
433
-
434
-    /**
435
-     *    update_espresso_config
436
-     *
437
-     * @access   public
438
-     */
439
-    protected function _reset_espresso_addon_config()
440
-    {
441
-        $this->_addon_option_names = array();
442
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
443
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
444
-            if ($addon_config_obj instanceof EE_Config_Base) {
445
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
446
-            }
447
-            $this->addons->{$addon_name} = null;
448
-        }
449
-    }
450
-
451
-
452
-    /**
453
-     *    update_espresso_config
454
-     *
455
-     * @access   public
456
-     * @param   bool $add_success
457
-     * @param   bool $add_error
458
-     * @return   bool
459
-     */
460
-    public function update_espresso_config($add_success = false, $add_error = true)
461
-    {
462
-        // don't allow config updates during WP heartbeats
463
-        /** @var RequestInterface $request */
464
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
465
-        if ($request->isWordPressHeartbeat()) {
466
-            return false;
467
-        }
468
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
469
-        // $clone = clone( self::$_instance );
470
-        // self::$_instance = NULL;
471
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
472
-        $this->_reset_espresso_addon_config();
473
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
474
-        // but BEFORE the actual update occurs
475
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
476
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
477
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
478
-        $this->legacy_shortcodes_manager = null;
479
-        // now update "ee_config"
480
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
481
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
482
-        EE_Config::log(EE_Config::OPTION_NAME);
483
-        // if not saved... check if the hook we just added still exists;
484
-        // if it does, it means one of two things:
485
-        // that update_option bailed at the($value === $old_value) conditional,
486
-        // or...
487
-        // the db update query returned 0 rows affected
488
-        // (probably because the data  value was the same from it's perspective)
489
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
490
-        // but just means no update occurred, so don't display an error to the user.
491
-        // BUT... if update_option returns FALSE, AND the hook is missing,
492
-        // then it means that something truly went wrong
493
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
494
-        // remove our action since we don't want it in the system anymore
495
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
496
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
497
-        // self::$_instance = $clone;
498
-        // unset( $clone );
499
-        // if config remains the same or was updated successfully
500
-        if ($saved) {
501
-            if ($add_success) {
502
-                EE_Error::add_success(
503
-                    esc_html__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
504
-                    __FILE__,
505
-                    __FUNCTION__,
506
-                    __LINE__
507
-                );
508
-            }
509
-            return true;
510
-        } else {
511
-            if ($add_error) {
512
-                EE_Error::add_error(
513
-                    esc_html__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
514
-                    __FILE__,
515
-                    __FUNCTION__,
516
-                    __LINE__
517
-                );
518
-            }
519
-            return false;
520
-        }
521
-    }
522
-
523
-
524
-    /**
525
-     *    _verify_config_params
526
-     *
527
-     * @access    private
528
-     * @param    string         $section
529
-     * @param    string         $name
530
-     * @param    string         $config_class
531
-     * @param    EE_Config_Base $config_obj
532
-     * @param    array          $tests_to_run
533
-     * @param    bool           $display_errors
534
-     * @return    bool    TRUE on success, FALSE on fail
535
-     */
536
-    private function _verify_config_params(
537
-        $section = '',
538
-        $name = '',
539
-        $config_class = '',
540
-        $config_obj = null,
541
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
542
-        $display_errors = true
543
-    ) {
544
-        try {
545
-            foreach ($tests_to_run as $test) {
546
-                switch ($test) {
547
-                    // TEST #1 : check that section was set
548
-                    case 1:
549
-                        if (empty($section)) {
550
-                            if ($display_errors) {
551
-                                throw new EE_Error(
552
-                                    sprintf(
553
-                                        esc_html__(
554
-                                            'No configuration section has been provided while attempting to save "%s".',
555
-                                            'event_espresso'
556
-                                        ),
557
-                                        $config_class
558
-                                    )
559
-                                );
560
-                            }
561
-                            return false;
562
-                        }
563
-                        break;
564
-                    // TEST #2 : check that settings section exists
565
-                    case 2:
566
-                        if (! isset($this->{$section})) {
567
-                            if ($display_errors) {
568
-                                throw new EE_Error(
569
-                                    sprintf(
570
-                                        esc_html__('The "%s" configuration section does not exist.', 'event_espresso'),
571
-                                        $section
572
-                                    )
573
-                                );
574
-                            }
575
-                            return false;
576
-                        }
577
-                        break;
578
-                    // TEST #3 : check that section is the proper format
579
-                    case 3:
580
-                        if (
581
-                            ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
582
-                        ) {
583
-                            if ($display_errors) {
584
-                                throw new EE_Error(
585
-                                    sprintf(
586
-                                        esc_html__(
587
-                                            'The "%s" configuration settings have not been formatted correctly.',
588
-                                            'event_espresso'
589
-                                        ),
590
-                                        $section
591
-                                    )
592
-                                );
593
-                            }
594
-                            return false;
595
-                        }
596
-                        break;
597
-                    // TEST #4 : check that config section name has been set
598
-                    case 4:
599
-                        if (empty($name)) {
600
-                            if ($display_errors) {
601
-                                throw new EE_Error(
602
-                                    esc_html__(
603
-                                        'No name has been provided for the specific configuration section.',
604
-                                        'event_espresso'
605
-                                    )
606
-                                );
607
-                            }
608
-                            return false;
609
-                        }
610
-                        break;
611
-                    // TEST #5 : check that a config class name has been set
612
-                    case 5:
613
-                        if (empty($config_class)) {
614
-                            if ($display_errors) {
615
-                                throw new EE_Error(
616
-                                    esc_html__(
617
-                                        'No class name has been provided for the specific configuration section.',
618
-                                        'event_espresso'
619
-                                    )
620
-                                );
621
-                            }
622
-                            return false;
623
-                        }
624
-                        break;
625
-                    // TEST #6 : verify config class is accessible
626
-                    case 6:
627
-                        if (! class_exists($config_class)) {
628
-                            if ($display_errors) {
629
-                                throw new EE_Error(
630
-                                    sprintf(
631
-                                        esc_html__(
632
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
633
-                                            'event_espresso'
634
-                                        ),
635
-                                        $config_class
636
-                                    )
637
-                                );
638
-                            }
639
-                            return false;
640
-                        }
641
-                        break;
642
-                    // TEST #7 : check that config has even been set
643
-                    case 7:
644
-                        if (! isset($this->{$section}->{$name})) {
645
-                            if ($display_errors) {
646
-                                throw new EE_Error(
647
-                                    sprintf(
648
-                                        esc_html__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
649
-                                        $section,
650
-                                        $name
651
-                                    )
652
-                                );
653
-                            }
654
-                            return false;
655
-                        } else {
656
-                            // and make sure it's not serialized
657
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
658
-                        }
659
-                        break;
660
-                    // TEST #8 : check that config is the requested type
661
-                    case 8:
662
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
663
-                            if ($display_errors) {
664
-                                throw new EE_Error(
665
-                                    sprintf(
666
-                                        esc_html__(
667
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
668
-                                            'event_espresso'
669
-                                        ),
670
-                                        $section,
671
-                                        $name,
672
-                                        $config_class
673
-                                    )
674
-                                );
675
-                            }
676
-                            return false;
677
-                        }
678
-                        break;
679
-                    // TEST #9 : verify config object
680
-                    case 9:
681
-                        if (! $config_obj instanceof EE_Config_Base) {
682
-                            if ($display_errors) {
683
-                                throw new EE_Error(
684
-                                    sprintf(
685
-                                        esc_html__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
686
-                                        print_r($config_obj, true)
687
-                                    )
688
-                                );
689
-                            }
690
-                            return false;
691
-                        }
692
-                        break;
693
-                }
694
-            }
695
-        } catch (EE_Error $e) {
696
-            $e->get_error();
697
-        }
698
-        // you have successfully run the gauntlet
699
-        return true;
700
-    }
701
-
702
-
703
-    /**
704
-     *    _generate_config_option_name
705
-     *
706
-     * @access        protected
707
-     * @param        string $section
708
-     * @param        string $name
709
-     * @return        string
710
-     */
711
-    private function _generate_config_option_name($section = '', $name = '')
712
-    {
713
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
714
-    }
715
-
716
-
717
-    /**
718
-     *    _set_config_class
719
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
720
-     *
721
-     * @access    private
722
-     * @param    string $config_class
723
-     * @param    string $name
724
-     * @return    string
725
-     */
726
-    private function _set_config_class($config_class = '', $name = '')
727
-    {
728
-        return ! empty($config_class)
729
-            ? $config_class
730
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
731
-    }
732
-
733
-
734
-    /**
735
-     *    set_config
736
-     *
737
-     * @access    protected
738
-     * @param    string         $section
739
-     * @param    string         $name
740
-     * @param    string         $config_class
741
-     * @param    EE_Config_Base $config_obj
742
-     * @return    EE_Config_Base
743
-     */
744
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
745
-    {
746
-        // ensure config class is set to something
747
-        $config_class = $this->_set_config_class($config_class, $name);
748
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
749
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
750
-            return null;
751
-        }
752
-        $config_option_name = $this->_generate_config_option_name($section, $name);
753
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
754
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
755
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
756
-            $this->update_addon_option_names();
757
-        }
758
-        // verify the incoming config object but suppress errors
759
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
760
-            $config_obj = new $config_class();
761
-        }
762
-        if (get_option($config_option_name)) {
763
-            EE_Config::log($config_option_name);
764
-            update_option($config_option_name, $config_obj);
765
-            $this->{$section}->{$name} = $config_obj;
766
-            return $this->{$section}->{$name};
767
-        } else {
768
-            // create a wp-option for this config
769
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
770
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
771
-                return $this->{$section}->{$name};
772
-            } else {
773
-                EE_Error::add_error(
774
-                    sprintf(esc_html__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
775
-                    __FILE__,
776
-                    __FUNCTION__,
777
-                    __LINE__
778
-                );
779
-                return null;
780
-            }
781
-        }
782
-    }
783
-
784
-
785
-    /**
786
-     *    update_config
787
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
788
-     *
789
-     * @access    public
790
-     * @param    string                $section
791
-     * @param    string                $name
792
-     * @param    EE_Config_Base|string $config_obj
793
-     * @param    bool                  $throw_errors
794
-     * @return    bool
795
-     */
796
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
797
-    {
798
-        // don't allow config updates during WP heartbeats
799
-        /** @var RequestInterface $request */
800
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
801
-        if ($request->isWordPressHeartbeat()) {
802
-            return false;
803
-        }
804
-        $config_obj = maybe_unserialize($config_obj);
805
-        // get class name of the incoming object
806
-        $config_class = get_class($config_obj);
807
-        // run tests 1-5 and 9 to verify config
808
-        if (
809
-            ! $this->_verify_config_params(
810
-                $section,
811
-                $name,
812
-                $config_class,
813
-                $config_obj,
814
-                array(1, 2, 3, 4, 7, 9)
815
-            )
816
-        ) {
817
-            return false;
818
-        }
819
-        $config_option_name = $this->_generate_config_option_name($section, $name);
820
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
821
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
822
-            // save new config to db
823
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
824
-                return true;
825
-            }
826
-        } else {
827
-            // first check if the record already exists
828
-            $existing_config = get_option($config_option_name);
829
-            $config_obj = serialize($config_obj);
830
-            // just return if db record is already up to date (NOT type safe comparison)
831
-            if ($existing_config == $config_obj) {
832
-                $this->{$section}->{$name} = $config_obj;
833
-                return true;
834
-            } elseif (update_option($config_option_name, $config_obj)) {
835
-                EE_Config::log($config_option_name);
836
-                // update wp-option for this config class
837
-                $this->{$section}->{$name} = $config_obj;
838
-                return true;
839
-            } elseif ($throw_errors) {
840
-                EE_Error::add_error(
841
-                    sprintf(
842
-                        esc_html__(
843
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
844
-                            'event_espresso'
845
-                        ),
846
-                        $config_class,
847
-                        'EE_Config->' . $section . '->' . $name
848
-                    ),
849
-                    __FILE__,
850
-                    __FUNCTION__,
851
-                    __LINE__
852
-                );
853
-            }
854
-        }
855
-        return false;
856
-    }
857
-
858
-
859
-    /**
860
-     *    get_config
861
-     *
862
-     * @access    public
863
-     * @param    string $section
864
-     * @param    string $name
865
-     * @param    string $config_class
866
-     * @return    mixed EE_Config_Base | NULL
867
-     */
868
-    public function get_config($section = '', $name = '', $config_class = '')
869
-    {
870
-        // ensure config class is set to something
871
-        $config_class = $this->_set_config_class($config_class, $name);
872
-        // run tests 1-4, 6 and 7 to verify that all params have been set
873
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
874
-            return null;
875
-        }
876
-        // now test if the requested config object exists, but suppress errors
877
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
878
-            // config already exists, so pass it back
879
-            return $this->{$section}->{$name};
880
-        }
881
-        // load config option from db if it exists
882
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
883
-        // verify the newly retrieved config object, but suppress errors
884
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
885
-            // config is good, so set it and pass it back
886
-            $this->{$section}->{$name} = $config_obj;
887
-            return $this->{$section}->{$name};
888
-        }
889
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
890
-        $config_obj = $this->set_config($section, $name, $config_class);
891
-        // verify the newly created config object
892
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
893
-            return $this->{$section}->{$name};
894
-        } else {
895
-            EE_Error::add_error(
896
-                sprintf(esc_html__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
897
-                __FILE__,
898
-                __FUNCTION__,
899
-                __LINE__
900
-            );
901
-        }
902
-        return null;
903
-    }
904
-
905
-
906
-    /**
907
-     *    get_config_option
908
-     *
909
-     * @access    public
910
-     * @param    string $config_option_name
911
-     * @return    mixed EE_Config_Base | FALSE
912
-     */
913
-    public function get_config_option($config_option_name = '')
914
-    {
915
-        // retrieve the wp-option for this config class.
916
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
917
-        if (empty($config_option)) {
918
-            EE_Config::log($config_option_name . '-NOT-FOUND');
919
-        }
920
-        return $config_option;
921
-    }
922
-
923
-
924
-    /**
925
-     * log
926
-     *
927
-     * @param string $config_option_name
928
-     */
929
-    public static function log($config_option_name = '')
930
-    {
931
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
932
-            $config_log = get_option(EE_Config::LOG_NAME, array());
933
-            /** @var RequestParams $request */
934
-            $request = LoaderFactory::getLoader()->getShared(RequestParams::class);
935
-            $config_log[ (string) microtime(true) ] = array(
936
-                'config_name' => $config_option_name,
937
-                'request'     => $request->requestParams(),
938
-            );
939
-            update_option(EE_Config::LOG_NAME, $config_log);
940
-        }
941
-    }
942
-
943
-
944
-    /**
945
-     * trim_log
946
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
947
-     */
948
-    public static function trim_log()
949
-    {
950
-        if (! EE_Config::logging_enabled()) {
951
-            return;
952
-        }
953
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
954
-        $log_length = count($config_log);
955
-        if ($log_length > EE_Config::LOG_LENGTH) {
956
-            ksort($config_log);
957
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
958
-            update_option(EE_Config::LOG_NAME, $config_log);
959
-        }
960
-    }
961
-
962
-
963
-    /**
964
-     *    get_page_for_posts
965
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
966
-     *    wp-option "page_for_posts", or "posts" if no page is selected
967
-     *
968
-     * @access    public
969
-     * @return    string
970
-     */
971
-    public static function get_page_for_posts()
972
-    {
973
-        $page_for_posts = get_option('page_for_posts');
974
-        if (! $page_for_posts) {
975
-            return 'posts';
976
-        }
977
-        global $wpdb;
978
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
979
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
980
-    }
981
-
982
-
983
-    /**
984
-     *    register_shortcodes_and_modules.
985
-     *    At this point, it's too early to tell if we're maintenance mode or not.
986
-     *    In fact, this is where we give modules a chance to let core know they exist
987
-     *    so they can help trigger maintenance mode if it's needed
988
-     *
989
-     * @access    public
990
-     * @return    void
991
-     */
992
-    public function register_shortcodes_and_modules()
993
-    {
994
-        // allow modules to set hooks for the rest of the system
995
-        EE_Registry::instance()->modules = $this->_register_modules();
996
-    }
997
-
998
-
999
-    /**
1000
-     *    initialize_shortcodes_and_modules
1001
-     *    meaning they can start adding their hooks to get stuff done
1002
-     *
1003
-     * @access    public
1004
-     * @return    void
1005
-     */
1006
-    public function initialize_shortcodes_and_modules()
1007
-    {
1008
-        // allow modules to set hooks for the rest of the system
1009
-        $this->_initialize_modules();
1010
-    }
1011
-
1012
-
1013
-    /**
1014
-     *    widgets_init
1015
-     *
1016
-     * @access private
1017
-     * @return void
1018
-     */
1019
-    public function widgets_init()
1020
-    {
1021
-        // only init widgets on admin pages when not in complete maintenance, and
1022
-        // on frontend when not in any maintenance mode
1023
-        if (
1024
-            ! EE_Maintenance_Mode::instance()->level()
1025
-            || (
1026
-                is_admin()
1027
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1028
-            )
1029
-        ) {
1030
-            // grab list of installed widgets
1031
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1032
-            // filter list of modules to register
1033
-            $widgets_to_register = apply_filters(
1034
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1035
-                $widgets_to_register
1036
-            );
1037
-            if (! empty($widgets_to_register)) {
1038
-                // cycle thru widget folders
1039
-                foreach ($widgets_to_register as $widget_path) {
1040
-                    // add to list of installed widget modules
1041
-                    EE_Config::register_ee_widget($widget_path);
1042
-                }
1043
-            }
1044
-            // filter list of installed modules
1045
-            EE_Registry::instance()->widgets = apply_filters(
1046
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1047
-                EE_Registry::instance()->widgets
1048
-            );
1049
-        }
1050
-    }
1051
-
1052
-
1053
-    /**
1054
-     *    register_ee_widget - makes core aware of this widget
1055
-     *
1056
-     * @access    public
1057
-     * @param    string $widget_path - full path up to and including widget folder
1058
-     * @return    void
1059
-     */
1060
-    public static function register_ee_widget($widget_path = null)
1061
-    {
1062
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1063
-        $widget_ext = '.widget.php';
1064
-        // make all separators match
1065
-        $widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1066
-        // does the file path INCLUDE the actual file name as part of the path ?
1067
-        if (strpos($widget_path, $widget_ext) !== false) {
1068
-            // grab and shortcode file name from directory name and break apart at dots
1069
-            $file_name = explode('.', basename($widget_path));
1070
-            // take first segment from file name pieces and remove class prefix if it exists
1071
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1072
-            // sanitize shortcode directory name
1073
-            $widget = sanitize_key($widget);
1074
-            // now we need to rebuild the shortcode path
1075
-            $widget_path = explode('/', $widget_path);
1076
-            // remove last segment
1077
-            array_pop($widget_path);
1078
-            // glue it back together
1079
-            $widget_path = implode(DS, $widget_path);
1080
-        } else {
1081
-            // grab and sanitize widget directory name
1082
-            $widget = sanitize_key(basename($widget_path));
1083
-        }
1084
-        // create classname from widget directory name
1085
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1086
-        // add class prefix
1087
-        $widget_class = 'EEW_' . $widget;
1088
-        // does the widget exist ?
1089
-        if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1090
-            $msg = sprintf(
1091
-                esc_html__(
1092
-                    'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1093
-                    'event_espresso'
1094
-                ),
1095
-                $widget_class,
1096
-                $widget_path . '/' . $widget_class . $widget_ext
1097
-            );
1098
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1099
-            return;
1100
-        }
1101
-        // load the widget class file
1102
-        require_once($widget_path . '/' . $widget_class . $widget_ext);
1103
-        // verify that class exists
1104
-        if (! class_exists($widget_class)) {
1105
-            $msg = sprintf(esc_html__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1106
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1107
-            return;
1108
-        }
1109
-        register_widget($widget_class);
1110
-        // add to array of registered widgets
1111
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1112
-    }
1113
-
1114
-
1115
-    /**
1116
-     *        _register_modules
1117
-     *
1118
-     * @access private
1119
-     * @return array
1120
-     */
1121
-    private function _register_modules()
1122
-    {
1123
-        // grab list of installed modules
1124
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1125
-        // filter list of modules to register
1126
-        $modules_to_register = apply_filters(
1127
-            'FHEE__EE_Config__register_modules__modules_to_register',
1128
-            $modules_to_register
1129
-        );
1130
-        if (! empty($modules_to_register)) {
1131
-            // loop through folders
1132
-            foreach ($modules_to_register as $module_path) {
1133
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1134
-                if (
1135
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1136
-                    && $module_path !== EE_MODULES . 'gateways'
1137
-                ) {
1138
-                    // add to list of installed modules
1139
-                    EE_Config::register_module($module_path);
1140
-                }
1141
-            }
1142
-        }
1143
-        // filter list of installed modules
1144
-        return apply_filters(
1145
-            'FHEE__EE_Config___register_modules__installed_modules',
1146
-            EE_Registry::instance()->modules
1147
-        );
1148
-    }
1149
-
1150
-
1151
-    /**
1152
-     *    register_module - makes core aware of this module
1153
-     *
1154
-     * @access    public
1155
-     * @param    string $module_path - full path up to and including module folder
1156
-     * @return    bool
1157
-     */
1158
-    public static function register_module($module_path = null)
1159
-    {
1160
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1161
-        $module_ext = '.module.php';
1162
-        // make all separators match
1163
-        $module_path = str_replace(array('\\', '/'), '/', $module_path);
1164
-        // does the file path INCLUDE the actual file name as part of the path ?
1165
-        if (strpos($module_path, $module_ext) !== false) {
1166
-            // grab and shortcode file name from directory name and break apart at dots
1167
-            $module_file = explode('.', basename($module_path));
1168
-            // now we need to rebuild the shortcode path
1169
-            $module_path = explode('/', $module_path);
1170
-            // remove last segment
1171
-            array_pop($module_path);
1172
-            // glue it back together
1173
-            $module_path = implode('/', $module_path) . '/';
1174
-            // take first segment from file name pieces and sanitize it
1175
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1176
-            // ensure class prefix is added
1177
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1178
-        } else {
1179
-            // we need to generate the filename based off of the folder name
1180
-            // grab and sanitize module name
1181
-            $module = strtolower(basename($module_path));
1182
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1183
-            // like trailingslashit()
1184
-            $module_path = rtrim($module_path, '/') . '/';
1185
-            // create classname from module directory name
1186
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1187
-            // add class prefix
1188
-            $module_class = 'EED_' . $module;
1189
-        }
1190
-        // does the module exist ?
1191
-        if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1192
-            $msg = sprintf(
1193
-                esc_html__(
1194
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1195
-                    'event_espresso'
1196
-                ),
1197
-                $module
1198
-            );
1199
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1200
-            return false;
1201
-        }
1202
-        // load the module class file
1203
-        require_once($module_path . $module_class . $module_ext);
1204
-        // verify that class exists
1205
-        if (! class_exists($module_class)) {
1206
-            $msg = sprintf(esc_html__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1207
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1208
-            return false;
1209
-        }
1210
-        // add to array of registered modules
1211
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1212
-        do_action(
1213
-            'AHEE__EE_Config__register_module__complete',
1214
-            $module_class,
1215
-            EE_Registry::instance()->modules->{$module_class}
1216
-        );
1217
-        return true;
1218
-    }
1219
-
1220
-
1221
-    /**
1222
-     *    _initialize_modules
1223
-     *    allow modules to set hooks for the rest of the system
1224
-     *
1225
-     * @access private
1226
-     * @return void
1227
-     */
1228
-    private function _initialize_modules()
1229
-    {
1230
-        // cycle thru shortcode folders
1231
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1232
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1233
-            // which set hooks ?
1234
-            if (is_admin()) {
1235
-                // fire immediately
1236
-                call_user_func(array($module_class, 'set_hooks_admin'));
1237
-            } else {
1238
-                // delay until other systems are online
1239
-                add_action(
1240
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1241
-                    array($module_class, 'set_hooks')
1242
-                );
1243
-            }
1244
-        }
1245
-    }
1246
-
1247
-
1248
-    /**
1249
-     *    register_route - adds module method routes to route_map
1250
-     *
1251
-     * @access    public
1252
-     * @param    string $route       - "pretty" public alias for module method
1253
-     * @param    string $module      - module name (classname without EED_ prefix)
1254
-     * @param    string $method_name - the actual module method to be routed to
1255
-     * @param    string $key         - url param key indicating a route is being called
1256
-     * @return    bool
1257
-     */
1258
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1259
-    {
1260
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1261
-        $module = str_replace('EED_', '', $module);
1262
-        $module_class = 'EED_' . $module;
1263
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1264
-            $msg = sprintf(esc_html__('The module %s has not been registered.', 'event_espresso'), $module);
1265
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1266
-            return false;
1267
-        }
1268
-        if (empty($route)) {
1269
-            $msg = sprintf(esc_html__('No route has been supplied.', 'event_espresso'), $route);
1270
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1271
-            return false;
1272
-        }
1273
-        if (! method_exists('EED_' . $module, $method_name)) {
1274
-            $msg = sprintf(
1275
-                esc_html__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1276
-                $route
1277
-            );
1278
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1279
-            return false;
1280
-        }
1281
-        EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1282
-        return true;
1283
-    }
1284
-
1285
-
1286
-    /**
1287
-     *    get_route - get module method route
1288
-     *
1289
-     * @access    public
1290
-     * @param    string $route - "pretty" public alias for module method
1291
-     * @param    string $key   - url param key indicating a route is being called
1292
-     * @return    string
1293
-     */
1294
-    public static function get_route($route = null, $key = 'ee')
1295
-    {
1296
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1297
-        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1298
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1299
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1300
-        }
1301
-        return null;
1302
-    }
1303
-
1304
-
1305
-    /**
1306
-     *    get_routes - get ALL module method routes
1307
-     *
1308
-     * @access    public
1309
-     * @return    array
1310
-     */
1311
-    public static function get_routes()
1312
-    {
1313
-        return EE_Config::$_module_route_map;
1314
-    }
1315
-
1316
-
1317
-    /**
1318
-     *    register_forward - allows modules to forward request to another module for further processing
1319
-     *
1320
-     * @access    public
1321
-     * @param    string       $route   - "pretty" public alias for module method
1322
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1323
-     *                                 class, allows different forwards to be served based on status
1324
-     * @param    array|string $forward - function name or array( class, method )
1325
-     * @param    string       $key     - url param key indicating a route is being called
1326
-     * @return    bool
1327
-     */
1328
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1329
-    {
1330
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1331
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1332
-            $msg = sprintf(
1333
-                esc_html__('The module route %s for this forward has not been registered.', 'event_espresso'),
1334
-                $route
1335
-            );
1336
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1337
-            return false;
1338
-        }
1339
-        if (empty($forward)) {
1340
-            $msg = sprintf(esc_html__('No forwarding route has been supplied.', 'event_espresso'), $route);
1341
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1342
-            return false;
1343
-        }
1344
-        if (is_array($forward)) {
1345
-            if (! isset($forward[1])) {
1346
-                $msg = sprintf(
1347
-                    esc_html__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1348
-                    $route
1349
-                );
1350
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1351
-                return false;
1352
-            }
1353
-            if (! method_exists($forward[0], $forward[1])) {
1354
-                $msg = sprintf(
1355
-                    esc_html__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1356
-                    $forward[1],
1357
-                    $route
1358
-                );
1359
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
-                return false;
1361
-            }
1362
-        } elseif (! function_exists($forward)) {
1363
-            $msg = sprintf(
1364
-                esc_html__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1365
-                $forward,
1366
-                $route
1367
-            );
1368
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1369
-            return false;
1370
-        }
1371
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1372
-        return true;
1373
-    }
1374
-
1375
-
1376
-    /**
1377
-     *    get_forward - get forwarding route
1378
-     *
1379
-     * @access    public
1380
-     * @param    string  $route  - "pretty" public alias for module method
1381
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1382
-     *                           allows different forwards to be served based on status
1383
-     * @param    string  $key    - url param key indicating a route is being called
1384
-     * @return    string
1385
-     */
1386
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1387
-    {
1388
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1389
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1390
-            return apply_filters(
1391
-                'FHEE__EE_Config__get_forward',
1392
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1393
-                $route,
1394
-                $status
1395
-            );
1396
-        }
1397
-        return null;
1398
-    }
1399
-
1400
-
1401
-    /**
1402
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1403
-     *    results
1404
-     *
1405
-     * @access    public
1406
-     * @param    string  $route  - "pretty" public alias for module method
1407
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1408
-     *                           allows different views to be served based on status
1409
-     * @param    string  $view
1410
-     * @param    string  $key    - url param key indicating a route is being called
1411
-     * @return    bool
1412
-     */
1413
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1414
-    {
1415
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1416
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1417
-            $msg = sprintf(
1418
-                esc_html__('The module route %s for this view has not been registered.', 'event_espresso'),
1419
-                $route
1420
-            );
1421
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1422
-            return false;
1423
-        }
1424
-        if (! is_readable($view)) {
1425
-            $msg = sprintf(
1426
-                esc_html__(
1427
-                    'The %s view file could not be found or is not readable due to file permissions.',
1428
-                    'event_espresso'
1429
-                ),
1430
-                $view
1431
-            );
1432
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1433
-            return false;
1434
-        }
1435
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1436
-        return true;
1437
-    }
1438
-
1439
-
1440
-    /**
1441
-     *    get_view - get view for route and status
1442
-     *
1443
-     * @access    public
1444
-     * @param    string  $route  - "pretty" public alias for module method
1445
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1446
-     *                           allows different views to be served based on status
1447
-     * @param    string  $key    - url param key indicating a route is being called
1448
-     * @return    string
1449
-     */
1450
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1451
-    {
1452
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1453
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1454
-            return apply_filters(
1455
-                'FHEE__EE_Config__get_view',
1456
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1457
-                $route,
1458
-                $status
1459
-            );
1460
-        }
1461
-        return null;
1462
-    }
1463
-
1464
-
1465
-    public function update_addon_option_names()
1466
-    {
1467
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1468
-    }
1469
-
1470
-
1471
-    public function shutdown()
1472
-    {
1473
-        $this->update_addon_option_names();
1474
-    }
1475
-
1476
-
1477
-    /**
1478
-     * @return LegacyShortcodesManager
1479
-     */
1480
-    public static function getLegacyShortcodesManager()
1481
-    {
1482
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1483
-            EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1484
-                LegacyShortcodesManager::class
1485
-            );
1486
-        }
1487
-        return EE_Config::instance()->legacy_shortcodes_manager;
1488
-    }
1489
-
1490
-
1491
-    /**
1492
-     * register_shortcode - makes core aware of this shortcode
1493
-     *
1494
-     * @deprecated 4.9.26
1495
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1496
-     * @return    bool
1497
-     */
1498
-    public static function register_shortcode($shortcode_path = null)
1499
-    {
1500
-        EE_Error::doing_it_wrong(
1501
-            __METHOD__,
1502
-            esc_html__(
1503
-                'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1504
-                'event_espresso'
1505
-            ),
1506
-            '4.9.26'
1507
-        );
1508
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1509
-    }
1510
-}
1511
-
1512
-/**
1513
- * Base class used for config classes. These classes should generally not have
1514
- * magic functions in use, except we'll allow them to magically set and get stuff...
1515
- * basically, they should just be well-defined stdClasses
1516
- */
1517
-class EE_Config_Base
1518
-{
1519
-
1520
-    /**
1521
-     * Utility function for escaping the value of a property and returning.
1522
-     *
1523
-     * @param string $property property name (checks to see if exists).
1524
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1525
-     * @throws EE_Error
1526
-     */
1527
-    public function get_pretty($property)
1528
-    {
1529
-        if (! property_exists($this, $property)) {
1530
-            throw new EE_Error(
1531
-                sprintf(
1532
-                    esc_html__(
1533
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1534
-                        'event_espresso'
1535
-                    ),
1536
-                    get_class($this),
1537
-                    $property
1538
-                )
1539
-            );
1540
-        }
1541
-        // just handling escaping of strings for now.
1542
-        if (is_string($this->{$property})) {
1543
-            return stripslashes($this->{$property});
1544
-        }
1545
-        return $this->{$property};
1546
-    }
1547
-
1548
-
1549
-    public function populate()
1550
-    {
1551
-        // grab defaults via a new instance of this class.
1552
-        $class_name = get_class($this);
1553
-        $defaults = new $class_name();
1554
-        // loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1555
-        // default from our $defaults object.
1556
-        foreach (get_object_vars($defaults) as $property => $value) {
1557
-            if ($this->{$property} === null) {
1558
-                $this->{$property} = $value;
1559
-            }
1560
-        }
1561
-        // cleanup
1562
-        unset($defaults);
1563
-    }
1564
-
1565
-
1566
-    /**
1567
-     *        __isset
1568
-     *
1569
-     * @param $a
1570
-     * @return bool
1571
-     */
1572
-    public function __isset($a)
1573
-    {
1574
-        return false;
1575
-    }
1576
-
1577
-
1578
-    /**
1579
-     *        __unset
1580
-     *
1581
-     * @param $a
1582
-     * @return bool
1583
-     */
1584
-    public function __unset($a)
1585
-    {
1586
-        return false;
1587
-    }
1588
-
1589
-
1590
-    /**
1591
-     *        __clone
1592
-     */
1593
-    public function __clone()
1594
-    {
1595
-    }
1596
-
1597
-
1598
-    /**
1599
-     *        __wakeup
1600
-     */
1601
-    public function __wakeup()
1602
-    {
1603
-    }
1604
-
1605
-
1606
-    /**
1607
-     *        __destruct
1608
-     */
1609
-    public function __destruct()
1610
-    {
1611
-    }
1612
-}
1613
-
1614
-/**
1615
- * Class for defining what's in the EE_Config relating to registration settings
1616
- */
1617
-class EE_Core_Config extends EE_Config_Base
1618
-{
1619
-
1620
-    const OPTION_NAME_UXIP = 'ee_ueip_optin';
1621
-
1622
-
1623
-    public $current_blog_id;
1624
-
1625
-    public $ee_ueip_optin;
1626
-
1627
-    public $ee_ueip_has_notified;
1628
-
1629
-    /**
1630
-     * Not to be confused with the 4 critical page variables (See
1631
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1632
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1633
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1634
-     *
1635
-     * @var array
1636
-     */
1637
-    public $post_shortcodes;
1638
-
1639
-    public $module_route_map;
1640
-
1641
-    public $module_forward_map;
1642
-
1643
-    public $module_view_map;
1644
-
1645
-    /**
1646
-     * The next 4 vars are the IDs of critical EE pages.
1647
-     *
1648
-     * @var int
1649
-     */
1650
-    public $reg_page_id;
1651
-
1652
-    public $txn_page_id;
1653
-
1654
-    public $thank_you_page_id;
1655
-
1656
-    public $cancel_page_id;
1657
-
1658
-    /**
1659
-     * The next 4 vars are the URLs of critical EE pages.
1660
-     *
1661
-     * @var int
1662
-     */
1663
-    public $reg_page_url;
1664
-
1665
-    public $txn_page_url;
1666
-
1667
-    public $thank_you_page_url;
1668
-
1669
-    public $cancel_page_url;
1670
-
1671
-    /**
1672
-     * The next vars relate to the custom slugs for EE CPT routes
1673
-     */
1674
-    public $event_cpt_slug;
1675
-
1676
-    /**
1677
-     * This caches the _ee_ueip_option in case this config is reset in the same
1678
-     * request across blog switches in a multisite context.
1679
-     * Avoids extra queries to the db for this option.
1680
-     *
1681
-     * @var bool
1682
-     */
1683
-    public static $ee_ueip_option;
1684
-
1685
-
1686
-    /**
1687
-     *    class constructor
1688
-     *
1689
-     * @access    public
1690
-     */
1691
-    public function __construct()
1692
-    {
1693
-        // set default organization settings
1694
-        $this->current_blog_id = get_current_blog_id();
1695
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1696
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1697
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1698
-        $this->post_shortcodes = array();
1699
-        $this->module_route_map = array();
1700
-        $this->module_forward_map = array();
1701
-        $this->module_view_map = array();
1702
-        // critical EE page IDs
1703
-        $this->reg_page_id = 0;
1704
-        $this->txn_page_id = 0;
1705
-        $this->thank_you_page_id = 0;
1706
-        $this->cancel_page_id = 0;
1707
-        // critical EE page URLs
1708
-        $this->reg_page_url = '';
1709
-        $this->txn_page_url = '';
1710
-        $this->thank_you_page_url = '';
1711
-        $this->cancel_page_url = '';
1712
-        // cpt slugs
1713
-        $this->event_cpt_slug = esc_html__('events', 'event_espresso');
1714
-        // ueip constant check
1715
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1716
-            $this->ee_ueip_optin = false;
1717
-            $this->ee_ueip_has_notified = true;
1718
-        }
1719
-    }
1720
-
1721
-
1722
-    /**
1723
-     * @return array
1724
-     */
1725
-    public function get_critical_pages_array()
1726
-    {
1727
-        return array(
1728
-            $this->reg_page_id,
1729
-            $this->txn_page_id,
1730
-            $this->thank_you_page_id,
1731
-            $this->cancel_page_id,
1732
-        );
1733
-    }
1734
-
1735
-
1736
-    /**
1737
-     * @return array
1738
-     */
1739
-    public function get_critical_pages_shortcodes_array()
1740
-    {
1741
-        return array(
1742
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1743
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1744
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1745
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1746
-        );
1747
-    }
1748
-
1749
-
1750
-    /**
1751
-     *  gets/returns URL for EE reg_page
1752
-     *
1753
-     * @access    public
1754
-     * @return    string
1755
-     */
1756
-    public function reg_page_url()
1757
-    {
1758
-        if (! $this->reg_page_url) {
1759
-            $this->reg_page_url = add_query_arg(
1760
-                array('uts' => time()),
1761
-                get_permalink($this->reg_page_id)
1762
-            ) . '#checkout';
1763
-        }
1764
-        return $this->reg_page_url;
1765
-    }
1766
-
1767
-
1768
-    /**
1769
-     *  gets/returns URL for EE txn_page
1770
-     *
1771
-     * @param array $query_args like what gets passed to
1772
-     *                          add_query_arg() as the first argument
1773
-     * @access    public
1774
-     * @return    string
1775
-     */
1776
-    public function txn_page_url($query_args = array())
1777
-    {
1778
-        if (! $this->txn_page_url) {
1779
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1780
-        }
1781
-        if ($query_args) {
1782
-            return add_query_arg($query_args, $this->txn_page_url);
1783
-        } else {
1784
-            return $this->txn_page_url;
1785
-        }
1786
-    }
1787
-
1788
-
1789
-    /**
1790
-     *  gets/returns URL for EE thank_you_page
1791
-     *
1792
-     * @param array $query_args like what gets passed to
1793
-     *                          add_query_arg() as the first argument
1794
-     * @access    public
1795
-     * @return    string
1796
-     */
1797
-    public function thank_you_page_url($query_args = array())
1798
-    {
1799
-        if (! $this->thank_you_page_url) {
1800
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1801
-        }
1802
-        if ($query_args) {
1803
-            return add_query_arg($query_args, $this->thank_you_page_url);
1804
-        } else {
1805
-            return $this->thank_you_page_url;
1806
-        }
1807
-    }
1808
-
1809
-
1810
-    /**
1811
-     *  gets/returns URL for EE cancel_page
1812
-     *
1813
-     * @access    public
1814
-     * @return    string
1815
-     */
1816
-    public function cancel_page_url()
1817
-    {
1818
-        if (! $this->cancel_page_url) {
1819
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1820
-        }
1821
-        return $this->cancel_page_url;
1822
-    }
1823
-
1824
-
1825
-    /**
1826
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1827
-     *
1828
-     * @since 4.7.5
1829
-     */
1830
-    protected function _reset_urls()
1831
-    {
1832
-        $this->reg_page_url = '';
1833
-        $this->txn_page_url = '';
1834
-        $this->cancel_page_url = '';
1835
-        $this->thank_you_page_url = '';
1836
-    }
1837
-
1838
-
1839
-    /**
1840
-     * Used to return what the optin value is set for the EE User Experience Program.
1841
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1842
-     * on the main site only.
1843
-     *
1844
-     * @return bool
1845
-     */
1846
-    protected function _get_main_ee_ueip_optin()
1847
-    {
1848
-        // if this is the main site then we can just bypass our direct query.
1849
-        if (is_main_site()) {
1850
-            return get_option(self::OPTION_NAME_UXIP, false);
1851
-        }
1852
-        // is this already cached for this request?  If so use it.
1853
-        if (EE_Core_Config::$ee_ueip_option !== null) {
1854
-            return EE_Core_Config::$ee_ueip_option;
1855
-        }
1856
-        global $wpdb;
1857
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1858
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1859
-        $option = self::OPTION_NAME_UXIP;
1860
-        // set correct table for query
1861
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1862
-        // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1863
-        // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1864
-        // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1865
-        // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1866
-        // for the purpose of caching.
1867
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1868
-        if (false !== $pre) {
1869
-            EE_Core_Config::$ee_ueip_option = $pre;
1870
-            return EE_Core_Config::$ee_ueip_option;
1871
-        }
1872
-        $row = $wpdb->get_row(
1873
-            $wpdb->prepare(
1874
-                "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1875
-                $option
1876
-            )
1877
-        );
1878
-        if (is_object($row)) {
1879
-            $value = $row->option_value;
1880
-        } else { // option does not exist so use default.
1881
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1882
-            return EE_Core_Config::$ee_ueip_option;
1883
-        }
1884
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1885
-        return EE_Core_Config::$ee_ueip_option;
1886
-    }
1887
-
1888
-
1889
-    /**
1890
-     * Utility function for escaping the value of a property and returning.
1891
-     *
1892
-     * @param string $property property name (checks to see if exists).
1893
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1894
-     * @throws EE_Error
1895
-     */
1896
-    public function get_pretty($property)
1897
-    {
1898
-        if ($property === self::OPTION_NAME_UXIP) {
1899
-            return $this->ee_ueip_optin ? 'yes' : 'no';
1900
-        }
1901
-        return parent::get_pretty($property);
1902
-    }
1903
-
1904
-
1905
-    /**
1906
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1907
-     * on the object.
1908
-     *
1909
-     * @return array
1910
-     */
1911
-    public function __sleep()
1912
-    {
1913
-        // reset all url properties
1914
-        $this->_reset_urls();
1915
-        // return what to save to db
1916
-        return array_keys(get_object_vars($this));
1917
-    }
1918
-}
1919
-
1920
-/**
1921
- * Config class for storing info on the Organization
1922
- */
1923
-class EE_Organization_Config extends EE_Config_Base
1924
-{
1925
-
1926
-    /**
1927
-     * @var string $name
1928
-     * eg EE4.1
1929
-     */
1930
-    public $name;
1931
-
1932
-    /**
1933
-     * @var string $address_1
1934
-     * eg 123 Onna Road
1935
-     */
1936
-    public $address_1 = '';
1937
-
1938
-    /**
1939
-     * @var string $address_2
1940
-     * eg PO Box 123
1941
-     */
1942
-    public $address_2 = '';
1943
-
1944
-    /**
1945
-     * @var string $city
1946
-     * eg Inna City
1947
-     */
1948
-    public $city = '';
1949
-
1950
-    /**
1951
-     * @var int $STA_ID
1952
-     * eg 4
1953
-     */
1954
-    public $STA_ID = 0;
1955
-
1956
-    /**
1957
-     * @var string $CNT_ISO
1958
-     * eg US
1959
-     */
1960
-    public $CNT_ISO = '';
1961
-
1962
-    /**
1963
-     * @var string $zip
1964
-     * eg 12345  or V1A 2B3
1965
-     */
1966
-    public $zip = '';
1967
-
1968
-    /**
1969
-     * @var string $email
1970
-     * eg [email protected]
1971
-     */
1972
-    public $email;
1973
-
1974
-    /**
1975
-     * @var string $phone
1976
-     * eg. 111-111-1111
1977
-     */
1978
-    public $phone = '';
1979
-
1980
-    /**
1981
-     * @var string $vat
1982
-     * VAT/Tax Number
1983
-     */
1984
-    public $vat = '';
1985
-
1986
-    /**
1987
-     * @var string $logo_url
1988
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1989
-     */
1990
-    public $logo_url = '';
1991
-
1992
-    /**
1993
-     * The below are all various properties for holding links to organization social network profiles
1994
-     *
1995
-     * @var string
1996
-     */
1997
-    /**
1998
-     * facebook (facebook.com/profile.name)
1999
-     *
2000
-     * @var string
2001
-     */
2002
-    public $facebook = '';
2003
-
2004
-    /**
2005
-     * twitter (twitter.com/twitter_handle)
2006
-     *
2007
-     * @var string
2008
-     */
2009
-    public $twitter = '';
2010
-
2011
-    /**
2012
-     * linkedin (linkedin.com/in/profile_name)
2013
-     *
2014
-     * @var string
2015
-     */
2016
-    public $linkedin = '';
2017
-
2018
-    /**
2019
-     * pinterest (www.pinterest.com/profile_name)
2020
-     *
2021
-     * @var string
2022
-     */
2023
-    public $pinterest = '';
2024
-
2025
-    /**
2026
-     * google+ (google.com/+profileName)
2027
-     *
2028
-     * @var string
2029
-     */
2030
-    public $google = '';
2031
-
2032
-    /**
2033
-     * instagram (instagram.com/handle)
2034
-     *
2035
-     * @var string
2036
-     */
2037
-    public $instagram = '';
2038
-
2039
-
2040
-    /**
2041
-     *    class constructor
2042
-     *
2043
-     * @access    public
2044
-     */
2045
-    public function __construct()
2046
-    {
2047
-        // set default organization settings
2048
-        // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2049
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2050
-        $this->email = get_bloginfo('admin_email');
2051
-    }
2052
-}
2053
-
2054
-/**
2055
- * Class for defining what's in the EE_Config relating to currency
2056
- */
2057
-class EE_Currency_Config extends EE_Config_Base
2058
-{
2059
-
2060
-    /**
2061
-     * @var string $code
2062
-     * eg 'US'
2063
-     */
2064
-    public $code;
2065
-
2066
-    /**
2067
-     * @var string $name
2068
-     * eg 'Dollar'
2069
-     */
2070
-    public $name;
2071
-
2072
-    /**
2073
-     * plural name
2074
-     *
2075
-     * @var string $plural
2076
-     * eg 'Dollars'
2077
-     */
2078
-    public $plural;
2079
-
2080
-    /**
2081
-     * currency sign
2082
-     *
2083
-     * @var string $sign
2084
-     * eg '$'
2085
-     */
2086
-    public $sign;
2087
-
2088
-    /**
2089
-     * Whether the currency sign should come before the number or not
2090
-     *
2091
-     * @var boolean $sign_b4
2092
-     */
2093
-    public $sign_b4;
2094
-
2095
-    /**
2096
-     * How many digits should come after the decimal place
2097
-     *
2098
-     * @var int $dec_plc
2099
-     */
2100
-    public $dec_plc;
2101
-
2102
-    /**
2103
-     * Symbol to use for decimal mark
2104
-     *
2105
-     * @var string $dec_mrk
2106
-     * eg '.'
2107
-     */
2108
-    public $dec_mrk;
2109
-
2110
-    /**
2111
-     * Symbol to use for thousands
2112
-     *
2113
-     * @var string $thsnds
2114
-     * eg ','
2115
-     */
2116
-    public $thsnds;
2117
-
2118
-
2119
-    /**
2120
-     *    class constructor
2121
-     *
2122
-     * @access    public
2123
-     * @param string $CNT_ISO
2124
-     * @throws EE_Error
2125
-     * @throws ReflectionException
2126
-     */
2127
-    public function __construct($CNT_ISO = '')
2128
-    {
2129
-        /** @var TableAnalysis $table_analysis */
2130
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2131
-        // get country code from organization settings or use default
2132
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2133
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2134
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2135
-            : '';
2136
-        // but override if requested
2137
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2138
-        // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2139
-        if (
2140
-            ! empty($CNT_ISO)
2141
-            && EE_Maintenance_Mode::instance()->models_can_query()
2142
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2143
-        ) {
2144
-            // retrieve the country settings from the db, just in case they have been customized
2145
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2146
-            if ($country instanceof EE_Country) {
2147
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2148
-                $this->name = $country->currency_name_single();    // Dollar
2149
-                $this->plural = $country->currency_name_plural();    // Dollars
2150
-                $this->sign = $country->currency_sign();            // currency sign: $
2151
-                $this->sign_b4 = $country->currency_sign_before(
2152
-                );        // currency sign before or after: $TRUE  or  FALSE$
2153
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2154
-                $this->dec_mrk = $country->currency_decimal_mark(
2155
-                );    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2156
-                $this->thsnds = $country->currency_thousands_separator(
2157
-                );    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2158
-            }
2159
-        }
2160
-        // fallback to hardcoded defaults, in case the above failed
2161
-        if (empty($this->code)) {
2162
-            // set default currency settings
2163
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2164
-            $this->name = esc_html__('Dollar', 'event_espresso');    // Dollar
2165
-            $this->plural = esc_html__('Dollars', 'event_espresso');    // Dollars
2166
-            $this->sign = '$';    // currency sign: $
2167
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2168
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2169
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2170
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2171
-        }
2172
-    }
2173
-}
2174
-
2175
-/**
2176
- * Class for defining what's in the EE_Config relating to registration settings
2177
- */
2178
-class EE_Registration_Config extends EE_Config_Base
2179
-{
2180
-
2181
-    /**
2182
-     * Default registration status
2183
-     *
2184
-     * @var string $default_STS_ID
2185
-     * eg 'RPP'
2186
-     */
2187
-    public $default_STS_ID;
2188
-
2189
-    /**
2190
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2191
-     * registrations)
2192
-     *
2193
-     * @var int
2194
-     */
2195
-    public $default_maximum_number_of_tickets;
2196
-
2197
-    /**
2198
-     * level of validation to apply to email addresses
2199
-     *
2200
-     * @var string $email_validation_level
2201
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2202
-     */
2203
-    public $email_validation_level;
2204
-
2205
-    /**
2206
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2207
-     *
2208
-     * @var boolean $show_pending_payment_options
2209
-     */
2210
-    public $show_pending_payment_options;
2211
-
2212
-    /**
2213
-     * Whether to skip the registration confirmation page
2214
-     *
2215
-     * @var boolean $skip_reg_confirmation
2216
-     */
2217
-    public $skip_reg_confirmation;
2218
-
2219
-    /**
2220
-     * an array of SPCO reg steps where:
2221
-     *        the keys denotes the reg step order
2222
-     *        each element consists of an array with the following elements:
2223
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2224
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2225
-     *            "slug" => the URL param used to trigger the reg step
2226
-     *
2227
-     * @var array $reg_steps
2228
-     */
2229
-    public $reg_steps;
2230
-
2231
-    /**
2232
-     * Whether registration confirmation should be the last page of SPCO
2233
-     *
2234
-     * @var boolean $reg_confirmation_last
2235
-     */
2236
-    public $reg_confirmation_last;
2237
-
2238
-    /**
2239
-     * Whether or not to enable the EE Bot Trap
2240
-     *
2241
-     * @var boolean $use_bot_trap
2242
-     */
2243
-    public $use_bot_trap;
2244
-
2245
-    /**
2246
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2247
-     *
2248
-     * @var boolean $use_encryption
2249
-     */
2250
-    public $use_encryption;
2251
-
2252
-    /**
2253
-     * Whether or not to use ReCaptcha
2254
-     *
2255
-     * @var boolean $use_captcha
2256
-     */
2257
-    public $use_captcha;
2258
-
2259
-    /**
2260
-     * ReCaptcha Theme
2261
-     *
2262
-     * @var string $recaptcha_theme
2263
-     *    options: 'dark', 'light', 'invisible'
2264
-     */
2265
-    public $recaptcha_theme;
2266
-
2267
-    /**
2268
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2269
-     *
2270
-     * @var string $recaptcha_badge
2271
-     *    options: 'bottomright', 'bottomleft', 'inline'
2272
-     */
2273
-    public $recaptcha_badge;
22
+	const OPTION_NAME = 'ee_config';
23
+
24
+	const LOG_NAME = 'ee_config_log';
25
+
26
+	const LOG_LENGTH = 100;
27
+
28
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
29
+
30
+	/**
31
+	 *    instance of the EE_Config object
32
+	 *
33
+	 * @var    EE_Config $_instance
34
+	 * @access    private
35
+	 */
36
+	private static $_instance;
37
+
38
+	/**
39
+	 * @var boolean $_logging_enabled
40
+	 */
41
+	private static $_logging_enabled = false;
42
+
43
+	/**
44
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
45
+	 */
46
+	private $legacy_shortcodes_manager;
47
+
48
+	/**
49
+	 * An StdClass whose property names are addon slugs,
50
+	 * and values are their config classes
51
+	 *
52
+	 * @var StdClass
53
+	 */
54
+	public $addons;
55
+
56
+	/**
57
+	 * @var EE_Admin_Config
58
+	 */
59
+	public $admin;
60
+
61
+	/**
62
+	 * @var EE_Core_Config
63
+	 */
64
+	public $core;
65
+
66
+	/**
67
+	 * @var EE_Currency_Config
68
+	 */
69
+	public $currency;
70
+
71
+	/**
72
+	 * @var EE_Organization_Config
73
+	 */
74
+	public $organization;
75
+
76
+	/**
77
+	 * @var EE_Registration_Config
78
+	 */
79
+	public $registration;
80
+
81
+	/**
82
+	 * @var EE_Template_Config
83
+	 */
84
+	public $template_settings;
85
+
86
+	/**
87
+	 * Holds EE environment values.
88
+	 *
89
+	 * @var EE_Environment_Config
90
+	 */
91
+	public $environment;
92
+
93
+	/**
94
+	 * settings pertaining to Google maps
95
+	 *
96
+	 * @var EE_Map_Config
97
+	 */
98
+	public $map_settings;
99
+
100
+	/**
101
+	 * settings pertaining to Taxes
102
+	 *
103
+	 * @var EE_Tax_Config
104
+	 */
105
+	public $tax_settings;
106
+
107
+	/**
108
+	 * Settings pertaining to global messages settings.
109
+	 *
110
+	 * @var EE_Messages_Config
111
+	 */
112
+	public $messages;
113
+
114
+	/**
115
+	 * @deprecated
116
+	 * @var EE_Gateway_Config
117
+	 */
118
+	public $gateway;
119
+
120
+	/**
121
+	 * @var    array $_addon_option_names
122
+	 * @access    private
123
+	 */
124
+	private $_addon_option_names = array();
125
+
126
+	/**
127
+	 * @var    array $_module_route_map
128
+	 * @access    private
129
+	 */
130
+	private static $_module_route_map = array();
131
+
132
+	/**
133
+	 * @var    array $_module_forward_map
134
+	 * @access    private
135
+	 */
136
+	private static $_module_forward_map = array();
137
+
138
+	/**
139
+	 * @var    array $_module_view_map
140
+	 * @access    private
141
+	 */
142
+	private static $_module_view_map = array();
143
+
144
+
145
+	/**
146
+	 * @singleton method used to instantiate class object
147
+	 * @access    public
148
+	 * @return EE_Config instance
149
+	 */
150
+	public static function instance()
151
+	{
152
+		// check if class object is instantiated, and instantiated properly
153
+		if (! self::$_instance instanceof EE_Config) {
154
+			self::$_instance = new self();
155
+		}
156
+		return self::$_instance;
157
+	}
158
+
159
+
160
+	/**
161
+	 * Resets the config
162
+	 *
163
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
164
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
165
+	 *                               reflect its state in the database
166
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
167
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
168
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
169
+	 *                               site was put into maintenance mode)
170
+	 * @return EE_Config
171
+	 */
172
+	public static function reset($hard_reset = false, $reinstantiate = true)
173
+	{
174
+		if (self::$_instance instanceof EE_Config) {
175
+			if ($hard_reset) {
176
+				self::$_instance->legacy_shortcodes_manager = null;
177
+				self::$_instance->_addon_option_names = array();
178
+				self::$_instance->_initialize_config();
179
+				self::$_instance->update_espresso_config();
180
+			}
181
+			self::$_instance->update_addon_option_names();
182
+		}
183
+		self::$_instance = null;
184
+		// we don't need to reset the static properties imo because those should
185
+		// only change when a module is added or removed. Currently we don't
186
+		// support removing a module during a request when it previously existed
187
+		if ($reinstantiate) {
188
+			return self::instance();
189
+		} else {
190
+			return null;
191
+		}
192
+	}
193
+
194
+
195
+	/**
196
+	 *    class constructor
197
+	 *
198
+	 * @access    private
199
+	 */
200
+	private function __construct()
201
+	{
202
+		do_action('AHEE__EE_Config__construct__begin', $this);
203
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
204
+		// setup empty config classes
205
+		$this->_initialize_config();
206
+		// load existing EE site settings
207
+		$this->_load_core_config();
208
+		// confirm everything loaded correctly and set filtered defaults if not
209
+		$this->_verify_config();
210
+		//  register shortcodes and modules
211
+		add_action(
212
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
213
+			array($this, 'register_shortcodes_and_modules'),
214
+			999
215
+		);
216
+		//  initialize shortcodes and modules
217
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
218
+		// register widgets
219
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
220
+		// shutdown
221
+		add_action('shutdown', array($this, 'shutdown'), 10);
222
+		// construct__end hook
223
+		do_action('AHEE__EE_Config__construct__end', $this);
224
+		// hardcoded hack
225
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
226
+	}
227
+
228
+
229
+	/**
230
+	 * @return boolean
231
+	 */
232
+	public static function logging_enabled()
233
+	{
234
+		return self::$_logging_enabled;
235
+	}
236
+
237
+
238
+	/**
239
+	 * use to get the current theme if needed from static context
240
+	 *
241
+	 * @return string current theme set.
242
+	 */
243
+	public static function get_current_theme()
244
+	{
245
+		return isset(self::$_instance->template_settings->current_espresso_theme)
246
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
247
+	}
248
+
249
+
250
+	/**
251
+	 *        _initialize_config
252
+	 *
253
+	 * @access private
254
+	 * @return void
255
+	 */
256
+	private function _initialize_config()
257
+	{
258
+		EE_Config::trim_log();
259
+		// set defaults
260
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
261
+		$this->addons = new stdClass();
262
+		// set _module_route_map
263
+		EE_Config::$_module_route_map = array();
264
+		// set _module_forward_map
265
+		EE_Config::$_module_forward_map = array();
266
+		// set _module_view_map
267
+		EE_Config::$_module_view_map = array();
268
+	}
269
+
270
+
271
+	/**
272
+	 *        load core plugin configuration
273
+	 *
274
+	 * @access private
275
+	 * @return void
276
+	 */
277
+	private function _load_core_config()
278
+	{
279
+		// load_core_config__start hook
280
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
281
+		$espresso_config = $this->get_espresso_config();
282
+		foreach ($espresso_config as $config => $settings) {
283
+			// load_core_config__start hook
284
+			$settings = apply_filters(
285
+				'FHEE__EE_Config___load_core_config__config_settings',
286
+				$settings,
287
+				$config,
288
+				$this
289
+			);
290
+			if (is_object($settings) && property_exists($this, $config)) {
291
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
292
+				// call configs populate method to ensure any defaults are set for empty values.
293
+				if (method_exists($settings, 'populate')) {
294
+					$this->{$config}->populate();
295
+				}
296
+				if (method_exists($settings, 'do_hooks')) {
297
+					$this->{$config}->do_hooks();
298
+				}
299
+			}
300
+		}
301
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
302
+			$this->update_espresso_config();
303
+		}
304
+		// load_core_config__end hook
305
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
306
+	}
307
+
308
+
309
+	/**
310
+	 *    _verify_config
311
+	 *
312
+	 * @access    protected
313
+	 * @return    void
314
+	 */
315
+	protected function _verify_config()
316
+	{
317
+		$this->core = $this->core instanceof EE_Core_Config
318
+			? $this->core
319
+			: new EE_Core_Config();
320
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
321
+		$this->organization = $this->organization instanceof EE_Organization_Config
322
+			? $this->organization
323
+			: new EE_Organization_Config();
324
+		$this->organization = apply_filters(
325
+			'FHEE__EE_Config___initialize_config__organization',
326
+			$this->organization
327
+		);
328
+		$this->currency = $this->currency instanceof EE_Currency_Config
329
+			? $this->currency
330
+			: new EE_Currency_Config();
331
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
332
+		$this->registration = $this->registration instanceof EE_Registration_Config
333
+			? $this->registration
334
+			: new EE_Registration_Config();
335
+		$this->registration = apply_filters(
336
+			'FHEE__EE_Config___initialize_config__registration',
337
+			$this->registration
338
+		);
339
+		$this->admin = $this->admin instanceof EE_Admin_Config
340
+			? $this->admin
341
+			: new EE_Admin_Config();
342
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
343
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
344
+			? $this->template_settings
345
+			: new EE_Template_Config();
346
+		$this->template_settings = apply_filters(
347
+			'FHEE__EE_Config___initialize_config__template_settings',
348
+			$this->template_settings
349
+		);
350
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
351
+			? $this->map_settings
352
+			: new EE_Map_Config();
353
+		$this->map_settings = apply_filters(
354
+			'FHEE__EE_Config___initialize_config__map_settings',
355
+			$this->map_settings
356
+		);
357
+		$this->environment = $this->environment instanceof EE_Environment_Config
358
+			? $this->environment
359
+			: new EE_Environment_Config();
360
+		$this->environment = apply_filters(
361
+			'FHEE__EE_Config___initialize_config__environment',
362
+			$this->environment
363
+		);
364
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
365
+			? $this->tax_settings
366
+			: new EE_Tax_Config();
367
+		$this->tax_settings = apply_filters(
368
+			'FHEE__EE_Config___initialize_config__tax_settings',
369
+			$this->tax_settings
370
+		);
371
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
372
+		$this->messages = $this->messages instanceof EE_Messages_Config
373
+			? $this->messages
374
+			: new EE_Messages_Config();
375
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
376
+			? $this->gateway
377
+			: new EE_Gateway_Config();
378
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
379
+		$this->legacy_shortcodes_manager = null;
380
+	}
381
+
382
+
383
+	/**
384
+	 *    get_espresso_config
385
+	 *
386
+	 * @access    public
387
+	 * @return    array of espresso config stuff
388
+	 */
389
+	public function get_espresso_config()
390
+	{
391
+		// grab espresso configuration
392
+		return apply_filters(
393
+			'FHEE__EE_Config__get_espresso_config__CFG',
394
+			get_option(EE_Config::OPTION_NAME, array())
395
+		);
396
+	}
397
+
398
+
399
+	/**
400
+	 *    double_check_config_comparison
401
+	 *
402
+	 * @access    public
403
+	 * @param string $option
404
+	 * @param        $old_value
405
+	 * @param        $value
406
+	 */
407
+	public function double_check_config_comparison($option = '', $old_value, $value)
408
+	{
409
+		// make sure we're checking the ee config
410
+		if ($option === EE_Config::OPTION_NAME) {
411
+			// run a loose comparison of the old value against the new value for type and properties,
412
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
413
+			if ($value != $old_value) {
414
+				// if they are NOT the same, then remove the hook,
415
+				// which means the subsequent update results will be based solely on the update query results
416
+				// the reason we do this is because, as stated above,
417
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
418
+				// this happens PRIOR to serialization and any subsequent update.
419
+				// If values are found to match their previous old value,
420
+				// then WP bails before performing any update.
421
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
422
+				// it just pulled from the db, with the one being passed to it (which will not match).
423
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
424
+				// MySQL MAY ALSO NOT perform the update because
425
+				// the string it sees in the db looks the same as the new one it has been passed!!!
426
+				// This results in the query returning an "affected rows" value of ZERO,
427
+				// which gets returned immediately by WP update_option and looks like an error.
428
+				remove_action('update_option', array($this, 'check_config_updated'));
429
+			}
430
+		}
431
+	}
432
+
433
+
434
+	/**
435
+	 *    update_espresso_config
436
+	 *
437
+	 * @access   public
438
+	 */
439
+	protected function _reset_espresso_addon_config()
440
+	{
441
+		$this->_addon_option_names = array();
442
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
443
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
444
+			if ($addon_config_obj instanceof EE_Config_Base) {
445
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
446
+			}
447
+			$this->addons->{$addon_name} = null;
448
+		}
449
+	}
450
+
451
+
452
+	/**
453
+	 *    update_espresso_config
454
+	 *
455
+	 * @access   public
456
+	 * @param   bool $add_success
457
+	 * @param   bool $add_error
458
+	 * @return   bool
459
+	 */
460
+	public function update_espresso_config($add_success = false, $add_error = true)
461
+	{
462
+		// don't allow config updates during WP heartbeats
463
+		/** @var RequestInterface $request */
464
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
465
+		if ($request->isWordPressHeartbeat()) {
466
+			return false;
467
+		}
468
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
469
+		// $clone = clone( self::$_instance );
470
+		// self::$_instance = NULL;
471
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
472
+		$this->_reset_espresso_addon_config();
473
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
474
+		// but BEFORE the actual update occurs
475
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
476
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
477
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
478
+		$this->legacy_shortcodes_manager = null;
479
+		// now update "ee_config"
480
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
481
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
482
+		EE_Config::log(EE_Config::OPTION_NAME);
483
+		// if not saved... check if the hook we just added still exists;
484
+		// if it does, it means one of two things:
485
+		// that update_option bailed at the($value === $old_value) conditional,
486
+		// or...
487
+		// the db update query returned 0 rows affected
488
+		// (probably because the data  value was the same from it's perspective)
489
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
490
+		// but just means no update occurred, so don't display an error to the user.
491
+		// BUT... if update_option returns FALSE, AND the hook is missing,
492
+		// then it means that something truly went wrong
493
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
494
+		// remove our action since we don't want it in the system anymore
495
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
496
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
497
+		// self::$_instance = $clone;
498
+		// unset( $clone );
499
+		// if config remains the same or was updated successfully
500
+		if ($saved) {
501
+			if ($add_success) {
502
+				EE_Error::add_success(
503
+					esc_html__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
504
+					__FILE__,
505
+					__FUNCTION__,
506
+					__LINE__
507
+				);
508
+			}
509
+			return true;
510
+		} else {
511
+			if ($add_error) {
512
+				EE_Error::add_error(
513
+					esc_html__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
514
+					__FILE__,
515
+					__FUNCTION__,
516
+					__LINE__
517
+				);
518
+			}
519
+			return false;
520
+		}
521
+	}
522
+
523
+
524
+	/**
525
+	 *    _verify_config_params
526
+	 *
527
+	 * @access    private
528
+	 * @param    string         $section
529
+	 * @param    string         $name
530
+	 * @param    string         $config_class
531
+	 * @param    EE_Config_Base $config_obj
532
+	 * @param    array          $tests_to_run
533
+	 * @param    bool           $display_errors
534
+	 * @return    bool    TRUE on success, FALSE on fail
535
+	 */
536
+	private function _verify_config_params(
537
+		$section = '',
538
+		$name = '',
539
+		$config_class = '',
540
+		$config_obj = null,
541
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
542
+		$display_errors = true
543
+	) {
544
+		try {
545
+			foreach ($tests_to_run as $test) {
546
+				switch ($test) {
547
+					// TEST #1 : check that section was set
548
+					case 1:
549
+						if (empty($section)) {
550
+							if ($display_errors) {
551
+								throw new EE_Error(
552
+									sprintf(
553
+										esc_html__(
554
+											'No configuration section has been provided while attempting to save "%s".',
555
+											'event_espresso'
556
+										),
557
+										$config_class
558
+									)
559
+								);
560
+							}
561
+							return false;
562
+						}
563
+						break;
564
+					// TEST #2 : check that settings section exists
565
+					case 2:
566
+						if (! isset($this->{$section})) {
567
+							if ($display_errors) {
568
+								throw new EE_Error(
569
+									sprintf(
570
+										esc_html__('The "%s" configuration section does not exist.', 'event_espresso'),
571
+										$section
572
+									)
573
+								);
574
+							}
575
+							return false;
576
+						}
577
+						break;
578
+					// TEST #3 : check that section is the proper format
579
+					case 3:
580
+						if (
581
+							! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
582
+						) {
583
+							if ($display_errors) {
584
+								throw new EE_Error(
585
+									sprintf(
586
+										esc_html__(
587
+											'The "%s" configuration settings have not been formatted correctly.',
588
+											'event_espresso'
589
+										),
590
+										$section
591
+									)
592
+								);
593
+							}
594
+							return false;
595
+						}
596
+						break;
597
+					// TEST #4 : check that config section name has been set
598
+					case 4:
599
+						if (empty($name)) {
600
+							if ($display_errors) {
601
+								throw new EE_Error(
602
+									esc_html__(
603
+										'No name has been provided for the specific configuration section.',
604
+										'event_espresso'
605
+									)
606
+								);
607
+							}
608
+							return false;
609
+						}
610
+						break;
611
+					// TEST #5 : check that a config class name has been set
612
+					case 5:
613
+						if (empty($config_class)) {
614
+							if ($display_errors) {
615
+								throw new EE_Error(
616
+									esc_html__(
617
+										'No class name has been provided for the specific configuration section.',
618
+										'event_espresso'
619
+									)
620
+								);
621
+							}
622
+							return false;
623
+						}
624
+						break;
625
+					// TEST #6 : verify config class is accessible
626
+					case 6:
627
+						if (! class_exists($config_class)) {
628
+							if ($display_errors) {
629
+								throw new EE_Error(
630
+									sprintf(
631
+										esc_html__(
632
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
633
+											'event_espresso'
634
+										),
635
+										$config_class
636
+									)
637
+								);
638
+							}
639
+							return false;
640
+						}
641
+						break;
642
+					// TEST #7 : check that config has even been set
643
+					case 7:
644
+						if (! isset($this->{$section}->{$name})) {
645
+							if ($display_errors) {
646
+								throw new EE_Error(
647
+									sprintf(
648
+										esc_html__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
649
+										$section,
650
+										$name
651
+									)
652
+								);
653
+							}
654
+							return false;
655
+						} else {
656
+							// and make sure it's not serialized
657
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
658
+						}
659
+						break;
660
+					// TEST #8 : check that config is the requested type
661
+					case 8:
662
+						if (! $this->{$section}->{$name} instanceof $config_class) {
663
+							if ($display_errors) {
664
+								throw new EE_Error(
665
+									sprintf(
666
+										esc_html__(
667
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
668
+											'event_espresso'
669
+										),
670
+										$section,
671
+										$name,
672
+										$config_class
673
+									)
674
+								);
675
+							}
676
+							return false;
677
+						}
678
+						break;
679
+					// TEST #9 : verify config object
680
+					case 9:
681
+						if (! $config_obj instanceof EE_Config_Base) {
682
+							if ($display_errors) {
683
+								throw new EE_Error(
684
+									sprintf(
685
+										esc_html__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
686
+										print_r($config_obj, true)
687
+									)
688
+								);
689
+							}
690
+							return false;
691
+						}
692
+						break;
693
+				}
694
+			}
695
+		} catch (EE_Error $e) {
696
+			$e->get_error();
697
+		}
698
+		// you have successfully run the gauntlet
699
+		return true;
700
+	}
701
+
702
+
703
+	/**
704
+	 *    _generate_config_option_name
705
+	 *
706
+	 * @access        protected
707
+	 * @param        string $section
708
+	 * @param        string $name
709
+	 * @return        string
710
+	 */
711
+	private function _generate_config_option_name($section = '', $name = '')
712
+	{
713
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
714
+	}
715
+
716
+
717
+	/**
718
+	 *    _set_config_class
719
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
720
+	 *
721
+	 * @access    private
722
+	 * @param    string $config_class
723
+	 * @param    string $name
724
+	 * @return    string
725
+	 */
726
+	private function _set_config_class($config_class = '', $name = '')
727
+	{
728
+		return ! empty($config_class)
729
+			? $config_class
730
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
731
+	}
732
+
733
+
734
+	/**
735
+	 *    set_config
736
+	 *
737
+	 * @access    protected
738
+	 * @param    string         $section
739
+	 * @param    string         $name
740
+	 * @param    string         $config_class
741
+	 * @param    EE_Config_Base $config_obj
742
+	 * @return    EE_Config_Base
743
+	 */
744
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
745
+	{
746
+		// ensure config class is set to something
747
+		$config_class = $this->_set_config_class($config_class, $name);
748
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
749
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
750
+			return null;
751
+		}
752
+		$config_option_name = $this->_generate_config_option_name($section, $name);
753
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
754
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
755
+			$this->_addon_option_names[ $config_option_name ] = $config_class;
756
+			$this->update_addon_option_names();
757
+		}
758
+		// verify the incoming config object but suppress errors
759
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
760
+			$config_obj = new $config_class();
761
+		}
762
+		if (get_option($config_option_name)) {
763
+			EE_Config::log($config_option_name);
764
+			update_option($config_option_name, $config_obj);
765
+			$this->{$section}->{$name} = $config_obj;
766
+			return $this->{$section}->{$name};
767
+		} else {
768
+			// create a wp-option for this config
769
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
770
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
771
+				return $this->{$section}->{$name};
772
+			} else {
773
+				EE_Error::add_error(
774
+					sprintf(esc_html__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
775
+					__FILE__,
776
+					__FUNCTION__,
777
+					__LINE__
778
+				);
779
+				return null;
780
+			}
781
+		}
782
+	}
783
+
784
+
785
+	/**
786
+	 *    update_config
787
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
788
+	 *
789
+	 * @access    public
790
+	 * @param    string                $section
791
+	 * @param    string                $name
792
+	 * @param    EE_Config_Base|string $config_obj
793
+	 * @param    bool                  $throw_errors
794
+	 * @return    bool
795
+	 */
796
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
797
+	{
798
+		// don't allow config updates during WP heartbeats
799
+		/** @var RequestInterface $request */
800
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
801
+		if ($request->isWordPressHeartbeat()) {
802
+			return false;
803
+		}
804
+		$config_obj = maybe_unserialize($config_obj);
805
+		// get class name of the incoming object
806
+		$config_class = get_class($config_obj);
807
+		// run tests 1-5 and 9 to verify config
808
+		if (
809
+			! $this->_verify_config_params(
810
+				$section,
811
+				$name,
812
+				$config_class,
813
+				$config_obj,
814
+				array(1, 2, 3, 4, 7, 9)
815
+			)
816
+		) {
817
+			return false;
818
+		}
819
+		$config_option_name = $this->_generate_config_option_name($section, $name);
820
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
821
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
822
+			// save new config to db
823
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
824
+				return true;
825
+			}
826
+		} else {
827
+			// first check if the record already exists
828
+			$existing_config = get_option($config_option_name);
829
+			$config_obj = serialize($config_obj);
830
+			// just return if db record is already up to date (NOT type safe comparison)
831
+			if ($existing_config == $config_obj) {
832
+				$this->{$section}->{$name} = $config_obj;
833
+				return true;
834
+			} elseif (update_option($config_option_name, $config_obj)) {
835
+				EE_Config::log($config_option_name);
836
+				// update wp-option for this config class
837
+				$this->{$section}->{$name} = $config_obj;
838
+				return true;
839
+			} elseif ($throw_errors) {
840
+				EE_Error::add_error(
841
+					sprintf(
842
+						esc_html__(
843
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
844
+							'event_espresso'
845
+						),
846
+						$config_class,
847
+						'EE_Config->' . $section . '->' . $name
848
+					),
849
+					__FILE__,
850
+					__FUNCTION__,
851
+					__LINE__
852
+				);
853
+			}
854
+		}
855
+		return false;
856
+	}
857
+
858
+
859
+	/**
860
+	 *    get_config
861
+	 *
862
+	 * @access    public
863
+	 * @param    string $section
864
+	 * @param    string $name
865
+	 * @param    string $config_class
866
+	 * @return    mixed EE_Config_Base | NULL
867
+	 */
868
+	public function get_config($section = '', $name = '', $config_class = '')
869
+	{
870
+		// ensure config class is set to something
871
+		$config_class = $this->_set_config_class($config_class, $name);
872
+		// run tests 1-4, 6 and 7 to verify that all params have been set
873
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
874
+			return null;
875
+		}
876
+		// now test if the requested config object exists, but suppress errors
877
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
878
+			// config already exists, so pass it back
879
+			return $this->{$section}->{$name};
880
+		}
881
+		// load config option from db if it exists
882
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
883
+		// verify the newly retrieved config object, but suppress errors
884
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
885
+			// config is good, so set it and pass it back
886
+			$this->{$section}->{$name} = $config_obj;
887
+			return $this->{$section}->{$name};
888
+		}
889
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
890
+		$config_obj = $this->set_config($section, $name, $config_class);
891
+		// verify the newly created config object
892
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
893
+			return $this->{$section}->{$name};
894
+		} else {
895
+			EE_Error::add_error(
896
+				sprintf(esc_html__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
897
+				__FILE__,
898
+				__FUNCTION__,
899
+				__LINE__
900
+			);
901
+		}
902
+		return null;
903
+	}
904
+
905
+
906
+	/**
907
+	 *    get_config_option
908
+	 *
909
+	 * @access    public
910
+	 * @param    string $config_option_name
911
+	 * @return    mixed EE_Config_Base | FALSE
912
+	 */
913
+	public function get_config_option($config_option_name = '')
914
+	{
915
+		// retrieve the wp-option for this config class.
916
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
917
+		if (empty($config_option)) {
918
+			EE_Config::log($config_option_name . '-NOT-FOUND');
919
+		}
920
+		return $config_option;
921
+	}
922
+
923
+
924
+	/**
925
+	 * log
926
+	 *
927
+	 * @param string $config_option_name
928
+	 */
929
+	public static function log($config_option_name = '')
930
+	{
931
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
932
+			$config_log = get_option(EE_Config::LOG_NAME, array());
933
+			/** @var RequestParams $request */
934
+			$request = LoaderFactory::getLoader()->getShared(RequestParams::class);
935
+			$config_log[ (string) microtime(true) ] = array(
936
+				'config_name' => $config_option_name,
937
+				'request'     => $request->requestParams(),
938
+			);
939
+			update_option(EE_Config::LOG_NAME, $config_log);
940
+		}
941
+	}
942
+
943
+
944
+	/**
945
+	 * trim_log
946
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
947
+	 */
948
+	public static function trim_log()
949
+	{
950
+		if (! EE_Config::logging_enabled()) {
951
+			return;
952
+		}
953
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
954
+		$log_length = count($config_log);
955
+		if ($log_length > EE_Config::LOG_LENGTH) {
956
+			ksort($config_log);
957
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
958
+			update_option(EE_Config::LOG_NAME, $config_log);
959
+		}
960
+	}
961
+
962
+
963
+	/**
964
+	 *    get_page_for_posts
965
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
966
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
967
+	 *
968
+	 * @access    public
969
+	 * @return    string
970
+	 */
971
+	public static function get_page_for_posts()
972
+	{
973
+		$page_for_posts = get_option('page_for_posts');
974
+		if (! $page_for_posts) {
975
+			return 'posts';
976
+		}
977
+		global $wpdb;
978
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
979
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
980
+	}
981
+
982
+
983
+	/**
984
+	 *    register_shortcodes_and_modules.
985
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
986
+	 *    In fact, this is where we give modules a chance to let core know they exist
987
+	 *    so they can help trigger maintenance mode if it's needed
988
+	 *
989
+	 * @access    public
990
+	 * @return    void
991
+	 */
992
+	public function register_shortcodes_and_modules()
993
+	{
994
+		// allow modules to set hooks for the rest of the system
995
+		EE_Registry::instance()->modules = $this->_register_modules();
996
+	}
997
+
998
+
999
+	/**
1000
+	 *    initialize_shortcodes_and_modules
1001
+	 *    meaning they can start adding their hooks to get stuff done
1002
+	 *
1003
+	 * @access    public
1004
+	 * @return    void
1005
+	 */
1006
+	public function initialize_shortcodes_and_modules()
1007
+	{
1008
+		// allow modules to set hooks for the rest of the system
1009
+		$this->_initialize_modules();
1010
+	}
1011
+
1012
+
1013
+	/**
1014
+	 *    widgets_init
1015
+	 *
1016
+	 * @access private
1017
+	 * @return void
1018
+	 */
1019
+	public function widgets_init()
1020
+	{
1021
+		// only init widgets on admin pages when not in complete maintenance, and
1022
+		// on frontend when not in any maintenance mode
1023
+		if (
1024
+			! EE_Maintenance_Mode::instance()->level()
1025
+			|| (
1026
+				is_admin()
1027
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1028
+			)
1029
+		) {
1030
+			// grab list of installed widgets
1031
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1032
+			// filter list of modules to register
1033
+			$widgets_to_register = apply_filters(
1034
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1035
+				$widgets_to_register
1036
+			);
1037
+			if (! empty($widgets_to_register)) {
1038
+				// cycle thru widget folders
1039
+				foreach ($widgets_to_register as $widget_path) {
1040
+					// add to list of installed widget modules
1041
+					EE_Config::register_ee_widget($widget_path);
1042
+				}
1043
+			}
1044
+			// filter list of installed modules
1045
+			EE_Registry::instance()->widgets = apply_filters(
1046
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1047
+				EE_Registry::instance()->widgets
1048
+			);
1049
+		}
1050
+	}
1051
+
1052
+
1053
+	/**
1054
+	 *    register_ee_widget - makes core aware of this widget
1055
+	 *
1056
+	 * @access    public
1057
+	 * @param    string $widget_path - full path up to and including widget folder
1058
+	 * @return    void
1059
+	 */
1060
+	public static function register_ee_widget($widget_path = null)
1061
+	{
1062
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1063
+		$widget_ext = '.widget.php';
1064
+		// make all separators match
1065
+		$widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1066
+		// does the file path INCLUDE the actual file name as part of the path ?
1067
+		if (strpos($widget_path, $widget_ext) !== false) {
1068
+			// grab and shortcode file name from directory name and break apart at dots
1069
+			$file_name = explode('.', basename($widget_path));
1070
+			// take first segment from file name pieces and remove class prefix if it exists
1071
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1072
+			// sanitize shortcode directory name
1073
+			$widget = sanitize_key($widget);
1074
+			// now we need to rebuild the shortcode path
1075
+			$widget_path = explode('/', $widget_path);
1076
+			// remove last segment
1077
+			array_pop($widget_path);
1078
+			// glue it back together
1079
+			$widget_path = implode(DS, $widget_path);
1080
+		} else {
1081
+			// grab and sanitize widget directory name
1082
+			$widget = sanitize_key(basename($widget_path));
1083
+		}
1084
+		// create classname from widget directory name
1085
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1086
+		// add class prefix
1087
+		$widget_class = 'EEW_' . $widget;
1088
+		// does the widget exist ?
1089
+		if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1090
+			$msg = sprintf(
1091
+				esc_html__(
1092
+					'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1093
+					'event_espresso'
1094
+				),
1095
+				$widget_class,
1096
+				$widget_path . '/' . $widget_class . $widget_ext
1097
+			);
1098
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1099
+			return;
1100
+		}
1101
+		// load the widget class file
1102
+		require_once($widget_path . '/' . $widget_class . $widget_ext);
1103
+		// verify that class exists
1104
+		if (! class_exists($widget_class)) {
1105
+			$msg = sprintf(esc_html__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1106
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1107
+			return;
1108
+		}
1109
+		register_widget($widget_class);
1110
+		// add to array of registered widgets
1111
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1112
+	}
1113
+
1114
+
1115
+	/**
1116
+	 *        _register_modules
1117
+	 *
1118
+	 * @access private
1119
+	 * @return array
1120
+	 */
1121
+	private function _register_modules()
1122
+	{
1123
+		// grab list of installed modules
1124
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1125
+		// filter list of modules to register
1126
+		$modules_to_register = apply_filters(
1127
+			'FHEE__EE_Config__register_modules__modules_to_register',
1128
+			$modules_to_register
1129
+		);
1130
+		if (! empty($modules_to_register)) {
1131
+			// loop through folders
1132
+			foreach ($modules_to_register as $module_path) {
1133
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1134
+				if (
1135
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1136
+					&& $module_path !== EE_MODULES . 'gateways'
1137
+				) {
1138
+					// add to list of installed modules
1139
+					EE_Config::register_module($module_path);
1140
+				}
1141
+			}
1142
+		}
1143
+		// filter list of installed modules
1144
+		return apply_filters(
1145
+			'FHEE__EE_Config___register_modules__installed_modules',
1146
+			EE_Registry::instance()->modules
1147
+		);
1148
+	}
1149
+
1150
+
1151
+	/**
1152
+	 *    register_module - makes core aware of this module
1153
+	 *
1154
+	 * @access    public
1155
+	 * @param    string $module_path - full path up to and including module folder
1156
+	 * @return    bool
1157
+	 */
1158
+	public static function register_module($module_path = null)
1159
+	{
1160
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1161
+		$module_ext = '.module.php';
1162
+		// make all separators match
1163
+		$module_path = str_replace(array('\\', '/'), '/', $module_path);
1164
+		// does the file path INCLUDE the actual file name as part of the path ?
1165
+		if (strpos($module_path, $module_ext) !== false) {
1166
+			// grab and shortcode file name from directory name and break apart at dots
1167
+			$module_file = explode('.', basename($module_path));
1168
+			// now we need to rebuild the shortcode path
1169
+			$module_path = explode('/', $module_path);
1170
+			// remove last segment
1171
+			array_pop($module_path);
1172
+			// glue it back together
1173
+			$module_path = implode('/', $module_path) . '/';
1174
+			// take first segment from file name pieces and sanitize it
1175
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1176
+			// ensure class prefix is added
1177
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1178
+		} else {
1179
+			// we need to generate the filename based off of the folder name
1180
+			// grab and sanitize module name
1181
+			$module = strtolower(basename($module_path));
1182
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1183
+			// like trailingslashit()
1184
+			$module_path = rtrim($module_path, '/') . '/';
1185
+			// create classname from module directory name
1186
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1187
+			// add class prefix
1188
+			$module_class = 'EED_' . $module;
1189
+		}
1190
+		// does the module exist ?
1191
+		if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1192
+			$msg = sprintf(
1193
+				esc_html__(
1194
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1195
+					'event_espresso'
1196
+				),
1197
+				$module
1198
+			);
1199
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1200
+			return false;
1201
+		}
1202
+		// load the module class file
1203
+		require_once($module_path . $module_class . $module_ext);
1204
+		// verify that class exists
1205
+		if (! class_exists($module_class)) {
1206
+			$msg = sprintf(esc_html__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1207
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1208
+			return false;
1209
+		}
1210
+		// add to array of registered modules
1211
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1212
+		do_action(
1213
+			'AHEE__EE_Config__register_module__complete',
1214
+			$module_class,
1215
+			EE_Registry::instance()->modules->{$module_class}
1216
+		);
1217
+		return true;
1218
+	}
1219
+
1220
+
1221
+	/**
1222
+	 *    _initialize_modules
1223
+	 *    allow modules to set hooks for the rest of the system
1224
+	 *
1225
+	 * @access private
1226
+	 * @return void
1227
+	 */
1228
+	private function _initialize_modules()
1229
+	{
1230
+		// cycle thru shortcode folders
1231
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1232
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1233
+			// which set hooks ?
1234
+			if (is_admin()) {
1235
+				// fire immediately
1236
+				call_user_func(array($module_class, 'set_hooks_admin'));
1237
+			} else {
1238
+				// delay until other systems are online
1239
+				add_action(
1240
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1241
+					array($module_class, 'set_hooks')
1242
+				);
1243
+			}
1244
+		}
1245
+	}
1246
+
1247
+
1248
+	/**
1249
+	 *    register_route - adds module method routes to route_map
1250
+	 *
1251
+	 * @access    public
1252
+	 * @param    string $route       - "pretty" public alias for module method
1253
+	 * @param    string $module      - module name (classname without EED_ prefix)
1254
+	 * @param    string $method_name - the actual module method to be routed to
1255
+	 * @param    string $key         - url param key indicating a route is being called
1256
+	 * @return    bool
1257
+	 */
1258
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1259
+	{
1260
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1261
+		$module = str_replace('EED_', '', $module);
1262
+		$module_class = 'EED_' . $module;
1263
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1264
+			$msg = sprintf(esc_html__('The module %s has not been registered.', 'event_espresso'), $module);
1265
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1266
+			return false;
1267
+		}
1268
+		if (empty($route)) {
1269
+			$msg = sprintf(esc_html__('No route has been supplied.', 'event_espresso'), $route);
1270
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1271
+			return false;
1272
+		}
1273
+		if (! method_exists('EED_' . $module, $method_name)) {
1274
+			$msg = sprintf(
1275
+				esc_html__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1276
+				$route
1277
+			);
1278
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1279
+			return false;
1280
+		}
1281
+		EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1282
+		return true;
1283
+	}
1284
+
1285
+
1286
+	/**
1287
+	 *    get_route - get module method route
1288
+	 *
1289
+	 * @access    public
1290
+	 * @param    string $route - "pretty" public alias for module method
1291
+	 * @param    string $key   - url param key indicating a route is being called
1292
+	 * @return    string
1293
+	 */
1294
+	public static function get_route($route = null, $key = 'ee')
1295
+	{
1296
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1297
+		$route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1298
+		if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1299
+			return EE_Config::$_module_route_map[ $key ][ $route ];
1300
+		}
1301
+		return null;
1302
+	}
1303
+
1304
+
1305
+	/**
1306
+	 *    get_routes - get ALL module method routes
1307
+	 *
1308
+	 * @access    public
1309
+	 * @return    array
1310
+	 */
1311
+	public static function get_routes()
1312
+	{
1313
+		return EE_Config::$_module_route_map;
1314
+	}
1315
+
1316
+
1317
+	/**
1318
+	 *    register_forward - allows modules to forward request to another module for further processing
1319
+	 *
1320
+	 * @access    public
1321
+	 * @param    string       $route   - "pretty" public alias for module method
1322
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1323
+	 *                                 class, allows different forwards to be served based on status
1324
+	 * @param    array|string $forward - function name or array( class, method )
1325
+	 * @param    string       $key     - url param key indicating a route is being called
1326
+	 * @return    bool
1327
+	 */
1328
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1329
+	{
1330
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1331
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1332
+			$msg = sprintf(
1333
+				esc_html__('The module route %s for this forward has not been registered.', 'event_espresso'),
1334
+				$route
1335
+			);
1336
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1337
+			return false;
1338
+		}
1339
+		if (empty($forward)) {
1340
+			$msg = sprintf(esc_html__('No forwarding route has been supplied.', 'event_espresso'), $route);
1341
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1342
+			return false;
1343
+		}
1344
+		if (is_array($forward)) {
1345
+			if (! isset($forward[1])) {
1346
+				$msg = sprintf(
1347
+					esc_html__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1348
+					$route
1349
+				);
1350
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1351
+				return false;
1352
+			}
1353
+			if (! method_exists($forward[0], $forward[1])) {
1354
+				$msg = sprintf(
1355
+					esc_html__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1356
+					$forward[1],
1357
+					$route
1358
+				);
1359
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
+				return false;
1361
+			}
1362
+		} elseif (! function_exists($forward)) {
1363
+			$msg = sprintf(
1364
+				esc_html__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1365
+				$forward,
1366
+				$route
1367
+			);
1368
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1369
+			return false;
1370
+		}
1371
+		EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1372
+		return true;
1373
+	}
1374
+
1375
+
1376
+	/**
1377
+	 *    get_forward - get forwarding route
1378
+	 *
1379
+	 * @access    public
1380
+	 * @param    string  $route  - "pretty" public alias for module method
1381
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1382
+	 *                           allows different forwards to be served based on status
1383
+	 * @param    string  $key    - url param key indicating a route is being called
1384
+	 * @return    string
1385
+	 */
1386
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1387
+	{
1388
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1389
+		if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1390
+			return apply_filters(
1391
+				'FHEE__EE_Config__get_forward',
1392
+				EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1393
+				$route,
1394
+				$status
1395
+			);
1396
+		}
1397
+		return null;
1398
+	}
1399
+
1400
+
1401
+	/**
1402
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1403
+	 *    results
1404
+	 *
1405
+	 * @access    public
1406
+	 * @param    string  $route  - "pretty" public alias for module method
1407
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1408
+	 *                           allows different views to be served based on status
1409
+	 * @param    string  $view
1410
+	 * @param    string  $key    - url param key indicating a route is being called
1411
+	 * @return    bool
1412
+	 */
1413
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1414
+	{
1415
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1416
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1417
+			$msg = sprintf(
1418
+				esc_html__('The module route %s for this view has not been registered.', 'event_espresso'),
1419
+				$route
1420
+			);
1421
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1422
+			return false;
1423
+		}
1424
+		if (! is_readable($view)) {
1425
+			$msg = sprintf(
1426
+				esc_html__(
1427
+					'The %s view file could not be found or is not readable due to file permissions.',
1428
+					'event_espresso'
1429
+				),
1430
+				$view
1431
+			);
1432
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1433
+			return false;
1434
+		}
1435
+		EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1436
+		return true;
1437
+	}
1438
+
1439
+
1440
+	/**
1441
+	 *    get_view - get view for route and status
1442
+	 *
1443
+	 * @access    public
1444
+	 * @param    string  $route  - "pretty" public alias for module method
1445
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1446
+	 *                           allows different views to be served based on status
1447
+	 * @param    string  $key    - url param key indicating a route is being called
1448
+	 * @return    string
1449
+	 */
1450
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1451
+	{
1452
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1453
+		if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1454
+			return apply_filters(
1455
+				'FHEE__EE_Config__get_view',
1456
+				EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1457
+				$route,
1458
+				$status
1459
+			);
1460
+		}
1461
+		return null;
1462
+	}
1463
+
1464
+
1465
+	public function update_addon_option_names()
1466
+	{
1467
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1468
+	}
1469
+
1470
+
1471
+	public function shutdown()
1472
+	{
1473
+		$this->update_addon_option_names();
1474
+	}
1475
+
1476
+
1477
+	/**
1478
+	 * @return LegacyShortcodesManager
1479
+	 */
1480
+	public static function getLegacyShortcodesManager()
1481
+	{
1482
+		if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1483
+			EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1484
+				LegacyShortcodesManager::class
1485
+			);
1486
+		}
1487
+		return EE_Config::instance()->legacy_shortcodes_manager;
1488
+	}
1489
+
1490
+
1491
+	/**
1492
+	 * register_shortcode - makes core aware of this shortcode
1493
+	 *
1494
+	 * @deprecated 4.9.26
1495
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1496
+	 * @return    bool
1497
+	 */
1498
+	public static function register_shortcode($shortcode_path = null)
1499
+	{
1500
+		EE_Error::doing_it_wrong(
1501
+			__METHOD__,
1502
+			esc_html__(
1503
+				'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1504
+				'event_espresso'
1505
+			),
1506
+			'4.9.26'
1507
+		);
1508
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1509
+	}
1510
+}
2274 1511
 
2275
-    /**
2276
-     * ReCaptcha Type
2277
-     *
2278
-     * @var string $recaptcha_type
2279
-     *    options: 'audio', 'image'
2280
-     */
2281
-    public $recaptcha_type;
1512
+/**
1513
+ * Base class used for config classes. These classes should generally not have
1514
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1515
+ * basically, they should just be well-defined stdClasses
1516
+ */
1517
+class EE_Config_Base
1518
+{
2282 1519
 
2283
-    /**
2284
-     * ReCaptcha language
2285
-     *
2286
-     * @var string $recaptcha_language
2287
-     * eg 'en'
2288
-     */
2289
-    public $recaptcha_language;
1520
+	/**
1521
+	 * Utility function for escaping the value of a property and returning.
1522
+	 *
1523
+	 * @param string $property property name (checks to see if exists).
1524
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1525
+	 * @throws EE_Error
1526
+	 */
1527
+	public function get_pretty($property)
1528
+	{
1529
+		if (! property_exists($this, $property)) {
1530
+			throw new EE_Error(
1531
+				sprintf(
1532
+					esc_html__(
1533
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1534
+						'event_espresso'
1535
+					),
1536
+					get_class($this),
1537
+					$property
1538
+				)
1539
+			);
1540
+		}
1541
+		// just handling escaping of strings for now.
1542
+		if (is_string($this->{$property})) {
1543
+			return stripslashes($this->{$property});
1544
+		}
1545
+		return $this->{$property};
1546
+	}
1547
+
1548
+
1549
+	public function populate()
1550
+	{
1551
+		// grab defaults via a new instance of this class.
1552
+		$class_name = get_class($this);
1553
+		$defaults = new $class_name();
1554
+		// loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1555
+		// default from our $defaults object.
1556
+		foreach (get_object_vars($defaults) as $property => $value) {
1557
+			if ($this->{$property} === null) {
1558
+				$this->{$property} = $value;
1559
+			}
1560
+		}
1561
+		// cleanup
1562
+		unset($defaults);
1563
+	}
1564
+
1565
+
1566
+	/**
1567
+	 *        __isset
1568
+	 *
1569
+	 * @param $a
1570
+	 * @return bool
1571
+	 */
1572
+	public function __isset($a)
1573
+	{
1574
+		return false;
1575
+	}
1576
+
1577
+
1578
+	/**
1579
+	 *        __unset
1580
+	 *
1581
+	 * @param $a
1582
+	 * @return bool
1583
+	 */
1584
+	public function __unset($a)
1585
+	{
1586
+		return false;
1587
+	}
1588
+
1589
+
1590
+	/**
1591
+	 *        __clone
1592
+	 */
1593
+	public function __clone()
1594
+	{
1595
+	}
1596
+
1597
+
1598
+	/**
1599
+	 *        __wakeup
1600
+	 */
1601
+	public function __wakeup()
1602
+	{
1603
+	}
1604
+
1605
+
1606
+	/**
1607
+	 *        __destruct
1608
+	 */
1609
+	public function __destruct()
1610
+	{
1611
+	}
1612
+}
2290 1613
 
2291
-    /**
2292
-     * ReCaptcha public key
2293
-     *
2294
-     * @var string $recaptcha_publickey
2295
-     */
2296
-    public $recaptcha_publickey;
1614
+/**
1615
+ * Class for defining what's in the EE_Config relating to registration settings
1616
+ */
1617
+class EE_Core_Config extends EE_Config_Base
1618
+{
2297 1619
 
2298
-    /**
2299
-     * ReCaptcha private key
2300
-     *
2301
-     * @var string $recaptcha_privatekey
2302
-     */
2303
-    public $recaptcha_privatekey;
1620
+	const OPTION_NAME_UXIP = 'ee_ueip_optin';
1621
+
1622
+
1623
+	public $current_blog_id;
1624
+
1625
+	public $ee_ueip_optin;
1626
+
1627
+	public $ee_ueip_has_notified;
1628
+
1629
+	/**
1630
+	 * Not to be confused with the 4 critical page variables (See
1631
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1632
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1633
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1634
+	 *
1635
+	 * @var array
1636
+	 */
1637
+	public $post_shortcodes;
1638
+
1639
+	public $module_route_map;
1640
+
1641
+	public $module_forward_map;
1642
+
1643
+	public $module_view_map;
1644
+
1645
+	/**
1646
+	 * The next 4 vars are the IDs of critical EE pages.
1647
+	 *
1648
+	 * @var int
1649
+	 */
1650
+	public $reg_page_id;
1651
+
1652
+	public $txn_page_id;
1653
+
1654
+	public $thank_you_page_id;
1655
+
1656
+	public $cancel_page_id;
1657
+
1658
+	/**
1659
+	 * The next 4 vars are the URLs of critical EE pages.
1660
+	 *
1661
+	 * @var int
1662
+	 */
1663
+	public $reg_page_url;
1664
+
1665
+	public $txn_page_url;
1666
+
1667
+	public $thank_you_page_url;
1668
+
1669
+	public $cancel_page_url;
1670
+
1671
+	/**
1672
+	 * The next vars relate to the custom slugs for EE CPT routes
1673
+	 */
1674
+	public $event_cpt_slug;
1675
+
1676
+	/**
1677
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1678
+	 * request across blog switches in a multisite context.
1679
+	 * Avoids extra queries to the db for this option.
1680
+	 *
1681
+	 * @var bool
1682
+	 */
1683
+	public static $ee_ueip_option;
1684
+
1685
+
1686
+	/**
1687
+	 *    class constructor
1688
+	 *
1689
+	 * @access    public
1690
+	 */
1691
+	public function __construct()
1692
+	{
1693
+		// set default organization settings
1694
+		$this->current_blog_id = get_current_blog_id();
1695
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1696
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1697
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1698
+		$this->post_shortcodes = array();
1699
+		$this->module_route_map = array();
1700
+		$this->module_forward_map = array();
1701
+		$this->module_view_map = array();
1702
+		// critical EE page IDs
1703
+		$this->reg_page_id = 0;
1704
+		$this->txn_page_id = 0;
1705
+		$this->thank_you_page_id = 0;
1706
+		$this->cancel_page_id = 0;
1707
+		// critical EE page URLs
1708
+		$this->reg_page_url = '';
1709
+		$this->txn_page_url = '';
1710
+		$this->thank_you_page_url = '';
1711
+		$this->cancel_page_url = '';
1712
+		// cpt slugs
1713
+		$this->event_cpt_slug = esc_html__('events', 'event_espresso');
1714
+		// ueip constant check
1715
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1716
+			$this->ee_ueip_optin = false;
1717
+			$this->ee_ueip_has_notified = true;
1718
+		}
1719
+	}
1720
+
1721
+
1722
+	/**
1723
+	 * @return array
1724
+	 */
1725
+	public function get_critical_pages_array()
1726
+	{
1727
+		return array(
1728
+			$this->reg_page_id,
1729
+			$this->txn_page_id,
1730
+			$this->thank_you_page_id,
1731
+			$this->cancel_page_id,
1732
+		);
1733
+	}
1734
+
1735
+
1736
+	/**
1737
+	 * @return array
1738
+	 */
1739
+	public function get_critical_pages_shortcodes_array()
1740
+	{
1741
+		return array(
1742
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1743
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1744
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1745
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1746
+		);
1747
+	}
1748
+
1749
+
1750
+	/**
1751
+	 *  gets/returns URL for EE reg_page
1752
+	 *
1753
+	 * @access    public
1754
+	 * @return    string
1755
+	 */
1756
+	public function reg_page_url()
1757
+	{
1758
+		if (! $this->reg_page_url) {
1759
+			$this->reg_page_url = add_query_arg(
1760
+				array('uts' => time()),
1761
+				get_permalink($this->reg_page_id)
1762
+			) . '#checkout';
1763
+		}
1764
+		return $this->reg_page_url;
1765
+	}
1766
+
1767
+
1768
+	/**
1769
+	 *  gets/returns URL for EE txn_page
1770
+	 *
1771
+	 * @param array $query_args like what gets passed to
1772
+	 *                          add_query_arg() as the first argument
1773
+	 * @access    public
1774
+	 * @return    string
1775
+	 */
1776
+	public function txn_page_url($query_args = array())
1777
+	{
1778
+		if (! $this->txn_page_url) {
1779
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1780
+		}
1781
+		if ($query_args) {
1782
+			return add_query_arg($query_args, $this->txn_page_url);
1783
+		} else {
1784
+			return $this->txn_page_url;
1785
+		}
1786
+	}
1787
+
1788
+
1789
+	/**
1790
+	 *  gets/returns URL for EE thank_you_page
1791
+	 *
1792
+	 * @param array $query_args like what gets passed to
1793
+	 *                          add_query_arg() as the first argument
1794
+	 * @access    public
1795
+	 * @return    string
1796
+	 */
1797
+	public function thank_you_page_url($query_args = array())
1798
+	{
1799
+		if (! $this->thank_you_page_url) {
1800
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1801
+		}
1802
+		if ($query_args) {
1803
+			return add_query_arg($query_args, $this->thank_you_page_url);
1804
+		} else {
1805
+			return $this->thank_you_page_url;
1806
+		}
1807
+	}
1808
+
1809
+
1810
+	/**
1811
+	 *  gets/returns URL for EE cancel_page
1812
+	 *
1813
+	 * @access    public
1814
+	 * @return    string
1815
+	 */
1816
+	public function cancel_page_url()
1817
+	{
1818
+		if (! $this->cancel_page_url) {
1819
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1820
+		}
1821
+		return $this->cancel_page_url;
1822
+	}
1823
+
1824
+
1825
+	/**
1826
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1827
+	 *
1828
+	 * @since 4.7.5
1829
+	 */
1830
+	protected function _reset_urls()
1831
+	{
1832
+		$this->reg_page_url = '';
1833
+		$this->txn_page_url = '';
1834
+		$this->cancel_page_url = '';
1835
+		$this->thank_you_page_url = '';
1836
+	}
1837
+
1838
+
1839
+	/**
1840
+	 * Used to return what the optin value is set for the EE User Experience Program.
1841
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1842
+	 * on the main site only.
1843
+	 *
1844
+	 * @return bool
1845
+	 */
1846
+	protected function _get_main_ee_ueip_optin()
1847
+	{
1848
+		// if this is the main site then we can just bypass our direct query.
1849
+		if (is_main_site()) {
1850
+			return get_option(self::OPTION_NAME_UXIP, false);
1851
+		}
1852
+		// is this already cached for this request?  If so use it.
1853
+		if (EE_Core_Config::$ee_ueip_option !== null) {
1854
+			return EE_Core_Config::$ee_ueip_option;
1855
+		}
1856
+		global $wpdb;
1857
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1858
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1859
+		$option = self::OPTION_NAME_UXIP;
1860
+		// set correct table for query
1861
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1862
+		// rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1863
+		// get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1864
+		// re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1865
+		// this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1866
+		// for the purpose of caching.
1867
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1868
+		if (false !== $pre) {
1869
+			EE_Core_Config::$ee_ueip_option = $pre;
1870
+			return EE_Core_Config::$ee_ueip_option;
1871
+		}
1872
+		$row = $wpdb->get_row(
1873
+			$wpdb->prepare(
1874
+				"SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1875
+				$option
1876
+			)
1877
+		);
1878
+		if (is_object($row)) {
1879
+			$value = $row->option_value;
1880
+		} else { // option does not exist so use default.
1881
+			EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1882
+			return EE_Core_Config::$ee_ueip_option;
1883
+		}
1884
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1885
+		return EE_Core_Config::$ee_ueip_option;
1886
+	}
1887
+
1888
+
1889
+	/**
1890
+	 * Utility function for escaping the value of a property and returning.
1891
+	 *
1892
+	 * @param string $property property name (checks to see if exists).
1893
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1894
+	 * @throws EE_Error
1895
+	 */
1896
+	public function get_pretty($property)
1897
+	{
1898
+		if ($property === self::OPTION_NAME_UXIP) {
1899
+			return $this->ee_ueip_optin ? 'yes' : 'no';
1900
+		}
1901
+		return parent::get_pretty($property);
1902
+	}
1903
+
1904
+
1905
+	/**
1906
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1907
+	 * on the object.
1908
+	 *
1909
+	 * @return array
1910
+	 */
1911
+	public function __sleep()
1912
+	{
1913
+		// reset all url properties
1914
+		$this->_reset_urls();
1915
+		// return what to save to db
1916
+		return array_keys(get_object_vars($this));
1917
+	}
1918
+}
2304 1919
 
2305
-    /**
2306
-     * array of form names protected by ReCaptcha
2307
-     *
2308
-     * @var array $recaptcha_protected_forms
2309
-     */
2310
-    public $recaptcha_protected_forms;
1920
+/**
1921
+ * Config class for storing info on the Organization
1922
+ */
1923
+class EE_Organization_Config extends EE_Config_Base
1924
+{
2311 1925
 
2312
-    /**
2313
-     * ReCaptcha width
2314
-     *
2315
-     * @var int $recaptcha_width
2316
-     * @deprecated
2317
-     */
2318
-    public $recaptcha_width;
1926
+	/**
1927
+	 * @var string $name
1928
+	 * eg EE4.1
1929
+	 */
1930
+	public $name;
1931
+
1932
+	/**
1933
+	 * @var string $address_1
1934
+	 * eg 123 Onna Road
1935
+	 */
1936
+	public $address_1 = '';
1937
+
1938
+	/**
1939
+	 * @var string $address_2
1940
+	 * eg PO Box 123
1941
+	 */
1942
+	public $address_2 = '';
1943
+
1944
+	/**
1945
+	 * @var string $city
1946
+	 * eg Inna City
1947
+	 */
1948
+	public $city = '';
1949
+
1950
+	/**
1951
+	 * @var int $STA_ID
1952
+	 * eg 4
1953
+	 */
1954
+	public $STA_ID = 0;
1955
+
1956
+	/**
1957
+	 * @var string $CNT_ISO
1958
+	 * eg US
1959
+	 */
1960
+	public $CNT_ISO = '';
1961
+
1962
+	/**
1963
+	 * @var string $zip
1964
+	 * eg 12345  or V1A 2B3
1965
+	 */
1966
+	public $zip = '';
1967
+
1968
+	/**
1969
+	 * @var string $email
1970
+	 * eg [email protected]
1971
+	 */
1972
+	public $email;
1973
+
1974
+	/**
1975
+	 * @var string $phone
1976
+	 * eg. 111-111-1111
1977
+	 */
1978
+	public $phone = '';
1979
+
1980
+	/**
1981
+	 * @var string $vat
1982
+	 * VAT/Tax Number
1983
+	 */
1984
+	public $vat = '';
1985
+
1986
+	/**
1987
+	 * @var string $logo_url
1988
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1989
+	 */
1990
+	public $logo_url = '';
1991
+
1992
+	/**
1993
+	 * The below are all various properties for holding links to organization social network profiles
1994
+	 *
1995
+	 * @var string
1996
+	 */
1997
+	/**
1998
+	 * facebook (facebook.com/profile.name)
1999
+	 *
2000
+	 * @var string
2001
+	 */
2002
+	public $facebook = '';
2003
+
2004
+	/**
2005
+	 * twitter (twitter.com/twitter_handle)
2006
+	 *
2007
+	 * @var string
2008
+	 */
2009
+	public $twitter = '';
2010
+
2011
+	/**
2012
+	 * linkedin (linkedin.com/in/profile_name)
2013
+	 *
2014
+	 * @var string
2015
+	 */
2016
+	public $linkedin = '';
2017
+
2018
+	/**
2019
+	 * pinterest (www.pinterest.com/profile_name)
2020
+	 *
2021
+	 * @var string
2022
+	 */
2023
+	public $pinterest = '';
2024
+
2025
+	/**
2026
+	 * google+ (google.com/+profileName)
2027
+	 *
2028
+	 * @var string
2029
+	 */
2030
+	public $google = '';
2031
+
2032
+	/**
2033
+	 * instagram (instagram.com/handle)
2034
+	 *
2035
+	 * @var string
2036
+	 */
2037
+	public $instagram = '';
2038
+
2039
+
2040
+	/**
2041
+	 *    class constructor
2042
+	 *
2043
+	 * @access    public
2044
+	 */
2045
+	public function __construct()
2046
+	{
2047
+		// set default organization settings
2048
+		// decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2049
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2050
+		$this->email = get_bloginfo('admin_email');
2051
+	}
2052
+}
2319 2053
 
2320
-    /**
2321
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2322
-     *
2323
-     * @var boolean $track_invalid_checkout_access
2324
-     */
2325
-    protected $track_invalid_checkout_access = true;
2054
+/**
2055
+ * Class for defining what's in the EE_Config relating to currency
2056
+ */
2057
+class EE_Currency_Config extends EE_Config_Base
2058
+{
2326 2059
 
2327
-    /**
2328
-     * Whether or not to show the privacy policy consent checkbox
2329
-     *
2330
-     * @var bool
2331
-     */
2332
-    public $consent_checkbox_enabled;
2060
+	/**
2061
+	 * @var string $code
2062
+	 * eg 'US'
2063
+	 */
2064
+	public $code;
2065
+
2066
+	/**
2067
+	 * @var string $name
2068
+	 * eg 'Dollar'
2069
+	 */
2070
+	public $name;
2071
+
2072
+	/**
2073
+	 * plural name
2074
+	 *
2075
+	 * @var string $plural
2076
+	 * eg 'Dollars'
2077
+	 */
2078
+	public $plural;
2079
+
2080
+	/**
2081
+	 * currency sign
2082
+	 *
2083
+	 * @var string $sign
2084
+	 * eg '$'
2085
+	 */
2086
+	public $sign;
2087
+
2088
+	/**
2089
+	 * Whether the currency sign should come before the number or not
2090
+	 *
2091
+	 * @var boolean $sign_b4
2092
+	 */
2093
+	public $sign_b4;
2094
+
2095
+	/**
2096
+	 * How many digits should come after the decimal place
2097
+	 *
2098
+	 * @var int $dec_plc
2099
+	 */
2100
+	public $dec_plc;
2101
+
2102
+	/**
2103
+	 * Symbol to use for decimal mark
2104
+	 *
2105
+	 * @var string $dec_mrk
2106
+	 * eg '.'
2107
+	 */
2108
+	public $dec_mrk;
2109
+
2110
+	/**
2111
+	 * Symbol to use for thousands
2112
+	 *
2113
+	 * @var string $thsnds
2114
+	 * eg ','
2115
+	 */
2116
+	public $thsnds;
2117
+
2118
+
2119
+	/**
2120
+	 *    class constructor
2121
+	 *
2122
+	 * @access    public
2123
+	 * @param string $CNT_ISO
2124
+	 * @throws EE_Error
2125
+	 * @throws ReflectionException
2126
+	 */
2127
+	public function __construct($CNT_ISO = '')
2128
+	{
2129
+		/** @var TableAnalysis $table_analysis */
2130
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2131
+		// get country code from organization settings or use default
2132
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2133
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2134
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2135
+			: '';
2136
+		// but override if requested
2137
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2138
+		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2139
+		if (
2140
+			! empty($CNT_ISO)
2141
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2142
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2143
+		) {
2144
+			// retrieve the country settings from the db, just in case they have been customized
2145
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2146
+			if ($country instanceof EE_Country) {
2147
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2148
+				$this->name = $country->currency_name_single();    // Dollar
2149
+				$this->plural = $country->currency_name_plural();    // Dollars
2150
+				$this->sign = $country->currency_sign();            // currency sign: $
2151
+				$this->sign_b4 = $country->currency_sign_before(
2152
+				);        // currency sign before or after: $TRUE  or  FALSE$
2153
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2154
+				$this->dec_mrk = $country->currency_decimal_mark(
2155
+				);    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2156
+				$this->thsnds = $country->currency_thousands_separator(
2157
+				);    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2158
+			}
2159
+		}
2160
+		// fallback to hardcoded defaults, in case the above failed
2161
+		if (empty($this->code)) {
2162
+			// set default currency settings
2163
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2164
+			$this->name = esc_html__('Dollar', 'event_espresso');    // Dollar
2165
+			$this->plural = esc_html__('Dollars', 'event_espresso');    // Dollars
2166
+			$this->sign = '$';    // currency sign: $
2167
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2168
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2169
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2170
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2171
+		}
2172
+	}
2173
+}
2333 2174
 
2334
-    /**
2335
-     * Label text to show on the checkbox
2336
-     *
2337
-     * @var string
2338
-     */
2339
-    public $consent_checkbox_label_text;
2175
+/**
2176
+ * Class for defining what's in the EE_Config relating to registration settings
2177
+ */
2178
+class EE_Registration_Config extends EE_Config_Base
2179
+{
2340 2180
 
2341
-    /*
2181
+	/**
2182
+	 * Default registration status
2183
+	 *
2184
+	 * @var string $default_STS_ID
2185
+	 * eg 'RPP'
2186
+	 */
2187
+	public $default_STS_ID;
2188
+
2189
+	/**
2190
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2191
+	 * registrations)
2192
+	 *
2193
+	 * @var int
2194
+	 */
2195
+	public $default_maximum_number_of_tickets;
2196
+
2197
+	/**
2198
+	 * level of validation to apply to email addresses
2199
+	 *
2200
+	 * @var string $email_validation_level
2201
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2202
+	 */
2203
+	public $email_validation_level;
2204
+
2205
+	/**
2206
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2207
+	 *
2208
+	 * @var boolean $show_pending_payment_options
2209
+	 */
2210
+	public $show_pending_payment_options;
2211
+
2212
+	/**
2213
+	 * Whether to skip the registration confirmation page
2214
+	 *
2215
+	 * @var boolean $skip_reg_confirmation
2216
+	 */
2217
+	public $skip_reg_confirmation;
2218
+
2219
+	/**
2220
+	 * an array of SPCO reg steps where:
2221
+	 *        the keys denotes the reg step order
2222
+	 *        each element consists of an array with the following elements:
2223
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2224
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2225
+	 *            "slug" => the URL param used to trigger the reg step
2226
+	 *
2227
+	 * @var array $reg_steps
2228
+	 */
2229
+	public $reg_steps;
2230
+
2231
+	/**
2232
+	 * Whether registration confirmation should be the last page of SPCO
2233
+	 *
2234
+	 * @var boolean $reg_confirmation_last
2235
+	 */
2236
+	public $reg_confirmation_last;
2237
+
2238
+	/**
2239
+	 * Whether or not to enable the EE Bot Trap
2240
+	 *
2241
+	 * @var boolean $use_bot_trap
2242
+	 */
2243
+	public $use_bot_trap;
2244
+
2245
+	/**
2246
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2247
+	 *
2248
+	 * @var boolean $use_encryption
2249
+	 */
2250
+	public $use_encryption;
2251
+
2252
+	/**
2253
+	 * Whether or not to use ReCaptcha
2254
+	 *
2255
+	 * @var boolean $use_captcha
2256
+	 */
2257
+	public $use_captcha;
2258
+
2259
+	/**
2260
+	 * ReCaptcha Theme
2261
+	 *
2262
+	 * @var string $recaptcha_theme
2263
+	 *    options: 'dark', 'light', 'invisible'
2264
+	 */
2265
+	public $recaptcha_theme;
2266
+
2267
+	/**
2268
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2269
+	 *
2270
+	 * @var string $recaptcha_badge
2271
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2272
+	 */
2273
+	public $recaptcha_badge;
2274
+
2275
+	/**
2276
+	 * ReCaptcha Type
2277
+	 *
2278
+	 * @var string $recaptcha_type
2279
+	 *    options: 'audio', 'image'
2280
+	 */
2281
+	public $recaptcha_type;
2282
+
2283
+	/**
2284
+	 * ReCaptcha language
2285
+	 *
2286
+	 * @var string $recaptcha_language
2287
+	 * eg 'en'
2288
+	 */
2289
+	public $recaptcha_language;
2290
+
2291
+	/**
2292
+	 * ReCaptcha public key
2293
+	 *
2294
+	 * @var string $recaptcha_publickey
2295
+	 */
2296
+	public $recaptcha_publickey;
2297
+
2298
+	/**
2299
+	 * ReCaptcha private key
2300
+	 *
2301
+	 * @var string $recaptcha_privatekey
2302
+	 */
2303
+	public $recaptcha_privatekey;
2304
+
2305
+	/**
2306
+	 * array of form names protected by ReCaptcha
2307
+	 *
2308
+	 * @var array $recaptcha_protected_forms
2309
+	 */
2310
+	public $recaptcha_protected_forms;
2311
+
2312
+	/**
2313
+	 * ReCaptcha width
2314
+	 *
2315
+	 * @var int $recaptcha_width
2316
+	 * @deprecated
2317
+	 */
2318
+	public $recaptcha_width;
2319
+
2320
+	/**
2321
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2322
+	 *
2323
+	 * @var boolean $track_invalid_checkout_access
2324
+	 */
2325
+	protected $track_invalid_checkout_access = true;
2326
+
2327
+	/**
2328
+	 * Whether or not to show the privacy policy consent checkbox
2329
+	 *
2330
+	 * @var bool
2331
+	 */
2332
+	public $consent_checkbox_enabled;
2333
+
2334
+	/**
2335
+	 * Label text to show on the checkbox
2336
+	 *
2337
+	 * @var string
2338
+	 */
2339
+	public $consent_checkbox_label_text;
2340
+
2341
+	/*
2342 2342
      * String describing how long to keep payment logs. Passed into DateTime constructor
2343 2343
      * @var string
2344 2344
      */
2345
-    public $gateway_log_lifespan = '1 week';
2346
-
2347
-    /**
2348
-     * Enable copy attendee info at form
2349
-     *
2350
-     * @var boolean $enable_copy_attendee
2351
-     */
2352
-    protected $copy_attendee_info = true;
2353
-
2354
-
2355
-    /**
2356
-     *    class constructor
2357
-     *
2358
-     * @access    public
2359
-     */
2360
-    public function __construct()
2361
-    {
2362
-        // set default registration settings
2363
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2364
-        $this->email_validation_level = 'wp_default';
2365
-        $this->show_pending_payment_options = true;
2366
-        $this->skip_reg_confirmation = true;
2367
-        $this->reg_steps = array();
2368
-        $this->reg_confirmation_last = false;
2369
-        $this->use_bot_trap = true;
2370
-        $this->use_encryption = true;
2371
-        $this->use_captcha = false;
2372
-        $this->recaptcha_theme = 'light';
2373
-        $this->recaptcha_badge = 'bottomleft';
2374
-        $this->recaptcha_type = 'image';
2375
-        $this->recaptcha_language = 'en';
2376
-        $this->recaptcha_publickey = null;
2377
-        $this->recaptcha_privatekey = null;
2378
-        $this->recaptcha_protected_forms = array();
2379
-        $this->recaptcha_width = 500;
2380
-        $this->default_maximum_number_of_tickets = 10;
2381
-        $this->consent_checkbox_enabled = false;
2382
-        $this->consent_checkbox_label_text = '';
2383
-        $this->gateway_log_lifespan = '7 days';
2384
-        $this->copy_attendee_info = true;
2385
-    }
2386
-
2387
-
2388
-    /**
2389
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2390
-     *
2391
-     * @since 4.8.8.rc.019
2392
-     */
2393
-    public function do_hooks()
2394
-    {
2395
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2396
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2397
-        add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2398
-    }
2399
-
2400
-
2401
-    /**
2402
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2403
-     * EVT_default_registration_status field matches the config setting for default_STS_ID.
2404
-     */
2405
-    public function set_default_reg_status_on_EEM_Event()
2406
-    {
2407
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2408
-    }
2409
-
2410
-
2411
-    /**
2412
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2413
-     * for Events matches the config setting for default_maximum_number_of_tickets
2414
-     */
2415
-    public function set_default_max_ticket_on_EEM_Event()
2416
-    {
2417
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2418
-    }
2419
-
2420
-
2421
-    /**
2422
-     * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2423
-     * constructed because that happens before we can get the privacy policy page's permalink.
2424
-     *
2425
-     * @throws InvalidArgumentException
2426
-     * @throws InvalidDataTypeException
2427
-     * @throws InvalidInterfaceException
2428
-     */
2429
-    public function setDefaultCheckboxLabelText()
2430
-    {
2431
-        if (
2432
-            $this->getConsentCheckboxLabelText() === null
2433
-            || $this->getConsentCheckboxLabelText() === ''
2434
-        ) {
2435
-            $opening_a_tag = '';
2436
-            $closing_a_tag = '';
2437
-            if (function_exists('get_privacy_policy_url')) {
2438
-                $privacy_page_url = get_privacy_policy_url();
2439
-                if (! empty($privacy_page_url)) {
2440
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2441
-                    $closing_a_tag = '</a>';
2442
-                }
2443
-            }
2444
-            $loader = LoaderFactory::getLoader();
2445
-            $org_config = $loader->getShared('EE_Organization_Config');
2446
-            /**
2447
-             * @var $org_config EE_Organization_Config
2448
-             */
2449
-
2450
-            $this->setConsentCheckboxLabelText(
2451
-                sprintf(
2452
-                    esc_html__(
2453
-                        'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2454
-                        'event_espresso'
2455
-                    ),
2456
-                    $org_config->name,
2457
-                    $opening_a_tag,
2458
-                    $closing_a_tag
2459
-                )
2460
-            );
2461
-        }
2462
-    }
2463
-
2464
-
2465
-    /**
2466
-     * @return boolean
2467
-     */
2468
-    public function track_invalid_checkout_access()
2469
-    {
2470
-        return $this->track_invalid_checkout_access;
2471
-    }
2472
-
2473
-
2474
-    /**
2475
-     * @param boolean $track_invalid_checkout_access
2476
-     */
2477
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2478
-    {
2479
-        $this->track_invalid_checkout_access = filter_var(
2480
-            $track_invalid_checkout_access,
2481
-            FILTER_VALIDATE_BOOLEAN
2482
-        );
2483
-    }
2484
-
2485
-    /**
2486
-     * @return boolean
2487
-     */
2488
-    public function copyAttendeeInfo()
2489
-    {
2490
-        return $this->copy_attendee_info;
2491
-    }
2492
-
2493
-
2494
-    /**
2495
-     * @param boolean $copy_attendee_info
2496
-     */
2497
-    public function setCopyAttendeeInfo($copy_attendee_info)
2498
-    {
2499
-        $this->copy_attendee_info = filter_var(
2500
-            $copy_attendee_info,
2501
-            FILTER_VALIDATE_BOOLEAN
2502
-        );
2503
-    }
2504
-
2505
-
2506
-    /**
2507
-     * Gets the options to make availalbe for the gateway log lifespan
2508
-     * @return array
2509
-     */
2510
-    public function gatewayLogLifespanOptions()
2511
-    {
2512
-        return (array) apply_filters(
2513
-            'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2514
-            array(
2515
-                '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2516
-                '1 day' => esc_html__('1 Day', 'event_espresso'),
2517
-                '7 days' => esc_html__('7 Days', 'event_espresso'),
2518
-                '14 days' => esc_html__('14 Days', 'event_espresso'),
2519
-                '30 days' => esc_html__('30 Days', 'event_espresso')
2520
-            )
2521
-        );
2522
-    }
2523
-
2524
-
2525
-    /**
2526
-     * @return bool
2527
-     */
2528
-    public function isConsentCheckboxEnabled()
2529
-    {
2530
-        return $this->consent_checkbox_enabled;
2531
-    }
2532
-
2533
-
2534
-    /**
2535
-     * @param bool $consent_checkbox_enabled
2536
-     */
2537
-    public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2538
-    {
2539
-        $this->consent_checkbox_enabled = filter_var(
2540
-            $consent_checkbox_enabled,
2541
-            FILTER_VALIDATE_BOOLEAN
2542
-        );
2543
-    }
2544
-
2545
-
2546
-    /**
2547
-     * @return string
2548
-     */
2549
-    public function getConsentCheckboxLabelText()
2550
-    {
2551
-        return $this->consent_checkbox_label_text;
2552
-    }
2553
-
2554
-
2555
-    /**
2556
-     * @param string $consent_checkbox_label_text
2557
-     */
2558
-    public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2559
-    {
2560
-        $this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2561
-    }
2345
+	public $gateway_log_lifespan = '1 week';
2346
+
2347
+	/**
2348
+	 * Enable copy attendee info at form
2349
+	 *
2350
+	 * @var boolean $enable_copy_attendee
2351
+	 */
2352
+	protected $copy_attendee_info = true;
2353
+
2354
+
2355
+	/**
2356
+	 *    class constructor
2357
+	 *
2358
+	 * @access    public
2359
+	 */
2360
+	public function __construct()
2361
+	{
2362
+		// set default registration settings
2363
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2364
+		$this->email_validation_level = 'wp_default';
2365
+		$this->show_pending_payment_options = true;
2366
+		$this->skip_reg_confirmation = true;
2367
+		$this->reg_steps = array();
2368
+		$this->reg_confirmation_last = false;
2369
+		$this->use_bot_trap = true;
2370
+		$this->use_encryption = true;
2371
+		$this->use_captcha = false;
2372
+		$this->recaptcha_theme = 'light';
2373
+		$this->recaptcha_badge = 'bottomleft';
2374
+		$this->recaptcha_type = 'image';
2375
+		$this->recaptcha_language = 'en';
2376
+		$this->recaptcha_publickey = null;
2377
+		$this->recaptcha_privatekey = null;
2378
+		$this->recaptcha_protected_forms = array();
2379
+		$this->recaptcha_width = 500;
2380
+		$this->default_maximum_number_of_tickets = 10;
2381
+		$this->consent_checkbox_enabled = false;
2382
+		$this->consent_checkbox_label_text = '';
2383
+		$this->gateway_log_lifespan = '7 days';
2384
+		$this->copy_attendee_info = true;
2385
+	}
2386
+
2387
+
2388
+	/**
2389
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2390
+	 *
2391
+	 * @since 4.8.8.rc.019
2392
+	 */
2393
+	public function do_hooks()
2394
+	{
2395
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2396
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2397
+		add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2398
+	}
2399
+
2400
+
2401
+	/**
2402
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2403
+	 * EVT_default_registration_status field matches the config setting for default_STS_ID.
2404
+	 */
2405
+	public function set_default_reg_status_on_EEM_Event()
2406
+	{
2407
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2408
+	}
2409
+
2410
+
2411
+	/**
2412
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2413
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2414
+	 */
2415
+	public function set_default_max_ticket_on_EEM_Event()
2416
+	{
2417
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2418
+	}
2419
+
2420
+
2421
+	/**
2422
+	 * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2423
+	 * constructed because that happens before we can get the privacy policy page's permalink.
2424
+	 *
2425
+	 * @throws InvalidArgumentException
2426
+	 * @throws InvalidDataTypeException
2427
+	 * @throws InvalidInterfaceException
2428
+	 */
2429
+	public function setDefaultCheckboxLabelText()
2430
+	{
2431
+		if (
2432
+			$this->getConsentCheckboxLabelText() === null
2433
+			|| $this->getConsentCheckboxLabelText() === ''
2434
+		) {
2435
+			$opening_a_tag = '';
2436
+			$closing_a_tag = '';
2437
+			if (function_exists('get_privacy_policy_url')) {
2438
+				$privacy_page_url = get_privacy_policy_url();
2439
+				if (! empty($privacy_page_url)) {
2440
+					$opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2441
+					$closing_a_tag = '</a>';
2442
+				}
2443
+			}
2444
+			$loader = LoaderFactory::getLoader();
2445
+			$org_config = $loader->getShared('EE_Organization_Config');
2446
+			/**
2447
+			 * @var $org_config EE_Organization_Config
2448
+			 */
2449
+
2450
+			$this->setConsentCheckboxLabelText(
2451
+				sprintf(
2452
+					esc_html__(
2453
+						'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2454
+						'event_espresso'
2455
+					),
2456
+					$org_config->name,
2457
+					$opening_a_tag,
2458
+					$closing_a_tag
2459
+				)
2460
+			);
2461
+		}
2462
+	}
2463
+
2464
+
2465
+	/**
2466
+	 * @return boolean
2467
+	 */
2468
+	public function track_invalid_checkout_access()
2469
+	{
2470
+		return $this->track_invalid_checkout_access;
2471
+	}
2472
+
2473
+
2474
+	/**
2475
+	 * @param boolean $track_invalid_checkout_access
2476
+	 */
2477
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2478
+	{
2479
+		$this->track_invalid_checkout_access = filter_var(
2480
+			$track_invalid_checkout_access,
2481
+			FILTER_VALIDATE_BOOLEAN
2482
+		);
2483
+	}
2484
+
2485
+	/**
2486
+	 * @return boolean
2487
+	 */
2488
+	public function copyAttendeeInfo()
2489
+	{
2490
+		return $this->copy_attendee_info;
2491
+	}
2492
+
2493
+
2494
+	/**
2495
+	 * @param boolean $copy_attendee_info
2496
+	 */
2497
+	public function setCopyAttendeeInfo($copy_attendee_info)
2498
+	{
2499
+		$this->copy_attendee_info = filter_var(
2500
+			$copy_attendee_info,
2501
+			FILTER_VALIDATE_BOOLEAN
2502
+		);
2503
+	}
2504
+
2505
+
2506
+	/**
2507
+	 * Gets the options to make availalbe for the gateway log lifespan
2508
+	 * @return array
2509
+	 */
2510
+	public function gatewayLogLifespanOptions()
2511
+	{
2512
+		return (array) apply_filters(
2513
+			'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2514
+			array(
2515
+				'1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2516
+				'1 day' => esc_html__('1 Day', 'event_espresso'),
2517
+				'7 days' => esc_html__('7 Days', 'event_espresso'),
2518
+				'14 days' => esc_html__('14 Days', 'event_espresso'),
2519
+				'30 days' => esc_html__('30 Days', 'event_espresso')
2520
+			)
2521
+		);
2522
+	}
2523
+
2524
+
2525
+	/**
2526
+	 * @return bool
2527
+	 */
2528
+	public function isConsentCheckboxEnabled()
2529
+	{
2530
+		return $this->consent_checkbox_enabled;
2531
+	}
2532
+
2533
+
2534
+	/**
2535
+	 * @param bool $consent_checkbox_enabled
2536
+	 */
2537
+	public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2538
+	{
2539
+		$this->consent_checkbox_enabled = filter_var(
2540
+			$consent_checkbox_enabled,
2541
+			FILTER_VALIDATE_BOOLEAN
2542
+		);
2543
+	}
2544
+
2545
+
2546
+	/**
2547
+	 * @return string
2548
+	 */
2549
+	public function getConsentCheckboxLabelText()
2550
+	{
2551
+		return $this->consent_checkbox_label_text;
2552
+	}
2553
+
2554
+
2555
+	/**
2556
+	 * @param string $consent_checkbox_label_text
2557
+	 */
2558
+	public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2559
+	{
2560
+		$this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2561
+	}
2562 2562
 }
2563 2563
 
2564 2564
 /**
@@ -2567,143 +2567,143 @@  discard block
 block discarded – undo
2567 2567
 class EE_Admin_Config extends EE_Config_Base
2568 2568
 {
2569 2569
 
2570
-    /**
2571
-     * @var boolean $use_personnel_manager
2572
-     */
2573
-    public $use_personnel_manager;
2574
-
2575
-    /**
2576
-     * @var boolean $use_dashboard_widget
2577
-     */
2578
-    public $use_dashboard_widget;
2579
-
2580
-    /**
2581
-     * @var int $events_in_dashboard
2582
-     */
2583
-    public $events_in_dashboard;
2584
-
2585
-    /**
2586
-     * @var boolean $use_event_timezones
2587
-     */
2588
-    public $use_event_timezones;
2589
-
2590
-    /**
2591
-     * @var string $log_file_name
2592
-     */
2593
-    public $log_file_name;
2594
-
2595
-    /**
2596
-     * @var string $debug_file_name
2597
-     */
2598
-    public $debug_file_name;
2599
-
2600
-    /**
2601
-     * @var boolean $use_remote_logging
2602
-     */
2603
-    public $use_remote_logging;
2604
-
2605
-    /**
2606
-     * @var string $remote_logging_url
2607
-     */
2608
-    public $remote_logging_url;
2609
-
2610
-    /**
2611
-     * @var boolean $show_reg_footer
2612
-     */
2613
-    public $show_reg_footer;
2614
-
2615
-    /**
2616
-     * @var string $affiliate_id
2617
-     */
2618
-    public $affiliate_id;
2619
-
2620
-    /**
2621
-     * adds extra layer of encoding to session data to prevent serialization errors
2622
-     * but is incompatible with some server configuration errors
2623
-     * if you get "500 internal server errors" during registration, try turning this on
2624
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2625
-     *
2626
-     * @var boolean $encode_session_data
2627
-     */
2628
-    private $encode_session_data = false;
2629
-
2630
-
2631
-    /**
2632
-     *    class constructor
2633
-     *
2634
-     * @access    public
2635
-     */
2636
-    public function __construct()
2637
-    {
2638
-        // set default general admin settings
2639
-        $this->use_personnel_manager = true;
2640
-        $this->use_dashboard_widget = true;
2641
-        $this->events_in_dashboard = 30;
2642
-        $this->use_event_timezones = false;
2643
-        $this->use_remote_logging = false;
2644
-        $this->remote_logging_url = null;
2645
-        $this->show_reg_footer = apply_filters(
2646
-            'FHEE__EE_Admin_Config__show_reg_footer__default',
2647
-            false
2648
-        );
2649
-        $this->affiliate_id = 'default';
2650
-        $this->encode_session_data = false;
2651
-    }
2652
-
2653
-
2654
-    /**
2655
-     * @param bool $reset
2656
-     * @return string
2657
-     */
2658
-    public function log_file_name($reset = false)
2659
-    {
2660
-        if (empty($this->log_file_name) || $reset) {
2661
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2662
-            EE_Config::instance()->update_espresso_config(false, false);
2663
-        }
2664
-        return $this->log_file_name;
2665
-    }
2666
-
2667
-
2668
-    /**
2669
-     * @param bool $reset
2670
-     * @return string
2671
-     */
2672
-    public function debug_file_name($reset = false)
2673
-    {
2674
-        if (empty($this->debug_file_name) || $reset) {
2675
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2676
-            EE_Config::instance()->update_espresso_config(false, false);
2677
-        }
2678
-        return $this->debug_file_name;
2679
-    }
2680
-
2681
-
2682
-    /**
2683
-     * @return string
2684
-     */
2685
-    public function affiliate_id()
2686
-    {
2687
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2688
-    }
2689
-
2690
-
2691
-    /**
2692
-     * @return boolean
2693
-     */
2694
-    public function encode_session_data()
2695
-    {
2696
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2697
-    }
2698
-
2699
-
2700
-    /**
2701
-     * @param boolean $encode_session_data
2702
-     */
2703
-    public function set_encode_session_data($encode_session_data)
2704
-    {
2705
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2706
-    }
2570
+	/**
2571
+	 * @var boolean $use_personnel_manager
2572
+	 */
2573
+	public $use_personnel_manager;
2574
+
2575
+	/**
2576
+	 * @var boolean $use_dashboard_widget
2577
+	 */
2578
+	public $use_dashboard_widget;
2579
+
2580
+	/**
2581
+	 * @var int $events_in_dashboard
2582
+	 */
2583
+	public $events_in_dashboard;
2584
+
2585
+	/**
2586
+	 * @var boolean $use_event_timezones
2587
+	 */
2588
+	public $use_event_timezones;
2589
+
2590
+	/**
2591
+	 * @var string $log_file_name
2592
+	 */
2593
+	public $log_file_name;
2594
+
2595
+	/**
2596
+	 * @var string $debug_file_name
2597
+	 */
2598
+	public $debug_file_name;
2599
+
2600
+	/**
2601
+	 * @var boolean $use_remote_logging
2602
+	 */
2603
+	public $use_remote_logging;
2604
+
2605
+	/**
2606
+	 * @var string $remote_logging_url
2607
+	 */
2608
+	public $remote_logging_url;
2609
+
2610
+	/**
2611
+	 * @var boolean $show_reg_footer
2612
+	 */
2613
+	public $show_reg_footer;
2614
+
2615
+	/**
2616
+	 * @var string $affiliate_id
2617
+	 */
2618
+	public $affiliate_id;
2619
+
2620
+	/**
2621
+	 * adds extra layer of encoding to session data to prevent serialization errors
2622
+	 * but is incompatible with some server configuration errors
2623
+	 * if you get "500 internal server errors" during registration, try turning this on
2624
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2625
+	 *
2626
+	 * @var boolean $encode_session_data
2627
+	 */
2628
+	private $encode_session_data = false;
2629
+
2630
+
2631
+	/**
2632
+	 *    class constructor
2633
+	 *
2634
+	 * @access    public
2635
+	 */
2636
+	public function __construct()
2637
+	{
2638
+		// set default general admin settings
2639
+		$this->use_personnel_manager = true;
2640
+		$this->use_dashboard_widget = true;
2641
+		$this->events_in_dashboard = 30;
2642
+		$this->use_event_timezones = false;
2643
+		$this->use_remote_logging = false;
2644
+		$this->remote_logging_url = null;
2645
+		$this->show_reg_footer = apply_filters(
2646
+			'FHEE__EE_Admin_Config__show_reg_footer__default',
2647
+			false
2648
+		);
2649
+		$this->affiliate_id = 'default';
2650
+		$this->encode_session_data = false;
2651
+	}
2652
+
2653
+
2654
+	/**
2655
+	 * @param bool $reset
2656
+	 * @return string
2657
+	 */
2658
+	public function log_file_name($reset = false)
2659
+	{
2660
+		if (empty($this->log_file_name) || $reset) {
2661
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2662
+			EE_Config::instance()->update_espresso_config(false, false);
2663
+		}
2664
+		return $this->log_file_name;
2665
+	}
2666
+
2667
+
2668
+	/**
2669
+	 * @param bool $reset
2670
+	 * @return string
2671
+	 */
2672
+	public function debug_file_name($reset = false)
2673
+	{
2674
+		if (empty($this->debug_file_name) || $reset) {
2675
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2676
+			EE_Config::instance()->update_espresso_config(false, false);
2677
+		}
2678
+		return $this->debug_file_name;
2679
+	}
2680
+
2681
+
2682
+	/**
2683
+	 * @return string
2684
+	 */
2685
+	public function affiliate_id()
2686
+	{
2687
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2688
+	}
2689
+
2690
+
2691
+	/**
2692
+	 * @return boolean
2693
+	 */
2694
+	public function encode_session_data()
2695
+	{
2696
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2697
+	}
2698
+
2699
+
2700
+	/**
2701
+	 * @param boolean $encode_session_data
2702
+	 */
2703
+	public function set_encode_session_data($encode_session_data)
2704
+	{
2705
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2706
+	}
2707 2707
 }
2708 2708
 
2709 2709
 /**
@@ -2712,70 +2712,70 @@  discard block
 block discarded – undo
2712 2712
 class EE_Template_Config extends EE_Config_Base
2713 2713
 {
2714 2714
 
2715
-    /**
2716
-     * @var boolean $enable_default_style
2717
-     */
2718
-    public $enable_default_style;
2719
-
2720
-    /**
2721
-     * @var string $custom_style_sheet
2722
-     */
2723
-    public $custom_style_sheet;
2724
-
2725
-    /**
2726
-     * @var boolean $display_address_in_regform
2727
-     */
2728
-    public $display_address_in_regform;
2729
-
2730
-    /**
2731
-     * @var int $display_description_on_multi_reg_page
2732
-     */
2733
-    public $display_description_on_multi_reg_page;
2734
-
2735
-    /**
2736
-     * @var boolean $use_custom_templates
2737
-     */
2738
-    public $use_custom_templates;
2739
-
2740
-    /**
2741
-     * @var string $current_espresso_theme
2742
-     */
2743
-    public $current_espresso_theme;
2744
-
2745
-    /**
2746
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2747
-     */
2748
-    public $EED_Ticket_Selector;
2749
-
2750
-    /**
2751
-     * @var EE_Event_Single_Config $EED_Event_Single
2752
-     */
2753
-    public $EED_Event_Single;
2754
-
2755
-    /**
2756
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2757
-     */
2758
-    public $EED_Events_Archive;
2759
-
2760
-
2761
-    /**
2762
-     *    class constructor
2763
-     *
2764
-     * @access    public
2765
-     */
2766
-    public function __construct()
2767
-    {
2768
-        // set default template settings
2769
-        $this->enable_default_style = true;
2770
-        $this->custom_style_sheet = null;
2771
-        $this->display_address_in_regform = true;
2772
-        $this->display_description_on_multi_reg_page = false;
2773
-        $this->use_custom_templates = false;
2774
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2775
-        $this->EED_Event_Single = null;
2776
-        $this->EED_Events_Archive = null;
2777
-        $this->EED_Ticket_Selector = null;
2778
-    }
2715
+	/**
2716
+	 * @var boolean $enable_default_style
2717
+	 */
2718
+	public $enable_default_style;
2719
+
2720
+	/**
2721
+	 * @var string $custom_style_sheet
2722
+	 */
2723
+	public $custom_style_sheet;
2724
+
2725
+	/**
2726
+	 * @var boolean $display_address_in_regform
2727
+	 */
2728
+	public $display_address_in_regform;
2729
+
2730
+	/**
2731
+	 * @var int $display_description_on_multi_reg_page
2732
+	 */
2733
+	public $display_description_on_multi_reg_page;
2734
+
2735
+	/**
2736
+	 * @var boolean $use_custom_templates
2737
+	 */
2738
+	public $use_custom_templates;
2739
+
2740
+	/**
2741
+	 * @var string $current_espresso_theme
2742
+	 */
2743
+	public $current_espresso_theme;
2744
+
2745
+	/**
2746
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2747
+	 */
2748
+	public $EED_Ticket_Selector;
2749
+
2750
+	/**
2751
+	 * @var EE_Event_Single_Config $EED_Event_Single
2752
+	 */
2753
+	public $EED_Event_Single;
2754
+
2755
+	/**
2756
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2757
+	 */
2758
+	public $EED_Events_Archive;
2759
+
2760
+
2761
+	/**
2762
+	 *    class constructor
2763
+	 *
2764
+	 * @access    public
2765
+	 */
2766
+	public function __construct()
2767
+	{
2768
+		// set default template settings
2769
+		$this->enable_default_style = true;
2770
+		$this->custom_style_sheet = null;
2771
+		$this->display_address_in_regform = true;
2772
+		$this->display_description_on_multi_reg_page = false;
2773
+		$this->use_custom_templates = false;
2774
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2775
+		$this->EED_Event_Single = null;
2776
+		$this->EED_Events_Archive = null;
2777
+		$this->EED_Ticket_Selector = null;
2778
+	}
2779 2779
 }
2780 2780
 
2781 2781
 /**
@@ -2784,114 +2784,114 @@  discard block
 block discarded – undo
2784 2784
 class EE_Map_Config extends EE_Config_Base
2785 2785
 {
2786 2786
 
2787
-    /**
2788
-     * @var boolean $use_google_maps
2789
-     */
2790
-    public $use_google_maps;
2791
-
2792
-    /**
2793
-     * @var string $api_key
2794
-     */
2795
-    public $google_map_api_key;
2796
-
2797
-    /**
2798
-     * @var int $event_details_map_width
2799
-     */
2800
-    public $event_details_map_width;
2801
-
2802
-    /**
2803
-     * @var int $event_details_map_height
2804
-     */
2805
-    public $event_details_map_height;
2806
-
2807
-    /**
2808
-     * @var int $event_details_map_zoom
2809
-     */
2810
-    public $event_details_map_zoom;
2811
-
2812
-    /**
2813
-     * @var boolean $event_details_display_nav
2814
-     */
2815
-    public $event_details_display_nav;
2816
-
2817
-    /**
2818
-     * @var boolean $event_details_nav_size
2819
-     */
2820
-    public $event_details_nav_size;
2821
-
2822
-    /**
2823
-     * @var string $event_details_control_type
2824
-     */
2825
-    public $event_details_control_type;
2826
-
2827
-    /**
2828
-     * @var string $event_details_map_align
2829
-     */
2830
-    public $event_details_map_align;
2831
-
2832
-    /**
2833
-     * @var int $event_list_map_width
2834
-     */
2835
-    public $event_list_map_width;
2836
-
2837
-    /**
2838
-     * @var int $event_list_map_height
2839
-     */
2840
-    public $event_list_map_height;
2841
-
2842
-    /**
2843
-     * @var int $event_list_map_zoom
2844
-     */
2845
-    public $event_list_map_zoom;
2846
-
2847
-    /**
2848
-     * @var boolean $event_list_display_nav
2849
-     */
2850
-    public $event_list_display_nav;
2851
-
2852
-    /**
2853
-     * @var boolean $event_list_nav_size
2854
-     */
2855
-    public $event_list_nav_size;
2856
-
2857
-    /**
2858
-     * @var string $event_list_control_type
2859
-     */
2860
-    public $event_list_control_type;
2861
-
2862
-    /**
2863
-     * @var string $event_list_map_align
2864
-     */
2865
-    public $event_list_map_align;
2866
-
2867
-
2868
-    /**
2869
-     *    class constructor
2870
-     *
2871
-     * @access    public
2872
-     */
2873
-    public function __construct()
2874
-    {
2875
-        // set default map settings
2876
-        $this->use_google_maps = true;
2877
-        $this->google_map_api_key = '';
2878
-        // for event details pages (reg page)
2879
-        $this->event_details_map_width = 585;            // ee_map_width_single
2880
-        $this->event_details_map_height = 362;            // ee_map_height_single
2881
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2882
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2883
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2884
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2885
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2886
-        // for event list pages
2887
-        $this->event_list_map_width = 300;            // ee_map_width
2888
-        $this->event_list_map_height = 185;        // ee_map_height
2889
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2890
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2891
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2892
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2893
-        $this->event_list_map_align = 'center';            // ee_map_align
2894
-    }
2787
+	/**
2788
+	 * @var boolean $use_google_maps
2789
+	 */
2790
+	public $use_google_maps;
2791
+
2792
+	/**
2793
+	 * @var string $api_key
2794
+	 */
2795
+	public $google_map_api_key;
2796
+
2797
+	/**
2798
+	 * @var int $event_details_map_width
2799
+	 */
2800
+	public $event_details_map_width;
2801
+
2802
+	/**
2803
+	 * @var int $event_details_map_height
2804
+	 */
2805
+	public $event_details_map_height;
2806
+
2807
+	/**
2808
+	 * @var int $event_details_map_zoom
2809
+	 */
2810
+	public $event_details_map_zoom;
2811
+
2812
+	/**
2813
+	 * @var boolean $event_details_display_nav
2814
+	 */
2815
+	public $event_details_display_nav;
2816
+
2817
+	/**
2818
+	 * @var boolean $event_details_nav_size
2819
+	 */
2820
+	public $event_details_nav_size;
2821
+
2822
+	/**
2823
+	 * @var string $event_details_control_type
2824
+	 */
2825
+	public $event_details_control_type;
2826
+
2827
+	/**
2828
+	 * @var string $event_details_map_align
2829
+	 */
2830
+	public $event_details_map_align;
2831
+
2832
+	/**
2833
+	 * @var int $event_list_map_width
2834
+	 */
2835
+	public $event_list_map_width;
2836
+
2837
+	/**
2838
+	 * @var int $event_list_map_height
2839
+	 */
2840
+	public $event_list_map_height;
2841
+
2842
+	/**
2843
+	 * @var int $event_list_map_zoom
2844
+	 */
2845
+	public $event_list_map_zoom;
2846
+
2847
+	/**
2848
+	 * @var boolean $event_list_display_nav
2849
+	 */
2850
+	public $event_list_display_nav;
2851
+
2852
+	/**
2853
+	 * @var boolean $event_list_nav_size
2854
+	 */
2855
+	public $event_list_nav_size;
2856
+
2857
+	/**
2858
+	 * @var string $event_list_control_type
2859
+	 */
2860
+	public $event_list_control_type;
2861
+
2862
+	/**
2863
+	 * @var string $event_list_map_align
2864
+	 */
2865
+	public $event_list_map_align;
2866
+
2867
+
2868
+	/**
2869
+	 *    class constructor
2870
+	 *
2871
+	 * @access    public
2872
+	 */
2873
+	public function __construct()
2874
+	{
2875
+		// set default map settings
2876
+		$this->use_google_maps = true;
2877
+		$this->google_map_api_key = '';
2878
+		// for event details pages (reg page)
2879
+		$this->event_details_map_width = 585;            // ee_map_width_single
2880
+		$this->event_details_map_height = 362;            // ee_map_height_single
2881
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2882
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2883
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2884
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2885
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2886
+		// for event list pages
2887
+		$this->event_list_map_width = 300;            // ee_map_width
2888
+		$this->event_list_map_height = 185;        // ee_map_height
2889
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2890
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2891
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2892
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2893
+		$this->event_list_map_align = 'center';            // ee_map_align
2894
+	}
2895 2895
 }
2896 2896
 
2897 2897
 /**
@@ -2900,46 +2900,46 @@  discard block
 block discarded – undo
2900 2900
 class EE_Events_Archive_Config extends EE_Config_Base
2901 2901
 {
2902 2902
 
2903
-    public $display_status_banner;
2903
+	public $display_status_banner;
2904 2904
 
2905
-    public $display_description;
2905
+	public $display_description;
2906 2906
 
2907
-    public $display_ticket_selector;
2907
+	public $display_ticket_selector;
2908 2908
 
2909
-    public $display_datetimes;
2909
+	public $display_datetimes;
2910 2910
 
2911
-    public $display_venue;
2911
+	public $display_venue;
2912 2912
 
2913
-    public $display_expired_events;
2913
+	public $display_expired_events;
2914 2914
 
2915
-    public $use_sortable_display_order;
2915
+	public $use_sortable_display_order;
2916 2916
 
2917
-    public $display_order_tickets;
2917
+	public $display_order_tickets;
2918 2918
 
2919
-    public $display_order_datetimes;
2919
+	public $display_order_datetimes;
2920 2920
 
2921
-    public $display_order_event;
2921
+	public $display_order_event;
2922 2922
 
2923
-    public $display_order_venue;
2923
+	public $display_order_venue;
2924 2924
 
2925 2925
 
2926
-    /**
2927
-     *    class constructor
2928
-     */
2929
-    public function __construct()
2930
-    {
2931
-        $this->display_status_banner = 0;
2932
-        $this->display_description = 1;
2933
-        $this->display_ticket_selector = 0;
2934
-        $this->display_datetimes = 1;
2935
-        $this->display_venue = 0;
2936
-        $this->display_expired_events = 0;
2937
-        $this->use_sortable_display_order = false;
2938
-        $this->display_order_tickets = 100;
2939
-        $this->display_order_datetimes = 110;
2940
-        $this->display_order_event = 120;
2941
-        $this->display_order_venue = 130;
2942
-    }
2926
+	/**
2927
+	 *    class constructor
2928
+	 */
2929
+	public function __construct()
2930
+	{
2931
+		$this->display_status_banner = 0;
2932
+		$this->display_description = 1;
2933
+		$this->display_ticket_selector = 0;
2934
+		$this->display_datetimes = 1;
2935
+		$this->display_venue = 0;
2936
+		$this->display_expired_events = 0;
2937
+		$this->use_sortable_display_order = false;
2938
+		$this->display_order_tickets = 100;
2939
+		$this->display_order_datetimes = 110;
2940
+		$this->display_order_event = 120;
2941
+		$this->display_order_venue = 130;
2942
+	}
2943 2943
 }
2944 2944
 
2945 2945
 /**
@@ -2948,34 +2948,34 @@  discard block
 block discarded – undo
2948 2948
 class EE_Event_Single_Config extends EE_Config_Base
2949 2949
 {
2950 2950
 
2951
-    public $display_status_banner_single;
2951
+	public $display_status_banner_single;
2952 2952
 
2953
-    public $display_venue;
2953
+	public $display_venue;
2954 2954
 
2955
-    public $use_sortable_display_order;
2955
+	public $use_sortable_display_order;
2956 2956
 
2957
-    public $display_order_tickets;
2957
+	public $display_order_tickets;
2958 2958
 
2959
-    public $display_order_datetimes;
2959
+	public $display_order_datetimes;
2960 2960
 
2961
-    public $display_order_event;
2961
+	public $display_order_event;
2962 2962
 
2963
-    public $display_order_venue;
2963
+	public $display_order_venue;
2964 2964
 
2965 2965
 
2966
-    /**
2967
-     *    class constructor
2968
-     */
2969
-    public function __construct()
2970
-    {
2971
-        $this->display_status_banner_single = 0;
2972
-        $this->display_venue = 1;
2973
-        $this->use_sortable_display_order = false;
2974
-        $this->display_order_tickets = 100;
2975
-        $this->display_order_datetimes = 110;
2976
-        $this->display_order_event = 120;
2977
-        $this->display_order_venue = 130;
2978
-    }
2966
+	/**
2967
+	 *    class constructor
2968
+	 */
2969
+	public function __construct()
2970
+	{
2971
+		$this->display_status_banner_single = 0;
2972
+		$this->display_venue = 1;
2973
+		$this->use_sortable_display_order = false;
2974
+		$this->display_order_tickets = 100;
2975
+		$this->display_order_datetimes = 110;
2976
+		$this->display_order_event = 120;
2977
+		$this->display_order_venue = 130;
2978
+	}
2979 2979
 }
2980 2980
 
2981 2981
 /**
@@ -2984,172 +2984,172 @@  discard block
 block discarded – undo
2984 2984
 class EE_Ticket_Selector_Config extends EE_Config_Base
2985 2985
 {
2986 2986
 
2987
-    /**
2988
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2989
-     */
2990
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2991
-
2992
-    /**
2993
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2994
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2995
-     */
2996
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2997
-
2998
-    /**
2999
-     * @var boolean $show_ticket_sale_columns
3000
-     */
3001
-    public $show_ticket_sale_columns;
3002
-
3003
-    /**
3004
-     * @var boolean $show_ticket_details
3005
-     */
3006
-    public $show_ticket_details;
3007
-
3008
-    /**
3009
-     * @var boolean $show_expired_tickets
3010
-     */
3011
-    public $show_expired_tickets;
3012
-
3013
-    /**
3014
-     * whether or not to display a dropdown box populated with event datetimes
3015
-     * that toggles which tickets are displayed for a ticket selector.
3016
-     * uses one of the *_DATETIME_SELECTOR constants defined above
3017
-     *
3018
-     * @var string $show_datetime_selector
3019
-     */
3020
-    private $show_datetime_selector = 'no_datetime_selector';
3021
-
3022
-    /**
3023
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
3024
-     *
3025
-     * @var int $datetime_selector_threshold
3026
-     */
3027
-    private $datetime_selector_threshold = 3;
3028
-
3029
-    /**
3030
-     * determines the maximum number of "checked" dates in the date and time filter
3031
-     *
3032
-     * @var int $datetime_selector_checked
3033
-     */
3034
-    private $datetime_selector_max_checked = 10;
3035
-
3036
-
3037
-    /**
3038
-     *    class constructor
3039
-     */
3040
-    public function __construct()
3041
-    {
3042
-        $this->show_ticket_sale_columns = true;
3043
-        $this->show_ticket_details = true;
3044
-        $this->show_expired_tickets = true;
3045
-        $this->show_datetime_selector = EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3046
-        $this->datetime_selector_threshold = 3;
3047
-        $this->datetime_selector_max_checked = 10;
3048
-    }
3049
-
3050
-
3051
-    /**
3052
-     * returns true if a datetime selector should be displayed
3053
-     *
3054
-     * @param array $datetimes
3055
-     * @return bool
3056
-     */
3057
-    public function showDatetimeSelector(array $datetimes)
3058
-    {
3059
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3060
-        return ! (
3061
-            $this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3062
-            || (
3063
-                $this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3064
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3065
-            )
3066
-        );
3067
-    }
3068
-
3069
-
3070
-    /**
3071
-     * @return string
3072
-     */
3073
-    public function getShowDatetimeSelector()
3074
-    {
3075
-        return $this->show_datetime_selector;
3076
-    }
3077
-
3078
-
3079
-    /**
3080
-     * @param bool $keys_only
3081
-     * @return array
3082
-     */
3083
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3084
-    {
3085
-        return $keys_only
3086
-            ? array(
3087
-                EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3088
-                EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3089
-            )
3090
-            : array(
3091
-                EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3092
-                    'Do not show date & time filter',
3093
-                    'event_espresso'
3094
-                ),
3095
-                EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3096
-                    'Maybe show date & time filter',
3097
-                    'event_espresso'
3098
-                ),
3099
-            );
3100
-    }
3101
-
3102
-
3103
-    /**
3104
-     * @param string $show_datetime_selector
3105
-     */
3106
-    public function setShowDatetimeSelector($show_datetime_selector)
3107
-    {
3108
-        $this->show_datetime_selector = in_array(
3109
-            $show_datetime_selector,
3110
-            $this->getShowDatetimeSelectorOptions(),
3111
-            true
3112
-        )
3113
-            ? $show_datetime_selector
3114
-            : EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3115
-    }
3116
-
3117
-
3118
-    /**
3119
-     * @return int
3120
-     */
3121
-    public function getDatetimeSelectorThreshold()
3122
-    {
3123
-        return $this->datetime_selector_threshold;
3124
-    }
3125
-
3126
-
3127
-    /**
3128
-     * @param int $datetime_selector_threshold
3129
-     */
3130
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3131
-    {
3132
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3133
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3134
-    }
3135
-
3136
-
3137
-    /**
3138
-     * @return int
3139
-     */
3140
-    public function getDatetimeSelectorMaxChecked()
3141
-    {
3142
-        return $this->datetime_selector_max_checked;
3143
-    }
3144
-
3145
-
3146
-    /**
3147
-     * @param int $datetime_selector_max_checked
3148
-     */
3149
-    public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3150
-    {
3151
-        $this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3152
-    }
2987
+	/**
2988
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2989
+	 */
2990
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2991
+
2992
+	/**
2993
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2994
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2995
+	 */
2996
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2997
+
2998
+	/**
2999
+	 * @var boolean $show_ticket_sale_columns
3000
+	 */
3001
+	public $show_ticket_sale_columns;
3002
+
3003
+	/**
3004
+	 * @var boolean $show_ticket_details
3005
+	 */
3006
+	public $show_ticket_details;
3007
+
3008
+	/**
3009
+	 * @var boolean $show_expired_tickets
3010
+	 */
3011
+	public $show_expired_tickets;
3012
+
3013
+	/**
3014
+	 * whether or not to display a dropdown box populated with event datetimes
3015
+	 * that toggles which tickets are displayed for a ticket selector.
3016
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
3017
+	 *
3018
+	 * @var string $show_datetime_selector
3019
+	 */
3020
+	private $show_datetime_selector = 'no_datetime_selector';
3021
+
3022
+	/**
3023
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
3024
+	 *
3025
+	 * @var int $datetime_selector_threshold
3026
+	 */
3027
+	private $datetime_selector_threshold = 3;
3028
+
3029
+	/**
3030
+	 * determines the maximum number of "checked" dates in the date and time filter
3031
+	 *
3032
+	 * @var int $datetime_selector_checked
3033
+	 */
3034
+	private $datetime_selector_max_checked = 10;
3035
+
3036
+
3037
+	/**
3038
+	 *    class constructor
3039
+	 */
3040
+	public function __construct()
3041
+	{
3042
+		$this->show_ticket_sale_columns = true;
3043
+		$this->show_ticket_details = true;
3044
+		$this->show_expired_tickets = true;
3045
+		$this->show_datetime_selector = EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3046
+		$this->datetime_selector_threshold = 3;
3047
+		$this->datetime_selector_max_checked = 10;
3048
+	}
3049
+
3050
+
3051
+	/**
3052
+	 * returns true if a datetime selector should be displayed
3053
+	 *
3054
+	 * @param array $datetimes
3055
+	 * @return bool
3056
+	 */
3057
+	public function showDatetimeSelector(array $datetimes)
3058
+	{
3059
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3060
+		return ! (
3061
+			$this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3062
+			|| (
3063
+				$this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3064
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3065
+			)
3066
+		);
3067
+	}
3068
+
3069
+
3070
+	/**
3071
+	 * @return string
3072
+	 */
3073
+	public function getShowDatetimeSelector()
3074
+	{
3075
+		return $this->show_datetime_selector;
3076
+	}
3077
+
3078
+
3079
+	/**
3080
+	 * @param bool $keys_only
3081
+	 * @return array
3082
+	 */
3083
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3084
+	{
3085
+		return $keys_only
3086
+			? array(
3087
+				EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3088
+				EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3089
+			)
3090
+			: array(
3091
+				EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3092
+					'Do not show date & time filter',
3093
+					'event_espresso'
3094
+				),
3095
+				EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3096
+					'Maybe show date & time filter',
3097
+					'event_espresso'
3098
+				),
3099
+			);
3100
+	}
3101
+
3102
+
3103
+	/**
3104
+	 * @param string $show_datetime_selector
3105
+	 */
3106
+	public function setShowDatetimeSelector($show_datetime_selector)
3107
+	{
3108
+		$this->show_datetime_selector = in_array(
3109
+			$show_datetime_selector,
3110
+			$this->getShowDatetimeSelectorOptions(),
3111
+			true
3112
+		)
3113
+			? $show_datetime_selector
3114
+			: EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3115
+	}
3116
+
3117
+
3118
+	/**
3119
+	 * @return int
3120
+	 */
3121
+	public function getDatetimeSelectorThreshold()
3122
+	{
3123
+		return $this->datetime_selector_threshold;
3124
+	}
3125
+
3126
+
3127
+	/**
3128
+	 * @param int $datetime_selector_threshold
3129
+	 */
3130
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3131
+	{
3132
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3133
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3134
+	}
3135
+
3136
+
3137
+	/**
3138
+	 * @return int
3139
+	 */
3140
+	public function getDatetimeSelectorMaxChecked()
3141
+	{
3142
+		return $this->datetime_selector_max_checked;
3143
+	}
3144
+
3145
+
3146
+	/**
3147
+	 * @param int $datetime_selector_max_checked
3148
+	 */
3149
+	public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3150
+	{
3151
+		$this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3152
+	}
3153 3153
 }
3154 3154
 
3155 3155
 /**
@@ -3162,87 +3162,87 @@  discard block
 block discarded – undo
3162 3162
 class EE_Environment_Config extends EE_Config_Base
3163 3163
 {
3164 3164
 
3165
-    /**
3166
-     * Hold any php environment variables that we want to track.
3167
-     *
3168
-     * @var stdClass;
3169
-     */
3170
-    public $php;
3171
-
3172
-
3173
-    /**
3174
-     *    constructor
3175
-     */
3176
-    public function __construct()
3177
-    {
3178
-        $this->php = new stdClass();
3179
-        $this->_set_php_values();
3180
-    }
3181
-
3182
-
3183
-    /**
3184
-     * This sets the php environment variables.
3185
-     *
3186
-     * @since 4.4.0
3187
-     * @return void
3188
-     */
3189
-    protected function _set_php_values()
3190
-    {
3191
-        $this->php->max_input_vars = ini_get('max_input_vars');
3192
-        $this->php->version = phpversion();
3193
-    }
3194
-
3195
-
3196
-    /**
3197
-     * helper method for determining whether input_count is
3198
-     * reaching the potential maximum the server can handle
3199
-     * according to max_input_vars
3200
-     *
3201
-     * @param int   $input_count the count of input vars.
3202
-     * @return array {
3203
-     *                           An array that represents whether available space and if no available space the error
3204
-     *                           message.
3205
-     * @type bool   $has_space   whether more inputs can be added.
3206
-     * @type string $msg         Any message to be displayed.
3207
-     *                           }
3208
-     */
3209
-    public function max_input_vars_limit_check($input_count = 0)
3210
-    {
3211
-        if (
3212
-            ! empty($this->php->max_input_vars)
3213
-            && ($input_count >= $this->php->max_input_vars)
3214
-        ) {
3215
-            // check the server setting because the config value could be stale
3216
-            $max_input_vars = ini_get('max_input_vars');
3217
-            if ($input_count >= $max_input_vars) {
3218
-                return sprintf(
3219
-                    esc_html__(
3220
-                        'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.',
3221
-                        'event_espresso'
3222
-                    ),
3223
-                    '<br>',
3224
-                    $input_count,
3225
-                    $max_input_vars
3226
-                );
3227
-            } else {
3228
-                return '';
3229
-            }
3230
-        } else {
3231
-            return '';
3232
-        }
3233
-    }
3234
-
3235
-
3236
-    /**
3237
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3238
-     *
3239
-     * @since 4.4.1
3240
-     * @return void
3241
-     */
3242
-    public function recheck_values()
3243
-    {
3244
-        $this->_set_php_values();
3245
-    }
3165
+	/**
3166
+	 * Hold any php environment variables that we want to track.
3167
+	 *
3168
+	 * @var stdClass;
3169
+	 */
3170
+	public $php;
3171
+
3172
+
3173
+	/**
3174
+	 *    constructor
3175
+	 */
3176
+	public function __construct()
3177
+	{
3178
+		$this->php = new stdClass();
3179
+		$this->_set_php_values();
3180
+	}
3181
+
3182
+
3183
+	/**
3184
+	 * This sets the php environment variables.
3185
+	 *
3186
+	 * @since 4.4.0
3187
+	 * @return void
3188
+	 */
3189
+	protected function _set_php_values()
3190
+	{
3191
+		$this->php->max_input_vars = ini_get('max_input_vars');
3192
+		$this->php->version = phpversion();
3193
+	}
3194
+
3195
+
3196
+	/**
3197
+	 * helper method for determining whether input_count is
3198
+	 * reaching the potential maximum the server can handle
3199
+	 * according to max_input_vars
3200
+	 *
3201
+	 * @param int   $input_count the count of input vars.
3202
+	 * @return array {
3203
+	 *                           An array that represents whether available space and if no available space the error
3204
+	 *                           message.
3205
+	 * @type bool   $has_space   whether more inputs can be added.
3206
+	 * @type string $msg         Any message to be displayed.
3207
+	 *                           }
3208
+	 */
3209
+	public function max_input_vars_limit_check($input_count = 0)
3210
+	{
3211
+		if (
3212
+			! empty($this->php->max_input_vars)
3213
+			&& ($input_count >= $this->php->max_input_vars)
3214
+		) {
3215
+			// check the server setting because the config value could be stale
3216
+			$max_input_vars = ini_get('max_input_vars');
3217
+			if ($input_count >= $max_input_vars) {
3218
+				return sprintf(
3219
+					esc_html__(
3220
+						'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.',
3221
+						'event_espresso'
3222
+					),
3223
+					'<br>',
3224
+					$input_count,
3225
+					$max_input_vars
3226
+				);
3227
+			} else {
3228
+				return '';
3229
+			}
3230
+		} else {
3231
+			return '';
3232
+		}
3233
+	}
3234
+
3235
+
3236
+	/**
3237
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3238
+	 *
3239
+	 * @since 4.4.1
3240
+	 * @return void
3241
+	 */
3242
+	public function recheck_values()
3243
+	{
3244
+		$this->_set_php_values();
3245
+	}
3246 3246
 }
3247 3247
 
3248 3248
 /**
@@ -3255,21 +3255,21 @@  discard block
 block discarded – undo
3255 3255
 class EE_Tax_Config extends EE_Config_Base
3256 3256
 {
3257 3257
 
3258
-    /*
3258
+	/*
3259 3259
      * flag to indicate whether or not to display ticket prices with the taxes included
3260 3260
      *
3261 3261
      * @var boolean $prices_displayed_including_taxes
3262 3262
      */
3263
-    public $prices_displayed_including_taxes;
3263
+	public $prices_displayed_including_taxes;
3264 3264
 
3265 3265
 
3266
-    /**
3267
-     *    class constructor
3268
-     */
3269
-    public function __construct()
3270
-    {
3271
-        $this->prices_displayed_including_taxes = true;
3272
-    }
3266
+	/**
3267
+	 *    class constructor
3268
+	 */
3269
+	public function __construct()
3270
+	{
3271
+		$this->prices_displayed_including_taxes = true;
3272
+	}
3273 3273
 }
3274 3274
 
3275 3275
 /**
@@ -3283,19 +3283,19 @@  discard block
 block discarded – undo
3283 3283
 class EE_Messages_Config extends EE_Config_Base
3284 3284
 {
3285 3285
 
3286
-    /**
3287
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3288
-     * A value of 0 represents never deleting.  Default is 0.
3289
-     *
3290
-     * @var integer
3291
-     */
3292
-    public $delete_threshold;
3286
+	/**
3287
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3288
+	 * A value of 0 represents never deleting.  Default is 0.
3289
+	 *
3290
+	 * @var integer
3291
+	 */
3292
+	public $delete_threshold;
3293 3293
 
3294 3294
 
3295
-    public function __construct()
3296
-    {
3297
-        $this->delete_threshold = 0;
3298
-    }
3295
+	public function __construct()
3296
+	{
3297
+		$this->delete_threshold = 0;
3298
+	}
3299 3299
 }
3300 3300
 
3301 3301
 /**
@@ -3306,31 +3306,31 @@  discard block
 block discarded – undo
3306 3306
 class EE_Gateway_Config extends EE_Config_Base
3307 3307
 {
3308 3308
 
3309
-    /**
3310
-     * Array with keys that are payment gateways slugs, and values are arrays
3311
-     * with any config info the gateway wants to store
3312
-     *
3313
-     * @var array
3314
-     */
3315
-    public $payment_settings;
3316
-
3317
-    /**
3318
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3319
-     * the gateway is stored in the uploads directory
3320
-     *
3321
-     * @var array
3322
-     */
3323
-    public $active_gateways;
3324
-
3325
-
3326
-    /**
3327
-     *    class constructor
3328
-     *
3329
-     * @deprecated
3330
-     */
3331
-    public function __construct()
3332
-    {
3333
-        $this->payment_settings = array();
3334
-        $this->active_gateways = array('Invoice' => false);
3335
-    }
3309
+	/**
3310
+	 * Array with keys that are payment gateways slugs, and values are arrays
3311
+	 * with any config info the gateway wants to store
3312
+	 *
3313
+	 * @var array
3314
+	 */
3315
+	public $payment_settings;
3316
+
3317
+	/**
3318
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3319
+	 * the gateway is stored in the uploads directory
3320
+	 *
3321
+	 * @var array
3322
+	 */
3323
+	public $active_gateways;
3324
+
3325
+
3326
+	/**
3327
+	 *    class constructor
3328
+	 *
3329
+	 * @deprecated
3330
+	 */
3331
+	public function __construct()
3332
+	{
3333
+		$this->payment_settings = array();
3334
+		$this->active_gateways = array('Invoice' => false);
3335
+	}
3336 3336
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin.core.php 1 patch
Indentation   +994 added lines, -994 removed lines patch added patch discarded remove patch
@@ -21,998 +21,998 @@
 block discarded – undo
21 21
 final class EE_Admin implements InterminableInterface
22 22
 {
23 23
 
24
-    /**
25
-     * @var EE_Admin $_instance
26
-     */
27
-    private static $_instance;
28
-
29
-    /**
30
-     * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
31
-     */
32
-    private $persistent_admin_notice_manager;
33
-
34
-    /**
35
-     * @var LoaderInterface
36
-     */
37
-    protected $loader;
38
-
39
-    /**
40
-     * @var RequestInterface
41
-     */
42
-    protected $request;
43
-
44
-
45
-    /**
46
-     * @param RequestInterface $request
47
-     * @singleton method used to instantiate class object
48
-     * @return EE_Admin
49
-     * @throws EE_Error
50
-     */
51
-    public static function instance(RequestInterface $request = null)
52
-    {
53
-        // check if class object is instantiated
54
-        if (! self::$_instance instanceof EE_Admin) {
55
-            self::$_instance = new self($request);
56
-        }
57
-        return self::$_instance;
58
-    }
59
-
60
-
61
-    /**
62
-     * @return EE_Admin
63
-     * @throws EE_Error
64
-     */
65
-    public static function reset()
66
-    {
67
-        self::$_instance = null;
68
-        $request         = LoaderFactory::getLoader()->getShared(RequestInterface::class);
69
-        return self::instance($request);
70
-    }
71
-
72
-
73
-    /**
74
-     * @param RequestInterface $request
75
-     * @throws EE_Error
76
-     * @throws InvalidDataTypeException
77
-     * @throws InvalidInterfaceException
78
-     * @throws InvalidArgumentException
79
-     */
80
-    protected function __construct(RequestInterface $request)
81
-    {
82
-        $this->request = $request;
83
-        $this->loader = LoaderFactory::getLoader();
84
-        // define global EE_Admin constants
85
-        $this->_define_all_constants();
86
-        // set autoloaders for our admin page classes based on included path information
87
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
88
-        // admin hooks
89
-        add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2);
90
-        add_action('AHEE__EE_System__initialize_last', [$this, 'init']);
91
-        add_action('AHEE__EE_Admin_Page__route_admin_request', [$this, 'route_admin_request'], 100, 2);
92
-        add_action('wp_loaded', [$this, 'wp_loaded'], 100);
93
-        add_action('admin_init', [$this, 'admin_init'], 100);
94
-        add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts'], 20);
95
-        add_action('admin_notices', [$this, 'display_admin_notices'], 10);
96
-        add_action('network_admin_notices', [$this, 'display_admin_notices'], 10);
97
-        add_filter('pre_update_option', [$this, 'check_for_invalid_datetime_formats'], 100, 2);
98
-        add_filter('admin_footer_text', [$this, 'espresso_admin_footer']);
99
-        add_action('load-plugins.php', [$this, 'hookIntoWpPluginsPage']);
100
-        add_action('display_post_states', [$this, 'displayStateForCriticalPages'], 10, 2);
101
-        add_filter('plugin_row_meta', [$this, 'addLinksToPluginRowMeta'], 10, 2);
102
-        // reset Environment config (we only do this on admin page loads);
103
-        EE_Registry::instance()->CFG->environment->recheck_values();
104
-        do_action('AHEE__EE_Admin__loaded');
105
-    }
106
-
107
-
108
-    /**
109
-     * _define_all_constants
110
-     * define constants that are set globally for all admin pages
111
-     *
112
-     * @return void
113
-     */
114
-    private function _define_all_constants()
115
-    {
116
-        if (! defined('EE_ADMIN_URL')) {
117
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
118
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
119
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/');
120
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
121
-            define('WP_AJAX_URL', admin_url('admin-ajax.php'));
122
-        }
123
-    }
124
-
125
-
126
-    /**
127
-     * filter_plugin_actions - adds links to the Plugins page listing
128
-     *
129
-     * @param array  $links
130
-     * @param string $plugin
131
-     * @return    array
132
-     */
133
-    public function filter_plugin_actions($links, $plugin)
134
-    {
135
-        // set $main_file in stone
136
-        static $main_file;
137
-        // if $main_file is not set yet
138
-        if (! $main_file) {
139
-            $main_file = EE_PLUGIN_BASENAME;
140
-        }
141
-        if ($plugin === $main_file) {
142
-            // compare current plugin to this one
143
-            if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
144
-                $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
145
-                                    . ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
146
-                                    . esc_html__('Maintenance Mode Active', 'event_espresso')
147
-                                    . '</a>';
148
-                array_unshift($links, $maintenance_link);
149
-            } else {
150
-                $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
151
-                                     . esc_html__('Settings', 'event_espresso')
152
-                                     . '</a>';
153
-                $events_link       = '<a href="admin.php?page=espresso_events">'
154
-                                     . esc_html__('Events', 'event_espresso')
155
-                                     . '</a>';
156
-                // add before other links
157
-                array_unshift($links, $org_settings_link, $events_link);
158
-            }
159
-        }
160
-        return $links;
161
-    }
162
-
163
-
164
-    /**
165
-     * @deprecated 4.10.14.p
166
-     */
167
-    public function get_request()
168
-    {
169
-    }
170
-
171
-
172
-    /**
173
-     * hide_admin_pages_except_maintenance_mode
174
-     *
175
-     * @param array $admin_page_folder_names
176
-     * @return array
177
-     */
178
-    public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = [])
179
-    {
180
-        return [
181
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance/',
182
-            'about'       => EE_ADMIN_PAGES . 'about/',
183
-            'support'     => EE_ADMIN_PAGES . 'support/',
184
-        ];
185
-    }
186
-
187
-
188
-    /**
189
-     * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
190
-     * EE_Front_Controller's init phases have run
191
-     *
192
-     * @return void
193
-     * @throws EE_Error
194
-     * @throws InvalidArgumentException
195
-     * @throws InvalidDataTypeException
196
-     * @throws InvalidInterfaceException
197
-     * @throws ReflectionException
198
-     * @throws ServiceNotFoundException
199
-     */
200
-    public function init()
201
-    {
202
-        // only enable most of the EE_Admin IF we're not in full maintenance mode
203
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
204
-            $this->initModelsReady();
205
-        }
206
-        // run the admin page factory but ONLY if:
207
-        // - it is a regular non ajax admin request
208
-        // - we are doing an ee admin ajax request
209
-        if ($this->request->isAdmin() || $this->request->isAdminAjax()) {
210
-            // this loads the controller for the admin pages which will setup routing etc
211
-            $this->loader->getShared('EE_Admin_Page_Loader', [$this->loader]);
212
-        }
213
-        if ($this->request->isAdminAjax()) {
214
-            return;
215
-        }
216
-        add_filter('content_save_pre', [$this, 'its_eSpresso'], 10, 1);
217
-        // make sure our CPTs and custom taxonomy metaboxes get shown for first time users
218
-        add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes'], 10);
219
-        add_action('admin_head', [$this, 'register_custom_nav_menu_boxes'], 10);
220
-        // exclude EE critical pages from all nav menus and wp_list_pages
221
-        add_filter('nav_menu_meta_box_object', [$this, 'remove_pages_from_nav_menu'], 10);
222
-    }
223
-
224
-
225
-    /**
226
-     * Gets the loader (and if it wasn't previously set, sets it)
227
-     *
228
-     * @return LoaderInterface
229
-     * @throws InvalidArgumentException
230
-     * @throws InvalidDataTypeException
231
-     * @throws InvalidInterfaceException
232
-     */
233
-    protected function getLoader()
234
-    {
235
-        return $this->loader;
236
-    }
237
-
238
-
239
-    /**
240
-     * Method that's fired on admin requests (including admin ajax) but only when the models are usable
241
-     * (ie, the site isn't in maintenance mode)
242
-     *
243
-     * @return void
244
-     * @throws EE_Error
245
-     * @since 4.9.63.p
246
-     */
247
-    protected function initModelsReady()
248
-    {
249
-        // ok so we want to enable the entire admin
250
-        $this->persistent_admin_notice_manager = $this->loader->getShared(
251
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
252
-        );
253
-        $this->persistent_admin_notice_manager->setReturnUrl(
254
-            EE_Admin_Page::add_query_args_and_nonce(
255
-                [
256
-                    'page'   => $this->request->getRequestParam('page'),
257
-                    'action' => $this->request->getRequestParam('action'),
258
-                ],
259
-                EE_ADMIN_URL
260
-            )
261
-        );
262
-        $this->maybeSetDatetimeWarningNotice();
263
-        // at a glance dashboard widget
264
-        add_filter('dashboard_glance_items', [$this, 'dashboard_glance_items'], 10);
265
-        // filter for get_edit_post_link used on comments for custom post types
266
-        add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 2);
267
-    }
268
-
269
-
270
-    /**
271
-     *    get_persistent_admin_notices
272
-     *
273
-     * @access    public
274
-     * @return void
275
-     * @throws EE_Error
276
-     * @throws InvalidArgumentException
277
-     * @throws InvalidDataTypeException
278
-     * @throws InvalidInterfaceException
279
-     */
280
-    public function maybeSetDatetimeWarningNotice()
281
-    {
282
-        // add dismissible notice for datetime changes.  Only valid if site does not have a timezone_string set.
283
-        // @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
284
-        // with this.  But after enough time (indeterminate at this point) we can just remove this notice.
285
-        // this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
286
-        if (
287
-            apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
288
-            && ! get_option('timezone_string')
289
-            && EEM_Event::instance()->count() > 0
290
-        ) {
291
-            new PersistentAdminNotice(
292
-                'datetime_fix_notice',
293
-                sprintf(
294
-                    esc_html__(
295
-                        '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times.  Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',
296
-                        'event_espresso'
297
-                    ),
298
-                    '<strong>',
299
-                    '</strong>',
300
-                    '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
301
-                    '</a>',
302
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
303
-                        [
304
-                            'page'   => 'espresso_maintenance_settings',
305
-                            'action' => 'datetime_tools',
306
-                        ],
307
-                        admin_url('admin.php')
308
-                    ) . '">'
309
-                ),
310
-                false,
311
-                'manage_options',
312
-                'datetime_fix_persistent_notice'
313
-            );
314
-        }
315
-    }
316
-
317
-
318
-    /**
319
-     * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
320
-     * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
321
-     * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
322
-     * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
323
-     * normal property on the post_type object.  It's found ONLY in this particular context.
324
-     *
325
-     * @param WP_Post $post_type WP post type object
326
-     * @return WP_Post
327
-     * @throws InvalidArgumentException
328
-     * @throws InvalidDataTypeException
329
-     * @throws InvalidInterfaceException
330
-     */
331
-    public function remove_pages_from_nav_menu($post_type)
332
-    {
333
-        // if this isn't the "pages" post type let's get out
334
-        if ($post_type->name !== 'page') {
335
-            return $post_type;
336
-        }
337
-        $critical_pages            = EE_Registry::instance()->CFG->core->get_critical_pages_array();
338
-        $post_type->_default_query = [
339
-            'post__not_in' => $critical_pages,
340
-        ];
341
-        return $post_type;
342
-    }
343
-
344
-
345
-    /**
346
-     * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
347
-     * metaboxes get shown as well
348
-     *
349
-     * @return void
350
-     */
351
-    public function enable_hidden_ee_nav_menu_metaboxes()
352
-    {
353
-        global $wp_meta_boxes, $pagenow;
354
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
355
-            return;
356
-        }
357
-        $user = wp_get_current_user();
358
-        // has this been done yet?
359
-        if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
360
-            return;
361
-        }
362
-
363
-        $hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
364
-        $initial_meta_boxes = apply_filters(
365
-            'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
366
-            [
367
-                'nav-menu-theme-locations',
368
-                'add-page',
369
-                'add-custom-links',
370
-                'add-category',
371
-                'add-espresso_events',
372
-                'add-espresso_venues',
373
-                'add-espresso_event_categories',
374
-                'add-espresso_venue_categories',
375
-                'add-post-type-post',
376
-                'add-post-type-page',
377
-            ]
378
-        );
379
-
380
-        if (is_array($hidden_meta_boxes)) {
381
-            foreach ($hidden_meta_boxes as $key => $meta_box_id) {
382
-                if (in_array($meta_box_id, $initial_meta_boxes, true)) {
383
-                    unset($hidden_meta_boxes[ $key ]);
384
-                }
385
-            }
386
-        }
387
-        update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
388
-        update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
389
-    }
390
-
391
-
392
-    /**
393
-     * This method simply registers custom nav menu boxes for "nav_menus.php route"
394
-     * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
395
-     *
396
-     * @return void
397
-     * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
398
-     *         addons etc.
399
-     */
400
-    public function register_custom_nav_menu_boxes()
401
-    {
402
-        add_meta_box(
403
-            'add-extra-nav-menu-pages',
404
-            esc_html__('Event Espresso Pages', 'event_espresso'),
405
-            [$this, 'ee_cpt_archive_pages'],
406
-            'nav-menus',
407
-            'side',
408
-            'core'
409
-        );
410
-    }
411
-
412
-
413
-    /**
414
-     * Use this to edit the post link for our cpts so that the edit link points to the correct page.
415
-     *
416
-     * @param string $link the original link generated by wp
417
-     * @param int    $id   post id
418
-     * @return string  the (maybe) modified link
419
-     * @since   4.3.0
420
-     */
421
-    public function modify_edit_post_link($link, $id)
422
-    {
423
-        if (! $post = get_post($id)) {
424
-            return $link;
425
-        }
426
-        if ($post->post_type === 'espresso_attendees') {
427
-            $query_args = [
428
-                'action' => 'edit_attendee',
429
-                'post'   => $id,
430
-            ];
431
-            return EEH_URL::add_query_args_and_nonce(
432
-                $query_args,
433
-                admin_url('admin.php?page=espresso_registrations')
434
-            );
435
-        }
436
-        return $link;
437
-    }
438
-
439
-
440
-    public function ee_cpt_archive_pages()
441
-    {
442
-        global $nav_menu_selected_id;
443
-        $removed_args = [
444
-            'action',
445
-            'customlink-tab',
446
-            'edit-menu-item',
447
-            'menu-item',
448
-            'page-tab',
449
-            '_wpnonce',
450
-        ];
451
-        $nav_tab_link = $nav_menu_selected_id
452
-            ? esc_url(
453
-                add_query_arg(
454
-                    'extra-nav-menu-pages-tab',
455
-                    'event-archives',
456
-                    remove_query_arg($removed_args)
457
-                )
458
-            )
459
-            : '';
460
-        $select_all_link = esc_url(
461
-            add_query_arg(
462
-                [
463
-                    'extra-nav-menu-pages-tab' => 'event-archives',
464
-                    'selectall'                => 1,
465
-                ],
466
-                remove_query_arg($removed_args)
467
-            )
468
-        );
469
-        $pages = $this->_get_extra_nav_menu_pages_items();
470
-        $args['walker'] = new Walker_Nav_Menu_Checklist(false);
471
-        ;
472
-        $nav_menu_pages_items = walk_nav_menu_tree(
473
-            array_map(
474
-                [$this, '_setup_extra_nav_menu_pages_items'],
475
-                $pages
476
-            ),
477
-            0,
478
-            (object) $args
479
-        );
480
-
481
-        EEH_Template::display_template(
482
-            EE_ADMIN_TEMPLATE . 'cpt_archive_page.template.php',
483
-            [
484
-                $nav_menu_pages_items,
485
-                $nav_tab_link,
486
-                $select_all_link,
487
-            ]
488
-        );
489
-    }
490
-
491
-
492
-    /**
493
-     * Returns an array of event archive nav items.
494
-     *
495
-     * @return array
496
-     * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
497
-     *        method we use for getting the extra nav menu items
498
-     */
499
-    private function _get_extra_nav_menu_pages_items()
500
-    {
501
-        $menuitems[] = [
502
-            'title'       => esc_html__('Event List', 'event_espresso'),
503
-            'url'         => get_post_type_archive_link('espresso_events'),
504
-            'description' => esc_html__('Archive page for all events.', 'event_espresso'),
505
-        ];
506
-        return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
507
-    }
508
-
509
-
510
-    /**
511
-     * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
512
-     * the properties and converts it to the menu item object.
513
-     *
514
-     * @param $menu_item_values
515
-     * @return stdClass
516
-     * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
517
-     */
518
-    private function _setup_extra_nav_menu_pages_items($menu_item_values)
519
-    {
520
-        $menu_item = new stdClass();
521
-        $keys      = [
522
-            'ID'               => 0,
523
-            'db_id'            => 0,
524
-            'menu_item_parent' => 0,
525
-            'object_id'        => -1,
526
-            'post_parent'      => 0,
527
-            'type'             => 'custom',
528
-            'object'           => '',
529
-            'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
530
-            'title'            => '',
531
-            'url'              => '',
532
-            'target'           => '',
533
-            'attr_title'       => '',
534
-            'description'      => '',
535
-            'classes'          => [],
536
-            'xfn'              => '',
537
-        ];
538
-
539
-        foreach ($keys as $key => $value) {
540
-            $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
541
-        }
542
-        return $menu_item;
543
-    }
544
-
545
-
546
-    /**
547
-     * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
548
-     * EE_Admin_Page route is called.
549
-     *
550
-     * @return void
551
-     */
552
-    public function route_admin_request()
553
-    {
554
-    }
555
-
556
-
557
-    /**
558
-     * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
559
-     *
560
-     * @return void
561
-     */
562
-    public function wp_loaded()
563
-    {
564
-    }
565
-
566
-
567
-    /**
568
-     * admin_init
569
-     *
570
-     * @return void
571
-     * @throws InvalidArgumentException
572
-     * @throws InvalidDataTypeException
573
-     * @throws InvalidInterfaceException
574
-     */
575
-    public function admin_init()
576
-    {
577
-        /**
578
-         * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
579
-         * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
580
-         * - check if doing post processing.
581
-         * - check if doing post processing of one of EE CPTs
582
-         * - instantiate the corresponding EE CPT model for the post_type being processed.
583
-         */
584
-        $action    = $this->request->getRequestParam('action');
585
-        $post_type = $this->request->getRequestParam('post_type');
586
-        if ($post_type && $action === 'editpost') {
587
-            /** @var CustomPostTypeDefinitions $custom_post_types */
588
-            $custom_post_types = $this->loader->getShared(CustomPostTypeDefinitions::class);
589
-            $custom_post_types->getCustomPostTypeModels($post_type);
590
-        }
591
-
592
-
593
-        /**
594
-         * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
595
-         * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
596
-         * Pages" tab in the EE General Settings Admin page.
597
-         * This is for user-proofing.
598
-         */
599
-        add_filter('wp_dropdown_pages', [$this, 'modify_dropdown_pages']);
600
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
601
-            $this->adminInitModelsReady();
602
-        }
603
-    }
604
-
605
-
606
-    /**
607
-     * Runs on admin_init but only if models are usable (ie, we're not in maintenance mode)
608
-     */
609
-    protected function adminInitModelsReady()
610
-    {
611
-        if (function_exists('wp_add_privacy_policy_content')) {
612
-            $this->loader->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager');
613
-        }
614
-    }
615
-
616
-
617
-    /**
618
-     * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
619
-     *
620
-     * @param string $output Current output.
621
-     * @return string
622
-     * @throws InvalidArgumentException
623
-     * @throws InvalidDataTypeException
624
-     * @throws InvalidInterfaceException
625
-     */
626
-    public function modify_dropdown_pages($output)
627
-    {
628
-        // get critical pages
629
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
630
-
631
-        // split current output by line break for easier parsing.
632
-        $split_output = explode("\n", $output);
633
-
634
-        // loop through to remove any critical pages from the array.
635
-        foreach ($critical_pages as $page_id) {
636
-            $needle = 'value="' . $page_id . '"';
637
-            foreach ($split_output as $key => $haystack) {
638
-                if (strpos($haystack, $needle) !== false) {
639
-                    unset($split_output[ $key ]);
640
-                }
641
-            }
642
-        }
643
-        // replace output with the new contents
644
-        return implode("\n", $split_output);
645
-    }
646
-
647
-
648
-    /**
649
-     * enqueue all admin scripts that need loaded for admin pages
650
-     *
651
-     * @return void
652
-     */
653
-    public function enqueue_admin_scripts()
654
-    {
655
-        // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
656
-        // Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
657
-        // calls.
658
-        wp_enqueue_script(
659
-            'ee-inject-wp',
660
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
661
-            ['jquery'],
662
-            EVENT_ESPRESSO_VERSION,
663
-            true
664
-        );
665
-        // register cookie script for future dependencies
666
-        wp_register_script(
667
-            'jquery-cookie',
668
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
669
-            ['jquery'],
670
-            '2.1',
671
-            true
672
-        );
673
-    }
674
-
675
-
676
-    /**
677
-     * display_admin_notices
678
-     *
679
-     * @return void
680
-     */
681
-    public function display_admin_notices()
682
-    {
683
-        echo EE_Error::get_notices(); // already escaped
684
-    }
685
-
686
-
687
-    /**
688
-     * @param array $elements
689
-     * @return array
690
-     * @throws EE_Error
691
-     * @throws InvalidArgumentException
692
-     * @throws InvalidDataTypeException
693
-     * @throws InvalidInterfaceException
694
-     */
695
-    public function dashboard_glance_items($elements)
696
-    {
697
-        $elements                        = is_array($elements) ? $elements : [$elements];
698
-        $events                          = EEM_Event::instance()->count();
699
-        $items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(
700
-            ['page' => 'espresso_events'],
701
-            admin_url('admin.php')
702
-        );
703
-        $items['events']['text']         = sprintf(
704
-            esc_html(
705
-                _n('%s Event', '%s Events', $events, 'event_espresso')
706
-            ),
707
-            number_format_i18n($events)
708
-        );
709
-        $items['events']['title']        = esc_html__('Click to view all Events', 'event_espresso');
710
-        $registrations                   = EEM_Registration::instance()->count(
711
-            [
712
-                [
713
-                    'STS_ID' => ['!=', EEM_Registration::status_id_incomplete],
714
-                ],
715
-            ]
716
-        );
717
-        $items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
718
-            ['page' => 'espresso_registrations'],
719
-            admin_url('admin.php')
720
-        );
721
-        $items['registrations']['text']  = sprintf(
722
-            esc_html(
723
-                _n('%s Registration', '%s Registrations', $registrations, 'event_espresso')
724
-            ),
725
-            number_format_i18n($registrations)
726
-        );
727
-        $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
728
-
729
-        $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
730
-
731
-        foreach ($items as $type => $item_properties) {
732
-            $elements[] = sprintf(
733
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
734
-                $item_properties['url'],
735
-                $item_properties['title'],
736
-                $item_properties['text']
737
-            );
738
-        }
739
-        return $elements;
740
-    }
741
-
742
-
743
-    /**
744
-     * check_for_invalid_datetime_formats
745
-     * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
746
-     * their selected format can be parsed by PHP
747
-     *
748
-     * @param    $value
749
-     * @param    $option
750
-     * @return    string
751
-     */
752
-    public function check_for_invalid_datetime_formats($value, $option)
753
-    {
754
-        // check for date_format or time_format
755
-        switch ($option) {
756
-            case 'date_format':
757
-                $date_time_format = $value . ' ' . get_option('time_format');
758
-                break;
759
-            case 'time_format':
760
-                $date_time_format = get_option('date_format') . ' ' . $value;
761
-                break;
762
-            default:
763
-                $date_time_format = false;
764
-        }
765
-        // do we have a date_time format to check ?
766
-        if ($date_time_format) {
767
-            $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
768
-
769
-            if (is_array($error_msg)) {
770
-                $msg = '<p>'
771
-                       . sprintf(
772
-                           esc_html__(
773
-                               'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
774
-                               'event_espresso'
775
-                           ),
776
-                           date($date_time_format),
777
-                           $date_time_format
778
-                       )
779
-                       . '</p><p><ul>';
780
-
781
-
782
-                foreach ($error_msg as $error) {
783
-                    $msg .= '<li>' . $error . '</li>';
784
-                }
785
-
786
-                $msg .= '</ul></p><p>'
787
-                        . sprintf(
788
-                            esc_html__(
789
-                                '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
790
-                                'event_espresso'
791
-                            ),
792
-                            '<span style="color:#D54E21;">',
793
-                            '</span>'
794
-                        )
795
-                        . '</p>';
796
-
797
-                // trigger WP settings error
798
-                add_settings_error(
799
-                    'date_format',
800
-                    'date_format',
801
-                    $msg
802
-                );
803
-
804
-                // set format to something valid
805
-                switch ($option) {
806
-                    case 'date_format':
807
-                        $value = 'F j, Y';
808
-                        break;
809
-                    case 'time_format':
810
-                        $value = 'g:i a';
811
-                        break;
812
-                }
813
-            }
814
-        }
815
-        return $value;
816
-    }
817
-
818
-
819
-    /**
820
-     * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
821
-     *
822
-     * @param $content
823
-     * @return    string
824
-     */
825
-    public function its_eSpresso($content)
826
-    {
827
-        return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
828
-    }
829
-
830
-
831
-    /**
832
-     * espresso_admin_footer
833
-     *
834
-     * @return    string
835
-     */
836
-    public function espresso_admin_footer()
837
-    {
838
-        return EEH_Template::powered_by_event_espresso('aln-cntr', '', ['utm_content' => 'admin_footer']);
839
-    }
840
-
841
-
842
-    /**
843
-     * static method for registering ee admin page.
844
-     * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
845
-     *
846
-     * @param       $page_basename
847
-     * @param       $page_path
848
-     * @param array $config
849
-     * @return void
850
-     * @throws EE_Error
851
-     * @see        EE_Register_Admin_Page::register()
852
-     * @since      4.3.0
853
-     * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
854
-     */
855
-    public static function register_ee_admin_page($page_basename, $page_path, $config = [])
856
-    {
857
-        EE_Error::doing_it_wrong(
858
-            __METHOD__,
859
-            sprintf(
860
-                esc_html__(
861
-                    'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
862
-                    'event_espresso'
863
-                ),
864
-                $page_basename
865
-            ),
866
-            '4.3'
867
-        );
868
-        if (class_exists('EE_Register_Admin_Page')) {
869
-            $config['page_path'] = $page_path;
870
-        }
871
-        EE_Register_Admin_Page::register($page_basename, $config);
872
-    }
873
-
874
-
875
-    /**
876
-     * @param int     $post_ID
877
-     * @param WP_Post $post
878
-     * @return void
879
-     * @deprecated 4.8.41
880
-     */
881
-    public static function parse_post_content_on_save($post_ID, $post)
882
-    {
883
-        EE_Error::doing_it_wrong(
884
-            __METHOD__,
885
-            esc_html__('Usage is deprecated', 'event_espresso'),
886
-            '4.8.41'
887
-        );
888
-    }
889
-
890
-
891
-    /**
892
-     * @param  $option
893
-     * @param  $old_value
894
-     * @param  $value
895
-     * @return void
896
-     * @deprecated 4.8.41
897
-     */
898
-    public function reset_page_for_posts_on_change($option, $old_value, $value)
899
-    {
900
-        EE_Error::doing_it_wrong(
901
-            __METHOD__,
902
-            esc_html__('Usage is deprecated', 'event_espresso'),
903
-            '4.8.41'
904
-        );
905
-    }
906
-
907
-
908
-    /**
909
-     * @return void
910
-     * @deprecated 4.9.27
911
-     */
912
-    public function get_persistent_admin_notices()
913
-    {
914
-        EE_Error::doing_it_wrong(
915
-            __METHOD__,
916
-            sprintf(
917
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
918
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
919
-            ),
920
-            '4.9.27'
921
-        );
922
-    }
923
-
924
-
925
-    /**
926
-     * @throws InvalidInterfaceException
927
-     * @throws InvalidDataTypeException
928
-     * @throws DomainException
929
-     * @deprecated 4.9.27
930
-     */
931
-    public function dismiss_ee_nag_notice_callback()
932
-    {
933
-        EE_Error::doing_it_wrong(
934
-            __METHOD__,
935
-            sprintf(
936
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
937
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
938
-            ),
939
-            '4.9.27'
940
-        );
941
-        $this->persistent_admin_notice_manager->dismissNotice();
942
-    }
943
-
944
-
945
-    /**
946
-     * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.
947
-     *
948
-     * @throws InvalidArgumentException
949
-     * @throws InvalidDataTypeException
950
-     * @throws InvalidInterfaceException
951
-     */
952
-    public function hookIntoWpPluginsPage()
953
-    {
954
-        $this->loader->getShared('EventEspresso\core\domain\services\admin\ExitModal');
955
-        $this->loader
956
-             ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells')
957
-             ->decafUpsells();
958
-    }
959
-
960
-
961
-    /**
962
-     * Hooks into the "post states" filter in a wp post type list table.
963
-     *
964
-     * @param array   $post_states
965
-     * @param WP_Post $post
966
-     * @return array
967
-     * @throws InvalidArgumentException
968
-     * @throws InvalidDataTypeException
969
-     * @throws InvalidInterfaceException
970
-     */
971
-    public function displayStateForCriticalPages($post_states, $post)
972
-    {
973
-        $post_states = (array) $post_states;
974
-        if (! $post instanceof WP_Post || $post->post_type !== 'page') {
975
-            return $post_states;
976
-        }
977
-        /** @var EE_Core_Config $config */
978
-        $config = $this->loader->getShared('EE_Config')->core;
979
-        if (in_array($post->ID, $config->get_critical_pages_array(), true)) {
980
-            $post_states[] = sprintf(
981
-            /* Translators: Using company name - Event Espresso Critical Page */
982
-                esc_html__('%s Critical Page', 'event_espresso'),
983
-                'Event Espresso'
984
-            );
985
-        }
986
-        return $post_states;
987
-    }
988
-
989
-
990
-    /**
991
-     * Show documentation links on the plugins page
992
-     *
993
-     * @param mixed $meta Plugin Row Meta
994
-     * @param mixed $file Plugin Base file
995
-     * @return array
996
-     */
997
-    public function addLinksToPluginRowMeta($meta, $file)
998
-    {
999
-        if (EE_PLUGIN_BASENAME === $file) {
1000
-            $row_meta = [
1001
-                'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"'
1002
-                          . ' aria-label="'
1003
-                          . esc_attr__('View Event Espresso documentation', 'event_espresso')
1004
-                          . '">'
1005
-                          . esc_html__('Docs', 'event_espresso')
1006
-                          . '</a>',
1007
-                'api'  => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"'
1008
-                          . ' aria-label="'
1009
-                          . esc_attr__('View Event Espresso API docs', 'event_espresso')
1010
-                          . '">'
1011
-                          . esc_html__('API docs', 'event_espresso')
1012
-                          . '</a>',
1013
-            ];
1014
-            return array_merge($meta, $row_meta);
1015
-        }
1016
-        return (array) $meta;
1017
-    }
24
+	/**
25
+	 * @var EE_Admin $_instance
26
+	 */
27
+	private static $_instance;
28
+
29
+	/**
30
+	 * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
31
+	 */
32
+	private $persistent_admin_notice_manager;
33
+
34
+	/**
35
+	 * @var LoaderInterface
36
+	 */
37
+	protected $loader;
38
+
39
+	/**
40
+	 * @var RequestInterface
41
+	 */
42
+	protected $request;
43
+
44
+
45
+	/**
46
+	 * @param RequestInterface $request
47
+	 * @singleton method used to instantiate class object
48
+	 * @return EE_Admin
49
+	 * @throws EE_Error
50
+	 */
51
+	public static function instance(RequestInterface $request = null)
52
+	{
53
+		// check if class object is instantiated
54
+		if (! self::$_instance instanceof EE_Admin) {
55
+			self::$_instance = new self($request);
56
+		}
57
+		return self::$_instance;
58
+	}
59
+
60
+
61
+	/**
62
+	 * @return EE_Admin
63
+	 * @throws EE_Error
64
+	 */
65
+	public static function reset()
66
+	{
67
+		self::$_instance = null;
68
+		$request         = LoaderFactory::getLoader()->getShared(RequestInterface::class);
69
+		return self::instance($request);
70
+	}
71
+
72
+
73
+	/**
74
+	 * @param RequestInterface $request
75
+	 * @throws EE_Error
76
+	 * @throws InvalidDataTypeException
77
+	 * @throws InvalidInterfaceException
78
+	 * @throws InvalidArgumentException
79
+	 */
80
+	protected function __construct(RequestInterface $request)
81
+	{
82
+		$this->request = $request;
83
+		$this->loader = LoaderFactory::getLoader();
84
+		// define global EE_Admin constants
85
+		$this->_define_all_constants();
86
+		// set autoloaders for our admin page classes based on included path information
87
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
88
+		// admin hooks
89
+		add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2);
90
+		add_action('AHEE__EE_System__initialize_last', [$this, 'init']);
91
+		add_action('AHEE__EE_Admin_Page__route_admin_request', [$this, 'route_admin_request'], 100, 2);
92
+		add_action('wp_loaded', [$this, 'wp_loaded'], 100);
93
+		add_action('admin_init', [$this, 'admin_init'], 100);
94
+		add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts'], 20);
95
+		add_action('admin_notices', [$this, 'display_admin_notices'], 10);
96
+		add_action('network_admin_notices', [$this, 'display_admin_notices'], 10);
97
+		add_filter('pre_update_option', [$this, 'check_for_invalid_datetime_formats'], 100, 2);
98
+		add_filter('admin_footer_text', [$this, 'espresso_admin_footer']);
99
+		add_action('load-plugins.php', [$this, 'hookIntoWpPluginsPage']);
100
+		add_action('display_post_states', [$this, 'displayStateForCriticalPages'], 10, 2);
101
+		add_filter('plugin_row_meta', [$this, 'addLinksToPluginRowMeta'], 10, 2);
102
+		// reset Environment config (we only do this on admin page loads);
103
+		EE_Registry::instance()->CFG->environment->recheck_values();
104
+		do_action('AHEE__EE_Admin__loaded');
105
+	}
106
+
107
+
108
+	/**
109
+	 * _define_all_constants
110
+	 * define constants that are set globally for all admin pages
111
+	 *
112
+	 * @return void
113
+	 */
114
+	private function _define_all_constants()
115
+	{
116
+		if (! defined('EE_ADMIN_URL')) {
117
+			define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
118
+			define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
119
+			define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/');
120
+			define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
121
+			define('WP_AJAX_URL', admin_url('admin-ajax.php'));
122
+		}
123
+	}
124
+
125
+
126
+	/**
127
+	 * filter_plugin_actions - adds links to the Plugins page listing
128
+	 *
129
+	 * @param array  $links
130
+	 * @param string $plugin
131
+	 * @return    array
132
+	 */
133
+	public function filter_plugin_actions($links, $plugin)
134
+	{
135
+		// set $main_file in stone
136
+		static $main_file;
137
+		// if $main_file is not set yet
138
+		if (! $main_file) {
139
+			$main_file = EE_PLUGIN_BASENAME;
140
+		}
141
+		if ($plugin === $main_file) {
142
+			// compare current plugin to this one
143
+			if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
144
+				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
145
+									. ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
146
+									. esc_html__('Maintenance Mode Active', 'event_espresso')
147
+									. '</a>';
148
+				array_unshift($links, $maintenance_link);
149
+			} else {
150
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
151
+									 . esc_html__('Settings', 'event_espresso')
152
+									 . '</a>';
153
+				$events_link       = '<a href="admin.php?page=espresso_events">'
154
+									 . esc_html__('Events', 'event_espresso')
155
+									 . '</a>';
156
+				// add before other links
157
+				array_unshift($links, $org_settings_link, $events_link);
158
+			}
159
+		}
160
+		return $links;
161
+	}
162
+
163
+
164
+	/**
165
+	 * @deprecated 4.10.14.p
166
+	 */
167
+	public function get_request()
168
+	{
169
+	}
170
+
171
+
172
+	/**
173
+	 * hide_admin_pages_except_maintenance_mode
174
+	 *
175
+	 * @param array $admin_page_folder_names
176
+	 * @return array
177
+	 */
178
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = [])
179
+	{
180
+		return [
181
+			'maintenance' => EE_ADMIN_PAGES . 'maintenance/',
182
+			'about'       => EE_ADMIN_PAGES . 'about/',
183
+			'support'     => EE_ADMIN_PAGES . 'support/',
184
+		];
185
+	}
186
+
187
+
188
+	/**
189
+	 * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
190
+	 * EE_Front_Controller's init phases have run
191
+	 *
192
+	 * @return void
193
+	 * @throws EE_Error
194
+	 * @throws InvalidArgumentException
195
+	 * @throws InvalidDataTypeException
196
+	 * @throws InvalidInterfaceException
197
+	 * @throws ReflectionException
198
+	 * @throws ServiceNotFoundException
199
+	 */
200
+	public function init()
201
+	{
202
+		// only enable most of the EE_Admin IF we're not in full maintenance mode
203
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
204
+			$this->initModelsReady();
205
+		}
206
+		// run the admin page factory but ONLY if:
207
+		// - it is a regular non ajax admin request
208
+		// - we are doing an ee admin ajax request
209
+		if ($this->request->isAdmin() || $this->request->isAdminAjax()) {
210
+			// this loads the controller for the admin pages which will setup routing etc
211
+			$this->loader->getShared('EE_Admin_Page_Loader', [$this->loader]);
212
+		}
213
+		if ($this->request->isAdminAjax()) {
214
+			return;
215
+		}
216
+		add_filter('content_save_pre', [$this, 'its_eSpresso'], 10, 1);
217
+		// make sure our CPTs and custom taxonomy metaboxes get shown for first time users
218
+		add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes'], 10);
219
+		add_action('admin_head', [$this, 'register_custom_nav_menu_boxes'], 10);
220
+		// exclude EE critical pages from all nav menus and wp_list_pages
221
+		add_filter('nav_menu_meta_box_object', [$this, 'remove_pages_from_nav_menu'], 10);
222
+	}
223
+
224
+
225
+	/**
226
+	 * Gets the loader (and if it wasn't previously set, sets it)
227
+	 *
228
+	 * @return LoaderInterface
229
+	 * @throws InvalidArgumentException
230
+	 * @throws InvalidDataTypeException
231
+	 * @throws InvalidInterfaceException
232
+	 */
233
+	protected function getLoader()
234
+	{
235
+		return $this->loader;
236
+	}
237
+
238
+
239
+	/**
240
+	 * Method that's fired on admin requests (including admin ajax) but only when the models are usable
241
+	 * (ie, the site isn't in maintenance mode)
242
+	 *
243
+	 * @return void
244
+	 * @throws EE_Error
245
+	 * @since 4.9.63.p
246
+	 */
247
+	protected function initModelsReady()
248
+	{
249
+		// ok so we want to enable the entire admin
250
+		$this->persistent_admin_notice_manager = $this->loader->getShared(
251
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
252
+		);
253
+		$this->persistent_admin_notice_manager->setReturnUrl(
254
+			EE_Admin_Page::add_query_args_and_nonce(
255
+				[
256
+					'page'   => $this->request->getRequestParam('page'),
257
+					'action' => $this->request->getRequestParam('action'),
258
+				],
259
+				EE_ADMIN_URL
260
+			)
261
+		);
262
+		$this->maybeSetDatetimeWarningNotice();
263
+		// at a glance dashboard widget
264
+		add_filter('dashboard_glance_items', [$this, 'dashboard_glance_items'], 10);
265
+		// filter for get_edit_post_link used on comments for custom post types
266
+		add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 2);
267
+	}
268
+
269
+
270
+	/**
271
+	 *    get_persistent_admin_notices
272
+	 *
273
+	 * @access    public
274
+	 * @return void
275
+	 * @throws EE_Error
276
+	 * @throws InvalidArgumentException
277
+	 * @throws InvalidDataTypeException
278
+	 * @throws InvalidInterfaceException
279
+	 */
280
+	public function maybeSetDatetimeWarningNotice()
281
+	{
282
+		// add dismissible notice for datetime changes.  Only valid if site does not have a timezone_string set.
283
+		// @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
284
+		// with this.  But after enough time (indeterminate at this point) we can just remove this notice.
285
+		// this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
286
+		if (
287
+			apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
288
+			&& ! get_option('timezone_string')
289
+			&& EEM_Event::instance()->count() > 0
290
+		) {
291
+			new PersistentAdminNotice(
292
+				'datetime_fix_notice',
293
+				sprintf(
294
+					esc_html__(
295
+						'%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times.  Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',
296
+						'event_espresso'
297
+					),
298
+					'<strong>',
299
+					'</strong>',
300
+					'<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
301
+					'</a>',
302
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
303
+						[
304
+							'page'   => 'espresso_maintenance_settings',
305
+							'action' => 'datetime_tools',
306
+						],
307
+						admin_url('admin.php')
308
+					) . '">'
309
+				),
310
+				false,
311
+				'manage_options',
312
+				'datetime_fix_persistent_notice'
313
+			);
314
+		}
315
+	}
316
+
317
+
318
+	/**
319
+	 * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
320
+	 * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
321
+	 * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
322
+	 * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
323
+	 * normal property on the post_type object.  It's found ONLY in this particular context.
324
+	 *
325
+	 * @param WP_Post $post_type WP post type object
326
+	 * @return WP_Post
327
+	 * @throws InvalidArgumentException
328
+	 * @throws InvalidDataTypeException
329
+	 * @throws InvalidInterfaceException
330
+	 */
331
+	public function remove_pages_from_nav_menu($post_type)
332
+	{
333
+		// if this isn't the "pages" post type let's get out
334
+		if ($post_type->name !== 'page') {
335
+			return $post_type;
336
+		}
337
+		$critical_pages            = EE_Registry::instance()->CFG->core->get_critical_pages_array();
338
+		$post_type->_default_query = [
339
+			'post__not_in' => $critical_pages,
340
+		];
341
+		return $post_type;
342
+	}
343
+
344
+
345
+	/**
346
+	 * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
347
+	 * metaboxes get shown as well
348
+	 *
349
+	 * @return void
350
+	 */
351
+	public function enable_hidden_ee_nav_menu_metaboxes()
352
+	{
353
+		global $wp_meta_boxes, $pagenow;
354
+		if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
355
+			return;
356
+		}
357
+		$user = wp_get_current_user();
358
+		// has this been done yet?
359
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
360
+			return;
361
+		}
362
+
363
+		$hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
364
+		$initial_meta_boxes = apply_filters(
365
+			'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
366
+			[
367
+				'nav-menu-theme-locations',
368
+				'add-page',
369
+				'add-custom-links',
370
+				'add-category',
371
+				'add-espresso_events',
372
+				'add-espresso_venues',
373
+				'add-espresso_event_categories',
374
+				'add-espresso_venue_categories',
375
+				'add-post-type-post',
376
+				'add-post-type-page',
377
+			]
378
+		);
379
+
380
+		if (is_array($hidden_meta_boxes)) {
381
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
382
+				if (in_array($meta_box_id, $initial_meta_boxes, true)) {
383
+					unset($hidden_meta_boxes[ $key ]);
384
+				}
385
+			}
386
+		}
387
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
388
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
389
+	}
390
+
391
+
392
+	/**
393
+	 * This method simply registers custom nav menu boxes for "nav_menus.php route"
394
+	 * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
395
+	 *
396
+	 * @return void
397
+	 * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
398
+	 *         addons etc.
399
+	 */
400
+	public function register_custom_nav_menu_boxes()
401
+	{
402
+		add_meta_box(
403
+			'add-extra-nav-menu-pages',
404
+			esc_html__('Event Espresso Pages', 'event_espresso'),
405
+			[$this, 'ee_cpt_archive_pages'],
406
+			'nav-menus',
407
+			'side',
408
+			'core'
409
+		);
410
+	}
411
+
412
+
413
+	/**
414
+	 * Use this to edit the post link for our cpts so that the edit link points to the correct page.
415
+	 *
416
+	 * @param string $link the original link generated by wp
417
+	 * @param int    $id   post id
418
+	 * @return string  the (maybe) modified link
419
+	 * @since   4.3.0
420
+	 */
421
+	public function modify_edit_post_link($link, $id)
422
+	{
423
+		if (! $post = get_post($id)) {
424
+			return $link;
425
+		}
426
+		if ($post->post_type === 'espresso_attendees') {
427
+			$query_args = [
428
+				'action' => 'edit_attendee',
429
+				'post'   => $id,
430
+			];
431
+			return EEH_URL::add_query_args_and_nonce(
432
+				$query_args,
433
+				admin_url('admin.php?page=espresso_registrations')
434
+			);
435
+		}
436
+		return $link;
437
+	}
438
+
439
+
440
+	public function ee_cpt_archive_pages()
441
+	{
442
+		global $nav_menu_selected_id;
443
+		$removed_args = [
444
+			'action',
445
+			'customlink-tab',
446
+			'edit-menu-item',
447
+			'menu-item',
448
+			'page-tab',
449
+			'_wpnonce',
450
+		];
451
+		$nav_tab_link = $nav_menu_selected_id
452
+			? esc_url(
453
+				add_query_arg(
454
+					'extra-nav-menu-pages-tab',
455
+					'event-archives',
456
+					remove_query_arg($removed_args)
457
+				)
458
+			)
459
+			: '';
460
+		$select_all_link = esc_url(
461
+			add_query_arg(
462
+				[
463
+					'extra-nav-menu-pages-tab' => 'event-archives',
464
+					'selectall'                => 1,
465
+				],
466
+				remove_query_arg($removed_args)
467
+			)
468
+		);
469
+		$pages = $this->_get_extra_nav_menu_pages_items();
470
+		$args['walker'] = new Walker_Nav_Menu_Checklist(false);
471
+		;
472
+		$nav_menu_pages_items = walk_nav_menu_tree(
473
+			array_map(
474
+				[$this, '_setup_extra_nav_menu_pages_items'],
475
+				$pages
476
+			),
477
+			0,
478
+			(object) $args
479
+		);
480
+
481
+		EEH_Template::display_template(
482
+			EE_ADMIN_TEMPLATE . 'cpt_archive_page.template.php',
483
+			[
484
+				$nav_menu_pages_items,
485
+				$nav_tab_link,
486
+				$select_all_link,
487
+			]
488
+		);
489
+	}
490
+
491
+
492
+	/**
493
+	 * Returns an array of event archive nav items.
494
+	 *
495
+	 * @return array
496
+	 * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
497
+	 *        method we use for getting the extra nav menu items
498
+	 */
499
+	private function _get_extra_nav_menu_pages_items()
500
+	{
501
+		$menuitems[] = [
502
+			'title'       => esc_html__('Event List', 'event_espresso'),
503
+			'url'         => get_post_type_archive_link('espresso_events'),
504
+			'description' => esc_html__('Archive page for all events.', 'event_espresso'),
505
+		];
506
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
507
+	}
508
+
509
+
510
+	/**
511
+	 * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
512
+	 * the properties and converts it to the menu item object.
513
+	 *
514
+	 * @param $menu_item_values
515
+	 * @return stdClass
516
+	 * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
517
+	 */
518
+	private function _setup_extra_nav_menu_pages_items($menu_item_values)
519
+	{
520
+		$menu_item = new stdClass();
521
+		$keys      = [
522
+			'ID'               => 0,
523
+			'db_id'            => 0,
524
+			'menu_item_parent' => 0,
525
+			'object_id'        => -1,
526
+			'post_parent'      => 0,
527
+			'type'             => 'custom',
528
+			'object'           => '',
529
+			'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
530
+			'title'            => '',
531
+			'url'              => '',
532
+			'target'           => '',
533
+			'attr_title'       => '',
534
+			'description'      => '',
535
+			'classes'          => [],
536
+			'xfn'              => '',
537
+		];
538
+
539
+		foreach ($keys as $key => $value) {
540
+			$menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
541
+		}
542
+		return $menu_item;
543
+	}
544
+
545
+
546
+	/**
547
+	 * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
548
+	 * EE_Admin_Page route is called.
549
+	 *
550
+	 * @return void
551
+	 */
552
+	public function route_admin_request()
553
+	{
554
+	}
555
+
556
+
557
+	/**
558
+	 * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
559
+	 *
560
+	 * @return void
561
+	 */
562
+	public function wp_loaded()
563
+	{
564
+	}
565
+
566
+
567
+	/**
568
+	 * admin_init
569
+	 *
570
+	 * @return void
571
+	 * @throws InvalidArgumentException
572
+	 * @throws InvalidDataTypeException
573
+	 * @throws InvalidInterfaceException
574
+	 */
575
+	public function admin_init()
576
+	{
577
+		/**
578
+		 * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
579
+		 * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
580
+		 * - check if doing post processing.
581
+		 * - check if doing post processing of one of EE CPTs
582
+		 * - instantiate the corresponding EE CPT model for the post_type being processed.
583
+		 */
584
+		$action    = $this->request->getRequestParam('action');
585
+		$post_type = $this->request->getRequestParam('post_type');
586
+		if ($post_type && $action === 'editpost') {
587
+			/** @var CustomPostTypeDefinitions $custom_post_types */
588
+			$custom_post_types = $this->loader->getShared(CustomPostTypeDefinitions::class);
589
+			$custom_post_types->getCustomPostTypeModels($post_type);
590
+		}
591
+
592
+
593
+		/**
594
+		 * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
595
+		 * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
596
+		 * Pages" tab in the EE General Settings Admin page.
597
+		 * This is for user-proofing.
598
+		 */
599
+		add_filter('wp_dropdown_pages', [$this, 'modify_dropdown_pages']);
600
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
601
+			$this->adminInitModelsReady();
602
+		}
603
+	}
604
+
605
+
606
+	/**
607
+	 * Runs on admin_init but only if models are usable (ie, we're not in maintenance mode)
608
+	 */
609
+	protected function adminInitModelsReady()
610
+	{
611
+		if (function_exists('wp_add_privacy_policy_content')) {
612
+			$this->loader->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager');
613
+		}
614
+	}
615
+
616
+
617
+	/**
618
+	 * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
619
+	 *
620
+	 * @param string $output Current output.
621
+	 * @return string
622
+	 * @throws InvalidArgumentException
623
+	 * @throws InvalidDataTypeException
624
+	 * @throws InvalidInterfaceException
625
+	 */
626
+	public function modify_dropdown_pages($output)
627
+	{
628
+		// get critical pages
629
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
630
+
631
+		// split current output by line break for easier parsing.
632
+		$split_output = explode("\n", $output);
633
+
634
+		// loop through to remove any critical pages from the array.
635
+		foreach ($critical_pages as $page_id) {
636
+			$needle = 'value="' . $page_id . '"';
637
+			foreach ($split_output as $key => $haystack) {
638
+				if (strpos($haystack, $needle) !== false) {
639
+					unset($split_output[ $key ]);
640
+				}
641
+			}
642
+		}
643
+		// replace output with the new contents
644
+		return implode("\n", $split_output);
645
+	}
646
+
647
+
648
+	/**
649
+	 * enqueue all admin scripts that need loaded for admin pages
650
+	 *
651
+	 * @return void
652
+	 */
653
+	public function enqueue_admin_scripts()
654
+	{
655
+		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
656
+		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
657
+		// calls.
658
+		wp_enqueue_script(
659
+			'ee-inject-wp',
660
+			EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
661
+			['jquery'],
662
+			EVENT_ESPRESSO_VERSION,
663
+			true
664
+		);
665
+		// register cookie script for future dependencies
666
+		wp_register_script(
667
+			'jquery-cookie',
668
+			EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
669
+			['jquery'],
670
+			'2.1',
671
+			true
672
+		);
673
+	}
674
+
675
+
676
+	/**
677
+	 * display_admin_notices
678
+	 *
679
+	 * @return void
680
+	 */
681
+	public function display_admin_notices()
682
+	{
683
+		echo EE_Error::get_notices(); // already escaped
684
+	}
685
+
686
+
687
+	/**
688
+	 * @param array $elements
689
+	 * @return array
690
+	 * @throws EE_Error
691
+	 * @throws InvalidArgumentException
692
+	 * @throws InvalidDataTypeException
693
+	 * @throws InvalidInterfaceException
694
+	 */
695
+	public function dashboard_glance_items($elements)
696
+	{
697
+		$elements                        = is_array($elements) ? $elements : [$elements];
698
+		$events                          = EEM_Event::instance()->count();
699
+		$items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(
700
+			['page' => 'espresso_events'],
701
+			admin_url('admin.php')
702
+		);
703
+		$items['events']['text']         = sprintf(
704
+			esc_html(
705
+				_n('%s Event', '%s Events', $events, 'event_espresso')
706
+			),
707
+			number_format_i18n($events)
708
+		);
709
+		$items['events']['title']        = esc_html__('Click to view all Events', 'event_espresso');
710
+		$registrations                   = EEM_Registration::instance()->count(
711
+			[
712
+				[
713
+					'STS_ID' => ['!=', EEM_Registration::status_id_incomplete],
714
+				],
715
+			]
716
+		);
717
+		$items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
718
+			['page' => 'espresso_registrations'],
719
+			admin_url('admin.php')
720
+		);
721
+		$items['registrations']['text']  = sprintf(
722
+			esc_html(
723
+				_n('%s Registration', '%s Registrations', $registrations, 'event_espresso')
724
+			),
725
+			number_format_i18n($registrations)
726
+		);
727
+		$items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
728
+
729
+		$items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
730
+
731
+		foreach ($items as $type => $item_properties) {
732
+			$elements[] = sprintf(
733
+				'<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
734
+				$item_properties['url'],
735
+				$item_properties['title'],
736
+				$item_properties['text']
737
+			);
738
+		}
739
+		return $elements;
740
+	}
741
+
742
+
743
+	/**
744
+	 * check_for_invalid_datetime_formats
745
+	 * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
746
+	 * their selected format can be parsed by PHP
747
+	 *
748
+	 * @param    $value
749
+	 * @param    $option
750
+	 * @return    string
751
+	 */
752
+	public function check_for_invalid_datetime_formats($value, $option)
753
+	{
754
+		// check for date_format or time_format
755
+		switch ($option) {
756
+			case 'date_format':
757
+				$date_time_format = $value . ' ' . get_option('time_format');
758
+				break;
759
+			case 'time_format':
760
+				$date_time_format = get_option('date_format') . ' ' . $value;
761
+				break;
762
+			default:
763
+				$date_time_format = false;
764
+		}
765
+		// do we have a date_time format to check ?
766
+		if ($date_time_format) {
767
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
768
+
769
+			if (is_array($error_msg)) {
770
+				$msg = '<p>'
771
+					   . sprintf(
772
+						   esc_html__(
773
+							   'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
774
+							   'event_espresso'
775
+						   ),
776
+						   date($date_time_format),
777
+						   $date_time_format
778
+					   )
779
+					   . '</p><p><ul>';
780
+
781
+
782
+				foreach ($error_msg as $error) {
783
+					$msg .= '<li>' . $error . '</li>';
784
+				}
785
+
786
+				$msg .= '</ul></p><p>'
787
+						. sprintf(
788
+							esc_html__(
789
+								'%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
790
+								'event_espresso'
791
+							),
792
+							'<span style="color:#D54E21;">',
793
+							'</span>'
794
+						)
795
+						. '</p>';
796
+
797
+				// trigger WP settings error
798
+				add_settings_error(
799
+					'date_format',
800
+					'date_format',
801
+					$msg
802
+				);
803
+
804
+				// set format to something valid
805
+				switch ($option) {
806
+					case 'date_format':
807
+						$value = 'F j, Y';
808
+						break;
809
+					case 'time_format':
810
+						$value = 'g:i a';
811
+						break;
812
+				}
813
+			}
814
+		}
815
+		return $value;
816
+	}
817
+
818
+
819
+	/**
820
+	 * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
821
+	 *
822
+	 * @param $content
823
+	 * @return    string
824
+	 */
825
+	public function its_eSpresso($content)
826
+	{
827
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
828
+	}
829
+
830
+
831
+	/**
832
+	 * espresso_admin_footer
833
+	 *
834
+	 * @return    string
835
+	 */
836
+	public function espresso_admin_footer()
837
+	{
838
+		return EEH_Template::powered_by_event_espresso('aln-cntr', '', ['utm_content' => 'admin_footer']);
839
+	}
840
+
841
+
842
+	/**
843
+	 * static method for registering ee admin page.
844
+	 * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
845
+	 *
846
+	 * @param       $page_basename
847
+	 * @param       $page_path
848
+	 * @param array $config
849
+	 * @return void
850
+	 * @throws EE_Error
851
+	 * @see        EE_Register_Admin_Page::register()
852
+	 * @since      4.3.0
853
+	 * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
854
+	 */
855
+	public static function register_ee_admin_page($page_basename, $page_path, $config = [])
856
+	{
857
+		EE_Error::doing_it_wrong(
858
+			__METHOD__,
859
+			sprintf(
860
+				esc_html__(
861
+					'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
862
+					'event_espresso'
863
+				),
864
+				$page_basename
865
+			),
866
+			'4.3'
867
+		);
868
+		if (class_exists('EE_Register_Admin_Page')) {
869
+			$config['page_path'] = $page_path;
870
+		}
871
+		EE_Register_Admin_Page::register($page_basename, $config);
872
+	}
873
+
874
+
875
+	/**
876
+	 * @param int     $post_ID
877
+	 * @param WP_Post $post
878
+	 * @return void
879
+	 * @deprecated 4.8.41
880
+	 */
881
+	public static function parse_post_content_on_save($post_ID, $post)
882
+	{
883
+		EE_Error::doing_it_wrong(
884
+			__METHOD__,
885
+			esc_html__('Usage is deprecated', 'event_espresso'),
886
+			'4.8.41'
887
+		);
888
+	}
889
+
890
+
891
+	/**
892
+	 * @param  $option
893
+	 * @param  $old_value
894
+	 * @param  $value
895
+	 * @return void
896
+	 * @deprecated 4.8.41
897
+	 */
898
+	public function reset_page_for_posts_on_change($option, $old_value, $value)
899
+	{
900
+		EE_Error::doing_it_wrong(
901
+			__METHOD__,
902
+			esc_html__('Usage is deprecated', 'event_espresso'),
903
+			'4.8.41'
904
+		);
905
+	}
906
+
907
+
908
+	/**
909
+	 * @return void
910
+	 * @deprecated 4.9.27
911
+	 */
912
+	public function get_persistent_admin_notices()
913
+	{
914
+		EE_Error::doing_it_wrong(
915
+			__METHOD__,
916
+			sprintf(
917
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
918
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
919
+			),
920
+			'4.9.27'
921
+		);
922
+	}
923
+
924
+
925
+	/**
926
+	 * @throws InvalidInterfaceException
927
+	 * @throws InvalidDataTypeException
928
+	 * @throws DomainException
929
+	 * @deprecated 4.9.27
930
+	 */
931
+	public function dismiss_ee_nag_notice_callback()
932
+	{
933
+		EE_Error::doing_it_wrong(
934
+			__METHOD__,
935
+			sprintf(
936
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
937
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
938
+			),
939
+			'4.9.27'
940
+		);
941
+		$this->persistent_admin_notice_manager->dismissNotice();
942
+	}
943
+
944
+
945
+	/**
946
+	 * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.
947
+	 *
948
+	 * @throws InvalidArgumentException
949
+	 * @throws InvalidDataTypeException
950
+	 * @throws InvalidInterfaceException
951
+	 */
952
+	public function hookIntoWpPluginsPage()
953
+	{
954
+		$this->loader->getShared('EventEspresso\core\domain\services\admin\ExitModal');
955
+		$this->loader
956
+			 ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells')
957
+			 ->decafUpsells();
958
+	}
959
+
960
+
961
+	/**
962
+	 * Hooks into the "post states" filter in a wp post type list table.
963
+	 *
964
+	 * @param array   $post_states
965
+	 * @param WP_Post $post
966
+	 * @return array
967
+	 * @throws InvalidArgumentException
968
+	 * @throws InvalidDataTypeException
969
+	 * @throws InvalidInterfaceException
970
+	 */
971
+	public function displayStateForCriticalPages($post_states, $post)
972
+	{
973
+		$post_states = (array) $post_states;
974
+		if (! $post instanceof WP_Post || $post->post_type !== 'page') {
975
+			return $post_states;
976
+		}
977
+		/** @var EE_Core_Config $config */
978
+		$config = $this->loader->getShared('EE_Config')->core;
979
+		if (in_array($post->ID, $config->get_critical_pages_array(), true)) {
980
+			$post_states[] = sprintf(
981
+			/* Translators: Using company name - Event Espresso Critical Page */
982
+				esc_html__('%s Critical Page', 'event_espresso'),
983
+				'Event Espresso'
984
+			);
985
+		}
986
+		return $post_states;
987
+	}
988
+
989
+
990
+	/**
991
+	 * Show documentation links on the plugins page
992
+	 *
993
+	 * @param mixed $meta Plugin Row Meta
994
+	 * @param mixed $file Plugin Base file
995
+	 * @return array
996
+	 */
997
+	public function addLinksToPluginRowMeta($meta, $file)
998
+	{
999
+		if (EE_PLUGIN_BASENAME === $file) {
1000
+			$row_meta = [
1001
+				'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"'
1002
+						  . ' aria-label="'
1003
+						  . esc_attr__('View Event Espresso documentation', 'event_espresso')
1004
+						  . '">'
1005
+						  . esc_html__('Docs', 'event_espresso')
1006
+						  . '</a>',
1007
+				'api'  => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"'
1008
+						  . ' aria-label="'
1009
+						  . esc_attr__('View Event Espresso API docs', 'event_espresso')
1010
+						  . '">'
1011
+						  . esc_html__('API docs', 'event_espresso')
1012
+						  . '</a>',
1013
+			];
1014
+			return array_merge($meta, $row_meta);
1015
+		}
1016
+		return (array) $meta;
1017
+	}
1018 1018
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +3905 added lines, -3905 removed lines patch added patch discarded remove patch
@@ -18,3979 +18,3979 @@
 block discarded – undo
18 18
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var LoaderInterface
23
-     */
24
-    protected $loader;
21
+	/**
22
+	 * @var LoaderInterface
23
+	 */
24
+	protected $loader;
25 25
 
26
-    /**
27
-     * @var RequestInterface
28
-     */
29
-    protected $request;
26
+	/**
27
+	 * @var RequestInterface
28
+	 */
29
+	protected $request;
30 30
 
31
-    // set in _init_page_props()
32
-    public $page_slug;
31
+	// set in _init_page_props()
32
+	public $page_slug;
33 33
 
34
-    public $page_label;
34
+	public $page_label;
35 35
 
36
-    public $page_folder;
36
+	public $page_folder;
37 37
 
38
-    // set in define_page_props()
39
-    protected $_admin_base_url;
38
+	// set in define_page_props()
39
+	protected $_admin_base_url;
40 40
 
41
-    protected $_admin_base_path;
41
+	protected $_admin_base_path;
42 42
 
43
-    protected $_admin_page_title;
43
+	protected $_admin_page_title;
44 44
 
45
-    protected $_labels;
45
+	protected $_labels;
46 46
 
47 47
 
48
-    // set early within EE_Admin_Init
49
-    protected $_wp_page_slug;
48
+	// set early within EE_Admin_Init
49
+	protected $_wp_page_slug;
50 50
 
51
-    // navtabs
52
-    protected $_nav_tabs;
51
+	// navtabs
52
+	protected $_nav_tabs;
53 53
 
54
-    protected $_default_nav_tab_name;
54
+	protected $_default_nav_tab_name;
55 55
 
56 56
 
57
-    // template variables (used by templates)
58
-    protected $_template_path;
57
+	// template variables (used by templates)
58
+	protected $_template_path;
59 59
 
60
-    protected $_column_template_path;
60
+	protected $_column_template_path;
61 61
 
62
-    /**
63
-     * @var array $_template_args
64
-     */
65
-    protected $_template_args = [];
62
+	/**
63
+	 * @var array $_template_args
64
+	 */
65
+	protected $_template_args = [];
66 66
 
67
-    /**
68
-     * this will hold the list table object for a given view.
69
-     *
70
-     * @var EE_Admin_List_Table $_list_table_object
71
-     */
72
-    protected $_list_table_object;
67
+	/**
68
+	 * this will hold the list table object for a given view.
69
+	 *
70
+	 * @var EE_Admin_List_Table $_list_table_object
71
+	 */
72
+	protected $_list_table_object;
73 73
 
74
-    // bools
75
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
74
+	// bools
75
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
76 76
 
77
-    protected $_routing;
77
+	protected $_routing;
78 78
 
79
-    // list table args
80
-    protected $_view;
79
+	// list table args
80
+	protected $_view;
81 81
 
82
-    protected $_views;
82
+	protected $_views;
83 83
 
84 84
 
85
-    // action => method pairs used for routing incoming requests
86
-    protected $_page_routes;
85
+	// action => method pairs used for routing incoming requests
86
+	protected $_page_routes;
87 87
 
88
-    /**
89
-     * @var array $_page_config
90
-     */
91
-    protected $_page_config;
88
+	/**
89
+	 * @var array $_page_config
90
+	 */
91
+	protected $_page_config;
92 92
 
93
-    /**
94
-     * the current page route and route config
95
-     *
96
-     * @var string $_route
97
-     */
98
-    protected $_route;
93
+	/**
94
+	 * the current page route and route config
95
+	 *
96
+	 * @var string $_route
97
+	 */
98
+	protected $_route;
99 99
 
100
-    /**
101
-     * @var string $_cpt_route
102
-     */
103
-    protected $_cpt_route;
100
+	/**
101
+	 * @var string $_cpt_route
102
+	 */
103
+	protected $_cpt_route;
104 104
 
105
-    /**
106
-     * @var array $_route_config
107
-     */
108
-    protected $_route_config;
105
+	/**
106
+	 * @var array $_route_config
107
+	 */
108
+	protected $_route_config;
109 109
 
110
-    /**
111
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
112
-     * actions.
113
-     *
114
-     * @since 4.6.x
115
-     * @var array.
116
-     */
117
-    protected $_default_route_query_args;
118
-
119
-    // set via request page and action args.
120
-    protected $_current_page;
121
-
122
-    protected $_current_view;
123
-
124
-    protected $_current_page_view_url;
125
-
126
-    /**
127
-     * unprocessed value for the 'action' request param (default '')
128
-     *
129
-     * @var string
130
-     */
131
-    protected $raw_req_action = '';
132
-
133
-    /**
134
-     * unprocessed value for the 'page' request param (default '')
135
-     *
136
-     * @var string
137
-     */
138
-    protected $raw_req_page = '';
139
-
140
-    /**
141
-     * sanitized request action (and nonce)
142
-     *
143
-     * @var string
144
-     */
145
-    protected $_req_action = '';
146
-
147
-    /**
148
-     * sanitized request action nonce
149
-     *
150
-     * @var string
151
-     */
152
-    protected $_req_nonce = '';
153
-
154
-    /**
155
-     * @var string
156
-     */
157
-    protected $_search_btn_label = '';
158
-
159
-    /**
160
-     * @var string
161
-     */
162
-    protected $_search_box_callback = '';
163
-
164
-    /**
165
-     * @var WP_Screen
166
-     */
167
-    protected $_current_screen;
168
-
169
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
170
-    protected $_hook_obj;
171
-
172
-    // for holding incoming request data
173
-    protected $_req_data = [];
174
-
175
-    // yes / no array for admin form fields
176
-    protected $_yes_no_values = [];
177
-
178
-    // some default things shared by all child classes
179
-    protected $_default_espresso_metaboxes;
180
-
181
-    /**
182
-     * @var EE_Registry
183
-     */
184
-    protected $EE = null;
185
-
186
-
187
-    /**
188
-     * This is just a property that flags whether the given route is a caffeinated route or not.
189
-     *
190
-     * @var boolean
191
-     */
192
-    protected $_is_caf = false;
193
-
194
-
195
-    /**
196
-     * @Constructor
197
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
198
-     * @throws EE_Error
199
-     * @throws InvalidArgumentException
200
-     * @throws ReflectionException
201
-     * @throws InvalidDataTypeException
202
-     * @throws InvalidInterfaceException
203
-     */
204
-    public function __construct($routing = true)
205
-    {
206
-        $this->loader  = LoaderFactory::getLoader();
207
-        $this->request = $this->loader->getShared(RequestInterface::class);
208
-        $this->_routing = $routing;
209
-
210
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
211
-            $this->_is_caf = true;
212
-        }
213
-        $this->_yes_no_values = [
214
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
215
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
216
-        ];
217
-        // set the _req_data property.
218
-        $this->_req_data = $this->request->requestParams();
219
-        // set initial page props (child method)
220
-        $this->_init_page_props();
221
-        // set global defaults
222
-        $this->_set_defaults();
223
-        // set early because incoming requests could be ajax related and we need to register those hooks.
224
-        $this->_global_ajax_hooks();
225
-        $this->_ajax_hooks();
226
-        // other_page_hooks have to be early too.
227
-        $this->_do_other_page_hooks();
228
-        // set up page dependencies
229
-        $this->_before_page_setup();
230
-        $this->_page_setup();
231
-        // die();
232
-    }
233
-
234
-
235
-    /**
236
-     * _init_page_props
237
-     * Child classes use to set at least the following properties:
238
-     * $page_slug.
239
-     * $page_label.
240
-     *
241
-     * @abstract
242
-     * @return void
243
-     */
244
-    abstract protected function _init_page_props();
245
-
246
-
247
-    /**
248
-     * _ajax_hooks
249
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
250
-     * Note: within the ajax callback methods.
251
-     *
252
-     * @abstract
253
-     * @return void
254
-     */
255
-    abstract protected function _ajax_hooks();
256
-
257
-
258
-    /**
259
-     * _define_page_props
260
-     * child classes define page properties in here.  Must include at least:
261
-     * $_admin_base_url = base_url for all admin pages
262
-     * $_admin_page_title = default admin_page_title for admin pages
263
-     * $_labels = array of default labels for various automatically generated elements:
264
-     *    array(
265
-     *        'buttons' => array(
266
-     *            'add' => esc_html__('label for add new button'),
267
-     *            'edit' => esc_html__('label for edit button'),
268
-     *            'delete' => esc_html__('label for delete button')
269
-     *            )
270
-     *        )
271
-     *
272
-     * @abstract
273
-     * @return void
274
-     */
275
-    abstract protected function _define_page_props();
276
-
277
-
278
-    /**
279
-     * _set_page_routes
280
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
281
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
282
-     * have a 'default' route. Here's the format
283
-     * $this->_page_routes = array(
284
-     *        'default' => array(
285
-     *            'func' => '_default_method_handling_route',
286
-     *            'args' => array('array','of','args'),
287
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
288
-     *            ajax request, backend processing)
289
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
290
-     *            headers route after.  The string you enter here should match the defined route reference for a
291
-     *            headers sent route.
292
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
293
-     *            this route.
294
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
295
-     *            checks).
296
-     *        ),
297
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
298
-     *        handling method.
299
-     *        )
300
-     * )
301
-     *
302
-     * @abstract
303
-     * @return void
304
-     */
305
-    abstract protected function _set_page_routes();
306
-
307
-
308
-    /**
309
-     * _set_page_config
310
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
311
-     * array corresponds to the page_route for the loaded page. Format:
312
-     * $this->_page_config = array(
313
-     *        'default' => array(
314
-     *            'labels' => array(
315
-     *                'buttons' => array(
316
-     *                    'add' => esc_html__('label for adding item'),
317
-     *                    'edit' => esc_html__('label for editing item'),
318
-     *                    'delete' => esc_html__('label for deleting item')
319
-     *                ),
320
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
321
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
322
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
323
-     *            _define_page_props() method
324
-     *            'nav' => array(
325
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
326
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
327
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
328
-     *                'order' => 10, //required to indicate tab position.
329
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
330
-     *                displayed then add this parameter.
331
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
332
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
333
-     *            metaboxes set for eventespresso admin pages.
334
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
335
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
336
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
337
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
338
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
339
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
340
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
341
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
342
-     *            want to display.
343
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
344
-     *                'tab_id' => array(
345
-     *                    'title' => 'tab_title',
346
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
347
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
348
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
349
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
350
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
351
-     *                    attempt to use the callback which should match the name of a method in the class
352
-     *                    ),
353
-     *                'tab2_id' => array(
354
-     *                    'title' => 'tab2 title',
355
-     *                    'filename' => 'file_name_2'
356
-     *                    'callback' => 'callback_method_for_content',
357
-     *                 ),
358
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
359
-     *            help tab area on an admin page. @return void
360
-     *
361
-     * @abstract
362
-     */
363
-    abstract protected function _set_page_config();
364
-
365
-
366
-    /**
367
-     * _add_screen_options
368
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
369
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
370
-     * to a particular view.
371
-     *
372
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
373
-     *         see also WP_Screen object documents...
374
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
375
-     * @abstract
376
-     * @return void
377
-     */
378
-    abstract protected function _add_screen_options();
379
-
380
-
381
-    /**
382
-     * _add_feature_pointers
383
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
384
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
385
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
386
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
387
-     * extended) also see:
388
-     *
389
-     * @link   http://eamann.com/tech/wordpress-portland/
390
-     * @abstract
391
-     * @return void
392
-     */
393
-    abstract protected function _add_feature_pointers();
394
-
395
-
396
-    /**
397
-     * load_scripts_styles
398
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
399
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
400
-     * scripts/styles per view by putting them in a dynamic function in this format
401
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
402
-     *
403
-     * @abstract
404
-     * @return void
405
-     */
406
-    abstract public function load_scripts_styles();
407
-
408
-
409
-    /**
410
-     * admin_init
411
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
412
-     * all pages/views loaded by child class.
413
-     *
414
-     * @abstract
415
-     * @return void
416
-     */
417
-    abstract public function admin_init();
418
-
419
-
420
-    /**
421
-     * admin_notices
422
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
423
-     * all pages/views loaded by child class.
424
-     *
425
-     * @abstract
426
-     * @return void
427
-     */
428
-    abstract public function admin_notices();
429
-
430
-
431
-    /**
432
-     * admin_footer_scripts
433
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
434
-     * will apply to all pages/views loaded by child class.
435
-     *
436
-     * @return void
437
-     */
438
-    abstract public function admin_footer_scripts();
439
-
440
-
441
-    /**
442
-     * admin_footer
443
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
444
-     * apply to all pages/views loaded by child class.
445
-     *
446
-     * @return void
447
-     */
448
-    public function admin_footer()
449
-    {
450
-    }
451
-
452
-
453
-    /**
454
-     * _global_ajax_hooks
455
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
456
-     * Note: within the ajax callback methods.
457
-     *
458
-     * @abstract
459
-     * @return void
460
-     */
461
-    protected function _global_ajax_hooks()
462
-    {
463
-        // for lazy loading of metabox content
464
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
465
-    }
466
-
467
-
468
-    public function ajax_metabox_content()
469
-    {
470
-        $content_id  = $this->request->getRequestParam('contentid', '');
471
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
472
-        self::cached_rss_display($content_id, $content_url);
473
-        wp_die();
474
-    }
475
-
476
-
477
-    /**
478
-     * allows extending classes do something specific before the parent constructor runs _page_setup().
479
-     *
480
-     * @return void
481
-     */
482
-    protected function _before_page_setup()
483
-    {
484
-        // default is to do nothing
485
-    }
486
-
487
-
488
-    /**
489
-     * Makes sure any things that need to be loaded early get handled.
490
-     * We also escape early here if the page requested doesn't match the object.
491
-     *
492
-     * @final
493
-     * @return void
494
-     * @throws EE_Error
495
-     * @throws InvalidArgumentException
496
-     * @throws ReflectionException
497
-     * @throws InvalidDataTypeException
498
-     * @throws InvalidInterfaceException
499
-     */
500
-    final protected function _page_setup()
501
-    {
502
-        // requires?
503
-        // admin_init stuff - global - we're setting this REALLY early
504
-        // so if EE_Admin pages have to hook into other WP pages they can.
505
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
506
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
507
-        // next verify if we need to load anything...
508
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
509
-        $this->page_folder   = strtolower(
510
-            str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
511
-        );
512
-        global $ee_menu_slugs;
513
-        $ee_menu_slugs = (array) $ee_menu_slugs;
514
-        if (
515
-            ! $this->request->isAjax()
516
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
517
-        ) {
518
-            return;
519
-        }
520
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
521
-        // we need to copy the action from the second to the first
522
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
523
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
524
-        $action     = $action !== '-1' ? $action : $action2;
525
-        $req_action = $action !== '-1' ? $action : 'default';
526
-
527
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
528
-        // then let's use the route as the action.
529
-        // This covers cases where we're coming in from a list table that isn't on the default route.
530
-        $route = $this->request->getRequestParam('route');
531
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
532
-            ? $route
533
-            : $req_action;
534
-
535
-        $this->_current_view = $this->_req_action;
536
-        $this->_req_nonce    = $this->_req_action . '_nonce';
537
-        $this->_define_page_props();
538
-        $this->_current_page_view_url = add_query_arg(
539
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
540
-            $this->_admin_base_url
541
-        );
542
-        // default things
543
-        $this->_default_espresso_metaboxes = [
544
-            '_espresso_news_post_box',
545
-            '_espresso_links_post_box',
546
-            '_espresso_ratings_request',
547
-            '_espresso_sponsors_post_box',
548
-        ];
549
-        // set page configs
550
-        $this->_set_page_routes();
551
-        $this->_set_page_config();
552
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
553
-        if ($this->request->requestParamIsSet('wp_referer')) {
554
-            $wp_referer = $this->request->getRequestParam('wp_referer');
555
-            if ($wp_referer) {
556
-                $this->_default_route_query_args['wp_referer'] = $wp_referer;
557
-            }
558
-        }
559
-        // for caffeinated and other extended functionality.
560
-        //  If there is a _extend_page_config method
561
-        // then let's run that to modify the all the various page configuration arrays
562
-        if (method_exists($this, '_extend_page_config')) {
563
-            $this->_extend_page_config();
564
-        }
565
-        // for CPT and other extended functionality.
566
-        // If there is an _extend_page_config_for_cpt
567
-        // then let's run that to modify all the various page configuration arrays.
568
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
569
-            $this->_extend_page_config_for_cpt();
570
-        }
571
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
572
-        $this->_page_routes = apply_filters(
573
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
574
-            $this->_page_routes,
575
-            $this
576
-        );
577
-        $this->_page_config = apply_filters(
578
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
579
-            $this->_page_config,
580
-            $this
581
-        );
582
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
583
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
584
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
585
-            add_action(
586
-                'AHEE__EE_Admin_Page__route_admin_request',
587
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
588
-                10,
589
-                2
590
-            );
591
-        }
592
-        // next route only if routing enabled
593
-        if ($this->_routing && ! $this->request->isAjax()) {
594
-            $this->_verify_routes();
595
-            // next let's just check user_access and kill if no access
596
-            $this->check_user_access();
597
-            if ($this->_is_UI_request) {
598
-                // admin_init stuff - global, all views for this page class, specific view
599
-                add_action('admin_init', [$this, 'admin_init'], 10);
600
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
601
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
602
-                }
603
-            } else {
604
-                // hijack regular WP loading and route admin request immediately
605
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
606
-                $this->route_admin_request();
607
-            }
608
-        }
609
-    }
610
-
611
-
612
-    /**
613
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
614
-     *
615
-     * @return void
616
-     * @throws EE_Error
617
-     */
618
-    private function _do_other_page_hooks()
619
-    {
620
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
621
-        foreach ($registered_pages as $page) {
622
-            // now let's setup the file name and class that should be present
623
-            $classname = str_replace('.class.php', '', $page);
624
-            // autoloaders should take care of loading file
625
-            if (! class_exists($classname)) {
626
-                $error_msg[] = sprintf(
627
-                    esc_html__(
628
-                        'Something went wrong with loading the %s admin hooks page.',
629
-                        'event_espresso'
630
-                    ),
631
-                    $page
632
-                );
633
-                $error_msg[] = $error_msg[0]
634
-                               . "\r\n"
635
-                               . sprintf(
636
-                                   esc_html__(
637
-                                       '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',
638
-                                       'event_espresso'
639
-                                   ),
640
-                                   $page,
641
-                                   '<br />',
642
-                                   '<strong>' . $classname . '</strong>'
643
-                               );
644
-                throw new EE_Error(implode('||', $error_msg));
645
-            }
646
-            // notice we are passing the instance of this class to the hook object.
647
-            $this->loader->getShared($classname, [$this]);
648
-        }
649
-    }
650
-
651
-
652
-    /**
653
-     * @throws ReflectionException
654
-     * @throws EE_Error
655
-     */
656
-    public function load_page_dependencies()
657
-    {
658
-        try {
659
-            $this->_load_page_dependencies();
660
-        } catch (EE_Error $e) {
661
-            $e->get_error();
662
-        }
663
-    }
664
-
665
-
666
-    /**
667
-     * load_page_dependencies
668
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
669
-     *
670
-     * @return void
671
-     * @throws DomainException
672
-     * @throws EE_Error
673
-     * @throws InvalidArgumentException
674
-     * @throws InvalidDataTypeException
675
-     * @throws InvalidInterfaceException
676
-     */
677
-    protected function _load_page_dependencies()
678
-    {
679
-        // let's set the current_screen and screen options to override what WP set
680
-        $this->_current_screen = get_current_screen();
681
-        // load admin_notices - global, page class, and view specific
682
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
683
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
684
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
685
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
686
-        }
687
-        // load network admin_notices - global, page class, and view specific
688
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
689
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
690
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
691
-        }
692
-        // this will save any per_page screen options if they are present
693
-        $this->_set_per_page_screen_options();
694
-        // setup list table properties
695
-        $this->_set_list_table();
696
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
697
-        // However in some cases the metaboxes will need to be added within a route handling callback.
698
-        $this->_add_registered_meta_boxes();
699
-        $this->_add_screen_columns();
700
-        // add screen options - global, page child class, and view specific
701
-        $this->_add_global_screen_options();
702
-        $this->_add_screen_options();
703
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
704
-        if (method_exists($this, $add_screen_options)) {
705
-            $this->{$add_screen_options}();
706
-        }
707
-        // add help tab(s) - set via page_config and qtips.
708
-        $this->_add_help_tabs();
709
-        $this->_add_qtips();
710
-        // add feature_pointers - global, page child class, and view specific
711
-        $this->_add_feature_pointers();
712
-        $this->_add_global_feature_pointers();
713
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
714
-        if (method_exists($this, $add_feature_pointer)) {
715
-            $this->{$add_feature_pointer}();
716
-        }
717
-        // enqueue scripts/styles - global, page class, and view specific
718
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
719
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
720
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
721
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
722
-        }
723
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
724
-        // admin_print_footer_scripts - global, page child class, and view specific.
725
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
726
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
727
-        // is a good use case. Notice the late priority we're giving these
728
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
729
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
730
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
731
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
732
-        }
733
-        // admin footer scripts
734
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
735
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
736
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
737
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
738
-        }
739
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
740
-        // targeted hook
741
-        do_action(
742
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
743
-        );
744
-    }
745
-
746
-
747
-    /**
748
-     * _set_defaults
749
-     * This sets some global defaults for class properties.
750
-     */
751
-    private function _set_defaults()
752
-    {
753
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
754
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
755
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
756
-        $this->_page_config          = $this->_default_route_query_args = [];
757
-        $this->_default_nav_tab_name = 'overview';
758
-        // init template args
759
-        $this->_template_args = [
760
-            'admin_page_header'  => '',
761
-            'admin_page_content' => '',
762
-            'post_body_content'  => '',
763
-            'before_list_table'  => '',
764
-            'after_list_table'   => '',
765
-        ];
766
-    }
767
-
768
-
769
-    /**
770
-     * route_admin_request
771
-     *
772
-     * @return void
773
-     * @throws InvalidArgumentException
774
-     * @throws InvalidInterfaceException
775
-     * @throws InvalidDataTypeException
776
-     * @throws EE_Error
777
-     * @throws ReflectionException
778
-     * @see    _route_admin_request()
779
-     */
780
-    public function route_admin_request()
781
-    {
782
-        try {
783
-            $this->_route_admin_request();
784
-        } catch (EE_Error $e) {
785
-            $e->get_error();
786
-        }
787
-    }
788
-
789
-
790
-    public function set_wp_page_slug($wp_page_slug)
791
-    {
792
-        $this->_wp_page_slug = $wp_page_slug;
793
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
794
-        if (is_network_admin()) {
795
-            $this->_wp_page_slug .= '-network';
796
-        }
797
-    }
798
-
799
-
800
-    /**
801
-     * _verify_routes
802
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
803
-     * we know if we need to drop out.
804
-     *
805
-     * @return bool
806
-     * @throws EE_Error
807
-     */
808
-    protected function _verify_routes()
809
-    {
810
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
811
-        if (! $this->_current_page && ! $this->request->isAjax()) {
812
-            return false;
813
-        }
814
-        $this->_route = false;
815
-        // check that the page_routes array is not empty
816
-        if (empty($this->_page_routes)) {
817
-            // user error msg
818
-            $error_msg = sprintf(
819
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
820
-                $this->_admin_page_title
821
-            );
822
-            // developer error msg
823
-            $error_msg .= '||' . $error_msg
824
-                          . esc_html__(
825
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
826
-                              'event_espresso'
827
-                          );
828
-            throw new EE_Error($error_msg);
829
-        }
830
-        // and that the requested page route exists
831
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
832
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
833
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
834
-                ? $this->_page_config[ $this->_req_action ]
835
-                : [];
836
-        } else {
837
-            // user error msg
838
-            $error_msg = sprintf(
839
-                esc_html__(
840
-                    'The requested page route does not exist for the %s admin page.',
841
-                    'event_espresso'
842
-                ),
843
-                $this->_admin_page_title
844
-            );
845
-            // developer error msg
846
-            $error_msg .= '||' . $error_msg
847
-                          . sprintf(
848
-                              esc_html__(
849
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
850
-                                  'event_espresso'
851
-                              ),
852
-                              $this->_req_action
853
-                          );
854
-            throw new EE_Error($error_msg);
855
-        }
856
-        // and that a default route exists
857
-        if (! array_key_exists('default', $this->_page_routes)) {
858
-            // user error msg
859
-            $error_msg = sprintf(
860
-                esc_html__(
861
-                    'A default page route has not been set for the % admin page.',
862
-                    'event_espresso'
863
-                ),
864
-                $this->_admin_page_title
865
-            );
866
-            // developer error msg
867
-            $error_msg .= '||' . $error_msg
868
-                          . esc_html__(
869
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
870
-                              'event_espresso'
871
-                          );
872
-            throw new EE_Error($error_msg);
873
-        }
874
-        // first lets' catch if the UI request has EVER been set.
875
-        if ($this->_is_UI_request === null) {
876
-            // lets set if this is a UI request or not.
877
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
878
-            // wait a minute... we might have a noheader in the route array
879
-            $this->_is_UI_request = ! (
880
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
881
-            )
882
-                ? $this->_is_UI_request
883
-                : false;
884
-        }
885
-        $this->_set_current_labels();
886
-        return true;
887
-    }
888
-
889
-
890
-    /**
891
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
892
-     *
893
-     * @param string $route the route name we're verifying
894
-     * @return bool we'll throw an exception if this isn't a valid route.
895
-     * @throws EE_Error
896
-     */
897
-    protected function _verify_route($route)
898
-    {
899
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
900
-            return true;
901
-        }
902
-        // user error msg
903
-        $error_msg = sprintf(
904
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
905
-            $this->_admin_page_title
906
-        );
907
-        // developer error msg
908
-        $error_msg .= '||' . $error_msg
909
-                      . sprintf(
910
-                          esc_html__(
911
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
912
-                              'event_espresso'
913
-                          ),
914
-                          $route
915
-                      );
916
-        throw new EE_Error($error_msg);
917
-    }
918
-
919
-
920
-    /**
921
-     * perform nonce verification
922
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
923
-     * using this method (and save retyping!)
924
-     *
925
-     * @param string $nonce     The nonce sent
926
-     * @param string $nonce_ref The nonce reference string (name0)
927
-     * @return void
928
-     * @throws EE_Error
929
-     */
930
-    protected function _verify_nonce($nonce, $nonce_ref)
931
-    {
932
-        // verify nonce against expected value
933
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
934
-            // these are not the droids you are looking for !!!
935
-            $msg = sprintf(
936
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
937
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
938
-                '</a>'
939
-            );
940
-            if (WP_DEBUG) {
941
-                $msg .= "\n  ";
942
-                $msg .= sprintf(
943
-                    esc_html__(
944
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
945
-                        'event_espresso'
946
-                    ),
947
-                    __CLASS__
948
-                );
949
-            }
950
-            if (! $this->request->isAjax()) {
951
-                wp_die($msg);
952
-            }
953
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
954
-            $this->_return_json();
955
-        }
956
-    }
957
-
958
-
959
-    /**
960
-     * _route_admin_request()
961
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
962
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
963
-     * in the page routes and then will try to load the corresponding method.
964
-     *
965
-     * @return void
966
-     * @throws EE_Error
967
-     * @throws InvalidArgumentException
968
-     * @throws InvalidDataTypeException
969
-     * @throws InvalidInterfaceException
970
-     * @throws ReflectionException
971
-     */
972
-    protected function _route_admin_request()
973
-    {
974
-        if (! $this->_is_UI_request) {
975
-            $this->_verify_routes();
976
-        }
977
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
978
-        if ($this->_req_action !== 'default' && $nonce_check) {
979
-            // set nonce from post data
980
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
981
-            $this->_verify_nonce($nonce, $this->_req_nonce);
982
-        }
983
-        // set the nav_tabs array but ONLY if this is  UI_request
984
-        if ($this->_is_UI_request) {
985
-            $this->_set_nav_tabs();
986
-        }
987
-        // grab callback function
988
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
989
-        // check if callback has args
990
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
991
-        $error_msg = '';
992
-        // action right before calling route
993
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
994
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
995
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
996
-        }
997
-        // right before calling the route, let's clean the _wp_http_referer
998
-        $this->request->setServerParam(
999
-            'REQUEST_URI',
1000
-            remove_query_arg(
1001
-                '_wp_http_referer',
1002
-                wp_unslash($this->request->getServerParam('REQUEST_URI'))
1003
-            )
1004
-        );
1005
-        if (! empty($func)) {
1006
-            if (is_array($func)) {
1007
-                list($class, $method) = $func;
1008
-            } elseif (strpos($func, '::') !== false) {
1009
-                list($class, $method) = explode('::', $func);
1010
-            } else {
1011
-                $class  = $this;
1012
-                $method = $func;
1013
-            }
1014
-            if (! (is_object($class) && $class === $this)) {
1015
-                // send along this admin page object for access by addons.
1016
-                $args['admin_page_object'] = $this;
1017
-            }
1018
-            if (
1019
-                // is it a method on a class that doesn't work?
1020
-                (
1021
-                    (
1022
-                        method_exists($class, $method)
1023
-                        && call_user_func_array([$class, $method], $args) === false
1024
-                    )
1025
-                    && (
1026
-                        // is it a standalone function that doesn't work?
1027
-                        function_exists($method)
1028
-                        && call_user_func_array(
1029
-                            $func,
1030
-                            array_merge(['admin_page_object' => $this], $args)
1031
-                        ) === false
1032
-                    )
1033
-                )
1034
-                || (
1035
-                    // is it neither a class method NOR a standalone function?
1036
-                    ! method_exists($class, $method)
1037
-                    && ! function_exists($method)
1038
-                )
1039
-            ) {
1040
-                // user error msg
1041
-                $error_msg = esc_html__(
1042
-                    'An error occurred. The  requested page route could not be found.',
1043
-                    'event_espresso'
1044
-                );
1045
-                // developer error msg
1046
-                $error_msg .= '||';
1047
-                $error_msg .= sprintf(
1048
-                    esc_html__(
1049
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1050
-                        'event_espresso'
1051
-                    ),
1052
-                    $method
1053
-                );
1054
-            }
1055
-            if (! empty($error_msg)) {
1056
-                throw new EE_Error($error_msg);
1057
-            }
1058
-        }
1059
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1060
-        // then we need to reset the routing properties to the new route.
1061
-        // 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.
1062
-        if (
1063
-            $this->_is_UI_request === false
1064
-            && is_array($this->_route)
1065
-            && ! empty($this->_route['headers_sent_route'])
1066
-        ) {
1067
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1068
-        }
1069
-    }
1070
-
1071
-
1072
-    /**
1073
-     * This method just allows the resetting of page properties in the case where a no headers
1074
-     * route redirects to a headers route in its route config.
1075
-     *
1076
-     * @param string $new_route New (non header) route to redirect to.
1077
-     * @return   void
1078
-     * @throws ReflectionException
1079
-     * @throws InvalidArgumentException
1080
-     * @throws InvalidInterfaceException
1081
-     * @throws InvalidDataTypeException
1082
-     * @throws EE_Error
1083
-     * @since   4.3.0
1084
-     */
1085
-    protected function _reset_routing_properties($new_route)
1086
-    {
1087
-        $this->_is_UI_request = true;
1088
-        // now we set the current route to whatever the headers_sent_route is set at
1089
-        $this->request->setRequestParam('action', $new_route);
1090
-        // rerun page setup
1091
-        $this->_page_setup();
1092
-    }
1093
-
1094
-
1095
-    /**
1096
-     * _add_query_arg
1097
-     * adds nonce to array of arguments then calls WP add_query_arg function
1098
-     *(internally just uses EEH_URL's function with the same name)
1099
-     *
1100
-     * @param array  $args
1101
-     * @param string $url
1102
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1103
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1104
-     *                                        Example usage: If the current page is:
1105
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1106
-     *                                        &action=default&event_id=20&month_range=March%202015
1107
-     *                                        &_wpnonce=5467821
1108
-     *                                        and you call:
1109
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1110
-     *                                        array(
1111
-     *                                        'action' => 'resend_something',
1112
-     *                                        'page=>espresso_registrations'
1113
-     *                                        ),
1114
-     *                                        $some_url,
1115
-     *                                        true
1116
-     *                                        );
1117
-     *                                        It will produce a url in this structure:
1118
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1119
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1120
-     *                                        month_range]=March%202015
1121
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1122
-     * @return string
1123
-     */
1124
-    public static function add_query_args_and_nonce(
1125
-        $args = [],
1126
-        $url = false,
1127
-        $sticky = false,
1128
-        $exclude_nonce = false
1129
-    ) {
1130
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1131
-        if ($sticky) {
1132
-            /** @var RequestInterface $request */
1133
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1134
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1135
-            foreach ($request->requestParams() as $key => $value) {
1136
-                // do not add nonces
1137
-                if (strpos($key, 'nonce') !== false) {
1138
-                    continue;
1139
-                }
1140
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1141
-            }
1142
-        }
1143
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1144
-    }
1145
-
1146
-
1147
-    /**
1148
-     * This returns a generated link that will load the related help tab.
1149
-     *
1150
-     * @param string $help_tab_id the id for the connected help tab
1151
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1152
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1153
-     * @return string              generated link
1154
-     * @uses EEH_Template::get_help_tab_link()
1155
-     */
1156
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1157
-    {
1158
-        return EEH_Template::get_help_tab_link(
1159
-            $help_tab_id,
1160
-            $this->page_slug,
1161
-            $this->_req_action,
1162
-            $icon_style,
1163
-            $help_text
1164
-        );
1165
-    }
1166
-
1167
-
1168
-    /**
1169
-     * _add_help_tabs
1170
-     * Note child classes define their help tabs within the page_config array.
1171
-     *
1172
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1173
-     * @return void
1174
-     * @throws DomainException
1175
-     * @throws EE_Error
1176
-     */
1177
-    protected function _add_help_tabs()
1178
-    {
1179
-        if (isset($this->_page_config[ $this->_req_action ])) {
1180
-            $config = $this->_page_config[ $this->_req_action ];
1181
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1182
-            if (is_array($config) && isset($config['help_sidebar'])) {
1183
-                // check that the callback given is valid
1184
-                if (! method_exists($this, $config['help_sidebar'])) {
1185
-                    throw new EE_Error(
1186
-                        sprintf(
1187
-                            esc_html__(
1188
-                                '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',
1189
-                                'event_espresso'
1190
-                            ),
1191
-                            $config['help_sidebar'],
1192
-                            get_class($this)
1193
-                        )
1194
-                    );
1195
-                }
1196
-                $content = apply_filters(
1197
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1198
-                    $this->{$config['help_sidebar']}()
1199
-                );
1200
-                $this->_current_screen->set_help_sidebar($content);
1201
-            }
1202
-            if (! isset($config['help_tabs'])) {
1203
-                return;
1204
-            } //no help tabs for this route
1205
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1206
-                // we're here so there ARE help tabs!
1207
-                // make sure we've got what we need
1208
-                if (! isset($cfg['title'])) {
1209
-                    throw new EE_Error(
1210
-                        esc_html__(
1211
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1212
-                            'event_espresso'
1213
-                        )
1214
-                    );
1215
-                }
1216
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1217
-                    throw new EE_Error(
1218
-                        esc_html__(
1219
-                            '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',
1220
-                            'event_espresso'
1221
-                        )
1222
-                    );
1223
-                }
1224
-                // first priority goes to content.
1225
-                if (! empty($cfg['content'])) {
1226
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1227
-                    // second priority goes to filename
1228
-                } elseif (! empty($cfg['filename'])) {
1229
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1230
-                    // 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)
1231
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1232
-                                                             . basename($this->_get_dir())
1233
-                                                             . '/help_tabs/'
1234
-                                                             . $cfg['filename']
1235
-                                                             . '.help_tab.php' : $file_path;
1236
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1237
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1238
-                        EE_Error::add_error(
1239
-                            sprintf(
1240
-                                esc_html__(
1241
-                                    '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',
1242
-                                    'event_espresso'
1243
-                                ),
1244
-                                $tab_id,
1245
-                                key($config),
1246
-                                $file_path
1247
-                            ),
1248
-                            __FILE__,
1249
-                            __FUNCTION__,
1250
-                            __LINE__
1251
-                        );
1252
-                        return;
1253
-                    }
1254
-                    $template_args['admin_page_obj'] = $this;
1255
-                    $content                         = EEH_Template::display_template(
1256
-                        $file_path,
1257
-                        $template_args,
1258
-                        true
1259
-                    );
1260
-                } else {
1261
-                    $content = '';
1262
-                }
1263
-                // check if callback is valid
1264
-                if (
1265
-                    empty($content)
1266
-                    && (
1267
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1268
-                    )
1269
-                ) {
1270
-                    EE_Error::add_error(
1271
-                        sprintf(
1272
-                            esc_html__(
1273
-                                '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.',
1274
-                                'event_espresso'
1275
-                            ),
1276
-                            $cfg['title']
1277
-                        ),
1278
-                        __FILE__,
1279
-                        __FUNCTION__,
1280
-                        __LINE__
1281
-                    );
1282
-                    return;
1283
-                }
1284
-                // setup config array for help tab method
1285
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1286
-                $_ht = [
1287
-                    'id'       => $id,
1288
-                    'title'    => $cfg['title'],
1289
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1290
-                    'content'  => $content,
1291
-                ];
1292
-                $this->_current_screen->add_help_tab($_ht);
1293
-            }
1294
-        }
1295
-    }
1296
-
1297
-
1298
-    /**
1299
-     * This simply sets up any qtips that have been defined in the page config
1300
-     *
1301
-     * @return void
1302
-     */
1303
-    protected function _add_qtips()
1304
-    {
1305
-        if (isset($this->_route_config['qtips'])) {
1306
-            $qtips = (array) $this->_route_config['qtips'];
1307
-            // load qtip loader
1308
-            $path = [
1309
-                $this->_get_dir() . '/qtips/',
1310
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1311
-            ];
1312
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1313
-        }
1314
-    }
1315
-
1316
-
1317
-    /**
1318
-     * _set_nav_tabs
1319
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1320
-     * wish to add additional tabs or modify accordingly.
1321
-     *
1322
-     * @return void
1323
-     * @throws InvalidArgumentException
1324
-     * @throws InvalidInterfaceException
1325
-     * @throws InvalidDataTypeException
1326
-     */
1327
-    protected function _set_nav_tabs()
1328
-    {
1329
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1330
-        $i = 0;
1331
-        foreach ($this->_page_config as $slug => $config) {
1332
-            if (! is_array($config) || empty($config['nav'])) {
1333
-                continue;
1334
-            }
1335
-            // no nav tab for this config
1336
-            // check for persistent flag
1337
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1338
-                // nav tab is only to appear when route requested.
1339
-                continue;
1340
-            }
1341
-            if (! $this->check_user_access($slug, true)) {
1342
-                // no nav tab because current user does not have access.
1343
-                continue;
1344
-            }
1345
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1346
-            $this->_nav_tabs[ $slug ] = [
1347
-                'url'       => isset($config['nav']['url'])
1348
-                    ? $config['nav']['url']
1349
-                    : self::add_query_args_and_nonce(
1350
-                        ['action' => $slug],
1351
-                        $this->_admin_base_url
1352
-                    ),
1353
-                'link_text' => isset($config['nav']['label'])
1354
-                    ? $config['nav']['label']
1355
-                    : ucwords(
1356
-                        str_replace('_', ' ', $slug)
1357
-                    ),
1358
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1359
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1360
-            ];
1361
-            $i++;
1362
-        }
1363
-        // if $this->_nav_tabs is empty then lets set the default
1364
-        if (empty($this->_nav_tabs)) {
1365
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1366
-                'url'       => $this->_admin_base_url,
1367
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1368
-                'css_class' => 'nav-tab-active',
1369
-                'order'     => 10,
1370
-            ];
1371
-        }
1372
-        // now let's sort the tabs according to order
1373
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1374
-    }
1375
-
1376
-
1377
-    /**
1378
-     * _set_current_labels
1379
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1380
-     * property array
1381
-     *
1382
-     * @return void
1383
-     */
1384
-    private function _set_current_labels()
1385
-    {
1386
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1387
-            foreach ($this->_route_config['labels'] as $label => $text) {
1388
-                if (is_array($text)) {
1389
-                    foreach ($text as $sublabel => $subtext) {
1390
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1391
-                    }
1392
-                } else {
1393
-                    $this->_labels[ $label ] = $text;
1394
-                }
1395
-            }
1396
-        }
1397
-    }
1398
-
1399
-
1400
-    /**
1401
-     *        verifies user access for this admin page
1402
-     *
1403
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1404
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1405
-     *                               return false if verify fail.
1406
-     * @return bool
1407
-     * @throws InvalidArgumentException
1408
-     * @throws InvalidDataTypeException
1409
-     * @throws InvalidInterfaceException
1410
-     */
1411
-    public function check_user_access($route_to_check = '', $verify_only = false)
1412
-    {
1413
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1414
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1415
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1416
-                          && is_array(
1417
-                              $this->_page_routes[ $route_to_check ]
1418
-                          )
1419
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1420
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1421
-        if (empty($capability) && empty($route_to_check)) {
1422
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1423
-                : $this->_route['capability'];
1424
-        } else {
1425
-            $capability = empty($capability) ? 'manage_options' : $capability;
1426
-        }
1427
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1428
-        if (
1429
-            ! $this->request->isAjax()
1430
-            && (
1431
-                ! function_exists('is_admin')
1432
-                || ! EE_Registry::instance()->CAP->current_user_can(
1433
-                    $capability,
1434
-                    $this->page_slug
1435
-                    . '_'
1436
-                    . $route_to_check,
1437
-                    $id
1438
-                )
1439
-            )
1440
-        ) {
1441
-            if ($verify_only) {
1442
-                return false;
1443
-            }
1444
-            if (is_user_logged_in()) {
1445
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1446
-            } else {
1447
-                return false;
1448
-            }
1449
-        }
1450
-        return true;
1451
-    }
1452
-
1453
-
1454
-    /**
1455
-     * admin_init_global
1456
-     * This runs all the code that we want executed within the WP admin_init hook.
1457
-     * This method executes for ALL EE Admin pages.
1458
-     *
1459
-     * @return void
1460
-     */
1461
-    public function admin_init_global()
1462
-    {
1463
-    }
1464
-
1465
-
1466
-    /**
1467
-     * wp_loaded_global
1468
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1469
-     * EE_Admin page and will execute on every EE Admin Page load
1470
-     *
1471
-     * @return void
1472
-     */
1473
-    public function wp_loaded()
1474
-    {
1475
-    }
1476
-
1477
-
1478
-    /**
1479
-     * admin_notices
1480
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1481
-     * ALL EE_Admin pages.
1482
-     *
1483
-     * @return void
1484
-     */
1485
-    public function admin_notices_global()
1486
-    {
1487
-        $this->_display_no_javascript_warning();
1488
-        $this->_display_espresso_notices();
1489
-    }
1490
-
1491
-
1492
-    public function network_admin_notices_global()
1493
-    {
1494
-        $this->_display_no_javascript_warning();
1495
-        $this->_display_espresso_notices();
1496
-    }
1497
-
1498
-
1499
-    /**
1500
-     * admin_footer_scripts_global
1501
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1502
-     * will apply on ALL EE_Admin pages.
1503
-     *
1504
-     * @return void
1505
-     */
1506
-    public function admin_footer_scripts_global()
1507
-    {
1508
-        $this->_add_admin_page_ajax_loading_img();
1509
-        $this->_add_admin_page_overlay();
1510
-        // if metaboxes are present we need to add the nonce field
1511
-        if (
1512
-            isset($this->_route_config['metaboxes'])
1513
-            || isset($this->_route_config['list_table'])
1514
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1515
-        ) {
1516
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1517
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1518
-        }
1519
-    }
1520
-
1521
-
1522
-    /**
1523
-     * admin_footer_global
1524
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1525
-     * ALL EE_Admin Pages.
1526
-     *
1527
-     * @return void
1528
-     */
1529
-    public function admin_footer_global()
1530
-    {
1531
-        // dialog container for dialog helper
1532
-        echo '
110
+	/**
111
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
112
+	 * actions.
113
+	 *
114
+	 * @since 4.6.x
115
+	 * @var array.
116
+	 */
117
+	protected $_default_route_query_args;
118
+
119
+	// set via request page and action args.
120
+	protected $_current_page;
121
+
122
+	protected $_current_view;
123
+
124
+	protected $_current_page_view_url;
125
+
126
+	/**
127
+	 * unprocessed value for the 'action' request param (default '')
128
+	 *
129
+	 * @var string
130
+	 */
131
+	protected $raw_req_action = '';
132
+
133
+	/**
134
+	 * unprocessed value for the 'page' request param (default '')
135
+	 *
136
+	 * @var string
137
+	 */
138
+	protected $raw_req_page = '';
139
+
140
+	/**
141
+	 * sanitized request action (and nonce)
142
+	 *
143
+	 * @var string
144
+	 */
145
+	protected $_req_action = '';
146
+
147
+	/**
148
+	 * sanitized request action nonce
149
+	 *
150
+	 * @var string
151
+	 */
152
+	protected $_req_nonce = '';
153
+
154
+	/**
155
+	 * @var string
156
+	 */
157
+	protected $_search_btn_label = '';
158
+
159
+	/**
160
+	 * @var string
161
+	 */
162
+	protected $_search_box_callback = '';
163
+
164
+	/**
165
+	 * @var WP_Screen
166
+	 */
167
+	protected $_current_screen;
168
+
169
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
170
+	protected $_hook_obj;
171
+
172
+	// for holding incoming request data
173
+	protected $_req_data = [];
174
+
175
+	// yes / no array for admin form fields
176
+	protected $_yes_no_values = [];
177
+
178
+	// some default things shared by all child classes
179
+	protected $_default_espresso_metaboxes;
180
+
181
+	/**
182
+	 * @var EE_Registry
183
+	 */
184
+	protected $EE = null;
185
+
186
+
187
+	/**
188
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
189
+	 *
190
+	 * @var boolean
191
+	 */
192
+	protected $_is_caf = false;
193
+
194
+
195
+	/**
196
+	 * @Constructor
197
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
198
+	 * @throws EE_Error
199
+	 * @throws InvalidArgumentException
200
+	 * @throws ReflectionException
201
+	 * @throws InvalidDataTypeException
202
+	 * @throws InvalidInterfaceException
203
+	 */
204
+	public function __construct($routing = true)
205
+	{
206
+		$this->loader  = LoaderFactory::getLoader();
207
+		$this->request = $this->loader->getShared(RequestInterface::class);
208
+		$this->_routing = $routing;
209
+
210
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
211
+			$this->_is_caf = true;
212
+		}
213
+		$this->_yes_no_values = [
214
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
215
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
216
+		];
217
+		// set the _req_data property.
218
+		$this->_req_data = $this->request->requestParams();
219
+		// set initial page props (child method)
220
+		$this->_init_page_props();
221
+		// set global defaults
222
+		$this->_set_defaults();
223
+		// set early because incoming requests could be ajax related and we need to register those hooks.
224
+		$this->_global_ajax_hooks();
225
+		$this->_ajax_hooks();
226
+		// other_page_hooks have to be early too.
227
+		$this->_do_other_page_hooks();
228
+		// set up page dependencies
229
+		$this->_before_page_setup();
230
+		$this->_page_setup();
231
+		// die();
232
+	}
233
+
234
+
235
+	/**
236
+	 * _init_page_props
237
+	 * Child classes use to set at least the following properties:
238
+	 * $page_slug.
239
+	 * $page_label.
240
+	 *
241
+	 * @abstract
242
+	 * @return void
243
+	 */
244
+	abstract protected function _init_page_props();
245
+
246
+
247
+	/**
248
+	 * _ajax_hooks
249
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
250
+	 * Note: within the ajax callback methods.
251
+	 *
252
+	 * @abstract
253
+	 * @return void
254
+	 */
255
+	abstract protected function _ajax_hooks();
256
+
257
+
258
+	/**
259
+	 * _define_page_props
260
+	 * child classes define page properties in here.  Must include at least:
261
+	 * $_admin_base_url = base_url for all admin pages
262
+	 * $_admin_page_title = default admin_page_title for admin pages
263
+	 * $_labels = array of default labels for various automatically generated elements:
264
+	 *    array(
265
+	 *        'buttons' => array(
266
+	 *            'add' => esc_html__('label for add new button'),
267
+	 *            'edit' => esc_html__('label for edit button'),
268
+	 *            'delete' => esc_html__('label for delete button')
269
+	 *            )
270
+	 *        )
271
+	 *
272
+	 * @abstract
273
+	 * @return void
274
+	 */
275
+	abstract protected function _define_page_props();
276
+
277
+
278
+	/**
279
+	 * _set_page_routes
280
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
281
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
282
+	 * have a 'default' route. Here's the format
283
+	 * $this->_page_routes = array(
284
+	 *        'default' => array(
285
+	 *            'func' => '_default_method_handling_route',
286
+	 *            'args' => array('array','of','args'),
287
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
288
+	 *            ajax request, backend processing)
289
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
290
+	 *            headers route after.  The string you enter here should match the defined route reference for a
291
+	 *            headers sent route.
292
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
293
+	 *            this route.
294
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
295
+	 *            checks).
296
+	 *        ),
297
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
298
+	 *        handling method.
299
+	 *        )
300
+	 * )
301
+	 *
302
+	 * @abstract
303
+	 * @return void
304
+	 */
305
+	abstract protected function _set_page_routes();
306
+
307
+
308
+	/**
309
+	 * _set_page_config
310
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
311
+	 * array corresponds to the page_route for the loaded page. Format:
312
+	 * $this->_page_config = array(
313
+	 *        'default' => array(
314
+	 *            'labels' => array(
315
+	 *                'buttons' => array(
316
+	 *                    'add' => esc_html__('label for adding item'),
317
+	 *                    'edit' => esc_html__('label for editing item'),
318
+	 *                    'delete' => esc_html__('label for deleting item')
319
+	 *                ),
320
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
321
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
322
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
323
+	 *            _define_page_props() method
324
+	 *            'nav' => array(
325
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
326
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
327
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
328
+	 *                'order' => 10, //required to indicate tab position.
329
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
330
+	 *                displayed then add this parameter.
331
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
332
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
333
+	 *            metaboxes set for eventespresso admin pages.
334
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
335
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
336
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
337
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
338
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
339
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
340
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
341
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
342
+	 *            want to display.
343
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
344
+	 *                'tab_id' => array(
345
+	 *                    'title' => 'tab_title',
346
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
347
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
348
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
349
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
350
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
351
+	 *                    attempt to use the callback which should match the name of a method in the class
352
+	 *                    ),
353
+	 *                'tab2_id' => array(
354
+	 *                    'title' => 'tab2 title',
355
+	 *                    'filename' => 'file_name_2'
356
+	 *                    'callback' => 'callback_method_for_content',
357
+	 *                 ),
358
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
359
+	 *            help tab area on an admin page. @return void
360
+	 *
361
+	 * @abstract
362
+	 */
363
+	abstract protected function _set_page_config();
364
+
365
+
366
+	/**
367
+	 * _add_screen_options
368
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
369
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
370
+	 * to a particular view.
371
+	 *
372
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
373
+	 *         see also WP_Screen object documents...
374
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
375
+	 * @abstract
376
+	 * @return void
377
+	 */
378
+	abstract protected function _add_screen_options();
379
+
380
+
381
+	/**
382
+	 * _add_feature_pointers
383
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
384
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
385
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
386
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
387
+	 * extended) also see:
388
+	 *
389
+	 * @link   http://eamann.com/tech/wordpress-portland/
390
+	 * @abstract
391
+	 * @return void
392
+	 */
393
+	abstract protected function _add_feature_pointers();
394
+
395
+
396
+	/**
397
+	 * load_scripts_styles
398
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
399
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
400
+	 * scripts/styles per view by putting them in a dynamic function in this format
401
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
402
+	 *
403
+	 * @abstract
404
+	 * @return void
405
+	 */
406
+	abstract public function load_scripts_styles();
407
+
408
+
409
+	/**
410
+	 * admin_init
411
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
412
+	 * all pages/views loaded by child class.
413
+	 *
414
+	 * @abstract
415
+	 * @return void
416
+	 */
417
+	abstract public function admin_init();
418
+
419
+
420
+	/**
421
+	 * admin_notices
422
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
423
+	 * all pages/views loaded by child class.
424
+	 *
425
+	 * @abstract
426
+	 * @return void
427
+	 */
428
+	abstract public function admin_notices();
429
+
430
+
431
+	/**
432
+	 * admin_footer_scripts
433
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
434
+	 * will apply to all pages/views loaded by child class.
435
+	 *
436
+	 * @return void
437
+	 */
438
+	abstract public function admin_footer_scripts();
439
+
440
+
441
+	/**
442
+	 * admin_footer
443
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
444
+	 * apply to all pages/views loaded by child class.
445
+	 *
446
+	 * @return void
447
+	 */
448
+	public function admin_footer()
449
+	{
450
+	}
451
+
452
+
453
+	/**
454
+	 * _global_ajax_hooks
455
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
456
+	 * Note: within the ajax callback methods.
457
+	 *
458
+	 * @abstract
459
+	 * @return void
460
+	 */
461
+	protected function _global_ajax_hooks()
462
+	{
463
+		// for lazy loading of metabox content
464
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
465
+	}
466
+
467
+
468
+	public function ajax_metabox_content()
469
+	{
470
+		$content_id  = $this->request->getRequestParam('contentid', '');
471
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
472
+		self::cached_rss_display($content_id, $content_url);
473
+		wp_die();
474
+	}
475
+
476
+
477
+	/**
478
+	 * allows extending classes do something specific before the parent constructor runs _page_setup().
479
+	 *
480
+	 * @return void
481
+	 */
482
+	protected function _before_page_setup()
483
+	{
484
+		// default is to do nothing
485
+	}
486
+
487
+
488
+	/**
489
+	 * Makes sure any things that need to be loaded early get handled.
490
+	 * We also escape early here if the page requested doesn't match the object.
491
+	 *
492
+	 * @final
493
+	 * @return void
494
+	 * @throws EE_Error
495
+	 * @throws InvalidArgumentException
496
+	 * @throws ReflectionException
497
+	 * @throws InvalidDataTypeException
498
+	 * @throws InvalidInterfaceException
499
+	 */
500
+	final protected function _page_setup()
501
+	{
502
+		// requires?
503
+		// admin_init stuff - global - we're setting this REALLY early
504
+		// so if EE_Admin pages have to hook into other WP pages they can.
505
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
506
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
507
+		// next verify if we need to load anything...
508
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
509
+		$this->page_folder   = strtolower(
510
+			str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
511
+		);
512
+		global $ee_menu_slugs;
513
+		$ee_menu_slugs = (array) $ee_menu_slugs;
514
+		if (
515
+			! $this->request->isAjax()
516
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
517
+		) {
518
+			return;
519
+		}
520
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
521
+		// we need to copy the action from the second to the first
522
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
523
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
524
+		$action     = $action !== '-1' ? $action : $action2;
525
+		$req_action = $action !== '-1' ? $action : 'default';
526
+
527
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
528
+		// then let's use the route as the action.
529
+		// This covers cases where we're coming in from a list table that isn't on the default route.
530
+		$route = $this->request->getRequestParam('route');
531
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
532
+			? $route
533
+			: $req_action;
534
+
535
+		$this->_current_view = $this->_req_action;
536
+		$this->_req_nonce    = $this->_req_action . '_nonce';
537
+		$this->_define_page_props();
538
+		$this->_current_page_view_url = add_query_arg(
539
+			['page' => $this->_current_page, 'action' => $this->_current_view],
540
+			$this->_admin_base_url
541
+		);
542
+		// default things
543
+		$this->_default_espresso_metaboxes = [
544
+			'_espresso_news_post_box',
545
+			'_espresso_links_post_box',
546
+			'_espresso_ratings_request',
547
+			'_espresso_sponsors_post_box',
548
+		];
549
+		// set page configs
550
+		$this->_set_page_routes();
551
+		$this->_set_page_config();
552
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
553
+		if ($this->request->requestParamIsSet('wp_referer')) {
554
+			$wp_referer = $this->request->getRequestParam('wp_referer');
555
+			if ($wp_referer) {
556
+				$this->_default_route_query_args['wp_referer'] = $wp_referer;
557
+			}
558
+		}
559
+		// for caffeinated and other extended functionality.
560
+		//  If there is a _extend_page_config method
561
+		// then let's run that to modify the all the various page configuration arrays
562
+		if (method_exists($this, '_extend_page_config')) {
563
+			$this->_extend_page_config();
564
+		}
565
+		// for CPT and other extended functionality.
566
+		// If there is an _extend_page_config_for_cpt
567
+		// then let's run that to modify all the various page configuration arrays.
568
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
569
+			$this->_extend_page_config_for_cpt();
570
+		}
571
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
572
+		$this->_page_routes = apply_filters(
573
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
574
+			$this->_page_routes,
575
+			$this
576
+		);
577
+		$this->_page_config = apply_filters(
578
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
579
+			$this->_page_config,
580
+			$this
581
+		);
582
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
583
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
584
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
585
+			add_action(
586
+				'AHEE__EE_Admin_Page__route_admin_request',
587
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
588
+				10,
589
+				2
590
+			);
591
+		}
592
+		// next route only if routing enabled
593
+		if ($this->_routing && ! $this->request->isAjax()) {
594
+			$this->_verify_routes();
595
+			// next let's just check user_access and kill if no access
596
+			$this->check_user_access();
597
+			if ($this->_is_UI_request) {
598
+				// admin_init stuff - global, all views for this page class, specific view
599
+				add_action('admin_init', [$this, 'admin_init'], 10);
600
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
601
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
602
+				}
603
+			} else {
604
+				// hijack regular WP loading and route admin request immediately
605
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
606
+				$this->route_admin_request();
607
+			}
608
+		}
609
+	}
610
+
611
+
612
+	/**
613
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
614
+	 *
615
+	 * @return void
616
+	 * @throws EE_Error
617
+	 */
618
+	private function _do_other_page_hooks()
619
+	{
620
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
621
+		foreach ($registered_pages as $page) {
622
+			// now let's setup the file name and class that should be present
623
+			$classname = str_replace('.class.php', '', $page);
624
+			// autoloaders should take care of loading file
625
+			if (! class_exists($classname)) {
626
+				$error_msg[] = sprintf(
627
+					esc_html__(
628
+						'Something went wrong with loading the %s admin hooks page.',
629
+						'event_espresso'
630
+					),
631
+					$page
632
+				);
633
+				$error_msg[] = $error_msg[0]
634
+							   . "\r\n"
635
+							   . sprintf(
636
+								   esc_html__(
637
+									   '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',
638
+									   'event_espresso'
639
+								   ),
640
+								   $page,
641
+								   '<br />',
642
+								   '<strong>' . $classname . '</strong>'
643
+							   );
644
+				throw new EE_Error(implode('||', $error_msg));
645
+			}
646
+			// notice we are passing the instance of this class to the hook object.
647
+			$this->loader->getShared($classname, [$this]);
648
+		}
649
+	}
650
+
651
+
652
+	/**
653
+	 * @throws ReflectionException
654
+	 * @throws EE_Error
655
+	 */
656
+	public function load_page_dependencies()
657
+	{
658
+		try {
659
+			$this->_load_page_dependencies();
660
+		} catch (EE_Error $e) {
661
+			$e->get_error();
662
+		}
663
+	}
664
+
665
+
666
+	/**
667
+	 * load_page_dependencies
668
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
669
+	 *
670
+	 * @return void
671
+	 * @throws DomainException
672
+	 * @throws EE_Error
673
+	 * @throws InvalidArgumentException
674
+	 * @throws InvalidDataTypeException
675
+	 * @throws InvalidInterfaceException
676
+	 */
677
+	protected function _load_page_dependencies()
678
+	{
679
+		// let's set the current_screen and screen options to override what WP set
680
+		$this->_current_screen = get_current_screen();
681
+		// load admin_notices - global, page class, and view specific
682
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
683
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
684
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
685
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
686
+		}
687
+		// load network admin_notices - global, page class, and view specific
688
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
689
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
690
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
691
+		}
692
+		// this will save any per_page screen options if they are present
693
+		$this->_set_per_page_screen_options();
694
+		// setup list table properties
695
+		$this->_set_list_table();
696
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
697
+		// However in some cases the metaboxes will need to be added within a route handling callback.
698
+		$this->_add_registered_meta_boxes();
699
+		$this->_add_screen_columns();
700
+		// add screen options - global, page child class, and view specific
701
+		$this->_add_global_screen_options();
702
+		$this->_add_screen_options();
703
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
704
+		if (method_exists($this, $add_screen_options)) {
705
+			$this->{$add_screen_options}();
706
+		}
707
+		// add help tab(s) - set via page_config and qtips.
708
+		$this->_add_help_tabs();
709
+		$this->_add_qtips();
710
+		// add feature_pointers - global, page child class, and view specific
711
+		$this->_add_feature_pointers();
712
+		$this->_add_global_feature_pointers();
713
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
714
+		if (method_exists($this, $add_feature_pointer)) {
715
+			$this->{$add_feature_pointer}();
716
+		}
717
+		// enqueue scripts/styles - global, page class, and view specific
718
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
719
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
720
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
721
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
722
+		}
723
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
724
+		// admin_print_footer_scripts - global, page child class, and view specific.
725
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
726
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
727
+		// is a good use case. Notice the late priority we're giving these
728
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
729
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
730
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
731
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
732
+		}
733
+		// admin footer scripts
734
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
735
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
736
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
737
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
738
+		}
739
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
740
+		// targeted hook
741
+		do_action(
742
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
743
+		);
744
+	}
745
+
746
+
747
+	/**
748
+	 * _set_defaults
749
+	 * This sets some global defaults for class properties.
750
+	 */
751
+	private function _set_defaults()
752
+	{
753
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
754
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
755
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
756
+		$this->_page_config          = $this->_default_route_query_args = [];
757
+		$this->_default_nav_tab_name = 'overview';
758
+		// init template args
759
+		$this->_template_args = [
760
+			'admin_page_header'  => '',
761
+			'admin_page_content' => '',
762
+			'post_body_content'  => '',
763
+			'before_list_table'  => '',
764
+			'after_list_table'   => '',
765
+		];
766
+	}
767
+
768
+
769
+	/**
770
+	 * route_admin_request
771
+	 *
772
+	 * @return void
773
+	 * @throws InvalidArgumentException
774
+	 * @throws InvalidInterfaceException
775
+	 * @throws InvalidDataTypeException
776
+	 * @throws EE_Error
777
+	 * @throws ReflectionException
778
+	 * @see    _route_admin_request()
779
+	 */
780
+	public function route_admin_request()
781
+	{
782
+		try {
783
+			$this->_route_admin_request();
784
+		} catch (EE_Error $e) {
785
+			$e->get_error();
786
+		}
787
+	}
788
+
789
+
790
+	public function set_wp_page_slug($wp_page_slug)
791
+	{
792
+		$this->_wp_page_slug = $wp_page_slug;
793
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
794
+		if (is_network_admin()) {
795
+			$this->_wp_page_slug .= '-network';
796
+		}
797
+	}
798
+
799
+
800
+	/**
801
+	 * _verify_routes
802
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
803
+	 * we know if we need to drop out.
804
+	 *
805
+	 * @return bool
806
+	 * @throws EE_Error
807
+	 */
808
+	protected function _verify_routes()
809
+	{
810
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
811
+		if (! $this->_current_page && ! $this->request->isAjax()) {
812
+			return false;
813
+		}
814
+		$this->_route = false;
815
+		// check that the page_routes array is not empty
816
+		if (empty($this->_page_routes)) {
817
+			// user error msg
818
+			$error_msg = sprintf(
819
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
820
+				$this->_admin_page_title
821
+			);
822
+			// developer error msg
823
+			$error_msg .= '||' . $error_msg
824
+						  . esc_html__(
825
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
826
+							  'event_espresso'
827
+						  );
828
+			throw new EE_Error($error_msg);
829
+		}
830
+		// and that the requested page route exists
831
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
832
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
833
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
834
+				? $this->_page_config[ $this->_req_action ]
835
+				: [];
836
+		} else {
837
+			// user error msg
838
+			$error_msg = sprintf(
839
+				esc_html__(
840
+					'The requested page route does not exist for the %s admin page.',
841
+					'event_espresso'
842
+				),
843
+				$this->_admin_page_title
844
+			);
845
+			// developer error msg
846
+			$error_msg .= '||' . $error_msg
847
+						  . sprintf(
848
+							  esc_html__(
849
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
850
+								  'event_espresso'
851
+							  ),
852
+							  $this->_req_action
853
+						  );
854
+			throw new EE_Error($error_msg);
855
+		}
856
+		// and that a default route exists
857
+		if (! array_key_exists('default', $this->_page_routes)) {
858
+			// user error msg
859
+			$error_msg = sprintf(
860
+				esc_html__(
861
+					'A default page route has not been set for the % admin page.',
862
+					'event_espresso'
863
+				),
864
+				$this->_admin_page_title
865
+			);
866
+			// developer error msg
867
+			$error_msg .= '||' . $error_msg
868
+						  . esc_html__(
869
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
870
+							  'event_espresso'
871
+						  );
872
+			throw new EE_Error($error_msg);
873
+		}
874
+		// first lets' catch if the UI request has EVER been set.
875
+		if ($this->_is_UI_request === null) {
876
+			// lets set if this is a UI request or not.
877
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
878
+			// wait a minute... we might have a noheader in the route array
879
+			$this->_is_UI_request = ! (
880
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
881
+			)
882
+				? $this->_is_UI_request
883
+				: false;
884
+		}
885
+		$this->_set_current_labels();
886
+		return true;
887
+	}
888
+
889
+
890
+	/**
891
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
892
+	 *
893
+	 * @param string $route the route name we're verifying
894
+	 * @return bool we'll throw an exception if this isn't a valid route.
895
+	 * @throws EE_Error
896
+	 */
897
+	protected function _verify_route($route)
898
+	{
899
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
900
+			return true;
901
+		}
902
+		// user error msg
903
+		$error_msg = sprintf(
904
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
905
+			$this->_admin_page_title
906
+		);
907
+		// developer error msg
908
+		$error_msg .= '||' . $error_msg
909
+					  . sprintf(
910
+						  esc_html__(
911
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
912
+							  'event_espresso'
913
+						  ),
914
+						  $route
915
+					  );
916
+		throw new EE_Error($error_msg);
917
+	}
918
+
919
+
920
+	/**
921
+	 * perform nonce verification
922
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
923
+	 * using this method (and save retyping!)
924
+	 *
925
+	 * @param string $nonce     The nonce sent
926
+	 * @param string $nonce_ref The nonce reference string (name0)
927
+	 * @return void
928
+	 * @throws EE_Error
929
+	 */
930
+	protected function _verify_nonce($nonce, $nonce_ref)
931
+	{
932
+		// verify nonce against expected value
933
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
934
+			// these are not the droids you are looking for !!!
935
+			$msg = sprintf(
936
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
937
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
938
+				'</a>'
939
+			);
940
+			if (WP_DEBUG) {
941
+				$msg .= "\n  ";
942
+				$msg .= sprintf(
943
+					esc_html__(
944
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
945
+						'event_espresso'
946
+					),
947
+					__CLASS__
948
+				);
949
+			}
950
+			if (! $this->request->isAjax()) {
951
+				wp_die($msg);
952
+			}
953
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
954
+			$this->_return_json();
955
+		}
956
+	}
957
+
958
+
959
+	/**
960
+	 * _route_admin_request()
961
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
962
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
963
+	 * in the page routes and then will try to load the corresponding method.
964
+	 *
965
+	 * @return void
966
+	 * @throws EE_Error
967
+	 * @throws InvalidArgumentException
968
+	 * @throws InvalidDataTypeException
969
+	 * @throws InvalidInterfaceException
970
+	 * @throws ReflectionException
971
+	 */
972
+	protected function _route_admin_request()
973
+	{
974
+		if (! $this->_is_UI_request) {
975
+			$this->_verify_routes();
976
+		}
977
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
978
+		if ($this->_req_action !== 'default' && $nonce_check) {
979
+			// set nonce from post data
980
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
981
+			$this->_verify_nonce($nonce, $this->_req_nonce);
982
+		}
983
+		// set the nav_tabs array but ONLY if this is  UI_request
984
+		if ($this->_is_UI_request) {
985
+			$this->_set_nav_tabs();
986
+		}
987
+		// grab callback function
988
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
989
+		// check if callback has args
990
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
991
+		$error_msg = '';
992
+		// action right before calling route
993
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
994
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
995
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
996
+		}
997
+		// right before calling the route, let's clean the _wp_http_referer
998
+		$this->request->setServerParam(
999
+			'REQUEST_URI',
1000
+			remove_query_arg(
1001
+				'_wp_http_referer',
1002
+				wp_unslash($this->request->getServerParam('REQUEST_URI'))
1003
+			)
1004
+		);
1005
+		if (! empty($func)) {
1006
+			if (is_array($func)) {
1007
+				list($class, $method) = $func;
1008
+			} elseif (strpos($func, '::') !== false) {
1009
+				list($class, $method) = explode('::', $func);
1010
+			} else {
1011
+				$class  = $this;
1012
+				$method = $func;
1013
+			}
1014
+			if (! (is_object($class) && $class === $this)) {
1015
+				// send along this admin page object for access by addons.
1016
+				$args['admin_page_object'] = $this;
1017
+			}
1018
+			if (
1019
+				// is it a method on a class that doesn't work?
1020
+				(
1021
+					(
1022
+						method_exists($class, $method)
1023
+						&& call_user_func_array([$class, $method], $args) === false
1024
+					)
1025
+					&& (
1026
+						// is it a standalone function that doesn't work?
1027
+						function_exists($method)
1028
+						&& call_user_func_array(
1029
+							$func,
1030
+							array_merge(['admin_page_object' => $this], $args)
1031
+						) === false
1032
+					)
1033
+				)
1034
+				|| (
1035
+					// is it neither a class method NOR a standalone function?
1036
+					! method_exists($class, $method)
1037
+					&& ! function_exists($method)
1038
+				)
1039
+			) {
1040
+				// user error msg
1041
+				$error_msg = esc_html__(
1042
+					'An error occurred. The  requested page route could not be found.',
1043
+					'event_espresso'
1044
+				);
1045
+				// developer error msg
1046
+				$error_msg .= '||';
1047
+				$error_msg .= sprintf(
1048
+					esc_html__(
1049
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1050
+						'event_espresso'
1051
+					),
1052
+					$method
1053
+				);
1054
+			}
1055
+			if (! empty($error_msg)) {
1056
+				throw new EE_Error($error_msg);
1057
+			}
1058
+		}
1059
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1060
+		// then we need to reset the routing properties to the new route.
1061
+		// 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.
1062
+		if (
1063
+			$this->_is_UI_request === false
1064
+			&& is_array($this->_route)
1065
+			&& ! empty($this->_route['headers_sent_route'])
1066
+		) {
1067
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1068
+		}
1069
+	}
1070
+
1071
+
1072
+	/**
1073
+	 * This method just allows the resetting of page properties in the case where a no headers
1074
+	 * route redirects to a headers route in its route config.
1075
+	 *
1076
+	 * @param string $new_route New (non header) route to redirect to.
1077
+	 * @return   void
1078
+	 * @throws ReflectionException
1079
+	 * @throws InvalidArgumentException
1080
+	 * @throws InvalidInterfaceException
1081
+	 * @throws InvalidDataTypeException
1082
+	 * @throws EE_Error
1083
+	 * @since   4.3.0
1084
+	 */
1085
+	protected function _reset_routing_properties($new_route)
1086
+	{
1087
+		$this->_is_UI_request = true;
1088
+		// now we set the current route to whatever the headers_sent_route is set at
1089
+		$this->request->setRequestParam('action', $new_route);
1090
+		// rerun page setup
1091
+		$this->_page_setup();
1092
+	}
1093
+
1094
+
1095
+	/**
1096
+	 * _add_query_arg
1097
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1098
+	 *(internally just uses EEH_URL's function with the same name)
1099
+	 *
1100
+	 * @param array  $args
1101
+	 * @param string $url
1102
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1103
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1104
+	 *                                        Example usage: If the current page is:
1105
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1106
+	 *                                        &action=default&event_id=20&month_range=March%202015
1107
+	 *                                        &_wpnonce=5467821
1108
+	 *                                        and you call:
1109
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1110
+	 *                                        array(
1111
+	 *                                        'action' => 'resend_something',
1112
+	 *                                        'page=>espresso_registrations'
1113
+	 *                                        ),
1114
+	 *                                        $some_url,
1115
+	 *                                        true
1116
+	 *                                        );
1117
+	 *                                        It will produce a url in this structure:
1118
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1119
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1120
+	 *                                        month_range]=March%202015
1121
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1122
+	 * @return string
1123
+	 */
1124
+	public static function add_query_args_and_nonce(
1125
+		$args = [],
1126
+		$url = false,
1127
+		$sticky = false,
1128
+		$exclude_nonce = false
1129
+	) {
1130
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1131
+		if ($sticky) {
1132
+			/** @var RequestInterface $request */
1133
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1134
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1135
+			foreach ($request->requestParams() as $key => $value) {
1136
+				// do not add nonces
1137
+				if (strpos($key, 'nonce') !== false) {
1138
+					continue;
1139
+				}
1140
+				$args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1141
+			}
1142
+		}
1143
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1144
+	}
1145
+
1146
+
1147
+	/**
1148
+	 * This returns a generated link that will load the related help tab.
1149
+	 *
1150
+	 * @param string $help_tab_id the id for the connected help tab
1151
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1152
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1153
+	 * @return string              generated link
1154
+	 * @uses EEH_Template::get_help_tab_link()
1155
+	 */
1156
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1157
+	{
1158
+		return EEH_Template::get_help_tab_link(
1159
+			$help_tab_id,
1160
+			$this->page_slug,
1161
+			$this->_req_action,
1162
+			$icon_style,
1163
+			$help_text
1164
+		);
1165
+	}
1166
+
1167
+
1168
+	/**
1169
+	 * _add_help_tabs
1170
+	 * Note child classes define their help tabs within the page_config array.
1171
+	 *
1172
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1173
+	 * @return void
1174
+	 * @throws DomainException
1175
+	 * @throws EE_Error
1176
+	 */
1177
+	protected function _add_help_tabs()
1178
+	{
1179
+		if (isset($this->_page_config[ $this->_req_action ])) {
1180
+			$config = $this->_page_config[ $this->_req_action ];
1181
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1182
+			if (is_array($config) && isset($config['help_sidebar'])) {
1183
+				// check that the callback given is valid
1184
+				if (! method_exists($this, $config['help_sidebar'])) {
1185
+					throw new EE_Error(
1186
+						sprintf(
1187
+							esc_html__(
1188
+								'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',
1189
+								'event_espresso'
1190
+							),
1191
+							$config['help_sidebar'],
1192
+							get_class($this)
1193
+						)
1194
+					);
1195
+				}
1196
+				$content = apply_filters(
1197
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1198
+					$this->{$config['help_sidebar']}()
1199
+				);
1200
+				$this->_current_screen->set_help_sidebar($content);
1201
+			}
1202
+			if (! isset($config['help_tabs'])) {
1203
+				return;
1204
+			} //no help tabs for this route
1205
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1206
+				// we're here so there ARE help tabs!
1207
+				// make sure we've got what we need
1208
+				if (! isset($cfg['title'])) {
1209
+					throw new EE_Error(
1210
+						esc_html__(
1211
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1212
+							'event_espresso'
1213
+						)
1214
+					);
1215
+				}
1216
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1217
+					throw new EE_Error(
1218
+						esc_html__(
1219
+							'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',
1220
+							'event_espresso'
1221
+						)
1222
+					);
1223
+				}
1224
+				// first priority goes to content.
1225
+				if (! empty($cfg['content'])) {
1226
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1227
+					// second priority goes to filename
1228
+				} elseif (! empty($cfg['filename'])) {
1229
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1230
+					// 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)
1231
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1232
+															 . basename($this->_get_dir())
1233
+															 . '/help_tabs/'
1234
+															 . $cfg['filename']
1235
+															 . '.help_tab.php' : $file_path;
1236
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1237
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1238
+						EE_Error::add_error(
1239
+							sprintf(
1240
+								esc_html__(
1241
+									'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',
1242
+									'event_espresso'
1243
+								),
1244
+								$tab_id,
1245
+								key($config),
1246
+								$file_path
1247
+							),
1248
+							__FILE__,
1249
+							__FUNCTION__,
1250
+							__LINE__
1251
+						);
1252
+						return;
1253
+					}
1254
+					$template_args['admin_page_obj'] = $this;
1255
+					$content                         = EEH_Template::display_template(
1256
+						$file_path,
1257
+						$template_args,
1258
+						true
1259
+					);
1260
+				} else {
1261
+					$content = '';
1262
+				}
1263
+				// check if callback is valid
1264
+				if (
1265
+					empty($content)
1266
+					&& (
1267
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1268
+					)
1269
+				) {
1270
+					EE_Error::add_error(
1271
+						sprintf(
1272
+							esc_html__(
1273
+								'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.',
1274
+								'event_espresso'
1275
+							),
1276
+							$cfg['title']
1277
+						),
1278
+						__FILE__,
1279
+						__FUNCTION__,
1280
+						__LINE__
1281
+					);
1282
+					return;
1283
+				}
1284
+				// setup config array for help tab method
1285
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1286
+				$_ht = [
1287
+					'id'       => $id,
1288
+					'title'    => $cfg['title'],
1289
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1290
+					'content'  => $content,
1291
+				];
1292
+				$this->_current_screen->add_help_tab($_ht);
1293
+			}
1294
+		}
1295
+	}
1296
+
1297
+
1298
+	/**
1299
+	 * This simply sets up any qtips that have been defined in the page config
1300
+	 *
1301
+	 * @return void
1302
+	 */
1303
+	protected function _add_qtips()
1304
+	{
1305
+		if (isset($this->_route_config['qtips'])) {
1306
+			$qtips = (array) $this->_route_config['qtips'];
1307
+			// load qtip loader
1308
+			$path = [
1309
+				$this->_get_dir() . '/qtips/',
1310
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1311
+			];
1312
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1313
+		}
1314
+	}
1315
+
1316
+
1317
+	/**
1318
+	 * _set_nav_tabs
1319
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1320
+	 * wish to add additional tabs or modify accordingly.
1321
+	 *
1322
+	 * @return void
1323
+	 * @throws InvalidArgumentException
1324
+	 * @throws InvalidInterfaceException
1325
+	 * @throws InvalidDataTypeException
1326
+	 */
1327
+	protected function _set_nav_tabs()
1328
+	{
1329
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1330
+		$i = 0;
1331
+		foreach ($this->_page_config as $slug => $config) {
1332
+			if (! is_array($config) || empty($config['nav'])) {
1333
+				continue;
1334
+			}
1335
+			// no nav tab for this config
1336
+			// check for persistent flag
1337
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1338
+				// nav tab is only to appear when route requested.
1339
+				continue;
1340
+			}
1341
+			if (! $this->check_user_access($slug, true)) {
1342
+				// no nav tab because current user does not have access.
1343
+				continue;
1344
+			}
1345
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1346
+			$this->_nav_tabs[ $slug ] = [
1347
+				'url'       => isset($config['nav']['url'])
1348
+					? $config['nav']['url']
1349
+					: self::add_query_args_and_nonce(
1350
+						['action' => $slug],
1351
+						$this->_admin_base_url
1352
+					),
1353
+				'link_text' => isset($config['nav']['label'])
1354
+					? $config['nav']['label']
1355
+					: ucwords(
1356
+						str_replace('_', ' ', $slug)
1357
+					),
1358
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1359
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1360
+			];
1361
+			$i++;
1362
+		}
1363
+		// if $this->_nav_tabs is empty then lets set the default
1364
+		if (empty($this->_nav_tabs)) {
1365
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1366
+				'url'       => $this->_admin_base_url,
1367
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1368
+				'css_class' => 'nav-tab-active',
1369
+				'order'     => 10,
1370
+			];
1371
+		}
1372
+		// now let's sort the tabs according to order
1373
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1374
+	}
1375
+
1376
+
1377
+	/**
1378
+	 * _set_current_labels
1379
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1380
+	 * property array
1381
+	 *
1382
+	 * @return void
1383
+	 */
1384
+	private function _set_current_labels()
1385
+	{
1386
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1387
+			foreach ($this->_route_config['labels'] as $label => $text) {
1388
+				if (is_array($text)) {
1389
+					foreach ($text as $sublabel => $subtext) {
1390
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1391
+					}
1392
+				} else {
1393
+					$this->_labels[ $label ] = $text;
1394
+				}
1395
+			}
1396
+		}
1397
+	}
1398
+
1399
+
1400
+	/**
1401
+	 *        verifies user access for this admin page
1402
+	 *
1403
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1404
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1405
+	 *                               return false if verify fail.
1406
+	 * @return bool
1407
+	 * @throws InvalidArgumentException
1408
+	 * @throws InvalidDataTypeException
1409
+	 * @throws InvalidInterfaceException
1410
+	 */
1411
+	public function check_user_access($route_to_check = '', $verify_only = false)
1412
+	{
1413
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1414
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1415
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1416
+						  && is_array(
1417
+							  $this->_page_routes[ $route_to_check ]
1418
+						  )
1419
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1420
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1421
+		if (empty($capability) && empty($route_to_check)) {
1422
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1423
+				: $this->_route['capability'];
1424
+		} else {
1425
+			$capability = empty($capability) ? 'manage_options' : $capability;
1426
+		}
1427
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1428
+		if (
1429
+			! $this->request->isAjax()
1430
+			&& (
1431
+				! function_exists('is_admin')
1432
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1433
+					$capability,
1434
+					$this->page_slug
1435
+					. '_'
1436
+					. $route_to_check,
1437
+					$id
1438
+				)
1439
+			)
1440
+		) {
1441
+			if ($verify_only) {
1442
+				return false;
1443
+			}
1444
+			if (is_user_logged_in()) {
1445
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1446
+			} else {
1447
+				return false;
1448
+			}
1449
+		}
1450
+		return true;
1451
+	}
1452
+
1453
+
1454
+	/**
1455
+	 * admin_init_global
1456
+	 * This runs all the code that we want executed within the WP admin_init hook.
1457
+	 * This method executes for ALL EE Admin pages.
1458
+	 *
1459
+	 * @return void
1460
+	 */
1461
+	public function admin_init_global()
1462
+	{
1463
+	}
1464
+
1465
+
1466
+	/**
1467
+	 * wp_loaded_global
1468
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1469
+	 * EE_Admin page and will execute on every EE Admin Page load
1470
+	 *
1471
+	 * @return void
1472
+	 */
1473
+	public function wp_loaded()
1474
+	{
1475
+	}
1476
+
1477
+
1478
+	/**
1479
+	 * admin_notices
1480
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1481
+	 * ALL EE_Admin pages.
1482
+	 *
1483
+	 * @return void
1484
+	 */
1485
+	public function admin_notices_global()
1486
+	{
1487
+		$this->_display_no_javascript_warning();
1488
+		$this->_display_espresso_notices();
1489
+	}
1490
+
1491
+
1492
+	public function network_admin_notices_global()
1493
+	{
1494
+		$this->_display_no_javascript_warning();
1495
+		$this->_display_espresso_notices();
1496
+	}
1497
+
1498
+
1499
+	/**
1500
+	 * admin_footer_scripts_global
1501
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1502
+	 * will apply on ALL EE_Admin pages.
1503
+	 *
1504
+	 * @return void
1505
+	 */
1506
+	public function admin_footer_scripts_global()
1507
+	{
1508
+		$this->_add_admin_page_ajax_loading_img();
1509
+		$this->_add_admin_page_overlay();
1510
+		// if metaboxes are present we need to add the nonce field
1511
+		if (
1512
+			isset($this->_route_config['metaboxes'])
1513
+			|| isset($this->_route_config['list_table'])
1514
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1515
+		) {
1516
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1517
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1518
+		}
1519
+	}
1520
+
1521
+
1522
+	/**
1523
+	 * admin_footer_global
1524
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1525
+	 * ALL EE_Admin Pages.
1526
+	 *
1527
+	 * @return void
1528
+	 */
1529
+	public function admin_footer_global()
1530
+	{
1531
+		// dialog container for dialog helper
1532
+		echo '
1533 1533
         <div class="ee-admin-dialog-container auto-hide hidden">
1534 1534
             <div class="ee-notices"></div>
1535 1535
             <div class="ee-admin-dialog-container-inner-content"></div>
1536 1536
         </div>
1537 1537
         ';
1538 1538
 
1539
-        // current set timezone for timezone js
1540
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1541
-    }
1542
-
1543
-
1544
-    /**
1545
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1546
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1547
-     * help popups then in your templates or your content you set "triggers" for the content using the
1548
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1549
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1550
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1551
-     * for the
1552
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1553
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1554
-     *    'help_trigger_id' => array(
1555
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1556
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1557
-     *    )
1558
-     * );
1559
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1560
-     *
1561
-     * @param array $help_array
1562
-     * @param bool  $display
1563
-     * @return string content
1564
-     * @throws DomainException
1565
-     * @throws EE_Error
1566
-     */
1567
-    protected function _set_help_popup_content($help_array = [], $display = false)
1568
-    {
1569
-        $content    = '';
1570
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1571
-        // loop through the array and setup content
1572
-        foreach ($help_array as $trigger => $help) {
1573
-            // make sure the array is setup properly
1574
-            if (! isset($help['title']) || ! isset($help['content'])) {
1575
-                throw new EE_Error(
1576
-                    esc_html__(
1577
-                        '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',
1578
-                        'event_espresso'
1579
-                    )
1580
-                );
1581
-            }
1582
-            // we're good so let's setup the template vars and then assign parsed template content to our content.
1583
-            $template_args = [
1584
-                'help_popup_id'      => $trigger,
1585
-                'help_popup_title'   => $help['title'],
1586
-                'help_popup_content' => $help['content'],
1587
-            ];
1588
-            $content       .= EEH_Template::display_template(
1589
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1590
-                $template_args,
1591
-                true
1592
-            );
1593
-        }
1594
-        if ($display) {
1595
-            echo $content; // already escaped
1596
-            return '';
1597
-        }
1598
-        return $content;
1599
-    }
1600
-
1601
-
1602
-    /**
1603
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1604
-     *
1605
-     * @return array properly formatted array for help popup content
1606
-     * @throws EE_Error
1607
-     */
1608
-    private function _get_help_content()
1609
-    {
1610
-        // what is the method we're looking for?
1611
-        $method_name = '_help_popup_content_' . $this->_req_action;
1612
-        // if method doesn't exist let's get out.
1613
-        if (! method_exists($this, $method_name)) {
1614
-            return [];
1615
-        }
1616
-        // k we're good to go let's retrieve the help array
1617
-        $help_array = call_user_func([$this, $method_name]);
1618
-        // make sure we've got an array!
1619
-        if (! is_array($help_array)) {
1620
-            throw new EE_Error(
1621
-                esc_html__(
1622
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1623
-                    'event_espresso'
1624
-                )
1625
-            );
1626
-        }
1627
-        return $help_array;
1628
-    }
1629
-
1630
-
1631
-    /**
1632
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1633
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1634
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1635
-     *
1636
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1637
-     * @param boolean $display    if false then we return the trigger string
1638
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1639
-     * @return string
1640
-     * @throws DomainException
1641
-     * @throws EE_Error
1642
-     */
1643
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1644
-    {
1645
-        if ($this->request->isAjax()) {
1646
-            return '';
1647
-        }
1648
-        // 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
1649
-        $help_array   = $this->_get_help_content();
1650
-        $help_content = '';
1651
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1652
-            $help_array[ $trigger_id ] = [
1653
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1654
-                'content' => esc_html__(
1655
-                    '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.)',
1656
-                    'event_espresso'
1657
-                ),
1658
-            ];
1659
-            $help_content              = $this->_set_help_popup_content($help_array);
1660
-        }
1661
-        // let's setup the trigger
1662
-        $content = '<a class="ee-dialog" href="?height='
1663
-                   . esc_attr($dimensions[0])
1664
-                   . '&width='
1665
-                   . esc_attr($dimensions[1])
1666
-                   . '&inlineId='
1667
-                   . esc_attr($trigger_id)
1668
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1669
-        $content .= $help_content;
1670
-        if ($display) {
1671
-            echo $content; // already escaped
1672
-            return '';
1673
-        }
1674
-        return $content;
1675
-    }
1676
-
1677
-
1678
-    /**
1679
-     * _add_global_screen_options
1680
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1681
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1682
-     *
1683
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1684
-     *         see also WP_Screen object documents...
1685
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1686
-     * @abstract
1687
-     * @return void
1688
-     */
1689
-    private function _add_global_screen_options()
1690
-    {
1691
-    }
1692
-
1693
-
1694
-    /**
1695
-     * _add_global_feature_pointers
1696
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1697
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1698
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1699
-     *
1700
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1701
-     *         extended) also see:
1702
-     * @link   http://eamann.com/tech/wordpress-portland/
1703
-     * @abstract
1704
-     * @return void
1705
-     */
1706
-    private function _add_global_feature_pointers()
1707
-    {
1708
-    }
1709
-
1710
-
1711
-    /**
1712
-     * load_global_scripts_styles
1713
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1714
-     *
1715
-     * @return void
1716
-     */
1717
-    public function load_global_scripts_styles()
1718
-    {
1719
-        /** STYLES **/
1720
-        // add debugging styles
1721
-        if (WP_DEBUG) {
1722
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1723
-        }
1724
-        // register all styles
1725
-        wp_register_style(
1726
-            'espresso-ui-theme',
1727
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1728
-            [],
1729
-            EVENT_ESPRESSO_VERSION
1730
-        );
1731
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1732
-        // helpers styles
1733
-        wp_register_style(
1734
-            'ee-text-links',
1735
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1736
-            [],
1737
-            EVENT_ESPRESSO_VERSION
1738
-        );
1739
-        /** SCRIPTS **/
1740
-        // register all scripts
1741
-        wp_register_script(
1742
-            'ee-dialog',
1743
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1744
-            ['jquery', 'jquery-ui-draggable'],
1745
-            EVENT_ESPRESSO_VERSION,
1746
-            true
1747
-        );
1748
-        wp_register_script(
1749
-            'ee_admin_js',
1750
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1751
-            ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1752
-            EVENT_ESPRESSO_VERSION,
1753
-            true
1754
-        );
1755
-        wp_register_script(
1756
-            'jquery-ui-timepicker-addon',
1757
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1758
-            ['jquery-ui-datepicker', 'jquery-ui-slider'],
1759
-            EVENT_ESPRESSO_VERSION,
1760
-            true
1761
-        );
1762
-        // script for sorting tables
1763
-        wp_register_script(
1764
-            'espresso_ajax_table_sorting',
1765
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1766
-            ['ee_admin_js', 'jquery-ui-sortable'],
1767
-            EVENT_ESPRESSO_VERSION,
1768
-            true
1769
-        );
1770
-        // script for parsing uri's
1771
-        wp_register_script(
1772
-            'ee-parse-uri',
1773
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1774
-            [],
1775
-            EVENT_ESPRESSO_VERSION,
1776
-            true
1777
-        );
1778
-        // and parsing associative serialized form elements
1779
-        wp_register_script(
1780
-            'ee-serialize-full-array',
1781
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1782
-            ['jquery'],
1783
-            EVENT_ESPRESSO_VERSION,
1784
-            true
1785
-        );
1786
-        // helpers scripts
1787
-        wp_register_script(
1788
-            'ee-text-links',
1789
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1790
-            ['jquery'],
1791
-            EVENT_ESPRESSO_VERSION,
1792
-            true
1793
-        );
1794
-        wp_register_script(
1795
-            'ee-moment-core',
1796
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1797
-            [],
1798
-            EVENT_ESPRESSO_VERSION,
1799
-            true
1800
-        );
1801
-        wp_register_script(
1802
-            'ee-moment',
1803
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1804
-            ['ee-moment-core'],
1805
-            EVENT_ESPRESSO_VERSION,
1806
-            true
1807
-        );
1808
-        wp_register_script(
1809
-            'ee-datepicker',
1810
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1811
-            ['jquery-ui-timepicker-addon', 'ee-moment'],
1812
-            EVENT_ESPRESSO_VERSION,
1813
-            true
1814
-        );
1815
-        // google charts
1816
-        wp_register_script(
1817
-            'google-charts',
1818
-            'https://www.gstatic.com/charts/loader.js',
1819
-            [],
1820
-            EVENT_ESPRESSO_VERSION
1821
-        );
1822
-        // ENQUEUE ALL BASICS BY DEFAULT
1823
-        wp_enqueue_style('ee-admin-css');
1824
-        wp_enqueue_script('ee_admin_js');
1825
-        wp_enqueue_script('ee-accounting');
1826
-        wp_enqueue_script('jquery-validate');
1827
-        // taking care of metaboxes
1828
-        if (
1829
-            empty($this->_cpt_route)
1830
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1831
-        ) {
1832
-            wp_enqueue_script('dashboard');
1833
-        }
1834
-        // LOCALIZED DATA
1835
-        // localize script for ajax lazy loading
1836
-        $lazy_loader_container_ids = apply_filters(
1837
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1838
-            ['espresso_news_post_box_content']
1839
-        );
1840
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1841
-        add_filter(
1842
-            'admin_body_class',
1843
-            function ($classes) {
1844
-                if (strpos($classes, 'espresso-admin') === false) {
1845
-                    $classes .= ' espresso-admin';
1846
-                }
1847
-                return $classes;
1848
-            }
1849
-        );
1850
-    }
1851
-
1852
-
1853
-    /**
1854
-     *        admin_footer_scripts_eei18n_js_strings
1855
-     *
1856
-     * @return        void
1857
-     */
1858
-    public function admin_footer_scripts_eei18n_js_strings()
1859
-    {
1860
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1861
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1862
-            __(
1863
-                '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!!!',
1864
-                'event_espresso'
1865
-            )
1866
-        );
1867
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1868
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1869
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1870
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1871
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1872
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1873
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1874
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1875
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1876
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1877
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1878
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1879
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1880
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1881
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1882
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1883
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1884
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1885
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1886
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1887
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1888
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1889
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1890
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1891
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1892
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1893
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1894
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1895
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1896
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1897
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1898
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1899
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1900
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1901
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1902
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1903
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1904
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1905
-    }
1906
-
1907
-
1908
-    /**
1909
-     *        load enhanced xdebug styles for ppl with failing eyesight
1910
-     *
1911
-     * @return        void
1912
-     */
1913
-    public function add_xdebug_style()
1914
-    {
1915
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1916
-    }
1917
-
1918
-
1919
-    /************************/
1920
-    /** LIST TABLE METHODS **/
1921
-    /************************/
1922
-    /**
1923
-     * this sets up the list table if the current view requires it.
1924
-     *
1925
-     * @return void
1926
-     * @throws EE_Error
1927
-     */
1928
-    protected function _set_list_table()
1929
-    {
1930
-        // first is this a list_table view?
1931
-        if (! isset($this->_route_config['list_table'])) {
1932
-            return;
1933
-        } //not a list_table view so get out.
1934
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
1935
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
1936
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1937
-            // user error msg
1938
-            $error_msg = esc_html__(
1939
-                'An error occurred. The requested list table views could not be found.',
1940
-                'event_espresso'
1941
-            );
1942
-            // developer error msg
1943
-            $error_msg .= '||'
1944
-                          . sprintf(
1945
-                              esc_html__(
1946
-                                  '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.',
1947
-                                  'event_espresso'
1948
-                              ),
1949
-                              $this->_req_action,
1950
-                              $list_table_view
1951
-                          );
1952
-            throw new EE_Error($error_msg);
1953
-        }
1954
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1955
-        $this->_views = apply_filters(
1956
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1957
-            $this->_views
1958
-        );
1959
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1960
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1961
-        $this->_set_list_table_view();
1962
-        $this->_set_list_table_object();
1963
-    }
1964
-
1965
-
1966
-    /**
1967
-     * set current view for List Table
1968
-     *
1969
-     * @return void
1970
-     */
1971
-    protected function _set_list_table_view()
1972
-    {
1973
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1974
-        $status = $this->request->getRequestParam('status', null, 'key');
1975
-        $this->_view = $status && array_key_exists($status, $this->_views)
1976
-            ? $status
1977
-            : $this->_view;
1978
-    }
1979
-
1980
-
1981
-    /**
1982
-     * _set_list_table_object
1983
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1984
-     *
1985
-     * @throws InvalidInterfaceException
1986
-     * @throws InvalidArgumentException
1987
-     * @throws InvalidDataTypeException
1988
-     * @throws EE_Error
1989
-     * @throws InvalidInterfaceException
1990
-     */
1991
-    protected function _set_list_table_object()
1992
-    {
1993
-        if (isset($this->_route_config['list_table'])) {
1994
-            if (! class_exists($this->_route_config['list_table'])) {
1995
-                throw new EE_Error(
1996
-                    sprintf(
1997
-                        esc_html__(
1998
-                            '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.',
1999
-                            'event_espresso'
2000
-                        ),
2001
-                        $this->_route_config['list_table'],
2002
-                        get_class($this)
2003
-                    )
2004
-                );
2005
-            }
2006
-            $this->_list_table_object = $this->loader->getShared(
2007
-                $this->_route_config['list_table'],
2008
-                [$this]
2009
-            );
2010
-        }
2011
-    }
2012
-
2013
-
2014
-    /**
2015
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2016
-     *
2017
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2018
-     *                                                    urls.  The array should be indexed by the view it is being
2019
-     *                                                    added to.
2020
-     * @return array
2021
-     */
2022
-    public function get_list_table_view_RLs($extra_query_args = [])
2023
-    {
2024
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2025
-        if (empty($this->_views)) {
2026
-            $this->_views = [];
2027
-        }
2028
-        // cycle thru views
2029
-        foreach ($this->_views as $key => $view) {
2030
-            $query_args = [];
2031
-            // check for current view
2032
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2033
-            $query_args['action']                        = $this->_req_action;
2034
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2035
-            $query_args['status']                        = $view['slug'];
2036
-            // merge any other arguments sent in.
2037
-            if (isset($extra_query_args[ $view['slug'] ])) {
2038
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2039
-            }
2040
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2041
-        }
2042
-        return $this->_views;
2043
-    }
2044
-
2045
-
2046
-    /**
2047
-     * _entries_per_page_dropdown
2048
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2049
-     *
2050
-     * @param int $max_entries total number of rows in the table
2051
-     * @return string
2052
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2053
-     *         WP does it.
2054
-     */
2055
-    protected function _entries_per_page_dropdown($max_entries = 0)
2056
-    {
2057
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2058
-        $values   = [10, 25, 50, 100];
2059
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2060
-        if ($max_entries) {
2061
-            $values[] = $max_entries;
2062
-            sort($values);
2063
-        }
2064
-        $entries_per_page_dropdown = '
1539
+		// current set timezone for timezone js
1540
+		echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1541
+	}
1542
+
1543
+
1544
+	/**
1545
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1546
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1547
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1548
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1549
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1550
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1551
+	 * for the
1552
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1553
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1554
+	 *    'help_trigger_id' => array(
1555
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1556
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1557
+	 *    )
1558
+	 * );
1559
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1560
+	 *
1561
+	 * @param array $help_array
1562
+	 * @param bool  $display
1563
+	 * @return string content
1564
+	 * @throws DomainException
1565
+	 * @throws EE_Error
1566
+	 */
1567
+	protected function _set_help_popup_content($help_array = [], $display = false)
1568
+	{
1569
+		$content    = '';
1570
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1571
+		// loop through the array and setup content
1572
+		foreach ($help_array as $trigger => $help) {
1573
+			// make sure the array is setup properly
1574
+			if (! isset($help['title']) || ! isset($help['content'])) {
1575
+				throw new EE_Error(
1576
+					esc_html__(
1577
+						'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',
1578
+						'event_espresso'
1579
+					)
1580
+				);
1581
+			}
1582
+			// we're good so let's setup the template vars and then assign parsed template content to our content.
1583
+			$template_args = [
1584
+				'help_popup_id'      => $trigger,
1585
+				'help_popup_title'   => $help['title'],
1586
+				'help_popup_content' => $help['content'],
1587
+			];
1588
+			$content       .= EEH_Template::display_template(
1589
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1590
+				$template_args,
1591
+				true
1592
+			);
1593
+		}
1594
+		if ($display) {
1595
+			echo $content; // already escaped
1596
+			return '';
1597
+		}
1598
+		return $content;
1599
+	}
1600
+
1601
+
1602
+	/**
1603
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1604
+	 *
1605
+	 * @return array properly formatted array for help popup content
1606
+	 * @throws EE_Error
1607
+	 */
1608
+	private function _get_help_content()
1609
+	{
1610
+		// what is the method we're looking for?
1611
+		$method_name = '_help_popup_content_' . $this->_req_action;
1612
+		// if method doesn't exist let's get out.
1613
+		if (! method_exists($this, $method_name)) {
1614
+			return [];
1615
+		}
1616
+		// k we're good to go let's retrieve the help array
1617
+		$help_array = call_user_func([$this, $method_name]);
1618
+		// make sure we've got an array!
1619
+		if (! is_array($help_array)) {
1620
+			throw new EE_Error(
1621
+				esc_html__(
1622
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1623
+					'event_espresso'
1624
+				)
1625
+			);
1626
+		}
1627
+		return $help_array;
1628
+	}
1629
+
1630
+
1631
+	/**
1632
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1633
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1634
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1635
+	 *
1636
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1637
+	 * @param boolean $display    if false then we return the trigger string
1638
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1639
+	 * @return string
1640
+	 * @throws DomainException
1641
+	 * @throws EE_Error
1642
+	 */
1643
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1644
+	{
1645
+		if ($this->request->isAjax()) {
1646
+			return '';
1647
+		}
1648
+		// 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
1649
+		$help_array   = $this->_get_help_content();
1650
+		$help_content = '';
1651
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1652
+			$help_array[ $trigger_id ] = [
1653
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1654
+				'content' => esc_html__(
1655
+					'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.)',
1656
+					'event_espresso'
1657
+				),
1658
+			];
1659
+			$help_content              = $this->_set_help_popup_content($help_array);
1660
+		}
1661
+		// let's setup the trigger
1662
+		$content = '<a class="ee-dialog" href="?height='
1663
+				   . esc_attr($dimensions[0])
1664
+				   . '&width='
1665
+				   . esc_attr($dimensions[1])
1666
+				   . '&inlineId='
1667
+				   . esc_attr($trigger_id)
1668
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1669
+		$content .= $help_content;
1670
+		if ($display) {
1671
+			echo $content; // already escaped
1672
+			return '';
1673
+		}
1674
+		return $content;
1675
+	}
1676
+
1677
+
1678
+	/**
1679
+	 * _add_global_screen_options
1680
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1681
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1682
+	 *
1683
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1684
+	 *         see also WP_Screen object documents...
1685
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1686
+	 * @abstract
1687
+	 * @return void
1688
+	 */
1689
+	private function _add_global_screen_options()
1690
+	{
1691
+	}
1692
+
1693
+
1694
+	/**
1695
+	 * _add_global_feature_pointers
1696
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1697
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1698
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1699
+	 *
1700
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1701
+	 *         extended) also see:
1702
+	 * @link   http://eamann.com/tech/wordpress-portland/
1703
+	 * @abstract
1704
+	 * @return void
1705
+	 */
1706
+	private function _add_global_feature_pointers()
1707
+	{
1708
+	}
1709
+
1710
+
1711
+	/**
1712
+	 * load_global_scripts_styles
1713
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1714
+	 *
1715
+	 * @return void
1716
+	 */
1717
+	public function load_global_scripts_styles()
1718
+	{
1719
+		/** STYLES **/
1720
+		// add debugging styles
1721
+		if (WP_DEBUG) {
1722
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1723
+		}
1724
+		// register all styles
1725
+		wp_register_style(
1726
+			'espresso-ui-theme',
1727
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1728
+			[],
1729
+			EVENT_ESPRESSO_VERSION
1730
+		);
1731
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1732
+		// helpers styles
1733
+		wp_register_style(
1734
+			'ee-text-links',
1735
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1736
+			[],
1737
+			EVENT_ESPRESSO_VERSION
1738
+		);
1739
+		/** SCRIPTS **/
1740
+		// register all scripts
1741
+		wp_register_script(
1742
+			'ee-dialog',
1743
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1744
+			['jquery', 'jquery-ui-draggable'],
1745
+			EVENT_ESPRESSO_VERSION,
1746
+			true
1747
+		);
1748
+		wp_register_script(
1749
+			'ee_admin_js',
1750
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1751
+			['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1752
+			EVENT_ESPRESSO_VERSION,
1753
+			true
1754
+		);
1755
+		wp_register_script(
1756
+			'jquery-ui-timepicker-addon',
1757
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1758
+			['jquery-ui-datepicker', 'jquery-ui-slider'],
1759
+			EVENT_ESPRESSO_VERSION,
1760
+			true
1761
+		);
1762
+		// script for sorting tables
1763
+		wp_register_script(
1764
+			'espresso_ajax_table_sorting',
1765
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1766
+			['ee_admin_js', 'jquery-ui-sortable'],
1767
+			EVENT_ESPRESSO_VERSION,
1768
+			true
1769
+		);
1770
+		// script for parsing uri's
1771
+		wp_register_script(
1772
+			'ee-parse-uri',
1773
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1774
+			[],
1775
+			EVENT_ESPRESSO_VERSION,
1776
+			true
1777
+		);
1778
+		// and parsing associative serialized form elements
1779
+		wp_register_script(
1780
+			'ee-serialize-full-array',
1781
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1782
+			['jquery'],
1783
+			EVENT_ESPRESSO_VERSION,
1784
+			true
1785
+		);
1786
+		// helpers scripts
1787
+		wp_register_script(
1788
+			'ee-text-links',
1789
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1790
+			['jquery'],
1791
+			EVENT_ESPRESSO_VERSION,
1792
+			true
1793
+		);
1794
+		wp_register_script(
1795
+			'ee-moment-core',
1796
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1797
+			[],
1798
+			EVENT_ESPRESSO_VERSION,
1799
+			true
1800
+		);
1801
+		wp_register_script(
1802
+			'ee-moment',
1803
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1804
+			['ee-moment-core'],
1805
+			EVENT_ESPRESSO_VERSION,
1806
+			true
1807
+		);
1808
+		wp_register_script(
1809
+			'ee-datepicker',
1810
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1811
+			['jquery-ui-timepicker-addon', 'ee-moment'],
1812
+			EVENT_ESPRESSO_VERSION,
1813
+			true
1814
+		);
1815
+		// google charts
1816
+		wp_register_script(
1817
+			'google-charts',
1818
+			'https://www.gstatic.com/charts/loader.js',
1819
+			[],
1820
+			EVENT_ESPRESSO_VERSION
1821
+		);
1822
+		// ENQUEUE ALL BASICS BY DEFAULT
1823
+		wp_enqueue_style('ee-admin-css');
1824
+		wp_enqueue_script('ee_admin_js');
1825
+		wp_enqueue_script('ee-accounting');
1826
+		wp_enqueue_script('jquery-validate');
1827
+		// taking care of metaboxes
1828
+		if (
1829
+			empty($this->_cpt_route)
1830
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1831
+		) {
1832
+			wp_enqueue_script('dashboard');
1833
+		}
1834
+		// LOCALIZED DATA
1835
+		// localize script for ajax lazy loading
1836
+		$lazy_loader_container_ids = apply_filters(
1837
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1838
+			['espresso_news_post_box_content']
1839
+		);
1840
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1841
+		add_filter(
1842
+			'admin_body_class',
1843
+			function ($classes) {
1844
+				if (strpos($classes, 'espresso-admin') === false) {
1845
+					$classes .= ' espresso-admin';
1846
+				}
1847
+				return $classes;
1848
+			}
1849
+		);
1850
+	}
1851
+
1852
+
1853
+	/**
1854
+	 *        admin_footer_scripts_eei18n_js_strings
1855
+	 *
1856
+	 * @return        void
1857
+	 */
1858
+	public function admin_footer_scripts_eei18n_js_strings()
1859
+	{
1860
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1861
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1862
+			__(
1863
+				'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!!!',
1864
+				'event_espresso'
1865
+			)
1866
+		);
1867
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1868
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1869
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1870
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1871
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1872
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1873
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1874
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1875
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1876
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1877
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1878
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1879
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1880
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1881
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1882
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1883
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1884
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1885
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1886
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1887
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1888
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1889
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1890
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1891
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1892
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1893
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1894
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1895
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1896
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1897
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1898
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1899
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1900
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1901
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1902
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1903
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1904
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1905
+	}
1906
+
1907
+
1908
+	/**
1909
+	 *        load enhanced xdebug styles for ppl with failing eyesight
1910
+	 *
1911
+	 * @return        void
1912
+	 */
1913
+	public function add_xdebug_style()
1914
+	{
1915
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1916
+	}
1917
+
1918
+
1919
+	/************************/
1920
+	/** LIST TABLE METHODS **/
1921
+	/************************/
1922
+	/**
1923
+	 * this sets up the list table if the current view requires it.
1924
+	 *
1925
+	 * @return void
1926
+	 * @throws EE_Error
1927
+	 */
1928
+	protected function _set_list_table()
1929
+	{
1930
+		// first is this a list_table view?
1931
+		if (! isset($this->_route_config['list_table'])) {
1932
+			return;
1933
+		} //not a list_table view so get out.
1934
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
1935
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
1936
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1937
+			// user error msg
1938
+			$error_msg = esc_html__(
1939
+				'An error occurred. The requested list table views could not be found.',
1940
+				'event_espresso'
1941
+			);
1942
+			// developer error msg
1943
+			$error_msg .= '||'
1944
+						  . sprintf(
1945
+							  esc_html__(
1946
+								  '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.',
1947
+								  'event_espresso'
1948
+							  ),
1949
+							  $this->_req_action,
1950
+							  $list_table_view
1951
+						  );
1952
+			throw new EE_Error($error_msg);
1953
+		}
1954
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1955
+		$this->_views = apply_filters(
1956
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1957
+			$this->_views
1958
+		);
1959
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1960
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1961
+		$this->_set_list_table_view();
1962
+		$this->_set_list_table_object();
1963
+	}
1964
+
1965
+
1966
+	/**
1967
+	 * set current view for List Table
1968
+	 *
1969
+	 * @return void
1970
+	 */
1971
+	protected function _set_list_table_view()
1972
+	{
1973
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1974
+		$status = $this->request->getRequestParam('status', null, 'key');
1975
+		$this->_view = $status && array_key_exists($status, $this->_views)
1976
+			? $status
1977
+			: $this->_view;
1978
+	}
1979
+
1980
+
1981
+	/**
1982
+	 * _set_list_table_object
1983
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1984
+	 *
1985
+	 * @throws InvalidInterfaceException
1986
+	 * @throws InvalidArgumentException
1987
+	 * @throws InvalidDataTypeException
1988
+	 * @throws EE_Error
1989
+	 * @throws InvalidInterfaceException
1990
+	 */
1991
+	protected function _set_list_table_object()
1992
+	{
1993
+		if (isset($this->_route_config['list_table'])) {
1994
+			if (! class_exists($this->_route_config['list_table'])) {
1995
+				throw new EE_Error(
1996
+					sprintf(
1997
+						esc_html__(
1998
+							'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.',
1999
+							'event_espresso'
2000
+						),
2001
+						$this->_route_config['list_table'],
2002
+						get_class($this)
2003
+					)
2004
+				);
2005
+			}
2006
+			$this->_list_table_object = $this->loader->getShared(
2007
+				$this->_route_config['list_table'],
2008
+				[$this]
2009
+			);
2010
+		}
2011
+	}
2012
+
2013
+
2014
+	/**
2015
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2016
+	 *
2017
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2018
+	 *                                                    urls.  The array should be indexed by the view it is being
2019
+	 *                                                    added to.
2020
+	 * @return array
2021
+	 */
2022
+	public function get_list_table_view_RLs($extra_query_args = [])
2023
+	{
2024
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2025
+		if (empty($this->_views)) {
2026
+			$this->_views = [];
2027
+		}
2028
+		// cycle thru views
2029
+		foreach ($this->_views as $key => $view) {
2030
+			$query_args = [];
2031
+			// check for current view
2032
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2033
+			$query_args['action']                        = $this->_req_action;
2034
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2035
+			$query_args['status']                        = $view['slug'];
2036
+			// merge any other arguments sent in.
2037
+			if (isset($extra_query_args[ $view['slug'] ])) {
2038
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2039
+			}
2040
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2041
+		}
2042
+		return $this->_views;
2043
+	}
2044
+
2045
+
2046
+	/**
2047
+	 * _entries_per_page_dropdown
2048
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2049
+	 *
2050
+	 * @param int $max_entries total number of rows in the table
2051
+	 * @return string
2052
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2053
+	 *         WP does it.
2054
+	 */
2055
+	protected function _entries_per_page_dropdown($max_entries = 0)
2056
+	{
2057
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2058
+		$values   = [10, 25, 50, 100];
2059
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2060
+		if ($max_entries) {
2061
+			$values[] = $max_entries;
2062
+			sort($values);
2063
+		}
2064
+		$entries_per_page_dropdown = '
2065 2065
 			<div id="entries-per-page-dv" class="alignleft actions">
2066 2066
 				<label class="hide-if-no-js">
2067 2067
 					Show
2068 2068
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2069
-        foreach ($values as $value) {
2070
-            if ($value < $max_entries) {
2071
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2072
-                $entries_per_page_dropdown .= '
2069
+		foreach ($values as $value) {
2070
+			if ($value < $max_entries) {
2071
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2072
+				$entries_per_page_dropdown .= '
2073 2073
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2074
-            }
2075
-        }
2076
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2077
-        $entries_per_page_dropdown .= '
2074
+			}
2075
+		}
2076
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2077
+		$entries_per_page_dropdown .= '
2078 2078
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2079
-        $entries_per_page_dropdown .= '
2079
+		$entries_per_page_dropdown .= '
2080 2080
 					</select>
2081 2081
 					entries
2082 2082
 				</label>
2083 2083
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2084 2084
 			</div>
2085 2085
 		';
2086
-        return $entries_per_page_dropdown;
2087
-    }
2088
-
2089
-
2090
-    /**
2091
-     *        _set_search_attributes
2092
-     *
2093
-     * @return        void
2094
-     */
2095
-    public function _set_search_attributes()
2096
-    {
2097
-        $this->_template_args['search']['btn_label'] = sprintf(
2098
-            esc_html__('Search %s', 'event_espresso'),
2099
-            empty($this->_search_btn_label) ? $this->page_label
2100
-                : $this->_search_btn_label
2101
-        );
2102
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2103
-    }
2104
-
2105
-
2106
-
2107
-    /*** END LIST TABLE METHODS **/
2108
-
2109
-
2110
-    /**
2111
-     * _add_registered_metaboxes
2112
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2113
-     *
2114
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2115
-     * @return void
2116
-     * @throws EE_Error
2117
-     */
2118
-    private function _add_registered_meta_boxes()
2119
-    {
2120
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2121
-        // we only add meta boxes if the page_route calls for it
2122
-        if (
2123
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2124
-            && is_array(
2125
-                $this->_route_config['metaboxes']
2126
-            )
2127
-        ) {
2128
-            // this simply loops through the callbacks provided
2129
-            // and checks if there is a corresponding callback registered by the child
2130
-            // if there is then we go ahead and process the metabox loader.
2131
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2132
-                // first check for Closures
2133
-                if ($metabox_callback instanceof Closure) {
2134
-                    $result = $metabox_callback();
2135
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2136
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2137
-                } else {
2138
-                    $result = call_user_func([$this, &$metabox_callback]);
2139
-                }
2140
-                if ($result === false) {
2141
-                    // user error msg
2142
-                    $error_msg = esc_html__(
2143
-                        'An error occurred. The  requested metabox could not be found.',
2144
-                        'event_espresso'
2145
-                    );
2146
-                    // developer error msg
2147
-                    $error_msg .= '||'
2148
-                                  . sprintf(
2149
-                                      esc_html__(
2150
-                                          '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.',
2151
-                                          'event_espresso'
2152
-                                      ),
2153
-                                      $metabox_callback
2154
-                                  );
2155
-                    throw new EE_Error($error_msg);
2156
-                }
2157
-            }
2158
-        }
2159
-    }
2160
-
2161
-
2162
-    /**
2163
-     * _add_screen_columns
2164
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2165
-     * the dynamic column template and we'll setup the column options for the page.
2166
-     *
2167
-     * @return void
2168
-     */
2169
-    private function _add_screen_columns()
2170
-    {
2171
-        if (
2172
-            is_array($this->_route_config)
2173
-            && isset($this->_route_config['columns'])
2174
-            && is_array($this->_route_config['columns'])
2175
-            && count($this->_route_config['columns']) === 2
2176
-        ) {
2177
-            add_screen_option(
2178
-                'layout_columns',
2179
-                [
2180
-                    'max'     => (int) $this->_route_config['columns'][0],
2181
-                    'default' => (int) $this->_route_config['columns'][1],
2182
-                ]
2183
-            );
2184
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2185
-            $screen_id                                           = $this->_current_screen->id;
2186
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2187
-            $total_columns                                       = ! empty($screen_columns)
2188
-                ? $screen_columns
2189
-                : $this->_route_config['columns'][1];
2190
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2191
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2192
-            $this->_template_args['screen']                      = $this->_current_screen;
2193
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2194
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2195
-            // finally if we don't have has_metaboxes set in the route config
2196
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2197
-            $this->_route_config['has_metaboxes'] = true;
2198
-        }
2199
-    }
2200
-
2201
-
2202
-
2203
-    /** GLOBALLY AVAILABLE METABOXES **/
2204
-
2205
-
2206
-    /**
2207
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2208
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2209
-     * these get loaded on.
2210
-     */
2211
-    private function _espresso_news_post_box()
2212
-    {
2213
-        $news_box_title = apply_filters(
2214
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2215
-            esc_html__('New @ Event Espresso', 'event_espresso')
2216
-        );
2217
-        add_meta_box(
2218
-            'espresso_news_post_box',
2219
-            $news_box_title,
2220
-            [
2221
-                $this,
2222
-                'espresso_news_post_box',
2223
-            ],
2224
-            $this->_wp_page_slug,
2225
-            'side'
2226
-        );
2227
-    }
2228
-
2229
-
2230
-    /**
2231
-     * Code for setting up espresso ratings request metabox.
2232
-     */
2233
-    protected function _espresso_ratings_request()
2234
-    {
2235
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2236
-            return;
2237
-        }
2238
-        $ratings_box_title = apply_filters(
2239
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2240
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2241
-        );
2242
-        add_meta_box(
2243
-            'espresso_ratings_request',
2244
-            $ratings_box_title,
2245
-            [
2246
-                $this,
2247
-                'espresso_ratings_request',
2248
-            ],
2249
-            $this->_wp_page_slug,
2250
-            'side'
2251
-        );
2252
-    }
2253
-
2254
-
2255
-    /**
2256
-     * Code for setting up espresso ratings request metabox content.
2257
-     *
2258
-     * @throws DomainException
2259
-     */
2260
-    public function espresso_ratings_request()
2261
-    {
2262
-        EEH_Template::display_template(
2263
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2264
-            []
2265
-        );
2266
-    }
2267
-
2268
-
2269
-    public static function cached_rss_display($rss_id, $url)
2270
-    {
2271
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2272
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2273
-                     . '</p><p class="hide-if-js">'
2274
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2275
-                     . '</p>';
2276
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2277
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2278
-        $post      = '</div>' . "\n";
2279
-        $cache_key = 'ee_rss_' . md5($rss_id);
2280
-        $output    = get_transient($cache_key);
2281
-        if ($output !== false) {
2282
-            echo $pre . $output . $post; // already escaped
2283
-            return true;
2284
-        }
2285
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2286
-            echo $pre . $loading . $post; // already escaped
2287
-            return false;
2288
-        }
2289
-        ob_start();
2290
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2291
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2292
-        return true;
2293
-    }
2294
-
2295
-
2296
-    public function espresso_news_post_box()
2297
-    {
2298
-        ?>
2086
+		return $entries_per_page_dropdown;
2087
+	}
2088
+
2089
+
2090
+	/**
2091
+	 *        _set_search_attributes
2092
+	 *
2093
+	 * @return        void
2094
+	 */
2095
+	public function _set_search_attributes()
2096
+	{
2097
+		$this->_template_args['search']['btn_label'] = sprintf(
2098
+			esc_html__('Search %s', 'event_espresso'),
2099
+			empty($this->_search_btn_label) ? $this->page_label
2100
+				: $this->_search_btn_label
2101
+		);
2102
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2103
+	}
2104
+
2105
+
2106
+
2107
+	/*** END LIST TABLE METHODS **/
2108
+
2109
+
2110
+	/**
2111
+	 * _add_registered_metaboxes
2112
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2113
+	 *
2114
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2115
+	 * @return void
2116
+	 * @throws EE_Error
2117
+	 */
2118
+	private function _add_registered_meta_boxes()
2119
+	{
2120
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2121
+		// we only add meta boxes if the page_route calls for it
2122
+		if (
2123
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2124
+			&& is_array(
2125
+				$this->_route_config['metaboxes']
2126
+			)
2127
+		) {
2128
+			// this simply loops through the callbacks provided
2129
+			// and checks if there is a corresponding callback registered by the child
2130
+			// if there is then we go ahead and process the metabox loader.
2131
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2132
+				// first check for Closures
2133
+				if ($metabox_callback instanceof Closure) {
2134
+					$result = $metabox_callback();
2135
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2136
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2137
+				} else {
2138
+					$result = call_user_func([$this, &$metabox_callback]);
2139
+				}
2140
+				if ($result === false) {
2141
+					// user error msg
2142
+					$error_msg = esc_html__(
2143
+						'An error occurred. The  requested metabox could not be found.',
2144
+						'event_espresso'
2145
+					);
2146
+					// developer error msg
2147
+					$error_msg .= '||'
2148
+								  . sprintf(
2149
+									  esc_html__(
2150
+										  '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.',
2151
+										  'event_espresso'
2152
+									  ),
2153
+									  $metabox_callback
2154
+								  );
2155
+					throw new EE_Error($error_msg);
2156
+				}
2157
+			}
2158
+		}
2159
+	}
2160
+
2161
+
2162
+	/**
2163
+	 * _add_screen_columns
2164
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2165
+	 * the dynamic column template and we'll setup the column options for the page.
2166
+	 *
2167
+	 * @return void
2168
+	 */
2169
+	private function _add_screen_columns()
2170
+	{
2171
+		if (
2172
+			is_array($this->_route_config)
2173
+			&& isset($this->_route_config['columns'])
2174
+			&& is_array($this->_route_config['columns'])
2175
+			&& count($this->_route_config['columns']) === 2
2176
+		) {
2177
+			add_screen_option(
2178
+				'layout_columns',
2179
+				[
2180
+					'max'     => (int) $this->_route_config['columns'][0],
2181
+					'default' => (int) $this->_route_config['columns'][1],
2182
+				]
2183
+			);
2184
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2185
+			$screen_id                                           = $this->_current_screen->id;
2186
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2187
+			$total_columns                                       = ! empty($screen_columns)
2188
+				? $screen_columns
2189
+				: $this->_route_config['columns'][1];
2190
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2191
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2192
+			$this->_template_args['screen']                      = $this->_current_screen;
2193
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2194
+																   . 'admin_details_metabox_column_wrapper.template.php';
2195
+			// finally if we don't have has_metaboxes set in the route config
2196
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2197
+			$this->_route_config['has_metaboxes'] = true;
2198
+		}
2199
+	}
2200
+
2201
+
2202
+
2203
+	/** GLOBALLY AVAILABLE METABOXES **/
2204
+
2205
+
2206
+	/**
2207
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2208
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2209
+	 * these get loaded on.
2210
+	 */
2211
+	private function _espresso_news_post_box()
2212
+	{
2213
+		$news_box_title = apply_filters(
2214
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2215
+			esc_html__('New @ Event Espresso', 'event_espresso')
2216
+		);
2217
+		add_meta_box(
2218
+			'espresso_news_post_box',
2219
+			$news_box_title,
2220
+			[
2221
+				$this,
2222
+				'espresso_news_post_box',
2223
+			],
2224
+			$this->_wp_page_slug,
2225
+			'side'
2226
+		);
2227
+	}
2228
+
2229
+
2230
+	/**
2231
+	 * Code for setting up espresso ratings request metabox.
2232
+	 */
2233
+	protected function _espresso_ratings_request()
2234
+	{
2235
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2236
+			return;
2237
+		}
2238
+		$ratings_box_title = apply_filters(
2239
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2240
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2241
+		);
2242
+		add_meta_box(
2243
+			'espresso_ratings_request',
2244
+			$ratings_box_title,
2245
+			[
2246
+				$this,
2247
+				'espresso_ratings_request',
2248
+			],
2249
+			$this->_wp_page_slug,
2250
+			'side'
2251
+		);
2252
+	}
2253
+
2254
+
2255
+	/**
2256
+	 * Code for setting up espresso ratings request metabox content.
2257
+	 *
2258
+	 * @throws DomainException
2259
+	 */
2260
+	public function espresso_ratings_request()
2261
+	{
2262
+		EEH_Template::display_template(
2263
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2264
+			[]
2265
+		);
2266
+	}
2267
+
2268
+
2269
+	public static function cached_rss_display($rss_id, $url)
2270
+	{
2271
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2272
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2273
+					 . '</p><p class="hide-if-js">'
2274
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2275
+					 . '</p>';
2276
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2277
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2278
+		$post      = '</div>' . "\n";
2279
+		$cache_key = 'ee_rss_' . md5($rss_id);
2280
+		$output    = get_transient($cache_key);
2281
+		if ($output !== false) {
2282
+			echo $pre . $output . $post; // already escaped
2283
+			return true;
2284
+		}
2285
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2286
+			echo $pre . $loading . $post; // already escaped
2287
+			return false;
2288
+		}
2289
+		ob_start();
2290
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2291
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2292
+		return true;
2293
+	}
2294
+
2295
+
2296
+	public function espresso_news_post_box()
2297
+	{
2298
+		?>
2299 2299
         <div class="padding">
2300 2300
             <div id="espresso_news_post_box_content" class="infolinks">
2301 2301
                 <?php
2302
-                // Get RSS Feed(s)
2303
-                self::cached_rss_display(
2304
-                    'espresso_news_post_box_content',
2305
-                    esc_url_raw(
2306
-                        apply_filters(
2307
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2308
-                            'https://eventespresso.com/feed/'
2309
-                        )
2310
-                    )
2311
-                );
2312
-                ?>
2302
+				// Get RSS Feed(s)
2303
+				self::cached_rss_display(
2304
+					'espresso_news_post_box_content',
2305
+					esc_url_raw(
2306
+						apply_filters(
2307
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2308
+							'https://eventespresso.com/feed/'
2309
+						)
2310
+					)
2311
+				);
2312
+				?>
2313 2313
             </div>
2314 2314
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2315 2315
         </div>
2316 2316
         <?php
2317
-    }
2318
-
2319
-
2320
-    private function _espresso_links_post_box()
2321
-    {
2322
-        // Hiding until we actually have content to put in here...
2323
-        // 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');
2324
-    }
2325
-
2326
-
2327
-    public function espresso_links_post_box()
2328
-    {
2329
-        // Hiding until we actually have content to put in here...
2330
-        // EEH_Template::display_template(
2331
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2332
-        // );
2333
-    }
2334
-
2335
-
2336
-    protected function _espresso_sponsors_post_box()
2337
-    {
2338
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2339
-            add_meta_box(
2340
-                'espresso_sponsors_post_box',
2341
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2342
-                [$this, 'espresso_sponsors_post_box'],
2343
-                $this->_wp_page_slug,
2344
-                'side'
2345
-            );
2346
-        }
2347
-    }
2348
-
2349
-
2350
-    public function espresso_sponsors_post_box()
2351
-    {
2352
-        EEH_Template::display_template(
2353
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2354
-        );
2355
-    }
2356
-
2357
-
2358
-    private function _publish_post_box()
2359
-    {
2360
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2361
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2362
-        // then we'll use that for the metabox label.
2363
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2364
-        if (! empty($this->_labels['publishbox'])) {
2365
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2366
-                : $this->_labels['publishbox'];
2367
-        } else {
2368
-            $box_label = esc_html__('Publish', 'event_espresso');
2369
-        }
2370
-        $box_label = apply_filters(
2371
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2372
-            $box_label,
2373
-            $this->_req_action,
2374
-            $this
2375
-        );
2376
-        add_meta_box(
2377
-            $meta_box_ref,
2378
-            $box_label,
2379
-            [$this, 'editor_overview'],
2380
-            $this->_current_screen->id,
2381
-            'side',
2382
-            'high'
2383
-        );
2384
-    }
2385
-
2386
-
2387
-    public function editor_overview()
2388
-    {
2389
-        // if we have extra content set let's add it in if not make sure its empty
2390
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2391
-            ? $this->_template_args['publish_box_extra_content']
2392
-            : '';
2393
-        echo EEH_Template::display_template(
2394
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2395
-            $this->_template_args,
2396
-            true
2397
-        );
2398
-    }
2399
-
2400
-
2401
-    /** end of globally available metaboxes section **/
2402
-
2403
-
2404
-    /**
2405
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2406
-     * protected method.
2407
-     *
2408
-     * @param string $name
2409
-     * @param int    $id
2410
-     * @param bool   $delete
2411
-     * @param string $save_close_redirect_URL
2412
-     * @param bool   $both_btns
2413
-     * @throws EE_Error
2414
-     * @throws InvalidArgumentException
2415
-     * @throws InvalidDataTypeException
2416
-     * @throws InvalidInterfaceException
2417
-     * @see   $this->_set_publish_post_box_vars for param details
2418
-     * @since 4.6.0
2419
-     */
2420
-    public function set_publish_post_box_vars(
2421
-        $name = '',
2422
-        $id = 0,
2423
-        $delete = false,
2424
-        $save_close_redirect_URL = '',
2425
-        $both_btns = true
2426
-    ) {
2427
-        $this->_set_publish_post_box_vars(
2428
-            $name,
2429
-            $id,
2430
-            $delete,
2431
-            $save_close_redirect_URL,
2432
-            $both_btns
2433
-        );
2434
-    }
2435
-
2436
-
2437
-    /**
2438
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2439
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2440
-     * save, and save and close buttons to work properly, then you will want to include a
2441
-     * values for the name and id arguments.
2442
-     *
2443
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2444
-     * @param int     $id                         id attached to the item published
2445
-     * @param string  $delete                     page route callback for the delete action
2446
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2447
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2448
-     *                                            the Save button
2449
-     * @throws EE_Error
2450
-     * @throws InvalidArgumentException
2451
-     * @throws InvalidDataTypeException
2452
-     * @throws InvalidInterfaceException
2453
-     * @todo  Add in validation for name/id arguments.
2454
-     */
2455
-    protected function _set_publish_post_box_vars(
2456
-        $name = '',
2457
-        $id = 0,
2458
-        $delete = '',
2459
-        $save_close_redirect_URL = '',
2460
-        $both_btns = true
2461
-    ) {
2462
-        // if Save & Close, use a custom redirect URL or default to the main page?
2463
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2464
-            ? $save_close_redirect_URL
2465
-            : $this->_admin_base_url;
2466
-        // create the Save & Close and Save buttons
2467
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2468
-        // if we have extra content set let's add it in if not make sure its empty
2469
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2470
-            ? $this->_template_args['publish_box_extra_content']
2471
-            : '';
2472
-        if ($delete && ! empty($id)) {
2473
-            // make sure we have a default if just true is sent.
2474
-            $delete           = ! empty($delete) ? $delete : 'delete';
2475
-            $delete_link_args = [$name => $id];
2476
-            $delete           = $this->get_action_link_or_button(
2477
-                $delete,
2478
-                $delete,
2479
-                $delete_link_args,
2480
-                'submitdelete deletion',
2481
-                '',
2482
-                false
2483
-            );
2484
-        }
2485
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2486
-        if (! empty($name) && ! empty($id)) {
2487
-            $hidden_field_arr[ $name ] = [
2488
-                'type'  => 'hidden',
2489
-                'value' => $id,
2490
-            ];
2491
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2492
-        } else {
2493
-            $hf = '';
2494
-        }
2495
-        // add hidden field
2496
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2497
-            ? $hf[ $name ]['field']
2498
-            : $hf;
2499
-    }
2500
-
2501
-
2502
-    /**
2503
-     * displays an error message to ppl who have javascript disabled
2504
-     *
2505
-     * @return void
2506
-     */
2507
-    private function _display_no_javascript_warning()
2508
-    {
2509
-        ?>
2317
+	}
2318
+
2319
+
2320
+	private function _espresso_links_post_box()
2321
+	{
2322
+		// Hiding until we actually have content to put in here...
2323
+		// 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');
2324
+	}
2325
+
2326
+
2327
+	public function espresso_links_post_box()
2328
+	{
2329
+		// Hiding until we actually have content to put in here...
2330
+		// EEH_Template::display_template(
2331
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2332
+		// );
2333
+	}
2334
+
2335
+
2336
+	protected function _espresso_sponsors_post_box()
2337
+	{
2338
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2339
+			add_meta_box(
2340
+				'espresso_sponsors_post_box',
2341
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2342
+				[$this, 'espresso_sponsors_post_box'],
2343
+				$this->_wp_page_slug,
2344
+				'side'
2345
+			);
2346
+		}
2347
+	}
2348
+
2349
+
2350
+	public function espresso_sponsors_post_box()
2351
+	{
2352
+		EEH_Template::display_template(
2353
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2354
+		);
2355
+	}
2356
+
2357
+
2358
+	private function _publish_post_box()
2359
+	{
2360
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2361
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2362
+		// then we'll use that for the metabox label.
2363
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2364
+		if (! empty($this->_labels['publishbox'])) {
2365
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2366
+				: $this->_labels['publishbox'];
2367
+		} else {
2368
+			$box_label = esc_html__('Publish', 'event_espresso');
2369
+		}
2370
+		$box_label = apply_filters(
2371
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2372
+			$box_label,
2373
+			$this->_req_action,
2374
+			$this
2375
+		);
2376
+		add_meta_box(
2377
+			$meta_box_ref,
2378
+			$box_label,
2379
+			[$this, 'editor_overview'],
2380
+			$this->_current_screen->id,
2381
+			'side',
2382
+			'high'
2383
+		);
2384
+	}
2385
+
2386
+
2387
+	public function editor_overview()
2388
+	{
2389
+		// if we have extra content set let's add it in if not make sure its empty
2390
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2391
+			? $this->_template_args['publish_box_extra_content']
2392
+			: '';
2393
+		echo EEH_Template::display_template(
2394
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2395
+			$this->_template_args,
2396
+			true
2397
+		);
2398
+	}
2399
+
2400
+
2401
+	/** end of globally available metaboxes section **/
2402
+
2403
+
2404
+	/**
2405
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2406
+	 * protected method.
2407
+	 *
2408
+	 * @param string $name
2409
+	 * @param int    $id
2410
+	 * @param bool   $delete
2411
+	 * @param string $save_close_redirect_URL
2412
+	 * @param bool   $both_btns
2413
+	 * @throws EE_Error
2414
+	 * @throws InvalidArgumentException
2415
+	 * @throws InvalidDataTypeException
2416
+	 * @throws InvalidInterfaceException
2417
+	 * @see   $this->_set_publish_post_box_vars for param details
2418
+	 * @since 4.6.0
2419
+	 */
2420
+	public function set_publish_post_box_vars(
2421
+		$name = '',
2422
+		$id = 0,
2423
+		$delete = false,
2424
+		$save_close_redirect_URL = '',
2425
+		$both_btns = true
2426
+	) {
2427
+		$this->_set_publish_post_box_vars(
2428
+			$name,
2429
+			$id,
2430
+			$delete,
2431
+			$save_close_redirect_URL,
2432
+			$both_btns
2433
+		);
2434
+	}
2435
+
2436
+
2437
+	/**
2438
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2439
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2440
+	 * save, and save and close buttons to work properly, then you will want to include a
2441
+	 * values for the name and id arguments.
2442
+	 *
2443
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2444
+	 * @param int     $id                         id attached to the item published
2445
+	 * @param string  $delete                     page route callback for the delete action
2446
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2447
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2448
+	 *                                            the Save button
2449
+	 * @throws EE_Error
2450
+	 * @throws InvalidArgumentException
2451
+	 * @throws InvalidDataTypeException
2452
+	 * @throws InvalidInterfaceException
2453
+	 * @todo  Add in validation for name/id arguments.
2454
+	 */
2455
+	protected function _set_publish_post_box_vars(
2456
+		$name = '',
2457
+		$id = 0,
2458
+		$delete = '',
2459
+		$save_close_redirect_URL = '',
2460
+		$both_btns = true
2461
+	) {
2462
+		// if Save & Close, use a custom redirect URL or default to the main page?
2463
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2464
+			? $save_close_redirect_URL
2465
+			: $this->_admin_base_url;
2466
+		// create the Save & Close and Save buttons
2467
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2468
+		// if we have extra content set let's add it in if not make sure its empty
2469
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2470
+			? $this->_template_args['publish_box_extra_content']
2471
+			: '';
2472
+		if ($delete && ! empty($id)) {
2473
+			// make sure we have a default if just true is sent.
2474
+			$delete           = ! empty($delete) ? $delete : 'delete';
2475
+			$delete_link_args = [$name => $id];
2476
+			$delete           = $this->get_action_link_or_button(
2477
+				$delete,
2478
+				$delete,
2479
+				$delete_link_args,
2480
+				'submitdelete deletion',
2481
+				'',
2482
+				false
2483
+			);
2484
+		}
2485
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2486
+		if (! empty($name) && ! empty($id)) {
2487
+			$hidden_field_arr[ $name ] = [
2488
+				'type'  => 'hidden',
2489
+				'value' => $id,
2490
+			];
2491
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2492
+		} else {
2493
+			$hf = '';
2494
+		}
2495
+		// add hidden field
2496
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2497
+			? $hf[ $name ]['field']
2498
+			: $hf;
2499
+	}
2500
+
2501
+
2502
+	/**
2503
+	 * displays an error message to ppl who have javascript disabled
2504
+	 *
2505
+	 * @return void
2506
+	 */
2507
+	private function _display_no_javascript_warning()
2508
+	{
2509
+		?>
2510 2510
         <noscript>
2511 2511
             <div id="no-js-message" class="error">
2512 2512
                 <p style="font-size:1.3em;">
2513 2513
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2514 2514
                     <?php esc_html_e(
2515
-                        '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.',
2516
-                        'event_espresso'
2517
-                    ); ?>
2515
+						'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.',
2516
+						'event_espresso'
2517
+					); ?>
2518 2518
                 </p>
2519 2519
             </div>
2520 2520
         </noscript>
2521 2521
         <?php
2522
-    }
2523
-
2524
-
2525
-    /**
2526
-     * displays espresso success and/or error notices
2527
-     *
2528
-     * @return void
2529
-     */
2530
-    protected function _display_espresso_notices()
2531
-    {
2532
-        $notices = $this->_get_transient(true);
2533
-        echo stripslashes($notices);
2534
-    }
2535
-
2536
-
2537
-    /**
2538
-     * spinny things pacify the masses
2539
-     *
2540
-     * @return void
2541
-     */
2542
-    protected function _add_admin_page_ajax_loading_img()
2543
-    {
2544
-        ?>
2522
+	}
2523
+
2524
+
2525
+	/**
2526
+	 * displays espresso success and/or error notices
2527
+	 *
2528
+	 * @return void
2529
+	 */
2530
+	protected function _display_espresso_notices()
2531
+	{
2532
+		$notices = $this->_get_transient(true);
2533
+		echo stripslashes($notices);
2534
+	}
2535
+
2536
+
2537
+	/**
2538
+	 * spinny things pacify the masses
2539
+	 *
2540
+	 * @return void
2541
+	 */
2542
+	protected function _add_admin_page_ajax_loading_img()
2543
+	{
2544
+		?>
2545 2545
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2546 2546
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2547
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2547
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2548 2548
         </div>
2549 2549
         <?php
2550
-    }
2550
+	}
2551 2551
 
2552 2552
 
2553
-    /**
2554
-     * add admin page overlay for modal boxes
2555
-     *
2556
-     * @return void
2557
-     */
2558
-    protected function _add_admin_page_overlay()
2559
-    {
2560
-        ?>
2553
+	/**
2554
+	 * add admin page overlay for modal boxes
2555
+	 *
2556
+	 * @return void
2557
+	 */
2558
+	protected function _add_admin_page_overlay()
2559
+	{
2560
+		?>
2561 2561
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2562 2562
         <?php
2563
-    }
2564
-
2565
-
2566
-    /**
2567
-     * facade for add_meta_box
2568
-     *
2569
-     * @param string  $action        where the metabox gets displayed
2570
-     * @param string  $title         Title of Metabox (output in metabox header)
2571
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2572
-     *                               instead of the one created in here.
2573
-     * @param array   $callback_args an array of args supplied for the metabox
2574
-     * @param string  $column        what metabox column
2575
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2576
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2577
-     *                               created but just set our own callback for wp's add_meta_box.
2578
-     * @throws DomainException
2579
-     */
2580
-    public function _add_admin_page_meta_box(
2581
-        $action,
2582
-        $title,
2583
-        $callback,
2584
-        $callback_args,
2585
-        $column = 'normal',
2586
-        $priority = 'high',
2587
-        $create_func = true
2588
-    ) {
2589
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2590
-        // 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.
2591
-        if (empty($callback_args) && $create_func) {
2592
-            $callback_args = [
2593
-                'template_path' => $this->_template_path,
2594
-                'template_args' => $this->_template_args,
2595
-            ];
2596
-        }
2597
-        // 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)
2598
-        $call_back_func = $create_func
2599
-            ? function ($post, $metabox) {
2600
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2601
-                echo EEH_Template::display_template(
2602
-                    $metabox['args']['template_path'],
2603
-                    $metabox['args']['template_args'],
2604
-                    true
2605
-                );
2606
-            }
2607
-            : $callback;
2608
-        add_meta_box(
2609
-            str_replace('_', '-', $action) . '-mbox',
2610
-            $title,
2611
-            $call_back_func,
2612
-            $this->_wp_page_slug,
2613
-            $column,
2614
-            $priority,
2615
-            $callback_args
2616
-        );
2617
-    }
2618
-
2619
-
2620
-    /**
2621
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2622
-     *
2623
-     * @throws DomainException
2624
-     * @throws EE_Error
2625
-     */
2626
-    public function display_admin_page_with_metabox_columns()
2627
-    {
2628
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2629
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2630
-            $this->_column_template_path,
2631
-            $this->_template_args,
2632
-            true
2633
-        );
2634
-        // the final wrapper
2635
-        $this->admin_page_wrapper();
2636
-    }
2637
-
2638
-
2639
-    /**
2640
-     * generates  HTML wrapper for an admin details page
2641
-     *
2642
-     * @return void
2643
-     * @throws EE_Error
2644
-     * @throws DomainException
2645
-     */
2646
-    public function display_admin_page_with_sidebar()
2647
-    {
2648
-        $this->_display_admin_page(true);
2649
-    }
2650
-
2651
-
2652
-    /**
2653
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2654
-     *
2655
-     * @return void
2656
-     * @throws EE_Error
2657
-     * @throws DomainException
2658
-     */
2659
-    public function display_admin_page_with_no_sidebar()
2660
-    {
2661
-        $this->_display_admin_page();
2662
-    }
2663
-
2664
-
2665
-    /**
2666
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2667
-     *
2668
-     * @return void
2669
-     * @throws EE_Error
2670
-     * @throws DomainException
2671
-     */
2672
-    public function display_about_admin_page()
2673
-    {
2674
-        $this->_display_admin_page(false, true);
2675
-    }
2676
-
2677
-
2678
-    /**
2679
-     * display_admin_page
2680
-     * contains the code for actually displaying an admin page
2681
-     *
2682
-     * @param boolean $sidebar true with sidebar, false without
2683
-     * @param boolean $about   use the about_admin_wrapper instead of the default.
2684
-     * @return void
2685
-     * @throws DomainException
2686
-     * @throws EE_Error
2687
-     */
2688
-    private function _display_admin_page($sidebar = false, $about = false)
2689
-    {
2690
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2691
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2692
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2693
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2694
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2695
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2696
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2697
-            ? 'poststuff'
2698
-            : 'espresso-default-admin';
2699
-        $template_path                                     = $sidebar
2700
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2701
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2702
-        if ($this->request->isAjax()) {
2703
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2704
-        }
2705
-        $template_path                                     = ! empty($this->_column_template_path)
2706
-            ? $this->_column_template_path : $template_path;
2707
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2708
-            ? $this->_template_args['admin_page_content']
2709
-            : '';
2710
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2711
-            ? $this->_template_args['before_admin_page_content']
2712
-            : '';
2713
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2714
-            ? $this->_template_args['after_admin_page_content']
2715
-            : '';
2716
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2717
-            $template_path,
2718
-            $this->_template_args,
2719
-            true
2720
-        );
2721
-        // the final template wrapper
2722
-        $this->admin_page_wrapper($about);
2723
-    }
2724
-
2725
-
2726
-    /**
2727
-     * This is used to display caf preview pages.
2728
-     *
2729
-     * @param string $utm_campaign_source what is the key used for google analytics link
2730
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2731
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2732
-     * @return void
2733
-     * @throws DomainException
2734
-     * @throws EE_Error
2735
-     * @throws InvalidArgumentException
2736
-     * @throws InvalidDataTypeException
2737
-     * @throws InvalidInterfaceException
2738
-     * @since 4.3.2
2739
-     */
2740
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2741
-    {
2742
-        // let's generate a default preview action button if there isn't one already present.
2743
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2744
-            'Upgrade to Event Espresso 4 Right Now',
2745
-            'event_espresso'
2746
-        );
2747
-        $buy_now_url                                   = add_query_arg(
2748
-            [
2749
-                'ee_ver'       => 'ee4',
2750
-                'utm_source'   => 'ee4_plugin_admin',
2751
-                'utm_medium'   => 'link',
2752
-                'utm_campaign' => $utm_campaign_source,
2753
-                'utm_content'  => 'buy_now_button',
2754
-            ],
2755
-            'https://eventespresso.com/pricing/'
2756
-        );
2757
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2758
-            ? $this->get_action_link_or_button(
2759
-                '',
2760
-                'buy_now',
2761
-                [],
2762
-                'button-primary button-large',
2763
-                esc_url_raw($buy_now_url),
2764
-                true
2765
-            )
2766
-            : $this->_template_args['preview_action_button'];
2767
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2768
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2769
-            $this->_template_args,
2770
-            true
2771
-        );
2772
-        $this->_display_admin_page($display_sidebar);
2773
-    }
2774
-
2775
-
2776
-    /**
2777
-     * display_admin_list_table_page_with_sidebar
2778
-     * generates HTML wrapper for an admin_page with list_table
2779
-     *
2780
-     * @return void
2781
-     * @throws EE_Error
2782
-     * @throws DomainException
2783
-     */
2784
-    public function display_admin_list_table_page_with_sidebar()
2785
-    {
2786
-        $this->_display_admin_list_table_page(true);
2787
-    }
2788
-
2789
-
2790
-    /**
2791
-     * display_admin_list_table_page_with_no_sidebar
2792
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2793
-     *
2794
-     * @return void
2795
-     * @throws EE_Error
2796
-     * @throws DomainException
2797
-     */
2798
-    public function display_admin_list_table_page_with_no_sidebar()
2799
-    {
2800
-        $this->_display_admin_list_table_page();
2801
-    }
2802
-
2803
-
2804
-    /**
2805
-     * generates html wrapper for an admin_list_table page
2806
-     *
2807
-     * @param boolean $sidebar whether to display with sidebar or not.
2808
-     * @return void
2809
-     * @throws DomainException
2810
-     * @throws EE_Error
2811
-     */
2812
-    private function _display_admin_list_table_page($sidebar = false)
2813
-    {
2814
-        // setup search attributes
2815
-        $this->_set_search_attributes();
2816
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
2817
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2818
-        $this->_template_args['table_url']        = $this->request->isAjax()
2819
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2820
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2821
-        $this->_template_args['list_table']       = $this->_list_table_object;
2822
-        $this->_template_args['current_route']    = $this->_req_action;
2823
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2824
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2825
-        if (! empty($ajax_sorting_callback)) {
2826
-            $sortable_list_table_form_fields = wp_nonce_field(
2827
-                $ajax_sorting_callback . '_nonce',
2828
-                $ajax_sorting_callback . '_nonce',
2829
-                false,
2830
-                false
2831
-            );
2832
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2833
-                                                . $this->page_slug
2834
-                                                . '" />';
2835
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2836
-                                                . $ajax_sorting_callback
2837
-                                                . '" />';
2838
-        } else {
2839
-            $sortable_list_table_form_fields = '';
2840
-        }
2841
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2842
-        $hidden_form_fields                                      =
2843
-            isset($this->_template_args['list_table_hidden_fields'])
2844
-                ? $this->_template_args['list_table_hidden_fields']
2845
-                : '';
2846
-        $nonce_ref                                               = $this->_req_action . '_nonce';
2847
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
2848
-                                                                    . $nonce_ref
2849
-                                                                    . '" value="'
2850
-                                                                    . wp_create_nonce($nonce_ref)
2851
-                                                                    . '">';
2852
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2853
-        // display message about search results?
2854
-        $search = $this->request->getRequestParam('s');
2855
-        $this->_template_args['before_list_table'] .= ! empty($search)
2856
-            ? '<p class="ee-search-results">' . sprintf(
2857
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2858
-                trim($search, '%')
2859
-            ) . '</p>'
2860
-            : '';
2861
-        // filter before_list_table template arg
2862
-        $this->_template_args['before_list_table'] = apply_filters(
2863
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2864
-            $this->_template_args['before_list_table'],
2865
-            $this->page_slug,
2866
-            $this->request->requestParams(),
2867
-            $this->_req_action
2868
-        );
2869
-        // convert to array and filter again
2870
-        // arrays are easier to inject new items in a specific location,
2871
-        // but would not be backwards compatible, so we have to add a new filter
2872
-        $this->_template_args['before_list_table'] = implode(
2873
-            " \n",
2874
-            (array) apply_filters(
2875
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2876
-                (array) $this->_template_args['before_list_table'],
2877
-                $this->page_slug,
2878
-                $this->request->requestParams(),
2879
-                $this->_req_action
2880
-            )
2881
-        );
2882
-        // filter after_list_table template arg
2883
-        $this->_template_args['after_list_table'] = apply_filters(
2884
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2885
-            $this->_template_args['after_list_table'],
2886
-            $this->page_slug,
2887
-            $this->request->requestParams(),
2888
-            $this->_req_action
2889
-        );
2890
-        // convert to array and filter again
2891
-        // arrays are easier to inject new items in a specific location,
2892
-        // but would not be backwards compatible, so we have to add a new filter
2893
-        $this->_template_args['after_list_table']   = implode(
2894
-            " \n",
2895
-            (array) apply_filters(
2896
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2897
-                (array) $this->_template_args['after_list_table'],
2898
-                $this->page_slug,
2899
-                $this->request->requestParams(),
2900
-                $this->_req_action
2901
-            )
2902
-        );
2903
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2904
-            $template_path,
2905
-            $this->_template_args,
2906
-            true
2907
-        );
2908
-        // the final template wrapper
2909
-        if ($sidebar) {
2910
-            $this->display_admin_page_with_sidebar();
2911
-        } else {
2912
-            $this->display_admin_page_with_no_sidebar();
2913
-        }
2914
-    }
2915
-
2916
-
2917
-    /**
2918
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2919
-     * html string for the legend.
2920
-     * $items are expected in an array in the following format:
2921
-     * $legend_items = array(
2922
-     *        'item_id' => array(
2923
-     *            'icon' => 'http://url_to_icon_being_described.png',
2924
-     *            'desc' => esc_html__('localized description of item');
2925
-     *        )
2926
-     * );
2927
-     *
2928
-     * @param array $items see above for format of array
2929
-     * @return string html string of legend
2930
-     * @throws DomainException
2931
-     */
2932
-    protected function _display_legend($items)
2933
-    {
2934
-        $this->_template_args['items'] = apply_filters(
2935
-            'FHEE__EE_Admin_Page___display_legend__items',
2936
-            (array) $items,
2937
-            $this
2938
-        );
2939
-        return EEH_Template::display_template(
2940
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2941
-            $this->_template_args,
2942
-            true
2943
-        );
2944
-    }
2945
-
2946
-
2947
-    /**
2948
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2949
-     * The returned json object is created from an array in the following format:
2950
-     * array(
2951
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2952
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
2953
-     *  'notices' => '', // - contains any EE_Error formatted notices
2954
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
2955
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
2956
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
2957
-     *  that might be included in here)
2958
-     * )
2959
-     * The json object is populated by whatever is set in the $_template_args property.
2960
-     *
2961
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
2962
-     *                                 instead of displayed.
2963
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
2964
-     * @return void
2965
-     * @throws EE_Error
2966
-     */
2967
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
2968
-    {
2969
-        // make sure any EE_Error notices have been handled.
2970
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
2971
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
2972
-        unset($this->_template_args['data']);
2973
-        $json = [
2974
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2975
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2976
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2977
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2978
-            'notices'   => EE_Error::get_notices(),
2979
-            'content'   => isset($this->_template_args['admin_page_content'])
2980
-                ? $this->_template_args['admin_page_content'] : '',
2981
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
2982
-            'isEEajax'  => true
2983
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2984
-        ];
2985
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
2986
-        if (null === error_get_last() || ! headers_sent()) {
2987
-            header('Content-Type: application/json; charset=UTF-8');
2988
-        }
2989
-        echo wp_json_encode($json);
2990
-        exit();
2991
-    }
2992
-
2993
-
2994
-    /**
2995
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2996
-     *
2997
-     * @return void
2998
-     * @throws EE_Error
2999
-     */
3000
-    public function return_json()
3001
-    {
3002
-        if ($this->request->isAjax()) {
3003
-            $this->_return_json();
3004
-        } else {
3005
-            throw new EE_Error(
3006
-                sprintf(
3007
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3008
-                    __FUNCTION__
3009
-                )
3010
-            );
3011
-        }
3012
-    }
3013
-
3014
-
3015
-    /**
3016
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3017
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3018
-     *
3019
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3020
-     */
3021
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3022
-    {
3023
-        $this->_hook_obj = $hook_obj;
3024
-    }
3025
-
3026
-
3027
-    /**
3028
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3029
-     *
3030
-     * @param boolean $about whether to use the special about page wrapper or default.
3031
-     * @return void
3032
-     * @throws DomainException
3033
-     * @throws EE_Error
3034
-     */
3035
-    public function admin_page_wrapper($about = false)
3036
-    {
3037
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3038
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3039
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3040
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3041
-
3042
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3043
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3044
-            isset($this->_template_args['before_admin_page_content'])
3045
-                ? $this->_template_args['before_admin_page_content']
3046
-                : ''
3047
-        );
3048
-
3049
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3050
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3051
-            isset($this->_template_args['after_admin_page_content'])
3052
-                ? $this->_template_args['after_admin_page_content']
3053
-                : ''
3054
-        );
3055
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3056
-
3057
-        if ($this->request->isAjax()) {
3058
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3059
-                // $template_path,
3060
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3061
-                $this->_template_args,
3062
-                true
3063
-            );
3064
-            $this->_return_json();
3065
-        }
3066
-        // load settings page wrapper template
3067
-        $template_path = $about
3068
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3069
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3070
-
3071
-        EEH_Template::display_template($template_path, $this->_template_args);
3072
-    }
3073
-
3074
-
3075
-    /**
3076
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3077
-     *
3078
-     * @return string html
3079
-     * @throws EE_Error
3080
-     */
3081
-    protected function _get_main_nav_tabs()
3082
-    {
3083
-        // let's generate the html using the EEH_Tabbed_Content helper.
3084
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3085
-        // (rather than setting in the page_routes array)
3086
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3087
-    }
3088
-
3089
-
3090
-    /**
3091
-     *        sort nav tabs
3092
-     *
3093
-     * @param $a
3094
-     * @param $b
3095
-     * @return int
3096
-     */
3097
-    private function _sort_nav_tabs($a, $b)
3098
-    {
3099
-        if ($a['order'] === $b['order']) {
3100
-            return 0;
3101
-        }
3102
-        return ($a['order'] < $b['order']) ? -1 : 1;
3103
-    }
3104
-
3105
-
3106
-    /**
3107
-     *    generates HTML for the forms used on admin pages
3108
-     *
3109
-     * @param array  $input_vars   - array of input field details
3110
-     * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3111
-     *                             use)
3112
-     * @param bool   $id
3113
-     * @return array|string
3114
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3115
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3116
-     */
3117
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3118
-    {
3119
-        return $generator === 'string'
3120
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3121
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3122
-    }
3123
-
3124
-
3125
-    /**
3126
-     * generates the "Save" and "Save & Close" buttons for edit forms
3127
-     *
3128
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3129
-     *                                   Close" button.
3130
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3131
-     *                                   'Save', [1] => 'save & close')
3132
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3133
-     *                                   via the "name" value in the button).  We can also use this to just dump
3134
-     *                                   default actions by submitting some other value.
3135
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3136
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3137
-     *                                   close (normal form handling).
3138
-     */
3139
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3140
-    {
3141
-        // make sure $text and $actions are in an array
3142
-        $text          = (array) $text;
3143
-        $actions       = (array) $actions;
3144
-        $referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3145
-        $button_text   = ! empty($text)
3146
-            ? $text
3147
-            : [
3148
-                esc_html__('Save', 'event_espresso'),
3149
-                esc_html__('Save and Close', 'event_espresso'),
3150
-            ];
3151
-        $default_names = ['save', 'save_and_close'];
3152
-        $buttons = '';
3153
-        foreach ($button_text as $key => $button) {
3154
-            $ref     = $default_names[ $key ];
3155
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3156
-            $buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3157
-                        . 'value="' . $button . '" name="' . $name . '" '
3158
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3159
-            if (! $both) {
3160
-                break;
3161
-            }
3162
-        }
3163
-        // add in a hidden index for the current page (so save and close redirects properly)
3164
-        $buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3165
-                   . $referrer_url
3166
-                   . '" />';
3167
-        $this->_template_args['save_buttons'] = $buttons;
3168
-    }
3169
-
3170
-
3171
-    /**
3172
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3173
-     *
3174
-     * @param string $route
3175
-     * @param array  $additional_hidden_fields
3176
-     * @see   $this->_set_add_edit_form_tags() for details on params
3177
-     * @since 4.6.0
3178
-     */
3179
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3180
-    {
3181
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3182
-    }
3183
-
3184
-
3185
-    /**
3186
-     * set form open and close tags on add/edit pages.
3187
-     *
3188
-     * @param string $route                    the route you want the form to direct to
3189
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3190
-     * @return void
3191
-     */
3192
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3193
-    {
3194
-        if (empty($route)) {
3195
-            $user_msg = esc_html__(
3196
-                'An error occurred. No action was set for this page\'s form.',
3197
-                'event_espresso'
3198
-            );
3199
-            $dev_msg  = $user_msg . "\n"
3200
-                        . sprintf(
3201
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3202
-                            __FUNCTION__,
3203
-                            __CLASS__
3204
-                        );
3205
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3206
-        }
3207
-        // open form
3208
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3209
-                                                             . $this->_admin_base_url
3210
-                                                             . '" id="'
3211
-                                                             . $route
3212
-                                                             . '_event_form" >';
3213
-        // add nonce
3214
-        $nonce                                             =
3215
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3216
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3217
-        // add REQUIRED form action
3218
-        $hidden_fields = [
3219
-            'action' => ['type' => 'hidden', 'value' => $route],
3220
-        ];
3221
-        // merge arrays
3222
-        $hidden_fields = is_array($additional_hidden_fields)
3223
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3224
-            : $hidden_fields;
3225
-        // generate form fields
3226
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3227
-        // add fields to form
3228
-        foreach ((array) $form_fields as $form_field) {
3229
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3230
-        }
3231
-        // close form
3232
-        $this->_template_args['after_admin_page_content'] = '</form>';
3233
-    }
3234
-
3235
-
3236
-    /**
3237
-     * Public Wrapper for _redirect_after_action() method since its
3238
-     * discovered it would be useful for external code to have access.
3239
-     *
3240
-     * @param bool   $success
3241
-     * @param string $what
3242
-     * @param string $action_desc
3243
-     * @param array  $query_args
3244
-     * @param bool   $override_overwrite
3245
-     * @throws EE_Error
3246
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3247
-     * @since 4.5.0
3248
-     */
3249
-    public function redirect_after_action(
3250
-        $success = false,
3251
-        $what = 'item',
3252
-        $action_desc = 'processed',
3253
-        $query_args = [],
3254
-        $override_overwrite = false
3255
-    ) {
3256
-        $this->_redirect_after_action(
3257
-            $success,
3258
-            $what,
3259
-            $action_desc,
3260
-            $query_args,
3261
-            $override_overwrite
3262
-        );
3263
-    }
3264
-
3265
-
3266
-    /**
3267
-     * Helper method for merging existing request data with the returned redirect url.
3268
-     *
3269
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3270
-     * filters are still applied.
3271
-     *
3272
-     * @param array $new_route_data
3273
-     * @return array
3274
-     */
3275
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3276
-    {
3277
-        foreach ($this->request->requestParams() as $ref => $value) {
3278
-            // unset nonces
3279
-            if (strpos($ref, 'nonce') !== false) {
3280
-                $this->request->unSetRequestParam($ref);
3281
-                continue;
3282
-            }
3283
-            // urlencode values.
3284
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3285
-            $this->request->setRequestParam($ref, $value);
3286
-        }
3287
-        return array_merge($this->request->requestParams(), $new_route_data);
3288
-    }
3289
-
3290
-
3291
-    /**
3292
-     *    _redirect_after_action
3293
-     *
3294
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3295
-     * @param string $what               - what the action was performed on
3296
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3297
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3298
-     *                                   action is completed
3299
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3300
-     *                                   override this so that they show.
3301
-     * @return void
3302
-     * @throws EE_Error
3303
-     */
3304
-    protected function _redirect_after_action(
3305
-        $success = 0,
3306
-        $what = 'item',
3307
-        $action_desc = 'processed',
3308
-        $query_args = [],
3309
-        $override_overwrite = false
3310
-    ) {
3311
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3312
-        // class name for actions/filters.
3313
-        $classname = get_class($this);
3314
-        // set redirect url.
3315
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3316
-        // otherwise we go with whatever is set as the _admin_base_url
3317
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3318
-        $notices      = EE_Error::get_notices(false);
3319
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3320
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3321
-            EE_Error::overwrite_success();
3322
-        }
3323
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3324
-            // how many records affected ? more than one record ? or just one ?
3325
-            if ($success > 1) {
3326
-                // set plural msg
3327
-                EE_Error::add_success(
3328
-                    sprintf(
3329
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3330
-                        $what,
3331
-                        $action_desc
3332
-                    ),
3333
-                    __FILE__,
3334
-                    __FUNCTION__,
3335
-                    __LINE__
3336
-                );
3337
-            } elseif ($success === 1) {
3338
-                // set singular msg
3339
-                EE_Error::add_success(
3340
-                    sprintf(
3341
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3342
-                        $what,
3343
-                        $action_desc
3344
-                    ),
3345
-                    __FILE__,
3346
-                    __FUNCTION__,
3347
-                    __LINE__
3348
-                );
3349
-            }
3350
-        }
3351
-        // check that $query_args isn't something crazy
3352
-        if (! is_array($query_args)) {
3353
-            $query_args = [];
3354
-        }
3355
-        /**
3356
-         * Allow injecting actions before the query_args are modified for possible different
3357
-         * redirections on save and close actions
3358
-         *
3359
-         * @param array $query_args       The original query_args array coming into the
3360
-         *                                method.
3361
-         * @since 4.2.0
3362
-         */
3363
-        do_action(
3364
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3365
-            $query_args
3366
-        );
3367
-        // calculate where we're going (if we have a "save and close" button pushed)
3368
-
3369
-        if (
3370
-            $this->request->requestParamIsSet('save_and_close')
3371
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3372
-        ) {
3373
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3374
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3375
-            // regenerate query args array from referrer URL
3376
-            parse_str($parsed_url['query'], $query_args);
3377
-            // correct page and action will be in the query args now
3378
-            $redirect_url = admin_url('admin.php');
3379
-        }
3380
-        // merge any default query_args set in _default_route_query_args property
3381
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3382
-            $args_to_merge = [];
3383
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3384
-                // is there a wp_referer array in our _default_route_query_args property?
3385
-                if ($query_param === 'wp_referer') {
3386
-                    $query_value = (array) $query_value;
3387
-                    foreach ($query_value as $reference => $value) {
3388
-                        if (strpos($reference, 'nonce') !== false) {
3389
-                            continue;
3390
-                        }
3391
-                        // finally we will override any arguments in the referer with
3392
-                        // what might be set on the _default_route_query_args array.
3393
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3394
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3395
-                        } else {
3396
-                            $args_to_merge[ $reference ] = urlencode($value);
3397
-                        }
3398
-                    }
3399
-                    continue;
3400
-                }
3401
-                $args_to_merge[ $query_param ] = $query_value;
3402
-            }
3403
-            // now let's merge these arguments but override with what was specifically sent in to the
3404
-            // redirect.
3405
-            $query_args = array_merge($args_to_merge, $query_args);
3406
-        }
3407
-        $this->_process_notices($query_args);
3408
-        // generate redirect url
3409
-        // if redirecting to anything other than the main page, add a nonce
3410
-        if (isset($query_args['action'])) {
3411
-            // manually generate wp_nonce and merge that with the query vars
3412
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3413
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3414
-        }
3415
-        // we're adding some hooks and filters in here for processing any things just before redirects
3416
-        // (example: an admin page has done an insert or update and we want to run something after that).
3417
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3418
-        $redirect_url = apply_filters(
3419
-            'FHEE_redirect_' . $classname . $this->_req_action,
3420
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3421
-            $query_args
3422
-        );
3423
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3424
-        if ($this->request->isAjax()) {
3425
-            $default_data                    = [
3426
-                'close'        => true,
3427
-                'redirect_url' => $redirect_url,
3428
-                'where'        => 'main',
3429
-                'what'         => 'append',
3430
-            ];
3431
-            $this->_template_args['success'] = $success;
3432
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3433
-                $default_data,
3434
-                $this->_template_args['data']
3435
-            ) : $default_data;
3436
-            $this->_return_json();
3437
-        }
3438
-        wp_safe_redirect($redirect_url);
3439
-        exit();
3440
-    }
3441
-
3442
-
3443
-    /**
3444
-     * process any notices before redirecting (or returning ajax request)
3445
-     * This method sets the $this->_template_args['notices'] attribute;
3446
-     *
3447
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3448
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3449
-     *                                  page_routes haven't been defined yet.
3450
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3451
-     *                                  still save a transient for the notice.
3452
-     * @return void
3453
-     * @throws EE_Error
3454
-     */
3455
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3456
-    {
3457
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3458
-        if ($this->request->isAjax()) {
3459
-            $notices = EE_Error::get_notices(false);
3460
-            if (empty($this->_template_args['success'])) {
3461
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3462
-            }
3463
-            if (empty($this->_template_args['errors'])) {
3464
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3465
-            }
3466
-            if (empty($this->_template_args['attention'])) {
3467
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3468
-            }
3469
-        }
3470
-        $this->_template_args['notices'] = EE_Error::get_notices();
3471
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3472
-        if (! $this->request->isAjax() || $sticky_notices) {
3473
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3474
-            $this->_add_transient(
3475
-                $route,
3476
-                $this->_template_args['notices'],
3477
-                true,
3478
-                $skip_route_verify
3479
-            );
3480
-        }
3481
-    }
3482
-
3483
-
3484
-    /**
3485
-     * get_action_link_or_button
3486
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3487
-     *
3488
-     * @param string $action        use this to indicate which action the url is generated with.
3489
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3490
-     *                              property.
3491
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3492
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3493
-     * @param string $base_url      If this is not provided
3494
-     *                              the _admin_base_url will be used as the default for the button base_url.
3495
-     *                              Otherwise this value will be used.
3496
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3497
-     * @return string
3498
-     * @throws InvalidArgumentException
3499
-     * @throws InvalidInterfaceException
3500
-     * @throws InvalidDataTypeException
3501
-     * @throws EE_Error
3502
-     */
3503
-    public function get_action_link_or_button(
3504
-        $action,
3505
-        $type = 'add',
3506
-        $extra_request = [],
3507
-        $class = 'button-primary',
3508
-        $base_url = '',
3509
-        $exclude_nonce = false
3510
-    ) {
3511
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3512
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3513
-            throw new EE_Error(
3514
-                sprintf(
3515
-                    esc_html__(
3516
-                        'There is no page route for given action for the button.  This action was given: %s',
3517
-                        'event_espresso'
3518
-                    ),
3519
-                    $action
3520
-                )
3521
-            );
3522
-        }
3523
-        if (! isset($this->_labels['buttons'][ $type ])) {
3524
-            throw new EE_Error(
3525
-                sprintf(
3526
-                    esc_html__(
3527
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3528
-                        'event_espresso'
3529
-                    ),
3530
-                    $type
3531
-                )
3532
-            );
3533
-        }
3534
-        // finally check user access for this button.
3535
-        $has_access = $this->check_user_access($action, true);
3536
-        if (! $has_access) {
3537
-            return '';
3538
-        }
3539
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3540
-        $query_args = [
3541
-            'action' => $action,
3542
-        ];
3543
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3544
-        if (! empty($extra_request)) {
3545
-            $query_args = array_merge($extra_request, $query_args);
3546
-        }
3547
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3548
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3549
-    }
3550
-
3551
-
3552
-    /**
3553
-     * _per_page_screen_option
3554
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3555
-     *
3556
-     * @return void
3557
-     * @throws InvalidArgumentException
3558
-     * @throws InvalidInterfaceException
3559
-     * @throws InvalidDataTypeException
3560
-     */
3561
-    protected function _per_page_screen_option()
3562
-    {
3563
-        $option = 'per_page';
3564
-        $args   = [
3565
-            'label'   => apply_filters(
3566
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3567
-                $this->_admin_page_title,
3568
-                $this
3569
-            ),
3570
-            'default' => (int) apply_filters(
3571
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3572
-                20
3573
-            ),
3574
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3575
-        ];
3576
-        // ONLY add the screen option if the user has access to it.
3577
-        if ($this->check_user_access($this->_current_view, true)) {
3578
-            add_screen_option($option, $args);
3579
-        }
3580
-    }
3581
-
3582
-
3583
-    /**
3584
-     * set_per_page_screen_option
3585
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3586
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3587
-     * admin_menu.
3588
-     *
3589
-     * @return void
3590
-     */
3591
-    private function _set_per_page_screen_options()
3592
-    {
3593
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3594
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3595
-            if (! $user = wp_get_current_user()) {
3596
-                return;
3597
-            }
3598
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3599
-            if (! $option) {
3600
-                return;
3601
-            }
3602
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3603
-            $map_option = $option;
3604
-            $option     = str_replace('-', '_', $option);
3605
-            switch ($map_option) {
3606
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3607
-                    $max_value = apply_filters(
3608
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3609
-                        999,
3610
-                        $this->_current_page,
3611
-                        $this->_current_view
3612
-                    );
3613
-                    if ($value < 1) {
3614
-                        return;
3615
-                    }
3616
-                    $value = min($value, $max_value);
3617
-                    break;
3618
-                default:
3619
-                    $value = apply_filters(
3620
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3621
-                        false,
3622
-                        $option,
3623
-                        $value
3624
-                    );
3625
-                    if (false === $value) {
3626
-                        return;
3627
-                    }
3628
-                    break;
3629
-            }
3630
-            update_user_meta($user->ID, $option, $value);
3631
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3632
-            exit;
3633
-        }
3634
-    }
3635
-
3636
-
3637
-    /**
3638
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3639
-     *
3640
-     * @param array $data array that will be assigned to template args.
3641
-     */
3642
-    public function set_template_args($data)
3643
-    {
3644
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3645
-    }
3646
-
3647
-
3648
-    /**
3649
-     * This makes available the WP transient system for temporarily moving data between routes
3650
-     *
3651
-     * @param string $route             the route that should receive the transient
3652
-     * @param array  $data              the data that gets sent
3653
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3654
-     *                                  normal route transient.
3655
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3656
-     *                                  when we are adding a transient before page_routes have been defined.
3657
-     * @return void
3658
-     * @throws EE_Error
3659
-     */
3660
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3661
-    {
3662
-        $user_id = get_current_user_id();
3663
-        if (! $skip_route_verify) {
3664
-            $this->_verify_route($route);
3665
-        }
3666
-        // now let's set the string for what kind of transient we're setting
3667
-        $transient = $notices
3668
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3669
-            : 'rte_tx_' . $route . '_' . $user_id;
3670
-        $data      = $notices ? ['notices' => $data] : $data;
3671
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3672
-        $existing = is_multisite() && is_network_admin()
3673
-            ? get_site_transient($transient)
3674
-            : get_transient($transient);
3675
-        if ($existing) {
3676
-            $data = array_merge((array) $data, (array) $existing);
3677
-        }
3678
-        if (is_multisite() && is_network_admin()) {
3679
-            set_site_transient($transient, $data, 8);
3680
-        } else {
3681
-            set_transient($transient, $data, 8);
3682
-        }
3683
-    }
3684
-
3685
-
3686
-    /**
3687
-     * this retrieves the temporary transient that has been set for moving data between routes.
3688
-     *
3689
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3690
-     * @param string $route
3691
-     * @return mixed data
3692
-     */
3693
-    protected function _get_transient($notices = false, $route = '')
3694
-    {
3695
-        $user_id   = get_current_user_id();
3696
-        $route     = ! $route ? $this->_req_action : $route;
3697
-        $transient = $notices
3698
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3699
-            : 'rte_tx_' . $route . '_' . $user_id;
3700
-        $data      = is_multisite() && is_network_admin()
3701
-            ? get_site_transient($transient)
3702
-            : get_transient($transient);
3703
-        // delete transient after retrieval (just in case it hasn't expired);
3704
-        if (is_multisite() && is_network_admin()) {
3705
-            delete_site_transient($transient);
3706
-        } else {
3707
-            delete_transient($transient);
3708
-        }
3709
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3710
-    }
3711
-
3712
-
3713
-    /**
3714
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3715
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3716
-     * default route callback on the EE_Admin page you want it run.)
3717
-     *
3718
-     * @return void
3719
-     */
3720
-    protected function _transient_garbage_collection()
3721
-    {
3722
-        global $wpdb;
3723
-        // retrieve all existing transients
3724
-        $query =
3725
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3726
-        if ($results = $wpdb->get_results($query)) {
3727
-            foreach ($results as $result) {
3728
-                $transient = str_replace('_transient_', '', $result->option_name);
3729
-                get_transient($transient);
3730
-                if (is_multisite() && is_network_admin()) {
3731
-                    get_site_transient($transient);
3732
-                }
3733
-            }
3734
-        }
3735
-    }
3736
-
3737
-
3738
-    /**
3739
-     * get_view
3740
-     *
3741
-     * @return string content of _view property
3742
-     */
3743
-    public function get_view()
3744
-    {
3745
-        return $this->_view;
3746
-    }
3747
-
3748
-
3749
-    /**
3750
-     * getter for the protected $_views property
3751
-     *
3752
-     * @return array
3753
-     */
3754
-    public function get_views()
3755
-    {
3756
-        return $this->_views;
3757
-    }
3758
-
3759
-
3760
-    /**
3761
-     * get_current_page
3762
-     *
3763
-     * @return string _current_page property value
3764
-     */
3765
-    public function get_current_page()
3766
-    {
3767
-        return $this->_current_page;
3768
-    }
3769
-
3770
-
3771
-    /**
3772
-     * get_current_view
3773
-     *
3774
-     * @return string _current_view property value
3775
-     */
3776
-    public function get_current_view()
3777
-    {
3778
-        return $this->_current_view;
3779
-    }
3780
-
3781
-
3782
-    /**
3783
-     * get_current_screen
3784
-     *
3785
-     * @return object The current WP_Screen object
3786
-     */
3787
-    public function get_current_screen()
3788
-    {
3789
-        return $this->_current_screen;
3790
-    }
3791
-
3792
-
3793
-    /**
3794
-     * get_current_page_view_url
3795
-     *
3796
-     * @return string This returns the url for the current_page_view.
3797
-     */
3798
-    public function get_current_page_view_url()
3799
-    {
3800
-        return $this->_current_page_view_url;
3801
-    }
3802
-
3803
-
3804
-    /**
3805
-     * just returns the Request
3806
-     *
3807
-     * @return RequestInterface
3808
-     */
3809
-    public function get_request()
3810
-    {
3811
-        return $this->request;
3812
-    }
3813
-
3814
-
3815
-    /**
3816
-     * just returns the _req_data property
3817
-     *
3818
-     * @return array
3819
-     */
3820
-    public function get_request_data()
3821
-    {
3822
-        return $this->request->requestParams();
3823
-    }
3824
-
3825
-
3826
-    /**
3827
-     * returns the _req_data protected property
3828
-     *
3829
-     * @return string
3830
-     */
3831
-    public function get_req_action()
3832
-    {
3833
-        return $this->_req_action;
3834
-    }
3835
-
3836
-
3837
-    /**
3838
-     * @return bool  value of $_is_caf property
3839
-     */
3840
-    public function is_caf()
3841
-    {
3842
-        return $this->_is_caf;
3843
-    }
3844
-
3845
-
3846
-    /**
3847
-     * @return mixed
3848
-     */
3849
-    public function default_espresso_metaboxes()
3850
-    {
3851
-        return $this->_default_espresso_metaboxes;
3852
-    }
3853
-
3854
-
3855
-    /**
3856
-     * @return mixed
3857
-     */
3858
-    public function admin_base_url()
3859
-    {
3860
-        return $this->_admin_base_url;
3861
-    }
3862
-
3863
-
3864
-    /**
3865
-     * @return mixed
3866
-     */
3867
-    public function wp_page_slug()
3868
-    {
3869
-        return $this->_wp_page_slug;
3870
-    }
3871
-
3872
-
3873
-    /**
3874
-     * updates  espresso configuration settings
3875
-     *
3876
-     * @param string                   $tab
3877
-     * @param EE_Config_Base|EE_Config $config
3878
-     * @param string                   $file file where error occurred
3879
-     * @param string                   $func function  where error occurred
3880
-     * @param string                   $line line no where error occurred
3881
-     * @return boolean
3882
-     */
3883
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3884
-    {
3885
-        // remove any options that are NOT going to be saved with the config settings.
3886
-        if (isset($config->core->ee_ueip_optin)) {
3887
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3888
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3889
-            update_option('ee_ueip_has_notified', true);
3890
-        }
3891
-        // and save it (note we're also doing the network save here)
3892
-        $net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3893
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3894
-        if ($config_saved && $net_saved) {
3895
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3896
-            return true;
3897
-        }
3898
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3899
-        return false;
3900
-    }
3901
-
3902
-
3903
-    /**
3904
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3905
-     *
3906
-     * @return array
3907
-     */
3908
-    public function get_yes_no_values()
3909
-    {
3910
-        return $this->_yes_no_values;
3911
-    }
3912
-
3913
-
3914
-    protected function _get_dir()
3915
-    {
3916
-        $reflector = new ReflectionClass(get_class($this));
3917
-        return dirname($reflector->getFileName());
3918
-    }
3919
-
3920
-
3921
-    /**
3922
-     * A helper for getting a "next link".
3923
-     *
3924
-     * @param string $url   The url to link to
3925
-     * @param string $class The class to use.
3926
-     * @return string
3927
-     */
3928
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3929
-    {
3930
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3931
-    }
3932
-
3933
-
3934
-    /**
3935
-     * A helper for getting a "previous link".
3936
-     *
3937
-     * @param string $url   The url to link to
3938
-     * @param string $class The class to use.
3939
-     * @return string
3940
-     */
3941
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3942
-    {
3943
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3944
-    }
3945
-
3946
-
3947
-
3948
-
3949
-
3950
-
3951
-
3952
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3953
-
3954
-
3955
-    /**
3956
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3957
-     * 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
3958
-     * _req_data array.
3959
-     *
3960
-     * @return bool success/fail
3961
-     * @throws EE_Error
3962
-     * @throws InvalidArgumentException
3963
-     * @throws ReflectionException
3964
-     * @throws InvalidDataTypeException
3965
-     * @throws InvalidInterfaceException
3966
-     */
3967
-    protected function _process_resend_registration()
3968
-    {
3969
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3970
-        do_action(
3971
-            'AHEE__EE_Admin_Page___process_resend_registration',
3972
-            $this->_template_args['success'],
3973
-            $this->request->requestParams()
3974
-        );
3975
-        return $this->_template_args['success'];
3976
-    }
3977
-
3978
-
3979
-    /**
3980
-     * This automatically processes any payment message notifications when manual payment has been applied.
3981
-     *
3982
-     * @param EE_Payment $payment
3983
-     * @return bool success/fail
3984
-     */
3985
-    protected function _process_payment_notification(EE_Payment $payment)
3986
-    {
3987
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3988
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3989
-        $this->_template_args['success'] = apply_filters(
3990
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3991
-            false,
3992
-            $payment
3993
-        );
3994
-        return $this->_template_args['success'];
3995
-    }
2563
+	}
2564
+
2565
+
2566
+	/**
2567
+	 * facade for add_meta_box
2568
+	 *
2569
+	 * @param string  $action        where the metabox gets displayed
2570
+	 * @param string  $title         Title of Metabox (output in metabox header)
2571
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2572
+	 *                               instead of the one created in here.
2573
+	 * @param array   $callback_args an array of args supplied for the metabox
2574
+	 * @param string  $column        what metabox column
2575
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2576
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2577
+	 *                               created but just set our own callback for wp's add_meta_box.
2578
+	 * @throws DomainException
2579
+	 */
2580
+	public function _add_admin_page_meta_box(
2581
+		$action,
2582
+		$title,
2583
+		$callback,
2584
+		$callback_args,
2585
+		$column = 'normal',
2586
+		$priority = 'high',
2587
+		$create_func = true
2588
+	) {
2589
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2590
+		// 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.
2591
+		if (empty($callback_args) && $create_func) {
2592
+			$callback_args = [
2593
+				'template_path' => $this->_template_path,
2594
+				'template_args' => $this->_template_args,
2595
+			];
2596
+		}
2597
+		// 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)
2598
+		$call_back_func = $create_func
2599
+			? function ($post, $metabox) {
2600
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2601
+				echo EEH_Template::display_template(
2602
+					$metabox['args']['template_path'],
2603
+					$metabox['args']['template_args'],
2604
+					true
2605
+				);
2606
+			}
2607
+			: $callback;
2608
+		add_meta_box(
2609
+			str_replace('_', '-', $action) . '-mbox',
2610
+			$title,
2611
+			$call_back_func,
2612
+			$this->_wp_page_slug,
2613
+			$column,
2614
+			$priority,
2615
+			$callback_args
2616
+		);
2617
+	}
2618
+
2619
+
2620
+	/**
2621
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2622
+	 *
2623
+	 * @throws DomainException
2624
+	 * @throws EE_Error
2625
+	 */
2626
+	public function display_admin_page_with_metabox_columns()
2627
+	{
2628
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2629
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2630
+			$this->_column_template_path,
2631
+			$this->_template_args,
2632
+			true
2633
+		);
2634
+		// the final wrapper
2635
+		$this->admin_page_wrapper();
2636
+	}
2637
+
2638
+
2639
+	/**
2640
+	 * generates  HTML wrapper for an admin details page
2641
+	 *
2642
+	 * @return void
2643
+	 * @throws EE_Error
2644
+	 * @throws DomainException
2645
+	 */
2646
+	public function display_admin_page_with_sidebar()
2647
+	{
2648
+		$this->_display_admin_page(true);
2649
+	}
2650
+
2651
+
2652
+	/**
2653
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2654
+	 *
2655
+	 * @return void
2656
+	 * @throws EE_Error
2657
+	 * @throws DomainException
2658
+	 */
2659
+	public function display_admin_page_with_no_sidebar()
2660
+	{
2661
+		$this->_display_admin_page();
2662
+	}
2663
+
2664
+
2665
+	/**
2666
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2667
+	 *
2668
+	 * @return void
2669
+	 * @throws EE_Error
2670
+	 * @throws DomainException
2671
+	 */
2672
+	public function display_about_admin_page()
2673
+	{
2674
+		$this->_display_admin_page(false, true);
2675
+	}
2676
+
2677
+
2678
+	/**
2679
+	 * display_admin_page
2680
+	 * contains the code for actually displaying an admin page
2681
+	 *
2682
+	 * @param boolean $sidebar true with sidebar, false without
2683
+	 * @param boolean $about   use the about_admin_wrapper instead of the default.
2684
+	 * @return void
2685
+	 * @throws DomainException
2686
+	 * @throws EE_Error
2687
+	 */
2688
+	private function _display_admin_page($sidebar = false, $about = false)
2689
+	{
2690
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2691
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2692
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2693
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2694
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2695
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2696
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2697
+			? 'poststuff'
2698
+			: 'espresso-default-admin';
2699
+		$template_path                                     = $sidebar
2700
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2701
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2702
+		if ($this->request->isAjax()) {
2703
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2704
+		}
2705
+		$template_path                                     = ! empty($this->_column_template_path)
2706
+			? $this->_column_template_path : $template_path;
2707
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2708
+			? $this->_template_args['admin_page_content']
2709
+			: '';
2710
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2711
+			? $this->_template_args['before_admin_page_content']
2712
+			: '';
2713
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2714
+			? $this->_template_args['after_admin_page_content']
2715
+			: '';
2716
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2717
+			$template_path,
2718
+			$this->_template_args,
2719
+			true
2720
+		);
2721
+		// the final template wrapper
2722
+		$this->admin_page_wrapper($about);
2723
+	}
2724
+
2725
+
2726
+	/**
2727
+	 * This is used to display caf preview pages.
2728
+	 *
2729
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2730
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2731
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2732
+	 * @return void
2733
+	 * @throws DomainException
2734
+	 * @throws EE_Error
2735
+	 * @throws InvalidArgumentException
2736
+	 * @throws InvalidDataTypeException
2737
+	 * @throws InvalidInterfaceException
2738
+	 * @since 4.3.2
2739
+	 */
2740
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2741
+	{
2742
+		// let's generate a default preview action button if there isn't one already present.
2743
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2744
+			'Upgrade to Event Espresso 4 Right Now',
2745
+			'event_espresso'
2746
+		);
2747
+		$buy_now_url                                   = add_query_arg(
2748
+			[
2749
+				'ee_ver'       => 'ee4',
2750
+				'utm_source'   => 'ee4_plugin_admin',
2751
+				'utm_medium'   => 'link',
2752
+				'utm_campaign' => $utm_campaign_source,
2753
+				'utm_content'  => 'buy_now_button',
2754
+			],
2755
+			'https://eventespresso.com/pricing/'
2756
+		);
2757
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2758
+			? $this->get_action_link_or_button(
2759
+				'',
2760
+				'buy_now',
2761
+				[],
2762
+				'button-primary button-large',
2763
+				esc_url_raw($buy_now_url),
2764
+				true
2765
+			)
2766
+			: $this->_template_args['preview_action_button'];
2767
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2768
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2769
+			$this->_template_args,
2770
+			true
2771
+		);
2772
+		$this->_display_admin_page($display_sidebar);
2773
+	}
2774
+
2775
+
2776
+	/**
2777
+	 * display_admin_list_table_page_with_sidebar
2778
+	 * generates HTML wrapper for an admin_page with list_table
2779
+	 *
2780
+	 * @return void
2781
+	 * @throws EE_Error
2782
+	 * @throws DomainException
2783
+	 */
2784
+	public function display_admin_list_table_page_with_sidebar()
2785
+	{
2786
+		$this->_display_admin_list_table_page(true);
2787
+	}
2788
+
2789
+
2790
+	/**
2791
+	 * display_admin_list_table_page_with_no_sidebar
2792
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2793
+	 *
2794
+	 * @return void
2795
+	 * @throws EE_Error
2796
+	 * @throws DomainException
2797
+	 */
2798
+	public function display_admin_list_table_page_with_no_sidebar()
2799
+	{
2800
+		$this->_display_admin_list_table_page();
2801
+	}
2802
+
2803
+
2804
+	/**
2805
+	 * generates html wrapper for an admin_list_table page
2806
+	 *
2807
+	 * @param boolean $sidebar whether to display with sidebar or not.
2808
+	 * @return void
2809
+	 * @throws DomainException
2810
+	 * @throws EE_Error
2811
+	 */
2812
+	private function _display_admin_list_table_page($sidebar = false)
2813
+	{
2814
+		// setup search attributes
2815
+		$this->_set_search_attributes();
2816
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
2817
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2818
+		$this->_template_args['table_url']        = $this->request->isAjax()
2819
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2820
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2821
+		$this->_template_args['list_table']       = $this->_list_table_object;
2822
+		$this->_template_args['current_route']    = $this->_req_action;
2823
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2824
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2825
+		if (! empty($ajax_sorting_callback)) {
2826
+			$sortable_list_table_form_fields = wp_nonce_field(
2827
+				$ajax_sorting_callback . '_nonce',
2828
+				$ajax_sorting_callback . '_nonce',
2829
+				false,
2830
+				false
2831
+			);
2832
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2833
+												. $this->page_slug
2834
+												. '" />';
2835
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2836
+												. $ajax_sorting_callback
2837
+												. '" />';
2838
+		} else {
2839
+			$sortable_list_table_form_fields = '';
2840
+		}
2841
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2842
+		$hidden_form_fields                                      =
2843
+			isset($this->_template_args['list_table_hidden_fields'])
2844
+				? $this->_template_args['list_table_hidden_fields']
2845
+				: '';
2846
+		$nonce_ref                                               = $this->_req_action . '_nonce';
2847
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
2848
+																	. $nonce_ref
2849
+																	. '" value="'
2850
+																	. wp_create_nonce($nonce_ref)
2851
+																	. '">';
2852
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2853
+		// display message about search results?
2854
+		$search = $this->request->getRequestParam('s');
2855
+		$this->_template_args['before_list_table'] .= ! empty($search)
2856
+			? '<p class="ee-search-results">' . sprintf(
2857
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2858
+				trim($search, '%')
2859
+			) . '</p>'
2860
+			: '';
2861
+		// filter before_list_table template arg
2862
+		$this->_template_args['before_list_table'] = apply_filters(
2863
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2864
+			$this->_template_args['before_list_table'],
2865
+			$this->page_slug,
2866
+			$this->request->requestParams(),
2867
+			$this->_req_action
2868
+		);
2869
+		// convert to array and filter again
2870
+		// arrays are easier to inject new items in a specific location,
2871
+		// but would not be backwards compatible, so we have to add a new filter
2872
+		$this->_template_args['before_list_table'] = implode(
2873
+			" \n",
2874
+			(array) apply_filters(
2875
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2876
+				(array) $this->_template_args['before_list_table'],
2877
+				$this->page_slug,
2878
+				$this->request->requestParams(),
2879
+				$this->_req_action
2880
+			)
2881
+		);
2882
+		// filter after_list_table template arg
2883
+		$this->_template_args['after_list_table'] = apply_filters(
2884
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2885
+			$this->_template_args['after_list_table'],
2886
+			$this->page_slug,
2887
+			$this->request->requestParams(),
2888
+			$this->_req_action
2889
+		);
2890
+		// convert to array and filter again
2891
+		// arrays are easier to inject new items in a specific location,
2892
+		// but would not be backwards compatible, so we have to add a new filter
2893
+		$this->_template_args['after_list_table']   = implode(
2894
+			" \n",
2895
+			(array) apply_filters(
2896
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2897
+				(array) $this->_template_args['after_list_table'],
2898
+				$this->page_slug,
2899
+				$this->request->requestParams(),
2900
+				$this->_req_action
2901
+			)
2902
+		);
2903
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2904
+			$template_path,
2905
+			$this->_template_args,
2906
+			true
2907
+		);
2908
+		// the final template wrapper
2909
+		if ($sidebar) {
2910
+			$this->display_admin_page_with_sidebar();
2911
+		} else {
2912
+			$this->display_admin_page_with_no_sidebar();
2913
+		}
2914
+	}
2915
+
2916
+
2917
+	/**
2918
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2919
+	 * html string for the legend.
2920
+	 * $items are expected in an array in the following format:
2921
+	 * $legend_items = array(
2922
+	 *        'item_id' => array(
2923
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2924
+	 *            'desc' => esc_html__('localized description of item');
2925
+	 *        )
2926
+	 * );
2927
+	 *
2928
+	 * @param array $items see above for format of array
2929
+	 * @return string html string of legend
2930
+	 * @throws DomainException
2931
+	 */
2932
+	protected function _display_legend($items)
2933
+	{
2934
+		$this->_template_args['items'] = apply_filters(
2935
+			'FHEE__EE_Admin_Page___display_legend__items',
2936
+			(array) $items,
2937
+			$this
2938
+		);
2939
+		return EEH_Template::display_template(
2940
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2941
+			$this->_template_args,
2942
+			true
2943
+		);
2944
+	}
2945
+
2946
+
2947
+	/**
2948
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2949
+	 * The returned json object is created from an array in the following format:
2950
+	 * array(
2951
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2952
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
2953
+	 *  'notices' => '', // - contains any EE_Error formatted notices
2954
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
2955
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
2956
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
2957
+	 *  that might be included in here)
2958
+	 * )
2959
+	 * The json object is populated by whatever is set in the $_template_args property.
2960
+	 *
2961
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
2962
+	 *                                 instead of displayed.
2963
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
2964
+	 * @return void
2965
+	 * @throws EE_Error
2966
+	 */
2967
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
2968
+	{
2969
+		// make sure any EE_Error notices have been handled.
2970
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
2971
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
2972
+		unset($this->_template_args['data']);
2973
+		$json = [
2974
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2975
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2976
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2977
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2978
+			'notices'   => EE_Error::get_notices(),
2979
+			'content'   => isset($this->_template_args['admin_page_content'])
2980
+				? $this->_template_args['admin_page_content'] : '',
2981
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
2982
+			'isEEajax'  => true
2983
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2984
+		];
2985
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
2986
+		if (null === error_get_last() || ! headers_sent()) {
2987
+			header('Content-Type: application/json; charset=UTF-8');
2988
+		}
2989
+		echo wp_json_encode($json);
2990
+		exit();
2991
+	}
2992
+
2993
+
2994
+	/**
2995
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2996
+	 *
2997
+	 * @return void
2998
+	 * @throws EE_Error
2999
+	 */
3000
+	public function return_json()
3001
+	{
3002
+		if ($this->request->isAjax()) {
3003
+			$this->_return_json();
3004
+		} else {
3005
+			throw new EE_Error(
3006
+				sprintf(
3007
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3008
+					__FUNCTION__
3009
+				)
3010
+			);
3011
+		}
3012
+	}
3013
+
3014
+
3015
+	/**
3016
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3017
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3018
+	 *
3019
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3020
+	 */
3021
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3022
+	{
3023
+		$this->_hook_obj = $hook_obj;
3024
+	}
3025
+
3026
+
3027
+	/**
3028
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3029
+	 *
3030
+	 * @param boolean $about whether to use the special about page wrapper or default.
3031
+	 * @return void
3032
+	 * @throws DomainException
3033
+	 * @throws EE_Error
3034
+	 */
3035
+	public function admin_page_wrapper($about = false)
3036
+	{
3037
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3038
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3039
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3040
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3041
+
3042
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3043
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3044
+			isset($this->_template_args['before_admin_page_content'])
3045
+				? $this->_template_args['before_admin_page_content']
3046
+				: ''
3047
+		);
3048
+
3049
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3050
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3051
+			isset($this->_template_args['after_admin_page_content'])
3052
+				? $this->_template_args['after_admin_page_content']
3053
+				: ''
3054
+		);
3055
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3056
+
3057
+		if ($this->request->isAjax()) {
3058
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3059
+				// $template_path,
3060
+				EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3061
+				$this->_template_args,
3062
+				true
3063
+			);
3064
+			$this->_return_json();
3065
+		}
3066
+		// load settings page wrapper template
3067
+		$template_path = $about
3068
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3069
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3070
+
3071
+		EEH_Template::display_template($template_path, $this->_template_args);
3072
+	}
3073
+
3074
+
3075
+	/**
3076
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3077
+	 *
3078
+	 * @return string html
3079
+	 * @throws EE_Error
3080
+	 */
3081
+	protected function _get_main_nav_tabs()
3082
+	{
3083
+		// let's generate the html using the EEH_Tabbed_Content helper.
3084
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3085
+		// (rather than setting in the page_routes array)
3086
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3087
+	}
3088
+
3089
+
3090
+	/**
3091
+	 *        sort nav tabs
3092
+	 *
3093
+	 * @param $a
3094
+	 * @param $b
3095
+	 * @return int
3096
+	 */
3097
+	private function _sort_nav_tabs($a, $b)
3098
+	{
3099
+		if ($a['order'] === $b['order']) {
3100
+			return 0;
3101
+		}
3102
+		return ($a['order'] < $b['order']) ? -1 : 1;
3103
+	}
3104
+
3105
+
3106
+	/**
3107
+	 *    generates HTML for the forms used on admin pages
3108
+	 *
3109
+	 * @param array  $input_vars   - array of input field details
3110
+	 * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3111
+	 *                             use)
3112
+	 * @param bool   $id
3113
+	 * @return array|string
3114
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3115
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3116
+	 */
3117
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3118
+	{
3119
+		return $generator === 'string'
3120
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3121
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3122
+	}
3123
+
3124
+
3125
+	/**
3126
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3127
+	 *
3128
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3129
+	 *                                   Close" button.
3130
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3131
+	 *                                   'Save', [1] => 'save & close')
3132
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3133
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3134
+	 *                                   default actions by submitting some other value.
3135
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3136
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3137
+	 *                                   close (normal form handling).
3138
+	 */
3139
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3140
+	{
3141
+		// make sure $text and $actions are in an array
3142
+		$text          = (array) $text;
3143
+		$actions       = (array) $actions;
3144
+		$referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3145
+		$button_text   = ! empty($text)
3146
+			? $text
3147
+			: [
3148
+				esc_html__('Save', 'event_espresso'),
3149
+				esc_html__('Save and Close', 'event_espresso'),
3150
+			];
3151
+		$default_names = ['save', 'save_and_close'];
3152
+		$buttons = '';
3153
+		foreach ($button_text as $key => $button) {
3154
+			$ref     = $default_names[ $key ];
3155
+			$name    = ! empty($actions) ? $actions[ $key ] : $ref;
3156
+			$buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3157
+						. 'value="' . $button . '" name="' . $name . '" '
3158
+						. 'id="' . $this->_current_view . '_' . $ref . '" />';
3159
+			if (! $both) {
3160
+				break;
3161
+			}
3162
+		}
3163
+		// add in a hidden index for the current page (so save and close redirects properly)
3164
+		$buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3165
+				   . $referrer_url
3166
+				   . '" />';
3167
+		$this->_template_args['save_buttons'] = $buttons;
3168
+	}
3169
+
3170
+
3171
+	/**
3172
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3173
+	 *
3174
+	 * @param string $route
3175
+	 * @param array  $additional_hidden_fields
3176
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3177
+	 * @since 4.6.0
3178
+	 */
3179
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3180
+	{
3181
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3182
+	}
3183
+
3184
+
3185
+	/**
3186
+	 * set form open and close tags on add/edit pages.
3187
+	 *
3188
+	 * @param string $route                    the route you want the form to direct to
3189
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3190
+	 * @return void
3191
+	 */
3192
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3193
+	{
3194
+		if (empty($route)) {
3195
+			$user_msg = esc_html__(
3196
+				'An error occurred. No action was set for this page\'s form.',
3197
+				'event_espresso'
3198
+			);
3199
+			$dev_msg  = $user_msg . "\n"
3200
+						. sprintf(
3201
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3202
+							__FUNCTION__,
3203
+							__CLASS__
3204
+						);
3205
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3206
+		}
3207
+		// open form
3208
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3209
+															 . $this->_admin_base_url
3210
+															 . '" id="'
3211
+															 . $route
3212
+															 . '_event_form" >';
3213
+		// add nonce
3214
+		$nonce                                             =
3215
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3216
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3217
+		// add REQUIRED form action
3218
+		$hidden_fields = [
3219
+			'action' => ['type' => 'hidden', 'value' => $route],
3220
+		];
3221
+		// merge arrays
3222
+		$hidden_fields = is_array($additional_hidden_fields)
3223
+			? array_merge($hidden_fields, $additional_hidden_fields)
3224
+			: $hidden_fields;
3225
+		// generate form fields
3226
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3227
+		// add fields to form
3228
+		foreach ((array) $form_fields as $form_field) {
3229
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3230
+		}
3231
+		// close form
3232
+		$this->_template_args['after_admin_page_content'] = '</form>';
3233
+	}
3234
+
3235
+
3236
+	/**
3237
+	 * Public Wrapper for _redirect_after_action() method since its
3238
+	 * discovered it would be useful for external code to have access.
3239
+	 *
3240
+	 * @param bool   $success
3241
+	 * @param string $what
3242
+	 * @param string $action_desc
3243
+	 * @param array  $query_args
3244
+	 * @param bool   $override_overwrite
3245
+	 * @throws EE_Error
3246
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3247
+	 * @since 4.5.0
3248
+	 */
3249
+	public function redirect_after_action(
3250
+		$success = false,
3251
+		$what = 'item',
3252
+		$action_desc = 'processed',
3253
+		$query_args = [],
3254
+		$override_overwrite = false
3255
+	) {
3256
+		$this->_redirect_after_action(
3257
+			$success,
3258
+			$what,
3259
+			$action_desc,
3260
+			$query_args,
3261
+			$override_overwrite
3262
+		);
3263
+	}
3264
+
3265
+
3266
+	/**
3267
+	 * Helper method for merging existing request data with the returned redirect url.
3268
+	 *
3269
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3270
+	 * filters are still applied.
3271
+	 *
3272
+	 * @param array $new_route_data
3273
+	 * @return array
3274
+	 */
3275
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3276
+	{
3277
+		foreach ($this->request->requestParams() as $ref => $value) {
3278
+			// unset nonces
3279
+			if (strpos($ref, 'nonce') !== false) {
3280
+				$this->request->unSetRequestParam($ref);
3281
+				continue;
3282
+			}
3283
+			// urlencode values.
3284
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3285
+			$this->request->setRequestParam($ref, $value);
3286
+		}
3287
+		return array_merge($this->request->requestParams(), $new_route_data);
3288
+	}
3289
+
3290
+
3291
+	/**
3292
+	 *    _redirect_after_action
3293
+	 *
3294
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3295
+	 * @param string $what               - what the action was performed on
3296
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3297
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3298
+	 *                                   action is completed
3299
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3300
+	 *                                   override this so that they show.
3301
+	 * @return void
3302
+	 * @throws EE_Error
3303
+	 */
3304
+	protected function _redirect_after_action(
3305
+		$success = 0,
3306
+		$what = 'item',
3307
+		$action_desc = 'processed',
3308
+		$query_args = [],
3309
+		$override_overwrite = false
3310
+	) {
3311
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3312
+		// class name for actions/filters.
3313
+		$classname = get_class($this);
3314
+		// set redirect url.
3315
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3316
+		// otherwise we go with whatever is set as the _admin_base_url
3317
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3318
+		$notices      = EE_Error::get_notices(false);
3319
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3320
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3321
+			EE_Error::overwrite_success();
3322
+		}
3323
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3324
+			// how many records affected ? more than one record ? or just one ?
3325
+			if ($success > 1) {
3326
+				// set plural msg
3327
+				EE_Error::add_success(
3328
+					sprintf(
3329
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3330
+						$what,
3331
+						$action_desc
3332
+					),
3333
+					__FILE__,
3334
+					__FUNCTION__,
3335
+					__LINE__
3336
+				);
3337
+			} elseif ($success === 1) {
3338
+				// set singular msg
3339
+				EE_Error::add_success(
3340
+					sprintf(
3341
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3342
+						$what,
3343
+						$action_desc
3344
+					),
3345
+					__FILE__,
3346
+					__FUNCTION__,
3347
+					__LINE__
3348
+				);
3349
+			}
3350
+		}
3351
+		// check that $query_args isn't something crazy
3352
+		if (! is_array($query_args)) {
3353
+			$query_args = [];
3354
+		}
3355
+		/**
3356
+		 * Allow injecting actions before the query_args are modified for possible different
3357
+		 * redirections on save and close actions
3358
+		 *
3359
+		 * @param array $query_args       The original query_args array coming into the
3360
+		 *                                method.
3361
+		 * @since 4.2.0
3362
+		 */
3363
+		do_action(
3364
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3365
+			$query_args
3366
+		);
3367
+		// calculate where we're going (if we have a "save and close" button pushed)
3368
+
3369
+		if (
3370
+			$this->request->requestParamIsSet('save_and_close')
3371
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3372
+		) {
3373
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3374
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3375
+			// regenerate query args array from referrer URL
3376
+			parse_str($parsed_url['query'], $query_args);
3377
+			// correct page and action will be in the query args now
3378
+			$redirect_url = admin_url('admin.php');
3379
+		}
3380
+		// merge any default query_args set in _default_route_query_args property
3381
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3382
+			$args_to_merge = [];
3383
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3384
+				// is there a wp_referer array in our _default_route_query_args property?
3385
+				if ($query_param === 'wp_referer') {
3386
+					$query_value = (array) $query_value;
3387
+					foreach ($query_value as $reference => $value) {
3388
+						if (strpos($reference, 'nonce') !== false) {
3389
+							continue;
3390
+						}
3391
+						// finally we will override any arguments in the referer with
3392
+						// what might be set on the _default_route_query_args array.
3393
+						if (isset($this->_default_route_query_args[ $reference ])) {
3394
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3395
+						} else {
3396
+							$args_to_merge[ $reference ] = urlencode($value);
3397
+						}
3398
+					}
3399
+					continue;
3400
+				}
3401
+				$args_to_merge[ $query_param ] = $query_value;
3402
+			}
3403
+			// now let's merge these arguments but override with what was specifically sent in to the
3404
+			// redirect.
3405
+			$query_args = array_merge($args_to_merge, $query_args);
3406
+		}
3407
+		$this->_process_notices($query_args);
3408
+		// generate redirect url
3409
+		// if redirecting to anything other than the main page, add a nonce
3410
+		if (isset($query_args['action'])) {
3411
+			// manually generate wp_nonce and merge that with the query vars
3412
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3413
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3414
+		}
3415
+		// we're adding some hooks and filters in here for processing any things just before redirects
3416
+		// (example: an admin page has done an insert or update and we want to run something after that).
3417
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3418
+		$redirect_url = apply_filters(
3419
+			'FHEE_redirect_' . $classname . $this->_req_action,
3420
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3421
+			$query_args
3422
+		);
3423
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3424
+		if ($this->request->isAjax()) {
3425
+			$default_data                    = [
3426
+				'close'        => true,
3427
+				'redirect_url' => $redirect_url,
3428
+				'where'        => 'main',
3429
+				'what'         => 'append',
3430
+			];
3431
+			$this->_template_args['success'] = $success;
3432
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3433
+				$default_data,
3434
+				$this->_template_args['data']
3435
+			) : $default_data;
3436
+			$this->_return_json();
3437
+		}
3438
+		wp_safe_redirect($redirect_url);
3439
+		exit();
3440
+	}
3441
+
3442
+
3443
+	/**
3444
+	 * process any notices before redirecting (or returning ajax request)
3445
+	 * This method sets the $this->_template_args['notices'] attribute;
3446
+	 *
3447
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3448
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3449
+	 *                                  page_routes haven't been defined yet.
3450
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3451
+	 *                                  still save a transient for the notice.
3452
+	 * @return void
3453
+	 * @throws EE_Error
3454
+	 */
3455
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3456
+	{
3457
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3458
+		if ($this->request->isAjax()) {
3459
+			$notices = EE_Error::get_notices(false);
3460
+			if (empty($this->_template_args['success'])) {
3461
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3462
+			}
3463
+			if (empty($this->_template_args['errors'])) {
3464
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3465
+			}
3466
+			if (empty($this->_template_args['attention'])) {
3467
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3468
+			}
3469
+		}
3470
+		$this->_template_args['notices'] = EE_Error::get_notices();
3471
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3472
+		if (! $this->request->isAjax() || $sticky_notices) {
3473
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3474
+			$this->_add_transient(
3475
+				$route,
3476
+				$this->_template_args['notices'],
3477
+				true,
3478
+				$skip_route_verify
3479
+			);
3480
+		}
3481
+	}
3482
+
3483
+
3484
+	/**
3485
+	 * get_action_link_or_button
3486
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3487
+	 *
3488
+	 * @param string $action        use this to indicate which action the url is generated with.
3489
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3490
+	 *                              property.
3491
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3492
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3493
+	 * @param string $base_url      If this is not provided
3494
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3495
+	 *                              Otherwise this value will be used.
3496
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3497
+	 * @return string
3498
+	 * @throws InvalidArgumentException
3499
+	 * @throws InvalidInterfaceException
3500
+	 * @throws InvalidDataTypeException
3501
+	 * @throws EE_Error
3502
+	 */
3503
+	public function get_action_link_or_button(
3504
+		$action,
3505
+		$type = 'add',
3506
+		$extra_request = [],
3507
+		$class = 'button-primary',
3508
+		$base_url = '',
3509
+		$exclude_nonce = false
3510
+	) {
3511
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3512
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3513
+			throw new EE_Error(
3514
+				sprintf(
3515
+					esc_html__(
3516
+						'There is no page route for given action for the button.  This action was given: %s',
3517
+						'event_espresso'
3518
+					),
3519
+					$action
3520
+				)
3521
+			);
3522
+		}
3523
+		if (! isset($this->_labels['buttons'][ $type ])) {
3524
+			throw new EE_Error(
3525
+				sprintf(
3526
+					esc_html__(
3527
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3528
+						'event_espresso'
3529
+					),
3530
+					$type
3531
+				)
3532
+			);
3533
+		}
3534
+		// finally check user access for this button.
3535
+		$has_access = $this->check_user_access($action, true);
3536
+		if (! $has_access) {
3537
+			return '';
3538
+		}
3539
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3540
+		$query_args = [
3541
+			'action' => $action,
3542
+		];
3543
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3544
+		if (! empty($extra_request)) {
3545
+			$query_args = array_merge($extra_request, $query_args);
3546
+		}
3547
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3548
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3549
+	}
3550
+
3551
+
3552
+	/**
3553
+	 * _per_page_screen_option
3554
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3555
+	 *
3556
+	 * @return void
3557
+	 * @throws InvalidArgumentException
3558
+	 * @throws InvalidInterfaceException
3559
+	 * @throws InvalidDataTypeException
3560
+	 */
3561
+	protected function _per_page_screen_option()
3562
+	{
3563
+		$option = 'per_page';
3564
+		$args   = [
3565
+			'label'   => apply_filters(
3566
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3567
+				$this->_admin_page_title,
3568
+				$this
3569
+			),
3570
+			'default' => (int) apply_filters(
3571
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3572
+				20
3573
+			),
3574
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3575
+		];
3576
+		// ONLY add the screen option if the user has access to it.
3577
+		if ($this->check_user_access($this->_current_view, true)) {
3578
+			add_screen_option($option, $args);
3579
+		}
3580
+	}
3581
+
3582
+
3583
+	/**
3584
+	 * set_per_page_screen_option
3585
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3586
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3587
+	 * admin_menu.
3588
+	 *
3589
+	 * @return void
3590
+	 */
3591
+	private function _set_per_page_screen_options()
3592
+	{
3593
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3594
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3595
+			if (! $user = wp_get_current_user()) {
3596
+				return;
3597
+			}
3598
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3599
+			if (! $option) {
3600
+				return;
3601
+			}
3602
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3603
+			$map_option = $option;
3604
+			$option     = str_replace('-', '_', $option);
3605
+			switch ($map_option) {
3606
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3607
+					$max_value = apply_filters(
3608
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3609
+						999,
3610
+						$this->_current_page,
3611
+						$this->_current_view
3612
+					);
3613
+					if ($value < 1) {
3614
+						return;
3615
+					}
3616
+					$value = min($value, $max_value);
3617
+					break;
3618
+				default:
3619
+					$value = apply_filters(
3620
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3621
+						false,
3622
+						$option,
3623
+						$value
3624
+					);
3625
+					if (false === $value) {
3626
+						return;
3627
+					}
3628
+					break;
3629
+			}
3630
+			update_user_meta($user->ID, $option, $value);
3631
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3632
+			exit;
3633
+		}
3634
+	}
3635
+
3636
+
3637
+	/**
3638
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3639
+	 *
3640
+	 * @param array $data array that will be assigned to template args.
3641
+	 */
3642
+	public function set_template_args($data)
3643
+	{
3644
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3645
+	}
3646
+
3647
+
3648
+	/**
3649
+	 * This makes available the WP transient system for temporarily moving data between routes
3650
+	 *
3651
+	 * @param string $route             the route that should receive the transient
3652
+	 * @param array  $data              the data that gets sent
3653
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3654
+	 *                                  normal route transient.
3655
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3656
+	 *                                  when we are adding a transient before page_routes have been defined.
3657
+	 * @return void
3658
+	 * @throws EE_Error
3659
+	 */
3660
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3661
+	{
3662
+		$user_id = get_current_user_id();
3663
+		if (! $skip_route_verify) {
3664
+			$this->_verify_route($route);
3665
+		}
3666
+		// now let's set the string for what kind of transient we're setting
3667
+		$transient = $notices
3668
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3669
+			: 'rte_tx_' . $route . '_' . $user_id;
3670
+		$data      = $notices ? ['notices' => $data] : $data;
3671
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3672
+		$existing = is_multisite() && is_network_admin()
3673
+			? get_site_transient($transient)
3674
+			: get_transient($transient);
3675
+		if ($existing) {
3676
+			$data = array_merge((array) $data, (array) $existing);
3677
+		}
3678
+		if (is_multisite() && is_network_admin()) {
3679
+			set_site_transient($transient, $data, 8);
3680
+		} else {
3681
+			set_transient($transient, $data, 8);
3682
+		}
3683
+	}
3684
+
3685
+
3686
+	/**
3687
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3688
+	 *
3689
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3690
+	 * @param string $route
3691
+	 * @return mixed data
3692
+	 */
3693
+	protected function _get_transient($notices = false, $route = '')
3694
+	{
3695
+		$user_id   = get_current_user_id();
3696
+		$route     = ! $route ? $this->_req_action : $route;
3697
+		$transient = $notices
3698
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3699
+			: 'rte_tx_' . $route . '_' . $user_id;
3700
+		$data      = is_multisite() && is_network_admin()
3701
+			? get_site_transient($transient)
3702
+			: get_transient($transient);
3703
+		// delete transient after retrieval (just in case it hasn't expired);
3704
+		if (is_multisite() && is_network_admin()) {
3705
+			delete_site_transient($transient);
3706
+		} else {
3707
+			delete_transient($transient);
3708
+		}
3709
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3710
+	}
3711
+
3712
+
3713
+	/**
3714
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3715
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3716
+	 * default route callback on the EE_Admin page you want it run.)
3717
+	 *
3718
+	 * @return void
3719
+	 */
3720
+	protected function _transient_garbage_collection()
3721
+	{
3722
+		global $wpdb;
3723
+		// retrieve all existing transients
3724
+		$query =
3725
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3726
+		if ($results = $wpdb->get_results($query)) {
3727
+			foreach ($results as $result) {
3728
+				$transient = str_replace('_transient_', '', $result->option_name);
3729
+				get_transient($transient);
3730
+				if (is_multisite() && is_network_admin()) {
3731
+					get_site_transient($transient);
3732
+				}
3733
+			}
3734
+		}
3735
+	}
3736
+
3737
+
3738
+	/**
3739
+	 * get_view
3740
+	 *
3741
+	 * @return string content of _view property
3742
+	 */
3743
+	public function get_view()
3744
+	{
3745
+		return $this->_view;
3746
+	}
3747
+
3748
+
3749
+	/**
3750
+	 * getter for the protected $_views property
3751
+	 *
3752
+	 * @return array
3753
+	 */
3754
+	public function get_views()
3755
+	{
3756
+		return $this->_views;
3757
+	}
3758
+
3759
+
3760
+	/**
3761
+	 * get_current_page
3762
+	 *
3763
+	 * @return string _current_page property value
3764
+	 */
3765
+	public function get_current_page()
3766
+	{
3767
+		return $this->_current_page;
3768
+	}
3769
+
3770
+
3771
+	/**
3772
+	 * get_current_view
3773
+	 *
3774
+	 * @return string _current_view property value
3775
+	 */
3776
+	public function get_current_view()
3777
+	{
3778
+		return $this->_current_view;
3779
+	}
3780
+
3781
+
3782
+	/**
3783
+	 * get_current_screen
3784
+	 *
3785
+	 * @return object The current WP_Screen object
3786
+	 */
3787
+	public function get_current_screen()
3788
+	{
3789
+		return $this->_current_screen;
3790
+	}
3791
+
3792
+
3793
+	/**
3794
+	 * get_current_page_view_url
3795
+	 *
3796
+	 * @return string This returns the url for the current_page_view.
3797
+	 */
3798
+	public function get_current_page_view_url()
3799
+	{
3800
+		return $this->_current_page_view_url;
3801
+	}
3802
+
3803
+
3804
+	/**
3805
+	 * just returns the Request
3806
+	 *
3807
+	 * @return RequestInterface
3808
+	 */
3809
+	public function get_request()
3810
+	{
3811
+		return $this->request;
3812
+	}
3813
+
3814
+
3815
+	/**
3816
+	 * just returns the _req_data property
3817
+	 *
3818
+	 * @return array
3819
+	 */
3820
+	public function get_request_data()
3821
+	{
3822
+		return $this->request->requestParams();
3823
+	}
3824
+
3825
+
3826
+	/**
3827
+	 * returns the _req_data protected property
3828
+	 *
3829
+	 * @return string
3830
+	 */
3831
+	public function get_req_action()
3832
+	{
3833
+		return $this->_req_action;
3834
+	}
3835
+
3836
+
3837
+	/**
3838
+	 * @return bool  value of $_is_caf property
3839
+	 */
3840
+	public function is_caf()
3841
+	{
3842
+		return $this->_is_caf;
3843
+	}
3844
+
3845
+
3846
+	/**
3847
+	 * @return mixed
3848
+	 */
3849
+	public function default_espresso_metaboxes()
3850
+	{
3851
+		return $this->_default_espresso_metaboxes;
3852
+	}
3853
+
3854
+
3855
+	/**
3856
+	 * @return mixed
3857
+	 */
3858
+	public function admin_base_url()
3859
+	{
3860
+		return $this->_admin_base_url;
3861
+	}
3862
+
3863
+
3864
+	/**
3865
+	 * @return mixed
3866
+	 */
3867
+	public function wp_page_slug()
3868
+	{
3869
+		return $this->_wp_page_slug;
3870
+	}
3871
+
3872
+
3873
+	/**
3874
+	 * updates  espresso configuration settings
3875
+	 *
3876
+	 * @param string                   $tab
3877
+	 * @param EE_Config_Base|EE_Config $config
3878
+	 * @param string                   $file file where error occurred
3879
+	 * @param string                   $func function  where error occurred
3880
+	 * @param string                   $line line no where error occurred
3881
+	 * @return boolean
3882
+	 */
3883
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3884
+	{
3885
+		// remove any options that are NOT going to be saved with the config settings.
3886
+		if (isset($config->core->ee_ueip_optin)) {
3887
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3888
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3889
+			update_option('ee_ueip_has_notified', true);
3890
+		}
3891
+		// and save it (note we're also doing the network save here)
3892
+		$net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3893
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3894
+		if ($config_saved && $net_saved) {
3895
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3896
+			return true;
3897
+		}
3898
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3899
+		return false;
3900
+	}
3901
+
3902
+
3903
+	/**
3904
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3905
+	 *
3906
+	 * @return array
3907
+	 */
3908
+	public function get_yes_no_values()
3909
+	{
3910
+		return $this->_yes_no_values;
3911
+	}
3912
+
3913
+
3914
+	protected function _get_dir()
3915
+	{
3916
+		$reflector = new ReflectionClass(get_class($this));
3917
+		return dirname($reflector->getFileName());
3918
+	}
3919
+
3920
+
3921
+	/**
3922
+	 * A helper for getting a "next link".
3923
+	 *
3924
+	 * @param string $url   The url to link to
3925
+	 * @param string $class The class to use.
3926
+	 * @return string
3927
+	 */
3928
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3929
+	{
3930
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3931
+	}
3932
+
3933
+
3934
+	/**
3935
+	 * A helper for getting a "previous link".
3936
+	 *
3937
+	 * @param string $url   The url to link to
3938
+	 * @param string $class The class to use.
3939
+	 * @return string
3940
+	 */
3941
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3942
+	{
3943
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3944
+	}
3945
+
3946
+
3947
+
3948
+
3949
+
3950
+
3951
+
3952
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3953
+
3954
+
3955
+	/**
3956
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3957
+	 * 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
3958
+	 * _req_data array.
3959
+	 *
3960
+	 * @return bool success/fail
3961
+	 * @throws EE_Error
3962
+	 * @throws InvalidArgumentException
3963
+	 * @throws ReflectionException
3964
+	 * @throws InvalidDataTypeException
3965
+	 * @throws InvalidInterfaceException
3966
+	 */
3967
+	protected function _process_resend_registration()
3968
+	{
3969
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3970
+		do_action(
3971
+			'AHEE__EE_Admin_Page___process_resend_registration',
3972
+			$this->_template_args['success'],
3973
+			$this->request->requestParams()
3974
+		);
3975
+		return $this->_template_args['success'];
3976
+	}
3977
+
3978
+
3979
+	/**
3980
+	 * This automatically processes any payment message notifications when manual payment has been applied.
3981
+	 *
3982
+	 * @param EE_Payment $payment
3983
+	 * @return bool success/fail
3984
+	 */
3985
+	protected function _process_payment_notification(EE_Payment $payment)
3986
+	{
3987
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3988
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3989
+		$this->_template_args['success'] = apply_filters(
3990
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3991
+			false,
3992
+			$payment
3993
+		);
3994
+		return $this->_template_args['success'];
3995
+	}
3996 3996
 }
Please login to merge, or discard this patch.
Spacing   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
         $ee_menu_slugs = (array) $ee_menu_slugs;
514 514
         if (
515 515
             ! $this->request->isAjax()
516
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
516
+            && ( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))
517 517
         ) {
518 518
             return;
519 519
         }
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
             : $req_action;
534 534
 
535 535
         $this->_current_view = $this->_req_action;
536
-        $this->_req_nonce    = $this->_req_action . '_nonce';
536
+        $this->_req_nonce    = $this->_req_action.'_nonce';
537 537
         $this->_define_page_props();
538 538
         $this->_current_page_view_url = add_query_arg(
539 539
             ['page' => $this->_current_page, 'action' => $this->_current_view],
@@ -570,21 +570,21 @@  discard block
 block discarded – undo
570 570
         }
571 571
         // filter routes and page_config so addons can add their stuff. Filtering done per class
572 572
         $this->_page_routes = apply_filters(
573
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
573
+            'FHEE__'.get_class($this).'__page_setup__page_routes',
574 574
             $this->_page_routes,
575 575
             $this
576 576
         );
577 577
         $this->_page_config = apply_filters(
578
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
578
+            'FHEE__'.get_class($this).'__page_setup__page_config',
579 579
             $this->_page_config,
580 580
             $this
581 581
         );
582 582
         // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
583 583
         // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
584
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
584
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
585 585
             add_action(
586 586
                 'AHEE__EE_Admin_Page__route_admin_request',
587
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
587
+                [$this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view],
588 588
                 10,
589 589
                 2
590 590
             );
@@ -597,8 +597,8 @@  discard block
 block discarded – undo
597 597
             if ($this->_is_UI_request) {
598 598
                 // admin_init stuff - global, all views for this page class, specific view
599 599
                 add_action('admin_init', [$this, 'admin_init'], 10);
600
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
601
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
600
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
601
+                    add_action('admin_init', [$this, 'admin_init_'.$this->_current_view], 15);
602 602
                 }
603 603
             } else {
604 604
                 // hijack regular WP loading and route admin request immediately
@@ -617,12 +617,12 @@  discard block
 block discarded – undo
617 617
      */
618 618
     private function _do_other_page_hooks()
619 619
     {
620
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
620
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, []);
621 621
         foreach ($registered_pages as $page) {
622 622
             // now let's setup the file name and class that should be present
623 623
             $classname = str_replace('.class.php', '', $page);
624 624
             // autoloaders should take care of loading file
625
-            if (! class_exists($classname)) {
625
+            if ( ! class_exists($classname)) {
626 626
                 $error_msg[] = sprintf(
627 627
                     esc_html__(
628 628
                         'Something went wrong with loading the %s admin hooks page.',
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
                                    ),
640 640
                                    $page,
641 641
                                    '<br />',
642
-                                   '<strong>' . $classname . '</strong>'
642
+                                   '<strong>'.$classname.'</strong>'
643 643
                                );
644 644
                 throw new EE_Error(implode('||', $error_msg));
645 645
             }
@@ -681,13 +681,13 @@  discard block
 block discarded – undo
681 681
         // load admin_notices - global, page class, and view specific
682 682
         add_action('admin_notices', [$this, 'admin_notices_global'], 5);
683 683
         add_action('admin_notices', [$this, 'admin_notices'], 10);
684
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
685
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
684
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
685
+            add_action('admin_notices', [$this, 'admin_notices_'.$this->_current_view], 15);
686 686
         }
687 687
         // load network admin_notices - global, page class, and view specific
688 688
         add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
689
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
690
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
689
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
690
+            add_action('network_admin_notices', [$this, 'network_admin_notices_'.$this->_current_view]);
691 691
         }
692 692
         // this will save any per_page screen options if they are present
693 693
         $this->_set_per_page_screen_options();
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
     protected function _verify_routes()
809 809
     {
810 810
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
811
-        if (! $this->_current_page && ! $this->request->isAjax()) {
811
+        if ( ! $this->_current_page && ! $this->request->isAjax()) {
812 812
             return false;
813 813
         }
814 814
         $this->_route = false;
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
                 $this->_admin_page_title
821 821
             );
822 822
             // developer error msg
823
-            $error_msg .= '||' . $error_msg
823
+            $error_msg .= '||'.$error_msg
824 824
                           . esc_html__(
825 825
                               ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
826 826
                               'event_espresso'
@@ -829,9 +829,9 @@  discard block
 block discarded – undo
829 829
         }
830 830
         // and that the requested page route exists
831 831
         if (array_key_exists($this->_req_action, $this->_page_routes)) {
832
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
833
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
834
-                ? $this->_page_config[ $this->_req_action ]
832
+            $this->_route        = $this->_page_routes[$this->_req_action];
833
+            $this->_route_config = isset($this->_page_config[$this->_req_action])
834
+                ? $this->_page_config[$this->_req_action]
835 835
                 : [];
836 836
         } else {
837 837
             // user error msg
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
                 $this->_admin_page_title
844 844
             );
845 845
             // developer error msg
846
-            $error_msg .= '||' . $error_msg
846
+            $error_msg .= '||'.$error_msg
847 847
                           . sprintf(
848 848
                               esc_html__(
849 849
                                   ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
             throw new EE_Error($error_msg);
855 855
         }
856 856
         // and that a default route exists
857
-        if (! array_key_exists('default', $this->_page_routes)) {
857
+        if ( ! array_key_exists('default', $this->_page_routes)) {
858 858
             // user error msg
859 859
             $error_msg = sprintf(
860 860
                 esc_html__(
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
                 $this->_admin_page_title
865 865
             );
866 866
             // developer error msg
867
-            $error_msg .= '||' . $error_msg
867
+            $error_msg .= '||'.$error_msg
868 868
                           . esc_html__(
869 869
                               ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
870 870
                               'event_espresso'
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
             $this->_admin_page_title
906 906
         );
907 907
         // developer error msg
908
-        $error_msg .= '||' . $error_msg
908
+        $error_msg .= '||'.$error_msg
909 909
                       . sprintf(
910 910
                           esc_html__(
911 911
                               ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
     protected function _verify_nonce($nonce, $nonce_ref)
931 931
     {
932 932
         // verify nonce against expected value
933
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
933
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
934 934
             // these are not the droids you are looking for !!!
935 935
             $msg = sprintf(
936 936
                 esc_html__('%sNonce Fail.%s', 'event_espresso'),
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
                     __CLASS__
948 948
                 );
949 949
             }
950
-            if (! $this->request->isAjax()) {
950
+            if ( ! $this->request->isAjax()) {
951 951
                 wp_die($msg);
952 952
             }
953 953
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
      */
972 972
     protected function _route_admin_request()
973 973
     {
974
-        if (! $this->_is_UI_request) {
974
+        if ( ! $this->_is_UI_request) {
975 975
             $this->_verify_routes();
976 976
         }
977 977
         $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
         $error_msg = '';
992 992
         // action right before calling route
993 993
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
994
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
994
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
995 995
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
996 996
         }
997 997
         // right before calling the route, let's clean the _wp_http_referer
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
                 wp_unslash($this->request->getServerParam('REQUEST_URI'))
1003 1003
             )
1004 1004
         );
1005
-        if (! empty($func)) {
1005
+        if ( ! empty($func)) {
1006 1006
             if (is_array($func)) {
1007 1007
                 list($class, $method) = $func;
1008 1008
             } elseif (strpos($func, '::') !== false) {
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
                 $class  = $this;
1012 1012
                 $method = $func;
1013 1013
             }
1014
-            if (! (is_object($class) && $class === $this)) {
1014
+            if ( ! (is_object($class) && $class === $this)) {
1015 1015
                 // send along this admin page object for access by addons.
1016 1016
                 $args['admin_page_object'] = $this;
1017 1017
             }
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
                     $method
1053 1053
                 );
1054 1054
             }
1055
-            if (! empty($error_msg)) {
1055
+            if ( ! empty($error_msg)) {
1056 1056
                 throw new EE_Error($error_msg);
1057 1057
             }
1058 1058
         }
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
                 if (strpos($key, 'nonce') !== false) {
1138 1138
                     continue;
1139 1139
                 }
1140
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1140
+                $args['wp_referer['.$key.']'] = is_string($value) ? htmlspecialchars($value) : $value;
1141 1141
             }
1142 1142
         }
1143 1143
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1176,12 +1176,12 @@  discard block
 block discarded – undo
1176 1176
      */
1177 1177
     protected function _add_help_tabs()
1178 1178
     {
1179
-        if (isset($this->_page_config[ $this->_req_action ])) {
1180
-            $config = $this->_page_config[ $this->_req_action ];
1179
+        if (isset($this->_page_config[$this->_req_action])) {
1180
+            $config = $this->_page_config[$this->_req_action];
1181 1181
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1182 1182
             if (is_array($config) && isset($config['help_sidebar'])) {
1183 1183
                 // check that the callback given is valid
1184
-                if (! method_exists($this, $config['help_sidebar'])) {
1184
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1185 1185
                     throw new EE_Error(
1186 1186
                         sprintf(
1187 1187
                             esc_html__(
@@ -1194,18 +1194,18 @@  discard block
 block discarded – undo
1194 1194
                     );
1195 1195
                 }
1196 1196
                 $content = apply_filters(
1197
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1197
+                    'FHEE__'.get_class($this).'__add_help_tabs__help_sidebar',
1198 1198
                     $this->{$config['help_sidebar']}()
1199 1199
                 );
1200 1200
                 $this->_current_screen->set_help_sidebar($content);
1201 1201
             }
1202
-            if (! isset($config['help_tabs'])) {
1202
+            if ( ! isset($config['help_tabs'])) {
1203 1203
                 return;
1204 1204
             } //no help tabs for this route
1205 1205
             foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1206 1206
                 // we're here so there ARE help tabs!
1207 1207
                 // make sure we've got what we need
1208
-                if (! isset($cfg['title'])) {
1208
+                if ( ! isset($cfg['title'])) {
1209 1209
                     throw new EE_Error(
1210 1210
                         esc_html__(
1211 1211
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
                         )
1214 1214
                     );
1215 1215
                 }
1216
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1216
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1217 1217
                     throw new EE_Error(
1218 1218
                         esc_html__(
1219 1219
                             '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',
@@ -1222,11 +1222,11 @@  discard block
 block discarded – undo
1222 1222
                     );
1223 1223
                 }
1224 1224
                 // first priority goes to content.
1225
-                if (! empty($cfg['content'])) {
1225
+                if ( ! empty($cfg['content'])) {
1226 1226
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1227 1227
                     // second priority goes to filename
1228
-                } elseif (! empty($cfg['filename'])) {
1229
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1228
+                } elseif ( ! empty($cfg['filename'])) {
1229
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1230 1230
                     // 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)
1231 1231
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1232 1232
                                                              . basename($this->_get_dir())
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
                                                              . $cfg['filename']
1235 1235
                                                              . '.help_tab.php' : $file_path;
1236 1236
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1237
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1237
+                    if ( ! isset($cfg['callback']) && ! is_readable($file_path)) {
1238 1238
                         EE_Error::add_error(
1239 1239
                             sprintf(
1240 1240
                                 esc_html__(
@@ -1282,7 +1282,7 @@  discard block
 block discarded – undo
1282 1282
                     return;
1283 1283
                 }
1284 1284
                 // setup config array for help tab method
1285
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1285
+                $id  = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1286 1286
                 $_ht = [
1287 1287
                     'id'       => $id,
1288 1288
                     'title'    => $cfg['title'],
@@ -1306,8 +1306,8 @@  discard block
 block discarded – undo
1306 1306
             $qtips = (array) $this->_route_config['qtips'];
1307 1307
             // load qtip loader
1308 1308
             $path = [
1309
-                $this->_get_dir() . '/qtips/',
1310
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1309
+                $this->_get_dir().'/qtips/',
1310
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1311 1311
             ];
1312 1312
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1313 1313
         }
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1330 1330
         $i = 0;
1331 1331
         foreach ($this->_page_config as $slug => $config) {
1332
-            if (! is_array($config) || empty($config['nav'])) {
1332
+            if ( ! is_array($config) || empty($config['nav'])) {
1333 1333
                 continue;
1334 1334
             }
1335 1335
             // no nav tab for this config
@@ -1338,12 +1338,12 @@  discard block
 block discarded – undo
1338 1338
                 // nav tab is only to appear when route requested.
1339 1339
                 continue;
1340 1340
             }
1341
-            if (! $this->check_user_access($slug, true)) {
1341
+            if ( ! $this->check_user_access($slug, true)) {
1342 1342
                 // no nav tab because current user does not have access.
1343 1343
                 continue;
1344 1344
             }
1345
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1346
-            $this->_nav_tabs[ $slug ] = [
1345
+            $css_class                = isset($config['css_class']) ? $config['css_class'].' ' : '';
1346
+            $this->_nav_tabs[$slug] = [
1347 1347
                 'url'       => isset($config['nav']['url'])
1348 1348
                     ? $config['nav']['url']
1349 1349
                     : self::add_query_args_and_nonce(
@@ -1355,14 +1355,14 @@  discard block
 block discarded – undo
1355 1355
                     : ucwords(
1356 1356
                         str_replace('_', ' ', $slug)
1357 1357
                     ),
1358
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1358
+                'css_class' => $this->_req_action === $slug ? $css_class.'nav-tab-active' : $css_class,
1359 1359
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1360 1360
             ];
1361 1361
             $i++;
1362 1362
         }
1363 1363
         // if $this->_nav_tabs is empty then lets set the default
1364 1364
         if (empty($this->_nav_tabs)) {
1365
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1365
+            $this->_nav_tabs[$this->_default_nav_tab_name] = [
1366 1366
                 'url'       => $this->_admin_base_url,
1367 1367
                 'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1368 1368
                 'css_class' => 'nav-tab-active',
@@ -1387,10 +1387,10 @@  discard block
 block discarded – undo
1387 1387
             foreach ($this->_route_config['labels'] as $label => $text) {
1388 1388
                 if (is_array($text)) {
1389 1389
                     foreach ($text as $sublabel => $subtext) {
1390
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1390
+                        $this->_labels[$label][$sublabel] = $subtext;
1391 1391
                     }
1392 1392
                 } else {
1393
-                    $this->_labels[ $label ] = $text;
1393
+                    $this->_labels[$label] = $text;
1394 1394
                 }
1395 1395
             }
1396 1396
         }
@@ -1412,12 +1412,12 @@  discard block
 block discarded – undo
1412 1412
     {
1413 1413
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1414 1414
         $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1415
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1415
+        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1416 1416
                           && is_array(
1417
-                              $this->_page_routes[ $route_to_check ]
1417
+                              $this->_page_routes[$route_to_check]
1418 1418
                           )
1419
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1420
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1419
+                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1420
+            ? $this->_page_routes[$route_to_check]['capability'] : null;
1421 1421
         if (empty($capability) && empty($route_to_check)) {
1422 1422
             $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1423 1423
                 : $this->_route['capability'];
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
         ';
1538 1538
 
1539 1539
         // current set timezone for timezone js
1540
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1540
+        echo '<span id="current_timezone" class="hidden">'.esc_html(EEH_DTT_Helper::get_timezone()).'</span>';
1541 1541
     }
1542 1542
 
1543 1543
 
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
         // loop through the array and setup content
1572 1572
         foreach ($help_array as $trigger => $help) {
1573 1573
             // make sure the array is setup properly
1574
-            if (! isset($help['title']) || ! isset($help['content'])) {
1574
+            if ( ! isset($help['title']) || ! isset($help['content'])) {
1575 1575
                 throw new EE_Error(
1576 1576
                     esc_html__(
1577 1577
                         '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',
@@ -1585,8 +1585,8 @@  discard block
 block discarded – undo
1585 1585
                 'help_popup_title'   => $help['title'],
1586 1586
                 'help_popup_content' => $help['content'],
1587 1587
             ];
1588
-            $content       .= EEH_Template::display_template(
1589
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1588
+            $content .= EEH_Template::display_template(
1589
+                EE_ADMIN_TEMPLATE.'admin_help_popup.template.php',
1590 1590
                 $template_args,
1591 1591
                 true
1592 1592
             );
@@ -1608,15 +1608,15 @@  discard block
 block discarded – undo
1608 1608
     private function _get_help_content()
1609 1609
     {
1610 1610
         // what is the method we're looking for?
1611
-        $method_name = '_help_popup_content_' . $this->_req_action;
1611
+        $method_name = '_help_popup_content_'.$this->_req_action;
1612 1612
         // if method doesn't exist let's get out.
1613
-        if (! method_exists($this, $method_name)) {
1613
+        if ( ! method_exists($this, $method_name)) {
1614 1614
             return [];
1615 1615
         }
1616 1616
         // k we're good to go let's retrieve the help array
1617 1617
         $help_array = call_user_func([$this, $method_name]);
1618 1618
         // make sure we've got an array!
1619
-        if (! is_array($help_array)) {
1619
+        if ( ! is_array($help_array)) {
1620 1620
             throw new EE_Error(
1621 1621
                 esc_html__(
1622 1622
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1648,15 +1648,15 @@  discard block
 block discarded – undo
1648 1648
         // 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
1649 1649
         $help_array   = $this->_get_help_content();
1650 1650
         $help_content = '';
1651
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1652
-            $help_array[ $trigger_id ] = [
1651
+        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1652
+            $help_array[$trigger_id] = [
1653 1653
                 'title'   => esc_html__('Missing Content', 'event_espresso'),
1654 1654
                 'content' => esc_html__(
1655 1655
                     '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.)',
1656 1656
                     'event_espresso'
1657 1657
                 ),
1658 1658
             ];
1659
-            $help_content              = $this->_set_help_popup_content($help_array);
1659
+            $help_content = $this->_set_help_popup_content($help_array);
1660 1660
         }
1661 1661
         // let's setup the trigger
1662 1662
         $content = '<a class="ee-dialog" href="?height='
@@ -1724,15 +1724,15 @@  discard block
 block discarded – undo
1724 1724
         // register all styles
1725 1725
         wp_register_style(
1726 1726
             'espresso-ui-theme',
1727
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1727
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1728 1728
             [],
1729 1729
             EVENT_ESPRESSO_VERSION
1730 1730
         );
1731
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1731
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1732 1732
         // helpers styles
1733 1733
         wp_register_style(
1734 1734
             'ee-text-links',
1735
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1735
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css',
1736 1736
             [],
1737 1737
             EVENT_ESPRESSO_VERSION
1738 1738
         );
@@ -1740,21 +1740,21 @@  discard block
 block discarded – undo
1740 1740
         // register all scripts
1741 1741
         wp_register_script(
1742 1742
             'ee-dialog',
1743
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1743
+            EE_ADMIN_URL.'assets/ee-dialog-helper.js',
1744 1744
             ['jquery', 'jquery-ui-draggable'],
1745 1745
             EVENT_ESPRESSO_VERSION,
1746 1746
             true
1747 1747
         );
1748 1748
         wp_register_script(
1749 1749
             'ee_admin_js',
1750
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1750
+            EE_ADMIN_URL.'assets/ee-admin-page.js',
1751 1751
             ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1752 1752
             EVENT_ESPRESSO_VERSION,
1753 1753
             true
1754 1754
         );
1755 1755
         wp_register_script(
1756 1756
             'jquery-ui-timepicker-addon',
1757
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1757
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js',
1758 1758
             ['jquery-ui-datepicker', 'jquery-ui-slider'],
1759 1759
             EVENT_ESPRESSO_VERSION,
1760 1760
             true
@@ -1762,7 +1762,7 @@  discard block
 block discarded – undo
1762 1762
         // script for sorting tables
1763 1763
         wp_register_script(
1764 1764
             'espresso_ajax_table_sorting',
1765
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1765
+            EE_ADMIN_URL.'assets/espresso_ajax_table_sorting.js',
1766 1766
             ['ee_admin_js', 'jquery-ui-sortable'],
1767 1767
             EVENT_ESPRESSO_VERSION,
1768 1768
             true
@@ -1770,7 +1770,7 @@  discard block
 block discarded – undo
1770 1770
         // script for parsing uri's
1771 1771
         wp_register_script(
1772 1772
             'ee-parse-uri',
1773
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1773
+            EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js',
1774 1774
             [],
1775 1775
             EVENT_ESPRESSO_VERSION,
1776 1776
             true
@@ -1778,7 +1778,7 @@  discard block
 block discarded – undo
1778 1778
         // and parsing associative serialized form elements
1779 1779
         wp_register_script(
1780 1780
             'ee-serialize-full-array',
1781
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1781
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js',
1782 1782
             ['jquery'],
1783 1783
             EVENT_ESPRESSO_VERSION,
1784 1784
             true
@@ -1786,28 +1786,28 @@  discard block
 block discarded – undo
1786 1786
         // helpers scripts
1787 1787
         wp_register_script(
1788 1788
             'ee-text-links',
1789
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1789
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js',
1790 1790
             ['jquery'],
1791 1791
             EVENT_ESPRESSO_VERSION,
1792 1792
             true
1793 1793
         );
1794 1794
         wp_register_script(
1795 1795
             'ee-moment-core',
1796
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1796
+            EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js',
1797 1797
             [],
1798 1798
             EVENT_ESPRESSO_VERSION,
1799 1799
             true
1800 1800
         );
1801 1801
         wp_register_script(
1802 1802
             'ee-moment',
1803
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1803
+            EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js',
1804 1804
             ['ee-moment-core'],
1805 1805
             EVENT_ESPRESSO_VERSION,
1806 1806
             true
1807 1807
         );
1808 1808
         wp_register_script(
1809 1809
             'ee-datepicker',
1810
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1810
+            EE_ADMIN_URL.'assets/ee-datepicker.js',
1811 1811
             ['jquery-ui-timepicker-addon', 'ee-moment'],
1812 1812
             EVENT_ESPRESSO_VERSION,
1813 1813
             true
@@ -1840,7 +1840,7 @@  discard block
 block discarded – undo
1840 1840
         wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1841 1841
         add_filter(
1842 1842
             'admin_body_class',
1843
-            function ($classes) {
1843
+            function($classes) {
1844 1844
                 if (strpos($classes, 'espresso-admin') === false) {
1845 1845
                     $classes .= ' espresso-admin';
1846 1846
                 }
@@ -1928,12 +1928,12 @@  discard block
 block discarded – undo
1928 1928
     protected function _set_list_table()
1929 1929
     {
1930 1930
         // first is this a list_table view?
1931
-        if (! isset($this->_route_config['list_table'])) {
1931
+        if ( ! isset($this->_route_config['list_table'])) {
1932 1932
             return;
1933 1933
         } //not a list_table view so get out.
1934 1934
         // list table functions are per view specific (because some admin pages might have more than one list table!)
1935
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
1936
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1935
+        $list_table_view = '_set_list_table_views_'.$this->_req_action;
1936
+        if ( ! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1937 1937
             // user error msg
1938 1938
             $error_msg = esc_html__(
1939 1939
                 'An error occurred. The requested list table views could not be found.',
@@ -1953,10 +1953,10 @@  discard block
 block discarded – undo
1953 1953
         }
1954 1954
         // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1955 1955
         $this->_views = apply_filters(
1956
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1956
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
1957 1957
             $this->_views
1958 1958
         );
1959
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1959
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
1960 1960
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1961 1961
         $this->_set_list_table_view();
1962 1962
         $this->_set_list_table_object();
@@ -1991,7 +1991,7 @@  discard block
 block discarded – undo
1991 1991
     protected function _set_list_table_object()
1992 1992
     {
1993 1993
         if (isset($this->_route_config['list_table'])) {
1994
-            if (! class_exists($this->_route_config['list_table'])) {
1994
+            if ( ! class_exists($this->_route_config['list_table'])) {
1995 1995
                 throw new EE_Error(
1996 1996
                     sprintf(
1997 1997
                         esc_html__(
@@ -2029,15 +2029,15 @@  discard block
 block discarded – undo
2029 2029
         foreach ($this->_views as $key => $view) {
2030 2030
             $query_args = [];
2031 2031
             // check for current view
2032
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2032
+            $this->_views[$key]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2033 2033
             $query_args['action']                        = $this->_req_action;
2034
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2034
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2035 2035
             $query_args['status']                        = $view['slug'];
2036 2036
             // merge any other arguments sent in.
2037
-            if (isset($extra_query_args[ $view['slug'] ])) {
2038
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2037
+            if (isset($extra_query_args[$view['slug']])) {
2038
+                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2039 2039
             }
2040
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2040
+            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2041 2041
         }
2042 2042
         return $this->_views;
2043 2043
     }
@@ -2068,14 +2068,14 @@  discard block
 block discarded – undo
2068 2068
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2069 2069
         foreach ($values as $value) {
2070 2070
             if ($value < $max_entries) {
2071
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2071
+                $selected = $value === $per_page ? ' selected="'.$per_page.'"' : '';
2072 2072
                 $entries_per_page_dropdown .= '
2073
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2073
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2074 2074
             }
2075 2075
         }
2076
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2076
+        $selected = $max_entries === $per_page ? ' selected="'.$per_page.'"' : '';
2077 2077
         $entries_per_page_dropdown .= '
2078
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2078
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2079 2079
         $entries_per_page_dropdown .= '
2080 2080
 					</select>
2081 2081
 					entries
@@ -2099,7 +2099,7 @@  discard block
 block discarded – undo
2099 2099
             empty($this->_search_btn_label) ? $this->page_label
2100 2100
                 : $this->_search_btn_label
2101 2101
         );
2102
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2102
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2103 2103
     }
2104 2104
 
2105 2105
 
@@ -2187,7 +2187,7 @@  discard block
 block discarded – undo
2187 2187
             $total_columns                                       = ! empty($screen_columns)
2188 2188
                 ? $screen_columns
2189 2189
                 : $this->_route_config['columns'][1];
2190
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2190
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2191 2191
             $this->_template_args['current_page']                = $this->_wp_page_slug;
2192 2192
             $this->_template_args['screen']                      = $this->_current_screen;
2193 2193
             $this->_column_template_path                         = EE_ADMIN_TEMPLATE
@@ -2232,7 +2232,7 @@  discard block
 block discarded – undo
2232 2232
      */
2233 2233
     protected function _espresso_ratings_request()
2234 2234
     {
2235
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2235
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2236 2236
             return;
2237 2237
         }
2238 2238
         $ratings_box_title = apply_filters(
@@ -2260,7 +2260,7 @@  discard block
 block discarded – undo
2260 2260
     public function espresso_ratings_request()
2261 2261
     {
2262 2262
         EEH_Template::display_template(
2263
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2263
+            EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php',
2264 2264
             []
2265 2265
         );
2266 2266
     }
@@ -2268,22 +2268,22 @@  discard block
 block discarded – undo
2268 2268
 
2269 2269
     public static function cached_rss_display($rss_id, $url)
2270 2270
     {
2271
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2271
+        $loading = '<p class="widget-loading hide-if-no-js">'
2272 2272
                      . esc_html__('Loading&#8230;', 'event_espresso')
2273 2273
                      . '</p><p class="hide-if-js">'
2274 2274
                      . esc_html__('This widget requires JavaScript.', 'event_espresso')
2275 2275
                      . '</p>';
2276
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2277
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2278
-        $post      = '</div>' . "\n";
2279
-        $cache_key = 'ee_rss_' . md5($rss_id);
2276
+        $pre       = '<div class="espresso-rss-display">'."\n\t";
2277
+        $pre .= '<span id="'.esc_attr($rss_id).'_url" class="hidden">'.esc_url_raw($url).'</span>';
2278
+        $post      = '</div>'."\n";
2279
+        $cache_key = 'ee_rss_'.md5($rss_id);
2280 2280
         $output    = get_transient($cache_key);
2281 2281
         if ($output !== false) {
2282
-            echo $pre . $output . $post; // already escaped
2282
+            echo $pre.$output.$post; // already escaped
2283 2283
             return true;
2284 2284
         }
2285
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2286
-            echo $pre . $loading . $post; // already escaped
2285
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
2286
+            echo $pre.$loading.$post; // already escaped
2287 2287
             return false;
2288 2288
         }
2289 2289
         ob_start();
@@ -2350,19 +2350,19 @@  discard block
 block discarded – undo
2350 2350
     public function espresso_sponsors_post_box()
2351 2351
     {
2352 2352
         EEH_Template::display_template(
2353
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2353
+            EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'
2354 2354
         );
2355 2355
     }
2356 2356
 
2357 2357
 
2358 2358
     private function _publish_post_box()
2359 2359
     {
2360
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2360
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2361 2361
         // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2362 2362
         // then we'll use that for the metabox label.
2363 2363
         // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2364
-        if (! empty($this->_labels['publishbox'])) {
2365
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2364
+        if ( ! empty($this->_labels['publishbox'])) {
2365
+            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2366 2366
                 : $this->_labels['publishbox'];
2367 2367
         } else {
2368 2368
             $box_label = esc_html__('Publish', 'event_espresso');
@@ -2391,7 +2391,7 @@  discard block
 block discarded – undo
2391 2391
             ? $this->_template_args['publish_box_extra_content']
2392 2392
             : '';
2393 2393
         echo EEH_Template::display_template(
2394
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2394
+            EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php',
2395 2395
             $this->_template_args,
2396 2396
             true
2397 2397
         );
@@ -2483,18 +2483,18 @@  discard block
 block discarded – undo
2483 2483
             );
2484 2484
         }
2485 2485
         $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2486
-        if (! empty($name) && ! empty($id)) {
2487
-            $hidden_field_arr[ $name ] = [
2486
+        if ( ! empty($name) && ! empty($id)) {
2487
+            $hidden_field_arr[$name] = [
2488 2488
                 'type'  => 'hidden',
2489 2489
                 'value' => $id,
2490 2490
             ];
2491
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2491
+            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2492 2492
         } else {
2493 2493
             $hf = '';
2494 2494
         }
2495 2495
         // add hidden field
2496 2496
         $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2497
-            ? $hf[ $name ]['field']
2497
+            ? $hf[$name]['field']
2498 2498
             : $hf;
2499 2499
     }
2500 2500
 
@@ -2596,7 +2596,7 @@  discard block
 block discarded – undo
2596 2596
         }
2597 2597
         // 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)
2598 2598
         $call_back_func = $create_func
2599
-            ? function ($post, $metabox) {
2599
+            ? function($post, $metabox) {
2600 2600
                 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2601 2601
                 echo EEH_Template::display_template(
2602 2602
                     $metabox['args']['template_path'],
@@ -2606,7 +2606,7 @@  discard block
 block discarded – undo
2606 2606
             }
2607 2607
             : $callback;
2608 2608
         add_meta_box(
2609
-            str_replace('_', '-', $action) . '-mbox',
2609
+            str_replace('_', '-', $action).'-mbox',
2610 2610
             $title,
2611 2611
             $call_back_func,
2612 2612
             $this->_wp_page_slug,
@@ -2698,9 +2698,9 @@  discard block
 block discarded – undo
2698 2698
             : 'espresso-default-admin';
2699 2699
         $template_path                                     = $sidebar
2700 2700
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2701
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2701
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2702 2702
         if ($this->request->isAjax()) {
2703
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2703
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2704 2704
         }
2705 2705
         $template_path                                     = ! empty($this->_column_template_path)
2706 2706
             ? $this->_column_template_path : $template_path;
@@ -2740,11 +2740,11 @@  discard block
 block discarded – undo
2740 2740
     public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2741 2741
     {
2742 2742
         // let's generate a default preview action button if there isn't one already present.
2743
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2743
+        $this->_labels['buttons']['buy_now'] = esc_html__(
2744 2744
             'Upgrade to Event Espresso 4 Right Now',
2745 2745
             'event_espresso'
2746 2746
         );
2747
-        $buy_now_url                                   = add_query_arg(
2747
+        $buy_now_url = add_query_arg(
2748 2748
             [
2749 2749
                 'ee_ver'       => 'ee4',
2750 2750
                 'utm_source'   => 'ee4_plugin_admin',
@@ -2764,8 +2764,8 @@  discard block
 block discarded – undo
2764 2764
                 true
2765 2765
             )
2766 2766
             : $this->_template_args['preview_action_button'];
2767
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2768
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2767
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2768
+            EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php',
2769 2769
             $this->_template_args,
2770 2770
             true
2771 2771
         );
@@ -2814,7 +2814,7 @@  discard block
 block discarded – undo
2814 2814
         // setup search attributes
2815 2815
         $this->_set_search_attributes();
2816 2816
         $this->_template_args['current_page']     = $this->_wp_page_slug;
2817
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2817
+        $template_path                            = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2818 2818
         $this->_template_args['table_url']        = $this->request->isAjax()
2819 2819
             ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2820 2820
             : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
@@ -2822,10 +2822,10 @@  discard block
 block discarded – undo
2822 2822
         $this->_template_args['current_route']    = $this->_req_action;
2823 2823
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2824 2824
         $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2825
-        if (! empty($ajax_sorting_callback)) {
2825
+        if ( ! empty($ajax_sorting_callback)) {
2826 2826
             $sortable_list_table_form_fields = wp_nonce_field(
2827
-                $ajax_sorting_callback . '_nonce',
2828
-                $ajax_sorting_callback . '_nonce',
2827
+                $ajax_sorting_callback.'_nonce',
2828
+                $ajax_sorting_callback.'_nonce',
2829 2829
                 false,
2830 2830
                 false
2831 2831
             );
@@ -2843,20 +2843,20 @@  discard block
 block discarded – undo
2843 2843
             isset($this->_template_args['list_table_hidden_fields'])
2844 2844
                 ? $this->_template_args['list_table_hidden_fields']
2845 2845
                 : '';
2846
-        $nonce_ref                                               = $this->_req_action . '_nonce';
2847
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
2846
+        $nonce_ref = $this->_req_action.'_nonce';
2847
+        $hidden_form_fields .= '<input type="hidden" name="'
2848 2848
                                                                     . $nonce_ref
2849 2849
                                                                     . '" value="'
2850 2850
                                                                     . wp_create_nonce($nonce_ref)
2851 2851
                                                                     . '">';
2852
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2852
+        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2853 2853
         // display message about search results?
2854 2854
         $search = $this->request->getRequestParam('s');
2855 2855
         $this->_template_args['before_list_table'] .= ! empty($search)
2856
-            ? '<p class="ee-search-results">' . sprintf(
2856
+            ? '<p class="ee-search-results">'.sprintf(
2857 2857
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2858 2858
                 trim($search, '%')
2859
-            ) . '</p>'
2859
+            ).'</p>'
2860 2860
             : '';
2861 2861
         // filter before_list_table template arg
2862 2862
         $this->_template_args['before_list_table'] = apply_filters(
@@ -2890,7 +2890,7 @@  discard block
 block discarded – undo
2890 2890
         // convert to array and filter again
2891 2891
         // arrays are easier to inject new items in a specific location,
2892 2892
         // but would not be backwards compatible, so we have to add a new filter
2893
-        $this->_template_args['after_list_table']   = implode(
2893
+        $this->_template_args['after_list_table'] = implode(
2894 2894
             " \n",
2895 2895
             (array) apply_filters(
2896 2896
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
@@ -2937,7 +2937,7 @@  discard block
 block discarded – undo
2937 2937
             $this
2938 2938
         );
2939 2939
         return EEH_Template::display_template(
2940
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2940
+            EE_ADMIN_TEMPLATE.'admin_details_legend.template.php',
2941 2941
             $this->_template_args,
2942 2942
             true
2943 2943
         );
@@ -3046,18 +3046,18 @@  discard block
 block discarded – undo
3046 3046
                 : ''
3047 3047
         );
3048 3048
 
3049
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3049
+        $this->_template_args['after_admin_page_content'] = apply_filters(
3050 3050
             "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3051 3051
             isset($this->_template_args['after_admin_page_content'])
3052 3052
                 ? $this->_template_args['after_admin_page_content']
3053 3053
                 : ''
3054 3054
         );
3055
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3055
+        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3056 3056
 
3057 3057
         if ($this->request->isAjax()) {
3058 3058
             $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3059 3059
                 // $template_path,
3060
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3060
+                EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php',
3061 3061
                 $this->_template_args,
3062 3062
                 true
3063 3063
             );
@@ -3066,7 +3066,7 @@  discard block
 block discarded – undo
3066 3066
         // load settings page wrapper template
3067 3067
         $template_path = $about
3068 3068
             ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3069
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3069
+            : EE_ADMIN_TEMPLATE.'admin_wrapper.template.php';
3070 3070
 
3071 3071
         EEH_Template::display_template($template_path, $this->_template_args);
3072 3072
     }
@@ -3151,12 +3151,12 @@  discard block
 block discarded – undo
3151 3151
         $default_names = ['save', 'save_and_close'];
3152 3152
         $buttons = '';
3153 3153
         foreach ($button_text as $key => $button) {
3154
-            $ref     = $default_names[ $key ];
3155
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3156
-            $buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3157
-                        . 'value="' . $button . '" name="' . $name . '" '
3158
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3159
-            if (! $both) {
3154
+            $ref     = $default_names[$key];
3155
+            $name    = ! empty($actions) ? $actions[$key] : $ref;
3156
+            $buttons .= '<input type="submit" class="button-primary '.$ref.'" '
3157
+                        . 'value="'.$button.'" name="'.$name.'" '
3158
+                        . 'id="'.$this->_current_view.'_'.$ref.'" />';
3159
+            if ( ! $both) {
3160 3160
                 break;
3161 3161
             }
3162 3162
         }
@@ -3196,13 +3196,13 @@  discard block
 block discarded – undo
3196 3196
                 'An error occurred. No action was set for this page\'s form.',
3197 3197
                 'event_espresso'
3198 3198
             );
3199
-            $dev_msg  = $user_msg . "\n"
3199
+            $dev_msg = $user_msg."\n"
3200 3200
                         . sprintf(
3201 3201
                             esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3202 3202
                             __FUNCTION__,
3203 3203
                             __CLASS__
3204 3204
                         );
3205
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3205
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3206 3206
         }
3207 3207
         // open form
3208 3208
         $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
@@ -3211,9 +3211,9 @@  discard block
 block discarded – undo
3211 3211
                                                              . $route
3212 3212
                                                              . '_event_form" >';
3213 3213
         // add nonce
3214
-        $nonce                                             =
3215
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3216
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3214
+        $nonce =
3215
+            wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3216
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3217 3217
         // add REQUIRED form action
3218 3218
         $hidden_fields = [
3219 3219
             'action' => ['type' => 'hidden', 'value' => $route],
@@ -3226,7 +3226,7 @@  discard block
 block discarded – undo
3226 3226
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3227 3227
         // add fields to form
3228 3228
         foreach ((array) $form_fields as $form_field) {
3229
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3229
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3230 3230
         }
3231 3231
         // close form
3232 3232
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3317,10 +3317,10 @@  discard block
 block discarded – undo
3317 3317
         $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3318 3318
         $notices      = EE_Error::get_notices(false);
3319 3319
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3320
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3320
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3321 3321
             EE_Error::overwrite_success();
3322 3322
         }
3323
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3323
+        if ( ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3324 3324
             // how many records affected ? more than one record ? or just one ?
3325 3325
             if ($success > 1) {
3326 3326
                 // set plural msg
@@ -3349,7 +3349,7 @@  discard block
 block discarded – undo
3349 3349
             }
3350 3350
         }
3351 3351
         // check that $query_args isn't something crazy
3352
-        if (! is_array($query_args)) {
3352
+        if ( ! is_array($query_args)) {
3353 3353
             $query_args = [];
3354 3354
         }
3355 3355
         /**
@@ -3378,7 +3378,7 @@  discard block
 block discarded – undo
3378 3378
             $redirect_url = admin_url('admin.php');
3379 3379
         }
3380 3380
         // merge any default query_args set in _default_route_query_args property
3381
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3381
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3382 3382
             $args_to_merge = [];
3383 3383
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3384 3384
                 // is there a wp_referer array in our _default_route_query_args property?
@@ -3390,15 +3390,15 @@  discard block
 block discarded – undo
3390 3390
                         }
3391 3391
                         // finally we will override any arguments in the referer with
3392 3392
                         // what might be set on the _default_route_query_args array.
3393
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3394
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3393
+                        if (isset($this->_default_route_query_args[$reference])) {
3394
+                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3395 3395
                         } else {
3396
-                            $args_to_merge[ $reference ] = urlencode($value);
3396
+                            $args_to_merge[$reference] = urlencode($value);
3397 3397
                         }
3398 3398
                     }
3399 3399
                     continue;
3400 3400
                 }
3401
-                $args_to_merge[ $query_param ] = $query_value;
3401
+                $args_to_merge[$query_param] = $query_value;
3402 3402
             }
3403 3403
             // now let's merge these arguments but override with what was specifically sent in to the
3404 3404
             // redirect.
@@ -3410,19 +3410,19 @@  discard block
 block discarded – undo
3410 3410
         if (isset($query_args['action'])) {
3411 3411
             // manually generate wp_nonce and merge that with the query vars
3412 3412
             // becuz the wp_nonce_url function wrecks havoc on some vars
3413
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3413
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3414 3414
         }
3415 3415
         // we're adding some hooks and filters in here for processing any things just before redirects
3416 3416
         // (example: an admin page has done an insert or update and we want to run something after that).
3417
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3417
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
3418 3418
         $redirect_url = apply_filters(
3419
-            'FHEE_redirect_' . $classname . $this->_req_action,
3419
+            'FHEE_redirect_'.$classname.$this->_req_action,
3420 3420
             self::add_query_args_and_nonce($query_args, $redirect_url),
3421 3421
             $query_args
3422 3422
         );
3423 3423
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3424 3424
         if ($this->request->isAjax()) {
3425
-            $default_data                    = [
3425
+            $default_data = [
3426 3426
                 'close'        => true,
3427 3427
                 'redirect_url' => $redirect_url,
3428 3428
                 'where'        => 'main',
@@ -3469,7 +3469,7 @@  discard block
 block discarded – undo
3469 3469
         }
3470 3470
         $this->_template_args['notices'] = EE_Error::get_notices();
3471 3471
         // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3472
-        if (! $this->request->isAjax() || $sticky_notices) {
3472
+        if ( ! $this->request->isAjax() || $sticky_notices) {
3473 3473
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3474 3474
             $this->_add_transient(
3475 3475
                 $route,
@@ -3509,7 +3509,7 @@  discard block
 block discarded – undo
3509 3509
         $exclude_nonce = false
3510 3510
     ) {
3511 3511
         // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3512
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3512
+        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3513 3513
             throw new EE_Error(
3514 3514
                 sprintf(
3515 3515
                     esc_html__(
@@ -3520,7 +3520,7 @@  discard block
 block discarded – undo
3520 3520
                 )
3521 3521
             );
3522 3522
         }
3523
-        if (! isset($this->_labels['buttons'][ $type ])) {
3523
+        if ( ! isset($this->_labels['buttons'][$type])) {
3524 3524
             throw new EE_Error(
3525 3525
                 sprintf(
3526 3526
                     esc_html__(
@@ -3533,7 +3533,7 @@  discard block
 block discarded – undo
3533 3533
         }
3534 3534
         // finally check user access for this button.
3535 3535
         $has_access = $this->check_user_access($action, true);
3536
-        if (! $has_access) {
3536
+        if ( ! $has_access) {
3537 3537
             return '';
3538 3538
         }
3539 3539
         $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3541,11 +3541,11 @@  discard block
 block discarded – undo
3541 3541
             'action' => $action,
3542 3542
         ];
3543 3543
         // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3544
-        if (! empty($extra_request)) {
3544
+        if ( ! empty($extra_request)) {
3545 3545
             $query_args = array_merge($extra_request, $query_args);
3546 3546
         }
3547 3547
         $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3548
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3548
+        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3549 3549
     }
3550 3550
 
3551 3551
 
@@ -3571,7 +3571,7 @@  discard block
 block discarded – undo
3571 3571
                 'FHEE__EE_Admin_Page___per_page_screen_options__default',
3572 3572
                 20
3573 3573
             ),
3574
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3574
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3575 3575
         ];
3576 3576
         // ONLY add the screen option if the user has access to it.
3577 3577
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3592,18 +3592,18 @@  discard block
 block discarded – undo
3592 3592
     {
3593 3593
         if ($this->request->requestParamIsSet('wp_screen_options')) {
3594 3594
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3595
-            if (! $user = wp_get_current_user()) {
3595
+            if ( ! $user = wp_get_current_user()) {
3596 3596
                 return;
3597 3597
             }
3598 3598
             $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3599
-            if (! $option) {
3599
+            if ( ! $option) {
3600 3600
                 return;
3601 3601
             }
3602
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3602
+            $value = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3603 3603
             $map_option = $option;
3604 3604
             $option     = str_replace('-', '_', $option);
3605 3605
             switch ($map_option) {
3606
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3606
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3607 3607
                     $max_value = apply_filters(
3608 3608
                         'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3609 3609
                         999,
@@ -3660,13 +3660,13 @@  discard block
 block discarded – undo
3660 3660
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3661 3661
     {
3662 3662
         $user_id = get_current_user_id();
3663
-        if (! $skip_route_verify) {
3663
+        if ( ! $skip_route_verify) {
3664 3664
             $this->_verify_route($route);
3665 3665
         }
3666 3666
         // now let's set the string for what kind of transient we're setting
3667 3667
         $transient = $notices
3668
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3669
-            : 'rte_tx_' . $route . '_' . $user_id;
3668
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3669
+            : 'rte_tx_'.$route.'_'.$user_id;
3670 3670
         $data      = $notices ? ['notices' => $data] : $data;
3671 3671
         // is there already a transient for this route?  If there is then let's ADD to that transient
3672 3672
         $existing = is_multisite() && is_network_admin()
@@ -3695,8 +3695,8 @@  discard block
 block discarded – undo
3695 3695
         $user_id   = get_current_user_id();
3696 3696
         $route     = ! $route ? $this->_req_action : $route;
3697 3697
         $transient = $notices
3698
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3699
-            : 'rte_tx_' . $route . '_' . $user_id;
3698
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3699
+            : 'rte_tx_'.$route.'_'.$user_id;
3700 3700
         $data      = is_multisite() && is_network_admin()
3701 3701
             ? get_site_transient($transient)
3702 3702
             : get_transient($transient);
@@ -3927,7 +3927,7 @@  discard block
 block discarded – undo
3927 3927
      */
3928 3928
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3929 3929
     {
3930
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3930
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3931 3931
     }
3932 3932
 
3933 3933
 
@@ -3940,7 +3940,7 @@  discard block
 block discarded – undo
3940 3940
      */
3941 3941
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3942 3942
     {
3943
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3943
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3944 3944
     }
3945 3945
 
3946 3946
 
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 1 patch
Indentation   +1302 added lines, -1302 removed lines patch added patch discarded remove patch
@@ -14,1306 +14,1306 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
 
17
-    /**
18
-     * Extend_Events_Admin_Page constructor.
19
-     *
20
-     * @param bool $routing
21
-     * @throws EE_Error
22
-     * @throws ReflectionException
23
-     */
24
-    public function __construct($routing = true)
25
-    {
26
-        parent::__construct($routing);
27
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
28
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
29
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
30
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
31
-        }
32
-    }
33
-
34
-
35
-    /**
36
-     * Sets routes.
37
-     *
38
-     * @throws EE_Error
39
-     */
40
-    protected function _extend_page_config()
41
-    {
42
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
43
-        // is there a evt_id in the request?
44
-        $EVT_ID             = $this->request->getRequestParam('EVT_ID', 0, 'int');
45
-        $EVT_ID             = $this->request->getRequestParam('post', $EVT_ID, 'int');
46
-        $TKT_ID             = $this->request->getRequestParam('TKT_ID', 0, 'int');
47
-        $new_page_routes    = [
48
-            'duplicate_event'          => [
49
-                'func'       => '_duplicate_event',
50
-                'capability' => 'ee_edit_event',
51
-                'obj_id'     => $EVT_ID,
52
-                'noheader'   => true,
53
-            ],
54
-            'ticket_list_table'        => [
55
-                'func'       => '_tickets_overview_list_table',
56
-                'capability' => 'ee_read_default_tickets',
57
-            ],
58
-            'trash_ticket'             => [
59
-                'func'       => '_trash_or_restore_ticket',
60
-                'capability' => 'ee_delete_default_ticket',
61
-                'obj_id'     => $TKT_ID,
62
-                'noheader'   => true,
63
-                'args'       => ['trash' => true],
64
-            ],
65
-            'trash_tickets'            => [
66
-                'func'       => '_trash_or_restore_ticket',
67
-                'capability' => 'ee_delete_default_tickets',
68
-                'noheader'   => true,
69
-                'args'       => ['trash' => true],
70
-            ],
71
-            'restore_ticket'           => [
72
-                'func'       => '_trash_or_restore_ticket',
73
-                'capability' => 'ee_delete_default_ticket',
74
-                'obj_id'     => $TKT_ID,
75
-                'noheader'   => true,
76
-            ],
77
-            'restore_tickets'          => [
78
-                'func'       => '_trash_or_restore_ticket',
79
-                'capability' => 'ee_delete_default_tickets',
80
-                'noheader'   => true,
81
-            ],
82
-            'delete_ticket'            => [
83
-                'func'       => '_delete_ticket',
84
-                'capability' => 'ee_delete_default_ticket',
85
-                'obj_id'     => $TKT_ID,
86
-                'noheader'   => true,
87
-            ],
88
-            'delete_tickets'           => [
89
-                'func'       => '_delete_ticket',
90
-                'capability' => 'ee_delete_default_tickets',
91
-                'noheader'   => true,
92
-            ],
93
-            'import_page'              => [
94
-                'func'       => '_import_page',
95
-                'capability' => 'import',
96
-            ],
97
-            'import'                   => [
98
-                'func'       => '_import_events',
99
-                'capability' => 'import',
100
-                'noheader'   => true,
101
-            ],
102
-            'import_events'            => [
103
-                'func'       => '_import_events',
104
-                'capability' => 'import',
105
-                'noheader'   => true,
106
-            ],
107
-            'export_events'            => [
108
-                'func'       => '_events_export',
109
-                'capability' => 'export',
110
-                'noheader'   => true,
111
-            ],
112
-            'export_categories'        => [
113
-                'func'       => '_categories_export',
114
-                'capability' => 'export',
115
-                'noheader'   => true,
116
-            ],
117
-            'sample_export_file'       => [
118
-                'func'       => '_sample_export_file',
119
-                'capability' => 'export',
120
-                'noheader'   => true,
121
-            ],
122
-            'update_template_settings' => [
123
-                'func'       => '_update_template_settings',
124
-                'capability' => 'manage_options',
125
-                'noheader'   => true,
126
-            ],
127
-        ];
128
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
129
-        // partial route/config override
130
-        $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
131
-        $this->_page_config['create_new']['metaboxes'][]  = '_premium_event_editor_meta_boxes';
132
-        $this->_page_config['create_new']['qtips'][]      = 'EE_Event_Editor_Tips';
133
-        $this->_page_config['edit']['qtips'][]            = 'EE_Event_Editor_Tips';
134
-        $this->_page_config['edit']['metaboxes'][]        = '_premium_event_editor_meta_boxes';
135
-        $this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
136
-        // add tickets tab but only if there are more than one default ticket!
137
-        $ticket_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
138
-            [['TKT_is_default' => 1]],
139
-            'TKT_ID',
140
-            true
141
-        );
142
-        if ($ticket_count > 1) {
143
-            $new_page_config = [
144
-                'ticket_list_table' => [
145
-                    'nav'           => [
146
-                        'label' => esc_html__('Default Tickets', 'event_espresso'),
147
-                        'order' => 60,
148
-                    ],
149
-                    'list_table'    => 'Tickets_List_Table',
150
-                    'require_nonce' => false,
151
-                ],
152
-            ];
153
-        }
154
-        // template settings
155
-        $new_page_config['template_settings'] = [
156
-            'nav'           => [
157
-                'label' => esc_html__('Templates', 'event_espresso'),
158
-                'order' => 30,
159
-            ],
160
-            'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
161
-            'help_tabs'     => [
162
-                'general_settings_templates_help_tab' => [
163
-                    'title'    => esc_html__('Templates', 'event_espresso'),
164
-                    'filename' => 'general_settings_templates',
165
-                ],
166
-            ],
167
-            'require_nonce' => false,
168
-        ];
169
-        $this->_page_config                   = array_merge($this->_page_config, $new_page_config);
170
-        // add filters and actions
171
-        // modifying _views
172
-        add_filter(
173
-            'FHEE_event_datetime_metabox_add_additional_date_time_template',
174
-            [$this, 'add_additional_datetime_button'],
175
-            10,
176
-            2
177
-        );
178
-        add_filter(
179
-            'FHEE_event_datetime_metabox_clone_button_template',
180
-            [$this, 'add_datetime_clone_button'],
181
-            10,
182
-            2
183
-        );
184
-        add_filter(
185
-            'FHEE_event_datetime_metabox_timezones_template',
186
-            [$this, 'datetime_timezones_template'],
187
-            10,
188
-            2
189
-        );
190
-        // filters for event list table
191
-        add_filter('FHEE__Extend_Events_Admin_List_Table__filters', [$this, 'list_table_filters'], 10, 2);
192
-        add_filter(
193
-            'FHEE__Events_Admin_List_Table__column_actions__action_links',
194
-            [$this, 'extra_list_table_actions'],
195
-            10,
196
-            2
197
-        );
198
-        // legend item
199
-        add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']);
200
-        add_action('admin_init', [$this, 'admin_init']);
201
-    }
202
-
203
-
204
-    /**
205
-     * admin_init
206
-     */
207
-    public function admin_init()
208
-    {
209
-        EE_Registry::$i18n_js_strings = array_merge(
210
-            EE_Registry::$i18n_js_strings,
211
-            [
212
-                'image_confirm'          => esc_html__(
213
-                    'Do you really want to delete this image? Please remember to update your event to complete the removal.',
214
-                    'event_espresso'
215
-                ),
216
-                'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
217
-                'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
218
-                'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
219
-                'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
220
-                'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
221
-            ]
222
-        );
223
-    }
224
-
225
-
226
-    /**
227
-     * Add per page screen options to the default ticket list table view.
228
-     */
229
-    protected function _add_screen_options_ticket_list_table()
230
-    {
231
-        $this->_per_page_screen_option();
232
-    }
233
-
234
-
235
-    /**
236
-     * @param string $return
237
-     * @param int    $id
238
-     * @param string $new_title
239
-     * @param string $new_slug
240
-     * @return string
241
-     */
242
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
243
-    {
244
-        $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
245
-        // make sure this is only when editing
246
-        if (! empty($id)) {
247
-            $href   = EE_Admin_Page::add_query_args_and_nonce(
248
-                ['action' => 'duplicate_event', 'EVT_ID' => $id],
249
-                $this->_admin_base_url
250
-            );
251
-            $title  = esc_attr__('Duplicate Event', 'event_espresso');
252
-            $return .= '<a href="'
253
-                       . $href
254
-                       . '" title="'
255
-                       . $title
256
-                       . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
257
-                       . $title
258
-                       . '</a>';
259
-        }
260
-        return $return;
261
-    }
262
-
263
-
264
-    /**
265
-     * Set the list table views for the default ticket list table view.
266
-     */
267
-    public function _set_list_table_views_ticket_list_table()
268
-    {
269
-        $this->_views = [
270
-            'all'     => [
271
-                'slug'        => 'all',
272
-                'label'       => esc_html__('All', 'event_espresso'),
273
-                'count'       => 0,
274
-                'bulk_action' => [
275
-                    'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
276
-                ],
277
-            ],
278
-            'trashed' => [
279
-                'slug'        => 'trashed',
280
-                'label'       => esc_html__('Trash', 'event_espresso'),
281
-                'count'       => 0,
282
-                'bulk_action' => [
283
-                    'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
284
-                    'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
285
-                ],
286
-            ],
287
-        ];
288
-    }
289
-
290
-
291
-    /**
292
-     * Enqueue scripts and styles for the event editor.
293
-     */
294
-    public function load_scripts_styles_edit()
295
-    {
296
-        wp_register_script(
297
-            'ee-event-editor-heartbeat',
298
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
299
-            ['ee_admin_js', 'heartbeat'],
300
-            EVENT_ESPRESSO_VERSION,
301
-            true
302
-        );
303
-        wp_enqueue_script('ee-accounting');
304
-        // styles
305
-        wp_enqueue_style('espresso-ui-theme');
306
-        wp_enqueue_script('event_editor_js');
307
-        wp_enqueue_script('ee-event-editor-heartbeat');
308
-    }
309
-
310
-
311
-    /**
312
-     * Returns template for the additional datetime.
313
-     *
314
-     * @param string $template
315
-     * @param array  $template_args
316
-     * @return string
317
-     * @throws DomainException
318
-     */
319
-    public function add_additional_datetime_button($template, $template_args)
320
-    {
321
-        return EEH_Template::display_template(
322
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
323
-            $template_args,
324
-            true
325
-        );
326
-    }
327
-
328
-
329
-    /**
330
-     * Returns the template for cloning a datetime.
331
-     *
332
-     * @param $template
333
-     * @param $template_args
334
-     * @return string
335
-     * @throws DomainException
336
-     */
337
-    public function add_datetime_clone_button($template, $template_args)
338
-    {
339
-        return EEH_Template::display_template(
340
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
341
-            $template_args,
342
-            true
343
-        );
344
-    }
345
-
346
-
347
-    /**
348
-     * Returns the template for datetime timezones.
349
-     *
350
-     * @param $template
351
-     * @param $template_args
352
-     * @return string
353
-     * @throws DomainException
354
-     */
355
-    public function datetime_timezones_template($template, $template_args)
356
-    {
357
-        return EEH_Template::display_template(
358
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
359
-            $template_args,
360
-            true
361
-        );
362
-    }
363
-
364
-
365
-    /**
366
-     * Sets the views for the default list table view.
367
-     *
368
-     * @throws EE_Error
369
-     */
370
-    protected function _set_list_table_views_default()
371
-    {
372
-        parent::_set_list_table_views_default();
373
-        $new_views    = [
374
-            'today' => [
375
-                'slug'        => 'today',
376
-                'label'       => esc_html__('Today', 'event_espresso'),
377
-                'count'       => $this->total_events_today(),
378
-                'bulk_action' => [
379
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
380
-                ],
381
-            ],
382
-            'month' => [
383
-                'slug'        => 'month',
384
-                'label'       => esc_html__('This Month', 'event_espresso'),
385
-                'count'       => $this->total_events_this_month(),
386
-                'bulk_action' => [
387
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
388
-                ],
389
-            ],
390
-        ];
391
-        $this->_views = array_merge($this->_views, $new_views);
392
-    }
393
-
394
-
395
-    /**
396
-     * Returns the extra action links for the default list table view.
397
-     *
398
-     * @param array    $action_links
399
-     * @param EE_Event $event
400
-     * @return array
401
-     * @throws EE_Error
402
-     * @throws ReflectionException
403
-     */
404
-    public function extra_list_table_actions(array $action_links, EE_Event $event)
405
-    {
406
-        if (
407
-            EE_Registry::instance()->CAP->current_user_can(
408
-                'ee_read_registrations',
409
-                'espresso_registrations_reports',
410
-                $event->ID()
411
-            )
412
-        ) {
413
-            $reports_query_args = [
414
-                'action' => 'reports',
415
-                'EVT_ID' => $event->ID(),
416
-            ];
417
-            $reports_link       = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
418
-            $action_links[]     = '<a href="'
419
-                                  . $reports_link
420
-                                  . '" title="'
421
-                                  . esc_attr__('View Report', 'event_espresso')
422
-                                  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
423
-                                  . "\n\t";
424
-        }
425
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
426
-            EE_Registry::instance()->load_helper('MSG_Template');
427
-            $action_links[] = EEH_MSG_Template::get_message_action_link(
428
-                'see_notifications_for',
429
-                null,
430
-                ['EVT_ID' => $event->ID()]
431
-            );
432
-        }
433
-        return $action_links;
434
-    }
435
-
436
-
437
-    /**
438
-     * @param $items
439
-     * @return mixed
440
-     */
441
-    public function additional_legend_items($items)
442
-    {
443
-        if (
444
-            EE_Registry::instance()->CAP->current_user_can(
445
-                'ee_read_registrations',
446
-                'espresso_registrations_reports'
447
-            )
448
-        ) {
449
-            $items['reports'] = [
450
-                'class' => 'dashicons dashicons-chart-bar',
451
-                'desc'  => esc_html__('Event Reports', 'event_espresso'),
452
-            ];
453
-        }
454
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
455
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
456
-            if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
457
-                $items['view_related_messages'] = [
458
-                    'class' => $related_for_icon['css_class'],
459
-                    'desc'  => $related_for_icon['label'],
460
-                ];
461
-            }
462
-        }
463
-        return $items;
464
-    }
465
-
466
-
467
-    /**
468
-     * This is the callback method for the duplicate event route
469
-     * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
470
-     * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
471
-     * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
472
-     * After duplication the redirect is to the new event edit page.
473
-     *
474
-     * @return void
475
-     * @throws EE_Error If EE_Event is not available with given ID
476
-     * @throws ReflectionException
477
-     * @access protected
478
-     */
479
-    protected function _duplicate_event()
480
-    {
481
-        // first make sure the ID for the event is in the request.
482
-        //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
483
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
484
-        if (! $EVT_ID) {
485
-            EE_Error::add_error(
486
-                esc_html__(
487
-                    'In order to duplicate an event an Event ID is required.  None was given.',
488
-                    'event_espresso'
489
-                ),
490
-                __FILE__,
491
-                __FUNCTION__,
492
-                __LINE__
493
-            );
494
-            $this->_redirect_after_action(false, '', '', [], true);
495
-            return;
496
-        }
497
-        // k we've got EVT_ID so let's use that to get the event we'll duplicate
498
-        $orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
499
-        if (! $orig_event instanceof EE_Event) {
500
-            throw new EE_Error(
501
-                sprintf(
502
-                    esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
503
-                    $EVT_ID
504
-                )
505
-            );
506
-        }
507
-        // k now let's clone the $orig_event before getting relations
508
-        $new_event = clone $orig_event;
509
-        // original datetimes
510
-        $orig_datetimes = $orig_event->get_many_related('Datetime');
511
-        // other original relations
512
-        $orig_ven = $orig_event->get_many_related('Venue');
513
-        // reset the ID and modify other details to make it clear this is a dupe
514
-        $new_event->set('EVT_ID', 0);
515
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
516
-        $new_event->set('EVT_name', $new_name);
517
-        $new_event->set(
518
-            'EVT_slug',
519
-            wp_unique_post_slug(
520
-                sanitize_title($orig_event->name()),
521
-                0,
522
-                'publish',
523
-                'espresso_events',
524
-                0
525
-            )
526
-        );
527
-        $new_event->set('status', 'draft');
528
-        // duplicate discussion settings
529
-        $new_event->set('comment_status', $orig_event->get('comment_status'));
530
-        $new_event->set('ping_status', $orig_event->get('ping_status'));
531
-        // save the new event
532
-        $new_event->save();
533
-        // venues
534
-        foreach ($orig_ven as $ven) {
535
-            $new_event->_add_relation_to($ven, 'Venue');
536
-        }
537
-        $new_event->save();
538
-        // now we need to get the question group relations and handle that
539
-        // first primary question groups
540
-        $orig_primary_qgs = $orig_event->get_many_related(
541
-            'Question_Group',
542
-            [['Event_Question_Group.EQG_primary' => true]]
543
-        );
544
-        if (! empty($orig_primary_qgs)) {
545
-            foreach ($orig_primary_qgs as $obj) {
546
-                if ($obj instanceof EE_Question_Group) {
547
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
548
-                }
549
-            }
550
-        }
551
-        // next additional attendee question groups
552
-        $orig_additional_qgs = $orig_event->get_many_related(
553
-            'Question_Group',
554
-            [['Event_Question_Group.EQG_additional' => true]]
555
-        );
556
-        if (! empty($orig_additional_qgs)) {
557
-            foreach ($orig_additional_qgs as $obj) {
558
-                if ($obj instanceof EE_Question_Group) {
559
-                    $new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
560
-                }
561
-            }
562
-        }
563
-
564
-        $new_event->save();
565
-
566
-        // k now that we have the new event saved we can loop through the datetimes and start adding relations.
567
-        $cloned_tickets = [];
568
-        foreach ($orig_datetimes as $orig_dtt) {
569
-            if (! $orig_dtt instanceof EE_Datetime) {
570
-                continue;
571
-            }
572
-            $new_dtt      = clone $orig_dtt;
573
-            $orig_tickets = $orig_dtt->tickets();
574
-            // save new dtt then add to event
575
-            $new_dtt->set('DTT_ID', 0);
576
-            $new_dtt->set('DTT_sold', 0);
577
-            $new_dtt->set_reserved(0);
578
-            $new_dtt->save();
579
-            $new_event->_add_relation_to($new_dtt, 'Datetime');
580
-            $new_event->save();
581
-            // now let's get the ticket relations setup.
582
-            foreach ((array) $orig_tickets as $orig_ticket) {
583
-                // it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
584
-                if (! $orig_ticket instanceof EE_Ticket) {
585
-                    continue;
586
-                }
587
-                // is this ticket archived?  If it is then let's skip
588
-                if ($orig_ticket->get('TKT_deleted')) {
589
-                    continue;
590
-                }
591
-                // does this original ticket already exist in the clone_tickets cache?
592
-                //  If so we'll just use the new ticket from it.
593
-                if (isset($cloned_tickets[ $orig_ticket->ID() ])) {
594
-                    $new_ticket = $cloned_tickets[ $orig_ticket->ID() ];
595
-                } else {
596
-                    $new_ticket = clone $orig_ticket;
597
-                    // get relations on the $orig_ticket that we need to setup.
598
-                    $orig_prices = $orig_ticket->prices();
599
-                    $new_ticket->set('TKT_ID', 0);
600
-                    $new_ticket->set('TKT_sold', 0);
601
-                    $new_ticket->set('TKT_reserved', 0);
602
-                    $new_ticket->save(); // make sure new ticket has ID.
603
-                    // price relations on new ticket need to be setup.
604
-                    foreach ($orig_prices as $orig_price) {
605
-                        $new_price = clone $orig_price;
606
-                        $new_price->set('PRC_ID', 0);
607
-                        $new_price->save();
608
-                        $new_ticket->_add_relation_to($new_price, 'Price');
609
-                        $new_ticket->save();
610
-                    }
611
-
612
-                    do_action(
613
-                        'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
614
-                        $orig_ticket,
615
-                        $new_ticket,
616
-                        $orig_prices,
617
-                        $orig_event,
618
-                        $orig_dtt,
619
-                        $new_dtt
620
-                    );
621
-                }
622
-                // k now we can add the new ticket as a relation to the new datetime
623
-                // and make sure its added to our cached $cloned_tickets array
624
-                // for use with later datetimes that have the same ticket.
625
-                $new_dtt->_add_relation_to($new_ticket, 'Ticket');
626
-                $new_dtt->save();
627
-                $cloned_tickets[ $orig_ticket->ID() ] = $new_ticket;
628
-            }
629
-        }
630
-        // clone taxonomy information
631
-        $taxonomies_to_clone_with = apply_filters(
632
-            'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
633
-            ['espresso_event_categories', 'espresso_event_type', 'post_tag']
634
-        );
635
-        // get terms for original event (notice)
636
-        $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
637
-        // loop through terms and add them to new event.
638
-        foreach ($orig_terms as $term) {
639
-            wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
640
-        }
641
-
642
-        // duplicate other core WP_Post items for this event.
643
-        // post thumbnail (feature image).
644
-        $feature_image_id = get_post_thumbnail_id($orig_event->ID());
645
-        if ($feature_image_id) {
646
-            update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
647
-        }
648
-
649
-        // duplicate page_template setting
650
-        $page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
651
-        if ($page_template) {
652
-            update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
653
-        }
654
-
655
-        do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
656
-        // now let's redirect to the edit page for this duplicated event if we have a new event id.
657
-        if ($new_event->ID()) {
658
-            $redirect_args = [
659
-                'post'   => $new_event->ID(),
660
-                'action' => 'edit',
661
-            ];
662
-            EE_Error::add_success(
663
-                esc_html__(
664
-                    'Event successfully duplicated.  Please review the details below and make any necessary edits',
665
-                    'event_espresso'
666
-                )
667
-            );
668
-        } else {
669
-            $redirect_args = [
670
-                'action' => 'default',
671
-            ];
672
-            EE_Error::add_error(
673
-                esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
674
-                __FILE__,
675
-                __FUNCTION__,
676
-                __LINE__
677
-            );
678
-        }
679
-        $this->_redirect_after_action(false, '', '', $redirect_args, true);
680
-    }
681
-
682
-
683
-    /**
684
-     * Generates output for the import page.
685
-     *
686
-     * @throws EE_Error
687
-     */
688
-    protected function _import_page()
689
-    {
690
-        $title = esc_html__('Import', 'event_espresso');
691
-        $intro = esc_html__(
692
-            'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
693
-            'event_espresso'
694
-        );
695
-
696
-        $form_url = EVENTS_ADMIN_URL;
697
-        $action   = 'import_events';
698
-        $type     = 'csv';
699
-
700
-        $this->_template_args['form'] = EE_Import::instance()->upload_form(
701
-            $title,
702
-            $intro,
703
-            $form_url,
704
-            $action,
705
-            $type
706
-        );
707
-
708
-        $this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
709
-            ['action' => 'sample_export_file'],
710
-            $this->_admin_base_url
711
-        );
712
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
713
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
714
-            $this->_template_args,
715
-            true
716
-        );
717
-        $this->display_admin_page_with_sidebar();
718
-    }
719
-
720
-
721
-    /**
722
-     * _import_events
723
-     * This handles displaying the screen and running imports for importing events.
724
-     *
725
-     * @return void
726
-     * @throws EE_Error
727
-     */
728
-    protected function _import_events()
729
-    {
730
-        require_once(EE_CLASSES . 'EE_Import.class.php');
731
-        $success = EE_Import::instance()->import();
732
-        $this->_redirect_after_action(
733
-            $success,
734
-            esc_html__('Import File', 'event_espresso'),
735
-            'ran',
736
-            ['action' => 'import_page'],
737
-            true
738
-        );
739
-    }
740
-
741
-
742
-    /**
743
-     * _events_export
744
-     * Will export all (or just the given event) to a Excel compatible file.
745
-     *
746
-     * @access protected
747
-     * @return void
748
-     */
749
-    protected function _events_export()
750
-    {
751
-        $EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
752
-        $EVT_ID = $this->request->getRequestParam('EVT_IDs', $EVT_ID, 'int');
753
-        $this->request->mergeRequestParams(
754
-            [
755
-                'export' => 'report',
756
-                'action' => 'all_event_data',
757
-                'EVT_ID' => $EVT_ID,
758
-            ]
759
-        );
760
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
761
-            require_once(EE_CLASSES . 'EE_Export.class.php');
762
-            $EE_Export = EE_Export::instance($this->request->requestParams());
763
-            $EE_Export->export();
764
-        }
765
-    }
766
-
767
-
768
-    /**
769
-     * handle category exports()
770
-     *
771
-     * @return void
772
-     */
773
-    protected function _categories_export()
774
-    {
775
-        $EVT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
776
-        $this->request->mergeRequestParams(
777
-            [
778
-                'export' => 'report',
779
-                'action' => 'categories',
780
-                'EVT_ID' => $EVT_ID,
781
-            ]
782
-        );
783
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
784
-            require_once(EE_CLASSES . 'EE_Export.class.php');
785
-            $EE_Export = EE_Export::instance($this->request->requestParams());
786
-            $EE_Export->export();
787
-        }
788
-    }
789
-
790
-
791
-    /**
792
-     * Creates a sample CSV file for importing
793
-     */
794
-    protected function _sample_export_file()
795
-    {
796
-        // require_once(EE_CLASSES . 'EE_Export.class.php');
797
-        EE_Export::instance()->export_sample();
798
-    }
799
-
800
-
801
-    /*************        Template Settings        *************/
802
-    /**
803
-     * Generates template settings page output
804
-     *
805
-     * @throws DomainException
806
-     * @throws EE_Error
807
-     */
808
-    protected function _template_settings()
809
-    {
810
-        $this->_template_args['values'] = $this->_yes_no_values;
811
-        /**
812
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
813
-         * from General_Settings_Admin_Page to here.
814
-         */
815
-        $this->_template_args = apply_filters(
816
-            'FHEE__General_Settings_Admin_Page__template_settings__template_args',
817
-            $this->_template_args
818
-        );
819
-        $this->_set_add_edit_form_tags('update_template_settings');
820
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
821
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
822
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
823
-            $this->_template_args,
824
-            true
825
-        );
826
-        $this->display_admin_page_with_sidebar();
827
-    }
828
-
829
-
830
-    /**
831
-     * Handler for updating template settings.
832
-     *
833
-     * @throws EE_Error
834
-     */
835
-    protected function _update_template_settings()
836
-    {
837
-        /**
838
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
839
-         * from General_Settings_Admin_Page to here.
840
-         */
841
-        EE_Registry::instance()->CFG->template_settings = apply_filters(
842
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
843
-            EE_Registry::instance()->CFG->template_settings,
844
-            $this->request->requestParams()
845
-        );
846
-        // update custom post type slugs and detect if we need to flush rewrite rules
847
-        $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
848
-
849
-        $event_cpt_slug = $this->request->getRequestParam('event_cpt_slug');
850
-
851
-        EE_Registry::instance()->CFG->core->event_cpt_slug = $event_cpt_slug
852
-            ? EEH_URL::slugify($event_cpt_slug, 'events')
853
-            : EE_Registry::instance()->CFG->core->event_cpt_slug;
854
-
855
-        $what    = esc_html__('Template Settings', 'event_espresso');
856
-        $success = $this->_update_espresso_configuration(
857
-            $what,
858
-            EE_Registry::instance()->CFG->template_settings,
859
-            __FILE__,
860
-            __FUNCTION__,
861
-            __LINE__
862
-        );
863
-        if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) {
864
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
865
-            $rewrite_rules = LoaderFactory::getLoader()->getShared(
866
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
867
-            );
868
-            $rewrite_rules->flush();
869
-        }
870
-        $this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']);
871
-    }
872
-
873
-
874
-    /**
875
-     * _premium_event_editor_meta_boxes
876
-     * add all metaboxes related to the event_editor
877
-     *
878
-     * @access protected
879
-     * @return void
880
-     * @throws EE_Error
881
-     * @throws ReflectionException
882
-     */
883
-    protected function _premium_event_editor_meta_boxes()
884
-    {
885
-        $this->verify_cpt_object();
886
-        add_meta_box(
887
-            'espresso_event_editor_event_options',
888
-            esc_html__('Event Registration Options', 'event_espresso'),
889
-            [$this, 'registration_options_meta_box'],
890
-            $this->page_slug,
891
-            'side',
892
-            'core'
893
-        );
894
-    }
895
-
896
-
897
-    /**
898
-     * override caf metabox
899
-     *
900
-     * @return void
901
-     * @throws EE_Error
902
-     * @throws ReflectionException
903
-     */
904
-    public function registration_options_meta_box()
905
-    {
906
-        $yes_no_values = [
907
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
908
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
909
-        ];
910
-
911
-        $default_reg_status_values = EEM_Registration::reg_status_array(
912
-            [
913
-                EEM_Registration::status_id_cancelled,
914
-                EEM_Registration::status_id_declined,
915
-                EEM_Registration::status_id_incomplete,
916
-                EEM_Registration::status_id_wait_list,
917
-            ],
918
-            true
919
-        );
920
-
921
-        $template_args['active_status']    = $this->_cpt_model_obj->pretty_active_status(false);
922
-        $template_args['_event']           = $this->_cpt_model_obj;
923
-        $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
924
-
925
-        $template_args['default_registration_status']     = EEH_Form_Fields::select_input(
926
-            'default_reg_status',
927
-            $default_reg_status_values,
928
-            $this->_cpt_model_obj->default_registration_status()
929
-        );
930
-        $template_args['display_description']             = EEH_Form_Fields::select_input(
931
-            'display_desc',
932
-            $yes_no_values,
933
-            $this->_cpt_model_obj->display_description()
934
-        );
935
-        $template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
936
-            'display_ticket_selector',
937
-            $yes_no_values,
938
-            $this->_cpt_model_obj->display_ticket_selector(),
939
-            '',
940
-            '',
941
-            false
942
-        );
943
-        $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
944
-            'EVT_default_registration_status',
945
-            $default_reg_status_values,
946
-            $this->_cpt_model_obj->default_registration_status()
947
-        );
948
-        $template_args['additional_registration_options'] = apply_filters(
949
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
950
-            '',
951
-            $template_args,
952
-            $yes_no_values,
953
-            $default_reg_status_values
954
-        );
955
-        EEH_Template::display_template(
956
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
957
-            $template_args
958
-        );
959
-    }
960
-
961
-
962
-
963
-    /**
964
-     * wp_list_table_mods for caf
965
-     * ============================
966
-     */
967
-    /**
968
-     * hook into list table filters and provide filters for caffeinated list table
969
-     *
970
-     * @param array $old_filters    any existing filters present
971
-     * @param array $list_table_obj the list table object
972
-     * @return array                  new filters
973
-     * @throws EE_Error
974
-     * @throws ReflectionException
975
-     */
976
-    public function list_table_filters($old_filters, $list_table_obj)
977
-    {
978
-        $filters = [];
979
-        // first month/year filters
980
-        $filters[] = $this->espresso_event_months_dropdown();
981
-        $status    = $this->request->getRequestParam('status');
982
-        // active status dropdown
983
-        if ($status !== 'draft') {
984
-            $filters[] = $this->active_status_dropdown($this->request->getRequestParam('active_status'));
985
-            $filters[] = $this->venuesDropdown($this->request->getRequestParam('venue'));
986
-        }
987
-        // category filter
988
-        $filters[] = $this->category_dropdown();
989
-        return array_merge($old_filters, $filters);
990
-    }
991
-
992
-
993
-    /**
994
-     * espresso_event_months_dropdown
995
-     *
996
-     * @access public
997
-     * @return string                dropdown listing month/year selections for events.
998
-     * @throws EE_Error
999
-     */
1000
-    public function espresso_event_months_dropdown()
1001
-    {
1002
-        // what we need to do is get all PRIMARY datetimes for all events to filter on.
1003
-        // Note we need to include any other filters that are set!
1004
-        return EEH_Form_Fields::generate_event_months_dropdown(
1005
-            $this->request->getRequestParam('month_range'),
1006
-            $this->request->getRequestParam('status'),
1007
-            $this->request->getRequestParam('EVT_CAT', 0, 'int'),
1008
-            $this->request->getRequestParam('active_status')
1009
-        );
1010
-    }
1011
-
1012
-
1013
-    /**
1014
-     * returns a list of "active" statuses on the event
1015
-     *
1016
-     * @param string $current_value whatever the current active status is
1017
-     * @return string
1018
-     */
1019
-    public function active_status_dropdown($current_value = '')
1020
-    {
1021
-        $select_name = 'active_status';
1022
-        $values      = [
1023
-            'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1024
-            'active'   => esc_html__('Active', 'event_espresso'),
1025
-            'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1026
-            'expired'  => esc_html__('Expired', 'event_espresso'),
1027
-            'inactive' => esc_html__('Inactive', 'event_espresso'),
1028
-        ];
1029
-
1030
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1031
-    }
1032
-
1033
-
1034
-    /**
1035
-     * returns a list of "venues"
1036
-     *
1037
-     * @param string $current_value whatever the current active status is
1038
-     * @return string
1039
-     * @throws EE_Error
1040
-     * @throws ReflectionException
1041
-     */
1042
-    protected function venuesDropdown($current_value = '')
1043
-    {
1044
-        $values = [
1045
-            '' => esc_html__('All Venues', 'event_espresso'),
1046
-        ];
1047
-        // populate the list of venues.
1048
-        $venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]);
1049
-
1050
-        foreach ($venues as $venue) {
1051
-            $values[ $venue->ID() ] = $venue->name();
1052
-        }
1053
-
1054
-        return EEH_Form_Fields::select_input('venue', $values, $current_value, '', 'wide');
1055
-    }
1056
-
1057
-
1058
-    /**
1059
-     * output a dropdown of the categories for the category filter on the event admin list table
1060
-     *
1061
-     * @access  public
1062
-     * @return string html
1063
-     * @throws EE_Error
1064
-     * @throws ReflectionException
1065
-     */
1066
-    public function category_dropdown()
1067
-    {
1068
-        return EEH_Form_Fields::generate_event_category_dropdown(
1069
-            $this->request->getRequestParam('EVT_CAT', -1, 'int')
1070
-        );
1071
-    }
1072
-
1073
-
1074
-    /**
1075
-     * get total number of events today
1076
-     *
1077
-     * @access public
1078
-     * @return int
1079
-     * @throws EE_Error
1080
-     */
1081
-    public function total_events_today()
1082
-    {
1083
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1084
-            'DTT_EVT_start',
1085
-            date('Y-m-d') . ' 00:00:00',
1086
-            'Y-m-d H:i:s',
1087
-            'UTC'
1088
-        );
1089
-        $end   = EEM_Datetime::instance()->convert_datetime_for_query(
1090
-            'DTT_EVT_start',
1091
-            date('Y-m-d') . ' 23:59:59',
1092
-            'Y-m-d H:i:s',
1093
-            'UTC'
1094
-        );
1095
-        $where = [
1096
-            'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1097
-        ];
1098
-        return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1099
-    }
1100
-
1101
-
1102
-    /**
1103
-     * get total number of events this month
1104
-     *
1105
-     * @access public
1106
-     * @return int
1107
-     * @throws EE_Error
1108
-     */
1109
-    public function total_events_this_month()
1110
-    {
1111
-        // Dates
1112
-        $this_year_r     = date('Y');
1113
-        $this_month_r    = date('m');
1114
-        $days_this_month = date('t');
1115
-        $start           = EEM_Datetime::instance()->convert_datetime_for_query(
1116
-            'DTT_EVT_start',
1117
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1118
-            'Y-m-d H:i:s',
1119
-            'UTC'
1120
-        );
1121
-        $end             = EEM_Datetime::instance()->convert_datetime_for_query(
1122
-            'DTT_EVT_start',
1123
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1124
-            'Y-m-d H:i:s',
1125
-            'UTC'
1126
-        );
1127
-        $where           = [
1128
-            'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1129
-        ];
1130
-        return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1131
-    }
1132
-
1133
-
1134
-    /** DEFAULT TICKETS STUFF **/
1135
-
1136
-    /**
1137
-     * Output default tickets list table view.
1138
-     *
1139
-     * @throws EE_Error
1140
-     */
1141
-    public function _tickets_overview_list_table()
1142
-    {
1143
-        $this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1144
-        $this->display_admin_list_table_page_with_no_sidebar();
1145
-    }
1146
-
1147
-
1148
-    /**
1149
-     * @param int  $per_page
1150
-     * @param bool $count
1151
-     * @param bool $trashed
1152
-     * @return EE_Soft_Delete_Base_Class[]|int
1153
-     * @throws EE_Error
1154
-     */
1155
-    public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1156
-    {
1157
-        $orderby = $this->request->getRequestParam('orderby', 'TKT_name');
1158
-        $order   = $this->request->getRequestParam('order', 'ASC');
1159
-        switch ($orderby) {
1160
-            case 'TKT_name':
1161
-                $orderby = ['TKT_name' => $order];
1162
-                break;
1163
-            case 'TKT_price':
1164
-                $orderby = ['TKT_price' => $order];
1165
-                break;
1166
-            case 'TKT_uses':
1167
-                $orderby = ['TKT_uses' => $order];
1168
-                break;
1169
-            case 'TKT_min':
1170
-                $orderby = ['TKT_min' => $order];
1171
-                break;
1172
-            case 'TKT_max':
1173
-                $orderby = ['TKT_max' => $order];
1174
-                break;
1175
-            case 'TKT_qty':
1176
-                $orderby = ['TKT_qty' => $order];
1177
-                break;
1178
-        }
1179
-
1180
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
1181
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1182
-        $offset       = ($current_page - 1) * $per_page;
1183
-
1184
-        $where = [
1185
-            'TKT_is_default' => 1,
1186
-            'TKT_deleted'    => $trashed,
1187
-        ];
1188
-
1189
-        $search_term = $this->request->getRequestParam('s');
1190
-        if ($search_term) {
1191
-            $search_term = '%' . $search_term . '%';
1192
-            $where['OR'] = [
1193
-                'TKT_name'        => ['LIKE', $search_term],
1194
-                'TKT_description' => ['LIKE', $search_term],
1195
-            ];
1196
-        }
1197
-
1198
-        return $count
1199
-            ? EEM_Ticket::instance()->count_deleted_and_undeleted([$where])
1200
-            : EEM_Ticket::instance()->get_all_deleted_and_undeleted(
1201
-                [
1202
-                    $where,
1203
-                    'order_by' => $orderby,
1204
-                    'limit'    => [$offset, $per_page],
1205
-                    'group_by' => 'TKT_ID',
1206
-                ]
1207
-            );
1208
-    }
1209
-
1210
-
1211
-    /**
1212
-     * @param bool $trash
1213
-     * @throws EE_Error
1214
-     */
1215
-    protected function _trash_or_restore_ticket($trash = false)
1216
-    {
1217
-        $success = 1;
1218
-        $TKT     = EEM_Ticket::instance();
1219
-        // checkboxes?
1220
-        $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1221
-        if (! empty($checkboxes)) {
1222
-            // if array has more than one element then success message should be plural
1223
-            $success = count($checkboxes) > 1 ? 2 : 1;
1224
-            // cycle thru the boxes
1225
-            while (list($TKT_ID, $value) = each($checkboxes)) {
1226
-                if ($trash) {
1227
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1228
-                        $success = 0;
1229
-                    }
1230
-                } else {
1231
-                    if (! $TKT->restore_by_ID($TKT_ID)) {
1232
-                        $success = 0;
1233
-                    }
1234
-                }
1235
-            }
1236
-        } else {
1237
-            // grab single id and trash
1238
-            $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1239
-            if ($trash) {
1240
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1241
-                    $success = 0;
1242
-                }
1243
-            } else {
1244
-                if (! $TKT->restore_by_ID($TKT_ID)) {
1245
-                    $success = 0;
1246
-                }
1247
-            }
1248
-        }
1249
-        $action_desc = $trash ? 'moved to the trash' : 'restored';
1250
-        $query_args  = [
1251
-            'action' => 'ticket_list_table',
1252
-            'status' => $trash ? '' : 'trashed',
1253
-        ];
1254
-        $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1255
-    }
1256
-
1257
-
1258
-    /**
1259
-     * Handles trashing default ticket.
1260
-     *
1261
-     * @throws EE_Error
1262
-     * @throws ReflectionException
1263
-     */
1264
-    protected function _delete_ticket()
1265
-    {
1266
-        $success = 1;
1267
-        // checkboxes?
1268
-        $checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1269
-        if (! empty($checkboxes)) {
1270
-            // if array has more than one element then success message should be plural
1271
-            $success = count($checkboxes) > 1 ? 2 : 1;
1272
-            // cycle thru the boxes
1273
-            while (list($TKT_ID, $value) = each($checkboxes)) {
1274
-                // delete
1275
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1276
-                    $success = 0;
1277
-                }
1278
-            }
1279
-        } else {
1280
-            // grab single id and trash
1281
-            $TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1282
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1283
-                $success = 0;
1284
-            }
1285
-        }
1286
-        $action_desc = 'deleted';
1287
-        $query_args  = [
1288
-            'action' => 'ticket_list_table',
1289
-            'status' => 'trashed',
1290
-        ];
1291
-        // fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1292
-        if (
1293
-            EEM_Ticket::instance()->count_deleted_and_undeleted(
1294
-                [['TKT_is_default' => 1]],
1295
-                'TKT_ID',
1296
-                true
1297
-            )
1298
-        ) {
1299
-            $query_args = [];
1300
-        }
1301
-        $this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1302
-    }
1303
-
1304
-
1305
-    /**
1306
-     * @param int $TKT_ID
1307
-     * @return bool|int
1308
-     * @throws EE_Error
1309
-     * @throws ReflectionException
1310
-     */
1311
-    protected function _delete_the_ticket($TKT_ID)
1312
-    {
1313
-        $ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1314
-        $ticket->_remove_relations('Datetime');
1315
-        // delete all related prices first
1316
-        $ticket->delete_related_permanently('Price');
1317
-        return $ticket->delete_permanently();
1318
-    }
17
+	/**
18
+	 * Extend_Events_Admin_Page constructor.
19
+	 *
20
+	 * @param bool $routing
21
+	 * @throws EE_Error
22
+	 * @throws ReflectionException
23
+	 */
24
+	public function __construct($routing = true)
25
+	{
26
+		parent::__construct($routing);
27
+		if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
28
+			define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
29
+			define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
30
+			define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
31
+		}
32
+	}
33
+
34
+
35
+	/**
36
+	 * Sets routes.
37
+	 *
38
+	 * @throws EE_Error
39
+	 */
40
+	protected function _extend_page_config()
41
+	{
42
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
43
+		// is there a evt_id in the request?
44
+		$EVT_ID             = $this->request->getRequestParam('EVT_ID', 0, 'int');
45
+		$EVT_ID             = $this->request->getRequestParam('post', $EVT_ID, 'int');
46
+		$TKT_ID             = $this->request->getRequestParam('TKT_ID', 0, 'int');
47
+		$new_page_routes    = [
48
+			'duplicate_event'          => [
49
+				'func'       => '_duplicate_event',
50
+				'capability' => 'ee_edit_event',
51
+				'obj_id'     => $EVT_ID,
52
+				'noheader'   => true,
53
+			],
54
+			'ticket_list_table'        => [
55
+				'func'       => '_tickets_overview_list_table',
56
+				'capability' => 'ee_read_default_tickets',
57
+			],
58
+			'trash_ticket'             => [
59
+				'func'       => '_trash_or_restore_ticket',
60
+				'capability' => 'ee_delete_default_ticket',
61
+				'obj_id'     => $TKT_ID,
62
+				'noheader'   => true,
63
+				'args'       => ['trash' => true],
64
+			],
65
+			'trash_tickets'            => [
66
+				'func'       => '_trash_or_restore_ticket',
67
+				'capability' => 'ee_delete_default_tickets',
68
+				'noheader'   => true,
69
+				'args'       => ['trash' => true],
70
+			],
71
+			'restore_ticket'           => [
72
+				'func'       => '_trash_or_restore_ticket',
73
+				'capability' => 'ee_delete_default_ticket',
74
+				'obj_id'     => $TKT_ID,
75
+				'noheader'   => true,
76
+			],
77
+			'restore_tickets'          => [
78
+				'func'       => '_trash_or_restore_ticket',
79
+				'capability' => 'ee_delete_default_tickets',
80
+				'noheader'   => true,
81
+			],
82
+			'delete_ticket'            => [
83
+				'func'       => '_delete_ticket',
84
+				'capability' => 'ee_delete_default_ticket',
85
+				'obj_id'     => $TKT_ID,
86
+				'noheader'   => true,
87
+			],
88
+			'delete_tickets'           => [
89
+				'func'       => '_delete_ticket',
90
+				'capability' => 'ee_delete_default_tickets',
91
+				'noheader'   => true,
92
+			],
93
+			'import_page'              => [
94
+				'func'       => '_import_page',
95
+				'capability' => 'import',
96
+			],
97
+			'import'                   => [
98
+				'func'       => '_import_events',
99
+				'capability' => 'import',
100
+				'noheader'   => true,
101
+			],
102
+			'import_events'            => [
103
+				'func'       => '_import_events',
104
+				'capability' => 'import',
105
+				'noheader'   => true,
106
+			],
107
+			'export_events'            => [
108
+				'func'       => '_events_export',
109
+				'capability' => 'export',
110
+				'noheader'   => true,
111
+			],
112
+			'export_categories'        => [
113
+				'func'       => '_categories_export',
114
+				'capability' => 'export',
115
+				'noheader'   => true,
116
+			],
117
+			'sample_export_file'       => [
118
+				'func'       => '_sample_export_file',
119
+				'capability' => 'export',
120
+				'noheader'   => true,
121
+			],
122
+			'update_template_settings' => [
123
+				'func'       => '_update_template_settings',
124
+				'capability' => 'manage_options',
125
+				'noheader'   => true,
126
+			],
127
+		];
128
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
129
+		// partial route/config override
130
+		$this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
131
+		$this->_page_config['create_new']['metaboxes'][]  = '_premium_event_editor_meta_boxes';
132
+		$this->_page_config['create_new']['qtips'][]      = 'EE_Event_Editor_Tips';
133
+		$this->_page_config['edit']['qtips'][]            = 'EE_Event_Editor_Tips';
134
+		$this->_page_config['edit']['metaboxes'][]        = '_premium_event_editor_meta_boxes';
135
+		$this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
136
+		// add tickets tab but only if there are more than one default ticket!
137
+		$ticket_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
138
+			[['TKT_is_default' => 1]],
139
+			'TKT_ID',
140
+			true
141
+		);
142
+		if ($ticket_count > 1) {
143
+			$new_page_config = [
144
+				'ticket_list_table' => [
145
+					'nav'           => [
146
+						'label' => esc_html__('Default Tickets', 'event_espresso'),
147
+						'order' => 60,
148
+					],
149
+					'list_table'    => 'Tickets_List_Table',
150
+					'require_nonce' => false,
151
+				],
152
+			];
153
+		}
154
+		// template settings
155
+		$new_page_config['template_settings'] = [
156
+			'nav'           => [
157
+				'label' => esc_html__('Templates', 'event_espresso'),
158
+				'order' => 30,
159
+			],
160
+			'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
161
+			'help_tabs'     => [
162
+				'general_settings_templates_help_tab' => [
163
+					'title'    => esc_html__('Templates', 'event_espresso'),
164
+					'filename' => 'general_settings_templates',
165
+				],
166
+			],
167
+			'require_nonce' => false,
168
+		];
169
+		$this->_page_config                   = array_merge($this->_page_config, $new_page_config);
170
+		// add filters and actions
171
+		// modifying _views
172
+		add_filter(
173
+			'FHEE_event_datetime_metabox_add_additional_date_time_template',
174
+			[$this, 'add_additional_datetime_button'],
175
+			10,
176
+			2
177
+		);
178
+		add_filter(
179
+			'FHEE_event_datetime_metabox_clone_button_template',
180
+			[$this, 'add_datetime_clone_button'],
181
+			10,
182
+			2
183
+		);
184
+		add_filter(
185
+			'FHEE_event_datetime_metabox_timezones_template',
186
+			[$this, 'datetime_timezones_template'],
187
+			10,
188
+			2
189
+		);
190
+		// filters for event list table
191
+		add_filter('FHEE__Extend_Events_Admin_List_Table__filters', [$this, 'list_table_filters'], 10, 2);
192
+		add_filter(
193
+			'FHEE__Events_Admin_List_Table__column_actions__action_links',
194
+			[$this, 'extra_list_table_actions'],
195
+			10,
196
+			2
197
+		);
198
+		// legend item
199
+		add_filter('FHEE__Events_Admin_Page___event_legend_items__items', [$this, 'additional_legend_items']);
200
+		add_action('admin_init', [$this, 'admin_init']);
201
+	}
202
+
203
+
204
+	/**
205
+	 * admin_init
206
+	 */
207
+	public function admin_init()
208
+	{
209
+		EE_Registry::$i18n_js_strings = array_merge(
210
+			EE_Registry::$i18n_js_strings,
211
+			[
212
+				'image_confirm'          => esc_html__(
213
+					'Do you really want to delete this image? Please remember to update your event to complete the removal.',
214
+					'event_espresso'
215
+				),
216
+				'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
217
+				'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
218
+				'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
219
+				'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
220
+				'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
221
+			]
222
+		);
223
+	}
224
+
225
+
226
+	/**
227
+	 * Add per page screen options to the default ticket list table view.
228
+	 */
229
+	protected function _add_screen_options_ticket_list_table()
230
+	{
231
+		$this->_per_page_screen_option();
232
+	}
233
+
234
+
235
+	/**
236
+	 * @param string $return
237
+	 * @param int    $id
238
+	 * @param string $new_title
239
+	 * @param string $new_slug
240
+	 * @return string
241
+	 */
242
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
243
+	{
244
+		$return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
245
+		// make sure this is only when editing
246
+		if (! empty($id)) {
247
+			$href   = EE_Admin_Page::add_query_args_and_nonce(
248
+				['action' => 'duplicate_event', 'EVT_ID' => $id],
249
+				$this->_admin_base_url
250
+			);
251
+			$title  = esc_attr__('Duplicate Event', 'event_espresso');
252
+			$return .= '<a href="'
253
+					   . $href
254
+					   . '" title="'
255
+					   . $title
256
+					   . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
257
+					   . $title
258
+					   . '</a>';
259
+		}
260
+		return $return;
261
+	}
262
+
263
+
264
+	/**
265
+	 * Set the list table views for the default ticket list table view.
266
+	 */
267
+	public function _set_list_table_views_ticket_list_table()
268
+	{
269
+		$this->_views = [
270
+			'all'     => [
271
+				'slug'        => 'all',
272
+				'label'       => esc_html__('All', 'event_espresso'),
273
+				'count'       => 0,
274
+				'bulk_action' => [
275
+					'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
276
+				],
277
+			],
278
+			'trashed' => [
279
+				'slug'        => 'trashed',
280
+				'label'       => esc_html__('Trash', 'event_espresso'),
281
+				'count'       => 0,
282
+				'bulk_action' => [
283
+					'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
284
+					'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
285
+				],
286
+			],
287
+		];
288
+	}
289
+
290
+
291
+	/**
292
+	 * Enqueue scripts and styles for the event editor.
293
+	 */
294
+	public function load_scripts_styles_edit()
295
+	{
296
+		wp_register_script(
297
+			'ee-event-editor-heartbeat',
298
+			EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
299
+			['ee_admin_js', 'heartbeat'],
300
+			EVENT_ESPRESSO_VERSION,
301
+			true
302
+		);
303
+		wp_enqueue_script('ee-accounting');
304
+		// styles
305
+		wp_enqueue_style('espresso-ui-theme');
306
+		wp_enqueue_script('event_editor_js');
307
+		wp_enqueue_script('ee-event-editor-heartbeat');
308
+	}
309
+
310
+
311
+	/**
312
+	 * Returns template for the additional datetime.
313
+	 *
314
+	 * @param string $template
315
+	 * @param array  $template_args
316
+	 * @return string
317
+	 * @throws DomainException
318
+	 */
319
+	public function add_additional_datetime_button($template, $template_args)
320
+	{
321
+		return EEH_Template::display_template(
322
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
323
+			$template_args,
324
+			true
325
+		);
326
+	}
327
+
328
+
329
+	/**
330
+	 * Returns the template for cloning a datetime.
331
+	 *
332
+	 * @param $template
333
+	 * @param $template_args
334
+	 * @return string
335
+	 * @throws DomainException
336
+	 */
337
+	public function add_datetime_clone_button($template, $template_args)
338
+	{
339
+		return EEH_Template::display_template(
340
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
341
+			$template_args,
342
+			true
343
+		);
344
+	}
345
+
346
+
347
+	/**
348
+	 * Returns the template for datetime timezones.
349
+	 *
350
+	 * @param $template
351
+	 * @param $template_args
352
+	 * @return string
353
+	 * @throws DomainException
354
+	 */
355
+	public function datetime_timezones_template($template, $template_args)
356
+	{
357
+		return EEH_Template::display_template(
358
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
359
+			$template_args,
360
+			true
361
+		);
362
+	}
363
+
364
+
365
+	/**
366
+	 * Sets the views for the default list table view.
367
+	 *
368
+	 * @throws EE_Error
369
+	 */
370
+	protected function _set_list_table_views_default()
371
+	{
372
+		parent::_set_list_table_views_default();
373
+		$new_views    = [
374
+			'today' => [
375
+				'slug'        => 'today',
376
+				'label'       => esc_html__('Today', 'event_espresso'),
377
+				'count'       => $this->total_events_today(),
378
+				'bulk_action' => [
379
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
380
+				],
381
+			],
382
+			'month' => [
383
+				'slug'        => 'month',
384
+				'label'       => esc_html__('This Month', 'event_espresso'),
385
+				'count'       => $this->total_events_this_month(),
386
+				'bulk_action' => [
387
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
388
+				],
389
+			],
390
+		];
391
+		$this->_views = array_merge($this->_views, $new_views);
392
+	}
393
+
394
+
395
+	/**
396
+	 * Returns the extra action links for the default list table view.
397
+	 *
398
+	 * @param array    $action_links
399
+	 * @param EE_Event $event
400
+	 * @return array
401
+	 * @throws EE_Error
402
+	 * @throws ReflectionException
403
+	 */
404
+	public function extra_list_table_actions(array $action_links, EE_Event $event)
405
+	{
406
+		if (
407
+			EE_Registry::instance()->CAP->current_user_can(
408
+				'ee_read_registrations',
409
+				'espresso_registrations_reports',
410
+				$event->ID()
411
+			)
412
+		) {
413
+			$reports_query_args = [
414
+				'action' => 'reports',
415
+				'EVT_ID' => $event->ID(),
416
+			];
417
+			$reports_link       = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
418
+			$action_links[]     = '<a href="'
419
+								  . $reports_link
420
+								  . '" title="'
421
+								  . esc_attr__('View Report', 'event_espresso')
422
+								  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
423
+								  . "\n\t";
424
+		}
425
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
426
+			EE_Registry::instance()->load_helper('MSG_Template');
427
+			$action_links[] = EEH_MSG_Template::get_message_action_link(
428
+				'see_notifications_for',
429
+				null,
430
+				['EVT_ID' => $event->ID()]
431
+			);
432
+		}
433
+		return $action_links;
434
+	}
435
+
436
+
437
+	/**
438
+	 * @param $items
439
+	 * @return mixed
440
+	 */
441
+	public function additional_legend_items($items)
442
+	{
443
+		if (
444
+			EE_Registry::instance()->CAP->current_user_can(
445
+				'ee_read_registrations',
446
+				'espresso_registrations_reports'
447
+			)
448
+		) {
449
+			$items['reports'] = [
450
+				'class' => 'dashicons dashicons-chart-bar',
451
+				'desc'  => esc_html__('Event Reports', 'event_espresso'),
452
+			];
453
+		}
454
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
455
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
456
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
457
+				$items['view_related_messages'] = [
458
+					'class' => $related_for_icon['css_class'],
459
+					'desc'  => $related_for_icon['label'],
460
+				];
461
+			}
462
+		}
463
+		return $items;
464
+	}
465
+
466
+
467
+	/**
468
+	 * This is the callback method for the duplicate event route
469
+	 * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
470
+	 * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
471
+	 * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
472
+	 * After duplication the redirect is to the new event edit page.
473
+	 *
474
+	 * @return void
475
+	 * @throws EE_Error If EE_Event is not available with given ID
476
+	 * @throws ReflectionException
477
+	 * @access protected
478
+	 */
479
+	protected function _duplicate_event()
480
+	{
481
+		// first make sure the ID for the event is in the request.
482
+		//  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
483
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
484
+		if (! $EVT_ID) {
485
+			EE_Error::add_error(
486
+				esc_html__(
487
+					'In order to duplicate an event an Event ID is required.  None was given.',
488
+					'event_espresso'
489
+				),
490
+				__FILE__,
491
+				__FUNCTION__,
492
+				__LINE__
493
+			);
494
+			$this->_redirect_after_action(false, '', '', [], true);
495
+			return;
496
+		}
497
+		// k we've got EVT_ID so let's use that to get the event we'll duplicate
498
+		$orig_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
499
+		if (! $orig_event instanceof EE_Event) {
500
+			throw new EE_Error(
501
+				sprintf(
502
+					esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
503
+					$EVT_ID
504
+				)
505
+			);
506
+		}
507
+		// k now let's clone the $orig_event before getting relations
508
+		$new_event = clone $orig_event;
509
+		// original datetimes
510
+		$orig_datetimes = $orig_event->get_many_related('Datetime');
511
+		// other original relations
512
+		$orig_ven = $orig_event->get_many_related('Venue');
513
+		// reset the ID and modify other details to make it clear this is a dupe
514
+		$new_event->set('EVT_ID', 0);
515
+		$new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
516
+		$new_event->set('EVT_name', $new_name);
517
+		$new_event->set(
518
+			'EVT_slug',
519
+			wp_unique_post_slug(
520
+				sanitize_title($orig_event->name()),
521
+				0,
522
+				'publish',
523
+				'espresso_events',
524
+				0
525
+			)
526
+		);
527
+		$new_event->set('status', 'draft');
528
+		// duplicate discussion settings
529
+		$new_event->set('comment_status', $orig_event->get('comment_status'));
530
+		$new_event->set('ping_status', $orig_event->get('ping_status'));
531
+		// save the new event
532
+		$new_event->save();
533
+		// venues
534
+		foreach ($orig_ven as $ven) {
535
+			$new_event->_add_relation_to($ven, 'Venue');
536
+		}
537
+		$new_event->save();
538
+		// now we need to get the question group relations and handle that
539
+		// first primary question groups
540
+		$orig_primary_qgs = $orig_event->get_many_related(
541
+			'Question_Group',
542
+			[['Event_Question_Group.EQG_primary' => true]]
543
+		);
544
+		if (! empty($orig_primary_qgs)) {
545
+			foreach ($orig_primary_qgs as $obj) {
546
+				if ($obj instanceof EE_Question_Group) {
547
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_primary' => true]);
548
+				}
549
+			}
550
+		}
551
+		// next additional attendee question groups
552
+		$orig_additional_qgs = $orig_event->get_many_related(
553
+			'Question_Group',
554
+			[['Event_Question_Group.EQG_additional' => true]]
555
+		);
556
+		if (! empty($orig_additional_qgs)) {
557
+			foreach ($orig_additional_qgs as $obj) {
558
+				if ($obj instanceof EE_Question_Group) {
559
+					$new_event->_add_relation_to($obj, 'Question_Group', ['EQG_additional' => true]);
560
+				}
561
+			}
562
+		}
563
+
564
+		$new_event->save();
565
+
566
+		// k now that we have the new event saved we can loop through the datetimes and start adding relations.
567
+		$cloned_tickets = [];
568
+		foreach ($orig_datetimes as $orig_dtt) {
569
+			if (! $orig_dtt instanceof EE_Datetime) {
570
+				continue;
571
+			}
572
+			$new_dtt      = clone $orig_dtt;
573
+			$orig_tickets = $orig_dtt->tickets();
574
+			// save new dtt then add to event
575
+			$new_dtt->set('DTT_ID', 0);
576
+			$new_dtt->set('DTT_sold', 0);
577
+			$new_dtt->set_reserved(0);
578
+			$new_dtt->save();
579
+			$new_event->_add_relation_to($new_dtt, 'Datetime');
580
+			$new_event->save();
581
+			// now let's get the ticket relations setup.
582
+			foreach ((array) $orig_tickets as $orig_ticket) {
583
+				// it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
584
+				if (! $orig_ticket instanceof EE_Ticket) {
585
+					continue;
586
+				}
587
+				// is this ticket archived?  If it is then let's skip
588
+				if ($orig_ticket->get('TKT_deleted')) {
589
+					continue;
590
+				}
591
+				// does this original ticket already exist in the clone_tickets cache?
592
+				//  If so we'll just use the new ticket from it.
593
+				if (isset($cloned_tickets[ $orig_ticket->ID() ])) {
594
+					$new_ticket = $cloned_tickets[ $orig_ticket->ID() ];
595
+				} else {
596
+					$new_ticket = clone $orig_ticket;
597
+					// get relations on the $orig_ticket that we need to setup.
598
+					$orig_prices = $orig_ticket->prices();
599
+					$new_ticket->set('TKT_ID', 0);
600
+					$new_ticket->set('TKT_sold', 0);
601
+					$new_ticket->set('TKT_reserved', 0);
602
+					$new_ticket->save(); // make sure new ticket has ID.
603
+					// price relations on new ticket need to be setup.
604
+					foreach ($orig_prices as $orig_price) {
605
+						$new_price = clone $orig_price;
606
+						$new_price->set('PRC_ID', 0);
607
+						$new_price->save();
608
+						$new_ticket->_add_relation_to($new_price, 'Price');
609
+						$new_ticket->save();
610
+					}
611
+
612
+					do_action(
613
+						'AHEE__Extend_Events_Admin_Page___duplicate_event__duplicate_ticket__after',
614
+						$orig_ticket,
615
+						$new_ticket,
616
+						$orig_prices,
617
+						$orig_event,
618
+						$orig_dtt,
619
+						$new_dtt
620
+					);
621
+				}
622
+				// k now we can add the new ticket as a relation to the new datetime
623
+				// and make sure its added to our cached $cloned_tickets array
624
+				// for use with later datetimes that have the same ticket.
625
+				$new_dtt->_add_relation_to($new_ticket, 'Ticket');
626
+				$new_dtt->save();
627
+				$cloned_tickets[ $orig_ticket->ID() ] = $new_ticket;
628
+			}
629
+		}
630
+		// clone taxonomy information
631
+		$taxonomies_to_clone_with = apply_filters(
632
+			'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
633
+			['espresso_event_categories', 'espresso_event_type', 'post_tag']
634
+		);
635
+		// get terms for original event (notice)
636
+		$orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
637
+		// loop through terms and add them to new event.
638
+		foreach ($orig_terms as $term) {
639
+			wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
640
+		}
641
+
642
+		// duplicate other core WP_Post items for this event.
643
+		// post thumbnail (feature image).
644
+		$feature_image_id = get_post_thumbnail_id($orig_event->ID());
645
+		if ($feature_image_id) {
646
+			update_post_meta($new_event->ID(), '_thumbnail_id', $feature_image_id);
647
+		}
648
+
649
+		// duplicate page_template setting
650
+		$page_template = get_post_meta($orig_event->ID(), '_wp_page_template', true);
651
+		if ($page_template) {
652
+			update_post_meta($new_event->ID(), '_wp_page_template', $page_template);
653
+		}
654
+
655
+		do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
656
+		// now let's redirect to the edit page for this duplicated event if we have a new event id.
657
+		if ($new_event->ID()) {
658
+			$redirect_args = [
659
+				'post'   => $new_event->ID(),
660
+				'action' => 'edit',
661
+			];
662
+			EE_Error::add_success(
663
+				esc_html__(
664
+					'Event successfully duplicated.  Please review the details below and make any necessary edits',
665
+					'event_espresso'
666
+				)
667
+			);
668
+		} else {
669
+			$redirect_args = [
670
+				'action' => 'default',
671
+			];
672
+			EE_Error::add_error(
673
+				esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
674
+				__FILE__,
675
+				__FUNCTION__,
676
+				__LINE__
677
+			);
678
+		}
679
+		$this->_redirect_after_action(false, '', '', $redirect_args, true);
680
+	}
681
+
682
+
683
+	/**
684
+	 * Generates output for the import page.
685
+	 *
686
+	 * @throws EE_Error
687
+	 */
688
+	protected function _import_page()
689
+	{
690
+		$title = esc_html__('Import', 'event_espresso');
691
+		$intro = esc_html__(
692
+			'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
693
+			'event_espresso'
694
+		);
695
+
696
+		$form_url = EVENTS_ADMIN_URL;
697
+		$action   = 'import_events';
698
+		$type     = 'csv';
699
+
700
+		$this->_template_args['form'] = EE_Import::instance()->upload_form(
701
+			$title,
702
+			$intro,
703
+			$form_url,
704
+			$action,
705
+			$type
706
+		);
707
+
708
+		$this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
709
+			['action' => 'sample_export_file'],
710
+			$this->_admin_base_url
711
+		);
712
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
713
+			EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
714
+			$this->_template_args,
715
+			true
716
+		);
717
+		$this->display_admin_page_with_sidebar();
718
+	}
719
+
720
+
721
+	/**
722
+	 * _import_events
723
+	 * This handles displaying the screen and running imports for importing events.
724
+	 *
725
+	 * @return void
726
+	 * @throws EE_Error
727
+	 */
728
+	protected function _import_events()
729
+	{
730
+		require_once(EE_CLASSES . 'EE_Import.class.php');
731
+		$success = EE_Import::instance()->import();
732
+		$this->_redirect_after_action(
733
+			$success,
734
+			esc_html__('Import File', 'event_espresso'),
735
+			'ran',
736
+			['action' => 'import_page'],
737
+			true
738
+		);
739
+	}
740
+
741
+
742
+	/**
743
+	 * _events_export
744
+	 * Will export all (or just the given event) to a Excel compatible file.
745
+	 *
746
+	 * @access protected
747
+	 * @return void
748
+	 */
749
+	protected function _events_export()
750
+	{
751
+		$EVT_ID = $this->request->getRequestParam('EVT_ID', 0, 'int');
752
+		$EVT_ID = $this->request->getRequestParam('EVT_IDs', $EVT_ID, 'int');
753
+		$this->request->mergeRequestParams(
754
+			[
755
+				'export' => 'report',
756
+				'action' => 'all_event_data',
757
+				'EVT_ID' => $EVT_ID,
758
+			]
759
+		);
760
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
761
+			require_once(EE_CLASSES . 'EE_Export.class.php');
762
+			$EE_Export = EE_Export::instance($this->request->requestParams());
763
+			$EE_Export->export();
764
+		}
765
+	}
766
+
767
+
768
+	/**
769
+	 * handle category exports()
770
+	 *
771
+	 * @return void
772
+	 */
773
+	protected function _categories_export()
774
+	{
775
+		$EVT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
776
+		$this->request->mergeRequestParams(
777
+			[
778
+				'export' => 'report',
779
+				'action' => 'categories',
780
+				'EVT_ID' => $EVT_ID,
781
+			]
782
+		);
783
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
784
+			require_once(EE_CLASSES . 'EE_Export.class.php');
785
+			$EE_Export = EE_Export::instance($this->request->requestParams());
786
+			$EE_Export->export();
787
+		}
788
+	}
789
+
790
+
791
+	/**
792
+	 * Creates a sample CSV file for importing
793
+	 */
794
+	protected function _sample_export_file()
795
+	{
796
+		// require_once(EE_CLASSES . 'EE_Export.class.php');
797
+		EE_Export::instance()->export_sample();
798
+	}
799
+
800
+
801
+	/*************        Template Settings        *************/
802
+	/**
803
+	 * Generates template settings page output
804
+	 *
805
+	 * @throws DomainException
806
+	 * @throws EE_Error
807
+	 */
808
+	protected function _template_settings()
809
+	{
810
+		$this->_template_args['values'] = $this->_yes_no_values;
811
+		/**
812
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
813
+		 * from General_Settings_Admin_Page to here.
814
+		 */
815
+		$this->_template_args = apply_filters(
816
+			'FHEE__General_Settings_Admin_Page__template_settings__template_args',
817
+			$this->_template_args
818
+		);
819
+		$this->_set_add_edit_form_tags('update_template_settings');
820
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
821
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
822
+			EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
823
+			$this->_template_args,
824
+			true
825
+		);
826
+		$this->display_admin_page_with_sidebar();
827
+	}
828
+
829
+
830
+	/**
831
+	 * Handler for updating template settings.
832
+	 *
833
+	 * @throws EE_Error
834
+	 */
835
+	protected function _update_template_settings()
836
+	{
837
+		/**
838
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
839
+		 * from General_Settings_Admin_Page to here.
840
+		 */
841
+		EE_Registry::instance()->CFG->template_settings = apply_filters(
842
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
843
+			EE_Registry::instance()->CFG->template_settings,
844
+			$this->request->requestParams()
845
+		);
846
+		// update custom post type slugs and detect if we need to flush rewrite rules
847
+		$old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
848
+
849
+		$event_cpt_slug = $this->request->getRequestParam('event_cpt_slug');
850
+
851
+		EE_Registry::instance()->CFG->core->event_cpt_slug = $event_cpt_slug
852
+			? EEH_URL::slugify($event_cpt_slug, 'events')
853
+			: EE_Registry::instance()->CFG->core->event_cpt_slug;
854
+
855
+		$what    = esc_html__('Template Settings', 'event_espresso');
856
+		$success = $this->_update_espresso_configuration(
857
+			$what,
858
+			EE_Registry::instance()->CFG->template_settings,
859
+			__FILE__,
860
+			__FUNCTION__,
861
+			__LINE__
862
+		);
863
+		if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) {
864
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
865
+			$rewrite_rules = LoaderFactory::getLoader()->getShared(
866
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
867
+			);
868
+			$rewrite_rules->flush();
869
+		}
870
+		$this->_redirect_after_action($success, $what, 'updated', ['action' => 'template_settings']);
871
+	}
872
+
873
+
874
+	/**
875
+	 * _premium_event_editor_meta_boxes
876
+	 * add all metaboxes related to the event_editor
877
+	 *
878
+	 * @access protected
879
+	 * @return void
880
+	 * @throws EE_Error
881
+	 * @throws ReflectionException
882
+	 */
883
+	protected function _premium_event_editor_meta_boxes()
884
+	{
885
+		$this->verify_cpt_object();
886
+		add_meta_box(
887
+			'espresso_event_editor_event_options',
888
+			esc_html__('Event Registration Options', 'event_espresso'),
889
+			[$this, 'registration_options_meta_box'],
890
+			$this->page_slug,
891
+			'side',
892
+			'core'
893
+		);
894
+	}
895
+
896
+
897
+	/**
898
+	 * override caf metabox
899
+	 *
900
+	 * @return void
901
+	 * @throws EE_Error
902
+	 * @throws ReflectionException
903
+	 */
904
+	public function registration_options_meta_box()
905
+	{
906
+		$yes_no_values = [
907
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
908
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
909
+		];
910
+
911
+		$default_reg_status_values = EEM_Registration::reg_status_array(
912
+			[
913
+				EEM_Registration::status_id_cancelled,
914
+				EEM_Registration::status_id_declined,
915
+				EEM_Registration::status_id_incomplete,
916
+				EEM_Registration::status_id_wait_list,
917
+			],
918
+			true
919
+		);
920
+
921
+		$template_args['active_status']    = $this->_cpt_model_obj->pretty_active_status(false);
922
+		$template_args['_event']           = $this->_cpt_model_obj;
923
+		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
924
+
925
+		$template_args['default_registration_status']     = EEH_Form_Fields::select_input(
926
+			'default_reg_status',
927
+			$default_reg_status_values,
928
+			$this->_cpt_model_obj->default_registration_status()
929
+		);
930
+		$template_args['display_description']             = EEH_Form_Fields::select_input(
931
+			'display_desc',
932
+			$yes_no_values,
933
+			$this->_cpt_model_obj->display_description()
934
+		);
935
+		$template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
936
+			'display_ticket_selector',
937
+			$yes_no_values,
938
+			$this->_cpt_model_obj->display_ticket_selector(),
939
+			'',
940
+			'',
941
+			false
942
+		);
943
+		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
944
+			'EVT_default_registration_status',
945
+			$default_reg_status_values,
946
+			$this->_cpt_model_obj->default_registration_status()
947
+		);
948
+		$template_args['additional_registration_options'] = apply_filters(
949
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
950
+			'',
951
+			$template_args,
952
+			$yes_no_values,
953
+			$default_reg_status_values
954
+		);
955
+		EEH_Template::display_template(
956
+			EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
957
+			$template_args
958
+		);
959
+	}
960
+
961
+
962
+
963
+	/**
964
+	 * wp_list_table_mods for caf
965
+	 * ============================
966
+	 */
967
+	/**
968
+	 * hook into list table filters and provide filters for caffeinated list table
969
+	 *
970
+	 * @param array $old_filters    any existing filters present
971
+	 * @param array $list_table_obj the list table object
972
+	 * @return array                  new filters
973
+	 * @throws EE_Error
974
+	 * @throws ReflectionException
975
+	 */
976
+	public function list_table_filters($old_filters, $list_table_obj)
977
+	{
978
+		$filters = [];
979
+		// first month/year filters
980
+		$filters[] = $this->espresso_event_months_dropdown();
981
+		$status    = $this->request->getRequestParam('status');
982
+		// active status dropdown
983
+		if ($status !== 'draft') {
984
+			$filters[] = $this->active_status_dropdown($this->request->getRequestParam('active_status'));
985
+			$filters[] = $this->venuesDropdown($this->request->getRequestParam('venue'));
986
+		}
987
+		// category filter
988
+		$filters[] = $this->category_dropdown();
989
+		return array_merge($old_filters, $filters);
990
+	}
991
+
992
+
993
+	/**
994
+	 * espresso_event_months_dropdown
995
+	 *
996
+	 * @access public
997
+	 * @return string                dropdown listing month/year selections for events.
998
+	 * @throws EE_Error
999
+	 */
1000
+	public function espresso_event_months_dropdown()
1001
+	{
1002
+		// what we need to do is get all PRIMARY datetimes for all events to filter on.
1003
+		// Note we need to include any other filters that are set!
1004
+		return EEH_Form_Fields::generate_event_months_dropdown(
1005
+			$this->request->getRequestParam('month_range'),
1006
+			$this->request->getRequestParam('status'),
1007
+			$this->request->getRequestParam('EVT_CAT', 0, 'int'),
1008
+			$this->request->getRequestParam('active_status')
1009
+		);
1010
+	}
1011
+
1012
+
1013
+	/**
1014
+	 * returns a list of "active" statuses on the event
1015
+	 *
1016
+	 * @param string $current_value whatever the current active status is
1017
+	 * @return string
1018
+	 */
1019
+	public function active_status_dropdown($current_value = '')
1020
+	{
1021
+		$select_name = 'active_status';
1022
+		$values      = [
1023
+			'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
1024
+			'active'   => esc_html__('Active', 'event_espresso'),
1025
+			'upcoming' => esc_html__('Upcoming', 'event_espresso'),
1026
+			'expired'  => esc_html__('Expired', 'event_espresso'),
1027
+			'inactive' => esc_html__('Inactive', 'event_espresso'),
1028
+		];
1029
+
1030
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, '', 'wide');
1031
+	}
1032
+
1033
+
1034
+	/**
1035
+	 * returns a list of "venues"
1036
+	 *
1037
+	 * @param string $current_value whatever the current active status is
1038
+	 * @return string
1039
+	 * @throws EE_Error
1040
+	 * @throws ReflectionException
1041
+	 */
1042
+	protected function venuesDropdown($current_value = '')
1043
+	{
1044
+		$values = [
1045
+			'' => esc_html__('All Venues', 'event_espresso'),
1046
+		];
1047
+		// populate the list of venues.
1048
+		$venues = EEM_Venue::instance()->get_all(['order_by' => ['VNU_name' => 'ASC']]);
1049
+
1050
+		foreach ($venues as $venue) {
1051
+			$values[ $venue->ID() ] = $venue->name();
1052
+		}
1053
+
1054
+		return EEH_Form_Fields::select_input('venue', $values, $current_value, '', 'wide');
1055
+	}
1056
+
1057
+
1058
+	/**
1059
+	 * output a dropdown of the categories for the category filter on the event admin list table
1060
+	 *
1061
+	 * @access  public
1062
+	 * @return string html
1063
+	 * @throws EE_Error
1064
+	 * @throws ReflectionException
1065
+	 */
1066
+	public function category_dropdown()
1067
+	{
1068
+		return EEH_Form_Fields::generate_event_category_dropdown(
1069
+			$this->request->getRequestParam('EVT_CAT', -1, 'int')
1070
+		);
1071
+	}
1072
+
1073
+
1074
+	/**
1075
+	 * get total number of events today
1076
+	 *
1077
+	 * @access public
1078
+	 * @return int
1079
+	 * @throws EE_Error
1080
+	 */
1081
+	public function total_events_today()
1082
+	{
1083
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1084
+			'DTT_EVT_start',
1085
+			date('Y-m-d') . ' 00:00:00',
1086
+			'Y-m-d H:i:s',
1087
+			'UTC'
1088
+		);
1089
+		$end   = EEM_Datetime::instance()->convert_datetime_for_query(
1090
+			'DTT_EVT_start',
1091
+			date('Y-m-d') . ' 23:59:59',
1092
+			'Y-m-d H:i:s',
1093
+			'UTC'
1094
+		);
1095
+		$where = [
1096
+			'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1097
+		];
1098
+		return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1099
+	}
1100
+
1101
+
1102
+	/**
1103
+	 * get total number of events this month
1104
+	 *
1105
+	 * @access public
1106
+	 * @return int
1107
+	 * @throws EE_Error
1108
+	 */
1109
+	public function total_events_this_month()
1110
+	{
1111
+		// Dates
1112
+		$this_year_r     = date('Y');
1113
+		$this_month_r    = date('m');
1114
+		$days_this_month = date('t');
1115
+		$start           = EEM_Datetime::instance()->convert_datetime_for_query(
1116
+			'DTT_EVT_start',
1117
+			$this_year_r . '-' . $this_month_r . '-01 00:00:00',
1118
+			'Y-m-d H:i:s',
1119
+			'UTC'
1120
+		);
1121
+		$end             = EEM_Datetime::instance()->convert_datetime_for_query(
1122
+			'DTT_EVT_start',
1123
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1124
+			'Y-m-d H:i:s',
1125
+			'UTC'
1126
+		);
1127
+		$where           = [
1128
+			'Datetime.DTT_EVT_start' => ['BETWEEN', [$start, $end]],
1129
+		];
1130
+		return EEM_Event::instance()->count([$where, 'caps' => 'read_admin'], 'EVT_ID', true);
1131
+	}
1132
+
1133
+
1134
+	/** DEFAULT TICKETS STUFF **/
1135
+
1136
+	/**
1137
+	 * Output default tickets list table view.
1138
+	 *
1139
+	 * @throws EE_Error
1140
+	 */
1141
+	public function _tickets_overview_list_table()
1142
+	{
1143
+		$this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1144
+		$this->display_admin_list_table_page_with_no_sidebar();
1145
+	}
1146
+
1147
+
1148
+	/**
1149
+	 * @param int  $per_page
1150
+	 * @param bool $count
1151
+	 * @param bool $trashed
1152
+	 * @return EE_Soft_Delete_Base_Class[]|int
1153
+	 * @throws EE_Error
1154
+	 */
1155
+	public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1156
+	{
1157
+		$orderby = $this->request->getRequestParam('orderby', 'TKT_name');
1158
+		$order   = $this->request->getRequestParam('order', 'ASC');
1159
+		switch ($orderby) {
1160
+			case 'TKT_name':
1161
+				$orderby = ['TKT_name' => $order];
1162
+				break;
1163
+			case 'TKT_price':
1164
+				$orderby = ['TKT_price' => $order];
1165
+				break;
1166
+			case 'TKT_uses':
1167
+				$orderby = ['TKT_uses' => $order];
1168
+				break;
1169
+			case 'TKT_min':
1170
+				$orderby = ['TKT_min' => $order];
1171
+				break;
1172
+			case 'TKT_max':
1173
+				$orderby = ['TKT_max' => $order];
1174
+				break;
1175
+			case 'TKT_qty':
1176
+				$orderby = ['TKT_qty' => $order];
1177
+				break;
1178
+		}
1179
+
1180
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
1181
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1182
+		$offset       = ($current_page - 1) * $per_page;
1183
+
1184
+		$where = [
1185
+			'TKT_is_default' => 1,
1186
+			'TKT_deleted'    => $trashed,
1187
+		];
1188
+
1189
+		$search_term = $this->request->getRequestParam('s');
1190
+		if ($search_term) {
1191
+			$search_term = '%' . $search_term . '%';
1192
+			$where['OR'] = [
1193
+				'TKT_name'        => ['LIKE', $search_term],
1194
+				'TKT_description' => ['LIKE', $search_term],
1195
+			];
1196
+		}
1197
+
1198
+		return $count
1199
+			? EEM_Ticket::instance()->count_deleted_and_undeleted([$where])
1200
+			: EEM_Ticket::instance()->get_all_deleted_and_undeleted(
1201
+				[
1202
+					$where,
1203
+					'order_by' => $orderby,
1204
+					'limit'    => [$offset, $per_page],
1205
+					'group_by' => 'TKT_ID',
1206
+				]
1207
+			);
1208
+	}
1209
+
1210
+
1211
+	/**
1212
+	 * @param bool $trash
1213
+	 * @throws EE_Error
1214
+	 */
1215
+	protected function _trash_or_restore_ticket($trash = false)
1216
+	{
1217
+		$success = 1;
1218
+		$TKT     = EEM_Ticket::instance();
1219
+		// checkboxes?
1220
+		$checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1221
+		if (! empty($checkboxes)) {
1222
+			// if array has more than one element then success message should be plural
1223
+			$success = count($checkboxes) > 1 ? 2 : 1;
1224
+			// cycle thru the boxes
1225
+			while (list($TKT_ID, $value) = each($checkboxes)) {
1226
+				if ($trash) {
1227
+					if (! $TKT->delete_by_ID($TKT_ID)) {
1228
+						$success = 0;
1229
+					}
1230
+				} else {
1231
+					if (! $TKT->restore_by_ID($TKT_ID)) {
1232
+						$success = 0;
1233
+					}
1234
+				}
1235
+			}
1236
+		} else {
1237
+			// grab single id and trash
1238
+			$TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1239
+			if ($trash) {
1240
+				if (! $TKT->delete_by_ID($TKT_ID)) {
1241
+					$success = 0;
1242
+				}
1243
+			} else {
1244
+				if (! $TKT->restore_by_ID($TKT_ID)) {
1245
+					$success = 0;
1246
+				}
1247
+			}
1248
+		}
1249
+		$action_desc = $trash ? 'moved to the trash' : 'restored';
1250
+		$query_args  = [
1251
+			'action' => 'ticket_list_table',
1252
+			'status' => $trash ? '' : 'trashed',
1253
+		];
1254
+		$this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1255
+	}
1256
+
1257
+
1258
+	/**
1259
+	 * Handles trashing default ticket.
1260
+	 *
1261
+	 * @throws EE_Error
1262
+	 * @throws ReflectionException
1263
+	 */
1264
+	protected function _delete_ticket()
1265
+	{
1266
+		$success = 1;
1267
+		// checkboxes?
1268
+		$checkboxes = $this->request->getRequestParam('checkbox', [], 'int', true);
1269
+		if (! empty($checkboxes)) {
1270
+			// if array has more than one element then success message should be plural
1271
+			$success = count($checkboxes) > 1 ? 2 : 1;
1272
+			// cycle thru the boxes
1273
+			while (list($TKT_ID, $value) = each($checkboxes)) {
1274
+				// delete
1275
+				if (! $this->_delete_the_ticket($TKT_ID)) {
1276
+					$success = 0;
1277
+				}
1278
+			}
1279
+		} else {
1280
+			// grab single id and trash
1281
+			$TKT_ID = $this->request->getRequestParam('TKT_ID', 0, 'int');
1282
+			if (! $this->_delete_the_ticket($TKT_ID)) {
1283
+				$success = 0;
1284
+			}
1285
+		}
1286
+		$action_desc = 'deleted';
1287
+		$query_args  = [
1288
+			'action' => 'ticket_list_table',
1289
+			'status' => 'trashed',
1290
+		];
1291
+		// fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1292
+		if (
1293
+			EEM_Ticket::instance()->count_deleted_and_undeleted(
1294
+				[['TKT_is_default' => 1]],
1295
+				'TKT_ID',
1296
+				true
1297
+			)
1298
+		) {
1299
+			$query_args = [];
1300
+		}
1301
+		$this->_redirect_after_action($success, esc_html__('Tickets', 'event_espresso'), $action_desc, $query_args);
1302
+	}
1303
+
1304
+
1305
+	/**
1306
+	 * @param int $TKT_ID
1307
+	 * @return bool|int
1308
+	 * @throws EE_Error
1309
+	 * @throws ReflectionException
1310
+	 */
1311
+	protected function _delete_the_ticket($TKT_ID)
1312
+	{
1313
+		$ticket = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1314
+		$ticket->_remove_relations('Datetime');
1315
+		// delete all related prices first
1316
+		$ticket->delete_related_permanently('Price');
1317
+		return $ticket->delete_permanently();
1318
+	}
1319 1319
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.29.rc.019');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.29.rc.019');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.