Completed
Branch add-cap-checks-to-routes (73eed8)
by
unknown
08:17 queued 10s
created
core/admin/EE_Admin_Page_Loader.core.php 2 patches
Indentation   +432 added lines, -432 removed lines patch added patch discarded remove patch
@@ -16,436 +16,436 @@
 block discarded – undo
16 16
  */
17 17
 class EE_Admin_Page_Loader
18 18
 {
19
-    /**
20
-     * @var AdminMenuManager $menu_manager
21
-     */
22
-    protected $menu_manager;
23
-
24
-    /**
25
-     * @var LoaderInterface $loader
26
-     */
27
-    protected $loader;
28
-
29
-    /**
30
-     * _installed_pages
31
-     * objects for page_init objects detected and loaded
32
-     *
33
-     * @access private
34
-     * @var EE_Admin_Page_Init[]
35
-     */
36
-    private $_installed_pages = [];
37
-
38
-
39
-    /**
40
-     * this is used to hold the registry of menu slugs for all the installed admin pages
41
-     *
42
-     * @var array
43
-     */
44
-    private $_menu_slugs = [];
45
-
46
-
47
-    /**
48
-     * _caffeinated_extends
49
-     * This array is the generated configuration array for which core EE_Admin pages are extended (and the bits and
50
-     * pieces needed to do so).  This property is defined in the _set_caffeinated method.
51
-     *
52
-     * @var array
53
-     */
54
-    private $_caffeinated_extends = [];
55
-
56
-
57
-    /**
58
-     * This property will hold the hook file for setting up the filter that does all the connections between admin
59
-     * pages.
60
-     *
61
-     * @var string
62
-     */
63
-    public $hook_file;
64
-
65
-    /**
66
-     * @var   int
67
-     * @since $VID:$
68
-     */
69
-    private $maintenance_mode = 0;
70
-
71
-
72
-    /**
73
-     * @throws InvalidArgumentException
74
-     * @throws InvalidDataTypeException
75
-     * @throws InvalidInterfaceException
76
-     */
77
-    public function __construct(?LoaderInterface $loader)
78
-    {
79
-        $this->loader = $loader instanceof LoaderInterface ? $loader : LoaderFactory::getLoader();
80
-        $this->menu_manager = $this->loader->getShared(AdminMenuManager::class, [$this->loader]);
81
-    }
82
-
83
-
84
-    /**
85
-     * @throws EE_Error
86
-     * @throws ReflectionException
87
-     * @since $VID:$
88
-     */
89
-    public function init()
90
-    {
91
-        $this->menu_manager->initialize();
92
-        $this->maintenance_mode = EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance;
93
-        // let's do a scan and see what installed pages we have
94
-        $this->findAndLoadAdminPages();
95
-    }
96
-
97
-
98
-    /**
99
-     * When caffeinated system is detected, this method is called to setup the caffeinated directory constants used by
100
-     * files in the caffeinated folder.
101
-     *
102
-     * @access private
103
-     * @return void
104
-     */
105
-    private function defineCaffeinatedConstants()
106
-    {
107
-        if (! defined('EE_CORE_CAF_ADMIN')) {
108
-            define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/');
109
-            define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/');
110
-            define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/');
111
-            define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/');
112
-            define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/');
113
-            define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/');
114
-        }
115
-    }
116
-
117
-
118
-    /**
119
-     * This just gets the list of installed EE_Admin_pages.
120
-     *
121
-     * @access private
122
-     * @return void
123
-     * @throws EE_Error
124
-     * @throws InvalidArgumentException
125
-     * @throws InvalidDataTypeException
126
-     * @throws InvalidInterfaceException
127
-     * @throws ReflectionException
128
-     */
129
-    private function findAndLoadAdminPages()
130
-    {
131
-        $admin_pages = $this->findAdminPages();
132
-        // this just checks the caffeinated folder and takes care of setting up any caffeinated stuff.
133
-        $admin_pages = $this->findCaffeinatedAdminPages($admin_pages);
134
-        // then extensions and hooks, although they don't get added to the admin pages array
135
-        $this->findAdminPageExtensions();
136
-        $this->findAdminPageHooks();
137
-        // allow plugins to add in their own pages (note at this point they will need to have an autoloader defined for their class) OR hook into EEH_Autoloader::load_admin_page() to add their path.;
138
-        // loop through admin pages and setup the $_installed_pages array.
139
-        $hooks_ref = [];
140
-        $menu_pages = [];
141
-        foreach ($admin_pages as $page => $path) {
142
-            // don't load the page init class IF IT's ALREADY LOADED !!!
143
-            if (
144
-                isset($this->_installed_pages[ $page ])
145
-                && $this->_installed_pages[ $page ] instanceof EE_Admin_Page_Init
146
-            ) {
147
-                continue;
148
-            }
149
-            // build list of installed pages
150
-            $admin_page_init = $this->loadAdminPageInit($page);
151
-            $this->_installed_pages[ $page ] = $admin_page_init;
152
-            $admin_menu = $this->menu_manager->getAdminMenu($admin_page_init);
153
-            $admin_page_init->setCapability($admin_menu->capability(), $admin_menu->menuSlug());
154
-            // skip if in full maintenance mode and maintenance_mode_parent is NOT set
155
-            if ($this->maintenance_mode && ! $admin_menu->maintenanceModeParent()) {
156
-                unset($admin_pages[ $page ]);
157
-                continue;
158
-            }
159
-            $menu_slug = $admin_menu->menuSlug();
160
-            $this->_menu_slugs[ $menu_slug ] = $page;
161
-            $menu_pages[ $menu_slug ] = $admin_page_init;
162
-            // now that we've got the admin_init objects...
163
-            // lets see if there are any caffeinated pages extending the originals.
164
-            // If there are then let's hook into the init admin filter and load our extend instead.
165
-            // Set flag for register hooks on extended pages b/c extended pages use the default INIT.
166
-            $extended_hooks = $admin_page_init->register_hooks(
167
-                $this->loadCaffeinatedExtensions($admin_page_init, $page, $menu_slug)
168
-            );
169
-            $hooks_ref      += $extended_hooks;
170
-        }
171
-        // the hooks_ref is all the pages where we have $extended _Hooks files
172
-        // that will extend a class in a different folder.
173
-        // So we want to make sure we load the file for the parent.
174
-        // first make sure we've got unique values
175
-        $hooks_ref = array_unique($hooks_ref);
176
-        // now let's loop and require!
177
-        foreach ($hooks_ref as $path) {
178
-            require_once($path);
179
-        }
180
-        // make sure we have menu slugs global setup. Used in EE_Admin_Page->page_setup() to ensure we don't do a full class load for an admin page that isn't requested.
181
-        global $ee_menu_slugs;
182
-        $ee_menu_slugs = $this->_menu_slugs;
183
-        // we need to loop again to run any early code
184
-        foreach ($this->_installed_pages as $page) {
185
-            $page->do_initial_loads();
186
-        }
187
-        $this->menu_manager->setInstalledPages($menu_pages);
188
-        do_action('AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages);
189
-    }
190
-
191
-
192
-    /**
193
-     * @return array
194
-     * @throws EE_Error
195
-     * @since   $VID:$
196
-     */
197
-    private function findAdminPages(): array
198
-    {
199
-
200
-        // grab everything in the  admin core directory
201
-        $admin_page_folders = $this->findAdminPageFolders(EE_ADMIN_PAGES . '*');
202
-        $admin_page_folders = apply_filters(
203
-            'FHEE__EE_Admin_Page_Loader__findAdminPages__admin_page_folders',
204
-            $admin_page_folders
205
-        );
206
-        if (! empty($admin_page_folders)) {
207
-            return $admin_page_folders;
208
-        }
209
-        $error_msg = esc_html__(
210
-            'There are no EE_Admin pages detected, it looks like EE did not install properly',
211
-            'event_espresso'
212
-        );
213
-        $error_msg .= '||';
214
-        $error_msg .= sprintf(
215
-            esc_html__(
216
-                'Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.',
217
-                'event_espresso'
218
-            ),
219
-            EE_ADMIN_PAGES
220
-        );
221
-        throw new RuntimeException($error_msg);
222
-    }
223
-
224
-
225
-    /**
226
-     * get_admin_page_object
227
-     *
228
-     * @param string $page_slug
229
-     * @return EE_Admin_Page
230
-     */
231
-    public function get_admin_page_object(string $page_slug = ''): ?EE_Admin_Page
232
-    {
233
-        return isset($this->_installed_pages[ $page_slug ])
234
-            ? $this->_installed_pages[ $page_slug ]->loaded_page_object()
235
-            : null;
236
-    }
237
-
238
-
239
-    /**
240
-     * generates an "Admin Page Init" class based on the directory  name
241
-     *
242
-     * @param string $dir_name
243
-     * @return string
244
-     */
245
-    private function getClassnameForAdminPageInit(string $dir_name = ''): string
246
-    {
247
-        $class_name = str_replace('_', ' ', strtolower($dir_name));
248
-        return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page_Init';
249
-    }
250
-
251
-
252
-    /**
253
-     * _load_admin_page
254
-     * Loads and instantiates page_init object for a single EE_admin page.
255
-     *
256
-     * @param string $page page_reference
257
-     * @return EE_Admin_Page_Init
258
-     * @throws EE_Error
259
-     */
260
-    private function loadAdminPageInit(string $page = ''): EE_Admin_Page_Init
261
-    {
262
-        $class_name = $this->getClassnameForAdminPageInit($page);
263
-        if (class_exists($class_name)) {
264
-            $admin_page_init = $this->loader->getShared($class_name);
265
-            // verify returned object
266
-            if ($admin_page_init instanceof EE_Admin_Page_Init) {
267
-                return $admin_page_init;
268
-            }
269
-        }
270
-        $error_msg = sprintf(
271
-            esc_html__('Something went wrong with loading the %s admin page.', 'event_espresso'),
272
-            $page
273
-        );
274
-        $error_msg .= '||'; // separates public from developer messages
275
-        $error_msg .= "\r\n";
276
-        $error_msg .= sprintf(
277
-            esc_html__('There is no Init class in place for the %s admin page.', 'event_espresso'),
278
-            $page
279
-        );
280
-        $error_msg .= '<br />';
281
-        $error_msg .= sprintf(
282
-            esc_html__(
283
-                'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
284
-                'event_espresso'
285
-            ),
286
-            '<strong>' . $class_name . '</strong>'
287
-        );
288
-        throw new EE_Error($error_msg);
289
-    }
290
-
291
-
292
-    /**
293
-     * This method is the "workhorse" for detecting and setting up caffeinated functionality.
294
-     * In this method there are three checks being done:
295
-     * 1. Do we have any NEW admin page sets.  If we do, lets add them into the menu setup (via the $admin_pages
296
-     * array) etc.  (new page sets are found in caffeinated/new/{page})
297
-     * 2. Do we have any EXTENDED page sets.  Basically an extended EE_Admin Page extends the core {child}_Admin_Page
298
-     * class.  eg. would be caffeinated/extend/events/Extend_Events_Admin_Page.core.php and in there would be a class:
299
-     * Extend_Events_Admin_Page extends Events_Admin_Page.
300
-     * 3. Do we have any files just for setting up hooks into other core pages.  The files can be any name in
301
-     * "caffeinated/hooks" EXCEPT they need a ".class.php" extension and the file name must correspond with the
302
-     * classname inside.  These classes are instantiated really early so that any hooks in them are run before the
303
-     * corresponding apply_filters/do_actions that are found in any future loaded EE_Admin pages (INCLUDING caffeinated
304
-     * admin_pages)
305
-     *
306
-     * @param array $admin_pages the original installed_refs array that may contain our NEW EE_Admin_Pages to be
307
-     *                              loaded.
308
-     * @return array
309
-     * @throws EE_Error
310
-     */
311
-    private function findCaffeinatedAdminPages(array $admin_pages): array
312
-    {
313
-        // first let's check if there IS a caffeinated folder. If there is not then lets get out.
314
-        if ((defined('EE_DECAF') && EE_DECAF) || ! is_dir(EE_PLUGIN_DIR_PATH . 'caffeinated/admin')) {
315
-            return $admin_pages;
316
-        }
317
-        $this->defineCaffeinatedConstants();
318
-        // okay let's setup an "New" pages first (we'll return installed refs later)
319
-        $admin_pages += $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'new/*', ['tickets']);
320
-
321
-        return apply_filters(
322
-            'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs',
323
-            $admin_pages
324
-        );
325
-    }
326
-
327
-
328
-    /**
329
-     * @throws EE_Error
330
-     * @since   $VID:$
331
-     */
332
-    private function findAdminPageExtensions()
333
-    {
334
-        // let's see if there are any EXTENDS to setup in the $_caffeinated_extends array
335
-        // (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page)
336
-        $extensions = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'extend/*');
337
-        if ($extensions) {
338
-            foreach ($extensions as $folder => $extension) {
339
-                // convert lowercase_snake_case to Uppercase_Snake_Case
340
-                $filename = str_replace(' ', '_', ucwords(str_replace('_', ' ', $folder)));
341
-                $filename = "Extend_{$filename}_Admin_Page";
342
-                $filepath = EE_CORE_CAF_ADMIN . "extend/$folder/$filename.core.php";
343
-                // save filename and filepath for later
344
-                $this->_caffeinated_extends[ $folder ]['path']       = str_replace(['\\', '/'], '/', $filepath);
345
-                $this->_caffeinated_extends[ $folder ]['admin_page'] = $filename;
346
-            }
347
-        }
348
-        $this->_caffeinated_extends = apply_filters(
349
-            'FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends',
350
-            $this->_caffeinated_extends
351
-        );
352
-    }
353
-
354
-
355
-    private function loadCaffeinatedExtensions(
356
-        EE_Admin_Page_Init $admin_page_init,
357
-        string $page,
358
-        string $menu_slug
359
-    ): bool {
360
-        if (! isset($this->_caffeinated_extends[ $page ])) {
361
-            return false;
362
-        }
363
-        $admin_page_name = $admin_page_init->get_admin_page_name();
364
-        $caf_path        = $this->_caffeinated_extends[ $page ]['path'];
365
-        $caf_admin_page  = $this->_caffeinated_extends[ $page ]['admin_page'];
366
-        add_filter(
367
-            "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$menu_slug}_$admin_page_name",
368
-            static function ($path_to_file) use ($caf_path) {
369
-                return $caf_path;
370
-            }
371
-        );
372
-        add_filter(
373
-            "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$menu_slug}_$admin_page_name",
374
-            static function ($admin_page) use ($caf_admin_page) {
375
-                return $caf_admin_page;
376
-            }
377
-        );
378
-        return true;
379
-    }
380
-
381
-
382
-    /**
383
-     * @throws EE_Error
384
-     * @since   $VID:$
385
-     */
386
-    private function findAdminPageHooks()
387
-    {
388
-        // let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!).
389
-        $ee_admin_hooks   = [];
390
-        $admin_page_hooks = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'hooks/*.class.php', [], 0, false);
391
-        if ($admin_page_hooks) {
392
-            foreach ($admin_page_hooks as $hook) {
393
-                if (is_readable($hook)) {
394
-                    require_once $hook;
395
-                    $classname = str_replace([EE_CORE_CAF_ADMIN . 'hooks/', '.class.php'], '', $hook);
396
-                    if (class_exists($classname)) {
397
-                        $ee_admin_hooks[] = $this->loader->getShared($classname);
398
-                    }
399
-                }
400
-            }
401
-        }
402
-        apply_filters('FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks);
403
-    }
404
-
405
-
406
-    /**
407
-     * _default_header_link
408
-     * This is just a dummy method to use with header submenu items
409
-     *
410
-     * @return bool false
411
-     */
412
-    public function _default_header_link(): bool
413
-    {
414
-        return false;
415
-    }
416
-
417
-
418
-    /**
419
-     * @param string $path
420
-     * @param int    $flags
421
-     * @param array  $exclude
422
-     * @param bool   $register_autoloaders
423
-     * @return array
424
-     * @throws EE_Error
425
-     * @since $VID:$
426
-     */
427
-    private function findAdminPageFolders(
428
-        string $path,
429
-        array $exclude = [],
430
-        int $flags = GLOB_ONLYDIR,
431
-        bool $register_autoloaders = true
432
-    ): array {
433
-        $folders = [];
434
-        $subfolders = glob($path, $flags);
435
-        if ($subfolders) {
436
-            foreach ($subfolders as $admin_screen) {
437
-                $admin_screen_name = basename($admin_screen);
438
-                // files and anything in the exclude array need not apply
439
-                if (! in_array($admin_screen_name, $exclude, true)) {
440
-                    // these folders represent the different EE admin pages
441
-                    $folders[ $admin_screen_name ] = $admin_screen;
442
-                    if ($register_autoloaders) {
443
-                        // set autoloaders for our admin page classes based on included path information
444
-                        EEH_Autoloader::register_autoloaders_for_each_file_in_folder($admin_screen);
445
-                    }
446
-                }
447
-            }
448
-        }
449
-        return $folders;
450
-    }
19
+	/**
20
+	 * @var AdminMenuManager $menu_manager
21
+	 */
22
+	protected $menu_manager;
23
+
24
+	/**
25
+	 * @var LoaderInterface $loader
26
+	 */
27
+	protected $loader;
28
+
29
+	/**
30
+	 * _installed_pages
31
+	 * objects for page_init objects detected and loaded
32
+	 *
33
+	 * @access private
34
+	 * @var EE_Admin_Page_Init[]
35
+	 */
36
+	private $_installed_pages = [];
37
+
38
+
39
+	/**
40
+	 * this is used to hold the registry of menu slugs for all the installed admin pages
41
+	 *
42
+	 * @var array
43
+	 */
44
+	private $_menu_slugs = [];
45
+
46
+
47
+	/**
48
+	 * _caffeinated_extends
49
+	 * This array is the generated configuration array for which core EE_Admin pages are extended (and the bits and
50
+	 * pieces needed to do so).  This property is defined in the _set_caffeinated method.
51
+	 *
52
+	 * @var array
53
+	 */
54
+	private $_caffeinated_extends = [];
55
+
56
+
57
+	/**
58
+	 * This property will hold the hook file for setting up the filter that does all the connections between admin
59
+	 * pages.
60
+	 *
61
+	 * @var string
62
+	 */
63
+	public $hook_file;
64
+
65
+	/**
66
+	 * @var   int
67
+	 * @since $VID:$
68
+	 */
69
+	private $maintenance_mode = 0;
70
+
71
+
72
+	/**
73
+	 * @throws InvalidArgumentException
74
+	 * @throws InvalidDataTypeException
75
+	 * @throws InvalidInterfaceException
76
+	 */
77
+	public function __construct(?LoaderInterface $loader)
78
+	{
79
+		$this->loader = $loader instanceof LoaderInterface ? $loader : LoaderFactory::getLoader();
80
+		$this->menu_manager = $this->loader->getShared(AdminMenuManager::class, [$this->loader]);
81
+	}
82
+
83
+
84
+	/**
85
+	 * @throws EE_Error
86
+	 * @throws ReflectionException
87
+	 * @since $VID:$
88
+	 */
89
+	public function init()
90
+	{
91
+		$this->menu_manager->initialize();
92
+		$this->maintenance_mode = EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance;
93
+		// let's do a scan and see what installed pages we have
94
+		$this->findAndLoadAdminPages();
95
+	}
96
+
97
+
98
+	/**
99
+	 * When caffeinated system is detected, this method is called to setup the caffeinated directory constants used by
100
+	 * files in the caffeinated folder.
101
+	 *
102
+	 * @access private
103
+	 * @return void
104
+	 */
105
+	private function defineCaffeinatedConstants()
106
+	{
107
+		if (! defined('EE_CORE_CAF_ADMIN')) {
108
+			define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/');
109
+			define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/');
110
+			define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/');
111
+			define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/');
112
+			define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/');
113
+			define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/');
114
+		}
115
+	}
116
+
117
+
118
+	/**
119
+	 * This just gets the list of installed EE_Admin_pages.
120
+	 *
121
+	 * @access private
122
+	 * @return void
123
+	 * @throws EE_Error
124
+	 * @throws InvalidArgumentException
125
+	 * @throws InvalidDataTypeException
126
+	 * @throws InvalidInterfaceException
127
+	 * @throws ReflectionException
128
+	 */
129
+	private function findAndLoadAdminPages()
130
+	{
131
+		$admin_pages = $this->findAdminPages();
132
+		// this just checks the caffeinated folder and takes care of setting up any caffeinated stuff.
133
+		$admin_pages = $this->findCaffeinatedAdminPages($admin_pages);
134
+		// then extensions and hooks, although they don't get added to the admin pages array
135
+		$this->findAdminPageExtensions();
136
+		$this->findAdminPageHooks();
137
+		// allow plugins to add in their own pages (note at this point they will need to have an autoloader defined for their class) OR hook into EEH_Autoloader::load_admin_page() to add their path.;
138
+		// loop through admin pages and setup the $_installed_pages array.
139
+		$hooks_ref = [];
140
+		$menu_pages = [];
141
+		foreach ($admin_pages as $page => $path) {
142
+			// don't load the page init class IF IT's ALREADY LOADED !!!
143
+			if (
144
+				isset($this->_installed_pages[ $page ])
145
+				&& $this->_installed_pages[ $page ] instanceof EE_Admin_Page_Init
146
+			) {
147
+				continue;
148
+			}
149
+			// build list of installed pages
150
+			$admin_page_init = $this->loadAdminPageInit($page);
151
+			$this->_installed_pages[ $page ] = $admin_page_init;
152
+			$admin_menu = $this->menu_manager->getAdminMenu($admin_page_init);
153
+			$admin_page_init->setCapability($admin_menu->capability(), $admin_menu->menuSlug());
154
+			// skip if in full maintenance mode and maintenance_mode_parent is NOT set
155
+			if ($this->maintenance_mode && ! $admin_menu->maintenanceModeParent()) {
156
+				unset($admin_pages[ $page ]);
157
+				continue;
158
+			}
159
+			$menu_slug = $admin_menu->menuSlug();
160
+			$this->_menu_slugs[ $menu_slug ] = $page;
161
+			$menu_pages[ $menu_slug ] = $admin_page_init;
162
+			// now that we've got the admin_init objects...
163
+			// lets see if there are any caffeinated pages extending the originals.
164
+			// If there are then let's hook into the init admin filter and load our extend instead.
165
+			// Set flag for register hooks on extended pages b/c extended pages use the default INIT.
166
+			$extended_hooks = $admin_page_init->register_hooks(
167
+				$this->loadCaffeinatedExtensions($admin_page_init, $page, $menu_slug)
168
+			);
169
+			$hooks_ref      += $extended_hooks;
170
+		}
171
+		// the hooks_ref is all the pages where we have $extended _Hooks files
172
+		// that will extend a class in a different folder.
173
+		// So we want to make sure we load the file for the parent.
174
+		// first make sure we've got unique values
175
+		$hooks_ref = array_unique($hooks_ref);
176
+		// now let's loop and require!
177
+		foreach ($hooks_ref as $path) {
178
+			require_once($path);
179
+		}
180
+		// make sure we have menu slugs global setup. Used in EE_Admin_Page->page_setup() to ensure we don't do a full class load for an admin page that isn't requested.
181
+		global $ee_menu_slugs;
182
+		$ee_menu_slugs = $this->_menu_slugs;
183
+		// we need to loop again to run any early code
184
+		foreach ($this->_installed_pages as $page) {
185
+			$page->do_initial_loads();
186
+		}
187
+		$this->menu_manager->setInstalledPages($menu_pages);
188
+		do_action('AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages);
189
+	}
190
+
191
+
192
+	/**
193
+	 * @return array
194
+	 * @throws EE_Error
195
+	 * @since   $VID:$
196
+	 */
197
+	private function findAdminPages(): array
198
+	{
199
+
200
+		// grab everything in the  admin core directory
201
+		$admin_page_folders = $this->findAdminPageFolders(EE_ADMIN_PAGES . '*');
202
+		$admin_page_folders = apply_filters(
203
+			'FHEE__EE_Admin_Page_Loader__findAdminPages__admin_page_folders',
204
+			$admin_page_folders
205
+		);
206
+		if (! empty($admin_page_folders)) {
207
+			return $admin_page_folders;
208
+		}
209
+		$error_msg = esc_html__(
210
+			'There are no EE_Admin pages detected, it looks like EE did not install properly',
211
+			'event_espresso'
212
+		);
213
+		$error_msg .= '||';
214
+		$error_msg .= sprintf(
215
+			esc_html__(
216
+				'Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.',
217
+				'event_espresso'
218
+			),
219
+			EE_ADMIN_PAGES
220
+		);
221
+		throw new RuntimeException($error_msg);
222
+	}
223
+
224
+
225
+	/**
226
+	 * get_admin_page_object
227
+	 *
228
+	 * @param string $page_slug
229
+	 * @return EE_Admin_Page
230
+	 */
231
+	public function get_admin_page_object(string $page_slug = ''): ?EE_Admin_Page
232
+	{
233
+		return isset($this->_installed_pages[ $page_slug ])
234
+			? $this->_installed_pages[ $page_slug ]->loaded_page_object()
235
+			: null;
236
+	}
237
+
238
+
239
+	/**
240
+	 * generates an "Admin Page Init" class based on the directory  name
241
+	 *
242
+	 * @param string $dir_name
243
+	 * @return string
244
+	 */
245
+	private function getClassnameForAdminPageInit(string $dir_name = ''): string
246
+	{
247
+		$class_name = str_replace('_', ' ', strtolower($dir_name));
248
+		return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page_Init';
249
+	}
250
+
251
+
252
+	/**
253
+	 * _load_admin_page
254
+	 * Loads and instantiates page_init object for a single EE_admin page.
255
+	 *
256
+	 * @param string $page page_reference
257
+	 * @return EE_Admin_Page_Init
258
+	 * @throws EE_Error
259
+	 */
260
+	private function loadAdminPageInit(string $page = ''): EE_Admin_Page_Init
261
+	{
262
+		$class_name = $this->getClassnameForAdminPageInit($page);
263
+		if (class_exists($class_name)) {
264
+			$admin_page_init = $this->loader->getShared($class_name);
265
+			// verify returned object
266
+			if ($admin_page_init instanceof EE_Admin_Page_Init) {
267
+				return $admin_page_init;
268
+			}
269
+		}
270
+		$error_msg = sprintf(
271
+			esc_html__('Something went wrong with loading the %s admin page.', 'event_espresso'),
272
+			$page
273
+		);
274
+		$error_msg .= '||'; // separates public from developer messages
275
+		$error_msg .= "\r\n";
276
+		$error_msg .= sprintf(
277
+			esc_html__('There is no Init class in place for the %s admin page.', 'event_espresso'),
278
+			$page
279
+		);
280
+		$error_msg .= '<br />';
281
+		$error_msg .= sprintf(
282
+			esc_html__(
283
+				'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
284
+				'event_espresso'
285
+			),
286
+			'<strong>' . $class_name . '</strong>'
287
+		);
288
+		throw new EE_Error($error_msg);
289
+	}
290
+
291
+
292
+	/**
293
+	 * This method is the "workhorse" for detecting and setting up caffeinated functionality.
294
+	 * In this method there are three checks being done:
295
+	 * 1. Do we have any NEW admin page sets.  If we do, lets add them into the menu setup (via the $admin_pages
296
+	 * array) etc.  (new page sets are found in caffeinated/new/{page})
297
+	 * 2. Do we have any EXTENDED page sets.  Basically an extended EE_Admin Page extends the core {child}_Admin_Page
298
+	 * class.  eg. would be caffeinated/extend/events/Extend_Events_Admin_Page.core.php and in there would be a class:
299
+	 * Extend_Events_Admin_Page extends Events_Admin_Page.
300
+	 * 3. Do we have any files just for setting up hooks into other core pages.  The files can be any name in
301
+	 * "caffeinated/hooks" EXCEPT they need a ".class.php" extension and the file name must correspond with the
302
+	 * classname inside.  These classes are instantiated really early so that any hooks in them are run before the
303
+	 * corresponding apply_filters/do_actions that are found in any future loaded EE_Admin pages (INCLUDING caffeinated
304
+	 * admin_pages)
305
+	 *
306
+	 * @param array $admin_pages the original installed_refs array that may contain our NEW EE_Admin_Pages to be
307
+	 *                              loaded.
308
+	 * @return array
309
+	 * @throws EE_Error
310
+	 */
311
+	private function findCaffeinatedAdminPages(array $admin_pages): array
312
+	{
313
+		// first let's check if there IS a caffeinated folder. If there is not then lets get out.
314
+		if ((defined('EE_DECAF') && EE_DECAF) || ! is_dir(EE_PLUGIN_DIR_PATH . 'caffeinated/admin')) {
315
+			return $admin_pages;
316
+		}
317
+		$this->defineCaffeinatedConstants();
318
+		// okay let's setup an "New" pages first (we'll return installed refs later)
319
+		$admin_pages += $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'new/*', ['tickets']);
320
+
321
+		return apply_filters(
322
+			'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs',
323
+			$admin_pages
324
+		);
325
+	}
326
+
327
+
328
+	/**
329
+	 * @throws EE_Error
330
+	 * @since   $VID:$
331
+	 */
332
+	private function findAdminPageExtensions()
333
+	{
334
+		// let's see if there are any EXTENDS to setup in the $_caffeinated_extends array
335
+		// (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page)
336
+		$extensions = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'extend/*');
337
+		if ($extensions) {
338
+			foreach ($extensions as $folder => $extension) {
339
+				// convert lowercase_snake_case to Uppercase_Snake_Case
340
+				$filename = str_replace(' ', '_', ucwords(str_replace('_', ' ', $folder)));
341
+				$filename = "Extend_{$filename}_Admin_Page";
342
+				$filepath = EE_CORE_CAF_ADMIN . "extend/$folder/$filename.core.php";
343
+				// save filename and filepath for later
344
+				$this->_caffeinated_extends[ $folder ]['path']       = str_replace(['\\', '/'], '/', $filepath);
345
+				$this->_caffeinated_extends[ $folder ]['admin_page'] = $filename;
346
+			}
347
+		}
348
+		$this->_caffeinated_extends = apply_filters(
349
+			'FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends',
350
+			$this->_caffeinated_extends
351
+		);
352
+	}
353
+
354
+
355
+	private function loadCaffeinatedExtensions(
356
+		EE_Admin_Page_Init $admin_page_init,
357
+		string $page,
358
+		string $menu_slug
359
+	): bool {
360
+		if (! isset($this->_caffeinated_extends[ $page ])) {
361
+			return false;
362
+		}
363
+		$admin_page_name = $admin_page_init->get_admin_page_name();
364
+		$caf_path        = $this->_caffeinated_extends[ $page ]['path'];
365
+		$caf_admin_page  = $this->_caffeinated_extends[ $page ]['admin_page'];
366
+		add_filter(
367
+			"FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$menu_slug}_$admin_page_name",
368
+			static function ($path_to_file) use ($caf_path) {
369
+				return $caf_path;
370
+			}
371
+		);
372
+		add_filter(
373
+			"FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$menu_slug}_$admin_page_name",
374
+			static function ($admin_page) use ($caf_admin_page) {
375
+				return $caf_admin_page;
376
+			}
377
+		);
378
+		return true;
379
+	}
380
+
381
+
382
+	/**
383
+	 * @throws EE_Error
384
+	 * @since   $VID:$
385
+	 */
386
+	private function findAdminPageHooks()
387
+	{
388
+		// let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!).
389
+		$ee_admin_hooks   = [];
390
+		$admin_page_hooks = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'hooks/*.class.php', [], 0, false);
391
+		if ($admin_page_hooks) {
392
+			foreach ($admin_page_hooks as $hook) {
393
+				if (is_readable($hook)) {
394
+					require_once $hook;
395
+					$classname = str_replace([EE_CORE_CAF_ADMIN . 'hooks/', '.class.php'], '', $hook);
396
+					if (class_exists($classname)) {
397
+						$ee_admin_hooks[] = $this->loader->getShared($classname);
398
+					}
399
+				}
400
+			}
401
+		}
402
+		apply_filters('FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks);
403
+	}
404
+
405
+
406
+	/**
407
+	 * _default_header_link
408
+	 * This is just a dummy method to use with header submenu items
409
+	 *
410
+	 * @return bool false
411
+	 */
412
+	public function _default_header_link(): bool
413
+	{
414
+		return false;
415
+	}
416
+
417
+
418
+	/**
419
+	 * @param string $path
420
+	 * @param int    $flags
421
+	 * @param array  $exclude
422
+	 * @param bool   $register_autoloaders
423
+	 * @return array
424
+	 * @throws EE_Error
425
+	 * @since $VID:$
426
+	 */
427
+	private function findAdminPageFolders(
428
+		string $path,
429
+		array $exclude = [],
430
+		int $flags = GLOB_ONLYDIR,
431
+		bool $register_autoloaders = true
432
+	): array {
433
+		$folders = [];
434
+		$subfolders = glob($path, $flags);
435
+		if ($subfolders) {
436
+			foreach ($subfolders as $admin_screen) {
437
+				$admin_screen_name = basename($admin_screen);
438
+				// files and anything in the exclude array need not apply
439
+				if (! in_array($admin_screen_name, $exclude, true)) {
440
+					// these folders represent the different EE admin pages
441
+					$folders[ $admin_screen_name ] = $admin_screen;
442
+					if ($register_autoloaders) {
443
+						// set autoloaders for our admin page classes based on included path information
444
+						EEH_Autoloader::register_autoloaders_for_each_file_in_folder($admin_screen);
445
+					}
446
+				}
447
+			}
448
+		}
449
+		return $folders;
450
+	}
451 451
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
      */
105 105
     private function defineCaffeinatedConstants()
106 106
     {
107
-        if (! defined('EE_CORE_CAF_ADMIN')) {
108
-            define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/');
109
-            define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/');
110
-            define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/');
111
-            define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/');
112
-            define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/');
113
-            define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/');
107
+        if ( ! defined('EE_CORE_CAF_ADMIN')) {
108
+            define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH.'caffeinated/admin/');
109
+            define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL.'caffeinated/admin/');
110
+            define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN.'new/');
111
+            define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN.'extend/');
112
+            define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL.'extend/');
113
+            define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN.'hooks/');
114 114
         }
115 115
     }
116 116
 
@@ -141,24 +141,24 @@  discard block
 block discarded – undo
141 141
         foreach ($admin_pages as $page => $path) {
142 142
             // don't load the page init class IF IT's ALREADY LOADED !!!
143 143
             if (
144
-                isset($this->_installed_pages[ $page ])
145
-                && $this->_installed_pages[ $page ] instanceof EE_Admin_Page_Init
144
+                isset($this->_installed_pages[$page])
145
+                && $this->_installed_pages[$page] instanceof EE_Admin_Page_Init
146 146
             ) {
147 147
                 continue;
148 148
             }
149 149
             // build list of installed pages
150 150
             $admin_page_init = $this->loadAdminPageInit($page);
151
-            $this->_installed_pages[ $page ] = $admin_page_init;
151
+            $this->_installed_pages[$page] = $admin_page_init;
152 152
             $admin_menu = $this->menu_manager->getAdminMenu($admin_page_init);
153 153
             $admin_page_init->setCapability($admin_menu->capability(), $admin_menu->menuSlug());
154 154
             // skip if in full maintenance mode and maintenance_mode_parent is NOT set
155 155
             if ($this->maintenance_mode && ! $admin_menu->maintenanceModeParent()) {
156
-                unset($admin_pages[ $page ]);
156
+                unset($admin_pages[$page]);
157 157
                 continue;
158 158
             }
159 159
             $menu_slug = $admin_menu->menuSlug();
160
-            $this->_menu_slugs[ $menu_slug ] = $page;
161
-            $menu_pages[ $menu_slug ] = $admin_page_init;
160
+            $this->_menu_slugs[$menu_slug] = $page;
161
+            $menu_pages[$menu_slug] = $admin_page_init;
162 162
             // now that we've got the admin_init objects...
163 163
             // lets see if there are any caffeinated pages extending the originals.
164 164
             // If there are then let's hook into the init admin filter and load our extend instead.
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
             $extended_hooks = $admin_page_init->register_hooks(
167 167
                 $this->loadCaffeinatedExtensions($admin_page_init, $page, $menu_slug)
168 168
             );
169
-            $hooks_ref      += $extended_hooks;
169
+            $hooks_ref += $extended_hooks;
170 170
         }
171 171
         // the hooks_ref is all the pages where we have $extended _Hooks files
172 172
         // that will extend a class in a different folder.
@@ -198,12 +198,12 @@  discard block
 block discarded – undo
198 198
     {
199 199
 
200 200
         // grab everything in the  admin core directory
201
-        $admin_page_folders = $this->findAdminPageFolders(EE_ADMIN_PAGES . '*');
201
+        $admin_page_folders = $this->findAdminPageFolders(EE_ADMIN_PAGES.'*');
202 202
         $admin_page_folders = apply_filters(
203 203
             'FHEE__EE_Admin_Page_Loader__findAdminPages__admin_page_folders',
204 204
             $admin_page_folders
205 205
         );
206
-        if (! empty($admin_page_folders)) {
206
+        if ( ! empty($admin_page_folders)) {
207 207
             return $admin_page_folders;
208 208
         }
209 209
         $error_msg = esc_html__(
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
      */
231 231
     public function get_admin_page_object(string $page_slug = ''): ?EE_Admin_Page
232 232
     {
233
-        return isset($this->_installed_pages[ $page_slug ])
234
-            ? $this->_installed_pages[ $page_slug ]->loaded_page_object()
233
+        return isset($this->_installed_pages[$page_slug])
234
+            ? $this->_installed_pages[$page_slug]->loaded_page_object()
235 235
             : null;
236 236
     }
237 237
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
     private function getClassnameForAdminPageInit(string $dir_name = ''): string
246 246
     {
247 247
         $class_name = str_replace('_', ' ', strtolower($dir_name));
248
-        return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page_Init';
248
+        return str_replace(' ', '_', ucwords($class_name)).'_Admin_Page_Init';
249 249
     }
250 250
 
251 251
 
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                 'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
284 284
                 'event_espresso'
285 285
             ),
286
-            '<strong>' . $class_name . '</strong>'
286
+            '<strong>'.$class_name.'</strong>'
287 287
         );
288 288
         throw new EE_Error($error_msg);
289 289
     }
@@ -311,12 +311,12 @@  discard block
 block discarded – undo
311 311
     private function findCaffeinatedAdminPages(array $admin_pages): array
312 312
     {
313 313
         // first let's check if there IS a caffeinated folder. If there is not then lets get out.
314
-        if ((defined('EE_DECAF') && EE_DECAF) || ! is_dir(EE_PLUGIN_DIR_PATH . 'caffeinated/admin')) {
314
+        if ((defined('EE_DECAF') && EE_DECAF) || ! is_dir(EE_PLUGIN_DIR_PATH.'caffeinated/admin')) {
315 315
             return $admin_pages;
316 316
         }
317 317
         $this->defineCaffeinatedConstants();
318 318
         // okay let's setup an "New" pages first (we'll return installed refs later)
319
-        $admin_pages += $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'new/*', ['tickets']);
319
+        $admin_pages += $this->findAdminPageFolders(EE_CORE_CAF_ADMIN.'new/*', ['tickets']);
320 320
 
321 321
         return apply_filters(
322 322
             'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs',
@@ -333,16 +333,16 @@  discard block
 block discarded – undo
333 333
     {
334 334
         // let's see if there are any EXTENDS to setup in the $_caffeinated_extends array
335 335
         // (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page)
336
-        $extensions = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'extend/*');
336
+        $extensions = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN.'extend/*');
337 337
         if ($extensions) {
338 338
             foreach ($extensions as $folder => $extension) {
339 339
                 // convert lowercase_snake_case to Uppercase_Snake_Case
340 340
                 $filename = str_replace(' ', '_', ucwords(str_replace('_', ' ', $folder)));
341 341
                 $filename = "Extend_{$filename}_Admin_Page";
342
-                $filepath = EE_CORE_CAF_ADMIN . "extend/$folder/$filename.core.php";
342
+                $filepath = EE_CORE_CAF_ADMIN."extend/$folder/$filename.core.php";
343 343
                 // save filename and filepath for later
344
-                $this->_caffeinated_extends[ $folder ]['path']       = str_replace(['\\', '/'], '/', $filepath);
345
-                $this->_caffeinated_extends[ $folder ]['admin_page'] = $filename;
344
+                $this->_caffeinated_extends[$folder]['path']       = str_replace(['\\', '/'], '/', $filepath);
345
+                $this->_caffeinated_extends[$folder]['admin_page'] = $filename;
346 346
             }
347 347
         }
348 348
         $this->_caffeinated_extends = apply_filters(
@@ -357,21 +357,21 @@  discard block
 block discarded – undo
357 357
         string $page,
358 358
         string $menu_slug
359 359
     ): bool {
360
-        if (! isset($this->_caffeinated_extends[ $page ])) {
360
+        if ( ! isset($this->_caffeinated_extends[$page])) {
361 361
             return false;
362 362
         }
363 363
         $admin_page_name = $admin_page_init->get_admin_page_name();
364
-        $caf_path        = $this->_caffeinated_extends[ $page ]['path'];
365
-        $caf_admin_page  = $this->_caffeinated_extends[ $page ]['admin_page'];
364
+        $caf_path        = $this->_caffeinated_extends[$page]['path'];
365
+        $caf_admin_page  = $this->_caffeinated_extends[$page]['admin_page'];
366 366
         add_filter(
367 367
             "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$menu_slug}_$admin_page_name",
368
-            static function ($path_to_file) use ($caf_path) {
368
+            static function($path_to_file) use ($caf_path) {
369 369
                 return $caf_path;
370 370
             }
371 371
         );
372 372
         add_filter(
373 373
             "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$menu_slug}_$admin_page_name",
374
-            static function ($admin_page) use ($caf_admin_page) {
374
+            static function($admin_page) use ($caf_admin_page) {
375 375
                 return $caf_admin_page;
376 376
             }
377 377
         );
@@ -387,12 +387,12 @@  discard block
 block discarded – undo
387 387
     {
388 388
         // let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!).
389 389
         $ee_admin_hooks   = [];
390
-        $admin_page_hooks = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN . 'hooks/*.class.php', [], 0, false);
390
+        $admin_page_hooks = $this->findAdminPageFolders(EE_CORE_CAF_ADMIN.'hooks/*.class.php', [], 0, false);
391 391
         if ($admin_page_hooks) {
392 392
             foreach ($admin_page_hooks as $hook) {
393 393
                 if (is_readable($hook)) {
394 394
                     require_once $hook;
395
-                    $classname = str_replace([EE_CORE_CAF_ADMIN . 'hooks/', '.class.php'], '', $hook);
395
+                    $classname = str_replace([EE_CORE_CAF_ADMIN.'hooks/', '.class.php'], '', $hook);
396 396
                     if (class_exists($classname)) {
397 397
                         $ee_admin_hooks[] = $this->loader->getShared($classname);
398 398
                     }
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
             foreach ($subfolders as $admin_screen) {
437 437
                 $admin_screen_name = basename($admin_screen);
438 438
                 // files and anything in the exclude array need not apply
439
-                if (! in_array($admin_screen_name, $exclude, true)) {
439
+                if ( ! in_array($admin_screen_name, $exclude, true)) {
440 440
                     // these folders represent the different EE admin pages
441
-                    $folders[ $admin_screen_name ] = $admin_screen;
441
+                    $folders[$admin_screen_name] = $admin_screen;
442 442
                     if ($register_autoloaders) {
443 443
                         // set autoloaders for our admin page classes based on included path information
444 444
                         EEH_Autoloader::register_autoloaders_for_each_file_in_folder($admin_screen);
Please login to merge, or discard this patch.
core/EE_Config.core.php 1 patch
Indentation   +3266 added lines, -3266 removed lines patch added patch discarded remove patch
@@ -18,2590 +18,2590 @@  discard block
 block discarded – undo
18 18
  */
19 19
 final class EE_Config implements ResettableInterface
20 20
 {
21
-    const OPTION_NAME = 'ee_config';
22
-
23
-    const LOG_NAME = 'ee_config_log';
24
-
25
-    const LOG_LENGTH = 100;
26
-
27
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
28
-
29
-    /**
30
-     *    instance of the EE_Config object
31
-     *
32
-     * @var    EE_Config $_instance
33
-     * @access    private
34
-     */
35
-    private static $_instance;
36
-
37
-    /**
38
-     * @var boolean $_logging_enabled
39
-     */
40
-    private static $_logging_enabled = false;
41
-
42
-    /**
43
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
44
-     */
45
-    private $legacy_shortcodes_manager;
46
-
47
-    /**
48
-     * An StdClass whose property names are addon slugs,
49
-     * and values are their config classes
50
-     *
51
-     * @var StdClass
52
-     */
53
-    public $addons;
54
-
55
-    /**
56
-     * @var EE_Admin_Config
57
-     */
58
-    public $admin;
59
-
60
-    /**
61
-     * @var EE_Core_Config
62
-     */
63
-    public $core;
64
-
65
-    /**
66
-     * @var EE_Currency_Config
67
-     */
68
-    public $currency;
69
-
70
-    /**
71
-     * @var EE_Organization_Config
72
-     */
73
-    public $organization;
74
-
75
-    /**
76
-     * @var EE_Registration_Config
77
-     */
78
-    public $registration;
79
-
80
-    /**
81
-     * @var EE_Template_Config
82
-     */
83
-    public $template_settings;
84
-
85
-    /**
86
-     * Holds EE environment values.
87
-     *
88
-     * @var EE_Environment_Config
89
-     */
90
-    public $environment;
91
-
92
-    /**
93
-     * settings pertaining to Google maps
94
-     *
95
-     * @var EE_Map_Config
96
-     */
97
-    public $map_settings;
98
-
99
-    /**
100
-     * settings pertaining to Taxes
101
-     *
102
-     * @var EE_Tax_Config
103
-     */
104
-    public $tax_settings;
105
-
106
-    /**
107
-     * Settings pertaining to global messages settings.
108
-     *
109
-     * @var EE_Messages_Config
110
-     */
111
-    public $messages;
112
-
113
-    /**
114
-     * @deprecated
115
-     * @var EE_Gateway_Config
116
-     */
117
-    public $gateway;
118
-
119
-    /**
120
-     * @var array
121
-     */
122
-    private $_addon_option_names = array();
123
-
124
-    /**
125
-     * @var array
126
-     */
127
-    private static $_module_route_map = array();
128
-
129
-    /**
130
-     * @var array
131
-     */
132
-    private static $_module_forward_map = array();
133
-
134
-    /**
135
-     * @var array
136
-     */
137
-    private static $_module_view_map = array();
138
-
139
-    /**
140
-     * @var bool
141
-     */
142
-    private static $initialized = false;
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
-        self::$initialized = false;
185
-        // we don't need to reset the static properties imo because those should
186
-        // only change when a module is added or removed. Currently we don't
187
-        // support removing a module during a request when it previously existed
188
-        if ($reinstantiate) {
189
-            return self::instance();
190
-        } else {
191
-            return null;
192
-        }
193
-    }
194
-
195
-
196
-    private function __construct()
197
-    {
198
-        if (self::$initialized) {
199
-            return;
200
-        }
201
-        self::$initialized = true;
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
-            [$this, 'register_shortcodes_and_modules'],
214
-            999
215
-        );
216
-        //  initialize shortcodes and modules
217
-        add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'initialize_shortcodes_and_modules']);
218
-        // register widgets
219
-        add_action('widgets_init', [$this, 'widgets_init'], 10);
220
-        // shutdown
221
-        add_action('shutdown', [$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 self::$_instance->template_settings->current_espresso_theme ?? 'Espresso_Arabica_2014';
246
-    }
247
-
248
-
249
-    /**
250
-     *        _initialize_config
251
-     *
252
-     * @access private
253
-     * @return void
254
-     */
255
-    private function _initialize_config()
256
-    {
257
-        EE_Config::trim_log();
258
-        // set defaults
259
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
260
-        $this->addons = new stdClass();
261
-        // set _module_route_map
262
-        EE_Config::$_module_route_map = array();
263
-        // set _module_forward_map
264
-        EE_Config::$_module_forward_map = array();
265
-        // set _module_view_map
266
-        EE_Config::$_module_view_map = array();
267
-    }
268
-
269
-
270
-    /**
271
-     *        load core plugin configuration
272
-     *
273
-     * @access private
274
-     * @return void
275
-     */
276
-    private function _load_core_config()
277
-    {
278
-        // load_core_config__start hook
279
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
280
-        $espresso_config = (array) $this->get_espresso_config();
281
-        // need to move the "addons" element to the end of the config array
282
-        // in case an addon config references one of the other config classes
283
-        $addons = $espresso_config['addons'] ?? new StdClass();
284
-        unset($espresso_config['addons']);
285
-        $espresso_config['addons'] = $addons;
286
-        foreach ($espresso_config as $config => $settings) {
287
-            // load_core_config__start hook
288
-            $settings = apply_filters(
289
-                'FHEE__EE_Config___load_core_config__config_settings',
290
-                $settings,
291
-                $config,
292
-                $this
293
-            );
294
-            if (is_object($settings) && property_exists($this, $config)) {
295
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
296
-                // call configs populate method to ensure any defaults are set for empty values.
297
-                if (method_exists($settings, 'populate')) {
298
-                    $this->{$config}->populate();
299
-                }
300
-                if (method_exists($settings, 'do_hooks')) {
301
-                    $this->{$config}->do_hooks();
302
-                }
303
-            }
304
-        }
305
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
306
-            $this->update_espresso_config();
307
-        }
308
-        // load_core_config__end hook
309
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
310
-    }
311
-
312
-
313
-    /**
314
-     *    _verify_config
315
-     *
316
-     * @access    protected
317
-     * @return    void
318
-     */
319
-    protected function _verify_config()
320
-    {
321
-        $this->core = $this->core instanceof EE_Core_Config
322
-            ? $this->core
323
-            : new EE_Core_Config();
324
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
325
-        $this->organization = $this->organization instanceof EE_Organization_Config
326
-            ? $this->organization
327
-            : new EE_Organization_Config();
328
-        $this->organization = apply_filters(
329
-            'FHEE__EE_Config___initialize_config__organization',
330
-            $this->organization
331
-        );
332
-        $this->currency = $this->currency instanceof EE_Currency_Config
333
-            ? $this->currency
334
-            : new EE_Currency_Config();
335
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
336
-        $this->registration = $this->registration instanceof EE_Registration_Config
337
-            ? $this->registration
338
-            : new EE_Registration_Config();
339
-        $this->registration = apply_filters(
340
-            'FHEE__EE_Config___initialize_config__registration',
341
-            $this->registration
342
-        );
343
-        $this->admin = $this->admin instanceof EE_Admin_Config
344
-            ? $this->admin
345
-            : new EE_Admin_Config();
346
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
347
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
348
-            ? $this->template_settings
349
-            : new EE_Template_Config();
350
-        $this->template_settings = apply_filters(
351
-            'FHEE__EE_Config___initialize_config__template_settings',
352
-            $this->template_settings
353
-        );
354
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
355
-            ? $this->map_settings
356
-            : new EE_Map_Config();
357
-        $this->map_settings = apply_filters(
358
-            'FHEE__EE_Config___initialize_config__map_settings',
359
-            $this->map_settings
360
-        );
361
-        $this->environment = $this->environment instanceof EE_Environment_Config
362
-            ? $this->environment
363
-            : new EE_Environment_Config();
364
-        $this->environment = apply_filters(
365
-            'FHEE__EE_Config___initialize_config__environment',
366
-            $this->environment
367
-        );
368
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
369
-            ? $this->tax_settings
370
-            : new EE_Tax_Config();
371
-        $this->tax_settings = apply_filters(
372
-            'FHEE__EE_Config___initialize_config__tax_settings',
373
-            $this->tax_settings
374
-        );
375
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
376
-        $this->messages = $this->messages instanceof EE_Messages_Config
377
-            ? $this->messages
378
-            : new EE_Messages_Config();
379
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
380
-            ? $this->gateway
381
-            : new EE_Gateway_Config();
382
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
383
-        $this->legacy_shortcodes_manager = null;
384
-    }
385
-
386
-
387
-    /**
388
-     *    get_espresso_config
389
-     *
390
-     * @access    public
391
-     * @return    array of espresso config stuff
392
-     */
393
-    public function get_espresso_config()
394
-    {
395
-        // grab espresso configuration
396
-        return apply_filters(
397
-            'FHEE__EE_Config__get_espresso_config__CFG',
398
-            get_option(EE_Config::OPTION_NAME, array())
399
-        );
400
-    }
401
-
402
-
403
-    /**
404
-     *    double_check_config_comparison
405
-     *
406
-     * @access    public
407
-     * @param string $option
408
-     * @param        $old_value
409
-     * @param        $value
410
-     */
411
-    public function double_check_config_comparison($option = '', $old_value, $value)
412
-    {
413
-        // make sure we're checking the ee config
414
-        if ($option === EE_Config::OPTION_NAME) {
415
-            // run a loose comparison of the old value against the new value for type and properties,
416
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
417
-            if ($value != $old_value) {
418
-                // if they are NOT the same, then remove the hook,
419
-                // which means the subsequent update results will be based solely on the update query results
420
-                // the reason we do this is because, as stated above,
421
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
422
-                // this happens PRIOR to serialization and any subsequent update.
423
-                // If values are found to match their previous old value,
424
-                // then WP bails before performing any update.
425
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
426
-                // it just pulled from the db, with the one being passed to it (which will not match).
427
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
428
-                // MySQL MAY ALSO NOT perform the update because
429
-                // the string it sees in the db looks the same as the new one it has been passed!!!
430
-                // This results in the query returning an "affected rows" value of ZERO,
431
-                // which gets returned immediately by WP update_option and looks like an error.
432
-                remove_action('update_option', array($this, 'check_config_updated'));
433
-            }
434
-        }
435
-    }
436
-
437
-
438
-    /**
439
-     *    update_espresso_config
440
-     *
441
-     * @access   public
442
-     */
443
-    protected function _reset_espresso_addon_config()
444
-    {
445
-        $this->_addon_option_names = array();
446
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
447
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
448
-            if ($addon_config_obj instanceof EE_Config_Base) {
449
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
450
-            }
451
-            $this->addons->{$addon_name} = null;
452
-        }
453
-    }
454
-
455
-
456
-    /**
457
-     *    update_espresso_config
458
-     *
459
-     * @access   public
460
-     * @param   bool $add_success
461
-     * @param   bool $add_error
462
-     * @return   bool
463
-     */
464
-    public function update_espresso_config($add_success = false, $add_error = true)
465
-    {
466
-        // don't allow config updates during WP heartbeats
467
-        /** @var RequestInterface $request */
468
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
469
-        if ($request->isWordPressHeartbeat()) {
470
-            return false;
471
-        }
472
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
473
-        // $clone = clone( self::$_instance );
474
-        // self::$_instance = NULL;
475
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
476
-        $this->_reset_espresso_addon_config();
477
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
478
-        // but BEFORE the actual update occurs
479
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
480
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
481
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
482
-        $this->legacy_shortcodes_manager = null;
483
-        // now update "ee_config"
484
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
485
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
486
-        EE_Config::log(EE_Config::OPTION_NAME);
487
-        // if not saved... check if the hook we just added still exists;
488
-        // if it does, it means one of two things:
489
-        // that update_option bailed at the($value === $old_value) conditional,
490
-        // or...
491
-        // the db update query returned 0 rows affected
492
-        // (probably because the data  value was the same from it's perspective)
493
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
494
-        // but just means no update occurred, so don't display an error to the user.
495
-        // BUT... if update_option returns FALSE, AND the hook is missing,
496
-        // then it means that something truly went wrong
497
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
498
-        // remove our action since we don't want it in the system anymore
499
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
500
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
501
-        // self::$_instance = $clone;
502
-        // unset( $clone );
503
-        // if config remains the same or was updated successfully
504
-        if ($saved) {
505
-            if ($add_success) {
506
-                EE_Error::add_success(
507
-                    esc_html__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
508
-                    __FILE__,
509
-                    __FUNCTION__,
510
-                    __LINE__
511
-                );
512
-            }
513
-            return true;
514
-        } else {
515
-            if ($add_error) {
516
-                EE_Error::add_error(
517
-                    esc_html__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
518
-                    __FILE__,
519
-                    __FUNCTION__,
520
-                    __LINE__
521
-                );
522
-            }
523
-            return false;
524
-        }
525
-    }
526
-
527
-
528
-    /**
529
-     *    _verify_config_params
530
-     *
531
-     * @access    private
532
-     * @param    string         $section
533
-     * @param    string         $name
534
-     * @param    string         $config_class
535
-     * @param    EE_Config_Base $config_obj
536
-     * @param    array          $tests_to_run
537
-     * @param    bool           $display_errors
538
-     * @return    bool    TRUE on success, FALSE on fail
539
-     */
540
-    private function _verify_config_params(
541
-        $section = '',
542
-        $name = '',
543
-        $config_class = '',
544
-        $config_obj = null,
545
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
-        $display_errors = true
547
-    ) {
548
-        try {
549
-            foreach ($tests_to_run as $test) {
550
-                switch ($test) {
551
-                    // TEST #1 : check that section was set
552
-                    case 1:
553
-                        if (empty($section)) {
554
-                            if ($display_errors) {
555
-                                throw new EE_Error(
556
-                                    sprintf(
557
-                                        esc_html__(
558
-                                            'No configuration section has been provided while attempting to save "%s".',
559
-                                            'event_espresso'
560
-                                        ),
561
-                                        $config_class
562
-                                    )
563
-                                );
564
-                            }
565
-                            return false;
566
-                        }
567
-                        break;
568
-                    // TEST #2 : check that settings section exists
569
-                    case 2:
570
-                        if (! isset($this->{$section})) {
571
-                            if ($display_errors) {
572
-                                throw new EE_Error(
573
-                                    sprintf(
574
-                                        esc_html__('The "%s" configuration section does not exist.', 'event_espresso'),
575
-                                        $section
576
-                                    )
577
-                                );
578
-                            }
579
-                            return false;
580
-                        }
581
-                        break;
582
-                    // TEST #3 : check that section is the proper format
583
-                    case 3:
584
-                        if (
585
-                            ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
-                        ) {
587
-                            if ($display_errors) {
588
-                                throw new EE_Error(
589
-                                    sprintf(
590
-                                        esc_html__(
591
-                                            'The "%s" configuration settings have not been formatted correctly.',
592
-                                            'event_espresso'
593
-                                        ),
594
-                                        $section
595
-                                    )
596
-                                );
597
-                            }
598
-                            return false;
599
-                        }
600
-                        break;
601
-                    // TEST #4 : check that config section name has been set
602
-                    case 4:
603
-                        if (empty($name)) {
604
-                            if ($display_errors) {
605
-                                throw new EE_Error(
606
-                                    esc_html__(
607
-                                        'No name has been provided for the specific configuration section.',
608
-                                        'event_espresso'
609
-                                    )
610
-                                );
611
-                            }
612
-                            return false;
613
-                        }
614
-                        break;
615
-                    // TEST #5 : check that a config class name has been set
616
-                    case 5:
617
-                        if (empty($config_class)) {
618
-                            if ($display_errors) {
619
-                                throw new EE_Error(
620
-                                    esc_html__(
621
-                                        'No class name has been provided for the specific configuration section.',
622
-                                        'event_espresso'
623
-                                    )
624
-                                );
625
-                            }
626
-                            return false;
627
-                        }
628
-                        break;
629
-                    // TEST #6 : verify config class is accessible
630
-                    case 6:
631
-                        if (! class_exists($config_class)) {
632
-                            if ($display_errors) {
633
-                                throw new EE_Error(
634
-                                    sprintf(
635
-                                        esc_html__(
636
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
-                                            'event_espresso'
638
-                                        ),
639
-                                        $config_class
640
-                                    )
641
-                                );
642
-                            }
643
-                            return false;
644
-                        }
645
-                        break;
646
-                    // TEST #7 : check that config has even been set
647
-                    case 7:
648
-                        if (! isset($this->{$section}->{$name})) {
649
-                            if ($display_errors) {
650
-                                throw new EE_Error(
651
-                                    sprintf(
652
-                                        esc_html__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
-                                        $section,
654
-                                        $name
655
-                                    )
656
-                                );
657
-                            }
658
-                            return false;
659
-                        } else {
660
-                            // and make sure it's not serialized
661
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
-                        }
663
-                        break;
664
-                    // TEST #8 : check that config is the requested type
665
-                    case 8:
666
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
667
-                            if ($display_errors) {
668
-                                throw new EE_Error(
669
-                                    sprintf(
670
-                                        esc_html__(
671
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
-                                            'event_espresso'
673
-                                        ),
674
-                                        $section,
675
-                                        $name,
676
-                                        $config_class
677
-                                    )
678
-                                );
679
-                            }
680
-                            return false;
681
-                        }
682
-                        break;
683
-                    // TEST #9 : verify config object
684
-                    case 9:
685
-                        if (! $config_obj instanceof EE_Config_Base) {
686
-                            if ($display_errors) {
687
-                                throw new EE_Error(
688
-                                    sprintf(
689
-                                        esc_html__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
-                                        print_r($config_obj, true)
691
-                                    )
692
-                                );
693
-                            }
694
-                            return false;
695
-                        }
696
-                        break;
697
-                }
698
-            }
699
-        } catch (EE_Error $e) {
700
-            $e->get_error();
701
-        }
702
-        // you have successfully run the gauntlet
703
-        return true;
704
-    }
705
-
706
-
707
-    /**
708
-     *    _generate_config_option_name
709
-     *
710
-     * @access        protected
711
-     * @param        string $section
712
-     * @param        string $name
713
-     * @return        string
714
-     */
715
-    private function _generate_config_option_name($section = '', $name = '')
716
-    {
717
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
718
-    }
719
-
720
-
721
-    /**
722
-     *    _set_config_class
723
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
724
-     *
725
-     * @access    private
726
-     * @param    string $config_class
727
-     * @param    string $name
728
-     * @return    string
729
-     */
730
-    private function _set_config_class($config_class = '', $name = '')
731
-    {
732
-        return ! empty($config_class)
733
-            ? $config_class
734
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
735
-    }
736
-
737
-
738
-    /**
739
-     *    set_config
740
-     *
741
-     * @access    protected
742
-     * @param    string         $section
743
-     * @param    string         $name
744
-     * @param    string         $config_class
745
-     * @param    EE_Config_Base $config_obj
746
-     * @return    EE_Config_Base
747
-     */
748
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
749
-    {
750
-        // ensure config class is set to something
751
-        $config_class = $this->_set_config_class($config_class, $name);
752
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
753
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
754
-            return null;
755
-        }
756
-        $config_option_name = $this->_generate_config_option_name($section, $name);
757
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
758
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
759
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
760
-            $this->update_addon_option_names();
761
-        }
762
-        // verify the incoming config object but suppress errors
763
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
764
-            $config_obj = new $config_class();
765
-        }
766
-        if (get_option($config_option_name)) {
767
-            EE_Config::log($config_option_name);
768
-            update_option($config_option_name, $config_obj);
769
-            $this->{$section}->{$name} = $config_obj;
770
-            return $this->{$section}->{$name};
771
-        } else {
772
-            // create a wp-option for this config
773
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
774
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
775
-                return $this->{$section}->{$name};
776
-            } else {
777
-                EE_Error::add_error(
778
-                    sprintf(esc_html__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
779
-                    __FILE__,
780
-                    __FUNCTION__,
781
-                    __LINE__
782
-                );
783
-                return null;
784
-            }
785
-        }
786
-    }
787
-
788
-
789
-    /**
790
-     *    update_config
791
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
792
-     *
793
-     * @access    public
794
-     * @param    string                $section
795
-     * @param    string                $name
796
-     * @param    EE_Config_Base|string $config_obj
797
-     * @param    bool                  $throw_errors
798
-     * @return    bool
799
-     */
800
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
801
-    {
802
-        // don't allow config updates during WP heartbeats
803
-        /** @var RequestInterface $request */
804
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
805
-        if ($request->isWordPressHeartbeat()) {
806
-            return false;
807
-        }
808
-        $config_obj = maybe_unserialize($config_obj);
809
-        // get class name of the incoming object
810
-        $config_class = get_class($config_obj);
811
-        // run tests 1-5 and 9 to verify config
812
-        if (
813
-            ! $this->_verify_config_params(
814
-                $section,
815
-                $name,
816
-                $config_class,
817
-                $config_obj,
818
-                array(1, 2, 3, 4, 7, 9)
819
-            )
820
-        ) {
821
-            return false;
822
-        }
823
-        $config_option_name = $this->_generate_config_option_name($section, $name);
824
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
825
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
826
-            // save new config to db
827
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
828
-                return true;
829
-            }
830
-        } else {
831
-            // first check if the record already exists
832
-            $existing_config = get_option($config_option_name);
833
-            $config_obj = serialize($config_obj);
834
-            // just return if db record is already up to date (NOT type safe comparison)
835
-            if ($existing_config == $config_obj) {
836
-                $this->{$section}->{$name} = $config_obj;
837
-                return true;
838
-            } elseif (update_option($config_option_name, $config_obj)) {
839
-                EE_Config::log($config_option_name);
840
-                // update wp-option for this config class
841
-                $this->{$section}->{$name} = $config_obj;
842
-                return true;
843
-            } elseif ($throw_errors) {
844
-                EE_Error::add_error(
845
-                    sprintf(
846
-                        esc_html__(
847
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
848
-                            'event_espresso'
849
-                        ),
850
-                        $config_class,
851
-                        'EE_Config->' . $section . '->' . $name
852
-                    ),
853
-                    __FILE__,
854
-                    __FUNCTION__,
855
-                    __LINE__
856
-                );
857
-            }
858
-        }
859
-        return false;
860
-    }
861
-
862
-
863
-    /**
864
-     *    get_config
865
-     *
866
-     * @access    public
867
-     * @param    string $section
868
-     * @param    string $name
869
-     * @param    string $config_class
870
-     * @return    mixed EE_Config_Base | NULL
871
-     */
872
-    public function get_config($section = '', $name = '', $config_class = '')
873
-    {
874
-        // ensure config class is set to something
875
-        $config_class = $this->_set_config_class($config_class, $name);
876
-        // run tests 1-4, 6 and 7 to verify that all params have been set
877
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
878
-            return null;
879
-        }
880
-        // now test if the requested config object exists, but suppress errors
881
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
882
-            // config already exists, so pass it back
883
-            return $this->{$section}->{$name};
884
-        }
885
-        // load config option from db if it exists
886
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
887
-        // verify the newly retrieved config object, but suppress errors
888
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
889
-            // config is good, so set it and pass it back
890
-            $this->{$section}->{$name} = $config_obj;
891
-            return $this->{$section}->{$name};
892
-        }
893
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
894
-        $config_obj = $this->set_config($section, $name, $config_class);
895
-        // verify the newly created config object
896
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
897
-            return $this->{$section}->{$name};
898
-        } else {
899
-            EE_Error::add_error(
900
-                sprintf(esc_html__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
901
-                __FILE__,
902
-                __FUNCTION__,
903
-                __LINE__
904
-            );
905
-        }
906
-        return null;
907
-    }
908
-
909
-
910
-    /**
911
-     *    get_config_option
912
-     *
913
-     * @access    public
914
-     * @param    string $config_option_name
915
-     * @return    mixed EE_Config_Base | FALSE
916
-     */
917
-    public function get_config_option($config_option_name = '')
918
-    {
919
-        // retrieve the wp-option for this config class.
920
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
921
-        if (empty($config_option)) {
922
-            EE_Config::log($config_option_name . '-NOT-FOUND');
923
-        }
924
-        return $config_option;
925
-    }
926
-
927
-
928
-    /**
929
-     * log
930
-     *
931
-     * @param string $config_option_name
932
-     */
933
-    public static function log($config_option_name = '')
934
-    {
935
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
936
-            $config_log = get_option(EE_Config::LOG_NAME, array());
937
-            /** @var RequestParams $request */
938
-            $request = LoaderFactory::getLoader()->getShared(RequestParams::class);
939
-            $config_log[ (string) microtime(true) ] = array(
940
-                'config_name' => $config_option_name,
941
-                'request'     => $request->requestParams(),
942
-            );
943
-            update_option(EE_Config::LOG_NAME, $config_log);
944
-        }
945
-    }
946
-
947
-
948
-    /**
949
-     * trim_log
950
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
951
-     */
952
-    public static function trim_log()
953
-    {
954
-        if (! EE_Config::logging_enabled()) {
955
-            return;
956
-        }
957
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
958
-        $log_length = count($config_log);
959
-        if ($log_length > EE_Config::LOG_LENGTH) {
960
-            ksort($config_log);
961
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
962
-            update_option(EE_Config::LOG_NAME, $config_log);
963
-        }
964
-    }
965
-
966
-
967
-    /**
968
-     *    get_page_for_posts
969
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
970
-     *    wp-option "page_for_posts", or "posts" if no page is selected
971
-     *
972
-     * @access    public
973
-     * @return    string
974
-     */
975
-    public static function get_page_for_posts()
976
-    {
977
-        $page_for_posts = get_option('page_for_posts');
978
-        if (! $page_for_posts) {
979
-            return 'posts';
980
-        }
981
-        global $wpdb;
982
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
983
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
984
-    }
985
-
986
-
987
-    /**
988
-     *    register_shortcodes_and_modules.
989
-     *    At this point, it's too early to tell if we're maintenance mode or not.
990
-     *    In fact, this is where we give modules a chance to let core know they exist
991
-     *    so they can help trigger maintenance mode if it's needed
992
-     *
993
-     * @access    public
994
-     * @return    void
995
-     */
996
-    public function register_shortcodes_and_modules()
997
-    {
998
-        // allow modules to set hooks for the rest of the system
999
-        EE_Registry::instance()->modules = $this->_register_modules();
1000
-    }
1001
-
1002
-
1003
-    /**
1004
-     *    initialize_shortcodes_and_modules
1005
-     *    meaning they can start adding their hooks to get stuff done
1006
-     *
1007
-     * @access    public
1008
-     * @return    void
1009
-     */
1010
-    public function initialize_shortcodes_and_modules()
1011
-    {
1012
-        // allow modules to set hooks for the rest of the system
1013
-        $this->_initialize_modules();
1014
-    }
1015
-
1016
-
1017
-    /**
1018
-     *    widgets_init
1019
-     *
1020
-     * @access private
1021
-     * @return void
1022
-     */
1023
-    public function widgets_init()
1024
-    {
1025
-        // only init widgets on admin pages when not in complete maintenance, and
1026
-        // on frontend when not in any maintenance mode
1027
-        if (
1028
-            ! EE_Maintenance_Mode::instance()->level()
1029
-            || (
1030
-                is_admin()
1031
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1032
-            )
1033
-        ) {
1034
-            // grab list of installed widgets
1035
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1036
-            // filter list of modules to register
1037
-            $widgets_to_register = apply_filters(
1038
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1039
-                $widgets_to_register
1040
-            );
1041
-            if (! empty($widgets_to_register)) {
1042
-                // cycle thru widget folders
1043
-                foreach ($widgets_to_register as $widget_path) {
1044
-                    // add to list of installed widget modules
1045
-                    EE_Config::register_ee_widget($widget_path);
1046
-                }
1047
-            }
1048
-            // filter list of installed modules
1049
-            EE_Registry::instance()->widgets = apply_filters(
1050
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1051
-                EE_Registry::instance()->widgets
1052
-            );
1053
-        }
1054
-    }
1055
-
1056
-
1057
-    /**
1058
-     *    register_ee_widget - makes core aware of this widget
1059
-     *
1060
-     * @access    public
1061
-     * @param    string $widget_path - full path up to and including widget folder
1062
-     * @return    void
1063
-     */
1064
-    public static function register_ee_widget($widget_path = null)
1065
-    {
1066
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1067
-        $widget_ext = '.widget.php';
1068
-        // make all separators match
1069
-        $widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1070
-        // does the file path INCLUDE the actual file name as part of the path ?
1071
-        if (strpos($widget_path, $widget_ext) !== false) {
1072
-            // grab and shortcode file name from directory name and break apart at dots
1073
-            $file_name = explode('.', basename($widget_path));
1074
-            // take first segment from file name pieces and remove class prefix if it exists
1075
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1076
-            // sanitize shortcode directory name
1077
-            $widget = sanitize_key($widget);
1078
-            // now we need to rebuild the shortcode path
1079
-            $widget_path = explode('/', $widget_path);
1080
-            // remove last segment
1081
-            array_pop($widget_path);
1082
-            // glue it back together
1083
-            $widget_path = implode(DS, $widget_path);
1084
-        } else {
1085
-            // grab and sanitize widget directory name
1086
-            $widget = sanitize_key(basename($widget_path));
1087
-        }
1088
-        // create classname from widget directory name
1089
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1090
-        // add class prefix
1091
-        $widget_class = 'EEW_' . $widget;
1092
-        // does the widget exist ?
1093
-        if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1094
-            $msg = sprintf(
1095
-                esc_html__(
1096
-                    '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',
1097
-                    'event_espresso'
1098
-                ),
1099
-                $widget_class,
1100
-                $widget_path . '/' . $widget_class . $widget_ext
1101
-            );
1102
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1103
-            return;
1104
-        }
1105
-        // load the widget class file
1106
-        require_once($widget_path . '/' . $widget_class . $widget_ext);
1107
-        // verify that class exists
1108
-        if (! class_exists($widget_class)) {
1109
-            $msg = sprintf(esc_html__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1110
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1111
-            return;
1112
-        }
1113
-        register_widget($widget_class);
1114
-        // add to array of registered widgets
1115
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1116
-    }
1117
-
1118
-
1119
-    /**
1120
-     *        _register_modules
1121
-     *
1122
-     * @access private
1123
-     * @return array
1124
-     */
1125
-    private function _register_modules()
1126
-    {
1127
-        // grab list of installed modules
1128
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1129
-        // filter list of modules to register
1130
-        $modules_to_register = apply_filters(
1131
-            'FHEE__EE_Config__register_modules__modules_to_register',
1132
-            $modules_to_register
1133
-        );
1134
-        if (! empty($modules_to_register)) {
1135
-            // loop through folders
1136
-            foreach ($modules_to_register as $module_path) {
1137
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1138
-                if (
1139
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1140
-                    && $module_path !== EE_MODULES . 'gateways'
1141
-                ) {
1142
-                    // add to list of installed modules
1143
-                    EE_Config::register_module($module_path);
1144
-                }
1145
-            }
1146
-        }
1147
-        // filter list of installed modules
1148
-        return apply_filters(
1149
-            'FHEE__EE_Config___register_modules__installed_modules',
1150
-            EE_Registry::instance()->modules
1151
-        );
1152
-    }
1153
-
1154
-
1155
-    /**
1156
-     *    register_module - makes core aware of this module
1157
-     *
1158
-     * @access    public
1159
-     * @param    string $module_path - full path up to and including module folder
1160
-     * @return    bool
1161
-     */
1162
-    public static function register_module($module_path = null)
1163
-    {
1164
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1165
-        $module_ext = '.module.php';
1166
-        // make all separators match
1167
-        $module_path = str_replace(array('\\', '/'), '/', $module_path);
1168
-        // does the file path INCLUDE the actual file name as part of the path ?
1169
-        if (strpos($module_path, $module_ext) !== false) {
1170
-            // grab and shortcode file name from directory name and break apart at dots
1171
-            $module_file = explode('.', basename($module_path));
1172
-            // now we need to rebuild the shortcode path
1173
-            $module_path = explode('/', $module_path);
1174
-            // remove last segment
1175
-            array_pop($module_path);
1176
-            // glue it back together
1177
-            $module_path = implode('/', $module_path) . '/';
1178
-            // take first segment from file name pieces and sanitize it
1179
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1180
-            // ensure class prefix is added
1181
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1182
-        } else {
1183
-            // we need to generate the filename based off of the folder name
1184
-            // grab and sanitize module name
1185
-            $module = strtolower(basename($module_path));
1186
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1187
-            // like trailingslashit()
1188
-            $module_path = rtrim($module_path, '/') . '/';
1189
-            // create classname from module directory name
1190
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1191
-            // add class prefix
1192
-            $module_class = 'EED_' . $module;
1193
-        }
1194
-        // does the module exist ?
1195
-        if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1196
-            $msg = sprintf(
1197
-                esc_html__(
1198
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1199
-                    'event_espresso'
1200
-                ),
1201
-                $module
1202
-            );
1203
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1204
-            return false;
1205
-        }
1206
-        // load the module class file
1207
-        require_once($module_path . $module_class . $module_ext);
1208
-        // verify that class exists
1209
-        if (! class_exists($module_class)) {
1210
-            $msg = sprintf(esc_html__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1211
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1212
-            return false;
1213
-        }
1214
-        // add to array of registered modules
1215
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1216
-        do_action(
1217
-            'AHEE__EE_Config__register_module__complete',
1218
-            $module_class,
1219
-            EE_Registry::instance()->modules->{$module_class}
1220
-        );
1221
-        return true;
1222
-    }
1223
-
1224
-
1225
-    /**
1226
-     *    _initialize_modules
1227
-     *    allow modules to set hooks for the rest of the system
1228
-     *
1229
-     * @access private
1230
-     * @return void
1231
-     */
1232
-    private function _initialize_modules()
1233
-    {
1234
-        // cycle thru shortcode folders
1235
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1236
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1237
-            // which set hooks ?
1238
-            if (is_admin()) {
1239
-                // fire immediately
1240
-                call_user_func(array($module_class, 'set_hooks_admin'));
1241
-            } else {
1242
-                // delay until other systems are online
1243
-                add_action(
1244
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1245
-                    array($module_class, 'set_hooks')
1246
-                );
1247
-            }
1248
-        }
1249
-    }
1250
-
1251
-
1252
-    /**
1253
-     *    register_route - adds module method routes to route_map
1254
-     *
1255
-     * @access    public
1256
-     * @param    string $route       - "pretty" public alias for module method
1257
-     * @param    string $module      - module name (classname without EED_ prefix)
1258
-     * @param    string $method_name - the actual module method to be routed to
1259
-     * @param    string $key         - url param key indicating a route is being called
1260
-     * @return    bool
1261
-     */
1262
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1263
-    {
1264
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1265
-        $module = str_replace('EED_', '', $module);
1266
-        $module_class = 'EED_' . $module;
1267
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1268
-            $msg = sprintf(esc_html__('The module %s has not been registered.', 'event_espresso'), $module);
1269
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1270
-            return false;
1271
-        }
1272
-        if (empty($route)) {
1273
-            $msg = sprintf(esc_html__('No route has been supplied.', 'event_espresso'), $route);
1274
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1275
-            return false;
1276
-        }
1277
-        if (! method_exists('EED_' . $module, $method_name)) {
1278
-            $msg = sprintf(
1279
-                esc_html__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1280
-                $route
1281
-            );
1282
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1283
-            return false;
1284
-        }
1285
-        EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1286
-        return true;
1287
-    }
1288
-
1289
-
1290
-    /**
1291
-     *    get_route - get module method route
1292
-     *
1293
-     * @access    public
1294
-     * @param    string $route - "pretty" public alias for module method
1295
-     * @param    string $key   - url param key indicating a route is being called
1296
-     * @return    string
1297
-     */
1298
-    public static function get_route($route = null, $key = 'ee')
1299
-    {
1300
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1301
-        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1302
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1303
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1304
-        }
1305
-        return null;
1306
-    }
1307
-
1308
-
1309
-    /**
1310
-     *    get_routes - get ALL module method routes
1311
-     *
1312
-     * @access    public
1313
-     * @return    array
1314
-     */
1315
-    public static function get_routes()
1316
-    {
1317
-        return EE_Config::$_module_route_map;
1318
-    }
1319
-
1320
-
1321
-    /**
1322
-     *    register_forward - allows modules to forward request to another module for further processing
1323
-     *
1324
-     * @access    public
1325
-     * @param    string       $route   - "pretty" public alias for module method
1326
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1327
-     *                                 class, allows different forwards to be served based on status
1328
-     * @param    array|string $forward - function name or array( class, method )
1329
-     * @param    string       $key     - url param key indicating a route is being called
1330
-     * @return    bool
1331
-     */
1332
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1333
-    {
1334
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1335
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1336
-            $msg = sprintf(
1337
-                esc_html__('The module route %s for this forward has not been registered.', 'event_espresso'),
1338
-                $route
1339
-            );
1340
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1341
-            return false;
1342
-        }
1343
-        if (empty($forward)) {
1344
-            $msg = sprintf(esc_html__('No forwarding route has been supplied.', 'event_espresso'), $route);
1345
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1346
-            return false;
1347
-        }
1348
-        if (is_array($forward)) {
1349
-            if (! isset($forward[1])) {
1350
-                $msg = sprintf(
1351
-                    esc_html__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1352
-                    $route
1353
-                );
1354
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1355
-                return false;
1356
-            }
1357
-            if (! method_exists($forward[0], $forward[1])) {
1358
-                $msg = sprintf(
1359
-                    esc_html__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1360
-                    $forward[1],
1361
-                    $route
1362
-                );
1363
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1364
-                return false;
1365
-            }
1366
-        } elseif (! function_exists($forward)) {
1367
-            $msg = sprintf(
1368
-                esc_html__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1369
-                $forward,
1370
-                $route
1371
-            );
1372
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1373
-            return false;
1374
-        }
1375
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1376
-        return true;
1377
-    }
1378
-
1379
-
1380
-    /**
1381
-     *    get_forward - get forwarding route
1382
-     *
1383
-     * @access    public
1384
-     * @param    string  $route  - "pretty" public alias for module method
1385
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1386
-     *                           allows different forwards to be served based on status
1387
-     * @param    string  $key    - url param key indicating a route is being called
1388
-     * @return    string
1389
-     */
1390
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1391
-    {
1392
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1393
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1394
-            return apply_filters(
1395
-                'FHEE__EE_Config__get_forward',
1396
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1397
-                $route,
1398
-                $status
1399
-            );
1400
-        }
1401
-        return null;
1402
-    }
1403
-
1404
-
1405
-    /**
1406
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1407
-     *    results
1408
-     *
1409
-     * @access    public
1410
-     * @param    string  $route  - "pretty" public alias for module method
1411
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1412
-     *                           allows different views to be served based on status
1413
-     * @param    string  $view
1414
-     * @param    string  $key    - url param key indicating a route is being called
1415
-     * @return    bool
1416
-     */
1417
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1418
-    {
1419
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1420
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1421
-            $msg = sprintf(
1422
-                esc_html__('The module route %s for this view has not been registered.', 'event_espresso'),
1423
-                $route
1424
-            );
1425
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1426
-            return false;
1427
-        }
1428
-        if (! is_readable($view)) {
1429
-            $msg = sprintf(
1430
-                esc_html__(
1431
-                    'The %s view file could not be found or is not readable due to file permissions.',
1432
-                    'event_espresso'
1433
-                ),
1434
-                $view
1435
-            );
1436
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1437
-            return false;
1438
-        }
1439
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1440
-        return true;
1441
-    }
1442
-
1443
-
1444
-    /**
1445
-     *    get_view - get view for route and status
1446
-     *
1447
-     * @access    public
1448
-     * @param    string  $route  - "pretty" public alias for module method
1449
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1450
-     *                           allows different views to be served based on status
1451
-     * @param    string  $key    - url param key indicating a route is being called
1452
-     * @return    string
1453
-     */
1454
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1455
-    {
1456
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1457
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1458
-            return apply_filters(
1459
-                'FHEE__EE_Config__get_view',
1460
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1461
-                $route,
1462
-                $status
1463
-            );
1464
-        }
1465
-        return null;
1466
-    }
1467
-
1468
-
1469
-    public function update_addon_option_names()
1470
-    {
1471
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1472
-    }
1473
-
1474
-
1475
-    public function shutdown()
1476
-    {
1477
-        $this->update_addon_option_names();
1478
-    }
1479
-
1480
-
1481
-    /**
1482
-     * @return LegacyShortcodesManager
1483
-     */
1484
-    public static function getLegacyShortcodesManager()
1485
-    {
1486
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1487
-            EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1488
-                LegacyShortcodesManager::class
1489
-            );
1490
-        }
1491
-        return EE_Config::instance()->legacy_shortcodes_manager;
1492
-    }
1493
-
1494
-
1495
-    /**
1496
-     * register_shortcode - makes core aware of this shortcode
1497
-     *
1498
-     * @deprecated 4.9.26
1499
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1500
-     * @return    bool
1501
-     */
1502
-    public static function register_shortcode($shortcode_path = null)
1503
-    {
1504
-        EE_Error::doing_it_wrong(
1505
-            __METHOD__,
1506
-            esc_html__(
1507
-                '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.',
1508
-                'event_espresso'
1509
-            ),
1510
-            '4.9.26'
1511
-        );
1512
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1513
-    }
1514
-}
1515
-
1516
-/**
1517
- * Base class used for config classes. These classes should generally not have
1518
- * magic functions in use, except we'll allow them to magically set and get stuff...
1519
- * basically, they should just be well-defined stdClasses
1520
- */
1521
-class EE_Config_Base
1522
-{
1523
-    /**
1524
-     * Utility function for escaping the value of a property and returning.
1525
-     *
1526
-     * @param string $property property name (checks to see if exists).
1527
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1528
-     * @throws EE_Error
1529
-     */
1530
-    public function get_pretty($property)
1531
-    {
1532
-        if (! property_exists($this, $property)) {
1533
-            throw new EE_Error(
1534
-                sprintf(
1535
-                    esc_html__(
1536
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1537
-                        'event_espresso'
1538
-                    ),
1539
-                    get_class($this),
1540
-                    $property
1541
-                )
1542
-            );
1543
-        }
1544
-        // just handling escaping of strings for now.
1545
-        if (is_string($this->{$property})) {
1546
-            return stripslashes($this->{$property});
1547
-        }
1548
-        return $this->{$property};
1549
-    }
1550
-
1551
-
1552
-    public function populate()
1553
-    {
1554
-        // grab defaults via a new instance of this class.
1555
-        $class_name = get_class($this);
1556
-        $defaults = new $class_name();
1557
-        // loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1558
-        // default from our $defaults object.
1559
-        foreach (get_object_vars($defaults) as $property => $value) {
1560
-            if ($this->{$property} === null) {
1561
-                $this->{$property} = $value;
1562
-            }
1563
-        }
1564
-        // cleanup
1565
-        unset($defaults);
1566
-    }
1567
-
1568
-
1569
-    /**
1570
-     *        __isset
1571
-     *
1572
-     * @param $a
1573
-     * @return bool
1574
-     */
1575
-    public function __isset($a)
1576
-    {
1577
-        return false;
1578
-    }
1579
-
1580
-
1581
-    /**
1582
-     *        __unset
1583
-     *
1584
-     * @param $a
1585
-     * @return bool
1586
-     */
1587
-    public function __unset($a)
1588
-    {
1589
-        return false;
1590
-    }
1591
-
1592
-
1593
-    /**
1594
-     *        __clone
1595
-     */
1596
-    public function __clone()
1597
-    {
1598
-    }
1599
-
1600
-
1601
-    /**
1602
-     *        __wakeup
1603
-     */
1604
-    public function __wakeup()
1605
-    {
1606
-    }
1607
-
1608
-
1609
-    /**
1610
-     *        __destruct
1611
-     */
1612
-    public function __destruct()
1613
-    {
1614
-    }
1615
-}
1616
-
1617
-/**
1618
- * Class for defining what's in the EE_Config relating to registration settings
1619
- */
1620
-class EE_Core_Config extends EE_Config_Base
1621
-{
1622
-    const OPTION_NAME_UXIP = 'ee_ueip_optin';
1623
-
1624
-
1625
-    public $current_blog_id;
1626
-
1627
-    public $ee_ueip_optin;
1628
-
1629
-    public $ee_ueip_has_notified;
1630
-
1631
-    /**
1632
-     * Not to be confused with the 4 critical page variables (See
1633
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1634
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1635
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1636
-     *
1637
-     * @var array
1638
-     */
1639
-    public $post_shortcodes;
1640
-
1641
-    public $module_route_map;
1642
-
1643
-    public $module_forward_map;
1644
-
1645
-    public $module_view_map;
1646
-
1647
-    /**
1648
-     * The next 4 vars are the IDs of critical EE pages.
1649
-     *
1650
-     * @var int
1651
-     */
1652
-    public $reg_page_id;
1653
-
1654
-    public $txn_page_id;
1655
-
1656
-    public $thank_you_page_id;
1657
-
1658
-    public $cancel_page_id;
1659
-
1660
-    /**
1661
-     * The next 4 vars are the URLs of critical EE pages.
1662
-     *
1663
-     * @var int
1664
-     */
1665
-    public $reg_page_url;
1666
-
1667
-    public $txn_page_url;
1668
-
1669
-    public $thank_you_page_url;
1670
-
1671
-    public $cancel_page_url;
1672
-
1673
-    /**
1674
-     * The next vars relate to the custom slugs for EE CPT routes
1675
-     */
1676
-    public $event_cpt_slug;
1677
-
1678
-    /**
1679
-     * This caches the _ee_ueip_option in case this config is reset in the same
1680
-     * request across blog switches in a multisite context.
1681
-     * Avoids extra queries to the db for this option.
1682
-     *
1683
-     * @var bool
1684
-     */
1685
-    public static $ee_ueip_option;
1686
-
1687
-
1688
-    /**
1689
-     *    class constructor
1690
-     *
1691
-     * @access    public
1692
-     */
1693
-    public function __construct()
1694
-    {
1695
-        // set default organization settings
1696
-        $this->current_blog_id = get_current_blog_id();
1697
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1698
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1699
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1700
-        $this->post_shortcodes = array();
1701
-        $this->module_route_map = array();
1702
-        $this->module_forward_map = array();
1703
-        $this->module_view_map = array();
1704
-        // critical EE page IDs
1705
-        $this->reg_page_id = 0;
1706
-        $this->txn_page_id = 0;
1707
-        $this->thank_you_page_id = 0;
1708
-        $this->cancel_page_id = 0;
1709
-        // critical EE page URLs
1710
-        $this->reg_page_url = '';
1711
-        $this->txn_page_url = '';
1712
-        $this->thank_you_page_url = '';
1713
-        $this->cancel_page_url = '';
1714
-        // cpt slugs
1715
-        $this->event_cpt_slug = esc_html__('events', 'event_espresso');
1716
-        // ueip constant check
1717
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1718
-            $this->ee_ueip_optin = false;
1719
-            $this->ee_ueip_has_notified = true;
1720
-        }
1721
-    }
1722
-
1723
-
1724
-    /**
1725
-     * @return array
1726
-     */
1727
-    public function get_critical_pages_array()
1728
-    {
1729
-        return array(
1730
-            $this->reg_page_id,
1731
-            $this->txn_page_id,
1732
-            $this->thank_you_page_id,
1733
-            $this->cancel_page_id,
1734
-        );
1735
-    }
1736
-
1737
-
1738
-    /**
1739
-     * @return array
1740
-     */
1741
-    public function get_critical_pages_shortcodes_array()
1742
-    {
1743
-        return array(
1744
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1745
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1746
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1747
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1748
-        );
1749
-    }
1750
-
1751
-
1752
-    /**
1753
-     *  gets/returns URL for EE reg_page
1754
-     *
1755
-     * @access    public
1756
-     * @return    string
1757
-     */
1758
-    public function reg_page_url()
1759
-    {
1760
-        if (! $this->reg_page_url) {
1761
-            $this->reg_page_url = add_query_arg(
1762
-                array('uts' => time()),
1763
-                get_permalink($this->reg_page_id)
1764
-            ) . '#checkout';
1765
-        }
1766
-        return $this->reg_page_url;
1767
-    }
1768
-
1769
-
1770
-    /**
1771
-     *  gets/returns URL for EE txn_page
1772
-     *
1773
-     * @param array $query_args like what gets passed to
1774
-     *                          add_query_arg() as the first argument
1775
-     * @access    public
1776
-     * @return    string
1777
-     */
1778
-    public function txn_page_url($query_args = array())
1779
-    {
1780
-        if (! $this->txn_page_url) {
1781
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1782
-        }
1783
-        if ($query_args) {
1784
-            return add_query_arg($query_args, $this->txn_page_url);
1785
-        } else {
1786
-            return $this->txn_page_url;
1787
-        }
1788
-    }
1789
-
1790
-
1791
-    /**
1792
-     *  gets/returns URL for EE thank_you_page
1793
-     *
1794
-     * @param array $query_args like what gets passed to
1795
-     *                          add_query_arg() as the first argument
1796
-     * @access    public
1797
-     * @return    string
1798
-     */
1799
-    public function thank_you_page_url($query_args = array())
1800
-    {
1801
-        if (! $this->thank_you_page_url) {
1802
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1803
-        }
1804
-        if ($query_args) {
1805
-            return add_query_arg($query_args, $this->thank_you_page_url);
1806
-        } else {
1807
-            return $this->thank_you_page_url;
1808
-        }
1809
-    }
1810
-
1811
-
1812
-    /**
1813
-     *  gets/returns URL for EE cancel_page
1814
-     *
1815
-     * @access    public
1816
-     * @return    string
1817
-     */
1818
-    public function cancel_page_url()
1819
-    {
1820
-        if (! $this->cancel_page_url) {
1821
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1822
-        }
1823
-        return $this->cancel_page_url;
1824
-    }
1825
-
1826
-
1827
-    /**
1828
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1829
-     *
1830
-     * @since 4.7.5
1831
-     */
1832
-    protected function _reset_urls()
1833
-    {
1834
-        $this->reg_page_url = '';
1835
-        $this->txn_page_url = '';
1836
-        $this->cancel_page_url = '';
1837
-        $this->thank_you_page_url = '';
1838
-    }
1839
-
1840
-
1841
-    /**
1842
-     * Used to return what the optin value is set for the EE User Experience Program.
1843
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1844
-     * on the main site only.
1845
-     *
1846
-     * @return bool
1847
-     */
1848
-    protected function _get_main_ee_ueip_optin()
1849
-    {
1850
-        // if this is the main site then we can just bypass our direct query.
1851
-        if (is_main_site()) {
1852
-            return get_option(self::OPTION_NAME_UXIP, false);
1853
-        }
1854
-        // is this already cached for this request?  If so use it.
1855
-        if (EE_Core_Config::$ee_ueip_option !== null) {
1856
-            return EE_Core_Config::$ee_ueip_option;
1857
-        }
1858
-        global $wpdb;
1859
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1860
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1861
-        $option = self::OPTION_NAME_UXIP;
1862
-        // set correct table for query
1863
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1864
-        // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1865
-        // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1866
-        // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1867
-        // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1868
-        // for the purpose of caching.
1869
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1870
-        if (false !== $pre) {
1871
-            EE_Core_Config::$ee_ueip_option = $pre;
1872
-            return EE_Core_Config::$ee_ueip_option;
1873
-        }
1874
-        $row = $wpdb->get_row(
1875
-            $wpdb->prepare(
1876
-                "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1877
-                $option
1878
-            )
1879
-        );
1880
-        if (is_object($row)) {
1881
-            $value = $row->option_value;
1882
-        } else { // option does not exist so use default.
1883
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1884
-            return EE_Core_Config::$ee_ueip_option;
1885
-        }
1886
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1887
-        return EE_Core_Config::$ee_ueip_option;
1888
-    }
1889
-
1890
-
1891
-    /**
1892
-     * Utility function for escaping the value of a property and returning.
1893
-     *
1894
-     * @param string $property property name (checks to see if exists).
1895
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1896
-     * @throws EE_Error
1897
-     */
1898
-    public function get_pretty($property)
1899
-    {
1900
-        if ($property === self::OPTION_NAME_UXIP) {
1901
-            return $this->ee_ueip_optin ? 'yes' : 'no';
1902
-        }
1903
-        return parent::get_pretty($property);
1904
-    }
1905
-
1906
-
1907
-    /**
1908
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1909
-     * on the object.
1910
-     *
1911
-     * @return array
1912
-     */
1913
-    public function __sleep()
1914
-    {
1915
-        // reset all url properties
1916
-        $this->_reset_urls();
1917
-        // return what to save to db
1918
-        return array_keys(get_object_vars($this));
1919
-    }
1920
-}
1921
-
1922
-/**
1923
- * Config class for storing info on the Organization
1924
- */
1925
-class EE_Organization_Config extends EE_Config_Base
1926
-{
1927
-    /**
1928
-     * @var string $name
1929
-     * eg EE4.1
1930
-     */
1931
-    public $name;
1932
-
1933
-    /**
1934
-     * @var string $address_1
1935
-     * eg 123 Onna Road
1936
-     */
1937
-    public $address_1 = '';
1938
-
1939
-    /**
1940
-     * @var string $address_2
1941
-     * eg PO Box 123
1942
-     */
1943
-    public $address_2 = '';
1944
-
1945
-    /**
1946
-     * @var string $city
1947
-     * eg Inna City
1948
-     */
1949
-    public $city = '';
1950
-
1951
-    /**
1952
-     * @var int $STA_ID
1953
-     * eg 4
1954
-     */
1955
-    public $STA_ID = 0;
1956
-
1957
-    /**
1958
-     * @var string $CNT_ISO
1959
-     * eg US
1960
-     */
1961
-    public $CNT_ISO = '';
1962
-
1963
-    /**
1964
-     * @var string $zip
1965
-     * eg 12345  or V1A 2B3
1966
-     */
1967
-    public $zip = '';
1968
-
1969
-    /**
1970
-     * @var string $email
1971
-     * eg [email protected]
1972
-     */
1973
-    public $email;
1974
-
1975
-    /**
1976
-     * @var string $phone
1977
-     * eg. 111-111-1111
1978
-     */
1979
-    public $phone = '';
1980
-
1981
-    /**
1982
-     * @var string $vat
1983
-     * VAT/Tax Number
1984
-     */
1985
-    public $vat = '';
1986
-
1987
-    /**
1988
-     * @var string $logo_url
1989
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1990
-     */
1991
-    public $logo_url = '';
1992
-
1993
-    /**
1994
-     * The below are all various properties for holding links to organization social network profiles
1995
-     *
1996
-     * @var string
1997
-     */
1998
-    /**
1999
-     * facebook (facebook.com/profile.name)
2000
-     *
2001
-     * @var string
2002
-     */
2003
-    public $facebook = '';
2004
-
2005
-    /**
2006
-     * twitter (twitter.com/twitter_handle)
2007
-     *
2008
-     * @var string
2009
-     */
2010
-    public $twitter = '';
2011
-
2012
-    /**
2013
-     * linkedin (linkedin.com/in/profile_name)
2014
-     *
2015
-     * @var string
2016
-     */
2017
-    public $linkedin = '';
2018
-
2019
-    /**
2020
-     * pinterest (www.pinterest.com/profile_name)
2021
-     *
2022
-     * @var string
2023
-     */
2024
-    public $pinterest = '';
2025
-
2026
-    /**
2027
-     * google+ (google.com/+profileName)
2028
-     *
2029
-     * @var string
2030
-     */
2031
-    public $google = '';
2032
-
2033
-    /**
2034
-     * instagram (instagram.com/handle)
2035
-     *
2036
-     * @var string
2037
-     */
2038
-    public $instagram = '';
2039
-
2040
-
2041
-    /**
2042
-     *    class constructor
2043
-     *
2044
-     * @access    public
2045
-     */
2046
-    public function __construct()
2047
-    {
2048
-        // set default organization settings
2049
-        // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2050
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2051
-        $this->email = get_bloginfo('admin_email');
2052
-    }
2053
-}
2054
-
2055
-/**
2056
- * Class for defining what's in the EE_Config relating to currency
2057
- */
2058
-class EE_Currency_Config extends EE_Config_Base
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
-        if ($CNT_ISO && $CNT_ISO === $this->code) {
2130
-            return;
2131
-        }
2132
-        // get country code from organization settings or use default
2133
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2134
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2135
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2136
-            : '';
2137
-        // but override if requested
2138
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2139
-        // 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
2140
-        $this->setCurrency($CNT_ISO);
2141
-        // fallback to hardcoded defaults, in case the above failed
2142
-        if (empty($this->code)) {
2143
-            $this->setFallbackCurrency();
2144
-        }
2145
-    }
2146
-
2147
-
2148
-    /**
2149
-     * @param string|null $CNT_ISO
2150
-     * @throws EE_Error
2151
-     * @throws ReflectionException
2152
-     */
2153
-    public function setCurrency(?string $CNT_ISO = '')
2154
-    {
2155
-        if (empty($CNT_ISO) || ! EE_Maintenance_Mode::instance()->models_can_query()) {
2156
-            return;
2157
-        }
2158
-
2159
-        /** @var TableAnalysis $table_analysis */
2160
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', [], true);
2161
-        if (! $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())) {
2162
-            return;
2163
-        }
2164
-        // retrieve the country settings from the db, just in case they have been customized
2165
-        $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2166
-        if (! $country instanceof EE_Country) {
2167
-            throw new DomainException(
2168
-                esc_html__('Invalid Country ISO Code.', 'event_espresso')
2169
-            );
2170
-        }
2171
-        $this->code    = $country->currency_code();                  // currency code: USD, CAD, EUR
2172
-        $this->name    = $country->currency_name_single();           // Dollar
2173
-        $this->plural  = $country->currency_name_plural();           // Dollars
2174
-        $this->sign    = $country->currency_sign();                  // currency sign: $
2175
-        $this->sign_b4 = $country->currency_sign_before();           // currency sign before or after
2176
-        $this->dec_plc = $country->currency_decimal_places();        // decimal places: 2 = 0.00  3 = 0.000
2177
-        $this->dec_mrk = $country->currency_decimal_mark();          // decimal mark: ',' = 0,01 or '.' = 0.01
2178
-        $this->thsnds  = $country->currency_thousands_separator();   // thousands sep: ',' = 1,000 or '.' = 1.000
2179
-    }
2180
-
2181
-
2182
-    private function setFallbackCurrency()
2183
-    {
2184
-        // set default currency settings
2185
-        $this->code    = 'USD';
2186
-        $this->name    = esc_html__('Dollar', 'event_espresso');
2187
-        $this->plural  = esc_html__('Dollars', 'event_espresso');
2188
-        $this->sign    = '$';
2189
-        $this->sign_b4 = true;
2190
-        $this->dec_plc = 2;
2191
-        $this->dec_mrk = '.';
2192
-        $this->thsnds  = ',';
2193
-    }
2194
-
2195
-
2196
-    /**
2197
-     * @param string|null $CNT_ISO
2198
-     * @return EE_Currency_Config
2199
-     * @throws EE_Error
2200
-     * @throws ReflectionException
2201
-     */
2202
-    public static function getCurrencyConfig(?string $CNT_ISO = ''): EE_Currency_Config
2203
-    {
2204
-        // if CNT_ISO passed lets try to get currency settings for it.
2205
-        $currency_config = ! empty($CNT_ISO)
2206
-            ? new EE_Currency_Config($CNT_ISO)
2207
-            : null;
2208
-        // default currency settings for site if not set
2209
-        if ($currency_config instanceof EE_Currency_Config) {
2210
-            return $currency_config;
2211
-        }
2212
-        EE_Config::instance()->currency = EE_Config::instance()->currency instanceof EE_Currency_Config
2213
-            ? EE_Config::instance()->currency
2214
-            : new EE_Currency_Config();
2215
-        return EE_Config::instance()->currency;
2216
-    }
2217
-}
2218
-
2219
-/**
2220
- * Class for defining what's in the EE_Config relating to registration settings
2221
- */
2222
-class EE_Registration_Config extends EE_Config_Base
2223
-{
2224
-    /**
2225
-     * Default registration status
2226
-     *
2227
-     * @var string $default_STS_ID
2228
-     * eg 'RPP'
2229
-     */
2230
-    public $default_STS_ID;
2231
-
2232
-    /**
2233
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2234
-     * registrations)
2235
-     *
2236
-     * @var int
2237
-     */
2238
-    public $default_maximum_number_of_tickets;
2239
-
2240
-    /**
2241
-     * level of validation to apply to email addresses
2242
-     *
2243
-     * @var string $email_validation_level
2244
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2245
-     */
2246
-    public $email_validation_level;
2247
-
2248
-    /**
2249
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2250
-     *
2251
-     * @var boolean $show_pending_payment_options
2252
-     */
2253
-    public $show_pending_payment_options;
2254
-
2255
-    /**
2256
-     * Whether to skip the registration confirmation page
2257
-     *
2258
-     * @var boolean $skip_reg_confirmation
2259
-     */
2260
-    public $skip_reg_confirmation;
2261
-
2262
-    /**
2263
-     * an array of SPCO reg steps where:
2264
-     *        the keys denotes the reg step order
2265
-     *        each element consists of an array with the following elements:
2266
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2267
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2268
-     *            "slug" => the URL param used to trigger the reg step
2269
-     *
2270
-     * @var array $reg_steps
2271
-     */
2272
-    public $reg_steps;
2273
-
2274
-    /**
2275
-     * Whether registration confirmation should be the last page of SPCO
2276
-     *
2277
-     * @var boolean $reg_confirmation_last
2278
-     */
2279
-    public $reg_confirmation_last;
2280
-
2281
-    /**
2282
-     * Whether or not to enable the EE Bot Trap
2283
-     *
2284
-     * @var boolean $use_bot_trap
2285
-     */
2286
-    public $use_bot_trap;
2287
-
2288
-    /**
2289
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2290
-     *
2291
-     * @var boolean $use_encryption
2292
-     */
2293
-    public $use_encryption;
2294
-
2295
-    /**
2296
-     * Whether or not to use ReCaptcha
2297
-     *
2298
-     * @var boolean $use_captcha
2299
-     */
2300
-    public $use_captcha;
2301
-
2302
-    /**
2303
-     * ReCaptcha Theme
2304
-     *
2305
-     * @var string $recaptcha_theme
2306
-     *    options: 'dark', 'light', 'invisible'
2307
-     */
2308
-    public $recaptcha_theme;
2309
-
2310
-    /**
2311
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2312
-     *
2313
-     * @var string $recaptcha_badge
2314
-     *    options: 'bottomright', 'bottomleft', 'inline'
2315
-     */
2316
-    public $recaptcha_badge;
2317
-
2318
-    /**
2319
-     * ReCaptcha Type
2320
-     *
2321
-     * @var string $recaptcha_type
2322
-     *    options: 'audio', 'image'
2323
-     */
2324
-    public $recaptcha_type;
2325
-
2326
-    /**
2327
-     * ReCaptcha language
2328
-     *
2329
-     * @var string $recaptcha_language
2330
-     * eg 'en'
2331
-     */
2332
-    public $recaptcha_language;
2333
-
2334
-    /**
2335
-     * ReCaptcha public key
2336
-     *
2337
-     * @var string $recaptcha_publickey
2338
-     */
2339
-    public $recaptcha_publickey;
2340
-
2341
-    /**
2342
-     * ReCaptcha private key
2343
-     *
2344
-     * @var string $recaptcha_privatekey
2345
-     */
2346
-    public $recaptcha_privatekey;
2347
-
2348
-    /**
2349
-     * array of form names protected by ReCaptcha
2350
-     *
2351
-     * @var array $recaptcha_protected_forms
2352
-     */
2353
-    public $recaptcha_protected_forms;
21
+	const OPTION_NAME = 'ee_config';
22
+
23
+	const LOG_NAME = 'ee_config_log';
24
+
25
+	const LOG_LENGTH = 100;
26
+
27
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
28
+
29
+	/**
30
+	 *    instance of the EE_Config object
31
+	 *
32
+	 * @var    EE_Config $_instance
33
+	 * @access    private
34
+	 */
35
+	private static $_instance;
36
+
37
+	/**
38
+	 * @var boolean $_logging_enabled
39
+	 */
40
+	private static $_logging_enabled = false;
41
+
42
+	/**
43
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
44
+	 */
45
+	private $legacy_shortcodes_manager;
46
+
47
+	/**
48
+	 * An StdClass whose property names are addon slugs,
49
+	 * and values are their config classes
50
+	 *
51
+	 * @var StdClass
52
+	 */
53
+	public $addons;
54
+
55
+	/**
56
+	 * @var EE_Admin_Config
57
+	 */
58
+	public $admin;
59
+
60
+	/**
61
+	 * @var EE_Core_Config
62
+	 */
63
+	public $core;
64
+
65
+	/**
66
+	 * @var EE_Currency_Config
67
+	 */
68
+	public $currency;
69
+
70
+	/**
71
+	 * @var EE_Organization_Config
72
+	 */
73
+	public $organization;
74
+
75
+	/**
76
+	 * @var EE_Registration_Config
77
+	 */
78
+	public $registration;
79
+
80
+	/**
81
+	 * @var EE_Template_Config
82
+	 */
83
+	public $template_settings;
84
+
85
+	/**
86
+	 * Holds EE environment values.
87
+	 *
88
+	 * @var EE_Environment_Config
89
+	 */
90
+	public $environment;
91
+
92
+	/**
93
+	 * settings pertaining to Google maps
94
+	 *
95
+	 * @var EE_Map_Config
96
+	 */
97
+	public $map_settings;
98
+
99
+	/**
100
+	 * settings pertaining to Taxes
101
+	 *
102
+	 * @var EE_Tax_Config
103
+	 */
104
+	public $tax_settings;
105
+
106
+	/**
107
+	 * Settings pertaining to global messages settings.
108
+	 *
109
+	 * @var EE_Messages_Config
110
+	 */
111
+	public $messages;
112
+
113
+	/**
114
+	 * @deprecated
115
+	 * @var EE_Gateway_Config
116
+	 */
117
+	public $gateway;
118
+
119
+	/**
120
+	 * @var array
121
+	 */
122
+	private $_addon_option_names = array();
123
+
124
+	/**
125
+	 * @var array
126
+	 */
127
+	private static $_module_route_map = array();
128
+
129
+	/**
130
+	 * @var array
131
+	 */
132
+	private static $_module_forward_map = array();
133
+
134
+	/**
135
+	 * @var array
136
+	 */
137
+	private static $_module_view_map = array();
138
+
139
+	/**
140
+	 * @var bool
141
+	 */
142
+	private static $initialized = false;
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
+		self::$initialized = false;
185
+		// we don't need to reset the static properties imo because those should
186
+		// only change when a module is added or removed. Currently we don't
187
+		// support removing a module during a request when it previously existed
188
+		if ($reinstantiate) {
189
+			return self::instance();
190
+		} else {
191
+			return null;
192
+		}
193
+	}
194
+
195
+
196
+	private function __construct()
197
+	{
198
+		if (self::$initialized) {
199
+			return;
200
+		}
201
+		self::$initialized = true;
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
+			[$this, 'register_shortcodes_and_modules'],
214
+			999
215
+		);
216
+		//  initialize shortcodes and modules
217
+		add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'initialize_shortcodes_and_modules']);
218
+		// register widgets
219
+		add_action('widgets_init', [$this, 'widgets_init'], 10);
220
+		// shutdown
221
+		add_action('shutdown', [$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 self::$_instance->template_settings->current_espresso_theme ?? 'Espresso_Arabica_2014';
246
+	}
247
+
248
+
249
+	/**
250
+	 *        _initialize_config
251
+	 *
252
+	 * @access private
253
+	 * @return void
254
+	 */
255
+	private function _initialize_config()
256
+	{
257
+		EE_Config::trim_log();
258
+		// set defaults
259
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
260
+		$this->addons = new stdClass();
261
+		// set _module_route_map
262
+		EE_Config::$_module_route_map = array();
263
+		// set _module_forward_map
264
+		EE_Config::$_module_forward_map = array();
265
+		// set _module_view_map
266
+		EE_Config::$_module_view_map = array();
267
+	}
268
+
269
+
270
+	/**
271
+	 *        load core plugin configuration
272
+	 *
273
+	 * @access private
274
+	 * @return void
275
+	 */
276
+	private function _load_core_config()
277
+	{
278
+		// load_core_config__start hook
279
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
280
+		$espresso_config = (array) $this->get_espresso_config();
281
+		// need to move the "addons" element to the end of the config array
282
+		// in case an addon config references one of the other config classes
283
+		$addons = $espresso_config['addons'] ?? new StdClass();
284
+		unset($espresso_config['addons']);
285
+		$espresso_config['addons'] = $addons;
286
+		foreach ($espresso_config as $config => $settings) {
287
+			// load_core_config__start hook
288
+			$settings = apply_filters(
289
+				'FHEE__EE_Config___load_core_config__config_settings',
290
+				$settings,
291
+				$config,
292
+				$this
293
+			);
294
+			if (is_object($settings) && property_exists($this, $config)) {
295
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
296
+				// call configs populate method to ensure any defaults are set for empty values.
297
+				if (method_exists($settings, 'populate')) {
298
+					$this->{$config}->populate();
299
+				}
300
+				if (method_exists($settings, 'do_hooks')) {
301
+					$this->{$config}->do_hooks();
302
+				}
303
+			}
304
+		}
305
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
306
+			$this->update_espresso_config();
307
+		}
308
+		// load_core_config__end hook
309
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
310
+	}
311
+
312
+
313
+	/**
314
+	 *    _verify_config
315
+	 *
316
+	 * @access    protected
317
+	 * @return    void
318
+	 */
319
+	protected function _verify_config()
320
+	{
321
+		$this->core = $this->core instanceof EE_Core_Config
322
+			? $this->core
323
+			: new EE_Core_Config();
324
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
325
+		$this->organization = $this->organization instanceof EE_Organization_Config
326
+			? $this->organization
327
+			: new EE_Organization_Config();
328
+		$this->organization = apply_filters(
329
+			'FHEE__EE_Config___initialize_config__organization',
330
+			$this->organization
331
+		);
332
+		$this->currency = $this->currency instanceof EE_Currency_Config
333
+			? $this->currency
334
+			: new EE_Currency_Config();
335
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
336
+		$this->registration = $this->registration instanceof EE_Registration_Config
337
+			? $this->registration
338
+			: new EE_Registration_Config();
339
+		$this->registration = apply_filters(
340
+			'FHEE__EE_Config___initialize_config__registration',
341
+			$this->registration
342
+		);
343
+		$this->admin = $this->admin instanceof EE_Admin_Config
344
+			? $this->admin
345
+			: new EE_Admin_Config();
346
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
347
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
348
+			? $this->template_settings
349
+			: new EE_Template_Config();
350
+		$this->template_settings = apply_filters(
351
+			'FHEE__EE_Config___initialize_config__template_settings',
352
+			$this->template_settings
353
+		);
354
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
355
+			? $this->map_settings
356
+			: new EE_Map_Config();
357
+		$this->map_settings = apply_filters(
358
+			'FHEE__EE_Config___initialize_config__map_settings',
359
+			$this->map_settings
360
+		);
361
+		$this->environment = $this->environment instanceof EE_Environment_Config
362
+			? $this->environment
363
+			: new EE_Environment_Config();
364
+		$this->environment = apply_filters(
365
+			'FHEE__EE_Config___initialize_config__environment',
366
+			$this->environment
367
+		);
368
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
369
+			? $this->tax_settings
370
+			: new EE_Tax_Config();
371
+		$this->tax_settings = apply_filters(
372
+			'FHEE__EE_Config___initialize_config__tax_settings',
373
+			$this->tax_settings
374
+		);
375
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
376
+		$this->messages = $this->messages instanceof EE_Messages_Config
377
+			? $this->messages
378
+			: new EE_Messages_Config();
379
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
380
+			? $this->gateway
381
+			: new EE_Gateway_Config();
382
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
383
+		$this->legacy_shortcodes_manager = null;
384
+	}
385
+
386
+
387
+	/**
388
+	 *    get_espresso_config
389
+	 *
390
+	 * @access    public
391
+	 * @return    array of espresso config stuff
392
+	 */
393
+	public function get_espresso_config()
394
+	{
395
+		// grab espresso configuration
396
+		return apply_filters(
397
+			'FHEE__EE_Config__get_espresso_config__CFG',
398
+			get_option(EE_Config::OPTION_NAME, array())
399
+		);
400
+	}
401
+
402
+
403
+	/**
404
+	 *    double_check_config_comparison
405
+	 *
406
+	 * @access    public
407
+	 * @param string $option
408
+	 * @param        $old_value
409
+	 * @param        $value
410
+	 */
411
+	public function double_check_config_comparison($option = '', $old_value, $value)
412
+	{
413
+		// make sure we're checking the ee config
414
+		if ($option === EE_Config::OPTION_NAME) {
415
+			// run a loose comparison of the old value against the new value for type and properties,
416
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
417
+			if ($value != $old_value) {
418
+				// if they are NOT the same, then remove the hook,
419
+				// which means the subsequent update results will be based solely on the update query results
420
+				// the reason we do this is because, as stated above,
421
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
422
+				// this happens PRIOR to serialization and any subsequent update.
423
+				// If values are found to match their previous old value,
424
+				// then WP bails before performing any update.
425
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
426
+				// it just pulled from the db, with the one being passed to it (which will not match).
427
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
428
+				// MySQL MAY ALSO NOT perform the update because
429
+				// the string it sees in the db looks the same as the new one it has been passed!!!
430
+				// This results in the query returning an "affected rows" value of ZERO,
431
+				// which gets returned immediately by WP update_option and looks like an error.
432
+				remove_action('update_option', array($this, 'check_config_updated'));
433
+			}
434
+		}
435
+	}
436
+
437
+
438
+	/**
439
+	 *    update_espresso_config
440
+	 *
441
+	 * @access   public
442
+	 */
443
+	protected function _reset_espresso_addon_config()
444
+	{
445
+		$this->_addon_option_names = array();
446
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
447
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
448
+			if ($addon_config_obj instanceof EE_Config_Base) {
449
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
450
+			}
451
+			$this->addons->{$addon_name} = null;
452
+		}
453
+	}
454
+
455
+
456
+	/**
457
+	 *    update_espresso_config
458
+	 *
459
+	 * @access   public
460
+	 * @param   bool $add_success
461
+	 * @param   bool $add_error
462
+	 * @return   bool
463
+	 */
464
+	public function update_espresso_config($add_success = false, $add_error = true)
465
+	{
466
+		// don't allow config updates during WP heartbeats
467
+		/** @var RequestInterface $request */
468
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
469
+		if ($request->isWordPressHeartbeat()) {
470
+			return false;
471
+		}
472
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
473
+		// $clone = clone( self::$_instance );
474
+		// self::$_instance = NULL;
475
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
476
+		$this->_reset_espresso_addon_config();
477
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
478
+		// but BEFORE the actual update occurs
479
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
480
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
481
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
482
+		$this->legacy_shortcodes_manager = null;
483
+		// now update "ee_config"
484
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
485
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
486
+		EE_Config::log(EE_Config::OPTION_NAME);
487
+		// if not saved... check if the hook we just added still exists;
488
+		// if it does, it means one of two things:
489
+		// that update_option bailed at the($value === $old_value) conditional,
490
+		// or...
491
+		// the db update query returned 0 rows affected
492
+		// (probably because the data  value was the same from it's perspective)
493
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
494
+		// but just means no update occurred, so don't display an error to the user.
495
+		// BUT... if update_option returns FALSE, AND the hook is missing,
496
+		// then it means that something truly went wrong
497
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
498
+		// remove our action since we don't want it in the system anymore
499
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
500
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
501
+		// self::$_instance = $clone;
502
+		// unset( $clone );
503
+		// if config remains the same or was updated successfully
504
+		if ($saved) {
505
+			if ($add_success) {
506
+				EE_Error::add_success(
507
+					esc_html__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
508
+					__FILE__,
509
+					__FUNCTION__,
510
+					__LINE__
511
+				);
512
+			}
513
+			return true;
514
+		} else {
515
+			if ($add_error) {
516
+				EE_Error::add_error(
517
+					esc_html__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
518
+					__FILE__,
519
+					__FUNCTION__,
520
+					__LINE__
521
+				);
522
+			}
523
+			return false;
524
+		}
525
+	}
526
+
527
+
528
+	/**
529
+	 *    _verify_config_params
530
+	 *
531
+	 * @access    private
532
+	 * @param    string         $section
533
+	 * @param    string         $name
534
+	 * @param    string         $config_class
535
+	 * @param    EE_Config_Base $config_obj
536
+	 * @param    array          $tests_to_run
537
+	 * @param    bool           $display_errors
538
+	 * @return    bool    TRUE on success, FALSE on fail
539
+	 */
540
+	private function _verify_config_params(
541
+		$section = '',
542
+		$name = '',
543
+		$config_class = '',
544
+		$config_obj = null,
545
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
+		$display_errors = true
547
+	) {
548
+		try {
549
+			foreach ($tests_to_run as $test) {
550
+				switch ($test) {
551
+					// TEST #1 : check that section was set
552
+					case 1:
553
+						if (empty($section)) {
554
+							if ($display_errors) {
555
+								throw new EE_Error(
556
+									sprintf(
557
+										esc_html__(
558
+											'No configuration section has been provided while attempting to save "%s".',
559
+											'event_espresso'
560
+										),
561
+										$config_class
562
+									)
563
+								);
564
+							}
565
+							return false;
566
+						}
567
+						break;
568
+					// TEST #2 : check that settings section exists
569
+					case 2:
570
+						if (! isset($this->{$section})) {
571
+							if ($display_errors) {
572
+								throw new EE_Error(
573
+									sprintf(
574
+										esc_html__('The "%s" configuration section does not exist.', 'event_espresso'),
575
+										$section
576
+									)
577
+								);
578
+							}
579
+							return false;
580
+						}
581
+						break;
582
+					// TEST #3 : check that section is the proper format
583
+					case 3:
584
+						if (
585
+							! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
+						) {
587
+							if ($display_errors) {
588
+								throw new EE_Error(
589
+									sprintf(
590
+										esc_html__(
591
+											'The "%s" configuration settings have not been formatted correctly.',
592
+											'event_espresso'
593
+										),
594
+										$section
595
+									)
596
+								);
597
+							}
598
+							return false;
599
+						}
600
+						break;
601
+					// TEST #4 : check that config section name has been set
602
+					case 4:
603
+						if (empty($name)) {
604
+							if ($display_errors) {
605
+								throw new EE_Error(
606
+									esc_html__(
607
+										'No name has been provided for the specific configuration section.',
608
+										'event_espresso'
609
+									)
610
+								);
611
+							}
612
+							return false;
613
+						}
614
+						break;
615
+					// TEST #5 : check that a config class name has been set
616
+					case 5:
617
+						if (empty($config_class)) {
618
+							if ($display_errors) {
619
+								throw new EE_Error(
620
+									esc_html__(
621
+										'No class name has been provided for the specific configuration section.',
622
+										'event_espresso'
623
+									)
624
+								);
625
+							}
626
+							return false;
627
+						}
628
+						break;
629
+					// TEST #6 : verify config class is accessible
630
+					case 6:
631
+						if (! class_exists($config_class)) {
632
+							if ($display_errors) {
633
+								throw new EE_Error(
634
+									sprintf(
635
+										esc_html__(
636
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
+											'event_espresso'
638
+										),
639
+										$config_class
640
+									)
641
+								);
642
+							}
643
+							return false;
644
+						}
645
+						break;
646
+					// TEST #7 : check that config has even been set
647
+					case 7:
648
+						if (! isset($this->{$section}->{$name})) {
649
+							if ($display_errors) {
650
+								throw new EE_Error(
651
+									sprintf(
652
+										esc_html__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
+										$section,
654
+										$name
655
+									)
656
+								);
657
+							}
658
+							return false;
659
+						} else {
660
+							// and make sure it's not serialized
661
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
+						}
663
+						break;
664
+					// TEST #8 : check that config is the requested type
665
+					case 8:
666
+						if (! $this->{$section}->{$name} instanceof $config_class) {
667
+							if ($display_errors) {
668
+								throw new EE_Error(
669
+									sprintf(
670
+										esc_html__(
671
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
+											'event_espresso'
673
+										),
674
+										$section,
675
+										$name,
676
+										$config_class
677
+									)
678
+								);
679
+							}
680
+							return false;
681
+						}
682
+						break;
683
+					// TEST #9 : verify config object
684
+					case 9:
685
+						if (! $config_obj instanceof EE_Config_Base) {
686
+							if ($display_errors) {
687
+								throw new EE_Error(
688
+									sprintf(
689
+										esc_html__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
+										print_r($config_obj, true)
691
+									)
692
+								);
693
+							}
694
+							return false;
695
+						}
696
+						break;
697
+				}
698
+			}
699
+		} catch (EE_Error $e) {
700
+			$e->get_error();
701
+		}
702
+		// you have successfully run the gauntlet
703
+		return true;
704
+	}
705
+
706
+
707
+	/**
708
+	 *    _generate_config_option_name
709
+	 *
710
+	 * @access        protected
711
+	 * @param        string $section
712
+	 * @param        string $name
713
+	 * @return        string
714
+	 */
715
+	private function _generate_config_option_name($section = '', $name = '')
716
+	{
717
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
718
+	}
719
+
720
+
721
+	/**
722
+	 *    _set_config_class
723
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
724
+	 *
725
+	 * @access    private
726
+	 * @param    string $config_class
727
+	 * @param    string $name
728
+	 * @return    string
729
+	 */
730
+	private function _set_config_class($config_class = '', $name = '')
731
+	{
732
+		return ! empty($config_class)
733
+			? $config_class
734
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
735
+	}
736
+
737
+
738
+	/**
739
+	 *    set_config
740
+	 *
741
+	 * @access    protected
742
+	 * @param    string         $section
743
+	 * @param    string         $name
744
+	 * @param    string         $config_class
745
+	 * @param    EE_Config_Base $config_obj
746
+	 * @return    EE_Config_Base
747
+	 */
748
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
749
+	{
750
+		// ensure config class is set to something
751
+		$config_class = $this->_set_config_class($config_class, $name);
752
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
753
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
754
+			return null;
755
+		}
756
+		$config_option_name = $this->_generate_config_option_name($section, $name);
757
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
758
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
759
+			$this->_addon_option_names[ $config_option_name ] = $config_class;
760
+			$this->update_addon_option_names();
761
+		}
762
+		// verify the incoming config object but suppress errors
763
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
764
+			$config_obj = new $config_class();
765
+		}
766
+		if (get_option($config_option_name)) {
767
+			EE_Config::log($config_option_name);
768
+			update_option($config_option_name, $config_obj);
769
+			$this->{$section}->{$name} = $config_obj;
770
+			return $this->{$section}->{$name};
771
+		} else {
772
+			// create a wp-option for this config
773
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
774
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
775
+				return $this->{$section}->{$name};
776
+			} else {
777
+				EE_Error::add_error(
778
+					sprintf(esc_html__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
779
+					__FILE__,
780
+					__FUNCTION__,
781
+					__LINE__
782
+				);
783
+				return null;
784
+			}
785
+		}
786
+	}
787
+
788
+
789
+	/**
790
+	 *    update_config
791
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
792
+	 *
793
+	 * @access    public
794
+	 * @param    string                $section
795
+	 * @param    string                $name
796
+	 * @param    EE_Config_Base|string $config_obj
797
+	 * @param    bool                  $throw_errors
798
+	 * @return    bool
799
+	 */
800
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
801
+	{
802
+		// don't allow config updates during WP heartbeats
803
+		/** @var RequestInterface $request */
804
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
805
+		if ($request->isWordPressHeartbeat()) {
806
+			return false;
807
+		}
808
+		$config_obj = maybe_unserialize($config_obj);
809
+		// get class name of the incoming object
810
+		$config_class = get_class($config_obj);
811
+		// run tests 1-5 and 9 to verify config
812
+		if (
813
+			! $this->_verify_config_params(
814
+				$section,
815
+				$name,
816
+				$config_class,
817
+				$config_obj,
818
+				array(1, 2, 3, 4, 7, 9)
819
+			)
820
+		) {
821
+			return false;
822
+		}
823
+		$config_option_name = $this->_generate_config_option_name($section, $name);
824
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
825
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
826
+			// save new config to db
827
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
828
+				return true;
829
+			}
830
+		} else {
831
+			// first check if the record already exists
832
+			$existing_config = get_option($config_option_name);
833
+			$config_obj = serialize($config_obj);
834
+			// just return if db record is already up to date (NOT type safe comparison)
835
+			if ($existing_config == $config_obj) {
836
+				$this->{$section}->{$name} = $config_obj;
837
+				return true;
838
+			} elseif (update_option($config_option_name, $config_obj)) {
839
+				EE_Config::log($config_option_name);
840
+				// update wp-option for this config class
841
+				$this->{$section}->{$name} = $config_obj;
842
+				return true;
843
+			} elseif ($throw_errors) {
844
+				EE_Error::add_error(
845
+					sprintf(
846
+						esc_html__(
847
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
848
+							'event_espresso'
849
+						),
850
+						$config_class,
851
+						'EE_Config->' . $section . '->' . $name
852
+					),
853
+					__FILE__,
854
+					__FUNCTION__,
855
+					__LINE__
856
+				);
857
+			}
858
+		}
859
+		return false;
860
+	}
861
+
862
+
863
+	/**
864
+	 *    get_config
865
+	 *
866
+	 * @access    public
867
+	 * @param    string $section
868
+	 * @param    string $name
869
+	 * @param    string $config_class
870
+	 * @return    mixed EE_Config_Base | NULL
871
+	 */
872
+	public function get_config($section = '', $name = '', $config_class = '')
873
+	{
874
+		// ensure config class is set to something
875
+		$config_class = $this->_set_config_class($config_class, $name);
876
+		// run tests 1-4, 6 and 7 to verify that all params have been set
877
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
878
+			return null;
879
+		}
880
+		// now test if the requested config object exists, but suppress errors
881
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
882
+			// config already exists, so pass it back
883
+			return $this->{$section}->{$name};
884
+		}
885
+		// load config option from db if it exists
886
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
887
+		// verify the newly retrieved config object, but suppress errors
888
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
889
+			// config is good, so set it and pass it back
890
+			$this->{$section}->{$name} = $config_obj;
891
+			return $this->{$section}->{$name};
892
+		}
893
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
894
+		$config_obj = $this->set_config($section, $name, $config_class);
895
+		// verify the newly created config object
896
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
897
+			return $this->{$section}->{$name};
898
+		} else {
899
+			EE_Error::add_error(
900
+				sprintf(esc_html__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
901
+				__FILE__,
902
+				__FUNCTION__,
903
+				__LINE__
904
+			);
905
+		}
906
+		return null;
907
+	}
908
+
909
+
910
+	/**
911
+	 *    get_config_option
912
+	 *
913
+	 * @access    public
914
+	 * @param    string $config_option_name
915
+	 * @return    mixed EE_Config_Base | FALSE
916
+	 */
917
+	public function get_config_option($config_option_name = '')
918
+	{
919
+		// retrieve the wp-option for this config class.
920
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
921
+		if (empty($config_option)) {
922
+			EE_Config::log($config_option_name . '-NOT-FOUND');
923
+		}
924
+		return $config_option;
925
+	}
926
+
927
+
928
+	/**
929
+	 * log
930
+	 *
931
+	 * @param string $config_option_name
932
+	 */
933
+	public static function log($config_option_name = '')
934
+	{
935
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
936
+			$config_log = get_option(EE_Config::LOG_NAME, array());
937
+			/** @var RequestParams $request */
938
+			$request = LoaderFactory::getLoader()->getShared(RequestParams::class);
939
+			$config_log[ (string) microtime(true) ] = array(
940
+				'config_name' => $config_option_name,
941
+				'request'     => $request->requestParams(),
942
+			);
943
+			update_option(EE_Config::LOG_NAME, $config_log);
944
+		}
945
+	}
946
+
947
+
948
+	/**
949
+	 * trim_log
950
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
951
+	 */
952
+	public static function trim_log()
953
+	{
954
+		if (! EE_Config::logging_enabled()) {
955
+			return;
956
+		}
957
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
958
+		$log_length = count($config_log);
959
+		if ($log_length > EE_Config::LOG_LENGTH) {
960
+			ksort($config_log);
961
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
962
+			update_option(EE_Config::LOG_NAME, $config_log);
963
+		}
964
+	}
965
+
966
+
967
+	/**
968
+	 *    get_page_for_posts
969
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
970
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
971
+	 *
972
+	 * @access    public
973
+	 * @return    string
974
+	 */
975
+	public static function get_page_for_posts()
976
+	{
977
+		$page_for_posts = get_option('page_for_posts');
978
+		if (! $page_for_posts) {
979
+			return 'posts';
980
+		}
981
+		global $wpdb;
982
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
983
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
984
+	}
985
+
986
+
987
+	/**
988
+	 *    register_shortcodes_and_modules.
989
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
990
+	 *    In fact, this is where we give modules a chance to let core know they exist
991
+	 *    so they can help trigger maintenance mode if it's needed
992
+	 *
993
+	 * @access    public
994
+	 * @return    void
995
+	 */
996
+	public function register_shortcodes_and_modules()
997
+	{
998
+		// allow modules to set hooks for the rest of the system
999
+		EE_Registry::instance()->modules = $this->_register_modules();
1000
+	}
1001
+
1002
+
1003
+	/**
1004
+	 *    initialize_shortcodes_and_modules
1005
+	 *    meaning they can start adding their hooks to get stuff done
1006
+	 *
1007
+	 * @access    public
1008
+	 * @return    void
1009
+	 */
1010
+	public function initialize_shortcodes_and_modules()
1011
+	{
1012
+		// allow modules to set hooks for the rest of the system
1013
+		$this->_initialize_modules();
1014
+	}
1015
+
1016
+
1017
+	/**
1018
+	 *    widgets_init
1019
+	 *
1020
+	 * @access private
1021
+	 * @return void
1022
+	 */
1023
+	public function widgets_init()
1024
+	{
1025
+		// only init widgets on admin pages when not in complete maintenance, and
1026
+		// on frontend when not in any maintenance mode
1027
+		if (
1028
+			! EE_Maintenance_Mode::instance()->level()
1029
+			|| (
1030
+				is_admin()
1031
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1032
+			)
1033
+		) {
1034
+			// grab list of installed widgets
1035
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1036
+			// filter list of modules to register
1037
+			$widgets_to_register = apply_filters(
1038
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1039
+				$widgets_to_register
1040
+			);
1041
+			if (! empty($widgets_to_register)) {
1042
+				// cycle thru widget folders
1043
+				foreach ($widgets_to_register as $widget_path) {
1044
+					// add to list of installed widget modules
1045
+					EE_Config::register_ee_widget($widget_path);
1046
+				}
1047
+			}
1048
+			// filter list of installed modules
1049
+			EE_Registry::instance()->widgets = apply_filters(
1050
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1051
+				EE_Registry::instance()->widgets
1052
+			);
1053
+		}
1054
+	}
1055
+
1056
+
1057
+	/**
1058
+	 *    register_ee_widget - makes core aware of this widget
1059
+	 *
1060
+	 * @access    public
1061
+	 * @param    string $widget_path - full path up to and including widget folder
1062
+	 * @return    void
1063
+	 */
1064
+	public static function register_ee_widget($widget_path = null)
1065
+	{
1066
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1067
+		$widget_ext = '.widget.php';
1068
+		// make all separators match
1069
+		$widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1070
+		// does the file path INCLUDE the actual file name as part of the path ?
1071
+		if (strpos($widget_path, $widget_ext) !== false) {
1072
+			// grab and shortcode file name from directory name and break apart at dots
1073
+			$file_name = explode('.', basename($widget_path));
1074
+			// take first segment from file name pieces and remove class prefix if it exists
1075
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1076
+			// sanitize shortcode directory name
1077
+			$widget = sanitize_key($widget);
1078
+			// now we need to rebuild the shortcode path
1079
+			$widget_path = explode('/', $widget_path);
1080
+			// remove last segment
1081
+			array_pop($widget_path);
1082
+			// glue it back together
1083
+			$widget_path = implode(DS, $widget_path);
1084
+		} else {
1085
+			// grab and sanitize widget directory name
1086
+			$widget = sanitize_key(basename($widget_path));
1087
+		}
1088
+		// create classname from widget directory name
1089
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1090
+		// add class prefix
1091
+		$widget_class = 'EEW_' . $widget;
1092
+		// does the widget exist ?
1093
+		if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1094
+			$msg = sprintf(
1095
+				esc_html__(
1096
+					'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',
1097
+					'event_espresso'
1098
+				),
1099
+				$widget_class,
1100
+				$widget_path . '/' . $widget_class . $widget_ext
1101
+			);
1102
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1103
+			return;
1104
+		}
1105
+		// load the widget class file
1106
+		require_once($widget_path . '/' . $widget_class . $widget_ext);
1107
+		// verify that class exists
1108
+		if (! class_exists($widget_class)) {
1109
+			$msg = sprintf(esc_html__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1110
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1111
+			return;
1112
+		}
1113
+		register_widget($widget_class);
1114
+		// add to array of registered widgets
1115
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1116
+	}
1117
+
1118
+
1119
+	/**
1120
+	 *        _register_modules
1121
+	 *
1122
+	 * @access private
1123
+	 * @return array
1124
+	 */
1125
+	private function _register_modules()
1126
+	{
1127
+		// grab list of installed modules
1128
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1129
+		// filter list of modules to register
1130
+		$modules_to_register = apply_filters(
1131
+			'FHEE__EE_Config__register_modules__modules_to_register',
1132
+			$modules_to_register
1133
+		);
1134
+		if (! empty($modules_to_register)) {
1135
+			// loop through folders
1136
+			foreach ($modules_to_register as $module_path) {
1137
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1138
+				if (
1139
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1140
+					&& $module_path !== EE_MODULES . 'gateways'
1141
+				) {
1142
+					// add to list of installed modules
1143
+					EE_Config::register_module($module_path);
1144
+				}
1145
+			}
1146
+		}
1147
+		// filter list of installed modules
1148
+		return apply_filters(
1149
+			'FHEE__EE_Config___register_modules__installed_modules',
1150
+			EE_Registry::instance()->modules
1151
+		);
1152
+	}
1153
+
1154
+
1155
+	/**
1156
+	 *    register_module - makes core aware of this module
1157
+	 *
1158
+	 * @access    public
1159
+	 * @param    string $module_path - full path up to and including module folder
1160
+	 * @return    bool
1161
+	 */
1162
+	public static function register_module($module_path = null)
1163
+	{
1164
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1165
+		$module_ext = '.module.php';
1166
+		// make all separators match
1167
+		$module_path = str_replace(array('\\', '/'), '/', $module_path);
1168
+		// does the file path INCLUDE the actual file name as part of the path ?
1169
+		if (strpos($module_path, $module_ext) !== false) {
1170
+			// grab and shortcode file name from directory name and break apart at dots
1171
+			$module_file = explode('.', basename($module_path));
1172
+			// now we need to rebuild the shortcode path
1173
+			$module_path = explode('/', $module_path);
1174
+			// remove last segment
1175
+			array_pop($module_path);
1176
+			// glue it back together
1177
+			$module_path = implode('/', $module_path) . '/';
1178
+			// take first segment from file name pieces and sanitize it
1179
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1180
+			// ensure class prefix is added
1181
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1182
+		} else {
1183
+			// we need to generate the filename based off of the folder name
1184
+			// grab and sanitize module name
1185
+			$module = strtolower(basename($module_path));
1186
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1187
+			// like trailingslashit()
1188
+			$module_path = rtrim($module_path, '/') . '/';
1189
+			// create classname from module directory name
1190
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1191
+			// add class prefix
1192
+			$module_class = 'EED_' . $module;
1193
+		}
1194
+		// does the module exist ?
1195
+		if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1196
+			$msg = sprintf(
1197
+				esc_html__(
1198
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1199
+					'event_espresso'
1200
+				),
1201
+				$module
1202
+			);
1203
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1204
+			return false;
1205
+		}
1206
+		// load the module class file
1207
+		require_once($module_path . $module_class . $module_ext);
1208
+		// verify that class exists
1209
+		if (! class_exists($module_class)) {
1210
+			$msg = sprintf(esc_html__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1211
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1212
+			return false;
1213
+		}
1214
+		// add to array of registered modules
1215
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1216
+		do_action(
1217
+			'AHEE__EE_Config__register_module__complete',
1218
+			$module_class,
1219
+			EE_Registry::instance()->modules->{$module_class}
1220
+		);
1221
+		return true;
1222
+	}
1223
+
1224
+
1225
+	/**
1226
+	 *    _initialize_modules
1227
+	 *    allow modules to set hooks for the rest of the system
1228
+	 *
1229
+	 * @access private
1230
+	 * @return void
1231
+	 */
1232
+	private function _initialize_modules()
1233
+	{
1234
+		// cycle thru shortcode folders
1235
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1236
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1237
+			// which set hooks ?
1238
+			if (is_admin()) {
1239
+				// fire immediately
1240
+				call_user_func(array($module_class, 'set_hooks_admin'));
1241
+			} else {
1242
+				// delay until other systems are online
1243
+				add_action(
1244
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1245
+					array($module_class, 'set_hooks')
1246
+				);
1247
+			}
1248
+		}
1249
+	}
1250
+
1251
+
1252
+	/**
1253
+	 *    register_route - adds module method routes to route_map
1254
+	 *
1255
+	 * @access    public
1256
+	 * @param    string $route       - "pretty" public alias for module method
1257
+	 * @param    string $module      - module name (classname without EED_ prefix)
1258
+	 * @param    string $method_name - the actual module method to be routed to
1259
+	 * @param    string $key         - url param key indicating a route is being called
1260
+	 * @return    bool
1261
+	 */
1262
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1263
+	{
1264
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1265
+		$module = str_replace('EED_', '', $module);
1266
+		$module_class = 'EED_' . $module;
1267
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1268
+			$msg = sprintf(esc_html__('The module %s has not been registered.', 'event_espresso'), $module);
1269
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1270
+			return false;
1271
+		}
1272
+		if (empty($route)) {
1273
+			$msg = sprintf(esc_html__('No route has been supplied.', 'event_espresso'), $route);
1274
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1275
+			return false;
1276
+		}
1277
+		if (! method_exists('EED_' . $module, $method_name)) {
1278
+			$msg = sprintf(
1279
+				esc_html__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1280
+				$route
1281
+			);
1282
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1283
+			return false;
1284
+		}
1285
+		EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1286
+		return true;
1287
+	}
1288
+
1289
+
1290
+	/**
1291
+	 *    get_route - get module method route
1292
+	 *
1293
+	 * @access    public
1294
+	 * @param    string $route - "pretty" public alias for module method
1295
+	 * @param    string $key   - url param key indicating a route is being called
1296
+	 * @return    string
1297
+	 */
1298
+	public static function get_route($route = null, $key = 'ee')
1299
+	{
1300
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1301
+		$route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1302
+		if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1303
+			return EE_Config::$_module_route_map[ $key ][ $route ];
1304
+		}
1305
+		return null;
1306
+	}
1307
+
1308
+
1309
+	/**
1310
+	 *    get_routes - get ALL module method routes
1311
+	 *
1312
+	 * @access    public
1313
+	 * @return    array
1314
+	 */
1315
+	public static function get_routes()
1316
+	{
1317
+		return EE_Config::$_module_route_map;
1318
+	}
1319
+
1320
+
1321
+	/**
1322
+	 *    register_forward - allows modules to forward request to another module for further processing
1323
+	 *
1324
+	 * @access    public
1325
+	 * @param    string       $route   - "pretty" public alias for module method
1326
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1327
+	 *                                 class, allows different forwards to be served based on status
1328
+	 * @param    array|string $forward - function name or array( class, method )
1329
+	 * @param    string       $key     - url param key indicating a route is being called
1330
+	 * @return    bool
1331
+	 */
1332
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1333
+	{
1334
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1335
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1336
+			$msg = sprintf(
1337
+				esc_html__('The module route %s for this forward has not been registered.', 'event_espresso'),
1338
+				$route
1339
+			);
1340
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1341
+			return false;
1342
+		}
1343
+		if (empty($forward)) {
1344
+			$msg = sprintf(esc_html__('No forwarding route has been supplied.', 'event_espresso'), $route);
1345
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1346
+			return false;
1347
+		}
1348
+		if (is_array($forward)) {
1349
+			if (! isset($forward[1])) {
1350
+				$msg = sprintf(
1351
+					esc_html__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1352
+					$route
1353
+				);
1354
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1355
+				return false;
1356
+			}
1357
+			if (! method_exists($forward[0], $forward[1])) {
1358
+				$msg = sprintf(
1359
+					esc_html__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1360
+					$forward[1],
1361
+					$route
1362
+				);
1363
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1364
+				return false;
1365
+			}
1366
+		} elseif (! function_exists($forward)) {
1367
+			$msg = sprintf(
1368
+				esc_html__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1369
+				$forward,
1370
+				$route
1371
+			);
1372
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1373
+			return false;
1374
+		}
1375
+		EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1376
+		return true;
1377
+	}
1378
+
1379
+
1380
+	/**
1381
+	 *    get_forward - get forwarding route
1382
+	 *
1383
+	 * @access    public
1384
+	 * @param    string  $route  - "pretty" public alias for module method
1385
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1386
+	 *                           allows different forwards to be served based on status
1387
+	 * @param    string  $key    - url param key indicating a route is being called
1388
+	 * @return    string
1389
+	 */
1390
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1391
+	{
1392
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1393
+		if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1394
+			return apply_filters(
1395
+				'FHEE__EE_Config__get_forward',
1396
+				EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1397
+				$route,
1398
+				$status
1399
+			);
1400
+		}
1401
+		return null;
1402
+	}
1403
+
1404
+
1405
+	/**
1406
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1407
+	 *    results
1408
+	 *
1409
+	 * @access    public
1410
+	 * @param    string  $route  - "pretty" public alias for module method
1411
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1412
+	 *                           allows different views to be served based on status
1413
+	 * @param    string  $view
1414
+	 * @param    string  $key    - url param key indicating a route is being called
1415
+	 * @return    bool
1416
+	 */
1417
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1418
+	{
1419
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1420
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1421
+			$msg = sprintf(
1422
+				esc_html__('The module route %s for this view has not been registered.', 'event_espresso'),
1423
+				$route
1424
+			);
1425
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1426
+			return false;
1427
+		}
1428
+		if (! is_readable($view)) {
1429
+			$msg = sprintf(
1430
+				esc_html__(
1431
+					'The %s view file could not be found or is not readable due to file permissions.',
1432
+					'event_espresso'
1433
+				),
1434
+				$view
1435
+			);
1436
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1437
+			return false;
1438
+		}
1439
+		EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1440
+		return true;
1441
+	}
1442
+
1443
+
1444
+	/**
1445
+	 *    get_view - get view for route and status
1446
+	 *
1447
+	 * @access    public
1448
+	 * @param    string  $route  - "pretty" public alias for module method
1449
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1450
+	 *                           allows different views to be served based on status
1451
+	 * @param    string  $key    - url param key indicating a route is being called
1452
+	 * @return    string
1453
+	 */
1454
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1455
+	{
1456
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1457
+		if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1458
+			return apply_filters(
1459
+				'FHEE__EE_Config__get_view',
1460
+				EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1461
+				$route,
1462
+				$status
1463
+			);
1464
+		}
1465
+		return null;
1466
+	}
1467
+
1468
+
1469
+	public function update_addon_option_names()
1470
+	{
1471
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1472
+	}
1473
+
1474
+
1475
+	public function shutdown()
1476
+	{
1477
+		$this->update_addon_option_names();
1478
+	}
1479
+
1480
+
1481
+	/**
1482
+	 * @return LegacyShortcodesManager
1483
+	 */
1484
+	public static function getLegacyShortcodesManager()
1485
+	{
1486
+		if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1487
+			EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1488
+				LegacyShortcodesManager::class
1489
+			);
1490
+		}
1491
+		return EE_Config::instance()->legacy_shortcodes_manager;
1492
+	}
1493
+
1494
+
1495
+	/**
1496
+	 * register_shortcode - makes core aware of this shortcode
1497
+	 *
1498
+	 * @deprecated 4.9.26
1499
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1500
+	 * @return    bool
1501
+	 */
1502
+	public static function register_shortcode($shortcode_path = null)
1503
+	{
1504
+		EE_Error::doing_it_wrong(
1505
+			__METHOD__,
1506
+			esc_html__(
1507
+				'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.',
1508
+				'event_espresso'
1509
+			),
1510
+			'4.9.26'
1511
+		);
1512
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1513
+	}
1514
+}
2354 1515
 
2355
-    /**
2356
-     * ReCaptcha width
2357
-     *
2358
-     * @var int $recaptcha_width
2359
-     * @deprecated
2360
-     */
2361
-    public $recaptcha_width;
1516
+/**
1517
+ * Base class used for config classes. These classes should generally not have
1518
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1519
+ * basically, they should just be well-defined stdClasses
1520
+ */
1521
+class EE_Config_Base
1522
+{
1523
+	/**
1524
+	 * Utility function for escaping the value of a property and returning.
1525
+	 *
1526
+	 * @param string $property property name (checks to see if exists).
1527
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1528
+	 * @throws EE_Error
1529
+	 */
1530
+	public function get_pretty($property)
1531
+	{
1532
+		if (! property_exists($this, $property)) {
1533
+			throw new EE_Error(
1534
+				sprintf(
1535
+					esc_html__(
1536
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1537
+						'event_espresso'
1538
+					),
1539
+					get_class($this),
1540
+					$property
1541
+				)
1542
+			);
1543
+		}
1544
+		// just handling escaping of strings for now.
1545
+		if (is_string($this->{$property})) {
1546
+			return stripslashes($this->{$property});
1547
+		}
1548
+		return $this->{$property};
1549
+	}
1550
+
1551
+
1552
+	public function populate()
1553
+	{
1554
+		// grab defaults via a new instance of this class.
1555
+		$class_name = get_class($this);
1556
+		$defaults = new $class_name();
1557
+		// loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1558
+		// default from our $defaults object.
1559
+		foreach (get_object_vars($defaults) as $property => $value) {
1560
+			if ($this->{$property} === null) {
1561
+				$this->{$property} = $value;
1562
+			}
1563
+		}
1564
+		// cleanup
1565
+		unset($defaults);
1566
+	}
1567
+
1568
+
1569
+	/**
1570
+	 *        __isset
1571
+	 *
1572
+	 * @param $a
1573
+	 * @return bool
1574
+	 */
1575
+	public function __isset($a)
1576
+	{
1577
+		return false;
1578
+	}
1579
+
1580
+
1581
+	/**
1582
+	 *        __unset
1583
+	 *
1584
+	 * @param $a
1585
+	 * @return bool
1586
+	 */
1587
+	public function __unset($a)
1588
+	{
1589
+		return false;
1590
+	}
1591
+
1592
+
1593
+	/**
1594
+	 *        __clone
1595
+	 */
1596
+	public function __clone()
1597
+	{
1598
+	}
1599
+
1600
+
1601
+	/**
1602
+	 *        __wakeup
1603
+	 */
1604
+	public function __wakeup()
1605
+	{
1606
+	}
1607
+
1608
+
1609
+	/**
1610
+	 *        __destruct
1611
+	 */
1612
+	public function __destruct()
1613
+	{
1614
+	}
1615
+}
2362 1616
 
2363
-    /**
2364
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2365
-     *
2366
-     * @var boolean $track_invalid_checkout_access
2367
-     */
2368
-    protected $track_invalid_checkout_access = true;
1617
+/**
1618
+ * Class for defining what's in the EE_Config relating to registration settings
1619
+ */
1620
+class EE_Core_Config extends EE_Config_Base
1621
+{
1622
+	const OPTION_NAME_UXIP = 'ee_ueip_optin';
1623
+
1624
+
1625
+	public $current_blog_id;
1626
+
1627
+	public $ee_ueip_optin;
1628
+
1629
+	public $ee_ueip_has_notified;
1630
+
1631
+	/**
1632
+	 * Not to be confused with the 4 critical page variables (See
1633
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1634
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1635
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1636
+	 *
1637
+	 * @var array
1638
+	 */
1639
+	public $post_shortcodes;
1640
+
1641
+	public $module_route_map;
1642
+
1643
+	public $module_forward_map;
1644
+
1645
+	public $module_view_map;
1646
+
1647
+	/**
1648
+	 * The next 4 vars are the IDs of critical EE pages.
1649
+	 *
1650
+	 * @var int
1651
+	 */
1652
+	public $reg_page_id;
1653
+
1654
+	public $txn_page_id;
1655
+
1656
+	public $thank_you_page_id;
1657
+
1658
+	public $cancel_page_id;
1659
+
1660
+	/**
1661
+	 * The next 4 vars are the URLs of critical EE pages.
1662
+	 *
1663
+	 * @var int
1664
+	 */
1665
+	public $reg_page_url;
1666
+
1667
+	public $txn_page_url;
1668
+
1669
+	public $thank_you_page_url;
1670
+
1671
+	public $cancel_page_url;
1672
+
1673
+	/**
1674
+	 * The next vars relate to the custom slugs for EE CPT routes
1675
+	 */
1676
+	public $event_cpt_slug;
1677
+
1678
+	/**
1679
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1680
+	 * request across blog switches in a multisite context.
1681
+	 * Avoids extra queries to the db for this option.
1682
+	 *
1683
+	 * @var bool
1684
+	 */
1685
+	public static $ee_ueip_option;
1686
+
1687
+
1688
+	/**
1689
+	 *    class constructor
1690
+	 *
1691
+	 * @access    public
1692
+	 */
1693
+	public function __construct()
1694
+	{
1695
+		// set default organization settings
1696
+		$this->current_blog_id = get_current_blog_id();
1697
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1698
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1699
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1700
+		$this->post_shortcodes = array();
1701
+		$this->module_route_map = array();
1702
+		$this->module_forward_map = array();
1703
+		$this->module_view_map = array();
1704
+		// critical EE page IDs
1705
+		$this->reg_page_id = 0;
1706
+		$this->txn_page_id = 0;
1707
+		$this->thank_you_page_id = 0;
1708
+		$this->cancel_page_id = 0;
1709
+		// critical EE page URLs
1710
+		$this->reg_page_url = '';
1711
+		$this->txn_page_url = '';
1712
+		$this->thank_you_page_url = '';
1713
+		$this->cancel_page_url = '';
1714
+		// cpt slugs
1715
+		$this->event_cpt_slug = esc_html__('events', 'event_espresso');
1716
+		// ueip constant check
1717
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1718
+			$this->ee_ueip_optin = false;
1719
+			$this->ee_ueip_has_notified = true;
1720
+		}
1721
+	}
1722
+
1723
+
1724
+	/**
1725
+	 * @return array
1726
+	 */
1727
+	public function get_critical_pages_array()
1728
+	{
1729
+		return array(
1730
+			$this->reg_page_id,
1731
+			$this->txn_page_id,
1732
+			$this->thank_you_page_id,
1733
+			$this->cancel_page_id,
1734
+		);
1735
+	}
1736
+
1737
+
1738
+	/**
1739
+	 * @return array
1740
+	 */
1741
+	public function get_critical_pages_shortcodes_array()
1742
+	{
1743
+		return array(
1744
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1745
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1746
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1747
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1748
+		);
1749
+	}
1750
+
1751
+
1752
+	/**
1753
+	 *  gets/returns URL for EE reg_page
1754
+	 *
1755
+	 * @access    public
1756
+	 * @return    string
1757
+	 */
1758
+	public function reg_page_url()
1759
+	{
1760
+		if (! $this->reg_page_url) {
1761
+			$this->reg_page_url = add_query_arg(
1762
+				array('uts' => time()),
1763
+				get_permalink($this->reg_page_id)
1764
+			) . '#checkout';
1765
+		}
1766
+		return $this->reg_page_url;
1767
+	}
1768
+
1769
+
1770
+	/**
1771
+	 *  gets/returns URL for EE txn_page
1772
+	 *
1773
+	 * @param array $query_args like what gets passed to
1774
+	 *                          add_query_arg() as the first argument
1775
+	 * @access    public
1776
+	 * @return    string
1777
+	 */
1778
+	public function txn_page_url($query_args = array())
1779
+	{
1780
+		if (! $this->txn_page_url) {
1781
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1782
+		}
1783
+		if ($query_args) {
1784
+			return add_query_arg($query_args, $this->txn_page_url);
1785
+		} else {
1786
+			return $this->txn_page_url;
1787
+		}
1788
+	}
1789
+
1790
+
1791
+	/**
1792
+	 *  gets/returns URL for EE thank_you_page
1793
+	 *
1794
+	 * @param array $query_args like what gets passed to
1795
+	 *                          add_query_arg() as the first argument
1796
+	 * @access    public
1797
+	 * @return    string
1798
+	 */
1799
+	public function thank_you_page_url($query_args = array())
1800
+	{
1801
+		if (! $this->thank_you_page_url) {
1802
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1803
+		}
1804
+		if ($query_args) {
1805
+			return add_query_arg($query_args, $this->thank_you_page_url);
1806
+		} else {
1807
+			return $this->thank_you_page_url;
1808
+		}
1809
+	}
1810
+
1811
+
1812
+	/**
1813
+	 *  gets/returns URL for EE cancel_page
1814
+	 *
1815
+	 * @access    public
1816
+	 * @return    string
1817
+	 */
1818
+	public function cancel_page_url()
1819
+	{
1820
+		if (! $this->cancel_page_url) {
1821
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1822
+		}
1823
+		return $this->cancel_page_url;
1824
+	}
1825
+
1826
+
1827
+	/**
1828
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1829
+	 *
1830
+	 * @since 4.7.5
1831
+	 */
1832
+	protected function _reset_urls()
1833
+	{
1834
+		$this->reg_page_url = '';
1835
+		$this->txn_page_url = '';
1836
+		$this->cancel_page_url = '';
1837
+		$this->thank_you_page_url = '';
1838
+	}
1839
+
1840
+
1841
+	/**
1842
+	 * Used to return what the optin value is set for the EE User Experience Program.
1843
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1844
+	 * on the main site only.
1845
+	 *
1846
+	 * @return bool
1847
+	 */
1848
+	protected function _get_main_ee_ueip_optin()
1849
+	{
1850
+		// if this is the main site then we can just bypass our direct query.
1851
+		if (is_main_site()) {
1852
+			return get_option(self::OPTION_NAME_UXIP, false);
1853
+		}
1854
+		// is this already cached for this request?  If so use it.
1855
+		if (EE_Core_Config::$ee_ueip_option !== null) {
1856
+			return EE_Core_Config::$ee_ueip_option;
1857
+		}
1858
+		global $wpdb;
1859
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1860
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1861
+		$option = self::OPTION_NAME_UXIP;
1862
+		// set correct table for query
1863
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1864
+		// rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1865
+		// get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1866
+		// re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1867
+		// this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1868
+		// for the purpose of caching.
1869
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1870
+		if (false !== $pre) {
1871
+			EE_Core_Config::$ee_ueip_option = $pre;
1872
+			return EE_Core_Config::$ee_ueip_option;
1873
+		}
1874
+		$row = $wpdb->get_row(
1875
+			$wpdb->prepare(
1876
+				"SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1877
+				$option
1878
+			)
1879
+		);
1880
+		if (is_object($row)) {
1881
+			$value = $row->option_value;
1882
+		} else { // option does not exist so use default.
1883
+			EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1884
+			return EE_Core_Config::$ee_ueip_option;
1885
+		}
1886
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1887
+		return EE_Core_Config::$ee_ueip_option;
1888
+	}
1889
+
1890
+
1891
+	/**
1892
+	 * Utility function for escaping the value of a property and returning.
1893
+	 *
1894
+	 * @param string $property property name (checks to see if exists).
1895
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1896
+	 * @throws EE_Error
1897
+	 */
1898
+	public function get_pretty($property)
1899
+	{
1900
+		if ($property === self::OPTION_NAME_UXIP) {
1901
+			return $this->ee_ueip_optin ? 'yes' : 'no';
1902
+		}
1903
+		return parent::get_pretty($property);
1904
+	}
1905
+
1906
+
1907
+	/**
1908
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1909
+	 * on the object.
1910
+	 *
1911
+	 * @return array
1912
+	 */
1913
+	public function __sleep()
1914
+	{
1915
+		// reset all url properties
1916
+		$this->_reset_urls();
1917
+		// return what to save to db
1918
+		return array_keys(get_object_vars($this));
1919
+	}
1920
+}
2369 1921
 
2370
-    /**
2371
-     * Whether or not to show the privacy policy consent checkbox
2372
-     *
2373
-     * @var bool
2374
-     */
2375
-    public $consent_checkbox_enabled;
1922
+/**
1923
+ * Config class for storing info on the Organization
1924
+ */
1925
+class EE_Organization_Config extends EE_Config_Base
1926
+{
1927
+	/**
1928
+	 * @var string $name
1929
+	 * eg EE4.1
1930
+	 */
1931
+	public $name;
1932
+
1933
+	/**
1934
+	 * @var string $address_1
1935
+	 * eg 123 Onna Road
1936
+	 */
1937
+	public $address_1 = '';
1938
+
1939
+	/**
1940
+	 * @var string $address_2
1941
+	 * eg PO Box 123
1942
+	 */
1943
+	public $address_2 = '';
1944
+
1945
+	/**
1946
+	 * @var string $city
1947
+	 * eg Inna City
1948
+	 */
1949
+	public $city = '';
1950
+
1951
+	/**
1952
+	 * @var int $STA_ID
1953
+	 * eg 4
1954
+	 */
1955
+	public $STA_ID = 0;
1956
+
1957
+	/**
1958
+	 * @var string $CNT_ISO
1959
+	 * eg US
1960
+	 */
1961
+	public $CNT_ISO = '';
1962
+
1963
+	/**
1964
+	 * @var string $zip
1965
+	 * eg 12345  or V1A 2B3
1966
+	 */
1967
+	public $zip = '';
1968
+
1969
+	/**
1970
+	 * @var string $email
1971
+	 * eg [email protected]
1972
+	 */
1973
+	public $email;
1974
+
1975
+	/**
1976
+	 * @var string $phone
1977
+	 * eg. 111-111-1111
1978
+	 */
1979
+	public $phone = '';
1980
+
1981
+	/**
1982
+	 * @var string $vat
1983
+	 * VAT/Tax Number
1984
+	 */
1985
+	public $vat = '';
1986
+
1987
+	/**
1988
+	 * @var string $logo_url
1989
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1990
+	 */
1991
+	public $logo_url = '';
1992
+
1993
+	/**
1994
+	 * The below are all various properties for holding links to organization social network profiles
1995
+	 *
1996
+	 * @var string
1997
+	 */
1998
+	/**
1999
+	 * facebook (facebook.com/profile.name)
2000
+	 *
2001
+	 * @var string
2002
+	 */
2003
+	public $facebook = '';
2004
+
2005
+	/**
2006
+	 * twitter (twitter.com/twitter_handle)
2007
+	 *
2008
+	 * @var string
2009
+	 */
2010
+	public $twitter = '';
2011
+
2012
+	/**
2013
+	 * linkedin (linkedin.com/in/profile_name)
2014
+	 *
2015
+	 * @var string
2016
+	 */
2017
+	public $linkedin = '';
2018
+
2019
+	/**
2020
+	 * pinterest (www.pinterest.com/profile_name)
2021
+	 *
2022
+	 * @var string
2023
+	 */
2024
+	public $pinterest = '';
2025
+
2026
+	/**
2027
+	 * google+ (google.com/+profileName)
2028
+	 *
2029
+	 * @var string
2030
+	 */
2031
+	public $google = '';
2032
+
2033
+	/**
2034
+	 * instagram (instagram.com/handle)
2035
+	 *
2036
+	 * @var string
2037
+	 */
2038
+	public $instagram = '';
2039
+
2040
+
2041
+	/**
2042
+	 *    class constructor
2043
+	 *
2044
+	 * @access    public
2045
+	 */
2046
+	public function __construct()
2047
+	{
2048
+		// set default organization settings
2049
+		// decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2050
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2051
+		$this->email = get_bloginfo('admin_email');
2052
+	}
2053
+}
2376 2054
 
2377
-    /**
2378
-     * Label text to show on the checkbox
2379
-     *
2380
-     * @var string
2381
-     */
2382
-    public $consent_checkbox_label_text;
2055
+/**
2056
+ * Class for defining what's in the EE_Config relating to currency
2057
+ */
2058
+class EE_Currency_Config extends EE_Config_Base
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
+		if ($CNT_ISO && $CNT_ISO === $this->code) {
2130
+			return;
2131
+		}
2132
+		// get country code from organization settings or use default
2133
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2134
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2135
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2136
+			: '';
2137
+		// but override if requested
2138
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2139
+		// 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
2140
+		$this->setCurrency($CNT_ISO);
2141
+		// fallback to hardcoded defaults, in case the above failed
2142
+		if (empty($this->code)) {
2143
+			$this->setFallbackCurrency();
2144
+		}
2145
+	}
2146
+
2147
+
2148
+	/**
2149
+	 * @param string|null $CNT_ISO
2150
+	 * @throws EE_Error
2151
+	 * @throws ReflectionException
2152
+	 */
2153
+	public function setCurrency(?string $CNT_ISO = '')
2154
+	{
2155
+		if (empty($CNT_ISO) || ! EE_Maintenance_Mode::instance()->models_can_query()) {
2156
+			return;
2157
+		}
2158
+
2159
+		/** @var TableAnalysis $table_analysis */
2160
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', [], true);
2161
+		if (! $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())) {
2162
+			return;
2163
+		}
2164
+		// retrieve the country settings from the db, just in case they have been customized
2165
+		$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2166
+		if (! $country instanceof EE_Country) {
2167
+			throw new DomainException(
2168
+				esc_html__('Invalid Country ISO Code.', 'event_espresso')
2169
+			);
2170
+		}
2171
+		$this->code    = $country->currency_code();                  // currency code: USD, CAD, EUR
2172
+		$this->name    = $country->currency_name_single();           // Dollar
2173
+		$this->plural  = $country->currency_name_plural();           // Dollars
2174
+		$this->sign    = $country->currency_sign();                  // currency sign: $
2175
+		$this->sign_b4 = $country->currency_sign_before();           // currency sign before or after
2176
+		$this->dec_plc = $country->currency_decimal_places();        // decimal places: 2 = 0.00  3 = 0.000
2177
+		$this->dec_mrk = $country->currency_decimal_mark();          // decimal mark: ',' = 0,01 or '.' = 0.01
2178
+		$this->thsnds  = $country->currency_thousands_separator();   // thousands sep: ',' = 1,000 or '.' = 1.000
2179
+	}
2180
+
2181
+
2182
+	private function setFallbackCurrency()
2183
+	{
2184
+		// set default currency settings
2185
+		$this->code    = 'USD';
2186
+		$this->name    = esc_html__('Dollar', 'event_espresso');
2187
+		$this->plural  = esc_html__('Dollars', 'event_espresso');
2188
+		$this->sign    = '$';
2189
+		$this->sign_b4 = true;
2190
+		$this->dec_plc = 2;
2191
+		$this->dec_mrk = '.';
2192
+		$this->thsnds  = ',';
2193
+	}
2194
+
2195
+
2196
+	/**
2197
+	 * @param string|null $CNT_ISO
2198
+	 * @return EE_Currency_Config
2199
+	 * @throws EE_Error
2200
+	 * @throws ReflectionException
2201
+	 */
2202
+	public static function getCurrencyConfig(?string $CNT_ISO = ''): EE_Currency_Config
2203
+	{
2204
+		// if CNT_ISO passed lets try to get currency settings for it.
2205
+		$currency_config = ! empty($CNT_ISO)
2206
+			? new EE_Currency_Config($CNT_ISO)
2207
+			: null;
2208
+		// default currency settings for site if not set
2209
+		if ($currency_config instanceof EE_Currency_Config) {
2210
+			return $currency_config;
2211
+		}
2212
+		EE_Config::instance()->currency = EE_Config::instance()->currency instanceof EE_Currency_Config
2213
+			? EE_Config::instance()->currency
2214
+			: new EE_Currency_Config();
2215
+		return EE_Config::instance()->currency;
2216
+	}
2217
+}
2383 2218
 
2384
-    /*
2219
+/**
2220
+ * Class for defining what's in the EE_Config relating to registration settings
2221
+ */
2222
+class EE_Registration_Config extends EE_Config_Base
2223
+{
2224
+	/**
2225
+	 * Default registration status
2226
+	 *
2227
+	 * @var string $default_STS_ID
2228
+	 * eg 'RPP'
2229
+	 */
2230
+	public $default_STS_ID;
2231
+
2232
+	/**
2233
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2234
+	 * registrations)
2235
+	 *
2236
+	 * @var int
2237
+	 */
2238
+	public $default_maximum_number_of_tickets;
2239
+
2240
+	/**
2241
+	 * level of validation to apply to email addresses
2242
+	 *
2243
+	 * @var string $email_validation_level
2244
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2245
+	 */
2246
+	public $email_validation_level;
2247
+
2248
+	/**
2249
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2250
+	 *
2251
+	 * @var boolean $show_pending_payment_options
2252
+	 */
2253
+	public $show_pending_payment_options;
2254
+
2255
+	/**
2256
+	 * Whether to skip the registration confirmation page
2257
+	 *
2258
+	 * @var boolean $skip_reg_confirmation
2259
+	 */
2260
+	public $skip_reg_confirmation;
2261
+
2262
+	/**
2263
+	 * an array of SPCO reg steps where:
2264
+	 *        the keys denotes the reg step order
2265
+	 *        each element consists of an array with the following elements:
2266
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2267
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2268
+	 *            "slug" => the URL param used to trigger the reg step
2269
+	 *
2270
+	 * @var array $reg_steps
2271
+	 */
2272
+	public $reg_steps;
2273
+
2274
+	/**
2275
+	 * Whether registration confirmation should be the last page of SPCO
2276
+	 *
2277
+	 * @var boolean $reg_confirmation_last
2278
+	 */
2279
+	public $reg_confirmation_last;
2280
+
2281
+	/**
2282
+	 * Whether or not to enable the EE Bot Trap
2283
+	 *
2284
+	 * @var boolean $use_bot_trap
2285
+	 */
2286
+	public $use_bot_trap;
2287
+
2288
+	/**
2289
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2290
+	 *
2291
+	 * @var boolean $use_encryption
2292
+	 */
2293
+	public $use_encryption;
2294
+
2295
+	/**
2296
+	 * Whether or not to use ReCaptcha
2297
+	 *
2298
+	 * @var boolean $use_captcha
2299
+	 */
2300
+	public $use_captcha;
2301
+
2302
+	/**
2303
+	 * ReCaptcha Theme
2304
+	 *
2305
+	 * @var string $recaptcha_theme
2306
+	 *    options: 'dark', 'light', 'invisible'
2307
+	 */
2308
+	public $recaptcha_theme;
2309
+
2310
+	/**
2311
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2312
+	 *
2313
+	 * @var string $recaptcha_badge
2314
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2315
+	 */
2316
+	public $recaptcha_badge;
2317
+
2318
+	/**
2319
+	 * ReCaptcha Type
2320
+	 *
2321
+	 * @var string $recaptcha_type
2322
+	 *    options: 'audio', 'image'
2323
+	 */
2324
+	public $recaptcha_type;
2325
+
2326
+	/**
2327
+	 * ReCaptcha language
2328
+	 *
2329
+	 * @var string $recaptcha_language
2330
+	 * eg 'en'
2331
+	 */
2332
+	public $recaptcha_language;
2333
+
2334
+	/**
2335
+	 * ReCaptcha public key
2336
+	 *
2337
+	 * @var string $recaptcha_publickey
2338
+	 */
2339
+	public $recaptcha_publickey;
2340
+
2341
+	/**
2342
+	 * ReCaptcha private key
2343
+	 *
2344
+	 * @var string $recaptcha_privatekey
2345
+	 */
2346
+	public $recaptcha_privatekey;
2347
+
2348
+	/**
2349
+	 * array of form names protected by ReCaptcha
2350
+	 *
2351
+	 * @var array $recaptcha_protected_forms
2352
+	 */
2353
+	public $recaptcha_protected_forms;
2354
+
2355
+	/**
2356
+	 * ReCaptcha width
2357
+	 *
2358
+	 * @var int $recaptcha_width
2359
+	 * @deprecated
2360
+	 */
2361
+	public $recaptcha_width;
2362
+
2363
+	/**
2364
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2365
+	 *
2366
+	 * @var boolean $track_invalid_checkout_access
2367
+	 */
2368
+	protected $track_invalid_checkout_access = true;
2369
+
2370
+	/**
2371
+	 * Whether or not to show the privacy policy consent checkbox
2372
+	 *
2373
+	 * @var bool
2374
+	 */
2375
+	public $consent_checkbox_enabled;
2376
+
2377
+	/**
2378
+	 * Label text to show on the checkbox
2379
+	 *
2380
+	 * @var string
2381
+	 */
2382
+	public $consent_checkbox_label_text;
2383
+
2384
+	/*
2385 2385
      * String describing how long to keep payment logs. Passed into DateTime constructor
2386 2386
      * @var string
2387 2387
      */
2388
-    public $gateway_log_lifespan = '1 week';
2389
-
2390
-    /**
2391
-     * Enable copy attendee info at form
2392
-     *
2393
-     * @var boolean $enable_copy_attendee
2394
-     */
2395
-    protected $copy_attendee_info = true;
2396
-
2397
-
2398
-    /**
2399
-     *    class constructor
2400
-     *
2401
-     * @access    public
2402
-     */
2403
-    public function __construct()
2404
-    {
2405
-        // set default registration settings
2406
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2407
-        $this->email_validation_level = 'wp_default';
2408
-        $this->show_pending_payment_options = true;
2409
-        $this->skip_reg_confirmation = true;
2410
-        $this->reg_steps = array();
2411
-        $this->reg_confirmation_last = false;
2412
-        $this->use_bot_trap = true;
2413
-        $this->use_encryption = true;
2414
-        $this->use_captcha = false;
2415
-        $this->recaptcha_theme = 'light';
2416
-        $this->recaptcha_badge = 'bottomleft';
2417
-        $this->recaptcha_type = 'image';
2418
-        $this->recaptcha_language = 'en';
2419
-        $this->recaptcha_publickey = null;
2420
-        $this->recaptcha_privatekey = null;
2421
-        $this->recaptcha_protected_forms = array();
2422
-        $this->recaptcha_width = 500;
2423
-        $this->default_maximum_number_of_tickets = 10;
2424
-        $this->consent_checkbox_enabled = false;
2425
-        $this->consent_checkbox_label_text = '';
2426
-        $this->gateway_log_lifespan = '7 days';
2427
-        $this->copy_attendee_info = true;
2428
-    }
2429
-
2430
-
2431
-    /**
2432
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2433
-     *
2434
-     * @since 4.8.8.rc.019
2435
-     */
2436
-    public function do_hooks()
2437
-    {
2438
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2439
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2440
-        add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2441
-    }
2442
-
2443
-
2444
-    /**
2445
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2446
-     * EVT_default_registration_status field matches the config setting for default_STS_ID.
2447
-     */
2448
-    public function set_default_reg_status_on_EEM_Event()
2449
-    {
2450
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2451
-    }
2452
-
2453
-
2454
-    /**
2455
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2456
-     * for Events matches the config setting for default_maximum_number_of_tickets
2457
-     */
2458
-    public function set_default_max_ticket_on_EEM_Event()
2459
-    {
2460
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2461
-    }
2462
-
2463
-
2464
-    /**
2465
-     * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2466
-     * constructed because that happens before we can get the privacy policy page's permalink.
2467
-     *
2468
-     * @throws InvalidArgumentException
2469
-     * @throws InvalidDataTypeException
2470
-     * @throws InvalidInterfaceException
2471
-     */
2472
-    public function setDefaultCheckboxLabelText()
2473
-    {
2474
-        if (
2475
-            $this->getConsentCheckboxLabelText() === null
2476
-            || $this->getConsentCheckboxLabelText() === ''
2477
-        ) {
2478
-            $opening_a_tag = '';
2479
-            $closing_a_tag = '';
2480
-            if (function_exists('get_privacy_policy_url')) {
2481
-                $privacy_page_url = get_privacy_policy_url();
2482
-                if (! empty($privacy_page_url)) {
2483
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2484
-                    $closing_a_tag = '</a>';
2485
-                }
2486
-            }
2487
-            $loader = LoaderFactory::getLoader();
2488
-            $org_config = $loader->getShared('EE_Organization_Config');
2489
-            /**
2490
-             * @var $org_config EE_Organization_Config
2491
-             */
2492
-
2493
-            $this->setConsentCheckboxLabelText(
2494
-                sprintf(
2495
-                    esc_html__(
2496
-                        'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2497
-                        'event_espresso'
2498
-                    ),
2499
-                    $org_config->name,
2500
-                    $opening_a_tag,
2501
-                    $closing_a_tag
2502
-                )
2503
-            );
2504
-        }
2505
-    }
2506
-
2507
-
2508
-    /**
2509
-     * @return boolean
2510
-     */
2511
-    public function track_invalid_checkout_access()
2512
-    {
2513
-        return $this->track_invalid_checkout_access;
2514
-    }
2515
-
2516
-
2517
-    /**
2518
-     * @param boolean $track_invalid_checkout_access
2519
-     */
2520
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2521
-    {
2522
-        $this->track_invalid_checkout_access = filter_var(
2523
-            $track_invalid_checkout_access,
2524
-            FILTER_VALIDATE_BOOLEAN
2525
-        );
2526
-    }
2527
-
2528
-    /**
2529
-     * @return boolean
2530
-     */
2531
-    public function copyAttendeeInfo()
2532
-    {
2533
-        return $this->copy_attendee_info;
2534
-    }
2535
-
2536
-
2537
-    /**
2538
-     * @param boolean $copy_attendee_info
2539
-     */
2540
-    public function setCopyAttendeeInfo($copy_attendee_info)
2541
-    {
2542
-        $this->copy_attendee_info = filter_var(
2543
-            $copy_attendee_info,
2544
-            FILTER_VALIDATE_BOOLEAN
2545
-        );
2546
-    }
2547
-
2548
-
2549
-    /**
2550
-     * Gets the options to make availalbe for the gateway log lifespan
2551
-     * @return array
2552
-     */
2553
-    public function gatewayLogLifespanOptions()
2554
-    {
2555
-        return (array) apply_filters(
2556
-            'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2557
-            array(
2558
-                '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2559
-                '1 day' => esc_html__('1 Day', 'event_espresso'),
2560
-                '7 days' => esc_html__('7 Days', 'event_espresso'),
2561
-                '14 days' => esc_html__('14 Days', 'event_espresso'),
2562
-                '30 days' => esc_html__('30 Days', 'event_espresso')
2563
-            )
2564
-        );
2565
-    }
2566
-
2567
-
2568
-    /**
2569
-     * @return bool
2570
-     */
2571
-    public function isConsentCheckboxEnabled()
2572
-    {
2573
-        return $this->consent_checkbox_enabled;
2574
-    }
2575
-
2576
-
2577
-    /**
2578
-     * @param bool $consent_checkbox_enabled
2579
-     */
2580
-    public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2581
-    {
2582
-        $this->consent_checkbox_enabled = filter_var(
2583
-            $consent_checkbox_enabled,
2584
-            FILTER_VALIDATE_BOOLEAN
2585
-        );
2586
-    }
2587
-
2588
-
2589
-    /**
2590
-     * @return string
2591
-     */
2592
-    public function getConsentCheckboxLabelText()
2593
-    {
2594
-        return $this->consent_checkbox_label_text;
2595
-    }
2596
-
2597
-
2598
-    /**
2599
-     * @param string $consent_checkbox_label_text
2600
-     */
2601
-    public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2602
-    {
2603
-        $this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2604
-    }
2388
+	public $gateway_log_lifespan = '1 week';
2389
+
2390
+	/**
2391
+	 * Enable copy attendee info at form
2392
+	 *
2393
+	 * @var boolean $enable_copy_attendee
2394
+	 */
2395
+	protected $copy_attendee_info = true;
2396
+
2397
+
2398
+	/**
2399
+	 *    class constructor
2400
+	 *
2401
+	 * @access    public
2402
+	 */
2403
+	public function __construct()
2404
+	{
2405
+		// set default registration settings
2406
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2407
+		$this->email_validation_level = 'wp_default';
2408
+		$this->show_pending_payment_options = true;
2409
+		$this->skip_reg_confirmation = true;
2410
+		$this->reg_steps = array();
2411
+		$this->reg_confirmation_last = false;
2412
+		$this->use_bot_trap = true;
2413
+		$this->use_encryption = true;
2414
+		$this->use_captcha = false;
2415
+		$this->recaptcha_theme = 'light';
2416
+		$this->recaptcha_badge = 'bottomleft';
2417
+		$this->recaptcha_type = 'image';
2418
+		$this->recaptcha_language = 'en';
2419
+		$this->recaptcha_publickey = null;
2420
+		$this->recaptcha_privatekey = null;
2421
+		$this->recaptcha_protected_forms = array();
2422
+		$this->recaptcha_width = 500;
2423
+		$this->default_maximum_number_of_tickets = 10;
2424
+		$this->consent_checkbox_enabled = false;
2425
+		$this->consent_checkbox_label_text = '';
2426
+		$this->gateway_log_lifespan = '7 days';
2427
+		$this->copy_attendee_info = true;
2428
+	}
2429
+
2430
+
2431
+	/**
2432
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2433
+	 *
2434
+	 * @since 4.8.8.rc.019
2435
+	 */
2436
+	public function do_hooks()
2437
+	{
2438
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2439
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2440
+		add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2441
+	}
2442
+
2443
+
2444
+	/**
2445
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2446
+	 * EVT_default_registration_status field matches the config setting for default_STS_ID.
2447
+	 */
2448
+	public function set_default_reg_status_on_EEM_Event()
2449
+	{
2450
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2451
+	}
2452
+
2453
+
2454
+	/**
2455
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2456
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2457
+	 */
2458
+	public function set_default_max_ticket_on_EEM_Event()
2459
+	{
2460
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2461
+	}
2462
+
2463
+
2464
+	/**
2465
+	 * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2466
+	 * constructed because that happens before we can get the privacy policy page's permalink.
2467
+	 *
2468
+	 * @throws InvalidArgumentException
2469
+	 * @throws InvalidDataTypeException
2470
+	 * @throws InvalidInterfaceException
2471
+	 */
2472
+	public function setDefaultCheckboxLabelText()
2473
+	{
2474
+		if (
2475
+			$this->getConsentCheckboxLabelText() === null
2476
+			|| $this->getConsentCheckboxLabelText() === ''
2477
+		) {
2478
+			$opening_a_tag = '';
2479
+			$closing_a_tag = '';
2480
+			if (function_exists('get_privacy_policy_url')) {
2481
+				$privacy_page_url = get_privacy_policy_url();
2482
+				if (! empty($privacy_page_url)) {
2483
+					$opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2484
+					$closing_a_tag = '</a>';
2485
+				}
2486
+			}
2487
+			$loader = LoaderFactory::getLoader();
2488
+			$org_config = $loader->getShared('EE_Organization_Config');
2489
+			/**
2490
+			 * @var $org_config EE_Organization_Config
2491
+			 */
2492
+
2493
+			$this->setConsentCheckboxLabelText(
2494
+				sprintf(
2495
+					esc_html__(
2496
+						'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2497
+						'event_espresso'
2498
+					),
2499
+					$org_config->name,
2500
+					$opening_a_tag,
2501
+					$closing_a_tag
2502
+				)
2503
+			);
2504
+		}
2505
+	}
2506
+
2507
+
2508
+	/**
2509
+	 * @return boolean
2510
+	 */
2511
+	public function track_invalid_checkout_access()
2512
+	{
2513
+		return $this->track_invalid_checkout_access;
2514
+	}
2515
+
2516
+
2517
+	/**
2518
+	 * @param boolean $track_invalid_checkout_access
2519
+	 */
2520
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2521
+	{
2522
+		$this->track_invalid_checkout_access = filter_var(
2523
+			$track_invalid_checkout_access,
2524
+			FILTER_VALIDATE_BOOLEAN
2525
+		);
2526
+	}
2527
+
2528
+	/**
2529
+	 * @return boolean
2530
+	 */
2531
+	public function copyAttendeeInfo()
2532
+	{
2533
+		return $this->copy_attendee_info;
2534
+	}
2535
+
2536
+
2537
+	/**
2538
+	 * @param boolean $copy_attendee_info
2539
+	 */
2540
+	public function setCopyAttendeeInfo($copy_attendee_info)
2541
+	{
2542
+		$this->copy_attendee_info = filter_var(
2543
+			$copy_attendee_info,
2544
+			FILTER_VALIDATE_BOOLEAN
2545
+		);
2546
+	}
2547
+
2548
+
2549
+	/**
2550
+	 * Gets the options to make availalbe for the gateway log lifespan
2551
+	 * @return array
2552
+	 */
2553
+	public function gatewayLogLifespanOptions()
2554
+	{
2555
+		return (array) apply_filters(
2556
+			'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2557
+			array(
2558
+				'1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2559
+				'1 day' => esc_html__('1 Day', 'event_espresso'),
2560
+				'7 days' => esc_html__('7 Days', 'event_espresso'),
2561
+				'14 days' => esc_html__('14 Days', 'event_espresso'),
2562
+				'30 days' => esc_html__('30 Days', 'event_espresso')
2563
+			)
2564
+		);
2565
+	}
2566
+
2567
+
2568
+	/**
2569
+	 * @return bool
2570
+	 */
2571
+	public function isConsentCheckboxEnabled()
2572
+	{
2573
+		return $this->consent_checkbox_enabled;
2574
+	}
2575
+
2576
+
2577
+	/**
2578
+	 * @param bool $consent_checkbox_enabled
2579
+	 */
2580
+	public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2581
+	{
2582
+		$this->consent_checkbox_enabled = filter_var(
2583
+			$consent_checkbox_enabled,
2584
+			FILTER_VALIDATE_BOOLEAN
2585
+		);
2586
+	}
2587
+
2588
+
2589
+	/**
2590
+	 * @return string
2591
+	 */
2592
+	public function getConsentCheckboxLabelText()
2593
+	{
2594
+		return $this->consent_checkbox_label_text;
2595
+	}
2596
+
2597
+
2598
+	/**
2599
+	 * @param string $consent_checkbox_label_text
2600
+	 */
2601
+	public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2602
+	{
2603
+		$this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2604
+	}
2605 2605
 }
2606 2606
 
2607 2607
 /**
@@ -2609,180 +2609,180 @@  discard block
 block discarded – undo
2609 2609
  */
2610 2610
 class EE_Admin_Config extends EE_Config_Base
2611 2611
 {
2612
-    /**
2613
-     * @var boolean $useAdvancedEditor
2614
-     */
2615
-    private $useAdvancedEditor;
2616
-
2617
-    /**
2618
-     * @var boolean $use_personnel_manager
2619
-     */
2620
-    public $use_personnel_manager;
2621
-
2622
-    /**
2623
-     * @var boolean $use_dashboard_widget
2624
-     */
2625
-    public $use_dashboard_widget;
2626
-
2627
-    /**
2628
-     * @var int $events_in_dashboard
2629
-     */
2630
-    public $events_in_dashboard;
2631
-
2632
-    /**
2633
-     * @var boolean $use_event_timezones
2634
-     */
2635
-    public $use_event_timezones;
2636
-
2637
-    /**
2638
-     * @var string $log_file_name
2639
-     */
2640
-    public $log_file_name;
2641
-
2642
-    /**
2643
-     * @var string $debug_file_name
2644
-     */
2645
-    public $debug_file_name;
2646
-
2647
-    /**
2648
-     * @var boolean $use_remote_logging
2649
-     */
2650
-    public $use_remote_logging;
2651
-
2652
-    /**
2653
-     * @var string $remote_logging_url
2654
-     */
2655
-    public $remote_logging_url;
2656
-
2657
-    /**
2658
-     * @var boolean $show_reg_footer
2659
-     */
2660
-    public $show_reg_footer;
2661
-
2662
-    /**
2663
-     * @var string $affiliate_id
2664
-     */
2665
-    public $affiliate_id;
2666
-
2667
-    /**
2668
-     * adds extra layer of encoding to session data to prevent serialization errors
2669
-     * but is incompatible with some server configuration errors
2670
-     * if you get "500 internal server errors" during registration, try turning this on
2671
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2672
-     *
2673
-     * @var boolean $encode_session_data
2674
-     */
2675
-    private $encode_session_data = false;
2676
-
2677
-    /**
2678
-     * @var boolean
2679
-     */
2680
-    private $is_caffeinated;
2681
-
2682
-
2683
-    /**
2684
-     *    class constructor
2685
-     *
2686
-     * @access    public
2687
-     */
2688
-    public function __construct()
2689
-    {
2690
-        // set default general admin settings
2691
-        $this->useAdvancedEditor = true;
2692
-        $this->use_personnel_manager = true;
2693
-        $this->use_dashboard_widget = true;
2694
-        $this->events_in_dashboard = 30;
2695
-        $this->use_event_timezones = false;
2696
-        $this->use_remote_logging = false;
2697
-        $this->remote_logging_url = null;
2698
-        $this->show_reg_footer = apply_filters(
2699
-            'FHEE__EE_Admin_Config__show_reg_footer__default',
2700
-            false
2701
-        );
2702
-        $this->affiliate_id = 'default';
2703
-        $this->encode_session_data = false;
2704
-    }
2705
-
2706
-
2707
-    /**
2708
-     * @param bool $reset
2709
-     * @return string
2710
-     */
2711
-    public function log_file_name($reset = false)
2712
-    {
2713
-        if (empty($this->log_file_name) || $reset) {
2714
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2715
-            EE_Config::instance()->update_espresso_config(false, false);
2716
-        }
2717
-        return $this->log_file_name;
2718
-    }
2719
-
2720
-
2721
-    /**
2722
-     * @param bool $reset
2723
-     * @return string
2724
-     */
2725
-    public function debug_file_name($reset = false)
2726
-    {
2727
-        if (empty($this->debug_file_name) || $reset) {
2728
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2729
-            EE_Config::instance()->update_espresso_config(false, false);
2730
-        }
2731
-        return $this->debug_file_name;
2732
-    }
2733
-
2734
-
2735
-    /**
2736
-     * @return string
2737
-     */
2738
-    public function affiliate_id()
2739
-    {
2740
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2741
-    }
2742
-
2743
-
2744
-    /**
2745
-     * @return boolean
2746
-     */
2747
-    public function encode_session_data()
2748
-    {
2749
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2750
-    }
2751
-
2752
-
2753
-    /**
2754
-     * @param boolean $encode_session_data
2755
-     */
2756
-    public function set_encode_session_data($encode_session_data)
2757
-    {
2758
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2759
-    }
2760
-
2761
-    /**
2762
-     * @return boolean
2763
-     */
2764
-    public function useAdvancedEditor()
2765
-    {
2766
-        if ($this->is_caffeinated === null) {
2767
-            $domain = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\Domain');
2768
-            $this->is_caffeinated = $domain->isCaffeinated();
2769
-        }
2770
-        return $this->useAdvancedEditor && $this->is_caffeinated;
2771
-    }
2772
-
2773
-    /**
2774
-     * @param boolean $use_advanced_editor
2775
-     */
2776
-    public function setUseAdvancedEditor($use_advanced_editor = true)
2777
-    {
2778
-        $this->useAdvancedEditor = filter_var(
2779
-            apply_filters(
2780
-                'FHEE__EE_Admin_Config__setUseAdvancedEditor__use_advanced_editor',
2781
-                $use_advanced_editor
2782
-            ),
2783
-            FILTER_VALIDATE_BOOLEAN
2784
-        );
2785
-    }
2612
+	/**
2613
+	 * @var boolean $useAdvancedEditor
2614
+	 */
2615
+	private $useAdvancedEditor;
2616
+
2617
+	/**
2618
+	 * @var boolean $use_personnel_manager
2619
+	 */
2620
+	public $use_personnel_manager;
2621
+
2622
+	/**
2623
+	 * @var boolean $use_dashboard_widget
2624
+	 */
2625
+	public $use_dashboard_widget;
2626
+
2627
+	/**
2628
+	 * @var int $events_in_dashboard
2629
+	 */
2630
+	public $events_in_dashboard;
2631
+
2632
+	/**
2633
+	 * @var boolean $use_event_timezones
2634
+	 */
2635
+	public $use_event_timezones;
2636
+
2637
+	/**
2638
+	 * @var string $log_file_name
2639
+	 */
2640
+	public $log_file_name;
2641
+
2642
+	/**
2643
+	 * @var string $debug_file_name
2644
+	 */
2645
+	public $debug_file_name;
2646
+
2647
+	/**
2648
+	 * @var boolean $use_remote_logging
2649
+	 */
2650
+	public $use_remote_logging;
2651
+
2652
+	/**
2653
+	 * @var string $remote_logging_url
2654
+	 */
2655
+	public $remote_logging_url;
2656
+
2657
+	/**
2658
+	 * @var boolean $show_reg_footer
2659
+	 */
2660
+	public $show_reg_footer;
2661
+
2662
+	/**
2663
+	 * @var string $affiliate_id
2664
+	 */
2665
+	public $affiliate_id;
2666
+
2667
+	/**
2668
+	 * adds extra layer of encoding to session data to prevent serialization errors
2669
+	 * but is incompatible with some server configuration errors
2670
+	 * if you get "500 internal server errors" during registration, try turning this on
2671
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2672
+	 *
2673
+	 * @var boolean $encode_session_data
2674
+	 */
2675
+	private $encode_session_data = false;
2676
+
2677
+	/**
2678
+	 * @var boolean
2679
+	 */
2680
+	private $is_caffeinated;
2681
+
2682
+
2683
+	/**
2684
+	 *    class constructor
2685
+	 *
2686
+	 * @access    public
2687
+	 */
2688
+	public function __construct()
2689
+	{
2690
+		// set default general admin settings
2691
+		$this->useAdvancedEditor = true;
2692
+		$this->use_personnel_manager = true;
2693
+		$this->use_dashboard_widget = true;
2694
+		$this->events_in_dashboard = 30;
2695
+		$this->use_event_timezones = false;
2696
+		$this->use_remote_logging = false;
2697
+		$this->remote_logging_url = null;
2698
+		$this->show_reg_footer = apply_filters(
2699
+			'FHEE__EE_Admin_Config__show_reg_footer__default',
2700
+			false
2701
+		);
2702
+		$this->affiliate_id = 'default';
2703
+		$this->encode_session_data = false;
2704
+	}
2705
+
2706
+
2707
+	/**
2708
+	 * @param bool $reset
2709
+	 * @return string
2710
+	 */
2711
+	public function log_file_name($reset = false)
2712
+	{
2713
+		if (empty($this->log_file_name) || $reset) {
2714
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2715
+			EE_Config::instance()->update_espresso_config(false, false);
2716
+		}
2717
+		return $this->log_file_name;
2718
+	}
2719
+
2720
+
2721
+	/**
2722
+	 * @param bool $reset
2723
+	 * @return string
2724
+	 */
2725
+	public function debug_file_name($reset = false)
2726
+	{
2727
+		if (empty($this->debug_file_name) || $reset) {
2728
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2729
+			EE_Config::instance()->update_espresso_config(false, false);
2730
+		}
2731
+		return $this->debug_file_name;
2732
+	}
2733
+
2734
+
2735
+	/**
2736
+	 * @return string
2737
+	 */
2738
+	public function affiliate_id()
2739
+	{
2740
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2741
+	}
2742
+
2743
+
2744
+	/**
2745
+	 * @return boolean
2746
+	 */
2747
+	public function encode_session_data()
2748
+	{
2749
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2750
+	}
2751
+
2752
+
2753
+	/**
2754
+	 * @param boolean $encode_session_data
2755
+	 */
2756
+	public function set_encode_session_data($encode_session_data)
2757
+	{
2758
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2759
+	}
2760
+
2761
+	/**
2762
+	 * @return boolean
2763
+	 */
2764
+	public function useAdvancedEditor()
2765
+	{
2766
+		if ($this->is_caffeinated === null) {
2767
+			$domain = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\Domain');
2768
+			$this->is_caffeinated = $domain->isCaffeinated();
2769
+		}
2770
+		return $this->useAdvancedEditor && $this->is_caffeinated;
2771
+	}
2772
+
2773
+	/**
2774
+	 * @param boolean $use_advanced_editor
2775
+	 */
2776
+	public function setUseAdvancedEditor($use_advanced_editor = true)
2777
+	{
2778
+		$this->useAdvancedEditor = filter_var(
2779
+			apply_filters(
2780
+				'FHEE__EE_Admin_Config__setUseAdvancedEditor__use_advanced_editor',
2781
+				$use_advanced_editor
2782
+			),
2783
+			FILTER_VALIDATE_BOOLEAN
2784
+		);
2785
+	}
2786 2786
 }
2787 2787
 
2788 2788
 /**
@@ -2790,70 +2790,70 @@  discard block
 block discarded – undo
2790 2790
  */
2791 2791
 class EE_Template_Config extends EE_Config_Base
2792 2792
 {
2793
-    /**
2794
-     * @var boolean $enable_default_style
2795
-     */
2796
-    public $enable_default_style;
2797
-
2798
-    /**
2799
-     * @var string $custom_style_sheet
2800
-     */
2801
-    public $custom_style_sheet;
2802
-
2803
-    /**
2804
-     * @var boolean $display_address_in_regform
2805
-     */
2806
-    public $display_address_in_regform;
2807
-
2808
-    /**
2809
-     * @var int $display_description_on_multi_reg_page
2810
-     */
2811
-    public $display_description_on_multi_reg_page;
2812
-
2813
-    /**
2814
-     * @var boolean $use_custom_templates
2815
-     */
2816
-    public $use_custom_templates;
2817
-
2818
-    /**
2819
-     * @var string $current_espresso_theme
2820
-     */
2821
-    public $current_espresso_theme;
2822
-
2823
-    /**
2824
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2825
-     */
2826
-    public $EED_Ticket_Selector;
2827
-
2828
-    /**
2829
-     * @var EE_Event_Single_Config $EED_Event_Single
2830
-     */
2831
-    public $EED_Event_Single;
2832
-
2833
-    /**
2834
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2835
-     */
2836
-    public $EED_Events_Archive;
2837
-
2838
-
2839
-    /**
2840
-     *    class constructor
2841
-     *
2842
-     * @access    public
2843
-     */
2844
-    public function __construct()
2845
-    {
2846
-        // set default template settings
2847
-        $this->enable_default_style = true;
2848
-        $this->custom_style_sheet = null;
2849
-        $this->display_address_in_regform = true;
2850
-        $this->display_description_on_multi_reg_page = false;
2851
-        $this->use_custom_templates = false;
2852
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2853
-        $this->EED_Event_Single = null;
2854
-        $this->EED_Events_Archive = null;
2855
-        $this->EED_Ticket_Selector = null;
2856
-    }
2793
+	/**
2794
+	 * @var boolean $enable_default_style
2795
+	 */
2796
+	public $enable_default_style;
2797
+
2798
+	/**
2799
+	 * @var string $custom_style_sheet
2800
+	 */
2801
+	public $custom_style_sheet;
2802
+
2803
+	/**
2804
+	 * @var boolean $display_address_in_regform
2805
+	 */
2806
+	public $display_address_in_regform;
2807
+
2808
+	/**
2809
+	 * @var int $display_description_on_multi_reg_page
2810
+	 */
2811
+	public $display_description_on_multi_reg_page;
2812
+
2813
+	/**
2814
+	 * @var boolean $use_custom_templates
2815
+	 */
2816
+	public $use_custom_templates;
2817
+
2818
+	/**
2819
+	 * @var string $current_espresso_theme
2820
+	 */
2821
+	public $current_espresso_theme;
2822
+
2823
+	/**
2824
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2825
+	 */
2826
+	public $EED_Ticket_Selector;
2827
+
2828
+	/**
2829
+	 * @var EE_Event_Single_Config $EED_Event_Single
2830
+	 */
2831
+	public $EED_Event_Single;
2832
+
2833
+	/**
2834
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2835
+	 */
2836
+	public $EED_Events_Archive;
2837
+
2838
+
2839
+	/**
2840
+	 *    class constructor
2841
+	 *
2842
+	 * @access    public
2843
+	 */
2844
+	public function __construct()
2845
+	{
2846
+		// set default template settings
2847
+		$this->enable_default_style = true;
2848
+		$this->custom_style_sheet = null;
2849
+		$this->display_address_in_regform = true;
2850
+		$this->display_description_on_multi_reg_page = false;
2851
+		$this->use_custom_templates = false;
2852
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2853
+		$this->EED_Event_Single = null;
2854
+		$this->EED_Events_Archive = null;
2855
+		$this->EED_Ticket_Selector = null;
2856
+	}
2857 2857
 }
2858 2858
 
2859 2859
 /**
@@ -2861,114 +2861,114 @@  discard block
 block discarded – undo
2861 2861
  */
2862 2862
 class EE_Map_Config extends EE_Config_Base
2863 2863
 {
2864
-    /**
2865
-     * @var boolean $use_google_maps
2866
-     */
2867
-    public $use_google_maps;
2868
-
2869
-    /**
2870
-     * @var string $api_key
2871
-     */
2872
-    public $google_map_api_key;
2873
-
2874
-    /**
2875
-     * @var int $event_details_map_width
2876
-     */
2877
-    public $event_details_map_width;
2878
-
2879
-    /**
2880
-     * @var int $event_details_map_height
2881
-     */
2882
-    public $event_details_map_height;
2883
-
2884
-    /**
2885
-     * @var int $event_details_map_zoom
2886
-     */
2887
-    public $event_details_map_zoom;
2888
-
2889
-    /**
2890
-     * @var boolean $event_details_display_nav
2891
-     */
2892
-    public $event_details_display_nav;
2893
-
2894
-    /**
2895
-     * @var boolean $event_details_nav_size
2896
-     */
2897
-    public $event_details_nav_size;
2898
-
2899
-    /**
2900
-     * @var string $event_details_control_type
2901
-     */
2902
-    public $event_details_control_type;
2903
-
2904
-    /**
2905
-     * @var string $event_details_map_align
2906
-     */
2907
-    public $event_details_map_align;
2908
-
2909
-    /**
2910
-     * @var int $event_list_map_width
2911
-     */
2912
-    public $event_list_map_width;
2913
-
2914
-    /**
2915
-     * @var int $event_list_map_height
2916
-     */
2917
-    public $event_list_map_height;
2918
-
2919
-    /**
2920
-     * @var int $event_list_map_zoom
2921
-     */
2922
-    public $event_list_map_zoom;
2923
-
2924
-    /**
2925
-     * @var boolean $event_list_display_nav
2926
-     */
2927
-    public $event_list_display_nav;
2928
-
2929
-    /**
2930
-     * @var boolean $event_list_nav_size
2931
-     */
2932
-    public $event_list_nav_size;
2933
-
2934
-    /**
2935
-     * @var string $event_list_control_type
2936
-     */
2937
-    public $event_list_control_type;
2938
-
2939
-    /**
2940
-     * @var string $event_list_map_align
2941
-     */
2942
-    public $event_list_map_align;
2943
-
2944
-
2945
-    /**
2946
-     *    class constructor
2947
-     *
2948
-     * @access    public
2949
-     */
2950
-    public function __construct()
2951
-    {
2952
-        // set default map settings
2953
-        $this->use_google_maps = true;
2954
-        $this->google_map_api_key = '';
2955
-        // for event details pages (reg page)
2956
-        $this->event_details_map_width = 585;            // ee_map_width_single
2957
-        $this->event_details_map_height = 362;            // ee_map_height_single
2958
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2959
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2960
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2961
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2962
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2963
-        // for event list pages
2964
-        $this->event_list_map_width = 300;            // ee_map_width
2965
-        $this->event_list_map_height = 185;        // ee_map_height
2966
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2967
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2968
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2969
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2970
-        $this->event_list_map_align = 'center';            // ee_map_align
2971
-    }
2864
+	/**
2865
+	 * @var boolean $use_google_maps
2866
+	 */
2867
+	public $use_google_maps;
2868
+
2869
+	/**
2870
+	 * @var string $api_key
2871
+	 */
2872
+	public $google_map_api_key;
2873
+
2874
+	/**
2875
+	 * @var int $event_details_map_width
2876
+	 */
2877
+	public $event_details_map_width;
2878
+
2879
+	/**
2880
+	 * @var int $event_details_map_height
2881
+	 */
2882
+	public $event_details_map_height;
2883
+
2884
+	/**
2885
+	 * @var int $event_details_map_zoom
2886
+	 */
2887
+	public $event_details_map_zoom;
2888
+
2889
+	/**
2890
+	 * @var boolean $event_details_display_nav
2891
+	 */
2892
+	public $event_details_display_nav;
2893
+
2894
+	/**
2895
+	 * @var boolean $event_details_nav_size
2896
+	 */
2897
+	public $event_details_nav_size;
2898
+
2899
+	/**
2900
+	 * @var string $event_details_control_type
2901
+	 */
2902
+	public $event_details_control_type;
2903
+
2904
+	/**
2905
+	 * @var string $event_details_map_align
2906
+	 */
2907
+	public $event_details_map_align;
2908
+
2909
+	/**
2910
+	 * @var int $event_list_map_width
2911
+	 */
2912
+	public $event_list_map_width;
2913
+
2914
+	/**
2915
+	 * @var int $event_list_map_height
2916
+	 */
2917
+	public $event_list_map_height;
2918
+
2919
+	/**
2920
+	 * @var int $event_list_map_zoom
2921
+	 */
2922
+	public $event_list_map_zoom;
2923
+
2924
+	/**
2925
+	 * @var boolean $event_list_display_nav
2926
+	 */
2927
+	public $event_list_display_nav;
2928
+
2929
+	/**
2930
+	 * @var boolean $event_list_nav_size
2931
+	 */
2932
+	public $event_list_nav_size;
2933
+
2934
+	/**
2935
+	 * @var string $event_list_control_type
2936
+	 */
2937
+	public $event_list_control_type;
2938
+
2939
+	/**
2940
+	 * @var string $event_list_map_align
2941
+	 */
2942
+	public $event_list_map_align;
2943
+
2944
+
2945
+	/**
2946
+	 *    class constructor
2947
+	 *
2948
+	 * @access    public
2949
+	 */
2950
+	public function __construct()
2951
+	{
2952
+		// set default map settings
2953
+		$this->use_google_maps = true;
2954
+		$this->google_map_api_key = '';
2955
+		// for event details pages (reg page)
2956
+		$this->event_details_map_width = 585;            // ee_map_width_single
2957
+		$this->event_details_map_height = 362;            // ee_map_height_single
2958
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2959
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2960
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2961
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2962
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2963
+		// for event list pages
2964
+		$this->event_list_map_width = 300;            // ee_map_width
2965
+		$this->event_list_map_height = 185;        // ee_map_height
2966
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2967
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2968
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2969
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2970
+		$this->event_list_map_align = 'center';            // ee_map_align
2971
+	}
2972 2972
 }
2973 2973
 
2974 2974
 /**
@@ -2976,46 +2976,46 @@  discard block
 block discarded – undo
2976 2976
  */
2977 2977
 class EE_Events_Archive_Config extends EE_Config_Base
2978 2978
 {
2979
-    public $display_status_banner;
2979
+	public $display_status_banner;
2980 2980
 
2981
-    public $display_description;
2981
+	public $display_description;
2982 2982
 
2983
-    public $display_ticket_selector;
2983
+	public $display_ticket_selector;
2984 2984
 
2985
-    public $display_datetimes;
2985
+	public $display_datetimes;
2986 2986
 
2987
-    public $display_venue;
2987
+	public $display_venue;
2988 2988
 
2989
-    public $display_expired_events;
2989
+	public $display_expired_events;
2990 2990
 
2991
-    public $use_sortable_display_order;
2991
+	public $use_sortable_display_order;
2992 2992
 
2993
-    public $display_order_tickets;
2993
+	public $display_order_tickets;
2994 2994
 
2995
-    public $display_order_datetimes;
2995
+	public $display_order_datetimes;
2996 2996
 
2997
-    public $display_order_event;
2997
+	public $display_order_event;
2998 2998
 
2999
-    public $display_order_venue;
2999
+	public $display_order_venue;
3000 3000
 
3001 3001
 
3002
-    /**
3003
-     *    class constructor
3004
-     */
3005
-    public function __construct()
3006
-    {
3007
-        $this->display_status_banner = 0;
3008
-        $this->display_description = 1;
3009
-        $this->display_ticket_selector = 0;
3010
-        $this->display_datetimes = 1;
3011
-        $this->display_venue = 0;
3012
-        $this->display_expired_events = 0;
3013
-        $this->use_sortable_display_order = false;
3014
-        $this->display_order_tickets = 100;
3015
-        $this->display_order_datetimes = 110;
3016
-        $this->display_order_event = 120;
3017
-        $this->display_order_venue = 130;
3018
-    }
3002
+	/**
3003
+	 *    class constructor
3004
+	 */
3005
+	public function __construct()
3006
+	{
3007
+		$this->display_status_banner = 0;
3008
+		$this->display_description = 1;
3009
+		$this->display_ticket_selector = 0;
3010
+		$this->display_datetimes = 1;
3011
+		$this->display_venue = 0;
3012
+		$this->display_expired_events = 0;
3013
+		$this->use_sortable_display_order = false;
3014
+		$this->display_order_tickets = 100;
3015
+		$this->display_order_datetimes = 110;
3016
+		$this->display_order_event = 120;
3017
+		$this->display_order_venue = 130;
3018
+	}
3019 3019
 }
3020 3020
 
3021 3021
 /**
@@ -3023,34 +3023,34 @@  discard block
 block discarded – undo
3023 3023
  */
3024 3024
 class EE_Event_Single_Config extends EE_Config_Base
3025 3025
 {
3026
-    public $display_status_banner_single;
3026
+	public $display_status_banner_single;
3027 3027
 
3028
-    public $display_venue;
3028
+	public $display_venue;
3029 3029
 
3030
-    public $use_sortable_display_order;
3030
+	public $use_sortable_display_order;
3031 3031
 
3032
-    public $display_order_tickets;
3032
+	public $display_order_tickets;
3033 3033
 
3034
-    public $display_order_datetimes;
3034
+	public $display_order_datetimes;
3035 3035
 
3036
-    public $display_order_event;
3036
+	public $display_order_event;
3037 3037
 
3038
-    public $display_order_venue;
3038
+	public $display_order_venue;
3039 3039
 
3040 3040
 
3041
-    /**
3042
-     *    class constructor
3043
-     */
3044
-    public function __construct()
3045
-    {
3046
-        $this->display_status_banner_single = 0;
3047
-        $this->display_venue = 1;
3048
-        $this->use_sortable_display_order = false;
3049
-        $this->display_order_tickets = 100;
3050
-        $this->display_order_datetimes = 110;
3051
-        $this->display_order_event = 120;
3052
-        $this->display_order_venue = 130;
3053
-    }
3041
+	/**
3042
+	 *    class constructor
3043
+	 */
3044
+	public function __construct()
3045
+	{
3046
+		$this->display_status_banner_single = 0;
3047
+		$this->display_venue = 1;
3048
+		$this->use_sortable_display_order = false;
3049
+		$this->display_order_tickets = 100;
3050
+		$this->display_order_datetimes = 110;
3051
+		$this->display_order_event = 120;
3052
+		$this->display_order_venue = 130;
3053
+	}
3054 3054
 }
3055 3055
 
3056 3056
 /**
@@ -3058,172 +3058,172 @@  discard block
 block discarded – undo
3058 3058
  */
3059 3059
 class EE_Ticket_Selector_Config extends EE_Config_Base
3060 3060
 {
3061
-    /**
3062
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
3063
-     */
3064
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
3065
-
3066
-    /**
3067
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
3068
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
3069
-     */
3070
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
3071
-
3072
-    /**
3073
-     * @var boolean $show_ticket_sale_columns
3074
-     */
3075
-    public $show_ticket_sale_columns;
3076
-
3077
-    /**
3078
-     * @var boolean $show_ticket_details
3079
-     */
3080
-    public $show_ticket_details;
3081
-
3082
-    /**
3083
-     * @var boolean $show_expired_tickets
3084
-     */
3085
-    public $show_expired_tickets;
3086
-
3087
-    /**
3088
-     * whether or not to display a dropdown box populated with event datetimes
3089
-     * that toggles which tickets are displayed for a ticket selector.
3090
-     * uses one of the *_DATETIME_SELECTOR constants defined above
3091
-     *
3092
-     * @var string $show_datetime_selector
3093
-     */
3094
-    private $show_datetime_selector = 'no_datetime_selector';
3095
-
3096
-    /**
3097
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
3098
-     *
3099
-     * @var int $datetime_selector_threshold
3100
-     */
3101
-    private $datetime_selector_threshold = 3;
3102
-
3103
-    /**
3104
-     * determines the maximum number of "checked" dates in the date and time filter
3105
-     *
3106
-     * @var int $datetime_selector_checked
3107
-     */
3108
-    private $datetime_selector_max_checked = 10;
3109
-
3110
-
3111
-    /**
3112
-     *    class constructor
3113
-     */
3114
-    public function __construct()
3115
-    {
3116
-        $this->show_ticket_sale_columns = true;
3117
-        $this->show_ticket_details = true;
3118
-        $this->show_expired_tickets = true;
3119
-        $this->show_datetime_selector = EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3120
-        $this->datetime_selector_threshold = 3;
3121
-        $this->datetime_selector_max_checked = 10;
3122
-    }
3123
-
3124
-
3125
-    /**
3126
-     * returns true if a datetime selector should be displayed
3127
-     *
3128
-     * @param array $datetimes
3129
-     * @return bool
3130
-     */
3131
-    public function showDatetimeSelector(array $datetimes)
3132
-    {
3133
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3134
-        return ! (
3135
-            $this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3136
-            || (
3137
-                $this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3138
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3139
-            )
3140
-        );
3141
-    }
3142
-
3143
-
3144
-    /**
3145
-     * @return string
3146
-     */
3147
-    public function getShowDatetimeSelector()
3148
-    {
3149
-        return $this->show_datetime_selector;
3150
-    }
3151
-
3152
-
3153
-    /**
3154
-     * @param bool $keys_only
3155
-     * @return array
3156
-     */
3157
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3158
-    {
3159
-        return $keys_only
3160
-            ? array(
3161
-                EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3162
-                EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3163
-            )
3164
-            : array(
3165
-                EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3166
-                    'Do not show date & time filter',
3167
-                    'event_espresso'
3168
-                ),
3169
-                EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3170
-                    'Maybe show date & time filter',
3171
-                    'event_espresso'
3172
-                ),
3173
-            );
3174
-    }
3175
-
3176
-
3177
-    /**
3178
-     * @param string $show_datetime_selector
3179
-     */
3180
-    public function setShowDatetimeSelector($show_datetime_selector)
3181
-    {
3182
-        $this->show_datetime_selector = in_array(
3183
-            $show_datetime_selector,
3184
-            $this->getShowDatetimeSelectorOptions(),
3185
-            true
3186
-        )
3187
-            ? $show_datetime_selector
3188
-            : EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3189
-    }
3190
-
3191
-
3192
-    /**
3193
-     * @return int
3194
-     */
3195
-    public function getDatetimeSelectorThreshold()
3196
-    {
3197
-        return $this->datetime_selector_threshold;
3198
-    }
3199
-
3200
-
3201
-    /**
3202
-     * @param int $datetime_selector_threshold
3203
-     */
3204
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3205
-    {
3206
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3207
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3208
-    }
3209
-
3210
-
3211
-    /**
3212
-     * @return int
3213
-     */
3214
-    public function getDatetimeSelectorMaxChecked()
3215
-    {
3216
-        return $this->datetime_selector_max_checked;
3217
-    }
3218
-
3219
-
3220
-    /**
3221
-     * @param int $datetime_selector_max_checked
3222
-     */
3223
-    public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3224
-    {
3225
-        $this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3226
-    }
3061
+	/**
3062
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
3063
+	 */
3064
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
3065
+
3066
+	/**
3067
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
3068
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
3069
+	 */
3070
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
3071
+
3072
+	/**
3073
+	 * @var boolean $show_ticket_sale_columns
3074
+	 */
3075
+	public $show_ticket_sale_columns;
3076
+
3077
+	/**
3078
+	 * @var boolean $show_ticket_details
3079
+	 */
3080
+	public $show_ticket_details;
3081
+
3082
+	/**
3083
+	 * @var boolean $show_expired_tickets
3084
+	 */
3085
+	public $show_expired_tickets;
3086
+
3087
+	/**
3088
+	 * whether or not to display a dropdown box populated with event datetimes
3089
+	 * that toggles which tickets are displayed for a ticket selector.
3090
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
3091
+	 *
3092
+	 * @var string $show_datetime_selector
3093
+	 */
3094
+	private $show_datetime_selector = 'no_datetime_selector';
3095
+
3096
+	/**
3097
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
3098
+	 *
3099
+	 * @var int $datetime_selector_threshold
3100
+	 */
3101
+	private $datetime_selector_threshold = 3;
3102
+
3103
+	/**
3104
+	 * determines the maximum number of "checked" dates in the date and time filter
3105
+	 *
3106
+	 * @var int $datetime_selector_checked
3107
+	 */
3108
+	private $datetime_selector_max_checked = 10;
3109
+
3110
+
3111
+	/**
3112
+	 *    class constructor
3113
+	 */
3114
+	public function __construct()
3115
+	{
3116
+		$this->show_ticket_sale_columns = true;
3117
+		$this->show_ticket_details = true;
3118
+		$this->show_expired_tickets = true;
3119
+		$this->show_datetime_selector = EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3120
+		$this->datetime_selector_threshold = 3;
3121
+		$this->datetime_selector_max_checked = 10;
3122
+	}
3123
+
3124
+
3125
+	/**
3126
+	 * returns true if a datetime selector should be displayed
3127
+	 *
3128
+	 * @param array $datetimes
3129
+	 * @return bool
3130
+	 */
3131
+	public function showDatetimeSelector(array $datetimes)
3132
+	{
3133
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3134
+		return ! (
3135
+			$this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3136
+			|| (
3137
+				$this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3138
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3139
+			)
3140
+		);
3141
+	}
3142
+
3143
+
3144
+	/**
3145
+	 * @return string
3146
+	 */
3147
+	public function getShowDatetimeSelector()
3148
+	{
3149
+		return $this->show_datetime_selector;
3150
+	}
3151
+
3152
+
3153
+	/**
3154
+	 * @param bool $keys_only
3155
+	 * @return array
3156
+	 */
3157
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3158
+	{
3159
+		return $keys_only
3160
+			? array(
3161
+				EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3162
+				EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3163
+			)
3164
+			: array(
3165
+				EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3166
+					'Do not show date & time filter',
3167
+					'event_espresso'
3168
+				),
3169
+				EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3170
+					'Maybe show date & time filter',
3171
+					'event_espresso'
3172
+				),
3173
+			);
3174
+	}
3175
+
3176
+
3177
+	/**
3178
+	 * @param string $show_datetime_selector
3179
+	 */
3180
+	public function setShowDatetimeSelector($show_datetime_selector)
3181
+	{
3182
+		$this->show_datetime_selector = in_array(
3183
+			$show_datetime_selector,
3184
+			$this->getShowDatetimeSelectorOptions(),
3185
+			true
3186
+		)
3187
+			? $show_datetime_selector
3188
+			: EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3189
+	}
3190
+
3191
+
3192
+	/**
3193
+	 * @return int
3194
+	 */
3195
+	public function getDatetimeSelectorThreshold()
3196
+	{
3197
+		return $this->datetime_selector_threshold;
3198
+	}
3199
+
3200
+
3201
+	/**
3202
+	 * @param int $datetime_selector_threshold
3203
+	 */
3204
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3205
+	{
3206
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3207
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3208
+	}
3209
+
3210
+
3211
+	/**
3212
+	 * @return int
3213
+	 */
3214
+	public function getDatetimeSelectorMaxChecked()
3215
+	{
3216
+		return $this->datetime_selector_max_checked;
3217
+	}
3218
+
3219
+
3220
+	/**
3221
+	 * @param int $datetime_selector_max_checked
3222
+	 */
3223
+	public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3224
+	{
3225
+		$this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3226
+	}
3227 3227
 }
3228 3228
 
3229 3229
 /**
@@ -3235,87 +3235,87 @@  discard block
 block discarded – undo
3235 3235
  */
3236 3236
 class EE_Environment_Config extends EE_Config_Base
3237 3237
 {
3238
-    /**
3239
-     * Hold any php environment variables that we want to track.
3240
-     *
3241
-     * @var stdClass;
3242
-     */
3243
-    public $php;
3244
-
3245
-
3246
-    /**
3247
-     *    constructor
3248
-     */
3249
-    public function __construct()
3250
-    {
3251
-        $this->php = new stdClass();
3252
-        $this->_set_php_values();
3253
-    }
3254
-
3255
-
3256
-    /**
3257
-     * This sets the php environment variables.
3258
-     *
3259
-     * @since 4.4.0
3260
-     * @return void
3261
-     */
3262
-    protected function _set_php_values()
3263
-    {
3264
-        $this->php->max_input_vars = ini_get('max_input_vars');
3265
-        $this->php->version = phpversion();
3266
-    }
3267
-
3268
-
3269
-    /**
3270
-     * helper method for determining whether input_count is
3271
-     * reaching the potential maximum the server can handle
3272
-     * according to max_input_vars
3273
-     *
3274
-     * @param int   $input_count the count of input vars.
3275
-     * @return array {
3276
-     *                           An array that represents whether available space and if no available space the error
3277
-     *                           message.
3278
-     * @type bool   $has_space   whether more inputs can be added.
3279
-     * @type string $msg         Any message to be displayed.
3280
-     *                           }
3281
-     */
3282
-    public function max_input_vars_limit_check($input_count = 0)
3283
-    {
3284
-        if (
3285
-            ! empty($this->php->max_input_vars)
3286
-            && ($input_count >= $this->php->max_input_vars)
3287
-        ) {
3288
-            // check the server setting because the config value could be stale
3289
-            $max_input_vars = ini_get('max_input_vars');
3290
-            if ($input_count >= $max_input_vars) {
3291
-                return sprintf(
3292
-                    esc_html__(
3293
-                        '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.',
3294
-                        'event_espresso'
3295
-                    ),
3296
-                    '<br>',
3297
-                    $input_count,
3298
-                    $max_input_vars
3299
-                );
3300
-            } else {
3301
-                return '';
3302
-            }
3303
-        } else {
3304
-            return '';
3305
-        }
3306
-    }
3307
-
3308
-
3309
-    /**
3310
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3311
-     *
3312
-     * @since 4.4.1
3313
-     * @return void
3314
-     */
3315
-    public function recheck_values()
3316
-    {
3317
-        $this->_set_php_values();
3318
-    }
3238
+	/**
3239
+	 * Hold any php environment variables that we want to track.
3240
+	 *
3241
+	 * @var stdClass;
3242
+	 */
3243
+	public $php;
3244
+
3245
+
3246
+	/**
3247
+	 *    constructor
3248
+	 */
3249
+	public function __construct()
3250
+	{
3251
+		$this->php = new stdClass();
3252
+		$this->_set_php_values();
3253
+	}
3254
+
3255
+
3256
+	/**
3257
+	 * This sets the php environment variables.
3258
+	 *
3259
+	 * @since 4.4.0
3260
+	 * @return void
3261
+	 */
3262
+	protected function _set_php_values()
3263
+	{
3264
+		$this->php->max_input_vars = ini_get('max_input_vars');
3265
+		$this->php->version = phpversion();
3266
+	}
3267
+
3268
+
3269
+	/**
3270
+	 * helper method for determining whether input_count is
3271
+	 * reaching the potential maximum the server can handle
3272
+	 * according to max_input_vars
3273
+	 *
3274
+	 * @param int   $input_count the count of input vars.
3275
+	 * @return array {
3276
+	 *                           An array that represents whether available space and if no available space the error
3277
+	 *                           message.
3278
+	 * @type bool   $has_space   whether more inputs can be added.
3279
+	 * @type string $msg         Any message to be displayed.
3280
+	 *                           }
3281
+	 */
3282
+	public function max_input_vars_limit_check($input_count = 0)
3283
+	{
3284
+		if (
3285
+			! empty($this->php->max_input_vars)
3286
+			&& ($input_count >= $this->php->max_input_vars)
3287
+		) {
3288
+			// check the server setting because the config value could be stale
3289
+			$max_input_vars = ini_get('max_input_vars');
3290
+			if ($input_count >= $max_input_vars) {
3291
+				return sprintf(
3292
+					esc_html__(
3293
+						'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.',
3294
+						'event_espresso'
3295
+					),
3296
+					'<br>',
3297
+					$input_count,
3298
+					$max_input_vars
3299
+				);
3300
+			} else {
3301
+				return '';
3302
+			}
3303
+		} else {
3304
+			return '';
3305
+		}
3306
+	}
3307
+
3308
+
3309
+	/**
3310
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3311
+	 *
3312
+	 * @since 4.4.1
3313
+	 * @return void
3314
+	 */
3315
+	public function recheck_values()
3316
+	{
3317
+		$this->_set_php_values();
3318
+	}
3319 3319
 }
3320 3320
 
3321 3321
 /**
@@ -3327,21 +3327,21 @@  discard block
 block discarded – undo
3327 3327
  */
3328 3328
 class EE_Tax_Config extends EE_Config_Base
3329 3329
 {
3330
-    /*
3330
+	/*
3331 3331
      * flag to indicate whether or not to display ticket prices with the taxes included
3332 3332
      *
3333 3333
      * @var boolean $prices_displayed_including_taxes
3334 3334
      */
3335
-    public $prices_displayed_including_taxes;
3335
+	public $prices_displayed_including_taxes;
3336 3336
 
3337 3337
 
3338
-    /**
3339
-     *    class constructor
3340
-     */
3341
-    public function __construct()
3342
-    {
3343
-        $this->prices_displayed_including_taxes = true;
3344
-    }
3338
+	/**
3339
+	 *    class constructor
3340
+	 */
3341
+	public function __construct()
3342
+	{
3343
+		$this->prices_displayed_including_taxes = true;
3344
+	}
3345 3345
 }
3346 3346
 
3347 3347
 /**
@@ -3354,19 +3354,19 @@  discard block
 block discarded – undo
3354 3354
  */
3355 3355
 class EE_Messages_Config extends EE_Config_Base
3356 3356
 {
3357
-    /**
3358
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3359
-     * A value of 0 represents never deleting.  Default is 0.
3360
-     *
3361
-     * @var integer
3362
-     */
3363
-    public $delete_threshold;
3364
-
3365
-
3366
-    public function __construct()
3367
-    {
3368
-        $this->delete_threshold = 0;
3369
-    }
3357
+	/**
3358
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3359
+	 * A value of 0 represents never deleting.  Default is 0.
3360
+	 *
3361
+	 * @var integer
3362
+	 */
3363
+	public $delete_threshold;
3364
+
3365
+
3366
+	public function __construct()
3367
+	{
3368
+		$this->delete_threshold = 0;
3369
+	}
3370 3370
 }
3371 3371
 
3372 3372
 /**
@@ -3376,31 +3376,31 @@  discard block
 block discarded – undo
3376 3376
  */
3377 3377
 class EE_Gateway_Config extends EE_Config_Base
3378 3378
 {
3379
-    /**
3380
-     * Array with keys that are payment gateways slugs, and values are arrays
3381
-     * with any config info the gateway wants to store
3382
-     *
3383
-     * @var array
3384
-     */
3385
-    public $payment_settings;
3386
-
3387
-    /**
3388
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3389
-     * the gateway is stored in the uploads directory
3390
-     *
3391
-     * @var array
3392
-     */
3393
-    public $active_gateways;
3394
-
3395
-
3396
-    /**
3397
-     *    class constructor
3398
-     *
3399
-     * @deprecated
3400
-     */
3401
-    public function __construct()
3402
-    {
3403
-        $this->payment_settings = array();
3404
-        $this->active_gateways = array('Invoice' => false);
3405
-    }
3379
+	/**
3380
+	 * Array with keys that are payment gateways slugs, and values are arrays
3381
+	 * with any config info the gateway wants to store
3382
+	 *
3383
+	 * @var array
3384
+	 */
3385
+	public $payment_settings;
3386
+
3387
+	/**
3388
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3389
+	 * the gateway is stored in the uploads directory
3390
+	 *
3391
+	 * @var array
3392
+	 */
3393
+	public $active_gateways;
3394
+
3395
+
3396
+	/**
3397
+	 *    class constructor
3398
+	 *
3399
+	 * @deprecated
3400
+	 */
3401
+	public function __construct()
3402
+	{
3403
+		$this->payment_settings = array();
3404
+		$this->active_gateways = array('Invoice' => false);
3405
+	}
3406 3406
 }
Please login to merge, or discard this patch.
caffeinated/admin/new/tickets/Tickets_Admin_Page_Init.core.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -14,49 +14,49 @@
 block discarded – undo
14 14
  */
15 15
 class Tickets_Admin_Page_Init extends EE_Admin_Page_Init
16 16
 {
17
-    /**
18
-     *        constructor
19
-     *
20
-     * @Constructor
21
-     * @access public
22
-     * @return void
23
-     */
24
-    public function __construct()
25
-    {
26
-        if (! defined('TICKETS_PG_SLUG')) {
27
-            define('TICKETS_PG_SLUG', 'tickets');
28
-            define('TICKETS_LABEL', esc_html__('Default Tickets', 'event_espresso'));
29
-            define('TICKETS_ADMIN', EE_CORE_CAF_ADMIN . 'new/' . TICKETS_PG_SLUG . '/');
30
-            define('TICKETS_ADMIN_URL', admin_url('admin.php?page=' . TICKETS_PG_SLUG));
31
-            define('TICKETS_ASSETS_PATH', TICKETS_ADMIN . 'assets/');
32
-            define('TICKETS_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . TICKETS_PG_SLUG . '/assets/');
33
-            define('TICKETS_TEMPLATE_PATH', TICKETS_ADMIN . 'templates/');
34
-            define('TICKETS_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . TICKETS_PG_SLUG . '/templates/');
35
-        }
36
-        parent::__construct();
37
-        $this->_folder_path = EE_CORE_CAF_ADMIN . 'new/' . $this->_folder_name . DS;
38
-    }
17
+	/**
18
+	 *        constructor
19
+	 *
20
+	 * @Constructor
21
+	 * @access public
22
+	 * @return void
23
+	 */
24
+	public function __construct()
25
+	{
26
+		if (! defined('TICKETS_PG_SLUG')) {
27
+			define('TICKETS_PG_SLUG', 'tickets');
28
+			define('TICKETS_LABEL', esc_html__('Default Tickets', 'event_espresso'));
29
+			define('TICKETS_ADMIN', EE_CORE_CAF_ADMIN . 'new/' . TICKETS_PG_SLUG . '/');
30
+			define('TICKETS_ADMIN_URL', admin_url('admin.php?page=' . TICKETS_PG_SLUG));
31
+			define('TICKETS_ASSETS_PATH', TICKETS_ADMIN . 'assets/');
32
+			define('TICKETS_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . TICKETS_PG_SLUG . '/assets/');
33
+			define('TICKETS_TEMPLATE_PATH', TICKETS_ADMIN . 'templates/');
34
+			define('TICKETS_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . TICKETS_PG_SLUG . '/templates/');
35
+		}
36
+		parent::__construct();
37
+		$this->_folder_path = EE_CORE_CAF_ADMIN . 'new/' . $this->_folder_name . DS;
38
+	}
39 39
 
40 40
 
41
-    protected function _set_init_properties()
42
-    {
43
-        $this->label = TICKETS_LABEL;
44
-    }
41
+	protected function _set_init_properties()
42
+	{
43
+		$this->label = TICKETS_LABEL;
44
+	}
45 45
 
46 46
 
47
-    protected function _set_menu_map()
48
-    {
49
-        $this->_menu_map = new AdminMenuSubItem(
50
-            array(
51
-                'menu_group'      => 'management',
52
-                'menu_order'      => 15,
53
-                'show_on_menu'    => AdminMenuItem::DISPLAY_BLOG_ONLY,
54
-                'parent_slug'     => 'espresso_events',
55
-                'menu_slug'       => TICKETS_PG_SLUG,
56
-                'menu_label'      => TICKETS_LABEL,
57
-                'capability'      => 'ee_read_default_tickets',
58
-                'admin_init_page' => $this,
59
-            )
60
-        );
61
-    }
47
+	protected function _set_menu_map()
48
+	{
49
+		$this->_menu_map = new AdminMenuSubItem(
50
+			array(
51
+				'menu_group'      => 'management',
52
+				'menu_order'      => 15,
53
+				'show_on_menu'    => AdminMenuItem::DISPLAY_BLOG_ONLY,
54
+				'parent_slug'     => 'espresso_events',
55
+				'menu_slug'       => TICKETS_PG_SLUG,
56
+				'menu_label'      => TICKETS_LABEL,
57
+				'capability'      => 'ee_read_default_tickets',
58
+				'admin_init_page' => $this,
59
+			)
60
+		);
61
+	}
62 62
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,18 +23,18 @@
 block discarded – undo
23 23
      */
24 24
     public function __construct()
25 25
     {
26
-        if (! defined('TICKETS_PG_SLUG')) {
26
+        if ( ! defined('TICKETS_PG_SLUG')) {
27 27
             define('TICKETS_PG_SLUG', 'tickets');
28 28
             define('TICKETS_LABEL', esc_html__('Default Tickets', 'event_espresso'));
29
-            define('TICKETS_ADMIN', EE_CORE_CAF_ADMIN . 'new/' . TICKETS_PG_SLUG . '/');
30
-            define('TICKETS_ADMIN_URL', admin_url('admin.php?page=' . TICKETS_PG_SLUG));
31
-            define('TICKETS_ASSETS_PATH', TICKETS_ADMIN . 'assets/');
32
-            define('TICKETS_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . TICKETS_PG_SLUG . '/assets/');
33
-            define('TICKETS_TEMPLATE_PATH', TICKETS_ADMIN . 'templates/');
34
-            define('TICKETS_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . TICKETS_PG_SLUG . '/templates/');
29
+            define('TICKETS_ADMIN', EE_CORE_CAF_ADMIN.'new/'.TICKETS_PG_SLUG.'/');
30
+            define('TICKETS_ADMIN_URL', admin_url('admin.php?page='.TICKETS_PG_SLUG));
31
+            define('TICKETS_ASSETS_PATH', TICKETS_ADMIN.'assets/');
32
+            define('TICKETS_ASSETS_URL', EE_CORE_CAF_ADMIN_URL.'new/'.TICKETS_PG_SLUG.'/assets/');
33
+            define('TICKETS_TEMPLATE_PATH', TICKETS_ADMIN.'templates/');
34
+            define('TICKETS_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL.'new/'.TICKETS_PG_SLUG.'/templates/');
35 35
         }
36 36
         parent::__construct();
37
-        $this->_folder_path = EE_CORE_CAF_ADMIN . 'new/' . $this->_folder_name . DS;
37
+        $this->_folder_path = EE_CORE_CAF_ADMIN.'new/'.$this->_folder_name.DS;
38 38
     }
39 39
 
40 40
 
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/Pricing_Admin_Page_Init.core.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -16,51 +16,51 @@
 block discarded – undo
16 16
  */
17 17
 class Pricing_Admin_Page_Init extends EE_Admin_Page_Init
18 18
 {
19
-    /**
20
-     * @Constructor
21
-     */
22
-    public function __construct()
23
-    {
24
-        if (! defined('PRICING_PG_SLUG')) {
25
-            define('PRICING_PG_SLUG', 'pricing');
26
-            define('PRICING_LABEL', esc_html__('Pricing', 'event_espresso'));
27
-            define('PRICING_PG_NAME', ucwords(str_replace('_', '', PRICING_PG_SLUG)));
28
-            define('PRICING_ADMIN', EE_CORE_CAF_ADMIN . 'new/' . PRICING_PG_SLUG . '/');
29
-            define('PRICING_ADMIN_URL', admin_url('admin.php?page=' . PRICING_PG_SLUG));
30
-            define('PRICING_ASSETS_PATH', PRICING_ADMIN . 'assets/');
31
-            define('PRICING_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/assets/');
32
-            define('PRICING_TEMPLATE_PATH', PRICING_ADMIN . 'templates/');
33
-            define('PRICING_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/templates/');
34
-        }
35
-        parent::__construct();
36
-        $this->_folder_path = EE_CORE_CAF_ADMIN . 'new/' . $this->_folder_name . '/';
37
-    }
19
+	/**
20
+	 * @Constructor
21
+	 */
22
+	public function __construct()
23
+	{
24
+		if (! defined('PRICING_PG_SLUG')) {
25
+			define('PRICING_PG_SLUG', 'pricing');
26
+			define('PRICING_LABEL', esc_html__('Pricing', 'event_espresso'));
27
+			define('PRICING_PG_NAME', ucwords(str_replace('_', '', PRICING_PG_SLUG)));
28
+			define('PRICING_ADMIN', EE_CORE_CAF_ADMIN . 'new/' . PRICING_PG_SLUG . '/');
29
+			define('PRICING_ADMIN_URL', admin_url('admin.php?page=' . PRICING_PG_SLUG));
30
+			define('PRICING_ASSETS_PATH', PRICING_ADMIN . 'assets/');
31
+			define('PRICING_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/assets/');
32
+			define('PRICING_TEMPLATE_PATH', PRICING_ADMIN . 'templates/');
33
+			define('PRICING_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/templates/');
34
+		}
35
+		parent::__construct();
36
+		$this->_folder_path = EE_CORE_CAF_ADMIN . 'new/' . $this->_folder_name . '/';
37
+	}
38 38
 
39 39
 
40
-    protected function _set_init_properties()
41
-    {
42
-        $this->label = PRICING_LABEL;
43
-    }
40
+	protected function _set_init_properties()
41
+	{
42
+		$this->label = PRICING_LABEL;
43
+	}
44 44
 
45 45
 
46
-    /**
47
-     * @return array|void
48
-     * @throws EE_Error
49
-     * @since $VID:$
50
-     */
51
-    protected function _set_menu_map()
52
-    {
53
-        $this->_menu_map = new AdminMenuSubItem(
54
-            array(
55
-                'menu_group'      => 'management',
56
-                'menu_order'      => 20,
57
-                'show_on_menu'    => AdminMenuItem::DISPLAY_BLOG_ONLY,
58
-                'parent_slug'     => 'espresso_events',
59
-                'menu_slug'       => PRICING_PG_SLUG,
60
-                'menu_label'      => PRICING_LABEL,
61
-                'capability'      => 'ee_read_default_prices',
62
-                'admin_init_page' => $this,
63
-            )
64
-        );
65
-    }
46
+	/**
47
+	 * @return array|void
48
+	 * @throws EE_Error
49
+	 * @since $VID:$
50
+	 */
51
+	protected function _set_menu_map()
52
+	{
53
+		$this->_menu_map = new AdminMenuSubItem(
54
+			array(
55
+				'menu_group'      => 'management',
56
+				'menu_order'      => 20,
57
+				'show_on_menu'    => AdminMenuItem::DISPLAY_BLOG_ONLY,
58
+				'parent_slug'     => 'espresso_events',
59
+				'menu_slug'       => PRICING_PG_SLUG,
60
+				'menu_label'      => PRICING_LABEL,
61
+				'capability'      => 'ee_read_default_prices',
62
+				'admin_init_page' => $this,
63
+			)
64
+		);
65
+	}
66 66
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,19 +21,19 @@
 block discarded – undo
21 21
      */
22 22
     public function __construct()
23 23
     {
24
-        if (! defined('PRICING_PG_SLUG')) {
24
+        if ( ! defined('PRICING_PG_SLUG')) {
25 25
             define('PRICING_PG_SLUG', 'pricing');
26 26
             define('PRICING_LABEL', esc_html__('Pricing', 'event_espresso'));
27 27
             define('PRICING_PG_NAME', ucwords(str_replace('_', '', PRICING_PG_SLUG)));
28
-            define('PRICING_ADMIN', EE_CORE_CAF_ADMIN . 'new/' . PRICING_PG_SLUG . '/');
29
-            define('PRICING_ADMIN_URL', admin_url('admin.php?page=' . PRICING_PG_SLUG));
30
-            define('PRICING_ASSETS_PATH', PRICING_ADMIN . 'assets/');
31
-            define('PRICING_ASSETS_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/assets/');
32
-            define('PRICING_TEMPLATE_PATH', PRICING_ADMIN . 'templates/');
33
-            define('PRICING_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL . 'new/' . PRICING_PG_SLUG . '/templates/');
28
+            define('PRICING_ADMIN', EE_CORE_CAF_ADMIN.'new/'.PRICING_PG_SLUG.'/');
29
+            define('PRICING_ADMIN_URL', admin_url('admin.php?page='.PRICING_PG_SLUG));
30
+            define('PRICING_ASSETS_PATH', PRICING_ADMIN.'assets/');
31
+            define('PRICING_ASSETS_URL', EE_CORE_CAF_ADMIN_URL.'new/'.PRICING_PG_SLUG.'/assets/');
32
+            define('PRICING_TEMPLATE_PATH', PRICING_ADMIN.'templates/');
33
+            define('PRICING_TEMPLATE_URL', EE_CORE_CAF_ADMIN_URL.'new/'.PRICING_PG_SLUG.'/templates/');
34 34
         }
35 35
         parent::__construct();
36
-        $this->_folder_path = EE_CORE_CAF_ADMIN . 'new/' . $this->_folder_name . '/';
36
+        $this->_folder_path = EE_CORE_CAF_ADMIN.'new/'.$this->_folder_name.'/';
37 37
     }
38 38
 
39 39
 
Please login to merge, or discard this patch.
admin_pages/transactions/Transactions_Admin_Page_Init.core.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,40 +11,40 @@
 block discarded – undo
11 11
  */
12 12
 class Transactions_Admin_Page_Init extends EE_Admin_Page_Init
13 13
 {
14
-    public function __construct()
15
-    {
16
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
17
-        if (! defined('TXN_PG_SLUG')) {
18
-            define('TXN_PG_SLUG', 'espresso_transactions');
19
-            define('TXN_PG_NAME', ucwords(str_replace('_', '', TXN_PG_SLUG)));
20
-            define('TXN_ADMIN', EE_ADMIN_PAGES . 'transactions/');
21
-            define('TXN_ADMIN_URL', admin_url('admin.php?page=' . TXN_PG_SLUG));
22
-            define('TXN_ASSETS_PATH', TXN_ADMIN . 'assets/');
23
-            define('TXN_ASSETS_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/assets/'));
24
-            define('TXN_TEMPLATE_PATH', TXN_ADMIN . 'templates/');
25
-            define('TXN_TEMPLATE_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/templates/'));
26
-        }
27
-        parent::__construct();
28
-    }
14
+	public function __construct()
15
+	{
16
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
17
+		if (! defined('TXN_PG_SLUG')) {
18
+			define('TXN_PG_SLUG', 'espresso_transactions');
19
+			define('TXN_PG_NAME', ucwords(str_replace('_', '', TXN_PG_SLUG)));
20
+			define('TXN_ADMIN', EE_ADMIN_PAGES . 'transactions/');
21
+			define('TXN_ADMIN_URL', admin_url('admin.php?page=' . TXN_PG_SLUG));
22
+			define('TXN_ASSETS_PATH', TXN_ADMIN . 'assets/');
23
+			define('TXN_ASSETS_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/assets/'));
24
+			define('TXN_TEMPLATE_PATH', TXN_ADMIN . 'templates/');
25
+			define('TXN_TEMPLATE_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/templates/'));
26
+		}
27
+		parent::__construct();
28
+	}
29 29
 
30 30
 
31
-    protected function _set_init_properties()
32
-    {
33
-        $this->label = esc_html__('Transactions Overview', 'event_espresso');
34
-    }
31
+	protected function _set_init_properties()
32
+	{
33
+		$this->label = esc_html__('Transactions Overview', 'event_espresso');
34
+	}
35 35
 
36 36
 
37
-    public function getMenuProperties(): array
38
-    {
39
-        return [
40
-            'menu_type'       => AdminMenuItem::TYPE_MENU_SUB_ITEM,
41
-            'menu_group'      => 'main',
42
-            'menu_order'      => 50,
43
-            'show_on_menu'    => AdminMenuItem::DISPLAY_BLOG_ONLY,
44
-            'parent_slug'     => 'espresso_events',
45
-            'menu_slug'       => TXN_PG_SLUG,
46
-            'menu_label'      => esc_html__('Transactions', 'event_espresso'),
47
-            'capability'      => 'ee_read_transactions',
48
-        ];
49
-    }
37
+	public function getMenuProperties(): array
38
+	{
39
+		return [
40
+			'menu_type'       => AdminMenuItem::TYPE_MENU_SUB_ITEM,
41
+			'menu_group'      => 'main',
42
+			'menu_order'      => 50,
43
+			'show_on_menu'    => AdminMenuItem::DISPLAY_BLOG_ONLY,
44
+			'parent_slug'     => 'espresso_events',
45
+			'menu_slug'       => TXN_PG_SLUG,
46
+			'menu_label'      => esc_html__('Transactions', 'event_espresso'),
47
+			'capability'      => 'ee_read_transactions',
48
+		];
49
+	}
50 50
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
     public function __construct()
15 15
     {
16 16
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
17
-        if (! defined('TXN_PG_SLUG')) {
17
+        if ( ! defined('TXN_PG_SLUG')) {
18 18
             define('TXN_PG_SLUG', 'espresso_transactions');
19 19
             define('TXN_PG_NAME', ucwords(str_replace('_', '', TXN_PG_SLUG)));
20
-            define('TXN_ADMIN', EE_ADMIN_PAGES . 'transactions/');
21
-            define('TXN_ADMIN_URL', admin_url('admin.php?page=' . TXN_PG_SLUG));
22
-            define('TXN_ASSETS_PATH', TXN_ADMIN . 'assets/');
23
-            define('TXN_ASSETS_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/assets/'));
24
-            define('TXN_TEMPLATE_PATH', TXN_ADMIN . 'templates/');
25
-            define('TXN_TEMPLATE_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/templates/'));
20
+            define('TXN_ADMIN', EE_ADMIN_PAGES.'transactions/');
21
+            define('TXN_ADMIN_URL', admin_url('admin.php?page='.TXN_PG_SLUG));
22
+            define('TXN_ASSETS_PATH', TXN_ADMIN.'assets/');
23
+            define('TXN_ASSETS_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL.'transactions/assets/'));
24
+            define('TXN_TEMPLATE_PATH', TXN_ADMIN.'templates/');
25
+            define('TXN_TEMPLATE_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL.'transactions/templates/'));
26 26
         }
27 27
         parent::__construct();
28 28
     }
Please login to merge, or discard this patch.
admin_pages/support/Support_Admin_Page_Init.core.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -14,38 +14,38 @@
 block discarded – undo
14 14
  */
15 15
 class Support_Admin_Page_Init extends EE_Admin_Page_Init
16 16
 {
17
-    public function __construct()
18
-    {
19
-        // define some help/support page related constants
20
-        if (! defined('EE_SUPPORT_PG_SLUG')) {
21
-            define('EE_SUPPORT_PG_SLUG', 'espresso_support');
22
-            define('EE_SUPPORT_ADMIN_URL', admin_url('admin.php?page=' . EE_SUPPORT_PG_SLUG));
23
-            define('EE_SUPPORT_ADMIN_TEMPLATE_PATH', EE_ADMIN_PAGES . 'support/templates/');
24
-            define('EE_SUPPORT_ADMIN', EE_ADMIN_PAGES . 'support/');
25
-            define('EE_SUPPORT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'support/assets/');
26
-        }
27
-        parent::__construct();
28
-    }
17
+	public function __construct()
18
+	{
19
+		// define some help/support page related constants
20
+		if (! defined('EE_SUPPORT_PG_SLUG')) {
21
+			define('EE_SUPPORT_PG_SLUG', 'espresso_support');
22
+			define('EE_SUPPORT_ADMIN_URL', admin_url('admin.php?page=' . EE_SUPPORT_PG_SLUG));
23
+			define('EE_SUPPORT_ADMIN_TEMPLATE_PATH', EE_ADMIN_PAGES . 'support/templates/');
24
+			define('EE_SUPPORT_ADMIN', EE_ADMIN_PAGES . 'support/');
25
+			define('EE_SUPPORT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'support/assets/');
26
+		}
27
+		parent::__construct();
28
+	}
29 29
 
30 30
 
31
-    protected function _set_init_properties()
32
-    {
33
-        $this->label = esc_html__('Help & Support', 'event_espresso');
34
-    }
31
+	protected function _set_init_properties()
32
+	{
33
+		$this->label = esc_html__('Help & Support', 'event_espresso');
34
+	}
35 35
 
36 36
 
37
-    public function getMenuProperties(): array
38
-    {
39
-        return [
40
-            'menu_type'               => AdminMenuItem::TYPE_MENU_SUB_ITEM,
41
-            'menu_group'              => 'extras',
42
-            'menu_order'              => 30,
43
-            'show_on_menu'            => AdminMenuItem::DISPLAY_BLOG_AND_NETWORK,
44
-            'parent_slug'             => 'espresso_events',
45
-            'menu_slug'               => EE_SUPPORT_PG_SLUG,
46
-            'menu_label'              => esc_html__('Help & Support', 'event_espresso'),
47
-            'capability'              => 'ee_read_ee',
48
-            'maintenance_mode_parent' => 'espresso_maintenance_settings',
49
-        ];
50
-    }
37
+	public function getMenuProperties(): array
38
+	{
39
+		return [
40
+			'menu_type'               => AdminMenuItem::TYPE_MENU_SUB_ITEM,
41
+			'menu_group'              => 'extras',
42
+			'menu_order'              => 30,
43
+			'show_on_menu'            => AdminMenuItem::DISPLAY_BLOG_AND_NETWORK,
44
+			'parent_slug'             => 'espresso_events',
45
+			'menu_slug'               => EE_SUPPORT_PG_SLUG,
46
+			'menu_label'              => esc_html__('Help & Support', 'event_espresso'),
47
+			'capability'              => 'ee_read_ee',
48
+			'maintenance_mode_parent' => 'espresso_maintenance_settings',
49
+		];
50
+	}
51 51
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@
 block discarded – undo
17 17
     public function __construct()
18 18
     {
19 19
         // define some help/support page related constants
20
-        if (! defined('EE_SUPPORT_PG_SLUG')) {
20
+        if ( ! defined('EE_SUPPORT_PG_SLUG')) {
21 21
             define('EE_SUPPORT_PG_SLUG', 'espresso_support');
22
-            define('EE_SUPPORT_ADMIN_URL', admin_url('admin.php?page=' . EE_SUPPORT_PG_SLUG));
23
-            define('EE_SUPPORT_ADMIN_TEMPLATE_PATH', EE_ADMIN_PAGES . 'support/templates/');
24
-            define('EE_SUPPORT_ADMIN', EE_ADMIN_PAGES . 'support/');
25
-            define('EE_SUPPORT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'support/assets/');
22
+            define('EE_SUPPORT_ADMIN_URL', admin_url('admin.php?page='.EE_SUPPORT_PG_SLUG));
23
+            define('EE_SUPPORT_ADMIN_TEMPLATE_PATH', EE_ADMIN_PAGES.'support/templates/');
24
+            define('EE_SUPPORT_ADMIN', EE_ADMIN_PAGES.'support/');
25
+            define('EE_SUPPORT_ASSETS_URL', EE_ADMIN_PAGES_URL.'support/assets/');
26 26
         }
27 27
         parent::__construct();
28 28
     }
Please login to merge, or discard this patch.
admin_pages/venues/Venues_Admin_Page_Init.core.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,39 +15,39 @@
 block discarded – undo
15 15
  */
16 16
 class Venues_Admin_Page_Init extends EE_Admin_Page_CPT_Init
17 17
 {
18
-    public function __construct()
19
-    {
20
-        // define some event categories related constants
21
-        if (! defined('EE_VENUES_PG_SLUG')) {
22
-            define('EE_VENUES_PG_SLUG', 'espresso_venues');
23
-            define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
24
-            define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
25
-            define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
26
-        }
27
-        parent::__construct();
28
-        $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
29
-    }
18
+	public function __construct()
19
+	{
20
+		// define some event categories related constants
21
+		if (! defined('EE_VENUES_PG_SLUG')) {
22
+			define('EE_VENUES_PG_SLUG', 'espresso_venues');
23
+			define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
24
+			define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
25
+			define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
26
+		}
27
+		parent::__construct();
28
+		$this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
29
+	}
30 30
 
31 31
 
32
-    protected function _set_init_properties()
33
-    {
34
-        $this->label      = esc_html__('Event Venues', 'event_espresso');
35
-        $this->menu_label = esc_html__('Venues', 'event_espresso');
36
-        $this->menu_slug  = EE_VENUES_PG_SLUG;
37
-    }
32
+	protected function _set_init_properties()
33
+	{
34
+		$this->label      = esc_html__('Event Venues', 'event_espresso');
35
+		$this->menu_label = esc_html__('Venues', 'event_espresso');
36
+		$this->menu_slug  = EE_VENUES_PG_SLUG;
37
+	}
38 38
 
39 39
 
40
-    public function getMenuProperties(): array
41
-    {
42
-        return [
43
-            'menu_type'       => AdminMenuItem::TYPE_MENU_SUB_ITEM,
44
-            'menu_group'      => 'management',
45
-            'menu_order'      => 40,
46
-            'show_on_menu'    => AdminMenuItem::DISPLAY_BLOG_ONLY,
47
-            'parent_slug'     => 'espresso_events',
48
-            'menu_slug'       => EE_VENUES_PG_SLUG,
49
-            'menu_label'      => esc_html__('Venues', 'event_espresso'),
50
-            'capability'      => 'ee_read_venues',
51
-        ];
52
-    }
40
+	public function getMenuProperties(): array
41
+	{
42
+		return [
43
+			'menu_type'       => AdminMenuItem::TYPE_MENU_SUB_ITEM,
44
+			'menu_group'      => 'management',
45
+			'menu_order'      => 40,
46
+			'show_on_menu'    => AdminMenuItem::DISPLAY_BLOG_ONLY,
47
+			'parent_slug'     => 'espresso_events',
48
+			'menu_slug'       => EE_VENUES_PG_SLUG,
49
+			'menu_label'      => esc_html__('Venues', 'event_espresso'),
50
+			'capability'      => 'ee_read_venues',
51
+		];
52
+	}
53 53
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@
 block discarded – undo
18 18
     public function __construct()
19 19
     {
20 20
         // define some event categories related constants
21
-        if (! defined('EE_VENUES_PG_SLUG')) {
21
+        if ( ! defined('EE_VENUES_PG_SLUG')) {
22 22
             define('EE_VENUES_PG_SLUG', 'espresso_venues');
23
-            define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
24
-            define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
25
-            define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
23
+            define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page='.EE_VENUES_PG_SLUG));
24
+            define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL.'venues/assets/');
25
+            define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES.'venues/templates/');
26 26
         }
27 27
         parent::__construct();
28
-        $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
28
+        $this->_folder_path = EE_ADMIN_PAGES.$this->_folder_name.'/';
29 29
     }
30 30
 
31 31
 
Please login to merge, or discard this patch.
admin_pages/maintenance/Maintenance_Admin_Page_Init.core.php 2 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -17,102 +17,102 @@
 block discarded – undo
17 17
  */
18 18
 class Maintenance_Admin_Page_Init extends EE_Admin_Page_Init
19 19
 {
20
-    /**
21
-     * @var int
22
-     */
23
-    protected $m_mode_level;
20
+	/**
21
+	 * @var int
22
+	 */
23
+	protected $m_mode_level;
24 24
 
25
-    /**
26
-     * @var bool
27
-     */
28
-    protected $is_full_m_mode;
25
+	/**
26
+	 * @var bool
27
+	 */
28
+	protected $is_full_m_mode;
29 29
 
30 30
 
31
-    public function __construct()
32
-    {
33
-        $this->m_mode_level = EE_Maintenance_Mode::instance()->level();
34
-        $this->is_full_m_mode = $this->m_mode_level /*=== EE_Maintenance_Mode::level_2_complete_maintenance*/;
35
-        // define some page related constants
36
-        if (! defined('EE_MAINTENANCE_PG_SLUG')) {
37
-            define('EE_MAINTENANCE_LABEL', esc_html__('Maintenance', 'event_espresso'));
38
-            define('EE_MAINTENANCE_PG_SLUG', 'espresso_maintenance_settings');
39
-            define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page=' . EE_MAINTENANCE_PG_SLUG));
40
-            define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES . 'maintenance/');
41
-            define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN . 'templates/');
42
-            define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL . 'maintenance/assets/');
43
-        }
44
-        // check that if we're in maintenance mode that we tell the admin that
45
-        add_action('admin_notices', [$this, 'check_maintenance_mode']);
46
-        parent::__construct();
47
-    }
31
+	public function __construct()
32
+	{
33
+		$this->m_mode_level = EE_Maintenance_Mode::instance()->level();
34
+		$this->is_full_m_mode = $this->m_mode_level /*=== EE_Maintenance_Mode::level_2_complete_maintenance*/;
35
+		// define some page related constants
36
+		if (! defined('EE_MAINTENANCE_PG_SLUG')) {
37
+			define('EE_MAINTENANCE_LABEL', esc_html__('Maintenance', 'event_espresso'));
38
+			define('EE_MAINTENANCE_PG_SLUG', 'espresso_maintenance_settings');
39
+			define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page=' . EE_MAINTENANCE_PG_SLUG));
40
+			define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES . 'maintenance/');
41
+			define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN . 'templates/');
42
+			define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL . 'maintenance/assets/');
43
+		}
44
+		// check that if we're in maintenance mode that we tell the admin that
45
+		add_action('admin_notices', [$this, 'check_maintenance_mode']);
46
+		parent::__construct();
47
+	}
48 48
 
49 49
 
50
-    protected function _set_init_properties()
51
-    {
52
-        $this->label = EE_MAINTENANCE_LABEL;
53
-    }
50
+	protected function _set_init_properties()
51
+	{
52
+		$this->label = EE_MAINTENANCE_LABEL;
53
+	}
54 54
 
55 55
 
56
-    public function getMenuProperties(): array
57
-    {
58
-        return [
59
-            'menu_type'               => AdminMenuItem::TYPE_MENU_SUB_ITEM,
60
-            'menu_group'              => $this->is_full_m_mode ? 'main' : 'extras',
61
-            'menu_order'              => 30,
62
-            'show_on_menu'            => AdminMenuItem::DISPLAY_BLOG_ONLY,
63
-            'parent_slug'             => 'espresso_events',
64
-            'menu_slug'               => EE_MAINTENANCE_PG_SLUG,
65
-            'menu_label'              => EE_MAINTENANCE_LABEL,
66
-            'capability'              => 'manage_options',
67
-            'maintenance_mode_parent' => EE_MAINTENANCE_PG_SLUG,
68
-        ];
69
-    }
56
+	public function getMenuProperties(): array
57
+	{
58
+		return [
59
+			'menu_type'               => AdminMenuItem::TYPE_MENU_SUB_ITEM,
60
+			'menu_group'              => $this->is_full_m_mode ? 'main' : 'extras',
61
+			'menu_order'              => 30,
62
+			'show_on_menu'            => AdminMenuItem::DISPLAY_BLOG_ONLY,
63
+			'parent_slug'             => 'espresso_events',
64
+			'menu_slug'               => EE_MAINTENANCE_PG_SLUG,
65
+			'menu_label'              => EE_MAINTENANCE_LABEL,
66
+			'capability'              => 'manage_options',
67
+			'maintenance_mode_parent' => EE_MAINTENANCE_PG_SLUG,
68
+		];
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * Checks if we're in maintenance mode, and if so we notify the admin adn tell them how to take the site OUT of
74
-     * maintenance mode
75
-     */
76
-    public function check_maintenance_mode()
77
-    {
78
-        $notice               = '';
79
-        $maintenance_page_url = '';
80
-        if ($this->m_mode_level) {
81
-            $maintenance_page_url = esc_url_raw(
82
-                EE_Admin_Page::add_query_args_and_nonce([], EE_MAINTENANCE_ADMIN_URL)
83
-            );
84
-            switch ($this->m_mode_level) {
85
-                case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
86
-                    $notice = '<div class="update-nag ee-update-nag">';
87
-                    $notice .= sprintf(
88
-                        esc_html__(
89
-                            "Event Espresso is in Frontend-Only MAINTENANCE MODE. This means the front-end (ie, non-wp-admin pages) is disabled for ALL users except site admins. Visit the %s Maintenance Page %s to disable maintenance mode.",
90
-                            "event_espresso"
91
-                        ),
92
-                        "<a href='$maintenance_page_url'>",
93
-                        "</a>"
94
-                    );
95
-                    $notice .= '</div>';
96
-                    break;
97
-                case EE_Maintenance_Mode::level_2_complete_maintenance:
98
-                    $notice = '<div class="error"><p>';
99
-                    $notice .= sprintf(
100
-                        esc_html__(
101
-                            "As part of the process for updating Event Espresso, your database also
72
+	/**
73
+	 * Checks if we're in maintenance mode, and if so we notify the admin adn tell them how to take the site OUT of
74
+	 * maintenance mode
75
+	 */
76
+	public function check_maintenance_mode()
77
+	{
78
+		$notice               = '';
79
+		$maintenance_page_url = '';
80
+		if ($this->m_mode_level) {
81
+			$maintenance_page_url = esc_url_raw(
82
+				EE_Admin_Page::add_query_args_and_nonce([], EE_MAINTENANCE_ADMIN_URL)
83
+			);
84
+			switch ($this->m_mode_level) {
85
+				case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
86
+					$notice = '<div class="update-nag ee-update-nag">';
87
+					$notice .= sprintf(
88
+						esc_html__(
89
+							"Event Espresso is in Frontend-Only MAINTENANCE MODE. This means the front-end (ie, non-wp-admin pages) is disabled for ALL users except site admins. Visit the %s Maintenance Page %s to disable maintenance mode.",
90
+							"event_espresso"
91
+						),
92
+						"<a href='$maintenance_page_url'>",
93
+						"</a>"
94
+					);
95
+					$notice .= '</div>';
96
+					break;
97
+				case EE_Maintenance_Mode::level_2_complete_maintenance:
98
+					$notice = '<div class="error"><p>';
99
+					$notice .= sprintf(
100
+						esc_html__(
101
+							"As part of the process for updating Event Espresso, your database also
102 102
 needs to be updated. Event Espresso is in COMPLETE MAINTENANCE MODE (both WordPress admin pages and front-end event registration pages are disabled) until you run the database update script. %s Visit the Maintenance Page to get started,%s it only takes a moment.",
103
-                            "event_espresso"
104
-                        ),
105
-                        "<a href='$maintenance_page_url'>",
106
-                        "</a>"
107
-                    );
108
-                    $notice .= '</p></div>';
109
-                    break;
110
-            }
111
-        }
112
-        echo apply_filters(
113
-            'FHEE__Maintenance_Admin_Page_Init__check_maintenance_mode__notice',
114
-            $notice, // already escaped
115
-            $maintenance_page_url // already escaped
116
-        );
117
-    }
103
+							"event_espresso"
104
+						),
105
+						"<a href='$maintenance_page_url'>",
106
+						"</a>"
107
+					);
108
+					$notice .= '</p></div>';
109
+					break;
110
+			}
111
+		}
112
+		echo apply_filters(
113
+			'FHEE__Maintenance_Admin_Page_Init__check_maintenance_mode__notice',
114
+			$notice, // already escaped
115
+			$maintenance_page_url // already escaped
116
+		);
117
+	}
118 118
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,13 +33,13 @@
 block discarded – undo
33 33
         $this->m_mode_level = EE_Maintenance_Mode::instance()->level();
34 34
         $this->is_full_m_mode = $this->m_mode_level /*=== EE_Maintenance_Mode::level_2_complete_maintenance*/;
35 35
         // define some page related constants
36
-        if (! defined('EE_MAINTENANCE_PG_SLUG')) {
36
+        if ( ! defined('EE_MAINTENANCE_PG_SLUG')) {
37 37
             define('EE_MAINTENANCE_LABEL', esc_html__('Maintenance', 'event_espresso'));
38 38
             define('EE_MAINTENANCE_PG_SLUG', 'espresso_maintenance_settings');
39
-            define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page=' . EE_MAINTENANCE_PG_SLUG));
40
-            define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES . 'maintenance/');
41
-            define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN . 'templates/');
42
-            define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL . 'maintenance/assets/');
39
+            define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page='.EE_MAINTENANCE_PG_SLUG));
40
+            define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES.'maintenance/');
41
+            define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN.'templates/');
42
+            define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL.'maintenance/assets/');
43 43
         }
44 44
         // check that if we're in maintenance mode that we tell the admin that
45 45
         add_action('admin_notices', [$this, 'check_maintenance_mode']);
Please login to merge, or discard this patch.
admin_pages/about/About_Admin_Page_Init.core.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -14,39 +14,39 @@
 block discarded – undo
14 14
  */
15 15
 class About_Admin_Page_Init extends EE_Admin_Page_Init
16 16
 {
17
-    public function __construct()
18
-    {
19
-        // define some events related constants
20
-        if (! defined('EE_ABOUT_PG_SLUG')) {
21
-            define('EE_ABOUT_PG_SLUG', 'espresso_about');
22
-            define('EE_ABOUT_LABEL', esc_html__('About', 'event_espresso'));
23
-            define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/');
24
-            define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG));
25
-            define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/');
26
-            define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/');
27
-        }
28
-        parent::__construct();
29
-    }
17
+	public function __construct()
18
+	{
19
+		// define some events related constants
20
+		if (! defined('EE_ABOUT_PG_SLUG')) {
21
+			define('EE_ABOUT_PG_SLUG', 'espresso_about');
22
+			define('EE_ABOUT_LABEL', esc_html__('About', 'event_espresso'));
23
+			define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/');
24
+			define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG));
25
+			define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/');
26
+			define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/');
27
+		}
28
+		parent::__construct();
29
+	}
30 30
 
31 31
 
32
-    protected function _set_init_properties()
33
-    {
34
-        $this->label = esc_html__('About Event Espresso', 'event_espresso');
35
-    }
32
+	protected function _set_init_properties()
33
+	{
34
+		$this->label = esc_html__('About Event Espresso', 'event_espresso');
35
+	}
36 36
 
37 37
 
38
-    public function getMenuProperties(): array
39
-    {
40
-        return [
41
-            'menu_type'               => AdminMenuItem::TYPE_MENU_SUB_ITEM,
42
-            'menu_group'              => 'extras',
43
-            'menu_order'              => 40,
44
-            'show_on_menu'            => AdminMenuItem::DISPLAY_BLOG_AND_NETWORK,
45
-            'parent_slug'             => 'espresso_events',
46
-            'menu_slug'               => 'espresso_about',
47
-            'menu_label'              => EE_ABOUT_LABEL,
48
-            'capability'              => 'manage_options',
49
-            'maintenance_mode_parent' => 'espresso_maintenance_settings',
50
-        ];
51
-    }
38
+	public function getMenuProperties(): array
39
+	{
40
+		return [
41
+			'menu_type'               => AdminMenuItem::TYPE_MENU_SUB_ITEM,
42
+			'menu_group'              => 'extras',
43
+			'menu_order'              => 40,
44
+			'show_on_menu'            => AdminMenuItem::DISPLAY_BLOG_AND_NETWORK,
45
+			'parent_slug'             => 'espresso_events',
46
+			'menu_slug'               => 'espresso_about',
47
+			'menu_label'              => EE_ABOUT_LABEL,
48
+			'capability'              => 'manage_options',
49
+			'maintenance_mode_parent' => 'espresso_maintenance_settings',
50
+		];
51
+	}
52 52
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@
 block discarded – undo
17 17
     public function __construct()
18 18
     {
19 19
         // define some events related constants
20
-        if (! defined('EE_ABOUT_PG_SLUG')) {
20
+        if ( ! defined('EE_ABOUT_PG_SLUG')) {
21 21
             define('EE_ABOUT_PG_SLUG', 'espresso_about');
22 22
             define('EE_ABOUT_LABEL', esc_html__('About', 'event_espresso'));
23
-            define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/');
24
-            define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG));
25
-            define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/');
26
-            define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/');
23
+            define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES.'about/');
24
+            define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page='.EE_ABOUT_PG_SLUG));
25
+            define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN.'templates/');
26
+            define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL.'about/assets/');
27 27
         }
28 28
         parent::__construct();
29 29
     }
Please login to merge, or discard this patch.