Completed
Branch FET/paypal-smart-button2 (052e8d)
by
unknown
102:07 queued 88:11
created
core/admin/EE_Admin.core.php 2 patches
Indentation   +958 added lines, -958 removed lines patch added patch discarded remove patch
@@ -20,487 +20,487 @@  discard block
 block discarded – undo
20 20
 final class EE_Admin implements InterminableInterface
21 21
 {
22 22
 
23
-    /**
24
-     * @var EE_Admin $_instance
25
-     */
26
-    private static $_instance;
27
-
28
-    /**
29
-     * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
30
-     */
31
-    private $persistent_admin_notice_manager;
32
-
33
-    /**
34
-     * @var LoaderInterface
35
-     */
36
-    protected $loader;
37
-
38
-    /**
39
-     * @singleton method used to instantiate class object
40
-     * @return EE_Admin
41
-     * @throws EE_Error
42
-     */
43
-    public static function instance()
44
-    {
45
-        // check if class object is instantiated
46
-        if (! self::$_instance instanceof EE_Admin) {
47
-            self::$_instance = new self();
48
-        }
49
-        return self::$_instance;
50
-    }
51
-
52
-
53
-    /**
54
-     * @return EE_Admin
55
-     * @throws EE_Error
56
-     */
57
-    public static function reset()
58
-    {
59
-        self::$_instance = null;
60
-        return self::instance();
61
-    }
62
-
63
-
64
-    /**
65
-     * class constructor
66
-     *
67
-     * @throws EE_Error
68
-     * @throws InvalidDataTypeException
69
-     * @throws InvalidInterfaceException
70
-     * @throws InvalidArgumentException
71
-     */
72
-    protected function __construct()
73
-    {
74
-        // define global EE_Admin constants
75
-        $this->_define_all_constants();
76
-        // set autoloaders for our admin page classes based on included path information
77
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
78
-        // admin hooks
79
-        add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
80
-        // load EE_Request_Handler early
81
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
82
-        add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
83
-        add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
84
-        add_action('wp_loaded', array($this, 'wp_loaded'), 100);
85
-        add_action('admin_init', array($this, 'admin_init'), 100);
86
-        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
87
-        add_action('admin_notices', array($this, 'display_admin_notices'), 10);
88
-        add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
89
-        add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
90
-        add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
91
-        add_action('load-plugins.php', array($this, 'hookIntoWpPluginsPage'));
92
-        // reset Environment config (we only do this on admin page loads);
93
-        EE_Registry::instance()->CFG->environment->recheck_values();
94
-        do_action('AHEE__EE_Admin__loaded');
95
-    }
96
-
97
-
98
-    /**
99
-     * _define_all_constants
100
-     * define constants that are set globally for all admin pages
101
-     *
102
-     * @return void
103
-     */
104
-    private function _define_all_constants()
105
-    {
106
-        if (! defined('EE_ADMIN_URL')) {
107
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
108
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
109
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
110
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
111
-            define('WP_AJAX_URL', admin_url('admin-ajax.php'));
112
-        }
113
-    }
114
-
115
-
116
-    /**
117
-     * filter_plugin_actions - adds links to the Plugins page listing
118
-     *
119
-     * @param    array  $links
120
-     * @param    string $plugin
121
-     * @return    array
122
-     */
123
-    public function filter_plugin_actions($links, $plugin)
124
-    {
125
-        // set $main_file in stone
126
-        static $main_file;
127
-        // if $main_file is not set yet
128
-        if (! $main_file) {
129
-            $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
130
-        }
131
-        if ($plugin === $main_file) {
132
-            // compare current plugin to this one
133
-            if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
134
-                $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
135
-                                    . ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
136
-                                    . esc_html__('Maintenance Mode Active', 'event_espresso')
137
-                                    . '</a>';
138
-                array_unshift($links, $maintenance_link);
139
-            } else {
140
-                $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
141
-                                     . esc_html__('Settings', 'event_espresso')
142
-                                     . '</a>';
143
-                $events_link = '<a href="admin.php?page=espresso_events">'
144
-                               . esc_html__('Events', 'event_espresso')
145
-                               . '</a>';
146
-                // add before other links
147
-                array_unshift($links, $org_settings_link, $events_link);
148
-            }
149
-        }
150
-        return $links;
151
-    }
152
-
153
-
154
-    /**
155
-     * _get_request
156
-     *
157
-     * @return void
158
-     * @throws EE_Error
159
-     * @throws InvalidArgumentException
160
-     * @throws InvalidDataTypeException
161
-     * @throws InvalidInterfaceException
162
-     * @throws ReflectionException
163
-     */
164
-    public function get_request()
165
-    {
166
-        EE_Registry::instance()->load_core('Request_Handler');
167
-        EE_Registry::instance()->load_core('CPT_Strategy');
168
-    }
169
-
170
-
171
-    /**
172
-     * hide_admin_pages_except_maintenance_mode
173
-     *
174
-     * @param array $admin_page_folder_names
175
-     * @return array
176
-     */
177
-    public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
178
-    {
179
-        return array(
180
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
181
-            'about'       => EE_ADMIN_PAGES . 'about' . DS,
182
-            'support'     => EE_ADMIN_PAGES . 'support' . DS,
183
-        );
184
-    }
185
-
186
-
187
-    /**
188
-     * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
189
-     * EE_Front_Controller's init phases have run
190
-     *
191
-     * @return void
192
-     * @throws EE_Error
193
-     * @throws InvalidArgumentException
194
-     * @throws InvalidDataTypeException
195
-     * @throws InvalidInterfaceException
196
-     * @throws ReflectionException
197
-     * @throws ServiceNotFoundException
198
-     */
199
-    public function init()
200
-    {
201
-        // only enable most of the EE_Admin IF we're not in full maintenance mode
202
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
203
-            $this->initModelsReady();
204
-        }
205
-        // run the admin page factory but ONLY if we are doing an ee admin ajax request
206
-        if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
207
-            try {
208
-                // this loads the controller for the admin pages which will setup routing etc
209
-                EE_Registry::instance()->load_core('Admin_Page_Loader');
210
-            } catch (EE_Error $e) {
211
-                $e->get_error();
212
-            }
213
-        }
214
-        add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
215
-        // make sure our CPTs and custom taxonomy metaboxes get shown for first time users
216
-        add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
217
-        add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
218
-        // exclude EE critical pages from all nav menus and wp_list_pages
219
-        add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
220
-    }
221
-
222
-
223
-    /**
224
-     * Gets the loader (and if it wasn't previously set, sets it)
225
-     * @return LoaderInterface
226
-     * @throws InvalidArgumentException
227
-     * @throws InvalidDataTypeException
228
-     * @throws InvalidInterfaceException
229
-     */
230
-    protected function getLoader()
231
-    {
232
-        if (! $this->loader instanceof LoaderInterface) {
233
-            $this->loader = LoaderFactory::getLoader();
234
-        }
235
-        return $this->loader;
236
-    }
237
-
238
-
239
-    /**
240
-     * Method that's fired on admin requests (including admin ajax) but only when the models are usable
241
-     * (ie, the site isn't in maintenance mode)
242
-     * @since $VID:$
243
-     * @return void
244
-     */
245
-    protected function initModelsReady()
246
-    {
247
-        // ok so we want to enable the entire admin
248
-        $this->persistent_admin_notice_manager = $this->getLoader()->getShared(
249
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
250
-        );
251
-        $this->persistent_admin_notice_manager->setReturnUrl(
252
-            EE_Admin_Page::add_query_args_and_nonce(
253
-                array(
254
-                    'page'   => EE_Registry::instance()->REQ->get('page', ''),
255
-                    'action' => EE_Registry::instance()->REQ->get('action', ''),
256
-                ),
257
-                EE_ADMIN_URL
258
-            )
259
-        );
260
-        $this->maybeSetDatetimeWarningNotice();
261
-        // at a glance dashboard widget
262
-        add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
263
-        // filter for get_edit_post_link used on comments for custom post types
264
-        add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
265
-    }
266
-
267
-
268
-    /**
269
-     *    get_persistent_admin_notices
270
-     *
271
-     * @access    public
272
-     * @return void
273
-     * @throws EE_Error
274
-     * @throws InvalidArgumentException
275
-     * @throws InvalidDataTypeException
276
-     * @throws InvalidInterfaceException
277
-     */
278
-    public function maybeSetDatetimeWarningNotice()
279
-    {
280
-        // add dismissable notice for datetime changes.  Only valid if site does not have a timezone_string set.
281
-        // @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
282
-        // with this.  But after enough time (indeterminate at this point) we can just remove this notice.
283
-        // this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
284
-        if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
285
-            && ! get_option('timezone_string')
286
-            && EEM_Event::instance()->count() > 0
287
-        ) {
288
-            new PersistentAdminNotice(
289
-                'datetime_fix_notice',
290
-                sprintf(
291
-                    esc_html__(
292
-                        '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times.  Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',
293
-                        'event_espresso'
294
-                    ),
295
-                    '<strong>',
296
-                    '</strong>',
297
-                    '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
298
-                    '</a>',
299
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
300
-                        array(
301
-                            'page'   => 'espresso_maintenance_settings',
302
-                            'action' => 'datetime_tools',
303
-                        ),
304
-                        admin_url('admin.php')
305
-                    ) . '">'
306
-                ),
307
-                false,
308
-                'manage_options',
309
-                'datetime_fix_persistent_notice'
310
-            );
311
-        }
312
-    }
313
-
314
-
315
-    /**
316
-     * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
317
-     * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
318
-     * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
319
-     * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
320
-     * normal property on the post_type object.  It's found ONLY in this particular context.
321
-     *
322
-     * @param WP_Post $post_type WP post type object
323
-     * @return WP_Post
324
-     * @throws InvalidArgumentException
325
-     * @throws InvalidDataTypeException
326
-     * @throws InvalidInterfaceException
327
-     */
328
-    public function remove_pages_from_nav_menu($post_type)
329
-    {
330
-        // if this isn't the "pages" post type let's get out
331
-        if ($post_type->name !== 'page') {
332
-            return $post_type;
333
-        }
334
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
335
-        $post_type->_default_query = array(
336
-            'post__not_in' => $critical_pages,
337
-        );
338
-        return $post_type;
339
-    }
340
-
341
-
342
-    /**
343
-     * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
344
-     * metaboxes get shown as well
345
-     *
346
-     * @return void
347
-     */
348
-    public function enable_hidden_ee_nav_menu_metaboxes()
349
-    {
350
-        global $wp_meta_boxes, $pagenow;
351
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
352
-            return;
353
-        }
354
-        $user = wp_get_current_user();
355
-        // has this been done yet?
356
-        if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
357
-            return;
358
-        }
359
-
360
-        $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID);
361
-        $initial_meta_boxes = apply_filters(
362
-            'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
363
-            array(
364
-                'nav-menu-theme-locations',
365
-                'add-page',
366
-                'add-custom-links',
367
-                'add-category',
368
-                'add-espresso_events',
369
-                'add-espresso_venues',
370
-                'add-espresso_event_categories',
371
-                'add-espresso_venue_categories',
372
-                'add-post-type-post',
373
-                'add-post-type-page',
374
-            )
375
-        );
376
-
377
-        if (is_array($hidden_meta_boxes)) {
378
-            foreach ($hidden_meta_boxes as $key => $meta_box_id) {
379
-                if (in_array($meta_box_id, $initial_meta_boxes, true)) {
380
-                    unset($hidden_meta_boxes[ $key ]);
381
-                }
382
-            }
383
-        }
384
-        update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
385
-        update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
386
-    }
387
-
388
-
389
-    /**
390
-     * This method simply registers custom nav menu boxes for "nav_menus.php route"
391
-     * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
392
-     *
393
-     * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
394
-     *         addons etc.
395
-     * @return void
396
-     */
397
-    public function register_custom_nav_menu_boxes()
398
-    {
399
-        add_meta_box(
400
-            'add-extra-nav-menu-pages',
401
-            esc_html__('Event Espresso Pages', 'event_espresso'),
402
-            array($this, 'ee_cpt_archive_pages'),
403
-            'nav-menus',
404
-            'side',
405
-            'core'
406
-        );
407
-    }
408
-
409
-
410
-    /**
411
-     * Use this to edit the post link for our cpts so that the edit link points to the correct page.
412
-     *
413
-     * @since   4.3.0
414
-     * @param string $link the original link generated by wp
415
-     * @param int    $id   post id
416
-     * @return string  the (maybe) modified link
417
-     */
418
-    public function modify_edit_post_link($link, $id)
419
-    {
420
-        if (! $post = get_post($id)) {
421
-            return $link;
422
-        }
423
-        if ($post->post_type === 'espresso_attendees') {
424
-            $query_args = array(
425
-                'action' => 'edit_attendee',
426
-                'post'   => $id,
427
-            );
428
-            return EEH_URL::add_query_args_and_nonce(
429
-                $query_args,
430
-                admin_url('admin.php?page=espresso_registrations')
431
-            );
432
-        }
433
-        return $link;
434
-    }
435
-
436
-
437
-    public function ee_cpt_archive_pages()
438
-    {
439
-        global $nav_menu_selected_id;
440
-        $db_fields = false;
441
-        $walker = new Walker_Nav_Menu_Checklist($db_fields);
442
-        $current_tab = 'event-archives';
443
-        $removed_args = array(
444
-            'action',
445
-            'customlink-tab',
446
-            'edit-menu-item',
447
-            'menu-item',
448
-            'page-tab',
449
-            '_wpnonce',
450
-        );
451
-        ?>
23
+	/**
24
+	 * @var EE_Admin $_instance
25
+	 */
26
+	private static $_instance;
27
+
28
+	/**
29
+	 * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
30
+	 */
31
+	private $persistent_admin_notice_manager;
32
+
33
+	/**
34
+	 * @var LoaderInterface
35
+	 */
36
+	protected $loader;
37
+
38
+	/**
39
+	 * @singleton method used to instantiate class object
40
+	 * @return EE_Admin
41
+	 * @throws EE_Error
42
+	 */
43
+	public static function instance()
44
+	{
45
+		// check if class object is instantiated
46
+		if (! self::$_instance instanceof EE_Admin) {
47
+			self::$_instance = new self();
48
+		}
49
+		return self::$_instance;
50
+	}
51
+
52
+
53
+	/**
54
+	 * @return EE_Admin
55
+	 * @throws EE_Error
56
+	 */
57
+	public static function reset()
58
+	{
59
+		self::$_instance = null;
60
+		return self::instance();
61
+	}
62
+
63
+
64
+	/**
65
+	 * class constructor
66
+	 *
67
+	 * @throws EE_Error
68
+	 * @throws InvalidDataTypeException
69
+	 * @throws InvalidInterfaceException
70
+	 * @throws InvalidArgumentException
71
+	 */
72
+	protected function __construct()
73
+	{
74
+		// define global EE_Admin constants
75
+		$this->_define_all_constants();
76
+		// set autoloaders for our admin page classes based on included path information
77
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
78
+		// admin hooks
79
+		add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
80
+		// load EE_Request_Handler early
81
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
82
+		add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
83
+		add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
84
+		add_action('wp_loaded', array($this, 'wp_loaded'), 100);
85
+		add_action('admin_init', array($this, 'admin_init'), 100);
86
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
87
+		add_action('admin_notices', array($this, 'display_admin_notices'), 10);
88
+		add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
89
+		add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
90
+		add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
91
+		add_action('load-plugins.php', array($this, 'hookIntoWpPluginsPage'));
92
+		// reset Environment config (we only do this on admin page loads);
93
+		EE_Registry::instance()->CFG->environment->recheck_values();
94
+		do_action('AHEE__EE_Admin__loaded');
95
+	}
96
+
97
+
98
+	/**
99
+	 * _define_all_constants
100
+	 * define constants that are set globally for all admin pages
101
+	 *
102
+	 * @return void
103
+	 */
104
+	private function _define_all_constants()
105
+	{
106
+		if (! defined('EE_ADMIN_URL')) {
107
+			define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
108
+			define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
109
+			define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
110
+			define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
111
+			define('WP_AJAX_URL', admin_url('admin-ajax.php'));
112
+		}
113
+	}
114
+
115
+
116
+	/**
117
+	 * filter_plugin_actions - adds links to the Plugins page listing
118
+	 *
119
+	 * @param    array  $links
120
+	 * @param    string $plugin
121
+	 * @return    array
122
+	 */
123
+	public function filter_plugin_actions($links, $plugin)
124
+	{
125
+		// set $main_file in stone
126
+		static $main_file;
127
+		// if $main_file is not set yet
128
+		if (! $main_file) {
129
+			$main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
130
+		}
131
+		if ($plugin === $main_file) {
132
+			// compare current plugin to this one
133
+			if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
134
+				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
135
+									. ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
136
+									. esc_html__('Maintenance Mode Active', 'event_espresso')
137
+									. '</a>';
138
+				array_unshift($links, $maintenance_link);
139
+			} else {
140
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
141
+									 . esc_html__('Settings', 'event_espresso')
142
+									 . '</a>';
143
+				$events_link = '<a href="admin.php?page=espresso_events">'
144
+							   . esc_html__('Events', 'event_espresso')
145
+							   . '</a>';
146
+				// add before other links
147
+				array_unshift($links, $org_settings_link, $events_link);
148
+			}
149
+		}
150
+		return $links;
151
+	}
152
+
153
+
154
+	/**
155
+	 * _get_request
156
+	 *
157
+	 * @return void
158
+	 * @throws EE_Error
159
+	 * @throws InvalidArgumentException
160
+	 * @throws InvalidDataTypeException
161
+	 * @throws InvalidInterfaceException
162
+	 * @throws ReflectionException
163
+	 */
164
+	public function get_request()
165
+	{
166
+		EE_Registry::instance()->load_core('Request_Handler');
167
+		EE_Registry::instance()->load_core('CPT_Strategy');
168
+	}
169
+
170
+
171
+	/**
172
+	 * hide_admin_pages_except_maintenance_mode
173
+	 *
174
+	 * @param array $admin_page_folder_names
175
+	 * @return array
176
+	 */
177
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
178
+	{
179
+		return array(
180
+			'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
181
+			'about'       => EE_ADMIN_PAGES . 'about' . DS,
182
+			'support'     => EE_ADMIN_PAGES . 'support' . DS,
183
+		);
184
+	}
185
+
186
+
187
+	/**
188
+	 * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
189
+	 * EE_Front_Controller's init phases have run
190
+	 *
191
+	 * @return void
192
+	 * @throws EE_Error
193
+	 * @throws InvalidArgumentException
194
+	 * @throws InvalidDataTypeException
195
+	 * @throws InvalidInterfaceException
196
+	 * @throws ReflectionException
197
+	 * @throws ServiceNotFoundException
198
+	 */
199
+	public function init()
200
+	{
201
+		// only enable most of the EE_Admin IF we're not in full maintenance mode
202
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
203
+			$this->initModelsReady();
204
+		}
205
+		// run the admin page factory but ONLY if we are doing an ee admin ajax request
206
+		if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
207
+			try {
208
+				// this loads the controller for the admin pages which will setup routing etc
209
+				EE_Registry::instance()->load_core('Admin_Page_Loader');
210
+			} catch (EE_Error $e) {
211
+				$e->get_error();
212
+			}
213
+		}
214
+		add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
215
+		// make sure our CPTs and custom taxonomy metaboxes get shown for first time users
216
+		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
217
+		add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
218
+		// exclude EE critical pages from all nav menus and wp_list_pages
219
+		add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
220
+	}
221
+
222
+
223
+	/**
224
+	 * Gets the loader (and if it wasn't previously set, sets it)
225
+	 * @return LoaderInterface
226
+	 * @throws InvalidArgumentException
227
+	 * @throws InvalidDataTypeException
228
+	 * @throws InvalidInterfaceException
229
+	 */
230
+	protected function getLoader()
231
+	{
232
+		if (! $this->loader instanceof LoaderInterface) {
233
+			$this->loader = LoaderFactory::getLoader();
234
+		}
235
+		return $this->loader;
236
+	}
237
+
238
+
239
+	/**
240
+	 * Method that's fired on admin requests (including admin ajax) but only when the models are usable
241
+	 * (ie, the site isn't in maintenance mode)
242
+	 * @since $VID:$
243
+	 * @return void
244
+	 */
245
+	protected function initModelsReady()
246
+	{
247
+		// ok so we want to enable the entire admin
248
+		$this->persistent_admin_notice_manager = $this->getLoader()->getShared(
249
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
250
+		);
251
+		$this->persistent_admin_notice_manager->setReturnUrl(
252
+			EE_Admin_Page::add_query_args_and_nonce(
253
+				array(
254
+					'page'   => EE_Registry::instance()->REQ->get('page', ''),
255
+					'action' => EE_Registry::instance()->REQ->get('action', ''),
256
+				),
257
+				EE_ADMIN_URL
258
+			)
259
+		);
260
+		$this->maybeSetDatetimeWarningNotice();
261
+		// at a glance dashboard widget
262
+		add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
263
+		// filter for get_edit_post_link used on comments for custom post types
264
+		add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
265
+	}
266
+
267
+
268
+	/**
269
+	 *    get_persistent_admin_notices
270
+	 *
271
+	 * @access    public
272
+	 * @return void
273
+	 * @throws EE_Error
274
+	 * @throws InvalidArgumentException
275
+	 * @throws InvalidDataTypeException
276
+	 * @throws InvalidInterfaceException
277
+	 */
278
+	public function maybeSetDatetimeWarningNotice()
279
+	{
280
+		// add dismissable notice for datetime changes.  Only valid if site does not have a timezone_string set.
281
+		// @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
282
+		// with this.  But after enough time (indeterminate at this point) we can just remove this notice.
283
+		// this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
284
+		if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
285
+			&& ! get_option('timezone_string')
286
+			&& EEM_Event::instance()->count() > 0
287
+		) {
288
+			new PersistentAdminNotice(
289
+				'datetime_fix_notice',
290
+				sprintf(
291
+					esc_html__(
292
+						'%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times.  Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',
293
+						'event_espresso'
294
+					),
295
+					'<strong>',
296
+					'</strong>',
297
+					'<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
298
+					'</a>',
299
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
300
+						array(
301
+							'page'   => 'espresso_maintenance_settings',
302
+							'action' => 'datetime_tools',
303
+						),
304
+						admin_url('admin.php')
305
+					) . '">'
306
+				),
307
+				false,
308
+				'manage_options',
309
+				'datetime_fix_persistent_notice'
310
+			);
311
+		}
312
+	}
313
+
314
+
315
+	/**
316
+	 * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
317
+	 * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
318
+	 * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
319
+	 * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
320
+	 * normal property on the post_type object.  It's found ONLY in this particular context.
321
+	 *
322
+	 * @param WP_Post $post_type WP post type object
323
+	 * @return WP_Post
324
+	 * @throws InvalidArgumentException
325
+	 * @throws InvalidDataTypeException
326
+	 * @throws InvalidInterfaceException
327
+	 */
328
+	public function remove_pages_from_nav_menu($post_type)
329
+	{
330
+		// if this isn't the "pages" post type let's get out
331
+		if ($post_type->name !== 'page') {
332
+			return $post_type;
333
+		}
334
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
335
+		$post_type->_default_query = array(
336
+			'post__not_in' => $critical_pages,
337
+		);
338
+		return $post_type;
339
+	}
340
+
341
+
342
+	/**
343
+	 * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
344
+	 * metaboxes get shown as well
345
+	 *
346
+	 * @return void
347
+	 */
348
+	public function enable_hidden_ee_nav_menu_metaboxes()
349
+	{
350
+		global $wp_meta_boxes, $pagenow;
351
+		if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
352
+			return;
353
+		}
354
+		$user = wp_get_current_user();
355
+		// has this been done yet?
356
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
357
+			return;
358
+		}
359
+
360
+		$hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID);
361
+		$initial_meta_boxes = apply_filters(
362
+			'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
363
+			array(
364
+				'nav-menu-theme-locations',
365
+				'add-page',
366
+				'add-custom-links',
367
+				'add-category',
368
+				'add-espresso_events',
369
+				'add-espresso_venues',
370
+				'add-espresso_event_categories',
371
+				'add-espresso_venue_categories',
372
+				'add-post-type-post',
373
+				'add-post-type-page',
374
+			)
375
+		);
376
+
377
+		if (is_array($hidden_meta_boxes)) {
378
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
379
+				if (in_array($meta_box_id, $initial_meta_boxes, true)) {
380
+					unset($hidden_meta_boxes[ $key ]);
381
+				}
382
+			}
383
+		}
384
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
385
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
386
+	}
387
+
388
+
389
+	/**
390
+	 * This method simply registers custom nav menu boxes for "nav_menus.php route"
391
+	 * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
392
+	 *
393
+	 * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
394
+	 *         addons etc.
395
+	 * @return void
396
+	 */
397
+	public function register_custom_nav_menu_boxes()
398
+	{
399
+		add_meta_box(
400
+			'add-extra-nav-menu-pages',
401
+			esc_html__('Event Espresso Pages', 'event_espresso'),
402
+			array($this, 'ee_cpt_archive_pages'),
403
+			'nav-menus',
404
+			'side',
405
+			'core'
406
+		);
407
+	}
408
+
409
+
410
+	/**
411
+	 * Use this to edit the post link for our cpts so that the edit link points to the correct page.
412
+	 *
413
+	 * @since   4.3.0
414
+	 * @param string $link the original link generated by wp
415
+	 * @param int    $id   post id
416
+	 * @return string  the (maybe) modified link
417
+	 */
418
+	public function modify_edit_post_link($link, $id)
419
+	{
420
+		if (! $post = get_post($id)) {
421
+			return $link;
422
+		}
423
+		if ($post->post_type === 'espresso_attendees') {
424
+			$query_args = array(
425
+				'action' => 'edit_attendee',
426
+				'post'   => $id,
427
+			);
428
+			return EEH_URL::add_query_args_and_nonce(
429
+				$query_args,
430
+				admin_url('admin.php?page=espresso_registrations')
431
+			);
432
+		}
433
+		return $link;
434
+	}
435
+
436
+
437
+	public function ee_cpt_archive_pages()
438
+	{
439
+		global $nav_menu_selected_id;
440
+		$db_fields = false;
441
+		$walker = new Walker_Nav_Menu_Checklist($db_fields);
442
+		$current_tab = 'event-archives';
443
+		$removed_args = array(
444
+			'action',
445
+			'customlink-tab',
446
+			'edit-menu-item',
447
+			'menu-item',
448
+			'page-tab',
449
+			'_wpnonce',
450
+		);
451
+		?>
452 452
         <div id="posttype-extra-nav-menu-pages" class="posttypediv">
453 453
             <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">
454 454
                 <li <?php echo('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>>
455 455
                     <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives"
456 456
                        href="<?php
457
-                        if ($nav_menu_selected_id) {
458
-                            echo esc_url(
459
-                                add_query_arg(
460
-                                    'extra-nav-menu-pages-tab',
461
-                                    'event-archives',
462
-                                    remove_query_arg($removed_args)
463
-                                )
464
-                            );
465
-                        }
466
-                        ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
457
+						if ($nav_menu_selected_id) {
458
+							echo esc_url(
459
+								add_query_arg(
460
+									'extra-nav-menu-pages-tab',
461
+									'event-archives',
462
+									remove_query_arg($removed_args)
463
+								)
464
+							);
465
+						}
466
+						?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
467 467
                         <?php _e('Event Archive Pages', 'event_espresso'); ?>
468 468
                     </a>
469 469
                 </li>
470 470
             </ul><!-- .posttype-tabs -->
471 471
 
472 472
             <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php
473
-            echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
474
-            ?>">
473
+			echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
474
+			?>">
475 475
                 <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear">
476 476
                     <?php
477
-                    $pages = $this->_get_extra_nav_menu_pages_items();
478
-                    $args['walker'] = $walker;
479
-                    echo walk_nav_menu_tree(
480
-                        array_map(
481
-                            array($this, '_setup_extra_nav_menu_pages_items'),
482
-                            $pages
483
-                        ),
484
-                        0,
485
-                        (object) $args
486
-                    );
487
-                    ?>
477
+					$pages = $this->_get_extra_nav_menu_pages_items();
478
+					$args['walker'] = $walker;
479
+					echo walk_nav_menu_tree(
480
+						array_map(
481
+							array($this, '_setup_extra_nav_menu_pages_items'),
482
+							$pages
483
+						),
484
+						0,
485
+						(object) $args
486
+					);
487
+					?>
488 488
                 </ul>
489 489
             </div><!-- /.tabs-panel -->
490 490
 
491 491
             <p class="button-controls">
492 492
                 <span class="list-controls">
493 493
                     <a href="<?php
494
-                             echo esc_url(
495
-                                 add_query_arg(
496
-                                     array(
497
-                                         'extra-nav-menu-pages-tab' => 'event-archives',
498
-                                         'selectall'                => 1,
499
-                                     ),
500
-                                     remove_query_arg($removed_args)
501
-                                 )
502
-                             );
503
-                        ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All', 'event_espresso'); ?></a>
494
+							 echo esc_url(
495
+								 add_query_arg(
496
+									 array(
497
+										 'extra-nav-menu-pages-tab' => 'event-archives',
498
+										 'selectall'                => 1,
499
+									 ),
500
+									 remove_query_arg($removed_args)
501
+								 )
502
+							 );
503
+						?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All', 'event_espresso'); ?></a>
504 504
                 </span>
505 505
                 <span class="add-to-menu">
506 506
                     <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?>
@@ -513,500 +513,500 @@  discard block
 block discarded – undo
513 513
 
514 514
         </div><!-- /.posttypediv -->
515 515
         <?php
516
-    }
517
-
518
-
519
-    /**
520
-     * Returns an array of event archive nav items.
521
-     *
522
-     * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
523
-     *        method we use for getting the extra nav menu items
524
-     * @return array
525
-     */
526
-    private function _get_extra_nav_menu_pages_items()
527
-    {
528
-        $menuitems[] = array(
529
-            'title'       => esc_html__('Event List', 'event_espresso'),
530
-            'url'         => get_post_type_archive_link('espresso_events'),
531
-            'description' => esc_html__('Archive page for all events.', 'event_espresso'),
532
-        );
533
-        return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
534
-    }
535
-
536
-
537
-    /**
538
-     * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
539
-     * the properties and converts it to the menu item object.
540
-     *
541
-     * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
542
-     * @param $menu_item_values
543
-     * @return stdClass
544
-     */
545
-    private function _setup_extra_nav_menu_pages_items($menu_item_values)
546
-    {
547
-        $menu_item = new stdClass();
548
-        $keys = array(
549
-            'ID'               => 0,
550
-            'db_id'            => 0,
551
-            'menu_item_parent' => 0,
552
-            'object_id'        => -1,
553
-            'post_parent'      => 0,
554
-            'type'             => 'custom',
555
-            'object'           => '',
556
-            'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
557
-            'title'            => '',
558
-            'url'              => '',
559
-            'target'           => '',
560
-            'attr_title'       => '',
561
-            'description'      => '',
562
-            'classes'          => array(),
563
-            'xfn'              => '',
564
-        );
565
-
566
-        foreach ($keys as $key => $value) {
567
-            $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
568
-        }
569
-        return $menu_item;
570
-    }
571
-
572
-
573
-    /**
574
-     * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
575
-     * EE_Admin_Page route is called.
576
-     *
577
-     * @return void
578
-     */
579
-    public function route_admin_request()
580
-    {
581
-    }
582
-
583
-
584
-    /**
585
-     * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
586
-     *
587
-     * @return void
588
-     */
589
-    public function wp_loaded()
590
-    {
591
-    }
592
-
593
-
594
-    /**
595
-     * admin_init
596
-     *
597
-     * @return void
598
-     * @throws EE_Error
599
-     * @throws InvalidArgumentException
600
-     * @throws InvalidDataTypeException
601
-     * @throws InvalidInterfaceException
602
-     * @throws ReflectionException
603
-     */
604
-    public function admin_init()
605
-    {
606
-        /**
607
-         * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
608
-         * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
609
-         * - check if doing post processing.
610
-         * - check if doing post processing of one of EE CPTs
611
-         * - instantiate the corresponding EE CPT model for the post_type being processed.
612
-         */
613
-        if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
614
-            /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
615
-            $custom_post_types = $this->getLoader()->getShared(
616
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
617
-            );
618
-            $custom_post_types->getCustomPostTypeModels($_POST['post_type']);
619
-        }
620
-
621
-
622
-        /**
623
-         * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
624
-         * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
625
-         * Pages" tab in the EE General Settings Admin page.
626
-         * This is for user-proofing.
627
-         */
628
-        add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
629
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
630
-            $this->adminInitModelsReady();
631
-        }
632
-    }
633
-
634
-
635
-    /**
636
-     * Runs on admin_init but only if models are usable (ie, we're not in maintenanc emode)
637
-     */
638
-    protected function adminInitModelsReady()
639
-    {
640
-        if (function_exists('wp_add_privacy_policy_content')) {
641
-            $this->getLoader()->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager');
642
-        }
643
-    }
644
-
645
-
646
-    /**
647
-     * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
648
-     *
649
-     * @param string $output Current output.
650
-     * @return string
651
-     * @throws InvalidArgumentException
652
-     * @throws InvalidDataTypeException
653
-     * @throws InvalidInterfaceException
654
-     */
655
-    public function modify_dropdown_pages($output)
656
-    {
657
-        // get critical pages
658
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
659
-
660
-        // split current output by line break for easier parsing.
661
-        $split_output = explode("\n", $output);
662
-
663
-        // loop through to remove any critical pages from the array.
664
-        foreach ($critical_pages as $page_id) {
665
-            $needle = 'value="' . $page_id . '"';
666
-            foreach ($split_output as $key => $haystack) {
667
-                if (strpos($haystack, $needle) !== false) {
668
-                    unset($split_output[ $key ]);
669
-                }
670
-            }
671
-        }
672
-        // replace output with the new contents
673
-        return implode("\n", $split_output);
674
-    }
675
-
676
-
677
-    /**
678
-     * enqueue all admin scripts that need loaded for admin pages
679
-     *
680
-     * @return void
681
-     */
682
-    public function enqueue_admin_scripts()
683
-    {
684
-        // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
685
-        // Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
686
-        // calls.
687
-        wp_enqueue_script(
688
-            'ee-inject-wp',
689
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
690
-            array('jquery'),
691
-            EVENT_ESPRESSO_VERSION,
692
-            true
693
-        );
694
-        // register cookie script for future dependencies
695
-        wp_register_script(
696
-            'jquery-cookie',
697
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
698
-            array('jquery'),
699
-            '2.1',
700
-            true
701
-        );
702
-        // joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again
703
-        // via: add_filter('FHEE_load_joyride', '__return_true' );
704
-        if (apply_filters('FHEE_load_joyride', false)) {
705
-            // joyride style
706
-            wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
707
-            wp_register_style(
708
-                'ee-joyride-css',
709
-                EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
710
-                array('joyride-css'),
711
-                EVENT_ESPRESSO_VERSION
712
-            );
713
-            wp_register_script(
714
-                'joyride-modernizr',
715
-                EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
716
-                array(),
717
-                '2.1',
718
-                true
719
-            );
720
-            // joyride JS
721
-            wp_register_script(
722
-                'jquery-joyride',
723
-                EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
724
-                array('jquery-cookie', 'joyride-modernizr'),
725
-                '2.1',
726
-                true
727
-            );
728
-            // wanna go for a joyride?
729
-            wp_enqueue_style('ee-joyride-css');
730
-            wp_enqueue_script('jquery-joyride');
731
-        }
732
-    }
733
-
734
-
735
-    /**
736
-     * display_admin_notices
737
-     *
738
-     * @return void
739
-     */
740
-    public function display_admin_notices()
741
-    {
742
-        echo EE_Error::get_notices();
743
-    }
744
-
745
-
746
-    /**
747
-     * @param array $elements
748
-     * @return array
749
-     * @throws EE_Error
750
-     * @throws InvalidArgumentException
751
-     * @throws InvalidDataTypeException
752
-     * @throws InvalidInterfaceException
753
-     */
754
-    public function dashboard_glance_items($elements)
755
-    {
756
-        $elements = is_array($elements) ? $elements : array($elements);
757
-        $events = EEM_Event::instance()->count();
758
-        $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(
759
-            array('page' => 'espresso_events'),
760
-            admin_url('admin.php')
761
-        );
762
-        $items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events, 'event_espresso'), number_format_i18n($events));
763
-        $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso');
764
-        $registrations = EEM_Registration::instance()->count(
765
-            array(
766
-                array(
767
-                    'STS_ID' => array('!=', EEM_Registration::status_id_incomplete),
768
-                ),
769
-            )
770
-        );
771
-        $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(
772
-            array('page' => 'espresso_registrations'),
773
-            admin_url('admin.php')
774
-        );
775
-        $items['registrations']['text'] = sprintf(
776
-            _n('%s Registration', '%s Registrations', $registrations, 'event_espresso'),
777
-            number_format_i18n($registrations)
778
-        );
779
-        $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
780
-
781
-        $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
782
-
783
-        foreach ($items as $type => $item_properties) {
784
-            $elements[] = sprintf(
785
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
786
-                $item_properties['url'],
787
-                $item_properties['title'],
788
-                $item_properties['text']
789
-            );
790
-        }
791
-        return $elements;
792
-    }
793
-
794
-
795
-    /**
796
-     * check_for_invalid_datetime_formats
797
-     * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
798
-     * their selected format can be parsed by PHP
799
-     *
800
-     * @param    $value
801
-     * @param    $option
802
-     * @throws EE_Error
803
-     * @return    string
804
-     */
805
-    public function check_for_invalid_datetime_formats($value, $option)
806
-    {
807
-        // check for date_format or time_format
808
-        switch ($option) {
809
-            case 'date_format':
810
-                $date_time_format = $value . ' ' . get_option('time_format');
811
-                break;
812
-            case 'time_format':
813
-                $date_time_format = get_option('date_format') . ' ' . $value;
814
-                break;
815
-            default:
816
-                $date_time_format = false;
817
-        }
818
-        // do we have a date_time format to check ?
819
-        if ($date_time_format) {
820
-            $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
821
-
822
-            if (is_array($error_msg)) {
823
-                $msg = '<p>'
824
-                       . sprintf(
825
-                           esc_html__(
826
-                               'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
827
-                               'event_espresso'
828
-                           ),
829
-                           date($date_time_format),
830
-                           $date_time_format
831
-                       )
832
-                       . '</p><p><ul>';
833
-
834
-
835
-                foreach ($error_msg as $error) {
836
-                    $msg .= '<li>' . $error . '</li>';
837
-                }
838
-
839
-                $msg .= '</ul></p><p>'
840
-                        . sprintf(
841
-                            esc_html__(
842
-                                '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
843
-                                'event_espresso'
844
-                            ),
845
-                            '<span style="color:#D54E21;">',
846
-                            '</span>'
847
-                        )
848
-                        . '</p>';
849
-
850
-                // trigger WP settings error
851
-                add_settings_error(
852
-                    'date_format',
853
-                    'date_format',
854
-                    $msg
855
-                );
856
-
857
-                // set format to something valid
858
-                switch ($option) {
859
-                    case 'date_format':
860
-                        $value = 'F j, Y';
861
-                        break;
862
-                    case 'time_format':
863
-                        $value = 'g:i a';
864
-                        break;
865
-                }
866
-            }
867
-        }
868
-        return $value;
869
-    }
870
-
871
-
872
-    /**
873
-     * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
874
-     *
875
-     * @param $content
876
-     * @return    string
877
-     */
878
-    public function its_eSpresso($content)
879
-    {
880
-        return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
881
-    }
882
-
883
-
884
-    /**
885
-     * espresso_admin_footer
886
-     *
887
-     * @return    string
888
-     */
889
-    public function espresso_admin_footer()
890
-    {
891
-        return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer'));
892
-    }
893
-
894
-
895
-    /**
896
-     * static method for registering ee admin page.
897
-     * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
898
-     *
899
-     * @since      4.3.0
900
-     * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
901
-     * @see        EE_Register_Admin_Page::register()
902
-     * @param       $page_basename
903
-     * @param       $page_path
904
-     * @param array $config
905
-     * @return void
906
-     * @throws EE_Error
907
-     */
908
-    public static function register_ee_admin_page($page_basename, $page_path, $config = array())
909
-    {
910
-        EE_Error::doing_it_wrong(
911
-            __METHOD__,
912
-            sprintf(
913
-                esc_html__(
914
-                    'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
915
-                    'event_espresso'
916
-                ),
917
-                $page_basename
918
-            ),
919
-            '4.3'
920
-        );
921
-        if (class_exists('EE_Register_Admin_Page')) {
922
-            $config['page_path'] = $page_path;
923
-        }
924
-        EE_Register_Admin_Page::register($page_basename, $config);
925
-    }
926
-
927
-
928
-    /**
929
-     * @deprecated 4.8.41
930
-     * @param  int      $post_ID
931
-     * @param  \WP_Post $post
932
-     * @return void
933
-     */
934
-    public static function parse_post_content_on_save($post_ID, $post)
935
-    {
936
-        EE_Error::doing_it_wrong(
937
-            __METHOD__,
938
-            esc_html__('Usage is deprecated', 'event_espresso'),
939
-            '4.8.41'
940
-        );
941
-    }
942
-
943
-
944
-    /**
945
-     * @deprecated 4.8.41
946
-     * @param  $option
947
-     * @param  $old_value
948
-     * @param  $value
949
-     * @return void
950
-     */
951
-    public function reset_page_for_posts_on_change($option, $old_value, $value)
952
-    {
953
-        EE_Error::doing_it_wrong(
954
-            __METHOD__,
955
-            esc_html__('Usage is deprecated', 'event_espresso'),
956
-            '4.8.41'
957
-        );
958
-    }
959
-
960
-
961
-    /**
962
-     * @deprecated 4.9.27
963
-     * @return void
964
-     */
965
-    public function get_persistent_admin_notices()
966
-    {
967
-        EE_Error::doing_it_wrong(
968
-            __METHOD__,
969
-            sprintf(
970
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
971
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
972
-            ),
973
-            '4.9.27'
974
-        );
975
-    }
976
-
977
-
978
-    /**
979
-     * @deprecated 4.9.27
980
-     * @throws InvalidInterfaceException
981
-     * @throws InvalidDataTypeException
982
-     * @throws DomainException
983
-     */
984
-    public function dismiss_ee_nag_notice_callback()
985
-    {
986
-        EE_Error::doing_it_wrong(
987
-            __METHOD__,
988
-            sprintf(
989
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
990
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
991
-            ),
992
-            '4.9.27'
993
-        );
994
-        $this->persistent_admin_notice_manager->dismissNotice();
995
-    }
996
-
997
-
998
-    /**
999
-     * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.
1000
-     *
1001
-     * @throws InvalidArgumentException
1002
-     * @throws InvalidDataTypeException
1003
-     * @throws InvalidInterfaceException
1004
-     */
1005
-    public function hookIntoWpPluginsPage()
1006
-    {
1007
-        $this->getLoader()->getShared('EventEspresso\core\domain\services\admin\ExitModal');
1008
-        $this->getLoader()
1009
-                     ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells')
1010
-                     ->decafUpsells();
1011
-    }
516
+	}
517
+
518
+
519
+	/**
520
+	 * Returns an array of event archive nav items.
521
+	 *
522
+	 * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
523
+	 *        method we use for getting the extra nav menu items
524
+	 * @return array
525
+	 */
526
+	private function _get_extra_nav_menu_pages_items()
527
+	{
528
+		$menuitems[] = array(
529
+			'title'       => esc_html__('Event List', 'event_espresso'),
530
+			'url'         => get_post_type_archive_link('espresso_events'),
531
+			'description' => esc_html__('Archive page for all events.', 'event_espresso'),
532
+		);
533
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
534
+	}
535
+
536
+
537
+	/**
538
+	 * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
539
+	 * the properties and converts it to the menu item object.
540
+	 *
541
+	 * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
542
+	 * @param $menu_item_values
543
+	 * @return stdClass
544
+	 */
545
+	private function _setup_extra_nav_menu_pages_items($menu_item_values)
546
+	{
547
+		$menu_item = new stdClass();
548
+		$keys = array(
549
+			'ID'               => 0,
550
+			'db_id'            => 0,
551
+			'menu_item_parent' => 0,
552
+			'object_id'        => -1,
553
+			'post_parent'      => 0,
554
+			'type'             => 'custom',
555
+			'object'           => '',
556
+			'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
557
+			'title'            => '',
558
+			'url'              => '',
559
+			'target'           => '',
560
+			'attr_title'       => '',
561
+			'description'      => '',
562
+			'classes'          => array(),
563
+			'xfn'              => '',
564
+		);
565
+
566
+		foreach ($keys as $key => $value) {
567
+			$menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
568
+		}
569
+		return $menu_item;
570
+	}
571
+
572
+
573
+	/**
574
+	 * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
575
+	 * EE_Admin_Page route is called.
576
+	 *
577
+	 * @return void
578
+	 */
579
+	public function route_admin_request()
580
+	{
581
+	}
582
+
583
+
584
+	/**
585
+	 * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
586
+	 *
587
+	 * @return void
588
+	 */
589
+	public function wp_loaded()
590
+	{
591
+	}
592
+
593
+
594
+	/**
595
+	 * admin_init
596
+	 *
597
+	 * @return void
598
+	 * @throws EE_Error
599
+	 * @throws InvalidArgumentException
600
+	 * @throws InvalidDataTypeException
601
+	 * @throws InvalidInterfaceException
602
+	 * @throws ReflectionException
603
+	 */
604
+	public function admin_init()
605
+	{
606
+		/**
607
+		 * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
608
+		 * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
609
+		 * - check if doing post processing.
610
+		 * - check if doing post processing of one of EE CPTs
611
+		 * - instantiate the corresponding EE CPT model for the post_type being processed.
612
+		 */
613
+		if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
614
+			/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
615
+			$custom_post_types = $this->getLoader()->getShared(
616
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
617
+			);
618
+			$custom_post_types->getCustomPostTypeModels($_POST['post_type']);
619
+		}
620
+
621
+
622
+		/**
623
+		 * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
624
+		 * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
625
+		 * Pages" tab in the EE General Settings Admin page.
626
+		 * This is for user-proofing.
627
+		 */
628
+		add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
629
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
630
+			$this->adminInitModelsReady();
631
+		}
632
+	}
633
+
634
+
635
+	/**
636
+	 * Runs on admin_init but only if models are usable (ie, we're not in maintenanc emode)
637
+	 */
638
+	protected function adminInitModelsReady()
639
+	{
640
+		if (function_exists('wp_add_privacy_policy_content')) {
641
+			$this->getLoader()->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager');
642
+		}
643
+	}
644
+
645
+
646
+	/**
647
+	 * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
648
+	 *
649
+	 * @param string $output Current output.
650
+	 * @return string
651
+	 * @throws InvalidArgumentException
652
+	 * @throws InvalidDataTypeException
653
+	 * @throws InvalidInterfaceException
654
+	 */
655
+	public function modify_dropdown_pages($output)
656
+	{
657
+		// get critical pages
658
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
659
+
660
+		// split current output by line break for easier parsing.
661
+		$split_output = explode("\n", $output);
662
+
663
+		// loop through to remove any critical pages from the array.
664
+		foreach ($critical_pages as $page_id) {
665
+			$needle = 'value="' . $page_id . '"';
666
+			foreach ($split_output as $key => $haystack) {
667
+				if (strpos($haystack, $needle) !== false) {
668
+					unset($split_output[ $key ]);
669
+				}
670
+			}
671
+		}
672
+		// replace output with the new contents
673
+		return implode("\n", $split_output);
674
+	}
675
+
676
+
677
+	/**
678
+	 * enqueue all admin scripts that need loaded for admin pages
679
+	 *
680
+	 * @return void
681
+	 */
682
+	public function enqueue_admin_scripts()
683
+	{
684
+		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
685
+		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
686
+		// calls.
687
+		wp_enqueue_script(
688
+			'ee-inject-wp',
689
+			EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
690
+			array('jquery'),
691
+			EVENT_ESPRESSO_VERSION,
692
+			true
693
+		);
694
+		// register cookie script for future dependencies
695
+		wp_register_script(
696
+			'jquery-cookie',
697
+			EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
698
+			array('jquery'),
699
+			'2.1',
700
+			true
701
+		);
702
+		// joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again
703
+		// via: add_filter('FHEE_load_joyride', '__return_true' );
704
+		if (apply_filters('FHEE_load_joyride', false)) {
705
+			// joyride style
706
+			wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
707
+			wp_register_style(
708
+				'ee-joyride-css',
709
+				EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
710
+				array('joyride-css'),
711
+				EVENT_ESPRESSO_VERSION
712
+			);
713
+			wp_register_script(
714
+				'joyride-modernizr',
715
+				EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
716
+				array(),
717
+				'2.1',
718
+				true
719
+			);
720
+			// joyride JS
721
+			wp_register_script(
722
+				'jquery-joyride',
723
+				EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
724
+				array('jquery-cookie', 'joyride-modernizr'),
725
+				'2.1',
726
+				true
727
+			);
728
+			// wanna go for a joyride?
729
+			wp_enqueue_style('ee-joyride-css');
730
+			wp_enqueue_script('jquery-joyride');
731
+		}
732
+	}
733
+
734
+
735
+	/**
736
+	 * display_admin_notices
737
+	 *
738
+	 * @return void
739
+	 */
740
+	public function display_admin_notices()
741
+	{
742
+		echo EE_Error::get_notices();
743
+	}
744
+
745
+
746
+	/**
747
+	 * @param array $elements
748
+	 * @return array
749
+	 * @throws EE_Error
750
+	 * @throws InvalidArgumentException
751
+	 * @throws InvalidDataTypeException
752
+	 * @throws InvalidInterfaceException
753
+	 */
754
+	public function dashboard_glance_items($elements)
755
+	{
756
+		$elements = is_array($elements) ? $elements : array($elements);
757
+		$events = EEM_Event::instance()->count();
758
+		$items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(
759
+			array('page' => 'espresso_events'),
760
+			admin_url('admin.php')
761
+		);
762
+		$items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events, 'event_espresso'), number_format_i18n($events));
763
+		$items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso');
764
+		$registrations = EEM_Registration::instance()->count(
765
+			array(
766
+				array(
767
+					'STS_ID' => array('!=', EEM_Registration::status_id_incomplete),
768
+				),
769
+			)
770
+		);
771
+		$items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(
772
+			array('page' => 'espresso_registrations'),
773
+			admin_url('admin.php')
774
+		);
775
+		$items['registrations']['text'] = sprintf(
776
+			_n('%s Registration', '%s Registrations', $registrations, 'event_espresso'),
777
+			number_format_i18n($registrations)
778
+		);
779
+		$items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
780
+
781
+		$items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
782
+
783
+		foreach ($items as $type => $item_properties) {
784
+			$elements[] = sprintf(
785
+				'<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
786
+				$item_properties['url'],
787
+				$item_properties['title'],
788
+				$item_properties['text']
789
+			);
790
+		}
791
+		return $elements;
792
+	}
793
+
794
+
795
+	/**
796
+	 * check_for_invalid_datetime_formats
797
+	 * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
798
+	 * their selected format can be parsed by PHP
799
+	 *
800
+	 * @param    $value
801
+	 * @param    $option
802
+	 * @throws EE_Error
803
+	 * @return    string
804
+	 */
805
+	public function check_for_invalid_datetime_formats($value, $option)
806
+	{
807
+		// check for date_format or time_format
808
+		switch ($option) {
809
+			case 'date_format':
810
+				$date_time_format = $value . ' ' . get_option('time_format');
811
+				break;
812
+			case 'time_format':
813
+				$date_time_format = get_option('date_format') . ' ' . $value;
814
+				break;
815
+			default:
816
+				$date_time_format = false;
817
+		}
818
+		// do we have a date_time format to check ?
819
+		if ($date_time_format) {
820
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
821
+
822
+			if (is_array($error_msg)) {
823
+				$msg = '<p>'
824
+					   . sprintf(
825
+						   esc_html__(
826
+							   'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
827
+							   'event_espresso'
828
+						   ),
829
+						   date($date_time_format),
830
+						   $date_time_format
831
+					   )
832
+					   . '</p><p><ul>';
833
+
834
+
835
+				foreach ($error_msg as $error) {
836
+					$msg .= '<li>' . $error . '</li>';
837
+				}
838
+
839
+				$msg .= '</ul></p><p>'
840
+						. sprintf(
841
+							esc_html__(
842
+								'%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
843
+								'event_espresso'
844
+							),
845
+							'<span style="color:#D54E21;">',
846
+							'</span>'
847
+						)
848
+						. '</p>';
849
+
850
+				// trigger WP settings error
851
+				add_settings_error(
852
+					'date_format',
853
+					'date_format',
854
+					$msg
855
+				);
856
+
857
+				// set format to something valid
858
+				switch ($option) {
859
+					case 'date_format':
860
+						$value = 'F j, Y';
861
+						break;
862
+					case 'time_format':
863
+						$value = 'g:i a';
864
+						break;
865
+				}
866
+			}
867
+		}
868
+		return $value;
869
+	}
870
+
871
+
872
+	/**
873
+	 * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
874
+	 *
875
+	 * @param $content
876
+	 * @return    string
877
+	 */
878
+	public function its_eSpresso($content)
879
+	{
880
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
881
+	}
882
+
883
+
884
+	/**
885
+	 * espresso_admin_footer
886
+	 *
887
+	 * @return    string
888
+	 */
889
+	public function espresso_admin_footer()
890
+	{
891
+		return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer'));
892
+	}
893
+
894
+
895
+	/**
896
+	 * static method for registering ee admin page.
897
+	 * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
898
+	 *
899
+	 * @since      4.3.0
900
+	 * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
901
+	 * @see        EE_Register_Admin_Page::register()
902
+	 * @param       $page_basename
903
+	 * @param       $page_path
904
+	 * @param array $config
905
+	 * @return void
906
+	 * @throws EE_Error
907
+	 */
908
+	public static function register_ee_admin_page($page_basename, $page_path, $config = array())
909
+	{
910
+		EE_Error::doing_it_wrong(
911
+			__METHOD__,
912
+			sprintf(
913
+				esc_html__(
914
+					'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
915
+					'event_espresso'
916
+				),
917
+				$page_basename
918
+			),
919
+			'4.3'
920
+		);
921
+		if (class_exists('EE_Register_Admin_Page')) {
922
+			$config['page_path'] = $page_path;
923
+		}
924
+		EE_Register_Admin_Page::register($page_basename, $config);
925
+	}
926
+
927
+
928
+	/**
929
+	 * @deprecated 4.8.41
930
+	 * @param  int      $post_ID
931
+	 * @param  \WP_Post $post
932
+	 * @return void
933
+	 */
934
+	public static function parse_post_content_on_save($post_ID, $post)
935
+	{
936
+		EE_Error::doing_it_wrong(
937
+			__METHOD__,
938
+			esc_html__('Usage is deprecated', 'event_espresso'),
939
+			'4.8.41'
940
+		);
941
+	}
942
+
943
+
944
+	/**
945
+	 * @deprecated 4.8.41
946
+	 * @param  $option
947
+	 * @param  $old_value
948
+	 * @param  $value
949
+	 * @return void
950
+	 */
951
+	public function reset_page_for_posts_on_change($option, $old_value, $value)
952
+	{
953
+		EE_Error::doing_it_wrong(
954
+			__METHOD__,
955
+			esc_html__('Usage is deprecated', 'event_espresso'),
956
+			'4.8.41'
957
+		);
958
+	}
959
+
960
+
961
+	/**
962
+	 * @deprecated 4.9.27
963
+	 * @return void
964
+	 */
965
+	public function get_persistent_admin_notices()
966
+	{
967
+		EE_Error::doing_it_wrong(
968
+			__METHOD__,
969
+			sprintf(
970
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
971
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
972
+			),
973
+			'4.9.27'
974
+		);
975
+	}
976
+
977
+
978
+	/**
979
+	 * @deprecated 4.9.27
980
+	 * @throws InvalidInterfaceException
981
+	 * @throws InvalidDataTypeException
982
+	 * @throws DomainException
983
+	 */
984
+	public function dismiss_ee_nag_notice_callback()
985
+	{
986
+		EE_Error::doing_it_wrong(
987
+			__METHOD__,
988
+			sprintf(
989
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
990
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
991
+			),
992
+			'4.9.27'
993
+		);
994
+		$this->persistent_admin_notice_manager->dismissNotice();
995
+	}
996
+
997
+
998
+	/**
999
+	 * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.
1000
+	 *
1001
+	 * @throws InvalidArgumentException
1002
+	 * @throws InvalidDataTypeException
1003
+	 * @throws InvalidInterfaceException
1004
+	 */
1005
+	public function hookIntoWpPluginsPage()
1006
+	{
1007
+		$this->getLoader()->getShared('EventEspresso\core\domain\services\admin\ExitModal');
1008
+		$this->getLoader()
1009
+					 ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells')
1010
+					 ->decafUpsells();
1011
+	}
1012 1012
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public static function instance()
44 44
     {
45 45
         // check if class object is instantiated
46
-        if (! self::$_instance instanceof EE_Admin) {
46
+        if ( ! self::$_instance instanceof EE_Admin) {
47 47
             self::$_instance = new self();
48 48
         }
49 49
         return self::$_instance;
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
      */
104 104
     private function _define_all_constants()
105 105
     {
106
-        if (! defined('EE_ADMIN_URL')) {
107
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
108
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
109
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
110
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
106
+        if ( ! defined('EE_ADMIN_URL')) {
107
+            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/');
108
+            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/');
109
+            define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS);
110
+            define('WP_ADMIN_PATH', ABSPATH.'wp-admin/');
111 111
             define('WP_AJAX_URL', admin_url('admin-ajax.php'));
112 112
         }
113 113
     }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         // set $main_file in stone
126 126
         static $main_file;
127 127
         // if $main_file is not set yet
128
-        if (! $main_file) {
128
+        if ( ! $main_file) {
129 129
             $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
130 130
         }
131 131
         if ($plugin === $main_file) {
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
     public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
178 178
     {
179 179
         return array(
180
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
181
-            'about'       => EE_ADMIN_PAGES . 'about' . DS,
182
-            'support'     => EE_ADMIN_PAGES . 'support' . DS,
180
+            'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS,
181
+            'about'       => EE_ADMIN_PAGES.'about'.DS,
182
+            'support'     => EE_ADMIN_PAGES.'support'.DS,
183 183
         );
184 184
     }
185 185
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
             $this->initModelsReady();
204 204
         }
205 205
         // run the admin page factory but ONLY if we are doing an ee admin ajax request
206
-        if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
206
+        if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
207 207
             try {
208 208
                 // this loads the controller for the admin pages which will setup routing etc
209 209
                 EE_Registry::instance()->load_core('Admin_Page_Loader');
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
      */
230 230
     protected function getLoader()
231 231
     {
232
-        if (! $this->loader instanceof LoaderInterface) {
232
+        if ( ! $this->loader instanceof LoaderInterface) {
233 233
             $this->loader = LoaderFactory::getLoader();
234 234
         }
235 235
         return $this->loader;
@@ -296,13 +296,13 @@  discard block
 block discarded – undo
296 296
                     '</strong>',
297 297
                     '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
298 298
                     '</a>',
299
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
299
+                    '<a href="'.EE_Admin_Page::add_query_args_and_nonce(
300 300
                         array(
301 301
                             'page'   => 'espresso_maintenance_settings',
302 302
                             'action' => 'datetime_tools',
303 303
                         ),
304 304
                         admin_url('admin.php')
305
-                    ) . '">'
305
+                    ).'">'
306 306
                 ),
307 307
                 false,
308 308
                 'manage_options',
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
     public function enable_hidden_ee_nav_menu_metaboxes()
349 349
     {
350 350
         global $wp_meta_boxes, $pagenow;
351
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
351
+        if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
352 352
             return;
353 353
         }
354 354
         $user = wp_get_current_user();
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
         if (is_array($hidden_meta_boxes)) {
378 378
             foreach ($hidden_meta_boxes as $key => $meta_box_id) {
379 379
                 if (in_array($meta_box_id, $initial_meta_boxes, true)) {
380
-                    unset($hidden_meta_boxes[ $key ]);
380
+                    unset($hidden_meta_boxes[$key]);
381 381
                 }
382 382
             }
383 383
         }
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
      */
418 418
     public function modify_edit_post_link($link, $id)
419 419
     {
420
-        if (! $post = get_post($id)) {
420
+        if ( ! $post = get_post($id)) {
421 421
             return $link;
422 422
         }
423 423
         if ($post->post_type === 'espresso_attendees') {
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
         );
565 565
 
566 566
         foreach ($keys as $key => $value) {
567
-            $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
567
+            $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
568 568
         }
569 569
         return $menu_item;
570 570
     }
@@ -662,10 +662,10 @@  discard block
 block discarded – undo
662 662
 
663 663
         // loop through to remove any critical pages from the array.
664 664
         foreach ($critical_pages as $page_id) {
665
-            $needle = 'value="' . $page_id . '"';
665
+            $needle = 'value="'.$page_id.'"';
666 666
             foreach ($split_output as $key => $haystack) {
667 667
                 if (strpos($haystack, $needle) !== false) {
668
-                    unset($split_output[ $key ]);
668
+                    unset($split_output[$key]);
669 669
                 }
670 670
             }
671 671
         }
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
         // calls.
687 687
         wp_enqueue_script(
688 688
             'ee-inject-wp',
689
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
689
+            EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js',
690 690
             array('jquery'),
691 691
             EVENT_ESPRESSO_VERSION,
692 692
             true
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
         // register cookie script for future dependencies
695 695
         wp_register_script(
696 696
             'jquery-cookie',
697
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
697
+            EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js',
698 698
             array('jquery'),
699 699
             '2.1',
700 700
             true
@@ -703,16 +703,16 @@  discard block
 block discarded – undo
703 703
         // via: add_filter('FHEE_load_joyride', '__return_true' );
704 704
         if (apply_filters('FHEE_load_joyride', false)) {
705 705
             // joyride style
706
-            wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
706
+            wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1');
707 707
             wp_register_style(
708 708
                 'ee-joyride-css',
709
-                EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
709
+                EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css',
710 710
                 array('joyride-css'),
711 711
                 EVENT_ESPRESSO_VERSION
712 712
             );
713 713
             wp_register_script(
714 714
                 'joyride-modernizr',
715
-                EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
715
+                EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js',
716 716
                 array(),
717 717
                 '2.1',
718 718
                 true
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
             // joyride JS
721 721
             wp_register_script(
722 722
                 'jquery-joyride',
723
-                EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
723
+                EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js',
724 724
                 array('jquery-cookie', 'joyride-modernizr'),
725 725
                 '2.1',
726 726
                 true
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 
783 783
         foreach ($items as $type => $item_properties) {
784 784
             $elements[] = sprintf(
785
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
785
+                '<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>',
786 786
                 $item_properties['url'],
787 787
                 $item_properties['title'],
788 788
                 $item_properties['text']
@@ -807,10 +807,10 @@  discard block
 block discarded – undo
807 807
         // check for date_format or time_format
808 808
         switch ($option) {
809 809
             case 'date_format':
810
-                $date_time_format = $value . ' ' . get_option('time_format');
810
+                $date_time_format = $value.' '.get_option('time_format');
811 811
                 break;
812 812
             case 'time_format':
813
-                $date_time_format = get_option('date_format') . ' ' . $value;
813
+                $date_time_format = get_option('date_format').' '.$value;
814 814
                 break;
815 815
             default:
816 816
                 $date_time_format = false;
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 
834 834
 
835 835
                 foreach ($error_msg as $error) {
836
-                    $msg .= '<li>' . $error . '</li>';
836
+                    $msg .= '<li>'.$error.'</li>';
837 837
                 }
838 838
 
839 839
                 $msg .= '</ul></p><p>'
Please login to merge, or discard this patch.
core/EE_Session.core.php 2 patches
Indentation   +1239 added lines, -1239 removed lines patch added patch discarded remove patch
@@ -23,1237 +23,1237 @@  discard block
 block discarded – undo
23 23
 class EE_Session implements SessionIdentifierInterface
24 24
 {
25 25
 
26
-    const session_id_prefix = 'ee_ssn_';
27
-
28
-    const hash_check_prefix = 'ee_shc_';
29
-
30
-    const OPTION_NAME_SETTINGS = 'ee_session_settings';
31
-
32
-    const STATUS_CLOSED = 0;
33
-
34
-    const STATUS_OPEN = 1;
35
-
36
-    /**
37
-     * instance of the EE_Session object
38
-     *
39
-     * @var EE_Session
40
-     */
41
-    private static $_instance;
42
-
43
-    /**
44
-     * @var CacheStorageInterface $cache_storage
45
-     */
46
-    protected $cache_storage;
47
-
48
-    /**
49
-     * EE_Encryption object
50
-     *
51
-     * @var EE_Encryption
52
-     */
53
-    protected $encryption;
54
-
55
-    /**
56
-     * the session id
57
-     *
58
-     * @var string
59
-     */
60
-    private $_sid;
61
-
62
-    /**
63
-     * session id salt
64
-     *
65
-     * @var string
66
-     */
67
-    private $_sid_salt;
68
-
69
-    /**
70
-     * session data
71
-     *
72
-     * @var array
73
-     */
74
-    private $_session_data = array();
75
-
76
-    /**
77
-     * how long an EE session lasts
78
-     * default session lifespan of 1 hour (for not so instant IPNs)
79
-     *
80
-     * @var SessionLifespan $session_lifespan
81
-     */
82
-    private $session_lifespan;
83
-
84
-    /**
85
-     * session expiration time as Unix timestamp in GMT
86
-     *
87
-     * @var int
88
-     */
89
-    private $_expiration;
90
-
91
-    /**
92
-     * whether or not session has expired at some point
93
-     *
94
-     * @var boolean
95
-     */
96
-    private $_expired = false;
97
-
98
-    /**
99
-     * current time as Unix timestamp in GMT
100
-     *
101
-     * @var int
102
-     */
103
-    private $_time;
104
-
105
-    /**
106
-     * whether to encrypt session data
107
-     *
108
-     * @var bool
109
-     */
110
-    private $_use_encryption;
111
-
112
-    /**
113
-     * well... according to the server...
114
-     *
115
-     * @var null
116
-     */
117
-    private $_user_agent;
118
-
119
-    /**
120
-     * do you really trust the server ?
121
-     *
122
-     * @var null
123
-     */
124
-    private $_ip_address;
125
-
126
-    /**
127
-     * current WP user_id
128
-     *
129
-     * @var null
130
-     */
131
-    private $_wp_user_id;
132
-
133
-    /**
134
-     * array for defining default session vars
135
-     *
136
-     * @var array
137
-     */
138
-    private $_default_session_vars = array(
139
-        'id'            => null,
140
-        'user_id'       => null,
141
-        'ip_address'    => null,
142
-        'user_agent'    => null,
143
-        'init_access'   => null,
144
-        'last_access'   => null,
145
-        'expiration'    => null,
146
-        'pages_visited' => array(),
147
-    );
148
-
149
-    /**
150
-     * timestamp for when last garbage collection cycle was performed
151
-     *
152
-     * @var int $_last_gc
153
-     */
154
-    private $_last_gc;
155
-
156
-    /**
157
-     * @var RequestInterface $request
158
-     */
159
-    protected $request;
160
-
161
-    /**
162
-     * whether session is active or not
163
-     *
164
-     * @var int $status
165
-     */
166
-    private $status = EE_Session::STATUS_CLOSED;
167
-
168
-
169
-    /**
170
-     * @singleton method used to instantiate class object
171
-     * @param CacheStorageInterface $cache_storage
172
-     * @param SessionLifespan|null  $lifespan
173
-     * @param RequestInterface      $request
174
-     * @param EE_Encryption         $encryption
175
-     * @return EE_Session
176
-     * @throws InvalidArgumentException
177
-     * @throws InvalidDataTypeException
178
-     * @throws InvalidInterfaceException
179
-     */
180
-    public static function instance(
181
-        CacheStorageInterface $cache_storage = null,
182
-        SessionLifespan $lifespan = null,
183
-        RequestInterface $request = null,
184
-        EE_Encryption $encryption = null
185
-    ) {
186
-        // check if class object is instantiated
187
-        // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via:
188
-        // add_filter( 'FHEE_load_EE_Session', '__return_false' );
189
-        if (! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) {
190
-            self::$_instance = new self(
191
-                $cache_storage,
192
-                $lifespan,
193
-                $request,
194
-                $encryption
195
-            );
196
-        }
197
-        return self::$_instance;
198
-    }
199
-
200
-
201
-    /**
202
-     * protected constructor to prevent direct creation
203
-     *
204
-     * @param CacheStorageInterface $cache_storage
205
-     * @param SessionLifespan       $lifespan
206
-     * @param RequestInterface      $request
207
-     * @param EE_Encryption         $encryption
208
-     * @throws InvalidArgumentException
209
-     * @throws InvalidDataTypeException
210
-     * @throws InvalidInterfaceException
211
-     */
212
-    protected function __construct(
213
-        CacheStorageInterface $cache_storage,
214
-        SessionLifespan $lifespan,
215
-        RequestInterface $request,
216
-        EE_Encryption $encryption = null
217
-    ) {
218
-        // session loading is turned ON by default,
219
-        // but prior to the 'AHEE__EE_System__core_loaded_and_ready' hook
220
-        // (which currently fires on the init hook at priority 9),
221
-        // can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' );
222
-        if (! apply_filters('FHEE_load_EE_Session', true)) {
223
-            return;
224
-        }
225
-        $this->session_lifespan = $lifespan;
226
-        $this->request = $request;
227
-        if (! defined('ESPRESSO_SESSION')) {
228
-            define('ESPRESSO_SESSION', true);
229
-        }
230
-        // retrieve session options from db
231
-        $session_settings = (array) get_option(EE_Session::OPTION_NAME_SETTINGS, array());
232
-        if (! empty($session_settings)) {
233
-            // cycle though existing session options
234
-            foreach ($session_settings as $var_name => $session_setting) {
235
-                // set values for class properties
236
-                $var_name = '_' . $var_name;
237
-                $this->{$var_name} = $session_setting;
238
-            }
239
-        }
240
-        $this->cache_storage = $cache_storage;
241
-        // are we using encryption?
242
-        $this->_use_encryption = $encryption instanceof EE_Encryption
243
-                                 && EE_Registry::instance()->CFG->admin->encode_session_data();
244
-        // encrypt data via: $this->encryption->encrypt();
245
-        $this->encryption = $encryption;
246
-        // filter hook allows outside functions/classes/plugins to change default empty cart
247
-        $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array());
248
-        array_merge($this->_default_session_vars, $extra_default_session_vars);
249
-        // apply default session vars
250
-        $this->_set_defaults();
251
-        add_action('AHEE__EE_System__initialize', array($this, 'open_session'));
252
-        // check request for 'clear_session' param
253
-        add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded'));
254
-        // once everything is all said and done,
255
-        add_action('shutdown', array($this, 'update'), 100);
256
-        add_action('shutdown', array($this, 'garbageCollection'), 1000);
257
-        $this->configure_garbage_collection_filters();
258
-    }
259
-
260
-
261
-    /**
262
-     * @return bool
263
-     * @throws InvalidArgumentException
264
-     * @throws InvalidDataTypeException
265
-     * @throws InvalidInterfaceException
266
-     */
267
-    public static function isLoadedAndActive()
268
-    {
269
-        return did_action('AHEE__EE_System__core_loaded_and_ready')
270
-               && EE_Session::instance() instanceof EE_Session
271
-               && EE_Session::instance()->isActive();
272
-    }
273
-
274
-
275
-    /**
276
-     * @return bool
277
-     */
278
-    public function isActive()
279
-    {
280
-        return $this->status === EE_Session::STATUS_OPEN;
281
-    }
282
-
283
-
284
-    /**
285
-     * @return void
286
-     * @throws EE_Error
287
-     * @throws InvalidArgumentException
288
-     * @throws InvalidDataTypeException
289
-     * @throws InvalidInterfaceException
290
-     * @throws InvalidSessionDataException
291
-     */
292
-    public function open_session()
293
-    {
294
-        // check for existing session and retrieve it from db
295
-        if (! $this->_espresso_session()) {
296
-            // or just start a new one
297
-            $this->_create_espresso_session();
298
-        }
299
-    }
300
-
301
-
302
-    /**
303
-     * @return bool
304
-     */
305
-    public function expired()
306
-    {
307
-        return $this->_expired;
308
-    }
309
-
310
-
311
-    /**
312
-     * @return void
313
-     */
314
-    public function reset_expired()
315
-    {
316
-        $this->_expired = false;
317
-    }
318
-
319
-
320
-    /**
321
-     * @return int
322
-     */
323
-    public function expiration()
324
-    {
325
-        return $this->_expiration;
326
-    }
327
-
328
-
329
-    /**
330
-     * @return int
331
-     */
332
-    public function extension()
333
-    {
334
-        return apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS);
335
-    }
336
-
337
-
338
-    /**
339
-     * @param int $time number of seconds to add to session expiration
340
-     */
341
-    public function extend_expiration($time = 0)
342
-    {
343
-        $time = $time ? $time : $this->extension();
344
-        $this->_expiration += absint($time);
345
-    }
346
-
347
-
348
-    /**
349
-     * @return int
350
-     */
351
-    public function lifespan()
352
-    {
353
-        return $this->session_lifespan->inSeconds();
354
-    }
355
-
356
-
357
-    /**
358
-     * This just sets some defaults for the _session data property
359
-     *
360
-     * @access private
361
-     * @return void
362
-     */
363
-    private function _set_defaults()
364
-    {
365
-        // set some defaults
366
-        foreach ($this->_default_session_vars as $key => $default_var) {
367
-            if (is_array($default_var)) {
368
-                $this->_session_data[ $key ] = array();
369
-            } else {
370
-                $this->_session_data[ $key ] = '';
371
-            }
372
-        }
373
-    }
374
-
375
-
376
-    /**
377
-     * @retrieve  session data
378
-     * @access    public
379
-     * @return    string
380
-     */
381
-    public function id()
382
-    {
383
-        return $this->_sid;
384
-    }
385
-
386
-
387
-    /**
388
-     * @param \EE_Cart $cart
389
-     * @return bool
390
-     */
391
-    public function set_cart(EE_Cart $cart)
392
-    {
393
-        $this->_session_data['cart'] = $cart;
394
-        return true;
395
-    }
396
-
397
-
398
-    /**
399
-     * reset_cart
400
-     */
401
-    public function reset_cart()
402
-    {
403
-        do_action('AHEE__EE_Session__reset_cart__before_reset', $this);
404
-        $this->_session_data['cart'] = null;
405
-    }
406
-
407
-
408
-    /**
409
-     * @return \EE_Cart
410
-     */
411
-    public function cart()
412
-    {
413
-        return isset($this->_session_data['cart']) && $this->_session_data['cart'] instanceof EE_Cart
414
-            ? $this->_session_data['cart']
415
-            : null;
416
-    }
417
-
418
-
419
-    /**
420
-     * @param \EE_Checkout $checkout
421
-     * @return bool
422
-     */
423
-    public function set_checkout(EE_Checkout $checkout)
424
-    {
425
-        $this->_session_data['checkout'] = $checkout;
426
-        return true;
427
-    }
428
-
429
-
430
-    /**
431
-     * reset_checkout
432
-     */
433
-    public function reset_checkout()
434
-    {
435
-        do_action('AHEE__EE_Session__reset_checkout__before_reset', $this);
436
-        $this->_session_data['checkout'] = null;
437
-    }
438
-
439
-
440
-    /**
441
-     * @return \EE_Checkout
442
-     */
443
-    public function checkout()
444
-    {
445
-        return isset($this->_session_data['checkout']) && $this->_session_data['checkout'] instanceof EE_Checkout
446
-            ? $this->_session_data['checkout']
447
-            : null;
448
-    }
449
-
450
-
451
-    /**
452
-     * @param \EE_Transaction $transaction
453
-     * @return bool
454
-     * @throws EE_Error
455
-     */
456
-    public function set_transaction(EE_Transaction $transaction)
457
-    {
458
-        // first remove the session from the transaction before we save the transaction in the session
459
-        $transaction->set_txn_session_data(null);
460
-        $this->_session_data['transaction'] = $transaction;
461
-        return true;
462
-    }
463
-
464
-
465
-    /**
466
-     * reset_transaction
467
-     */
468
-    public function reset_transaction()
469
-    {
470
-        do_action('AHEE__EE_Session__reset_transaction__before_reset', $this);
471
-        $this->_session_data['transaction'] = null;
472
-    }
473
-
474
-
475
-    /**
476
-     * @return \EE_Transaction
477
-     */
478
-    public function transaction()
479
-    {
480
-        return isset($this->_session_data['transaction'])
481
-               && $this->_session_data['transaction'] instanceof EE_Transaction
482
-            ? $this->_session_data['transaction']
483
-            : null;
484
-    }
485
-
486
-
487
-    /**
488
-     * retrieve session data
489
-     *
490
-     * @param null $key
491
-     * @param bool $reset_cache
492
-     * @return array
493
-     */
494
-    public function get_session_data($key = null, $reset_cache = false)
495
-    {
496
-        if ($reset_cache) {
497
-            $this->reset_cart();
498
-            $this->reset_checkout();
499
-            $this->reset_transaction();
500
-        }
501
-        if (! empty($key)) {
502
-            return isset($this->_session_data[ $key ]) ? $this->_session_data[ $key ] : null;
503
-        }
504
-        return $this->_session_data;
505
-    }
506
-
507
-
508
-    /**
509
-     * Returns TRUE on success, FALSE on fail
510
-     *
511
-     * @param array $data
512
-     * @return bool
513
-     */
514
-    public function set_session_data($data)
515
-    {
516
-        // nothing ??? bad data ??? go home!
517
-        if (empty($data) || ! is_array($data)) {
518
-            EE_Error::add_error(
519
-                esc_html__(
520
-                    'No session data or invalid session data was provided.',
521
-                    'event_espresso'
522
-                ),
523
-                __FILE__,
524
-                __FUNCTION__,
525
-                __LINE__
526
-            );
527
-            return false;
528
-        }
529
-        foreach ($data as $key => $value) {
530
-            if (isset($this->_default_session_vars[ $key ])) {
531
-                EE_Error::add_error(
532
-                    sprintf(
533
-                        esc_html__(
534
-                            'Sorry! %s is a default session datum and can not be reset.',
535
-                            'event_espresso'
536
-                        ),
537
-                        $key
538
-                    ),
539
-                    __FILE__,
540
-                    __FUNCTION__,
541
-                    __LINE__
542
-                );
543
-                return false;
544
-            }
545
-            $this->_session_data[ $key ] = $value;
546
-        }
547
-        return true;
548
-    }
549
-
550
-
551
-    /**
552
-     * @initiate session
553
-     * @access   private
554
-     * @return TRUE on success, FALSE on fail
555
-     * @throws EE_Error
556
-     * @throws InvalidArgumentException
557
-     * @throws InvalidDataTypeException
558
-     * @throws InvalidInterfaceException
559
-     * @throws InvalidSessionDataException
560
-     */
561
-    private function _espresso_session()
562
-    {
563
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
564
-        // check that session has started
565
-        if (session_id() === '') {
566
-            // starts a new session if one doesn't already exist, or re-initiates an existing one
567
-            session_start();
568
-        }
569
-        $this->status = EE_Session::STATUS_OPEN;
570
-        // get our modified session ID
571
-        $this->_sid = $this->_generate_session_id();
572
-        // and the visitors IP
573
-        $this->_ip_address = $this->request->ipAddress();
574
-        // set the "user agent"
575
-        $this->_user_agent = $this->request->userAgent();
576
-        // now let's retrieve what's in the db
577
-        $session_data = $this->_retrieve_session_data();
578
-        if (! empty($session_data)) {
579
-            // get the current time in UTC
580
-            $this->_time = $this->_time !== null ? $this->_time : time();
581
-            // and reset the session expiration
582
-            $this->_expiration = isset($session_data['expiration'])
583
-                ? $session_data['expiration']
584
-                : $this->_time + $this->session_lifespan->inSeconds();
585
-        } else {
586
-            // set initial site access time and the session expiration
587
-            $this->_set_init_access_and_expiration();
588
-            // set referer
589
-            $this->_session_data['pages_visited'][ $this->_session_data['init_access'] ] = isset($_SERVER['HTTP_REFERER'])
590
-                ? esc_attr($_SERVER['HTTP_REFERER'])
591
-                : '';
592
-            // no previous session = go back and create one (on top of the data above)
593
-            return false;
594
-        }
595
-        // now the user agent
596
-        if ($session_data['user_agent'] !== $this->_user_agent) {
597
-            return false;
598
-        }
599
-        // wait a minute... how old are you?
600
-        if ($this->_time > $this->_expiration) {
601
-            // yer too old fer me!
602
-            $this->_expired = true;
603
-            // wipe out everything that isn't a default session datum
604
-            $this->clear_session(__CLASS__, __FUNCTION__);
605
-        }
606
-        // make event espresso session data available to plugin
607
-        $this->_session_data = array_merge($this->_session_data, $session_data);
608
-        return true;
609
-    }
610
-
611
-
612
-    /**
613
-     * _get_session_data
614
-     * Retrieves the session data, and attempts to correct any encoding issues that can occur due to improperly setup
615
-     * databases
616
-     *
617
-     * @return array
618
-     * @throws EE_Error
619
-     * @throws InvalidArgumentException
620
-     * @throws InvalidSessionDataException
621
-     * @throws InvalidDataTypeException
622
-     * @throws InvalidInterfaceException
623
-     */
624
-    protected function _retrieve_session_data()
625
-    {
626
-        $ssn_key = EE_Session::session_id_prefix . $this->_sid;
627
-        try {
628
-            // we're using WP's Transient API to store session data using the PHP session ID as the option name
629
-            $session_data = $this->cache_storage->get($ssn_key, false);
630
-            if (empty($session_data)) {
631
-                return array();
632
-            }
633
-            if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
634
-                $hash_check = $this->cache_storage->get(
635
-                    EE_Session::hash_check_prefix . $this->_sid,
636
-                    false
637
-                );
638
-                if ($hash_check && $hash_check !== md5($session_data)) {
639
-                    EE_Error::add_error(
640
-                        sprintf(
641
-                            __(
642
-                                'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.',
643
-                                'event_espresso'
644
-                            ),
645
-                            EE_Session::session_id_prefix . $this->_sid
646
-                        ),
647
-                        __FILE__,
648
-                        __FUNCTION__,
649
-                        __LINE__
650
-                    );
651
-                }
652
-            }
653
-        } catch (Exception $e) {
654
-            // let's just eat that error for now and attempt to correct any corrupted data
655
-            global $wpdb;
656
-            $row = $wpdb->get_row(
657
-                $wpdb->prepare(
658
-                    "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
659
-                    '_transient_' . $ssn_key
660
-                )
661
-            );
662
-            $session_data = is_object($row) ? $row->option_value : null;
663
-            if ($session_data) {
664
-                $session_data = preg_replace_callback(
665
-                    '!s:(d+):"(.*?)";!',
666
-                    function ($match) {
667
-                        return $match[1] === strlen($match[2])
668
-                            ? $match[0]
669
-                            : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
670
-                    },
671
-                    $session_data
672
-                );
673
-            }
674
-            $session_data = maybe_unserialize($session_data);
675
-        }
676
-        // in case the data is encoded... try to decode it
677
-        $session_data = $this->encryption instanceof EE_Encryption
678
-            ? $this->encryption->base64_string_decode($session_data)
679
-            : $session_data;
680
-        if (! is_array($session_data)) {
681
-            try {
682
-                $session_data = maybe_unserialize($session_data);
683
-            } catch (Exception $e) {
684
-                $msg = esc_html__(
685
-                    'An error occurred while attempting to unserialize the session data.',
686
-                    'event_espresso'
687
-                );
688
-                $msg .= WP_DEBUG
689
-                    ? '<br><pre>'
690
-                      . print_r($session_data, true)
691
-                      . '</pre><br>'
692
-                      . $this->find_serialize_error($session_data)
693
-                    : '';
694
-                $this->cache_storage->delete(EE_Session::session_id_prefix . $this->_sid);
695
-                throw new InvalidSessionDataException($msg, 0, $e);
696
-            }
697
-        }
698
-        // just a check to make sure the session array is indeed an array
699
-        if (! is_array($session_data)) {
700
-            // no?!?! then something is wrong
701
-            $msg = esc_html__(
702
-                'The session data is missing, invalid, or corrupted.',
703
-                'event_espresso'
704
-            );
705
-            $msg .= WP_DEBUG
706
-                ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
707
-                : '';
708
-            $this->cache_storage->delete(EE_Session::session_id_prefix . $this->_sid);
709
-            throw new InvalidSessionDataException($msg);
710
-        }
711
-        if (isset($session_data['transaction']) && absint($session_data['transaction']) !== 0) {
712
-            $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
713
-                $session_data['transaction']
714
-            );
715
-        }
716
-        return $session_data;
717
-    }
718
-
719
-
720
-    /**
721
-     * _generate_session_id
722
-     * Retrieves the PHP session id either directly from the PHP session,
723
-     * or from the $_REQUEST array if it was passed in from an AJAX request.
724
-     * The session id is then salted and hashed (mmm sounds tasty)
725
-     * so that it can be safely used as a $_REQUEST param
726
-     *
727
-     * @return string
728
-     */
729
-    protected function _generate_session_id()
730
-    {
731
-        // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length
732
-        if (isset($_REQUEST['EESID'])) {
733
-            $session_id = sanitize_text_field($_REQUEST['EESID']);
734
-        } else {
735
-            $session_id = md5(session_id() . get_current_blog_id() . $this->_get_sid_salt());
736
-        }
737
-        return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id);
738
-    }
739
-
740
-
741
-    /**
742
-     * _get_sid_salt
743
-     *
744
-     * @return string
745
-     */
746
-    protected function _get_sid_salt()
747
-    {
748
-        // was session id salt already saved to db ?
749
-        if (empty($this->_sid_salt)) {
750
-            // no?  then maybe use WP defined constant
751
-            if (defined('AUTH_SALT')) {
752
-                $this->_sid_salt = AUTH_SALT;
753
-            }
754
-            // if salt doesn't exist or is too short
755
-            if (strlen($this->_sid_salt) < 32) {
756
-                // create a new one
757
-                $this->_sid_salt = wp_generate_password(64);
758
-            }
759
-            // and save it as a permanent session setting
760
-            $this->updateSessionSettings(array('sid_salt' => $this->_sid_salt));
761
-        }
762
-        return $this->_sid_salt;
763
-    }
764
-
765
-
766
-    /**
767
-     * _set_init_access_and_expiration
768
-     *
769
-     * @return void
770
-     */
771
-    protected function _set_init_access_and_expiration()
772
-    {
773
-        $this->_time = time();
774
-        $this->_expiration = $this->_time + $this->session_lifespan->inSeconds();
775
-        // set initial site access time
776
-        $this->_session_data['init_access'] = $this->_time;
777
-        // and the session expiration
778
-        $this->_session_data['expiration'] = $this->_expiration;
779
-    }
780
-
781
-
782
-    /**
783
-     * @update session data  prior to saving to the db
784
-     * @access public
785
-     * @param bool $new_session
786
-     * @return TRUE on success, FALSE on fail
787
-     * @throws EE_Error
788
-     * @throws InvalidArgumentException
789
-     * @throws InvalidDataTypeException
790
-     * @throws InvalidInterfaceException
791
-     */
792
-    public function update($new_session = false)
793
-    {
794
-        $this->_session_data = $this->_session_data !== null
795
-                               && is_array($this->_session_data)
796
-                               && isset($this->_session_data['id'])
797
-            ? $this->_session_data
798
-            : array();
799
-        if (empty($this->_session_data)) {
800
-            $this->_set_defaults();
801
-        }
802
-        $session_data = array();
803
-        foreach ($this->_session_data as $key => $value) {
804
-            switch ($key) {
805
-                case 'id':
806
-                    // session ID
807
-                    $session_data['id'] = $this->_sid;
808
-                    break;
809
-                case 'ip_address':
810
-                    // visitor ip address
811
-                    $session_data['ip_address'] = $this->request->ipAddress();
812
-                    break;
813
-                case 'user_agent':
814
-                    // visitor user_agent
815
-                    $session_data['user_agent'] = $this->_user_agent;
816
-                    break;
817
-                case 'init_access':
818
-                    $session_data['init_access'] = absint($value);
819
-                    break;
820
-                case 'last_access':
821
-                    // current access time
822
-                    $session_data['last_access'] = $this->_time;
823
-                    break;
824
-                case 'expiration':
825
-                    // when the session expires
826
-                    $session_data['expiration'] = ! empty($this->_expiration)
827
-                        ? $this->_expiration
828
-                        : $session_data['init_access'] + $this->session_lifespan->inSeconds();
829
-                    break;
830
-                case 'user_id':
831
-                    // current user if logged in
832
-                    $session_data['user_id'] = $this->_wp_user_id();
833
-                    break;
834
-                case 'pages_visited':
835
-                    $page_visit = $this->_get_page_visit();
836
-                    if ($page_visit) {
837
-                        // set pages visited where the first will be the http referrer
838
-                        $this->_session_data['pages_visited'][ $this->_time ] = $page_visit;
839
-                        // we'll only save the last 10 page visits.
840
-                        $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10);
841
-                    }
842
-                    break;
843
-                default:
844
-                    // carry any other data over
845
-                    $session_data[ $key ] = $this->_session_data[ $key ];
846
-            }
847
-        }
848
-        $this->_session_data = $session_data;
849
-        // creating a new session does not require saving to the db just yet
850
-        if (! $new_session) {
851
-            // ready? let's save
852
-            if ($this->_save_session_to_db()) {
853
-                return true;
854
-            }
855
-            return false;
856
-        }
857
-        // meh, why not?
858
-        return true;
859
-    }
860
-
861
-
862
-    /**
863
-     * @create session data array
864
-     * @access public
865
-     * @return bool
866
-     * @throws EE_Error
867
-     * @throws InvalidArgumentException
868
-     * @throws InvalidDataTypeException
869
-     * @throws InvalidInterfaceException
870
-     */
871
-    private function _create_espresso_session()
872
-    {
873
-        do_action('AHEE_log', __CLASS__, __FUNCTION__, '');
874
-        // use the update function for now with $new_session arg set to TRUE
875
-        return $this->update(true) ? true : false;
876
-    }
877
-
878
-
879
-    /**
880
-     * _save_session_to_db
881
-     *
882
-     * @param bool $clear_session
883
-     * @return string
884
-     * @throws EE_Error
885
-     * @throws InvalidArgumentException
886
-     * @throws InvalidDataTypeException
887
-     * @throws InvalidInterfaceException
888
-     */
889
-    private function _save_session_to_db($clear_session = false)
890
-    {
891
-        // don't save sessions for crawlers
892
-        // and unless we're deleting the session data, don't save anything if there isn't a cart
893
-        if ($this->request->isBot()
894
-            || (
895
-                ! $clear_session
896
-                && ! $this->cart() instanceof EE_Cart
897
-                && apply_filters('FHEE__EE_Session___save_session_to_db__abort_session_save', true)
898
-            )
899
-        ) {
900
-            return false;
901
-        }
902
-        $transaction = $this->transaction();
903
-        if ($transaction instanceof EE_Transaction) {
904
-            if (! $transaction->ID()) {
905
-                $transaction->save();
906
-            }
907
-            $this->_session_data['transaction'] = $transaction->ID();
908
-        }
909
-        // then serialize all of our session data
910
-        $session_data = serialize($this->_session_data);
911
-        // do we need to also encode it to avoid corrupted data when saved to the db?
912
-        $session_data = $this->_use_encryption
913
-            ? $this->encryption->base64_string_encode($session_data)
914
-            : $session_data;
915
-        // maybe save hash check
916
-        if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
917
-            $this->cache_storage->add(
918
-                EE_Session::hash_check_prefix . $this->_sid,
919
-                md5($session_data),
920
-                $this->session_lifespan->inSeconds()
921
-            );
922
-        }
923
-        // we're using the Transient API for storing session data,
924
-        return $this->cache_storage->add(
925
-            EE_Session::session_id_prefix . $this->_sid,
926
-            $session_data,
927
-            $this->session_lifespan->inSeconds()
928
-        );
929
-    }
930
-
931
-
932
-    /**
933
-     * @get    the full page request the visitor is accessing
934
-     * @access public
935
-     * @return string
936
-     */
937
-    public function _get_page_visit()
938
-    {
939
-        $page_visit = home_url('/') . 'wp-admin/admin-ajax.php';
940
-        // check for request url
941
-        if (isset($_SERVER['REQUEST_URI'])) {
942
-            $http_host = '';
943
-            $page_id = '?';
944
-            $e_reg = '';
945
-            $request_uri = esc_url($_SERVER['REQUEST_URI']);
946
-            $ru_bits = explode('?', $request_uri);
947
-            $request_uri = $ru_bits[0];
948
-            // check for and grab host as well
949
-            if (isset($_SERVER['HTTP_HOST'])) {
950
-                $http_host = esc_url($_SERVER['HTTP_HOST']);
951
-            }
952
-            // check for page_id in SERVER REQUEST
953
-            if (isset($_REQUEST['page_id'])) {
954
-                // rebuild $e_reg without any of the extra parameters
955
-                $page_id = '?page_id=' . esc_attr($_REQUEST['page_id']) . '&amp;';
956
-            }
957
-            // check for $e_reg in SERVER REQUEST
958
-            if (isset($_REQUEST['ee'])) {
959
-                // rebuild $e_reg without any of the extra parameters
960
-                $e_reg = 'ee=' . esc_attr($_REQUEST['ee']);
961
-            }
962
-            $page_visit = rtrim($http_host . $request_uri . $page_id . $e_reg, '?');
963
-        }
964
-        return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : '';
965
-    }
966
-
967
-
968
-    /**
969
-     * @the    current wp user id
970
-     * @access public
971
-     * @return int
972
-     */
973
-    public function _wp_user_id()
974
-    {
975
-        // if I need to explain the following lines of code, then you shouldn't be looking at this!
976
-        $this->_wp_user_id = get_current_user_id();
977
-        return $this->_wp_user_id;
978
-    }
979
-
980
-
981
-    /**
982
-     * Clear EE_Session data
983
-     *
984
-     * @access public
985
-     * @param string $class
986
-     * @param string $function
987
-     * @return void
988
-     * @throws EE_Error
989
-     * @throws InvalidArgumentException
990
-     * @throws InvalidDataTypeException
991
-     * @throws InvalidInterfaceException
992
-     */
993
-    public function clear_session($class = '', $function = '')
994
-    {
26
+	const session_id_prefix = 'ee_ssn_';
27
+
28
+	const hash_check_prefix = 'ee_shc_';
29
+
30
+	const OPTION_NAME_SETTINGS = 'ee_session_settings';
31
+
32
+	const STATUS_CLOSED = 0;
33
+
34
+	const STATUS_OPEN = 1;
35
+
36
+	/**
37
+	 * instance of the EE_Session object
38
+	 *
39
+	 * @var EE_Session
40
+	 */
41
+	private static $_instance;
42
+
43
+	/**
44
+	 * @var CacheStorageInterface $cache_storage
45
+	 */
46
+	protected $cache_storage;
47
+
48
+	/**
49
+	 * EE_Encryption object
50
+	 *
51
+	 * @var EE_Encryption
52
+	 */
53
+	protected $encryption;
54
+
55
+	/**
56
+	 * the session id
57
+	 *
58
+	 * @var string
59
+	 */
60
+	private $_sid;
61
+
62
+	/**
63
+	 * session id salt
64
+	 *
65
+	 * @var string
66
+	 */
67
+	private $_sid_salt;
68
+
69
+	/**
70
+	 * session data
71
+	 *
72
+	 * @var array
73
+	 */
74
+	private $_session_data = array();
75
+
76
+	/**
77
+	 * how long an EE session lasts
78
+	 * default session lifespan of 1 hour (for not so instant IPNs)
79
+	 *
80
+	 * @var SessionLifespan $session_lifespan
81
+	 */
82
+	private $session_lifespan;
83
+
84
+	/**
85
+	 * session expiration time as Unix timestamp in GMT
86
+	 *
87
+	 * @var int
88
+	 */
89
+	private $_expiration;
90
+
91
+	/**
92
+	 * whether or not session has expired at some point
93
+	 *
94
+	 * @var boolean
95
+	 */
96
+	private $_expired = false;
97
+
98
+	/**
99
+	 * current time as Unix timestamp in GMT
100
+	 *
101
+	 * @var int
102
+	 */
103
+	private $_time;
104
+
105
+	/**
106
+	 * whether to encrypt session data
107
+	 *
108
+	 * @var bool
109
+	 */
110
+	private $_use_encryption;
111
+
112
+	/**
113
+	 * well... according to the server...
114
+	 *
115
+	 * @var null
116
+	 */
117
+	private $_user_agent;
118
+
119
+	/**
120
+	 * do you really trust the server ?
121
+	 *
122
+	 * @var null
123
+	 */
124
+	private $_ip_address;
125
+
126
+	/**
127
+	 * current WP user_id
128
+	 *
129
+	 * @var null
130
+	 */
131
+	private $_wp_user_id;
132
+
133
+	/**
134
+	 * array for defining default session vars
135
+	 *
136
+	 * @var array
137
+	 */
138
+	private $_default_session_vars = array(
139
+		'id'            => null,
140
+		'user_id'       => null,
141
+		'ip_address'    => null,
142
+		'user_agent'    => null,
143
+		'init_access'   => null,
144
+		'last_access'   => null,
145
+		'expiration'    => null,
146
+		'pages_visited' => array(),
147
+	);
148
+
149
+	/**
150
+	 * timestamp for when last garbage collection cycle was performed
151
+	 *
152
+	 * @var int $_last_gc
153
+	 */
154
+	private $_last_gc;
155
+
156
+	/**
157
+	 * @var RequestInterface $request
158
+	 */
159
+	protected $request;
160
+
161
+	/**
162
+	 * whether session is active or not
163
+	 *
164
+	 * @var int $status
165
+	 */
166
+	private $status = EE_Session::STATUS_CLOSED;
167
+
168
+
169
+	/**
170
+	 * @singleton method used to instantiate class object
171
+	 * @param CacheStorageInterface $cache_storage
172
+	 * @param SessionLifespan|null  $lifespan
173
+	 * @param RequestInterface      $request
174
+	 * @param EE_Encryption         $encryption
175
+	 * @return EE_Session
176
+	 * @throws InvalidArgumentException
177
+	 * @throws InvalidDataTypeException
178
+	 * @throws InvalidInterfaceException
179
+	 */
180
+	public static function instance(
181
+		CacheStorageInterface $cache_storage = null,
182
+		SessionLifespan $lifespan = null,
183
+		RequestInterface $request = null,
184
+		EE_Encryption $encryption = null
185
+	) {
186
+		// check if class object is instantiated
187
+		// session loading is turned ON by default, but prior to the init hook, can be turned back OFF via:
188
+		// add_filter( 'FHEE_load_EE_Session', '__return_false' );
189
+		if (! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) {
190
+			self::$_instance = new self(
191
+				$cache_storage,
192
+				$lifespan,
193
+				$request,
194
+				$encryption
195
+			);
196
+		}
197
+		return self::$_instance;
198
+	}
199
+
200
+
201
+	/**
202
+	 * protected constructor to prevent direct creation
203
+	 *
204
+	 * @param CacheStorageInterface $cache_storage
205
+	 * @param SessionLifespan       $lifespan
206
+	 * @param RequestInterface      $request
207
+	 * @param EE_Encryption         $encryption
208
+	 * @throws InvalidArgumentException
209
+	 * @throws InvalidDataTypeException
210
+	 * @throws InvalidInterfaceException
211
+	 */
212
+	protected function __construct(
213
+		CacheStorageInterface $cache_storage,
214
+		SessionLifespan $lifespan,
215
+		RequestInterface $request,
216
+		EE_Encryption $encryption = null
217
+	) {
218
+		// session loading is turned ON by default,
219
+		// but prior to the 'AHEE__EE_System__core_loaded_and_ready' hook
220
+		// (which currently fires on the init hook at priority 9),
221
+		// can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' );
222
+		if (! apply_filters('FHEE_load_EE_Session', true)) {
223
+			return;
224
+		}
225
+		$this->session_lifespan = $lifespan;
226
+		$this->request = $request;
227
+		if (! defined('ESPRESSO_SESSION')) {
228
+			define('ESPRESSO_SESSION', true);
229
+		}
230
+		// retrieve session options from db
231
+		$session_settings = (array) get_option(EE_Session::OPTION_NAME_SETTINGS, array());
232
+		if (! empty($session_settings)) {
233
+			// cycle though existing session options
234
+			foreach ($session_settings as $var_name => $session_setting) {
235
+				// set values for class properties
236
+				$var_name = '_' . $var_name;
237
+				$this->{$var_name} = $session_setting;
238
+			}
239
+		}
240
+		$this->cache_storage = $cache_storage;
241
+		// are we using encryption?
242
+		$this->_use_encryption = $encryption instanceof EE_Encryption
243
+								 && EE_Registry::instance()->CFG->admin->encode_session_data();
244
+		// encrypt data via: $this->encryption->encrypt();
245
+		$this->encryption = $encryption;
246
+		// filter hook allows outside functions/classes/plugins to change default empty cart
247
+		$extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array());
248
+		array_merge($this->_default_session_vars, $extra_default_session_vars);
249
+		// apply default session vars
250
+		$this->_set_defaults();
251
+		add_action('AHEE__EE_System__initialize', array($this, 'open_session'));
252
+		// check request for 'clear_session' param
253
+		add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded'));
254
+		// once everything is all said and done,
255
+		add_action('shutdown', array($this, 'update'), 100);
256
+		add_action('shutdown', array($this, 'garbageCollection'), 1000);
257
+		$this->configure_garbage_collection_filters();
258
+	}
259
+
260
+
261
+	/**
262
+	 * @return bool
263
+	 * @throws InvalidArgumentException
264
+	 * @throws InvalidDataTypeException
265
+	 * @throws InvalidInterfaceException
266
+	 */
267
+	public static function isLoadedAndActive()
268
+	{
269
+		return did_action('AHEE__EE_System__core_loaded_and_ready')
270
+			   && EE_Session::instance() instanceof EE_Session
271
+			   && EE_Session::instance()->isActive();
272
+	}
273
+
274
+
275
+	/**
276
+	 * @return bool
277
+	 */
278
+	public function isActive()
279
+	{
280
+		return $this->status === EE_Session::STATUS_OPEN;
281
+	}
282
+
283
+
284
+	/**
285
+	 * @return void
286
+	 * @throws EE_Error
287
+	 * @throws InvalidArgumentException
288
+	 * @throws InvalidDataTypeException
289
+	 * @throws InvalidInterfaceException
290
+	 * @throws InvalidSessionDataException
291
+	 */
292
+	public function open_session()
293
+	{
294
+		// check for existing session and retrieve it from db
295
+		if (! $this->_espresso_session()) {
296
+			// or just start a new one
297
+			$this->_create_espresso_session();
298
+		}
299
+	}
300
+
301
+
302
+	/**
303
+	 * @return bool
304
+	 */
305
+	public function expired()
306
+	{
307
+		return $this->_expired;
308
+	}
309
+
310
+
311
+	/**
312
+	 * @return void
313
+	 */
314
+	public function reset_expired()
315
+	{
316
+		$this->_expired = false;
317
+	}
318
+
319
+
320
+	/**
321
+	 * @return int
322
+	 */
323
+	public function expiration()
324
+	{
325
+		return $this->_expiration;
326
+	}
327
+
328
+
329
+	/**
330
+	 * @return int
331
+	 */
332
+	public function extension()
333
+	{
334
+		return apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS);
335
+	}
336
+
337
+
338
+	/**
339
+	 * @param int $time number of seconds to add to session expiration
340
+	 */
341
+	public function extend_expiration($time = 0)
342
+	{
343
+		$time = $time ? $time : $this->extension();
344
+		$this->_expiration += absint($time);
345
+	}
346
+
347
+
348
+	/**
349
+	 * @return int
350
+	 */
351
+	public function lifespan()
352
+	{
353
+		return $this->session_lifespan->inSeconds();
354
+	}
355
+
356
+
357
+	/**
358
+	 * This just sets some defaults for the _session data property
359
+	 *
360
+	 * @access private
361
+	 * @return void
362
+	 */
363
+	private function _set_defaults()
364
+	{
365
+		// set some defaults
366
+		foreach ($this->_default_session_vars as $key => $default_var) {
367
+			if (is_array($default_var)) {
368
+				$this->_session_data[ $key ] = array();
369
+			} else {
370
+				$this->_session_data[ $key ] = '';
371
+			}
372
+		}
373
+	}
374
+
375
+
376
+	/**
377
+	 * @retrieve  session data
378
+	 * @access    public
379
+	 * @return    string
380
+	 */
381
+	public function id()
382
+	{
383
+		return $this->_sid;
384
+	}
385
+
386
+
387
+	/**
388
+	 * @param \EE_Cart $cart
389
+	 * @return bool
390
+	 */
391
+	public function set_cart(EE_Cart $cart)
392
+	{
393
+		$this->_session_data['cart'] = $cart;
394
+		return true;
395
+	}
396
+
397
+
398
+	/**
399
+	 * reset_cart
400
+	 */
401
+	public function reset_cart()
402
+	{
403
+		do_action('AHEE__EE_Session__reset_cart__before_reset', $this);
404
+		$this->_session_data['cart'] = null;
405
+	}
406
+
407
+
408
+	/**
409
+	 * @return \EE_Cart
410
+	 */
411
+	public function cart()
412
+	{
413
+		return isset($this->_session_data['cart']) && $this->_session_data['cart'] instanceof EE_Cart
414
+			? $this->_session_data['cart']
415
+			: null;
416
+	}
417
+
418
+
419
+	/**
420
+	 * @param \EE_Checkout $checkout
421
+	 * @return bool
422
+	 */
423
+	public function set_checkout(EE_Checkout $checkout)
424
+	{
425
+		$this->_session_data['checkout'] = $checkout;
426
+		return true;
427
+	}
428
+
429
+
430
+	/**
431
+	 * reset_checkout
432
+	 */
433
+	public function reset_checkout()
434
+	{
435
+		do_action('AHEE__EE_Session__reset_checkout__before_reset', $this);
436
+		$this->_session_data['checkout'] = null;
437
+	}
438
+
439
+
440
+	/**
441
+	 * @return \EE_Checkout
442
+	 */
443
+	public function checkout()
444
+	{
445
+		return isset($this->_session_data['checkout']) && $this->_session_data['checkout'] instanceof EE_Checkout
446
+			? $this->_session_data['checkout']
447
+			: null;
448
+	}
449
+
450
+
451
+	/**
452
+	 * @param \EE_Transaction $transaction
453
+	 * @return bool
454
+	 * @throws EE_Error
455
+	 */
456
+	public function set_transaction(EE_Transaction $transaction)
457
+	{
458
+		// first remove the session from the transaction before we save the transaction in the session
459
+		$transaction->set_txn_session_data(null);
460
+		$this->_session_data['transaction'] = $transaction;
461
+		return true;
462
+	}
463
+
464
+
465
+	/**
466
+	 * reset_transaction
467
+	 */
468
+	public function reset_transaction()
469
+	{
470
+		do_action('AHEE__EE_Session__reset_transaction__before_reset', $this);
471
+		$this->_session_data['transaction'] = null;
472
+	}
473
+
474
+
475
+	/**
476
+	 * @return \EE_Transaction
477
+	 */
478
+	public function transaction()
479
+	{
480
+		return isset($this->_session_data['transaction'])
481
+			   && $this->_session_data['transaction'] instanceof EE_Transaction
482
+			? $this->_session_data['transaction']
483
+			: null;
484
+	}
485
+
486
+
487
+	/**
488
+	 * retrieve session data
489
+	 *
490
+	 * @param null $key
491
+	 * @param bool $reset_cache
492
+	 * @return array
493
+	 */
494
+	public function get_session_data($key = null, $reset_cache = false)
495
+	{
496
+		if ($reset_cache) {
497
+			$this->reset_cart();
498
+			$this->reset_checkout();
499
+			$this->reset_transaction();
500
+		}
501
+		if (! empty($key)) {
502
+			return isset($this->_session_data[ $key ]) ? $this->_session_data[ $key ] : null;
503
+		}
504
+		return $this->_session_data;
505
+	}
506
+
507
+
508
+	/**
509
+	 * Returns TRUE on success, FALSE on fail
510
+	 *
511
+	 * @param array $data
512
+	 * @return bool
513
+	 */
514
+	public function set_session_data($data)
515
+	{
516
+		// nothing ??? bad data ??? go home!
517
+		if (empty($data) || ! is_array($data)) {
518
+			EE_Error::add_error(
519
+				esc_html__(
520
+					'No session data or invalid session data was provided.',
521
+					'event_espresso'
522
+				),
523
+				__FILE__,
524
+				__FUNCTION__,
525
+				__LINE__
526
+			);
527
+			return false;
528
+		}
529
+		foreach ($data as $key => $value) {
530
+			if (isset($this->_default_session_vars[ $key ])) {
531
+				EE_Error::add_error(
532
+					sprintf(
533
+						esc_html__(
534
+							'Sorry! %s is a default session datum and can not be reset.',
535
+							'event_espresso'
536
+						),
537
+						$key
538
+					),
539
+					__FILE__,
540
+					__FUNCTION__,
541
+					__LINE__
542
+				);
543
+				return false;
544
+			}
545
+			$this->_session_data[ $key ] = $value;
546
+		}
547
+		return true;
548
+	}
549
+
550
+
551
+	/**
552
+	 * @initiate session
553
+	 * @access   private
554
+	 * @return TRUE on success, FALSE on fail
555
+	 * @throws EE_Error
556
+	 * @throws InvalidArgumentException
557
+	 * @throws InvalidDataTypeException
558
+	 * @throws InvalidInterfaceException
559
+	 * @throws InvalidSessionDataException
560
+	 */
561
+	private function _espresso_session()
562
+	{
563
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
564
+		// check that session has started
565
+		if (session_id() === '') {
566
+			// starts a new session if one doesn't already exist, or re-initiates an existing one
567
+			session_start();
568
+		}
569
+		$this->status = EE_Session::STATUS_OPEN;
570
+		// get our modified session ID
571
+		$this->_sid = $this->_generate_session_id();
572
+		// and the visitors IP
573
+		$this->_ip_address = $this->request->ipAddress();
574
+		// set the "user agent"
575
+		$this->_user_agent = $this->request->userAgent();
576
+		// now let's retrieve what's in the db
577
+		$session_data = $this->_retrieve_session_data();
578
+		if (! empty($session_data)) {
579
+			// get the current time in UTC
580
+			$this->_time = $this->_time !== null ? $this->_time : time();
581
+			// and reset the session expiration
582
+			$this->_expiration = isset($session_data['expiration'])
583
+				? $session_data['expiration']
584
+				: $this->_time + $this->session_lifespan->inSeconds();
585
+		} else {
586
+			// set initial site access time and the session expiration
587
+			$this->_set_init_access_and_expiration();
588
+			// set referer
589
+			$this->_session_data['pages_visited'][ $this->_session_data['init_access'] ] = isset($_SERVER['HTTP_REFERER'])
590
+				? esc_attr($_SERVER['HTTP_REFERER'])
591
+				: '';
592
+			// no previous session = go back and create one (on top of the data above)
593
+			return false;
594
+		}
595
+		// now the user agent
596
+		if ($session_data['user_agent'] !== $this->_user_agent) {
597
+			return false;
598
+		}
599
+		// wait a minute... how old are you?
600
+		if ($this->_time > $this->_expiration) {
601
+			// yer too old fer me!
602
+			$this->_expired = true;
603
+			// wipe out everything that isn't a default session datum
604
+			$this->clear_session(__CLASS__, __FUNCTION__);
605
+		}
606
+		// make event espresso session data available to plugin
607
+		$this->_session_data = array_merge($this->_session_data, $session_data);
608
+		return true;
609
+	}
610
+
611
+
612
+	/**
613
+	 * _get_session_data
614
+	 * Retrieves the session data, and attempts to correct any encoding issues that can occur due to improperly setup
615
+	 * databases
616
+	 *
617
+	 * @return array
618
+	 * @throws EE_Error
619
+	 * @throws InvalidArgumentException
620
+	 * @throws InvalidSessionDataException
621
+	 * @throws InvalidDataTypeException
622
+	 * @throws InvalidInterfaceException
623
+	 */
624
+	protected function _retrieve_session_data()
625
+	{
626
+		$ssn_key = EE_Session::session_id_prefix . $this->_sid;
627
+		try {
628
+			// we're using WP's Transient API to store session data using the PHP session ID as the option name
629
+			$session_data = $this->cache_storage->get($ssn_key, false);
630
+			if (empty($session_data)) {
631
+				return array();
632
+			}
633
+			if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
634
+				$hash_check = $this->cache_storage->get(
635
+					EE_Session::hash_check_prefix . $this->_sid,
636
+					false
637
+				);
638
+				if ($hash_check && $hash_check !== md5($session_data)) {
639
+					EE_Error::add_error(
640
+						sprintf(
641
+							__(
642
+								'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.',
643
+								'event_espresso'
644
+							),
645
+							EE_Session::session_id_prefix . $this->_sid
646
+						),
647
+						__FILE__,
648
+						__FUNCTION__,
649
+						__LINE__
650
+					);
651
+				}
652
+			}
653
+		} catch (Exception $e) {
654
+			// let's just eat that error for now and attempt to correct any corrupted data
655
+			global $wpdb;
656
+			$row = $wpdb->get_row(
657
+				$wpdb->prepare(
658
+					"SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
659
+					'_transient_' . $ssn_key
660
+				)
661
+			);
662
+			$session_data = is_object($row) ? $row->option_value : null;
663
+			if ($session_data) {
664
+				$session_data = preg_replace_callback(
665
+					'!s:(d+):"(.*?)";!',
666
+					function ($match) {
667
+						return $match[1] === strlen($match[2])
668
+							? $match[0]
669
+							: 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
670
+					},
671
+					$session_data
672
+				);
673
+			}
674
+			$session_data = maybe_unserialize($session_data);
675
+		}
676
+		// in case the data is encoded... try to decode it
677
+		$session_data = $this->encryption instanceof EE_Encryption
678
+			? $this->encryption->base64_string_decode($session_data)
679
+			: $session_data;
680
+		if (! is_array($session_data)) {
681
+			try {
682
+				$session_data = maybe_unserialize($session_data);
683
+			} catch (Exception $e) {
684
+				$msg = esc_html__(
685
+					'An error occurred while attempting to unserialize the session data.',
686
+					'event_espresso'
687
+				);
688
+				$msg .= WP_DEBUG
689
+					? '<br><pre>'
690
+					  . print_r($session_data, true)
691
+					  . '</pre><br>'
692
+					  . $this->find_serialize_error($session_data)
693
+					: '';
694
+				$this->cache_storage->delete(EE_Session::session_id_prefix . $this->_sid);
695
+				throw new InvalidSessionDataException($msg, 0, $e);
696
+			}
697
+		}
698
+		// just a check to make sure the session array is indeed an array
699
+		if (! is_array($session_data)) {
700
+			// no?!?! then something is wrong
701
+			$msg = esc_html__(
702
+				'The session data is missing, invalid, or corrupted.',
703
+				'event_espresso'
704
+			);
705
+			$msg .= WP_DEBUG
706
+				? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
707
+				: '';
708
+			$this->cache_storage->delete(EE_Session::session_id_prefix . $this->_sid);
709
+			throw new InvalidSessionDataException($msg);
710
+		}
711
+		if (isset($session_data['transaction']) && absint($session_data['transaction']) !== 0) {
712
+			$session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
713
+				$session_data['transaction']
714
+			);
715
+		}
716
+		return $session_data;
717
+	}
718
+
719
+
720
+	/**
721
+	 * _generate_session_id
722
+	 * Retrieves the PHP session id either directly from the PHP session,
723
+	 * or from the $_REQUEST array if it was passed in from an AJAX request.
724
+	 * The session id is then salted and hashed (mmm sounds tasty)
725
+	 * so that it can be safely used as a $_REQUEST param
726
+	 *
727
+	 * @return string
728
+	 */
729
+	protected function _generate_session_id()
730
+	{
731
+		// check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length
732
+		if (isset($_REQUEST['EESID'])) {
733
+			$session_id = sanitize_text_field($_REQUEST['EESID']);
734
+		} else {
735
+			$session_id = md5(session_id() . get_current_blog_id() . $this->_get_sid_salt());
736
+		}
737
+		return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id);
738
+	}
739
+
740
+
741
+	/**
742
+	 * _get_sid_salt
743
+	 *
744
+	 * @return string
745
+	 */
746
+	protected function _get_sid_salt()
747
+	{
748
+		// was session id salt already saved to db ?
749
+		if (empty($this->_sid_salt)) {
750
+			// no?  then maybe use WP defined constant
751
+			if (defined('AUTH_SALT')) {
752
+				$this->_sid_salt = AUTH_SALT;
753
+			}
754
+			// if salt doesn't exist or is too short
755
+			if (strlen($this->_sid_salt) < 32) {
756
+				// create a new one
757
+				$this->_sid_salt = wp_generate_password(64);
758
+			}
759
+			// and save it as a permanent session setting
760
+			$this->updateSessionSettings(array('sid_salt' => $this->_sid_salt));
761
+		}
762
+		return $this->_sid_salt;
763
+	}
764
+
765
+
766
+	/**
767
+	 * _set_init_access_and_expiration
768
+	 *
769
+	 * @return void
770
+	 */
771
+	protected function _set_init_access_and_expiration()
772
+	{
773
+		$this->_time = time();
774
+		$this->_expiration = $this->_time + $this->session_lifespan->inSeconds();
775
+		// set initial site access time
776
+		$this->_session_data['init_access'] = $this->_time;
777
+		// and the session expiration
778
+		$this->_session_data['expiration'] = $this->_expiration;
779
+	}
780
+
781
+
782
+	/**
783
+	 * @update session data  prior to saving to the db
784
+	 * @access public
785
+	 * @param bool $new_session
786
+	 * @return TRUE on success, FALSE on fail
787
+	 * @throws EE_Error
788
+	 * @throws InvalidArgumentException
789
+	 * @throws InvalidDataTypeException
790
+	 * @throws InvalidInterfaceException
791
+	 */
792
+	public function update($new_session = false)
793
+	{
794
+		$this->_session_data = $this->_session_data !== null
795
+							   && is_array($this->_session_data)
796
+							   && isset($this->_session_data['id'])
797
+			? $this->_session_data
798
+			: array();
799
+		if (empty($this->_session_data)) {
800
+			$this->_set_defaults();
801
+		}
802
+		$session_data = array();
803
+		foreach ($this->_session_data as $key => $value) {
804
+			switch ($key) {
805
+				case 'id':
806
+					// session ID
807
+					$session_data['id'] = $this->_sid;
808
+					break;
809
+				case 'ip_address':
810
+					// visitor ip address
811
+					$session_data['ip_address'] = $this->request->ipAddress();
812
+					break;
813
+				case 'user_agent':
814
+					// visitor user_agent
815
+					$session_data['user_agent'] = $this->_user_agent;
816
+					break;
817
+				case 'init_access':
818
+					$session_data['init_access'] = absint($value);
819
+					break;
820
+				case 'last_access':
821
+					// current access time
822
+					$session_data['last_access'] = $this->_time;
823
+					break;
824
+				case 'expiration':
825
+					// when the session expires
826
+					$session_data['expiration'] = ! empty($this->_expiration)
827
+						? $this->_expiration
828
+						: $session_data['init_access'] + $this->session_lifespan->inSeconds();
829
+					break;
830
+				case 'user_id':
831
+					// current user if logged in
832
+					$session_data['user_id'] = $this->_wp_user_id();
833
+					break;
834
+				case 'pages_visited':
835
+					$page_visit = $this->_get_page_visit();
836
+					if ($page_visit) {
837
+						// set pages visited where the first will be the http referrer
838
+						$this->_session_data['pages_visited'][ $this->_time ] = $page_visit;
839
+						// we'll only save the last 10 page visits.
840
+						$session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10);
841
+					}
842
+					break;
843
+				default:
844
+					// carry any other data over
845
+					$session_data[ $key ] = $this->_session_data[ $key ];
846
+			}
847
+		}
848
+		$this->_session_data = $session_data;
849
+		// creating a new session does not require saving to the db just yet
850
+		if (! $new_session) {
851
+			// ready? let's save
852
+			if ($this->_save_session_to_db()) {
853
+				return true;
854
+			}
855
+			return false;
856
+		}
857
+		// meh, why not?
858
+		return true;
859
+	}
860
+
861
+
862
+	/**
863
+	 * @create session data array
864
+	 * @access public
865
+	 * @return bool
866
+	 * @throws EE_Error
867
+	 * @throws InvalidArgumentException
868
+	 * @throws InvalidDataTypeException
869
+	 * @throws InvalidInterfaceException
870
+	 */
871
+	private function _create_espresso_session()
872
+	{
873
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, '');
874
+		// use the update function for now with $new_session arg set to TRUE
875
+		return $this->update(true) ? true : false;
876
+	}
877
+
878
+
879
+	/**
880
+	 * _save_session_to_db
881
+	 *
882
+	 * @param bool $clear_session
883
+	 * @return string
884
+	 * @throws EE_Error
885
+	 * @throws InvalidArgumentException
886
+	 * @throws InvalidDataTypeException
887
+	 * @throws InvalidInterfaceException
888
+	 */
889
+	private function _save_session_to_db($clear_session = false)
890
+	{
891
+		// don't save sessions for crawlers
892
+		// and unless we're deleting the session data, don't save anything if there isn't a cart
893
+		if ($this->request->isBot()
894
+			|| (
895
+				! $clear_session
896
+				&& ! $this->cart() instanceof EE_Cart
897
+				&& apply_filters('FHEE__EE_Session___save_session_to_db__abort_session_save', true)
898
+			)
899
+		) {
900
+			return false;
901
+		}
902
+		$transaction = $this->transaction();
903
+		if ($transaction instanceof EE_Transaction) {
904
+			if (! $transaction->ID()) {
905
+				$transaction->save();
906
+			}
907
+			$this->_session_data['transaction'] = $transaction->ID();
908
+		}
909
+		// then serialize all of our session data
910
+		$session_data = serialize($this->_session_data);
911
+		// do we need to also encode it to avoid corrupted data when saved to the db?
912
+		$session_data = $this->_use_encryption
913
+			? $this->encryption->base64_string_encode($session_data)
914
+			: $session_data;
915
+		// maybe save hash check
916
+		if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
917
+			$this->cache_storage->add(
918
+				EE_Session::hash_check_prefix . $this->_sid,
919
+				md5($session_data),
920
+				$this->session_lifespan->inSeconds()
921
+			);
922
+		}
923
+		// we're using the Transient API for storing session data,
924
+		return $this->cache_storage->add(
925
+			EE_Session::session_id_prefix . $this->_sid,
926
+			$session_data,
927
+			$this->session_lifespan->inSeconds()
928
+		);
929
+	}
930
+
931
+
932
+	/**
933
+	 * @get    the full page request the visitor is accessing
934
+	 * @access public
935
+	 * @return string
936
+	 */
937
+	public function _get_page_visit()
938
+	{
939
+		$page_visit = home_url('/') . 'wp-admin/admin-ajax.php';
940
+		// check for request url
941
+		if (isset($_SERVER['REQUEST_URI'])) {
942
+			$http_host = '';
943
+			$page_id = '?';
944
+			$e_reg = '';
945
+			$request_uri = esc_url($_SERVER['REQUEST_URI']);
946
+			$ru_bits = explode('?', $request_uri);
947
+			$request_uri = $ru_bits[0];
948
+			// check for and grab host as well
949
+			if (isset($_SERVER['HTTP_HOST'])) {
950
+				$http_host = esc_url($_SERVER['HTTP_HOST']);
951
+			}
952
+			// check for page_id in SERVER REQUEST
953
+			if (isset($_REQUEST['page_id'])) {
954
+				// rebuild $e_reg without any of the extra parameters
955
+				$page_id = '?page_id=' . esc_attr($_REQUEST['page_id']) . '&amp;';
956
+			}
957
+			// check for $e_reg in SERVER REQUEST
958
+			if (isset($_REQUEST['ee'])) {
959
+				// rebuild $e_reg without any of the extra parameters
960
+				$e_reg = 'ee=' . esc_attr($_REQUEST['ee']);
961
+			}
962
+			$page_visit = rtrim($http_host . $request_uri . $page_id . $e_reg, '?');
963
+		}
964
+		return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : '';
965
+	}
966
+
967
+
968
+	/**
969
+	 * @the    current wp user id
970
+	 * @access public
971
+	 * @return int
972
+	 */
973
+	public function _wp_user_id()
974
+	{
975
+		// if I need to explain the following lines of code, then you shouldn't be looking at this!
976
+		$this->_wp_user_id = get_current_user_id();
977
+		return $this->_wp_user_id;
978
+	}
979
+
980
+
981
+	/**
982
+	 * Clear EE_Session data
983
+	 *
984
+	 * @access public
985
+	 * @param string $class
986
+	 * @param string $function
987
+	 * @return void
988
+	 * @throws EE_Error
989
+	 * @throws InvalidArgumentException
990
+	 * @throws InvalidDataTypeException
991
+	 * @throws InvalidInterfaceException
992
+	 */
993
+	public function clear_session($class = '', $function = '')
994
+	{
995 995
 //         echo '
996 996
 // <h3 style="color:#999;line-height:.9em;">
997 997
 // <span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/>
998 998
 // <span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span>    <b style="font-size:10px;">  ' . __LINE__ . ' </b>
999 999
 // </h3>';
1000
-        do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()');
1001
-        $this->reset_cart();
1002
-        $this->reset_checkout();
1003
-        $this->reset_transaction();
1004
-        // wipe out everything that isn't a default session datum
1005
-        $this->reset_data(array_keys($this->_session_data));
1006
-        // reset initial site access time and the session expiration
1007
-        $this->_set_init_access_and_expiration();
1008
-        $this->_save_session_to_db(true);
1009
-    }
1010
-
1011
-
1012
-    /**
1013
-     * resets all non-default session vars. Returns TRUE on success, FALSE on fail
1014
-     *
1015
-     * @param array|mixed $data_to_reset
1016
-     * @param bool        $show_all_notices
1017
-     * @return bool
1018
-     */
1019
-    public function reset_data($data_to_reset = array(), $show_all_notices = false)
1020
-    {
1021
-        // if $data_to_reset is not in an array, then put it in one
1022
-        if (! is_array($data_to_reset)) {
1023
-            $data_to_reset = array($data_to_reset);
1024
-        }
1025
-        // nothing ??? go home!
1026
-        if (empty($data_to_reset)) {
1027
-            EE_Error::add_error(
1028
-                __(
1029
-                    'No session data could be reset, because no session var name was provided.',
1030
-                    'event_espresso'
1031
-                ),
1032
-                __FILE__,
1033
-                __FUNCTION__,
1034
-                __LINE__
1035
-            );
1036
-            return false;
1037
-        }
1038
-        $return_value = true;
1039
-        // since $data_to_reset is an array, cycle through the values
1040
-        foreach ($data_to_reset as $reset) {
1041
-            // first check to make sure it is a valid session var
1042
-            if (isset($this->_session_data[ $reset ])) {
1043
-                // then check to make sure it is not a default var
1044
-                if (! array_key_exists($reset, $this->_default_session_vars)) {
1045
-                    // remove session var
1046
-                    unset($this->_session_data[ $reset ]);
1047
-                    if ($show_all_notices) {
1048
-                        EE_Error::add_success(
1049
-                            sprintf(
1050
-                                __('The session variable %s was removed.', 'event_espresso'),
1051
-                                $reset
1052
-                            ),
1053
-                            __FILE__,
1054
-                            __FUNCTION__,
1055
-                            __LINE__
1056
-                        );
1057
-                    }
1058
-                } else {
1059
-                    // yeeeeeeeeerrrrrrrrrrr OUT !!!!
1060
-                    if ($show_all_notices) {
1061
-                        EE_Error::add_error(
1062
-                            sprintf(
1063
-                                __(
1064
-                                    'Sorry! %s is a default session datum and can not be reset.',
1065
-                                    'event_espresso'
1066
-                                ),
1067
-                                $reset
1068
-                            ),
1069
-                            __FILE__,
1070
-                            __FUNCTION__,
1071
-                            __LINE__
1072
-                        );
1073
-                    }
1074
-                    $return_value = false;
1075
-                }
1076
-            } elseif ($show_all_notices) {
1077
-                // oops! that session var does not exist!
1078
-                EE_Error::add_error(
1079
-                    sprintf(
1080
-                        __(
1081
-                            'The session item provided, %s, is invalid or does not exist.',
1082
-                            'event_espresso'
1083
-                        ),
1084
-                        $reset
1085
-                    ),
1086
-                    __FILE__,
1087
-                    __FUNCTION__,
1088
-                    __LINE__
1089
-                );
1090
-                $return_value = false;
1091
-            }
1092
-        } // end of foreach
1093
-        return $return_value;
1094
-    }
1095
-
1096
-
1097
-    /**
1098
-     *   wp_loaded
1099
-     *
1100
-     * @access public
1101
-     * @throws EE_Error
1102
-     * @throws InvalidDataTypeException
1103
-     * @throws InvalidInterfaceException
1104
-     * @throws InvalidArgumentException
1105
-     */
1106
-    public function wp_loaded()
1107
-    {
1108
-        if ($this->request->requestParamIsSet('clear_session')) {
1109
-            $this->clear_session(__CLASS__, __FUNCTION__);
1110
-        }
1111
-    }
1112
-
1113
-
1114
-    /**
1115
-     * Used to reset the entire object (for tests).
1116
-     *
1117
-     * @since 4.3.0
1118
-     * @throws EE_Error
1119
-     * @throws InvalidDataTypeException
1120
-     * @throws InvalidInterfaceException
1121
-     * @throws InvalidArgumentException
1122
-     */
1123
-    public function reset_instance()
1124
-    {
1125
-        $this->clear_session();
1126
-        self::$_instance = null;
1127
-    }
1128
-
1129
-
1130
-    public function configure_garbage_collection_filters()
1131
-    {
1132
-        // run old filter we had for controlling session cleanup
1133
-        $expired_session_transient_delete_query_limit = absint(
1134
-            apply_filters(
1135
-                'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit',
1136
-                50
1137
-            )
1138
-        );
1139
-        // is there a value? or one that is different than the default 50 records?
1140
-        if ($expired_session_transient_delete_query_limit === 0) {
1141
-            // hook into TransientCacheStorage in case Session cleanup was turned off
1142
-            add_filter('FHEE__TransientCacheStorage__transient_cleanup_schedule', '__return_zero');
1143
-        } elseif ($expired_session_transient_delete_query_limit !== 50) {
1144
-            // or use that for the new transient cleanup query limit
1145
-            add_filter(
1146
-                'FHEE__TransientCacheStorage__clearExpiredTransients__limit',
1147
-                function () use ($expired_session_transient_delete_query_limit) {
1148
-                    return $expired_session_transient_delete_query_limit;
1149
-                }
1150
-            );
1151
-        }
1152
-    }
1153
-
1154
-
1155
-    /**
1156
-     * @see http://stackoverflow.com/questions/10152904/unserialize-function-unserialize-error-at-offset/21389439#10152996
1157
-     * @param $data1
1158
-     * @return string
1159
-     */
1160
-    private function find_serialize_error($data1)
1161
-    {
1162
-        $error = '<pre>';
1163
-        $data2 = preg_replace_callback(
1164
-            '!s:(\d+):"(.*?)";!',
1165
-            function ($match) {
1166
-                return ($match[1] === strlen($match[2]))
1167
-                    ? $match[0]
1168
-                    : 's:'
1169
-                      . strlen($match[2])
1170
-                      . ':"'
1171
-                      . $match[2]
1172
-                      . '";';
1173
-            },
1174
-            $data1
1175
-        );
1176
-        $max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2);
1177
-        $error .= $data1 . PHP_EOL;
1178
-        $error .= $data2 . PHP_EOL;
1179
-        for ($i = 0; $i < $max; $i++) {
1180
-            if (@$data1[ $i ] !== @$data2[ $i ]) {
1181
-                $error .= 'Difference ' . @$data1[ $i ] . ' != ' . @$data2[ $i ] . PHP_EOL;
1182
-                $error .= "\t-> ORD number " . ord(@$data1[ $i ]) . ' != ' . ord(@$data2[ $i ]) . PHP_EOL;
1183
-                $error .= "\t-> Line Number = $i" . PHP_EOL;
1184
-                $start = ($i - 20);
1185
-                $start = ($start < 0) ? 0 : $start;
1186
-                $length = 40;
1187
-                $point = $max - $i;
1188
-                if ($point < 20) {
1189
-                    $rlength = 1;
1190
-                    $rpoint = -$point;
1191
-                } else {
1192
-                    $rpoint = $length - 20;
1193
-                    $rlength = 1;
1194
-                }
1195
-                $error .= "\t-> Section Data1  = ";
1196
-                $error .= substr_replace(
1197
-                    substr($data1, $start, $length),
1198
-                    "<b style=\"color:green\">{$data1[ $i ]}</b>",
1199
-                    $rpoint,
1200
-                    $rlength
1201
-                );
1202
-                $error .= PHP_EOL;
1203
-                $error .= "\t-> Section Data2  = ";
1204
-                $error .= substr_replace(
1205
-                    substr($data2, $start, $length),
1206
-                    "<b style=\"color:red\">{$data2[ $i ]}</b>",
1207
-                    $rpoint,
1208
-                    $rlength
1209
-                );
1210
-                $error .= PHP_EOL;
1211
-            }
1212
-        }
1213
-        $error .= '</pre>';
1214
-        return $error;
1215
-    }
1216
-
1217
-
1218
-    /**
1219
-     * Saves an  array of settings used for configuring aspects of session behaviour
1220
-     *
1221
-     * @param array $updated_settings
1222
-     */
1223
-    private function updateSessionSettings(array $updated_settings = array())
1224
-    {
1225
-        // add existing settings, but only if not included in incoming $updated_settings array
1226
-        $updated_settings += get_option(EE_Session::OPTION_NAME_SETTINGS, array());
1227
-        update_option(EE_Session::OPTION_NAME_SETTINGS, $updated_settings);
1228
-    }
1229
-
1230
-
1231
-    /**
1232
-     * garbage_collection
1233
-     */
1234
-    public function garbageCollection()
1235
-    {
1236
-        // only perform during regular requests if last garbage collection was over an hour ago
1237
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && (time() - HOUR_IN_SECONDS) >= $this->_last_gc) {
1238
-            $this->_last_gc = time();
1239
-            $this->updateSessionSettings(array('last_gc' => $this->_last_gc));
1240
-            /** @type WPDB $wpdb */
1241
-            global $wpdb;
1242
-            // filter the query limit. Set to 0 to turn off garbage collection
1243
-            $expired_session_transient_delete_query_limit = absint(
1244
-                apply_filters(
1245
-                    'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit',
1246
-                    50
1247
-                )
1248
-            );
1249
-            // non-zero LIMIT means take out the trash
1250
-            if ($expired_session_transient_delete_query_limit) {
1251
-                $session_key = str_replace('_', '\_', EE_Session::session_id_prefix);
1252
-                $hash_check_key = str_replace('_', '\_', EE_Session::hash_check_prefix);
1253
-                // since transient expiration timestamps are set in the future, we can compare against NOW
1254
-                // but we only want to pick up any trash that's been around for more than a day
1255
-                $expiration = time() - DAY_IN_SECONDS;
1256
-                $SQL = "
1000
+		do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()');
1001
+		$this->reset_cart();
1002
+		$this->reset_checkout();
1003
+		$this->reset_transaction();
1004
+		// wipe out everything that isn't a default session datum
1005
+		$this->reset_data(array_keys($this->_session_data));
1006
+		// reset initial site access time and the session expiration
1007
+		$this->_set_init_access_and_expiration();
1008
+		$this->_save_session_to_db(true);
1009
+	}
1010
+
1011
+
1012
+	/**
1013
+	 * resets all non-default session vars. Returns TRUE on success, FALSE on fail
1014
+	 *
1015
+	 * @param array|mixed $data_to_reset
1016
+	 * @param bool        $show_all_notices
1017
+	 * @return bool
1018
+	 */
1019
+	public function reset_data($data_to_reset = array(), $show_all_notices = false)
1020
+	{
1021
+		// if $data_to_reset is not in an array, then put it in one
1022
+		if (! is_array($data_to_reset)) {
1023
+			$data_to_reset = array($data_to_reset);
1024
+		}
1025
+		// nothing ??? go home!
1026
+		if (empty($data_to_reset)) {
1027
+			EE_Error::add_error(
1028
+				__(
1029
+					'No session data could be reset, because no session var name was provided.',
1030
+					'event_espresso'
1031
+				),
1032
+				__FILE__,
1033
+				__FUNCTION__,
1034
+				__LINE__
1035
+			);
1036
+			return false;
1037
+		}
1038
+		$return_value = true;
1039
+		// since $data_to_reset is an array, cycle through the values
1040
+		foreach ($data_to_reset as $reset) {
1041
+			// first check to make sure it is a valid session var
1042
+			if (isset($this->_session_data[ $reset ])) {
1043
+				// then check to make sure it is not a default var
1044
+				if (! array_key_exists($reset, $this->_default_session_vars)) {
1045
+					// remove session var
1046
+					unset($this->_session_data[ $reset ]);
1047
+					if ($show_all_notices) {
1048
+						EE_Error::add_success(
1049
+							sprintf(
1050
+								__('The session variable %s was removed.', 'event_espresso'),
1051
+								$reset
1052
+							),
1053
+							__FILE__,
1054
+							__FUNCTION__,
1055
+							__LINE__
1056
+						);
1057
+					}
1058
+				} else {
1059
+					// yeeeeeeeeerrrrrrrrrrr OUT !!!!
1060
+					if ($show_all_notices) {
1061
+						EE_Error::add_error(
1062
+							sprintf(
1063
+								__(
1064
+									'Sorry! %s is a default session datum and can not be reset.',
1065
+									'event_espresso'
1066
+								),
1067
+								$reset
1068
+							),
1069
+							__FILE__,
1070
+							__FUNCTION__,
1071
+							__LINE__
1072
+						);
1073
+					}
1074
+					$return_value = false;
1075
+				}
1076
+			} elseif ($show_all_notices) {
1077
+				// oops! that session var does not exist!
1078
+				EE_Error::add_error(
1079
+					sprintf(
1080
+						__(
1081
+							'The session item provided, %s, is invalid or does not exist.',
1082
+							'event_espresso'
1083
+						),
1084
+						$reset
1085
+					),
1086
+					__FILE__,
1087
+					__FUNCTION__,
1088
+					__LINE__
1089
+				);
1090
+				$return_value = false;
1091
+			}
1092
+		} // end of foreach
1093
+		return $return_value;
1094
+	}
1095
+
1096
+
1097
+	/**
1098
+	 *   wp_loaded
1099
+	 *
1100
+	 * @access public
1101
+	 * @throws EE_Error
1102
+	 * @throws InvalidDataTypeException
1103
+	 * @throws InvalidInterfaceException
1104
+	 * @throws InvalidArgumentException
1105
+	 */
1106
+	public function wp_loaded()
1107
+	{
1108
+		if ($this->request->requestParamIsSet('clear_session')) {
1109
+			$this->clear_session(__CLASS__, __FUNCTION__);
1110
+		}
1111
+	}
1112
+
1113
+
1114
+	/**
1115
+	 * Used to reset the entire object (for tests).
1116
+	 *
1117
+	 * @since 4.3.0
1118
+	 * @throws EE_Error
1119
+	 * @throws InvalidDataTypeException
1120
+	 * @throws InvalidInterfaceException
1121
+	 * @throws InvalidArgumentException
1122
+	 */
1123
+	public function reset_instance()
1124
+	{
1125
+		$this->clear_session();
1126
+		self::$_instance = null;
1127
+	}
1128
+
1129
+
1130
+	public function configure_garbage_collection_filters()
1131
+	{
1132
+		// run old filter we had for controlling session cleanup
1133
+		$expired_session_transient_delete_query_limit = absint(
1134
+			apply_filters(
1135
+				'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit',
1136
+				50
1137
+			)
1138
+		);
1139
+		// is there a value? or one that is different than the default 50 records?
1140
+		if ($expired_session_transient_delete_query_limit === 0) {
1141
+			// hook into TransientCacheStorage in case Session cleanup was turned off
1142
+			add_filter('FHEE__TransientCacheStorage__transient_cleanup_schedule', '__return_zero');
1143
+		} elseif ($expired_session_transient_delete_query_limit !== 50) {
1144
+			// or use that for the new transient cleanup query limit
1145
+			add_filter(
1146
+				'FHEE__TransientCacheStorage__clearExpiredTransients__limit',
1147
+				function () use ($expired_session_transient_delete_query_limit) {
1148
+					return $expired_session_transient_delete_query_limit;
1149
+				}
1150
+			);
1151
+		}
1152
+	}
1153
+
1154
+
1155
+	/**
1156
+	 * @see http://stackoverflow.com/questions/10152904/unserialize-function-unserialize-error-at-offset/21389439#10152996
1157
+	 * @param $data1
1158
+	 * @return string
1159
+	 */
1160
+	private function find_serialize_error($data1)
1161
+	{
1162
+		$error = '<pre>';
1163
+		$data2 = preg_replace_callback(
1164
+			'!s:(\d+):"(.*?)";!',
1165
+			function ($match) {
1166
+				return ($match[1] === strlen($match[2]))
1167
+					? $match[0]
1168
+					: 's:'
1169
+					  . strlen($match[2])
1170
+					  . ':"'
1171
+					  . $match[2]
1172
+					  . '";';
1173
+			},
1174
+			$data1
1175
+		);
1176
+		$max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2);
1177
+		$error .= $data1 . PHP_EOL;
1178
+		$error .= $data2 . PHP_EOL;
1179
+		for ($i = 0; $i < $max; $i++) {
1180
+			if (@$data1[ $i ] !== @$data2[ $i ]) {
1181
+				$error .= 'Difference ' . @$data1[ $i ] . ' != ' . @$data2[ $i ] . PHP_EOL;
1182
+				$error .= "\t-> ORD number " . ord(@$data1[ $i ]) . ' != ' . ord(@$data2[ $i ]) . PHP_EOL;
1183
+				$error .= "\t-> Line Number = $i" . PHP_EOL;
1184
+				$start = ($i - 20);
1185
+				$start = ($start < 0) ? 0 : $start;
1186
+				$length = 40;
1187
+				$point = $max - $i;
1188
+				if ($point < 20) {
1189
+					$rlength = 1;
1190
+					$rpoint = -$point;
1191
+				} else {
1192
+					$rpoint = $length - 20;
1193
+					$rlength = 1;
1194
+				}
1195
+				$error .= "\t-> Section Data1  = ";
1196
+				$error .= substr_replace(
1197
+					substr($data1, $start, $length),
1198
+					"<b style=\"color:green\">{$data1[ $i ]}</b>",
1199
+					$rpoint,
1200
+					$rlength
1201
+				);
1202
+				$error .= PHP_EOL;
1203
+				$error .= "\t-> Section Data2  = ";
1204
+				$error .= substr_replace(
1205
+					substr($data2, $start, $length),
1206
+					"<b style=\"color:red\">{$data2[ $i ]}</b>",
1207
+					$rpoint,
1208
+					$rlength
1209
+				);
1210
+				$error .= PHP_EOL;
1211
+			}
1212
+		}
1213
+		$error .= '</pre>';
1214
+		return $error;
1215
+	}
1216
+
1217
+
1218
+	/**
1219
+	 * Saves an  array of settings used for configuring aspects of session behaviour
1220
+	 *
1221
+	 * @param array $updated_settings
1222
+	 */
1223
+	private function updateSessionSettings(array $updated_settings = array())
1224
+	{
1225
+		// add existing settings, but only if not included in incoming $updated_settings array
1226
+		$updated_settings += get_option(EE_Session::OPTION_NAME_SETTINGS, array());
1227
+		update_option(EE_Session::OPTION_NAME_SETTINGS, $updated_settings);
1228
+	}
1229
+
1230
+
1231
+	/**
1232
+	 * garbage_collection
1233
+	 */
1234
+	public function garbageCollection()
1235
+	{
1236
+		// only perform during regular requests if last garbage collection was over an hour ago
1237
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && (time() - HOUR_IN_SECONDS) >= $this->_last_gc) {
1238
+			$this->_last_gc = time();
1239
+			$this->updateSessionSettings(array('last_gc' => $this->_last_gc));
1240
+			/** @type WPDB $wpdb */
1241
+			global $wpdb;
1242
+			// filter the query limit. Set to 0 to turn off garbage collection
1243
+			$expired_session_transient_delete_query_limit = absint(
1244
+				apply_filters(
1245
+					'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit',
1246
+					50
1247
+				)
1248
+			);
1249
+			// non-zero LIMIT means take out the trash
1250
+			if ($expired_session_transient_delete_query_limit) {
1251
+				$session_key = str_replace('_', '\_', EE_Session::session_id_prefix);
1252
+				$hash_check_key = str_replace('_', '\_', EE_Session::hash_check_prefix);
1253
+				// since transient expiration timestamps are set in the future, we can compare against NOW
1254
+				// but we only want to pick up any trash that's been around for more than a day
1255
+				$expiration = time() - DAY_IN_SECONDS;
1256
+				$SQL = "
1257 1257
                     SELECT option_name
1258 1258
                     FROM {$wpdb->options}
1259 1259
                     WHERE
@@ -1262,17 +1262,17 @@  discard block
 block discarded – undo
1262 1262
                     AND option_value < {$expiration}
1263 1263
                     LIMIT {$expired_session_transient_delete_query_limit}
1264 1264
                 ";
1265
-                // produces something like:
1266
-                // SELECT option_name FROM wp_options
1267
-                // WHERE ( option_name LIKE '\_transient\_timeout\_ee\_ssn\_%'
1268
-                // OR option_name LIKE '\_transient\_timeout\_ee\_shc\_%' )
1269
-                // AND option_value < 1508368198 LIMIT 50
1270
-                $expired_sessions = $wpdb->get_col($SQL);
1271
-                // valid results?
1272
-                if (! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) {
1273
-                    $this->cache_storage->deleteMany($expired_sessions, true);
1274
-                }
1275
-            }
1276
-        }
1277
-    }
1265
+				// produces something like:
1266
+				// SELECT option_name FROM wp_options
1267
+				// WHERE ( option_name LIKE '\_transient\_timeout\_ee\_ssn\_%'
1268
+				// OR option_name LIKE '\_transient\_timeout\_ee\_shc\_%' )
1269
+				// AND option_value < 1508368198 LIMIT 50
1270
+				$expired_sessions = $wpdb->get_col($SQL);
1271
+				// valid results?
1272
+				if (! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) {
1273
+					$this->cache_storage->deleteMany($expired_sessions, true);
1274
+				}
1275
+			}
1276
+		}
1277
+	}
1278 1278
 }
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         // check if class object is instantiated
187 187
         // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via:
188 188
         // add_filter( 'FHEE_load_EE_Session', '__return_false' );
189
-        if (! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) {
189
+        if ( ! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) {
190 190
             self::$_instance = new self(
191 191
                 $cache_storage,
192 192
                 $lifespan,
@@ -219,21 +219,21 @@  discard block
 block discarded – undo
219 219
         // but prior to the 'AHEE__EE_System__core_loaded_and_ready' hook
220 220
         // (which currently fires on the init hook at priority 9),
221 221
         // can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' );
222
-        if (! apply_filters('FHEE_load_EE_Session', true)) {
222
+        if ( ! apply_filters('FHEE_load_EE_Session', true)) {
223 223
             return;
224 224
         }
225 225
         $this->session_lifespan = $lifespan;
226 226
         $this->request = $request;
227
-        if (! defined('ESPRESSO_SESSION')) {
227
+        if ( ! defined('ESPRESSO_SESSION')) {
228 228
             define('ESPRESSO_SESSION', true);
229 229
         }
230 230
         // retrieve session options from db
231 231
         $session_settings = (array) get_option(EE_Session::OPTION_NAME_SETTINGS, array());
232
-        if (! empty($session_settings)) {
232
+        if ( ! empty($session_settings)) {
233 233
             // cycle though existing session options
234 234
             foreach ($session_settings as $var_name => $session_setting) {
235 235
                 // set values for class properties
236
-                $var_name = '_' . $var_name;
236
+                $var_name = '_'.$var_name;
237 237
                 $this->{$var_name} = $session_setting;
238 238
             }
239 239
         }
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
     public function open_session()
293 293
     {
294 294
         // check for existing session and retrieve it from db
295
-        if (! $this->_espresso_session()) {
295
+        if ( ! $this->_espresso_session()) {
296 296
             // or just start a new one
297 297
             $this->_create_espresso_session();
298 298
         }
@@ -365,9 +365,9 @@  discard block
 block discarded – undo
365 365
         // set some defaults
366 366
         foreach ($this->_default_session_vars as $key => $default_var) {
367 367
             if (is_array($default_var)) {
368
-                $this->_session_data[ $key ] = array();
368
+                $this->_session_data[$key] = array();
369 369
             } else {
370
-                $this->_session_data[ $key ] = '';
370
+                $this->_session_data[$key] = '';
371 371
             }
372 372
         }
373 373
     }
@@ -498,8 +498,8 @@  discard block
 block discarded – undo
498 498
             $this->reset_checkout();
499 499
             $this->reset_transaction();
500 500
         }
501
-        if (! empty($key)) {
502
-            return isset($this->_session_data[ $key ]) ? $this->_session_data[ $key ] : null;
501
+        if ( ! empty($key)) {
502
+            return isset($this->_session_data[$key]) ? $this->_session_data[$key] : null;
503 503
         }
504 504
         return $this->_session_data;
505 505
     }
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
             return false;
528 528
         }
529 529
         foreach ($data as $key => $value) {
530
-            if (isset($this->_default_session_vars[ $key ])) {
530
+            if (isset($this->_default_session_vars[$key])) {
531 531
                 EE_Error::add_error(
532 532
                     sprintf(
533 533
                         esc_html__(
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
                 );
543 543
                 return false;
544 544
             }
545
-            $this->_session_data[ $key ] = $value;
545
+            $this->_session_data[$key] = $value;
546 546
         }
547 547
         return true;
548 548
     }
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
         $this->_user_agent = $this->request->userAgent();
576 576
         // now let's retrieve what's in the db
577 577
         $session_data = $this->_retrieve_session_data();
578
-        if (! empty($session_data)) {
578
+        if ( ! empty($session_data)) {
579 579
             // get the current time in UTC
580 580
             $this->_time = $this->_time !== null ? $this->_time : time();
581 581
             // and reset the session expiration
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
             // set initial site access time and the session expiration
587 587
             $this->_set_init_access_and_expiration();
588 588
             // set referer
589
-            $this->_session_data['pages_visited'][ $this->_session_data['init_access'] ] = isset($_SERVER['HTTP_REFERER'])
589
+            $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER'])
590 590
                 ? esc_attr($_SERVER['HTTP_REFERER'])
591 591
                 : '';
592 592
             // no previous session = go back and create one (on top of the data above)
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
      */
624 624
     protected function _retrieve_session_data()
625 625
     {
626
-        $ssn_key = EE_Session::session_id_prefix . $this->_sid;
626
+        $ssn_key = EE_Session::session_id_prefix.$this->_sid;
627 627
         try {
628 628
             // we're using WP's Transient API to store session data using the PHP session ID as the option name
629 629
             $session_data = $this->cache_storage->get($ssn_key, false);
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
             }
633 633
             if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
634 634
                 $hash_check = $this->cache_storage->get(
635
-                    EE_Session::hash_check_prefix . $this->_sid,
635
+                    EE_Session::hash_check_prefix.$this->_sid,
636 636
                     false
637 637
                 );
638 638
                 if ($hash_check && $hash_check !== md5($session_data)) {
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
                                 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.',
643 643
                                 'event_espresso'
644 644
                             ),
645
-                            EE_Session::session_id_prefix . $this->_sid
645
+                            EE_Session::session_id_prefix.$this->_sid
646 646
                         ),
647 647
                         __FILE__,
648 648
                         __FUNCTION__,
@@ -656,17 +656,17 @@  discard block
 block discarded – undo
656 656
             $row = $wpdb->get_row(
657 657
                 $wpdb->prepare(
658 658
                     "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
659
-                    '_transient_' . $ssn_key
659
+                    '_transient_'.$ssn_key
660 660
                 )
661 661
             );
662 662
             $session_data = is_object($row) ? $row->option_value : null;
663 663
             if ($session_data) {
664 664
                 $session_data = preg_replace_callback(
665 665
                     '!s:(d+):"(.*?)";!',
666
-                    function ($match) {
666
+                    function($match) {
667 667
                         return $match[1] === strlen($match[2])
668 668
                             ? $match[0]
669
-                            : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
669
+                            : 's:'.strlen($match[2]).':"'.$match[2].'";';
670 670
                     },
671 671
                     $session_data
672 672
                 );
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
         $session_data = $this->encryption instanceof EE_Encryption
678 678
             ? $this->encryption->base64_string_decode($session_data)
679 679
             : $session_data;
680
-        if (! is_array($session_data)) {
680
+        if ( ! is_array($session_data)) {
681 681
             try {
682 682
                 $session_data = maybe_unserialize($session_data);
683 683
             } catch (Exception $e) {
@@ -691,21 +691,21 @@  discard block
 block discarded – undo
691 691
                       . '</pre><br>'
692 692
                       . $this->find_serialize_error($session_data)
693 693
                     : '';
694
-                $this->cache_storage->delete(EE_Session::session_id_prefix . $this->_sid);
694
+                $this->cache_storage->delete(EE_Session::session_id_prefix.$this->_sid);
695 695
                 throw new InvalidSessionDataException($msg, 0, $e);
696 696
             }
697 697
         }
698 698
         // just a check to make sure the session array is indeed an array
699
-        if (! is_array($session_data)) {
699
+        if ( ! is_array($session_data)) {
700 700
             // no?!?! then something is wrong
701 701
             $msg = esc_html__(
702 702
                 'The session data is missing, invalid, or corrupted.',
703 703
                 'event_espresso'
704 704
             );
705 705
             $msg .= WP_DEBUG
706
-                ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
706
+                ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data)
707 707
                 : '';
708
-            $this->cache_storage->delete(EE_Session::session_id_prefix . $this->_sid);
708
+            $this->cache_storage->delete(EE_Session::session_id_prefix.$this->_sid);
709 709
             throw new InvalidSessionDataException($msg);
710 710
         }
711 711
         if (isset($session_data['transaction']) && absint($session_data['transaction']) !== 0) {
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
         if (isset($_REQUEST['EESID'])) {
733 733
             $session_id = sanitize_text_field($_REQUEST['EESID']);
734 734
         } else {
735
-            $session_id = md5(session_id() . get_current_blog_id() . $this->_get_sid_salt());
735
+            $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt());
736 736
         }
737 737
         return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id);
738 738
     }
@@ -835,19 +835,19 @@  discard block
 block discarded – undo
835 835
                     $page_visit = $this->_get_page_visit();
836 836
                     if ($page_visit) {
837 837
                         // set pages visited where the first will be the http referrer
838
-                        $this->_session_data['pages_visited'][ $this->_time ] = $page_visit;
838
+                        $this->_session_data['pages_visited'][$this->_time] = $page_visit;
839 839
                         // we'll only save the last 10 page visits.
840 840
                         $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10);
841 841
                     }
842 842
                     break;
843 843
                 default:
844 844
                     // carry any other data over
845
-                    $session_data[ $key ] = $this->_session_data[ $key ];
845
+                    $session_data[$key] = $this->_session_data[$key];
846 846
             }
847 847
         }
848 848
         $this->_session_data = $session_data;
849 849
         // creating a new session does not require saving to the db just yet
850
-        if (! $new_session) {
850
+        if ( ! $new_session) {
851 851
             // ready? let's save
852 852
             if ($this->_save_session_to_db()) {
853 853
                 return true;
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
         }
902 902
         $transaction = $this->transaction();
903 903
         if ($transaction instanceof EE_Transaction) {
904
-            if (! $transaction->ID()) {
904
+            if ( ! $transaction->ID()) {
905 905
                 $transaction->save();
906 906
             }
907 907
             $this->_session_data['transaction'] = $transaction->ID();
@@ -915,14 +915,14 @@  discard block
 block discarded – undo
915 915
         // maybe save hash check
916 916
         if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
917 917
             $this->cache_storage->add(
918
-                EE_Session::hash_check_prefix . $this->_sid,
918
+                EE_Session::hash_check_prefix.$this->_sid,
919 919
                 md5($session_data),
920 920
                 $this->session_lifespan->inSeconds()
921 921
             );
922 922
         }
923 923
         // we're using the Transient API for storing session data,
924 924
         return $this->cache_storage->add(
925
-            EE_Session::session_id_prefix . $this->_sid,
925
+            EE_Session::session_id_prefix.$this->_sid,
926 926
             $session_data,
927 927
             $this->session_lifespan->inSeconds()
928 928
         );
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
      */
937 937
     public function _get_page_visit()
938 938
     {
939
-        $page_visit = home_url('/') . 'wp-admin/admin-ajax.php';
939
+        $page_visit = home_url('/').'wp-admin/admin-ajax.php';
940 940
         // check for request url
941 941
         if (isset($_SERVER['REQUEST_URI'])) {
942 942
             $http_host = '';
@@ -952,14 +952,14 @@  discard block
 block discarded – undo
952 952
             // check for page_id in SERVER REQUEST
953 953
             if (isset($_REQUEST['page_id'])) {
954 954
                 // rebuild $e_reg without any of the extra parameters
955
-                $page_id = '?page_id=' . esc_attr($_REQUEST['page_id']) . '&amp;';
955
+                $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&amp;';
956 956
             }
957 957
             // check for $e_reg in SERVER REQUEST
958 958
             if (isset($_REQUEST['ee'])) {
959 959
                 // rebuild $e_reg without any of the extra parameters
960
-                $e_reg = 'ee=' . esc_attr($_REQUEST['ee']);
960
+                $e_reg = 'ee='.esc_attr($_REQUEST['ee']);
961 961
             }
962
-            $page_visit = rtrim($http_host . $request_uri . $page_id . $e_reg, '?');
962
+            $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?');
963 963
         }
964 964
         return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : '';
965 965
     }
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
 // <span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/>
998 998
 // <span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span>    <b style="font-size:10px;">  ' . __LINE__ . ' </b>
999 999
 // </h3>';
1000
-        do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()');
1000
+        do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()');
1001 1001
         $this->reset_cart();
1002 1002
         $this->reset_checkout();
1003 1003
         $this->reset_transaction();
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
     public function reset_data($data_to_reset = array(), $show_all_notices = false)
1020 1020
     {
1021 1021
         // if $data_to_reset is not in an array, then put it in one
1022
-        if (! is_array($data_to_reset)) {
1022
+        if ( ! is_array($data_to_reset)) {
1023 1023
             $data_to_reset = array($data_to_reset);
1024 1024
         }
1025 1025
         // nothing ??? go home!
@@ -1039,11 +1039,11 @@  discard block
 block discarded – undo
1039 1039
         // since $data_to_reset is an array, cycle through the values
1040 1040
         foreach ($data_to_reset as $reset) {
1041 1041
             // first check to make sure it is a valid session var
1042
-            if (isset($this->_session_data[ $reset ])) {
1042
+            if (isset($this->_session_data[$reset])) {
1043 1043
                 // then check to make sure it is not a default var
1044
-                if (! array_key_exists($reset, $this->_default_session_vars)) {
1044
+                if ( ! array_key_exists($reset, $this->_default_session_vars)) {
1045 1045
                     // remove session var
1046
-                    unset($this->_session_data[ $reset ]);
1046
+                    unset($this->_session_data[$reset]);
1047 1047
                     if ($show_all_notices) {
1048 1048
                         EE_Error::add_success(
1049 1049
                             sprintf(
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
             // or use that for the new transient cleanup query limit
1145 1145
             add_filter(
1146 1146
                 'FHEE__TransientCacheStorage__clearExpiredTransients__limit',
1147
-                function () use ($expired_session_transient_delete_query_limit) {
1147
+                function() use ($expired_session_transient_delete_query_limit) {
1148 1148
                     return $expired_session_transient_delete_query_limit;
1149 1149
                 }
1150 1150
             );
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
         $error = '<pre>';
1163 1163
         $data2 = preg_replace_callback(
1164 1164
             '!s:(\d+):"(.*?)";!',
1165
-            function ($match) {
1165
+            function($match) {
1166 1166
                 return ($match[1] === strlen($match[2]))
1167 1167
                     ? $match[0]
1168 1168
                     : 's:'
@@ -1174,13 +1174,13 @@  discard block
 block discarded – undo
1174 1174
             $data1
1175 1175
         );
1176 1176
         $max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2);
1177
-        $error .= $data1 . PHP_EOL;
1178
-        $error .= $data2 . PHP_EOL;
1177
+        $error .= $data1.PHP_EOL;
1178
+        $error .= $data2.PHP_EOL;
1179 1179
         for ($i = 0; $i < $max; $i++) {
1180
-            if (@$data1[ $i ] !== @$data2[ $i ]) {
1181
-                $error .= 'Difference ' . @$data1[ $i ] . ' != ' . @$data2[ $i ] . PHP_EOL;
1182
-                $error .= "\t-> ORD number " . ord(@$data1[ $i ]) . ' != ' . ord(@$data2[ $i ]) . PHP_EOL;
1183
-                $error .= "\t-> Line Number = $i" . PHP_EOL;
1180
+            if (@$data1[$i] !== @$data2[$i]) {
1181
+                $error .= 'Difference '.@$data1[$i].' != '.@$data2[$i].PHP_EOL;
1182
+                $error .= "\t-> ORD number ".ord(@$data1[$i]).' != '.ord(@$data2[$i]).PHP_EOL;
1183
+                $error .= "\t-> Line Number = $i".PHP_EOL;
1184 1184
                 $start = ($i - 20);
1185 1185
                 $start = ($start < 0) ? 0 : $start;
1186 1186
                 $length = 40;
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
                 $error .= "\t-> Section Data1  = ";
1196 1196
                 $error .= substr_replace(
1197 1197
                     substr($data1, $start, $length),
1198
-                    "<b style=\"color:green\">{$data1[ $i ]}</b>",
1198
+                    "<b style=\"color:green\">{$data1[$i]}</b>",
1199 1199
                     $rpoint,
1200 1200
                     $rlength
1201 1201
                 );
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
                 $error .= "\t-> Section Data2  = ";
1204 1204
                 $error .= substr_replace(
1205 1205
                     substr($data2, $start, $length),
1206
-                    "<b style=\"color:red\">{$data2[ $i ]}</b>",
1206
+                    "<b style=\"color:red\">{$data2[$i]}</b>",
1207 1207
                     $rpoint,
1208 1208
                     $rlength
1209 1209
                 );
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
     public function garbageCollection()
1235 1235
     {
1236 1236
         // only perform during regular requests if last garbage collection was over an hour ago
1237
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && (time() - HOUR_IN_SECONDS) >= $this->_last_gc) {
1237
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && (time() - HOUR_IN_SECONDS) >= $this->_last_gc) {
1238 1238
             $this->_last_gc = time();
1239 1239
             $this->updateSessionSettings(array('last_gc' => $this->_last_gc));
1240 1240
             /** @type WPDB $wpdb */
@@ -1269,7 +1269,7 @@  discard block
 block discarded – undo
1269 1269
                 // AND option_value < 1508368198 LIMIT 50
1270 1270
                 $expired_sessions = $wpdb->get_col($SQL);
1271 1271
                 // valid results?
1272
-                if (! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) {
1272
+                if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) {
1273 1273
                     $this->cache_storage->deleteMany($expired_sessions, true);
1274 1274
                 }
1275 1275
             }
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +994 added lines, -994 removed lines patch added patch discarded remove patch
@@ -20,998 +20,998 @@
 block discarded – undo
20 20
 class EE_Dependency_Map
21 21
 {
22 22
 
23
-    /**
24
-     * This means that the requested class dependency is not present in the dependency map
25
-     */
26
-    const not_registered = 0;
27
-
28
-    /**
29
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
-     */
31
-    const load_new_object = 1;
32
-
33
-    /**
34
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
-     */
37
-    const load_from_cache = 2;
38
-
39
-    /**
40
-     * When registering a dependency,
41
-     * this indicates to keep any existing dependencies that already exist,
42
-     * and simply discard any new dependencies declared in the incoming data
43
-     */
44
-    const KEEP_EXISTING_DEPENDENCIES = 0;
45
-
46
-    /**
47
-     * When registering a dependency,
48
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
-     */
50
-    const OVERWRITE_DEPENDENCIES = 1;
51
-
52
-
53
-    /**
54
-     * @type EE_Dependency_Map $_instance
55
-     */
56
-    protected static $_instance;
57
-
58
-    /**
59
-     * @var ClassInterfaceCache $class_cache
60
-     */
61
-    private $class_cache;
62
-
63
-    /**
64
-     * @type RequestInterface $request
65
-     */
66
-    protected $request;
67
-
68
-    /**
69
-     * @type LegacyRequestInterface $legacy_request
70
-     */
71
-    protected $legacy_request;
72
-
73
-    /**
74
-     * @type ResponseInterface $response
75
-     */
76
-    protected $response;
77
-
78
-    /**
79
-     * @type LoaderInterface $loader
80
-     */
81
-    protected $loader;
82
-
83
-    /**
84
-     * @type array $_dependency_map
85
-     */
86
-    protected $_dependency_map = array();
87
-
88
-    /**
89
-     * @type array $_class_loaders
90
-     */
91
-    protected $_class_loaders = array();
92
-
93
-
94
-    /**
95
-     * EE_Dependency_Map constructor.
96
-     *
97
-     * @param ClassInterfaceCache $class_cache
98
-     */
99
-    protected function __construct(ClassInterfaceCache $class_cache)
100
-    {
101
-        $this->class_cache = $class_cache;
102
-        do_action('EE_Dependency_Map____construct', $this);
103
-    }
104
-
105
-
106
-    /**
107
-     * @return void
108
-     */
109
-    public function initialize()
110
-    {
111
-        $this->_register_core_dependencies();
112
-        $this->_register_core_class_loaders();
113
-        $this->_register_core_aliases();
114
-    }
115
-
116
-
117
-    /**
118
-     * @singleton method used to instantiate class object
119
-     * @param ClassInterfaceCache|null $class_cache
120
-     * @return EE_Dependency_Map
121
-     */
122
-    public static function instance(ClassInterfaceCache $class_cache = null)
123
-    {
124
-        // check if class object is instantiated, and instantiated properly
125
-        if (! self::$_instance instanceof EE_Dependency_Map
126
-            && $class_cache instanceof ClassInterfaceCache
127
-        ) {
128
-            self::$_instance = new EE_Dependency_Map($class_cache);
129
-        }
130
-        return self::$_instance;
131
-    }
132
-
133
-
134
-    /**
135
-     * @param RequestInterface $request
136
-     */
137
-    public function setRequest(RequestInterface $request)
138
-    {
139
-        $this->request = $request;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param LegacyRequestInterface $legacy_request
145
-     */
146
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
-    {
148
-        $this->legacy_request = $legacy_request;
149
-    }
150
-
151
-
152
-    /**
153
-     * @param ResponseInterface $response
154
-     */
155
-    public function setResponse(ResponseInterface $response)
156
-    {
157
-        $this->response = $response;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param LoaderInterface $loader
163
-     */
164
-    public function setLoader(LoaderInterface $loader)
165
-    {
166
-        $this->loader = $loader;
167
-    }
168
-
169
-
170
-    /**
171
-     * @param string $class
172
-     * @param array  $dependencies
173
-     * @param int    $overwrite
174
-     * @return bool
175
-     */
176
-    public static function register_dependencies(
177
-        $class,
178
-        array $dependencies,
179
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
-    ) {
181
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
-    }
183
-
184
-
185
-    /**
186
-     * Assigns an array of class names and corresponding load sources (new or cached)
187
-     * to the class specified by the first parameter.
188
-     * IMPORTANT !!!
189
-     * The order of elements in the incoming $dependencies array MUST match
190
-     * the order of the constructor parameters for the class in question.
191
-     * This is especially important when overriding any existing dependencies that are registered.
192
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
-     *
194
-     * @param string $class
195
-     * @param array  $dependencies
196
-     * @param int    $overwrite
197
-     * @return bool
198
-     */
199
-    public function registerDependencies(
200
-        $class,
201
-        array $dependencies,
202
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
-    ) {
204
-        $class = trim($class, '\\');
205
-        $registered = false;
206
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
207
-            self::$_instance->_dependency_map[ $class ] = array();
208
-        }
209
-        // we need to make sure that any aliases used when registering a dependency
210
-        // get resolved to the correct class name
211
-        foreach ($dependencies as $dependency => $load_source) {
212
-            $alias = self::$_instance->getFqnForAlias($dependency);
213
-            if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
-            ) {
216
-                unset($dependencies[ $dependency ]);
217
-                $dependencies[ $alias ] = $load_source;
218
-                $registered = true;
219
-            }
220
-        }
221
-        // now add our two lists of dependencies together.
222
-        // using Union (+=) favours the arrays in precedence from left to right,
223
-        // so $dependencies is NOT overwritten because it is listed first
224
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
-        // Union is way faster than array_merge() but should be used with caution...
226
-        // especially with numerically indexed arrays
227
-        $dependencies += self::$_instance->_dependency_map[ $class ];
228
-        // now we need to ensure that the resulting dependencies
229
-        // array only has the entries that are required for the class
230
-        // so first count how many dependencies were originally registered for the class
231
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
-        // if that count is non-zero (meaning dependencies were already registered)
233
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
234
-            // then truncate the  final array to match that count
235
-            ? array_slice($dependencies, 0, $dependency_count)
236
-            // otherwise just take the incoming array because nothing previously existed
237
-            : $dependencies;
238
-        return $registered;
239
-    }
240
-
241
-
242
-    /**
243
-     * @param string $class_name
244
-     * @param string $loader
245
-     * @return bool
246
-     * @throws DomainException
247
-     */
248
-    public static function register_class_loader($class_name, $loader = 'load_core')
249
-    {
250
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
-            throw new DomainException(
252
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
-            );
254
-        }
255
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
256
-        if (! is_callable($loader)
257
-            && (
258
-                strpos($loader, 'load_') !== 0
259
-                || ! method_exists('EE_Registry', $loader)
260
-            )
261
-        ) {
262
-            throw new DomainException(
263
-                sprintf(
264
-                    esc_html__(
265
-                        '"%1$s" is not a valid loader method on EE_Registry.',
266
-                        'event_espresso'
267
-                    ),
268
-                    $loader
269
-                )
270
-            );
271
-        }
272
-        $class_name = self::$_instance->getFqnForAlias($class_name);
273
-        if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
-            self::$_instance->_class_loaders[ $class_name ] = $loader;
275
-            return true;
276
-        }
277
-        return false;
278
-    }
279
-
280
-
281
-    /**
282
-     * @return array
283
-     */
284
-    public function dependency_map()
285
-    {
286
-        return $this->_dependency_map;
287
-    }
288
-
289
-
290
-    /**
291
-     * returns TRUE if dependency map contains a listing for the provided class name
292
-     *
293
-     * @param string $class_name
294
-     * @return boolean
295
-     */
296
-    public function has($class_name = '')
297
-    {
298
-        // all legacy models have the same dependencies
299
-        if (strpos($class_name, 'EEM_') === 0) {
300
-            $class_name = 'LEGACY_MODELS';
301
-        }
302
-        return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
-    }
304
-
305
-
306
-    /**
307
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
-     *
309
-     * @param string $class_name
310
-     * @param string $dependency
311
-     * @return bool
312
-     */
313
-    public function has_dependency_for_class($class_name = '', $dependency = '')
314
-    {
315
-        // all legacy models have the same dependencies
316
-        if (strpos($class_name, 'EEM_') === 0) {
317
-            $class_name = 'LEGACY_MODELS';
318
-        }
319
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
320
-        return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
-            ? true
322
-            : false;
323
-    }
324
-
325
-
326
-    /**
327
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
-     *
329
-     * @param string $class_name
330
-     * @param string $dependency
331
-     * @return int
332
-     */
333
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
-    {
335
-        // all legacy models have the same dependencies
336
-        if (strpos($class_name, 'EEM_') === 0) {
337
-            $class_name = 'LEGACY_MODELS';
338
-        }
339
-        $dependency = $this->getFqnForAlias($dependency);
340
-        return $this->has_dependency_for_class($class_name, $dependency)
341
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
342
-            : EE_Dependency_Map::not_registered;
343
-    }
344
-
345
-
346
-    /**
347
-     * @param string $class_name
348
-     * @return string | Closure
349
-     */
350
-    public function class_loader($class_name)
351
-    {
352
-        // all legacy models use load_model()
353
-        if (strpos($class_name, 'EEM_') === 0) {
354
-            return 'load_model';
355
-        }
356
-        // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
-        // perform strpos() first to avoid loading regex every time we load a class
358
-        if (strpos($class_name, 'EE_CPT_') === 0
359
-            && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
-        ) {
361
-            return 'load_core';
362
-        }
363
-        $class_name = $this->getFqnForAlias($class_name);
364
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
-    }
366
-
367
-
368
-    /**
369
-     * @return array
370
-     */
371
-    public function class_loaders()
372
-    {
373
-        return $this->_class_loaders;
374
-    }
375
-
376
-
377
-    /**
378
-     * adds an alias for a classname
379
-     *
380
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
-     */
384
-    public function add_alias($fqcn, $alias, $for_class = '')
385
-    {
386
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
387
-    }
388
-
389
-
390
-    /**
391
-     * Returns TRUE if the provided fully qualified name IS an alias
392
-     * WHY?
393
-     * Because if a class is type hinting for a concretion,
394
-     * then why would we need to find another class to supply it?
395
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
-     * Don't go looking for some substitute.
398
-     * Whereas if a class is type hinting for an interface...
399
-     * then we need to find an actual class to use.
400
-     * So the interface IS the alias for some other FQN,
401
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
-     * represents some other class.
403
-     *
404
-     * @param string $fqn
405
-     * @param string $for_class
406
-     * @return bool
407
-     */
408
-    public function isAlias($fqn = '', $for_class = '')
409
-    {
410
-        return $this->class_cache->isAlias($fqn, $for_class);
411
-    }
412
-
413
-
414
-    /**
415
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
-     *  for example:
418
-     *      if the following two entries were added to the _aliases array:
419
-     *          array(
420
-     *              'interface_alias'           => 'some\namespace\interface'
421
-     *              'some\namespace\interface'  => 'some\namespace\classname'
422
-     *          )
423
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
-     *      to load an instance of 'some\namespace\classname'
425
-     *
426
-     * @param string $alias
427
-     * @param string $for_class
428
-     * @return string
429
-     */
430
-    public function getFqnForAlias($alias = '', $for_class = '')
431
-    {
432
-        return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
-    }
434
-
435
-
436
-    /**
437
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
-     * This is done by using the following class constants:
440
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
442
-     */
443
-    protected function _register_core_dependencies()
444
-    {
445
-        $this->_dependency_map = array(
446
-            'EE_Request_Handler'                                                                                          => array(
447
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
448
-            ),
449
-            'EE_System'                                                                                                   => array(
450
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
-            ),
455
-            'EE_Session'                                                                                                  => array(
456
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
460
-            ),
461
-            'EE_Cart'                                                                                                     => array(
462
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
463
-            ),
464
-            'EE_Front_Controller'                                                                                         => array(
465
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
466
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
467
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
468
-            ),
469
-            'EE_Messenger_Collection_Loader'                                                                              => array(
470
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
471
-            ),
472
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
473
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
474
-            ),
475
-            'EE_Message_Resource_Manager'                                                                                 => array(
476
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
477
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
478
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
479
-            ),
480
-            'EE_Message_Factory'                                                                                          => array(
481
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
482
-            ),
483
-            'EE_messages'                                                                                                 => array(
484
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
485
-            ),
486
-            'EE_Messages_Generator'                                                                                       => array(
487
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
488
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
489
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
490
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
491
-            ),
492
-            'EE_Messages_Processor'                                                                                       => array(
493
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
494
-            ),
495
-            'EE_Messages_Queue'                                                                                           => array(
496
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
497
-            ),
498
-            'EE_Messages_Template_Defaults'                                                                               => array(
499
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
500
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
501
-            ),
502
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
503
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
504
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
505
-            ),
506
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
507
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
508
-            ),
509
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
510
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
511
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
512
-            ),
513
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
514
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
515
-            ),
516
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
517
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
518
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
519
-            ),
520
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
521
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
522
-            ),
523
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
524
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
525
-            ),
526
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
527
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
528
-            ),
529
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
530
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
531
-            ),
532
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
533
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
534
-            ),
535
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
536
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
537
-            ),
538
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
539
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
540
-            ),
541
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
542
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
543
-            ),
544
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
545
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
546
-            ),
547
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
548
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
549
-            ),
550
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
551
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
552
-            ),
553
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
554
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
555
-            ),
556
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
557
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
558
-            ),
559
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
560
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
561
-            ),
562
-            'EE_Data_Migration_Class_Base'                                                                                => array(
563
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
564
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
565
-            ),
566
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
567
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
568
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
569
-            ),
570
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
571
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
572
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
573
-            ),
574
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
575
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
576
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
577
-            ),
578
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
579
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
581
-            ),
582
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
583
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
584
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
585
-            ),
586
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
587
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
588
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
589
-            ),
590
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
591
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
592
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
593
-            ),
594
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
595
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
596
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
597
-            ),
598
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
599
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
600
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
601
-            ),
602
-            'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
603
-                array(),
604
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
605
-            ),
606
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
607
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
608
-                'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
609
-            ),
610
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
611
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
612
-            ),
613
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
614
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
615
-            ),
616
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
617
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
-            ),
619
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
620
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
621
-            ),
622
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
623
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
624
-            ),
625
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
626
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
627
-            ),
628
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
629
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
-            ),
631
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
632
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
633
-            ),
634
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
635
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
636
-            ),
637
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
638
-                'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
639
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
640
-            ),
641
-            'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
642
-                null,
643
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
644
-            ),
645
-            'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
646
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
647
-            ),
648
-            'LEGACY_MODELS'                                                                                               => array(
649
-                null,
650
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
651
-            ),
652
-            'EE_Module_Request_Router'                                                                                    => array(
653
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
654
-            ),
655
-            'EE_Registration_Processor'                                                                                   => array(
656
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
657
-            ),
658
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
659
-                null,
660
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
661
-                'EE_Request'                                                          => EE_Dependency_Map::load_from_cache,
662
-            ),
663
-            'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
664
-                'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
665
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
666
-            ),
667
-            'EE_Admin_Transactions_List_Table'                                                                            => array(
668
-                null,
669
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
670
-            ),
671
-            'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
672
-                'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
673
-                'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
674
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
675
-            ),
676
-            'EventEspresso\core\domain\services\pue\Config'                                                               => array(
677
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
678
-                'EE_Config'         => EE_Dependency_Map::load_from_cache,
679
-            ),
680
-            'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
681
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
682
-                'EEM_Event'          => EE_Dependency_Map::load_from_cache,
683
-                'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
684
-                'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
685
-                'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
686
-                'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
687
-                'EE_Config'          => EE_Dependency_Map::load_from_cache,
688
-            ),
689
-            'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
690
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
691
-            ),
692
-            'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
693
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
694
-            ),
695
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
696
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
697
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
698
-            ),
699
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
700
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
701
-            ),
702
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
703
-                'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
704
-                'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
705
-                'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
706
-                'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
707
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
708
-            ),
709
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
710
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
711
-            ),
712
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
713
-                'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
714
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
715
-            ),
716
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
717
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
718
-            ),
719
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
720
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
721
-            ),
722
-            'EE_CPT_Strategy'                                                                                             => array(
723
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
724
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
725
-            ),
726
-            'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
727
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
728
-            ),
729
-            'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
730
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
731
-                'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
732
-                'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
733
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
734
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
735
-            ),
736
-            'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
737
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
738
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
739
-            ),
740
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
741
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
742
-            ),
743
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
744
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
745
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
746
-            ),
747
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
748
-                'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
749
-            ),
750
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
751
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
752
-            ),
753
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
754
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
755
-            ),
756
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
757
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
758
-            ),
759
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
760
-                'EEM_Answer' => EE_Dependency_Map::load_from_cache,
761
-                'EEM_Question' => EE_Dependency_Map::load_from_cache,
762
-            ),
763
-            'EventEspresso\core\CPTs\CptQueryModifier' => array(
764
-                null,
765
-                null,
766
-                null,
767
-                'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
768
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
769
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
770
-            ),
771
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
772
-                'EE_Registry' => EE_Dependency_Map::load_from_cache,
773
-                'EE_Config' => EE_Dependency_Map::load_from_cache
774
-            ),
775
-        );
776
-    }
777
-
778
-
779
-    /**
780
-     * Registers how core classes are loaded.
781
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
782
-     *        'EE_Request_Handler' => 'load_core'
783
-     *        'EE_Messages_Queue'  => 'load_lib'
784
-     *        'EEH_Debug_Tools'    => 'load_helper'
785
-     * or, if greater control is required, by providing a custom closure. For example:
786
-     *        'Some_Class' => function () {
787
-     *            return new Some_Class();
788
-     *        },
789
-     * This is required for instantiating dependencies
790
-     * where an interface has been type hinted in a class constructor. For example:
791
-     *        'Required_Interface' => function () {
792
-     *            return new A_Class_That_Implements_Required_Interface();
793
-     *        },
794
-     */
795
-    protected function _register_core_class_loaders()
796
-    {
797
-        // for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
798
-        // be used in a closure.
799
-        $request = &$this->request;
800
-        $response = &$this->response;
801
-        $legacy_request = &$this->legacy_request;
802
-        // $loader = &$this->loader;
803
-        $this->_class_loaders = array(
804
-            // load_core
805
-            'EE_Capabilities'                              => 'load_core',
806
-            'EE_Encryption'                                => 'load_core',
807
-            'EE_Front_Controller'                          => 'load_core',
808
-            'EE_Module_Request_Router'                     => 'load_core',
809
-            'EE_Registry'                                  => 'load_core',
810
-            'EE_Request'                                   => function () use (&$legacy_request) {
811
-                return $legacy_request;
812
-            },
813
-            'EventEspresso\core\services\request\Request'  => function () use (&$request) {
814
-                return $request;
815
-            },
816
-            'EventEspresso\core\services\request\Response' => function () use (&$response) {
817
-                return $response;
818
-            },
819
-            'EE_Base'                                      => 'load_core',
820
-            'EE_Request_Handler'                           => 'load_core',
821
-            'EE_Session'                                   => 'load_core',
822
-            'EE_Cron_Tasks'                                => 'load_core',
823
-            'EE_System'                                    => 'load_core',
824
-            'EE_Maintenance_Mode'                          => 'load_core',
825
-            'EE_Register_CPTs'                             => 'load_core',
826
-            'EE_Admin'                                     => 'load_core',
827
-            'EE_CPT_Strategy'                              => 'load_core',
828
-            // load_lib
829
-            'EE_Message_Resource_Manager'                  => 'load_lib',
830
-            'EE_Message_Type_Collection'                   => 'load_lib',
831
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
832
-            'EE_Messenger_Collection'                      => 'load_lib',
833
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
834
-            'EE_Messages_Processor'                        => 'load_lib',
835
-            'EE_Message_Repository'                        => 'load_lib',
836
-            'EE_Messages_Queue'                            => 'load_lib',
837
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
838
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
839
-            'EE_Payment_Method_Manager'                    => 'load_lib',
840
-            'EE_Messages_Generator'                        => function () {
841
-                return EE_Registry::instance()->load_lib(
842
-                    'Messages_Generator',
843
-                    array(),
844
-                    false,
845
-                    false
846
-                );
847
-            },
848
-            'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
849
-                return EE_Registry::instance()->load_lib(
850
-                    'Messages_Template_Defaults',
851
-                    $arguments,
852
-                    false,
853
-                    false
854
-                );
855
-            },
856
-            // load_helper
857
-            'EEH_Parse_Shortcodes'                         => function () {
858
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
859
-                    return new EEH_Parse_Shortcodes();
860
-                }
861
-                return null;
862
-            },
863
-            'EE_Template_Config'                           => function () {
864
-                return EE_Config::instance()->template_settings;
865
-            },
866
-            'EE_Currency_Config'                           => function () {
867
-                return EE_Config::instance()->currency;
868
-            },
869
-            'EE_Registration_Config'                       => function () {
870
-                return EE_Config::instance()->registration;
871
-            },
872
-            'EE_Core_Config'                               => function () {
873
-                return EE_Config::instance()->core;
874
-            },
875
-            'EventEspresso\core\services\loaders\Loader'   => function () {
876
-                return LoaderFactory::getLoader();
877
-            },
878
-            'EE_Network_Config'                            => function () {
879
-                return EE_Network_Config::instance();
880
-            },
881
-            'EE_Config'                                    => function () {
882
-                return EE_Config::instance();
883
-            },
884
-            'EventEspresso\core\domain\Domain'             => function () {
885
-                return DomainFactory::getEventEspressoCoreDomain();
886
-            },
887
-            'EE_Admin_Config'                              => function () {
888
-                return EE_Config::instance()->admin;
889
-            },
890
-        );
891
-    }
892
-
893
-
894
-    /**
895
-     * can be used for supplying alternate names for classes,
896
-     * or for connecting interface names to instantiable classes
897
-     */
898
-    protected function _register_core_aliases()
899
-    {
900
-        $aliases = array(
901
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
902
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
903
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
904
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
905
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
906
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
907
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
908
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
909
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
910
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
911
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
912
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
913
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
914
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
915
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
916
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
917
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
918
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
919
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
920
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
921
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
922
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
923
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
924
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
925
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
926
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
927
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
928
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
929
-            'EventEspresso\core\domain\services\session\SessionIdentifierInterface'        => 'EE_Session',
930
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
931
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
932
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
933
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
934
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
935
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
936
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
937
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
938
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
939
-        );
940
-        foreach ($aliases as $alias => $fqn) {
941
-            if (is_array($fqn)) {
942
-                foreach ($fqn as $class => $for_class) {
943
-                    $this->class_cache->addAlias($class, $alias, $for_class);
944
-                }
945
-                continue;
946
-            }
947
-            $this->class_cache->addAlias($fqn, $alias);
948
-        }
949
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
950
-            $this->class_cache->addAlias(
951
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
952
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
953
-            );
954
-        }
955
-    }
956
-
957
-
958
-    /**
959
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
960
-     * request Primarily used by unit tests.
961
-     */
962
-    public function reset()
963
-    {
964
-        $this->_register_core_class_loaders();
965
-        $this->_register_core_dependencies();
966
-    }
967
-
968
-
969
-    /**
970
-     * PLZ NOTE: a better name for this method would be is_alias()
971
-     * because it returns TRUE if the provided fully qualified name IS an alias
972
-     * WHY?
973
-     * Because if a class is type hinting for a concretion,
974
-     * then why would we need to find another class to supply it?
975
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
976
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
977
-     * Don't go looking for some substitute.
978
-     * Whereas if a class is type hinting for an interface...
979
-     * then we need to find an actual class to use.
980
-     * So the interface IS the alias for some other FQN,
981
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
982
-     * represents some other class.
983
-     *
984
-     * @deprecated 4.9.62.p
985
-     * @param string $fqn
986
-     * @param string $for_class
987
-     * @return bool
988
-     */
989
-    public function has_alias($fqn = '', $for_class = '')
990
-    {
991
-        return $this->isAlias($fqn, $for_class);
992
-    }
993
-
994
-
995
-    /**
996
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
997
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
998
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
999
-     *  for example:
1000
-     *      if the following two entries were added to the _aliases array:
1001
-     *          array(
1002
-     *              'interface_alias'           => 'some\namespace\interface'
1003
-     *              'some\namespace\interface'  => 'some\namespace\classname'
1004
-     *          )
1005
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1006
-     *      to load an instance of 'some\namespace\classname'
1007
-     *
1008
-     * @deprecated 4.9.62.p
1009
-     * @param string $alias
1010
-     * @param string $for_class
1011
-     * @return string
1012
-     */
1013
-    public function get_alias($alias = '', $for_class = '')
1014
-    {
1015
-        return $this->getFqnForAlias($alias, $for_class);
1016
-    }
23
+	/**
24
+	 * This means that the requested class dependency is not present in the dependency map
25
+	 */
26
+	const not_registered = 0;
27
+
28
+	/**
29
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
+	 */
31
+	const load_new_object = 1;
32
+
33
+	/**
34
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
+	 */
37
+	const load_from_cache = 2;
38
+
39
+	/**
40
+	 * When registering a dependency,
41
+	 * this indicates to keep any existing dependencies that already exist,
42
+	 * and simply discard any new dependencies declared in the incoming data
43
+	 */
44
+	const KEEP_EXISTING_DEPENDENCIES = 0;
45
+
46
+	/**
47
+	 * When registering a dependency,
48
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
+	 */
50
+	const OVERWRITE_DEPENDENCIES = 1;
51
+
52
+
53
+	/**
54
+	 * @type EE_Dependency_Map $_instance
55
+	 */
56
+	protected static $_instance;
57
+
58
+	/**
59
+	 * @var ClassInterfaceCache $class_cache
60
+	 */
61
+	private $class_cache;
62
+
63
+	/**
64
+	 * @type RequestInterface $request
65
+	 */
66
+	protected $request;
67
+
68
+	/**
69
+	 * @type LegacyRequestInterface $legacy_request
70
+	 */
71
+	protected $legacy_request;
72
+
73
+	/**
74
+	 * @type ResponseInterface $response
75
+	 */
76
+	protected $response;
77
+
78
+	/**
79
+	 * @type LoaderInterface $loader
80
+	 */
81
+	protected $loader;
82
+
83
+	/**
84
+	 * @type array $_dependency_map
85
+	 */
86
+	protected $_dependency_map = array();
87
+
88
+	/**
89
+	 * @type array $_class_loaders
90
+	 */
91
+	protected $_class_loaders = array();
92
+
93
+
94
+	/**
95
+	 * EE_Dependency_Map constructor.
96
+	 *
97
+	 * @param ClassInterfaceCache $class_cache
98
+	 */
99
+	protected function __construct(ClassInterfaceCache $class_cache)
100
+	{
101
+		$this->class_cache = $class_cache;
102
+		do_action('EE_Dependency_Map____construct', $this);
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return void
108
+	 */
109
+	public function initialize()
110
+	{
111
+		$this->_register_core_dependencies();
112
+		$this->_register_core_class_loaders();
113
+		$this->_register_core_aliases();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @singleton method used to instantiate class object
119
+	 * @param ClassInterfaceCache|null $class_cache
120
+	 * @return EE_Dependency_Map
121
+	 */
122
+	public static function instance(ClassInterfaceCache $class_cache = null)
123
+	{
124
+		// check if class object is instantiated, and instantiated properly
125
+		if (! self::$_instance instanceof EE_Dependency_Map
126
+			&& $class_cache instanceof ClassInterfaceCache
127
+		) {
128
+			self::$_instance = new EE_Dependency_Map($class_cache);
129
+		}
130
+		return self::$_instance;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @param RequestInterface $request
136
+	 */
137
+	public function setRequest(RequestInterface $request)
138
+	{
139
+		$this->request = $request;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param LegacyRequestInterface $legacy_request
145
+	 */
146
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
+	{
148
+		$this->legacy_request = $legacy_request;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @param ResponseInterface $response
154
+	 */
155
+	public function setResponse(ResponseInterface $response)
156
+	{
157
+		$this->response = $response;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param LoaderInterface $loader
163
+	 */
164
+	public function setLoader(LoaderInterface $loader)
165
+	{
166
+		$this->loader = $loader;
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param string $class
172
+	 * @param array  $dependencies
173
+	 * @param int    $overwrite
174
+	 * @return bool
175
+	 */
176
+	public static function register_dependencies(
177
+		$class,
178
+		array $dependencies,
179
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
+	) {
181
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
+	}
183
+
184
+
185
+	/**
186
+	 * Assigns an array of class names and corresponding load sources (new or cached)
187
+	 * to the class specified by the first parameter.
188
+	 * IMPORTANT !!!
189
+	 * The order of elements in the incoming $dependencies array MUST match
190
+	 * the order of the constructor parameters for the class in question.
191
+	 * This is especially important when overriding any existing dependencies that are registered.
192
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
+	 *
194
+	 * @param string $class
195
+	 * @param array  $dependencies
196
+	 * @param int    $overwrite
197
+	 * @return bool
198
+	 */
199
+	public function registerDependencies(
200
+		$class,
201
+		array $dependencies,
202
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
+	) {
204
+		$class = trim($class, '\\');
205
+		$registered = false;
206
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
207
+			self::$_instance->_dependency_map[ $class ] = array();
208
+		}
209
+		// we need to make sure that any aliases used when registering a dependency
210
+		// get resolved to the correct class name
211
+		foreach ($dependencies as $dependency => $load_source) {
212
+			$alias = self::$_instance->getFqnForAlias($dependency);
213
+			if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
+			) {
216
+				unset($dependencies[ $dependency ]);
217
+				$dependencies[ $alias ] = $load_source;
218
+				$registered = true;
219
+			}
220
+		}
221
+		// now add our two lists of dependencies together.
222
+		// using Union (+=) favours the arrays in precedence from left to right,
223
+		// so $dependencies is NOT overwritten because it is listed first
224
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
+		// Union is way faster than array_merge() but should be used with caution...
226
+		// especially with numerically indexed arrays
227
+		$dependencies += self::$_instance->_dependency_map[ $class ];
228
+		// now we need to ensure that the resulting dependencies
229
+		// array only has the entries that are required for the class
230
+		// so first count how many dependencies were originally registered for the class
231
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
+		// if that count is non-zero (meaning dependencies were already registered)
233
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
234
+			// then truncate the  final array to match that count
235
+			? array_slice($dependencies, 0, $dependency_count)
236
+			// otherwise just take the incoming array because nothing previously existed
237
+			: $dependencies;
238
+		return $registered;
239
+	}
240
+
241
+
242
+	/**
243
+	 * @param string $class_name
244
+	 * @param string $loader
245
+	 * @return bool
246
+	 * @throws DomainException
247
+	 */
248
+	public static function register_class_loader($class_name, $loader = 'load_core')
249
+	{
250
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
+			throw new DomainException(
252
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
+			);
254
+		}
255
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
256
+		if (! is_callable($loader)
257
+			&& (
258
+				strpos($loader, 'load_') !== 0
259
+				|| ! method_exists('EE_Registry', $loader)
260
+			)
261
+		) {
262
+			throw new DomainException(
263
+				sprintf(
264
+					esc_html__(
265
+						'"%1$s" is not a valid loader method on EE_Registry.',
266
+						'event_espresso'
267
+					),
268
+					$loader
269
+				)
270
+			);
271
+		}
272
+		$class_name = self::$_instance->getFqnForAlias($class_name);
273
+		if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
+			self::$_instance->_class_loaders[ $class_name ] = $loader;
275
+			return true;
276
+		}
277
+		return false;
278
+	}
279
+
280
+
281
+	/**
282
+	 * @return array
283
+	 */
284
+	public function dependency_map()
285
+	{
286
+		return $this->_dependency_map;
287
+	}
288
+
289
+
290
+	/**
291
+	 * returns TRUE if dependency map contains a listing for the provided class name
292
+	 *
293
+	 * @param string $class_name
294
+	 * @return boolean
295
+	 */
296
+	public function has($class_name = '')
297
+	{
298
+		// all legacy models have the same dependencies
299
+		if (strpos($class_name, 'EEM_') === 0) {
300
+			$class_name = 'LEGACY_MODELS';
301
+		}
302
+		return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
+	}
304
+
305
+
306
+	/**
307
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
+	 *
309
+	 * @param string $class_name
310
+	 * @param string $dependency
311
+	 * @return bool
312
+	 */
313
+	public function has_dependency_for_class($class_name = '', $dependency = '')
314
+	{
315
+		// all legacy models have the same dependencies
316
+		if (strpos($class_name, 'EEM_') === 0) {
317
+			$class_name = 'LEGACY_MODELS';
318
+		}
319
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
320
+		return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
+			? true
322
+			: false;
323
+	}
324
+
325
+
326
+	/**
327
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
+	 *
329
+	 * @param string $class_name
330
+	 * @param string $dependency
331
+	 * @return int
332
+	 */
333
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
+	{
335
+		// all legacy models have the same dependencies
336
+		if (strpos($class_name, 'EEM_') === 0) {
337
+			$class_name = 'LEGACY_MODELS';
338
+		}
339
+		$dependency = $this->getFqnForAlias($dependency);
340
+		return $this->has_dependency_for_class($class_name, $dependency)
341
+			? $this->_dependency_map[ $class_name ][ $dependency ]
342
+			: EE_Dependency_Map::not_registered;
343
+	}
344
+
345
+
346
+	/**
347
+	 * @param string $class_name
348
+	 * @return string | Closure
349
+	 */
350
+	public function class_loader($class_name)
351
+	{
352
+		// all legacy models use load_model()
353
+		if (strpos($class_name, 'EEM_') === 0) {
354
+			return 'load_model';
355
+		}
356
+		// EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
+		// perform strpos() first to avoid loading regex every time we load a class
358
+		if (strpos($class_name, 'EE_CPT_') === 0
359
+			&& preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
+		) {
361
+			return 'load_core';
362
+		}
363
+		$class_name = $this->getFqnForAlias($class_name);
364
+		return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
+	}
366
+
367
+
368
+	/**
369
+	 * @return array
370
+	 */
371
+	public function class_loaders()
372
+	{
373
+		return $this->_class_loaders;
374
+	}
375
+
376
+
377
+	/**
378
+	 * adds an alias for a classname
379
+	 *
380
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
+	 */
384
+	public function add_alias($fqcn, $alias, $for_class = '')
385
+	{
386
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
387
+	}
388
+
389
+
390
+	/**
391
+	 * Returns TRUE if the provided fully qualified name IS an alias
392
+	 * WHY?
393
+	 * Because if a class is type hinting for a concretion,
394
+	 * then why would we need to find another class to supply it?
395
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
+	 * Don't go looking for some substitute.
398
+	 * Whereas if a class is type hinting for an interface...
399
+	 * then we need to find an actual class to use.
400
+	 * So the interface IS the alias for some other FQN,
401
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
+	 * represents some other class.
403
+	 *
404
+	 * @param string $fqn
405
+	 * @param string $for_class
406
+	 * @return bool
407
+	 */
408
+	public function isAlias($fqn = '', $for_class = '')
409
+	{
410
+		return $this->class_cache->isAlias($fqn, $for_class);
411
+	}
412
+
413
+
414
+	/**
415
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
+	 *  for example:
418
+	 *      if the following two entries were added to the _aliases array:
419
+	 *          array(
420
+	 *              'interface_alias'           => 'some\namespace\interface'
421
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
422
+	 *          )
423
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
+	 *      to load an instance of 'some\namespace\classname'
425
+	 *
426
+	 * @param string $alias
427
+	 * @param string $for_class
428
+	 * @return string
429
+	 */
430
+	public function getFqnForAlias($alias = '', $for_class = '')
431
+	{
432
+		return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
+	}
434
+
435
+
436
+	/**
437
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
+	 * This is done by using the following class constants:
440
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
442
+	 */
443
+	protected function _register_core_dependencies()
444
+	{
445
+		$this->_dependency_map = array(
446
+			'EE_Request_Handler'                                                                                          => array(
447
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
448
+			),
449
+			'EE_System'                                                                                                   => array(
450
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
+			),
455
+			'EE_Session'                                                                                                  => array(
456
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
460
+			),
461
+			'EE_Cart'                                                                                                     => array(
462
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
463
+			),
464
+			'EE_Front_Controller'                                                                                         => array(
465
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
466
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
467
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
468
+			),
469
+			'EE_Messenger_Collection_Loader'                                                                              => array(
470
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
471
+			),
472
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
473
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
474
+			),
475
+			'EE_Message_Resource_Manager'                                                                                 => array(
476
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
477
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
478
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
479
+			),
480
+			'EE_Message_Factory'                                                                                          => array(
481
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
482
+			),
483
+			'EE_messages'                                                                                                 => array(
484
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
485
+			),
486
+			'EE_Messages_Generator'                                                                                       => array(
487
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
488
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
489
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
490
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
491
+			),
492
+			'EE_Messages_Processor'                                                                                       => array(
493
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
494
+			),
495
+			'EE_Messages_Queue'                                                                                           => array(
496
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
497
+			),
498
+			'EE_Messages_Template_Defaults'                                                                               => array(
499
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
500
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
501
+			),
502
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
503
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
504
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
505
+			),
506
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
507
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
508
+			),
509
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
510
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
511
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
512
+			),
513
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
514
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
515
+			),
516
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
517
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
518
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
519
+			),
520
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
521
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
522
+			),
523
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
524
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
525
+			),
526
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
527
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
528
+			),
529
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
530
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
531
+			),
532
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
533
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
534
+			),
535
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
536
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
537
+			),
538
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
539
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
540
+			),
541
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
542
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
543
+			),
544
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
545
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
546
+			),
547
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
548
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
549
+			),
550
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
551
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
552
+			),
553
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
554
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
555
+			),
556
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
557
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
558
+			),
559
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
560
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
561
+			),
562
+			'EE_Data_Migration_Class_Base'                                                                                => array(
563
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
564
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
565
+			),
566
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
567
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
568
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
569
+			),
570
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
571
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
572
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
573
+			),
574
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
575
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
576
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
577
+			),
578
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
579
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
581
+			),
582
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
583
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
584
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
585
+			),
586
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
587
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
588
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
589
+			),
590
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
591
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
592
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
593
+			),
594
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
595
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
596
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
597
+			),
598
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
599
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
600
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
601
+			),
602
+			'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
603
+				array(),
604
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
605
+			),
606
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
607
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
608
+				'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
609
+			),
610
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
611
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
612
+			),
613
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
614
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
615
+			),
616
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
617
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
+			),
619
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
620
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
621
+			),
622
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
623
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
624
+			),
625
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
626
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
627
+			),
628
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
629
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
630
+			),
631
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
632
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
633
+			),
634
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
635
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
636
+			),
637
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
638
+				'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
639
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
640
+			),
641
+			'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
642
+				null,
643
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
644
+			),
645
+			'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
646
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
647
+			),
648
+			'LEGACY_MODELS'                                                                                               => array(
649
+				null,
650
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
651
+			),
652
+			'EE_Module_Request_Router'                                                                                    => array(
653
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
654
+			),
655
+			'EE_Registration_Processor'                                                                                   => array(
656
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
657
+			),
658
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
659
+				null,
660
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
661
+				'EE_Request'                                                          => EE_Dependency_Map::load_from_cache,
662
+			),
663
+			'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
664
+				'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
665
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
666
+			),
667
+			'EE_Admin_Transactions_List_Table'                                                                            => array(
668
+				null,
669
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
670
+			),
671
+			'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
672
+				'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
673
+				'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
674
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
675
+			),
676
+			'EventEspresso\core\domain\services\pue\Config'                                                               => array(
677
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
678
+				'EE_Config'         => EE_Dependency_Map::load_from_cache,
679
+			),
680
+			'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
681
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
682
+				'EEM_Event'          => EE_Dependency_Map::load_from_cache,
683
+				'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
684
+				'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
685
+				'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
686
+				'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
687
+				'EE_Config'          => EE_Dependency_Map::load_from_cache,
688
+			),
689
+			'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
690
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
691
+			),
692
+			'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
693
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
694
+			),
695
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
696
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
697
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
698
+			),
699
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
700
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
701
+			),
702
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
703
+				'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
704
+				'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
705
+				'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
706
+				'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
707
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
708
+			),
709
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
710
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
711
+			),
712
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
713
+				'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
714
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
715
+			),
716
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
717
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
718
+			),
719
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
720
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
721
+			),
722
+			'EE_CPT_Strategy'                                                                                             => array(
723
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
724
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
725
+			),
726
+			'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
727
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
728
+			),
729
+			'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
730
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
731
+				'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
732
+				'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
733
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
734
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
735
+			),
736
+			'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
737
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
738
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
739
+			),
740
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
741
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
742
+			),
743
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
744
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
745
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
746
+			),
747
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
748
+				'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
749
+			),
750
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
751
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
752
+			),
753
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
754
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
755
+			),
756
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
757
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
758
+			),
759
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
760
+				'EEM_Answer' => EE_Dependency_Map::load_from_cache,
761
+				'EEM_Question' => EE_Dependency_Map::load_from_cache,
762
+			),
763
+			'EventEspresso\core\CPTs\CptQueryModifier' => array(
764
+				null,
765
+				null,
766
+				null,
767
+				'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
768
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
769
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
770
+			),
771
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
772
+				'EE_Registry' => EE_Dependency_Map::load_from_cache,
773
+				'EE_Config' => EE_Dependency_Map::load_from_cache
774
+			),
775
+		);
776
+	}
777
+
778
+
779
+	/**
780
+	 * Registers how core classes are loaded.
781
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
782
+	 *        'EE_Request_Handler' => 'load_core'
783
+	 *        'EE_Messages_Queue'  => 'load_lib'
784
+	 *        'EEH_Debug_Tools'    => 'load_helper'
785
+	 * or, if greater control is required, by providing a custom closure. For example:
786
+	 *        'Some_Class' => function () {
787
+	 *            return new Some_Class();
788
+	 *        },
789
+	 * This is required for instantiating dependencies
790
+	 * where an interface has been type hinted in a class constructor. For example:
791
+	 *        'Required_Interface' => function () {
792
+	 *            return new A_Class_That_Implements_Required_Interface();
793
+	 *        },
794
+	 */
795
+	protected function _register_core_class_loaders()
796
+	{
797
+		// for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
798
+		// be used in a closure.
799
+		$request = &$this->request;
800
+		$response = &$this->response;
801
+		$legacy_request = &$this->legacy_request;
802
+		// $loader = &$this->loader;
803
+		$this->_class_loaders = array(
804
+			// load_core
805
+			'EE_Capabilities'                              => 'load_core',
806
+			'EE_Encryption'                                => 'load_core',
807
+			'EE_Front_Controller'                          => 'load_core',
808
+			'EE_Module_Request_Router'                     => 'load_core',
809
+			'EE_Registry'                                  => 'load_core',
810
+			'EE_Request'                                   => function () use (&$legacy_request) {
811
+				return $legacy_request;
812
+			},
813
+			'EventEspresso\core\services\request\Request'  => function () use (&$request) {
814
+				return $request;
815
+			},
816
+			'EventEspresso\core\services\request\Response' => function () use (&$response) {
817
+				return $response;
818
+			},
819
+			'EE_Base'                                      => 'load_core',
820
+			'EE_Request_Handler'                           => 'load_core',
821
+			'EE_Session'                                   => 'load_core',
822
+			'EE_Cron_Tasks'                                => 'load_core',
823
+			'EE_System'                                    => 'load_core',
824
+			'EE_Maintenance_Mode'                          => 'load_core',
825
+			'EE_Register_CPTs'                             => 'load_core',
826
+			'EE_Admin'                                     => 'load_core',
827
+			'EE_CPT_Strategy'                              => 'load_core',
828
+			// load_lib
829
+			'EE_Message_Resource_Manager'                  => 'load_lib',
830
+			'EE_Message_Type_Collection'                   => 'load_lib',
831
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
832
+			'EE_Messenger_Collection'                      => 'load_lib',
833
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
834
+			'EE_Messages_Processor'                        => 'load_lib',
835
+			'EE_Message_Repository'                        => 'load_lib',
836
+			'EE_Messages_Queue'                            => 'load_lib',
837
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
838
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
839
+			'EE_Payment_Method_Manager'                    => 'load_lib',
840
+			'EE_Messages_Generator'                        => function () {
841
+				return EE_Registry::instance()->load_lib(
842
+					'Messages_Generator',
843
+					array(),
844
+					false,
845
+					false
846
+				);
847
+			},
848
+			'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
849
+				return EE_Registry::instance()->load_lib(
850
+					'Messages_Template_Defaults',
851
+					$arguments,
852
+					false,
853
+					false
854
+				);
855
+			},
856
+			// load_helper
857
+			'EEH_Parse_Shortcodes'                         => function () {
858
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
859
+					return new EEH_Parse_Shortcodes();
860
+				}
861
+				return null;
862
+			},
863
+			'EE_Template_Config'                           => function () {
864
+				return EE_Config::instance()->template_settings;
865
+			},
866
+			'EE_Currency_Config'                           => function () {
867
+				return EE_Config::instance()->currency;
868
+			},
869
+			'EE_Registration_Config'                       => function () {
870
+				return EE_Config::instance()->registration;
871
+			},
872
+			'EE_Core_Config'                               => function () {
873
+				return EE_Config::instance()->core;
874
+			},
875
+			'EventEspresso\core\services\loaders\Loader'   => function () {
876
+				return LoaderFactory::getLoader();
877
+			},
878
+			'EE_Network_Config'                            => function () {
879
+				return EE_Network_Config::instance();
880
+			},
881
+			'EE_Config'                                    => function () {
882
+				return EE_Config::instance();
883
+			},
884
+			'EventEspresso\core\domain\Domain'             => function () {
885
+				return DomainFactory::getEventEspressoCoreDomain();
886
+			},
887
+			'EE_Admin_Config'                              => function () {
888
+				return EE_Config::instance()->admin;
889
+			},
890
+		);
891
+	}
892
+
893
+
894
+	/**
895
+	 * can be used for supplying alternate names for classes,
896
+	 * or for connecting interface names to instantiable classes
897
+	 */
898
+	protected function _register_core_aliases()
899
+	{
900
+		$aliases = array(
901
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
902
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
903
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
904
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
905
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
906
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
907
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
908
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
909
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
910
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
911
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
912
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
913
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
914
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
915
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
916
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
917
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
918
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
919
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
920
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
921
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
922
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
923
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
924
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
925
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
926
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
927
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
928
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
929
+			'EventEspresso\core\domain\services\session\SessionIdentifierInterface'        => 'EE_Session',
930
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
931
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
932
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
933
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
934
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
935
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
936
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
937
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
938
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
939
+		);
940
+		foreach ($aliases as $alias => $fqn) {
941
+			if (is_array($fqn)) {
942
+				foreach ($fqn as $class => $for_class) {
943
+					$this->class_cache->addAlias($class, $alias, $for_class);
944
+				}
945
+				continue;
946
+			}
947
+			$this->class_cache->addAlias($fqn, $alias);
948
+		}
949
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
950
+			$this->class_cache->addAlias(
951
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
952
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
953
+			);
954
+		}
955
+	}
956
+
957
+
958
+	/**
959
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
960
+	 * request Primarily used by unit tests.
961
+	 */
962
+	public function reset()
963
+	{
964
+		$this->_register_core_class_loaders();
965
+		$this->_register_core_dependencies();
966
+	}
967
+
968
+
969
+	/**
970
+	 * PLZ NOTE: a better name for this method would be is_alias()
971
+	 * because it returns TRUE if the provided fully qualified name IS an alias
972
+	 * WHY?
973
+	 * Because if a class is type hinting for a concretion,
974
+	 * then why would we need to find another class to supply it?
975
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
976
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
977
+	 * Don't go looking for some substitute.
978
+	 * Whereas if a class is type hinting for an interface...
979
+	 * then we need to find an actual class to use.
980
+	 * So the interface IS the alias for some other FQN,
981
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
982
+	 * represents some other class.
983
+	 *
984
+	 * @deprecated 4.9.62.p
985
+	 * @param string $fqn
986
+	 * @param string $for_class
987
+	 * @return bool
988
+	 */
989
+	public function has_alias($fqn = '', $for_class = '')
990
+	{
991
+		return $this->isAlias($fqn, $for_class);
992
+	}
993
+
994
+
995
+	/**
996
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
997
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
998
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
999
+	 *  for example:
1000
+	 *      if the following two entries were added to the _aliases array:
1001
+	 *          array(
1002
+	 *              'interface_alias'           => 'some\namespace\interface'
1003
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
1004
+	 *          )
1005
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1006
+	 *      to load an instance of 'some\namespace\classname'
1007
+	 *
1008
+	 * @deprecated 4.9.62.p
1009
+	 * @param string $alias
1010
+	 * @param string $for_class
1011
+	 * @return string
1012
+	 */
1013
+	public function get_alias($alias = '', $for_class = '')
1014
+	{
1015
+		return $this->getFqnForAlias($alias, $for_class);
1016
+	}
1017 1017
 }
Please login to merge, or discard this patch.
core/EE_System.core.php 1 patch
Indentation   +1261 added lines, -1261 removed lines patch added patch discarded remove patch
@@ -27,1265 +27,1265 @@
 block discarded – undo
27 27
 final class EE_System implements ResettableInterface
28 28
 {
29 29
 
30
-    /**
31
-     * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
32
-     * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
33
-     */
34
-    const req_type_normal = 0;
35
-
36
-    /**
37
-     * Indicates this is a brand new installation of EE so we should install
38
-     * tables and default data etc
39
-     */
40
-    const req_type_new_activation = 1;
41
-
42
-    /**
43
-     * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
44
-     * and we just exited maintenance mode). We MUST check the database is setup properly
45
-     * and that default data is setup too
46
-     */
47
-    const req_type_reactivation = 2;
48
-
49
-    /**
50
-     * indicates that EE has been upgraded since its previous request.
51
-     * We may have data migration scripts to call and will want to trigger maintenance mode
52
-     */
53
-    const req_type_upgrade = 3;
54
-
55
-    /**
56
-     * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
57
-     */
58
-    const req_type_downgrade = 4;
59
-
60
-    /**
61
-     * @deprecated since version 4.6.0.dev.006
62
-     * Now whenever a new_activation is detected the request type is still just
63
-     * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
64
-     * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
65
-     * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
66
-     * (Specifically, when the migration manager indicates migrations are finished
67
-     * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
68
-     */
69
-    const req_type_activation_but_not_installed = 5;
70
-
71
-    /**
72
-     * option prefix for recording the activation history (like core's "espresso_db_update") of addons
73
-     */
74
-    const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
75
-
76
-    /**
77
-     * @var EE_System $_instance
78
-     */
79
-    private static $_instance;
80
-
81
-    /**
82
-     * @var EE_Registry $registry
83
-     */
84
-    private $registry;
85
-
86
-    /**
87
-     * @var LoaderInterface $loader
88
-     */
89
-    private $loader;
90
-
91
-    /**
92
-     * @var EE_Capabilities $capabilities
93
-     */
94
-    private $capabilities;
95
-
96
-    /**
97
-     * @var RequestInterface $request
98
-     */
99
-    private $request;
100
-
101
-    /**
102
-     * @var EE_Maintenance_Mode $maintenance_mode
103
-     */
104
-    private $maintenance_mode;
105
-
106
-    /**
107
-     * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
108
-     * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
109
-     *
110
-     * @var int $_req_type
111
-     */
112
-    private $_req_type;
113
-
114
-    /**
115
-     * Whether or not there was a non-micro version change in EE core version during this request
116
-     *
117
-     * @var boolean $_major_version_change
118
-     */
119
-    private $_major_version_change = false;
120
-
121
-    /**
122
-     * A Context DTO dedicated solely to identifying the current request type.
123
-     *
124
-     * @var RequestTypeContextCheckerInterface $request_type
125
-     */
126
-    private $request_type;
127
-
128
-
129
-    /**
130
-     * @singleton method used to instantiate class object
131
-     * @param EE_Registry|null         $registry
132
-     * @param LoaderInterface|null     $loader
133
-     * @param RequestInterface|null    $request
134
-     * @param EE_Maintenance_Mode|null $maintenance_mode
135
-     * @return EE_System
136
-     */
137
-    public static function instance(
138
-        EE_Registry $registry = null,
139
-        LoaderInterface $loader = null,
140
-        RequestInterface $request = null,
141
-        EE_Maintenance_Mode $maintenance_mode = null
142
-    ) {
143
-        // check if class object is instantiated
144
-        if (! self::$_instance instanceof EE_System) {
145
-            self::$_instance = new self($registry, $loader, $request, $maintenance_mode);
146
-        }
147
-        return self::$_instance;
148
-    }
149
-
150
-
151
-    /**
152
-     * resets the instance and returns it
153
-     *
154
-     * @return EE_System
155
-     */
156
-    public static function reset()
157
-    {
158
-        self::$_instance->_req_type = null;
159
-        // make sure none of the old hooks are left hanging around
160
-        remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
161
-        // we need to reset the migration manager in order for it to detect DMSs properly
162
-        EE_Data_Migration_Manager::reset();
163
-        self::instance()->detect_activations_or_upgrades();
164
-        self::instance()->perform_activations_upgrades_and_migrations();
165
-        return self::instance();
166
-    }
167
-
168
-
169
-    /**
170
-     * sets hooks for running rest of system
171
-     * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
172
-     * starting EE Addons from any other point may lead to problems
173
-     *
174
-     * @param EE_Registry         $registry
175
-     * @param LoaderInterface     $loader
176
-     * @param RequestInterface    $request
177
-     * @param EE_Maintenance_Mode $maintenance_mode
178
-     */
179
-    private function __construct(
180
-        EE_Registry $registry,
181
-        LoaderInterface $loader,
182
-        RequestInterface $request,
183
-        EE_Maintenance_Mode $maintenance_mode
184
-    ) {
185
-        $this->registry = $registry;
186
-        $this->loader = $loader;
187
-        $this->request = $request;
188
-        $this->maintenance_mode = $maintenance_mode;
189
-        do_action('AHEE__EE_System__construct__begin', $this);
190
-        add_action(
191
-            'AHEE__EE_Bootstrap__load_espresso_addons',
192
-            array($this, 'loadCapabilities'),
193
-            5
194
-        );
195
-        add_action(
196
-            'AHEE__EE_Bootstrap__load_espresso_addons',
197
-            array($this, 'loadCommandBus'),
198
-            7
199
-        );
200
-        add_action(
201
-            'AHEE__EE_Bootstrap__load_espresso_addons',
202
-            array($this, 'loadPluginApi'),
203
-            9
204
-        );
205
-        // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
206
-        add_action(
207
-            'AHEE__EE_Bootstrap__load_espresso_addons',
208
-            array($this, 'load_espresso_addons')
209
-        );
210
-        // when an ee addon is activated, we want to call the core hook(s) again
211
-        // because the newly-activated addon didn't get a chance to run at all
212
-        add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
213
-        // detect whether install or upgrade
214
-        add_action(
215
-            'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
216
-            array($this, 'detect_activations_or_upgrades'),
217
-            3
218
-        );
219
-        // load EE_Config, EE_Textdomain, etc
220
-        add_action(
221
-            'AHEE__EE_Bootstrap__load_core_configuration',
222
-            array($this, 'load_core_configuration'),
223
-            5
224
-        );
225
-        // load EE_Config, EE_Textdomain, etc
226
-        add_action(
227
-            'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
228
-            array($this, 'register_shortcodes_modules_and_widgets'),
229
-            7
230
-        );
231
-        // you wanna get going? I wanna get going... let's get going!
232
-        add_action(
233
-            'AHEE__EE_Bootstrap__brew_espresso',
234
-            array($this, 'brew_espresso'),
235
-            9
236
-        );
237
-        // other housekeeping
238
-        // exclude EE critical pages from wp_list_pages
239
-        add_filter(
240
-            'wp_list_pages_excludes',
241
-            array($this, 'remove_pages_from_wp_list_pages'),
242
-            10
243
-        );
244
-        // ALL EE Addons should use the following hook point to attach their initial setup too
245
-        // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
246
-        do_action('AHEE__EE_System__construct__complete', $this);
247
-    }
248
-
249
-
250
-    /**
251
-     * load and setup EE_Capabilities
252
-     *
253
-     * @return void
254
-     * @throws EE_Error
255
-     */
256
-    public function loadCapabilities()
257
-    {
258
-        $this->capabilities = $this->loader->getShared('EE_Capabilities');
259
-        add_action(
260
-            'AHEE__EE_Capabilities__init_caps__before_initialization',
261
-            function () {
262
-                LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
263
-            }
264
-        );
265
-    }
266
-
267
-
268
-    /**
269
-     * create and cache the CommandBus, and also add middleware
270
-     * The CapChecker middleware requires the use of EE_Capabilities
271
-     * which is why we need to load the CommandBus after Caps are set up
272
-     *
273
-     * @return void
274
-     * @throws EE_Error
275
-     */
276
-    public function loadCommandBus()
277
-    {
278
-        $this->loader->getShared(
279
-            'CommandBusInterface',
280
-            array(
281
-                null,
282
-                apply_filters(
283
-                    'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
284
-                    array(
285
-                        $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'),
286
-                        $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'),
287
-                    )
288
-                ),
289
-            )
290
-        );
291
-    }
292
-
293
-
294
-    /**
295
-     * @return void
296
-     * @throws EE_Error
297
-     */
298
-    public function loadPluginApi()
299
-    {
300
-        // set autoloaders for all of the classes implementing EEI_Plugin_API
301
-        // which provide helpers for EE plugin authors to more easily register certain components with EE.
302
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
303
-        $this->loader->getShared('EE_Request_Handler');
304
-    }
305
-
306
-
307
-    /**
308
-     * @param string $addon_name
309
-     * @param string $version_constant
310
-     * @param string $min_version_required
311
-     * @param string $load_callback
312
-     * @param string $plugin_file_constant
313
-     * @return void
314
-     */
315
-    private function deactivateIncompatibleAddon(
316
-        $addon_name,
317
-        $version_constant,
318
-        $min_version_required,
319
-        $load_callback,
320
-        $plugin_file_constant
321
-    ) {
322
-        if (! defined($version_constant)) {
323
-            return;
324
-        }
325
-        $addon_version = constant($version_constant);
326
-        if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
327
-            remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
328
-            if (! function_exists('deactivate_plugins')) {
329
-                require_once ABSPATH . 'wp-admin/includes/plugin.php';
330
-            }
331
-            deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
332
-            unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
333
-            EE_Error::add_error(
334
-                sprintf(
335
-                    esc_html__(
336
-                        'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.',
337
-                        'event_espresso'
338
-                    ),
339
-                    $addon_name,
340
-                    $min_version_required
341
-                ),
342
-                __FILE__,
343
-                __FUNCTION__ . "({$addon_name})",
344
-                __LINE__
345
-            );
346
-            EE_Error::get_notices(false, true);
347
-        }
348
-    }
349
-
350
-
351
-    /**
352
-     * load_espresso_addons
353
-     * allow addons to load first so that they can set hooks for running DMS's, etc
354
-     * this is hooked into both:
355
-     *    'AHEE__EE_Bootstrap__load_core_configuration'
356
-     *        which runs during the WP 'plugins_loaded' action at priority 5
357
-     *    and the WP 'activate_plugin' hook point
358
-     *
359
-     * @access public
360
-     * @return void
361
-     */
362
-    public function load_espresso_addons()
363
-    {
364
-        $this->deactivateIncompatibleAddon(
365
-            'Wait Lists',
366
-            'EE_WAIT_LISTS_VERSION',
367
-            '1.0.0.beta.074',
368
-            'load_espresso_wait_lists',
369
-            'EE_WAIT_LISTS_PLUGIN_FILE'
370
-        );
371
-        $this->deactivateIncompatibleAddon(
372
-            'Automated Upcoming Event Notifications',
373
-            'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION',
374
-            '1.0.0.beta.091',
375
-            'load_espresso_automated_upcoming_event_notification',
376
-            'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE'
377
-        );
378
-        do_action('AHEE__EE_System__load_espresso_addons');
379
-        // if the WP API basic auth plugin isn't already loaded, load it now.
380
-        // We want it for mobile apps. Just include the entire plugin
381
-        // also, don't load the basic auth when a plugin is getting activated, because
382
-        // it could be the basic auth plugin, and it doesn't check if its methods are already defined
383
-        // and causes a fatal error
384
-        if ($this->request->getRequestParam('activate') !== 'true'
385
-            && ! function_exists('json_basic_auth_handler')
386
-            && ! function_exists('json_basic_auth_error')
387
-            && ! in_array(
388
-                $this->request->getRequestParam('action'),
389
-                array('activate', 'activate-selected'),
390
-                true
391
-            )
392
-        ) {
393
-            include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
394
-        }
395
-        do_action('AHEE__EE_System__load_espresso_addons__complete');
396
-    }
397
-
398
-
399
-    /**
400
-     * detect_activations_or_upgrades
401
-     * Checks for activation or upgrade of core first;
402
-     * then also checks if any registered addons have been activated or upgraded
403
-     * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
404
-     * which runs during the WP 'plugins_loaded' action at priority 3
405
-     *
406
-     * @access public
407
-     * @return void
408
-     */
409
-    public function detect_activations_or_upgrades()
410
-    {
411
-        // first off: let's make sure to handle core
412
-        $this->detect_if_activation_or_upgrade();
413
-        foreach ($this->registry->addons as $addon) {
414
-            if ($addon instanceof EE_Addon) {
415
-                // detect teh request type for that addon
416
-                $addon->detect_activation_or_upgrade();
417
-            }
418
-        }
419
-    }
420
-
421
-
422
-    /**
423
-     * detect_if_activation_or_upgrade
424
-     * Takes care of detecting whether this is a brand new install or code upgrade,
425
-     * and either setting up the DB or setting up maintenance mode etc.
426
-     *
427
-     * @access public
428
-     * @return void
429
-     */
430
-    public function detect_if_activation_or_upgrade()
431
-    {
432
-        do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
433
-        // check if db has been updated, or if its a brand-new installation
434
-        $espresso_db_update = $this->fix_espresso_db_upgrade_option();
435
-        $request_type = $this->detect_req_type($espresso_db_update);
436
-        // EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
437
-        switch ($request_type) {
438
-            case EE_System::req_type_new_activation:
439
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
440
-                $this->_handle_core_version_change($espresso_db_update);
441
-                break;
442
-            case EE_System::req_type_reactivation:
443
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
444
-                $this->_handle_core_version_change($espresso_db_update);
445
-                break;
446
-            case EE_System::req_type_upgrade:
447
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
448
-                // migrations may be required now that we've upgraded
449
-                $this->maintenance_mode->set_maintenance_mode_if_db_old();
450
-                $this->_handle_core_version_change($espresso_db_update);
451
-                break;
452
-            case EE_System::req_type_downgrade:
453
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
454
-                // its possible migrations are no longer required
455
-                $this->maintenance_mode->set_maintenance_mode_if_db_old();
456
-                $this->_handle_core_version_change($espresso_db_update);
457
-                break;
458
-            case EE_System::req_type_normal:
459
-            default:
460
-                break;
461
-        }
462
-        do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
463
-    }
464
-
465
-
466
-    /**
467
-     * Updates the list of installed versions and sets hooks for
468
-     * initializing the database later during the request
469
-     *
470
-     * @param array $espresso_db_update
471
-     */
472
-    private function _handle_core_version_change($espresso_db_update)
473
-    {
474
-        $this->update_list_of_installed_versions($espresso_db_update);
475
-        // get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
476
-        add_action(
477
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
478
-            array($this, 'initialize_db_if_no_migrations_required')
479
-        );
480
-    }
481
-
482
-
483
-    /**
484
-     * standardizes the wp option 'espresso_db_upgrade' which actually stores
485
-     * information about what versions of EE have been installed and activated,
486
-     * NOT necessarily the state of the database
487
-     *
488
-     * @param mixed $espresso_db_update           the value of the WordPress option.
489
-     *                                            If not supplied, fetches it from the options table
490
-     * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
491
-     */
492
-    private function fix_espresso_db_upgrade_option($espresso_db_update = null)
493
-    {
494
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
495
-        if (! $espresso_db_update) {
496
-            $espresso_db_update = get_option('espresso_db_update');
497
-        }
498
-        // check that option is an array
499
-        if (! is_array($espresso_db_update)) {
500
-            // if option is FALSE, then it never existed
501
-            if ($espresso_db_update === false) {
502
-                // make $espresso_db_update an array and save option with autoload OFF
503
-                $espresso_db_update = array();
504
-                add_option('espresso_db_update', $espresso_db_update, '', 'no');
505
-            } else {
506
-                // option is NOT FALSE but also is NOT an array, so make it an array and save it
507
-                $espresso_db_update = array($espresso_db_update => array());
508
-                update_option('espresso_db_update', $espresso_db_update);
509
-            }
510
-        } else {
511
-            $corrected_db_update = array();
512
-            // if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
513
-            foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
514
-                if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
515
-                    // the key is an int, and the value IS NOT an array
516
-                    // so it must be numerically-indexed, where values are versions installed...
517
-                    // fix it!
518
-                    $version_string = $should_be_array;
519
-                    $corrected_db_update[ $version_string ] = array('unknown-date');
520
-                } else {
521
-                    // ok it checks out
522
-                    $corrected_db_update[ $should_be_version_string ] = $should_be_array;
523
-                }
524
-            }
525
-            $espresso_db_update = $corrected_db_update;
526
-            update_option('espresso_db_update', $espresso_db_update);
527
-        }
528
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
529
-        return $espresso_db_update;
530
-    }
531
-
532
-
533
-    /**
534
-     * Does the traditional work of setting up the plugin's database and adding default data.
535
-     * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
536
-     * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
537
-     * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
538
-     * so that it will be done when migrations are finished
539
-     *
540
-     * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
541
-     * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
542
-     *                                       This is a resource-intensive job
543
-     *                                       so we prefer to only do it when necessary
544
-     * @return void
545
-     * @throws EE_Error
546
-     */
547
-    public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
548
-    {
549
-        $request_type = $this->detect_req_type();
550
-        // only initialize system if we're not in maintenance mode.
551
-        if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
552
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
553
-            $rewrite_rules = $this->loader->getShared(
554
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
555
-            );
556
-            $rewrite_rules->flush();
557
-            if ($verify_schema) {
558
-                EEH_Activation::initialize_db_and_folders();
559
-            }
560
-            EEH_Activation::initialize_db_content();
561
-            EEH_Activation::system_initialization();
562
-            if ($initialize_addons_too) {
563
-                $this->initialize_addons();
564
-            }
565
-        } else {
566
-            EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
567
-        }
568
-        if ($request_type === EE_System::req_type_new_activation
569
-            || $request_type === EE_System::req_type_reactivation
570
-            || (
571
-                $request_type === EE_System::req_type_upgrade
572
-                && $this->is_major_version_change()
573
-            )
574
-        ) {
575
-            add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
576
-        }
577
-    }
578
-
579
-
580
-    /**
581
-     * Initializes the db for all registered addons
582
-     *
583
-     * @throws EE_Error
584
-     */
585
-    public function initialize_addons()
586
-    {
587
-        // foreach registered addon, make sure its db is up-to-date too
588
-        foreach ($this->registry->addons as $addon) {
589
-            if ($addon instanceof EE_Addon) {
590
-                $addon->initialize_db_if_no_migrations_required();
591
-            }
592
-        }
593
-    }
594
-
595
-
596
-    /**
597
-     * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
598
-     *
599
-     * @param    array  $version_history
600
-     * @param    string $current_version_to_add version to be added to the version history
601
-     * @return    boolean success as to whether or not this option was changed
602
-     */
603
-    public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
604
-    {
605
-        if (! $version_history) {
606
-            $version_history = $this->fix_espresso_db_upgrade_option($version_history);
607
-        }
608
-        if ($current_version_to_add === null) {
609
-            $current_version_to_add = espresso_version();
610
-        }
611
-        $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
612
-        // re-save
613
-        return update_option('espresso_db_update', $version_history);
614
-    }
615
-
616
-
617
-    /**
618
-     * Detects if the current version indicated in the has existed in the list of
619
-     * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
620
-     *
621
-     * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
622
-     *                                  If not supplied, fetches it from the options table.
623
-     *                                  Also, caches its result so later parts of the code can also know whether
624
-     *                                  there's been an update or not. This way we can add the current version to
625
-     *                                  espresso_db_update, but still know if this is a new install or not
626
-     * @return int one of the constants on EE_System::req_type_
627
-     */
628
-    public function detect_req_type($espresso_db_update = null)
629
-    {
630
-        if ($this->_req_type === null) {
631
-            $espresso_db_update = ! empty($espresso_db_update)
632
-                ? $espresso_db_update
633
-                : $this->fix_espresso_db_upgrade_option();
634
-            $this->_req_type = EE_System::detect_req_type_given_activation_history(
635
-                $espresso_db_update,
636
-                'ee_espresso_activation',
637
-                espresso_version()
638
-            );
639
-            $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
640
-            $this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal);
641
-        }
642
-        return $this->_req_type;
643
-    }
644
-
645
-
646
-    /**
647
-     * Returns whether or not there was a non-micro version change (ie, change in either
648
-     * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
649
-     * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
650
-     *
651
-     * @param $activation_history
652
-     * @return bool
653
-     */
654
-    private function _detect_major_version_change($activation_history)
655
-    {
656
-        $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
657
-        $previous_version_parts = explode('.', $previous_version);
658
-        $current_version_parts = explode('.', espresso_version());
659
-        return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
660
-               && ($previous_version_parts[0] !== $current_version_parts[0]
661
-                   || $previous_version_parts[1] !== $current_version_parts[1]
662
-               );
663
-    }
664
-
665
-
666
-    /**
667
-     * Returns true if either the major or minor version of EE changed during this request.
668
-     * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001
669
-     *
670
-     * @return bool
671
-     */
672
-    public function is_major_version_change()
673
-    {
674
-        return $this->_major_version_change;
675
-    }
676
-
677
-
678
-    /**
679
-     * Determines the request type for any ee addon, given three piece of info: the current array of activation
680
-     * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
681
-     * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
682
-     * just activated to (for core that will always be espresso_version())
683
-     *
684
-     * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
685
-     *                                                 ee plugin. for core that's 'espresso_db_update'
686
-     * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
687
-     *                                                 indicate that this plugin was just activated
688
-     * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
689
-     *                                                 espresso_version())
690
-     * @return int one of the constants on EE_System::req_type_*
691
-     */
692
-    public static function detect_req_type_given_activation_history(
693
-        $activation_history_for_addon,
694
-        $activation_indicator_option_name,
695
-        $version_to_upgrade_to
696
-    ) {
697
-        $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
698
-        if ($activation_history_for_addon) {
699
-            // it exists, so this isn't a completely new install
700
-            // check if this version already in that list of previously installed versions
701
-            if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) {
702
-                // it a version we haven't seen before
703
-                if ($version_is_higher === 1) {
704
-                    $req_type = EE_System::req_type_upgrade;
705
-                } else {
706
-                    $req_type = EE_System::req_type_downgrade;
707
-                }
708
-                delete_option($activation_indicator_option_name);
709
-            } else {
710
-                // its not an update. maybe a reactivation?
711
-                if (get_option($activation_indicator_option_name, false)) {
712
-                    if ($version_is_higher === -1) {
713
-                        $req_type = EE_System::req_type_downgrade;
714
-                    } elseif ($version_is_higher === 0) {
715
-                        // we've seen this version before, but it's an activation. must be a reactivation
716
-                        $req_type = EE_System::req_type_reactivation;
717
-                    } else {// $version_is_higher === 1
718
-                        $req_type = EE_System::req_type_upgrade;
719
-                    }
720
-                    delete_option($activation_indicator_option_name);
721
-                } else {
722
-                    // we've seen this version before and the activation indicate doesn't show it was just activated
723
-                    if ($version_is_higher === -1) {
724
-                        $req_type = EE_System::req_type_downgrade;
725
-                    } elseif ($version_is_higher === 0) {
726
-                        // we've seen this version before and it's not an activation. its normal request
727
-                        $req_type = EE_System::req_type_normal;
728
-                    } else {// $version_is_higher === 1
729
-                        $req_type = EE_System::req_type_upgrade;
730
-                    }
731
-                }
732
-            }
733
-        } else {
734
-            // brand new install
735
-            $req_type = EE_System::req_type_new_activation;
736
-            delete_option($activation_indicator_option_name);
737
-        }
738
-        return $req_type;
739
-    }
740
-
741
-
742
-    /**
743
-     * Detects if the $version_to_upgrade_to is higher than the most recent version in
744
-     * the $activation_history_for_addon
745
-     *
746
-     * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
747
-     *                                             sometimes containing 'unknown-date'
748
-     * @param string $version_to_upgrade_to        (current version)
749
-     * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
750
-     *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
751
-     *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
752
-     *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
753
-     */
754
-    private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
755
-    {
756
-        // find the most recently-activated version
757
-        $most_recently_active_version =
758
-            EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
759
-        return version_compare($version_to_upgrade_to, $most_recently_active_version);
760
-    }
761
-
762
-
763
-    /**
764
-     * Gets the most recently active version listed in the activation history,
765
-     * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
766
-     *
767
-     * @param array $activation_history  (keys are versions, values are arrays of times activated,
768
-     *                                   sometimes containing 'unknown-date'
769
-     * @return string
770
-     */
771
-    private static function _get_most_recently_active_version_from_activation_history($activation_history)
772
-    {
773
-        $most_recently_active_version_activation = '1970-01-01 00:00:00';
774
-        $most_recently_active_version = '0.0.0.dev.000';
775
-        if (is_array($activation_history)) {
776
-            foreach ($activation_history as $version => $times_activated) {
777
-                // check there is a record of when this version was activated. Otherwise,
778
-                // mark it as unknown
779
-                if (! $times_activated) {
780
-                    $times_activated = array('unknown-date');
781
-                }
782
-                if (is_string($times_activated)) {
783
-                    $times_activated = array($times_activated);
784
-                }
785
-                foreach ($times_activated as $an_activation) {
786
-                    if ($an_activation !== 'unknown-date'
787
-                        && $an_activation
788
-                           > $most_recently_active_version_activation) {
789
-                        $most_recently_active_version = $version;
790
-                        $most_recently_active_version_activation = $an_activation === 'unknown-date'
791
-                            ? '1970-01-01 00:00:00'
792
-                            : $an_activation;
793
-                    }
794
-                }
795
-            }
796
-        }
797
-        return $most_recently_active_version;
798
-    }
799
-
800
-
801
-    /**
802
-     * This redirects to the about EE page after activation
803
-     *
804
-     * @return void
805
-     */
806
-    public function redirect_to_about_ee()
807
-    {
808
-        $notices = EE_Error::get_notices(false);
809
-        // if current user is an admin and it's not an ajax or rest request
810
-        if (! isset($notices['errors'])
811
-            && $this->request->isAdmin()
812
-            && apply_filters(
813
-                'FHEE__EE_System__redirect_to_about_ee__do_redirect',
814
-                $this->capabilities->current_user_can('manage_options', 'espresso_about_default')
815
-            )
816
-        ) {
817
-            $query_params = array('page' => 'espresso_about');
818
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
819
-                $query_params['new_activation'] = true;
820
-            }
821
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
822
-                $query_params['reactivation'] = true;
823
-            }
824
-            $url = add_query_arg($query_params, admin_url('admin.php'));
825
-            wp_safe_redirect($url);
826
-            exit();
827
-        }
828
-    }
829
-
830
-
831
-    /**
832
-     * load_core_configuration
833
-     * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
834
-     * which runs during the WP 'plugins_loaded' action at priority 5
835
-     *
836
-     * @return void
837
-     * @throws ReflectionException
838
-     */
839
-    public function load_core_configuration()
840
-    {
841
-        do_action('AHEE__EE_System__load_core_configuration__begin', $this);
842
-        $this->loader->getShared('EE_Load_Textdomain');
843
-        // load textdomain
844
-        EE_Load_Textdomain::load_textdomain();
845
-        // load and setup EE_Config and EE_Network_Config
846
-        $config = $this->loader->getShared('EE_Config');
847
-        $this->loader->getShared('EE_Network_Config');
848
-        // setup autoloaders
849
-        // enable logging?
850
-        if ($config->admin->use_full_logging) {
851
-            $this->loader->getShared('EE_Log');
852
-        }
853
-        // check for activation errors
854
-        $activation_errors = get_option('ee_plugin_activation_errors', false);
855
-        if ($activation_errors) {
856
-            EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
857
-            update_option('ee_plugin_activation_errors', false);
858
-        }
859
-        // get model names
860
-        $this->_parse_model_names();
861
-        // load caf stuff a chance to play during the activation process too.
862
-        $this->_maybe_brew_regular();
863
-        // configure custom post type definitions
864
-        $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions');
865
-        $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions');
866
-        do_action('AHEE__EE_System__load_core_configuration__complete', $this);
867
-    }
868
-
869
-
870
-    /**
871
-     * cycles through all of the models/*.model.php files, and assembles an array of model names
872
-     *
873
-     * @return void
874
-     * @throws ReflectionException
875
-     */
876
-    private function _parse_model_names()
877
-    {
878
-        // get all the files in the EE_MODELS folder that end in .model.php
879
-        $models = glob(EE_MODELS . '*.model.php');
880
-        $model_names = array();
881
-        $non_abstract_db_models = array();
882
-        foreach ($models as $model) {
883
-            // get model classname
884
-            $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
885
-            $short_name = str_replace('EEM_', '', $classname);
886
-            $reflectionClass = new ReflectionClass($classname);
887
-            if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
888
-                $non_abstract_db_models[ $short_name ] = $classname;
889
-            }
890
-            $model_names[ $short_name ] = $classname;
891
-        }
892
-        $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
893
-        $this->registry->non_abstract_db_models = apply_filters(
894
-            'FHEE__EE_System__parse_implemented_model_names',
895
-            $non_abstract_db_models
896
-        );
897
-    }
898
-
899
-
900
-    /**
901
-     * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
902
-     * that need to be setup before our EE_System launches.
903
-     *
904
-     * @return void
905
-     * @throws DomainException
906
-     * @throws InvalidArgumentException
907
-     * @throws InvalidDataTypeException
908
-     * @throws InvalidInterfaceException
909
-     * @throws InvalidClassException
910
-     * @throws InvalidFilePathException
911
-     */
912
-    private function _maybe_brew_regular()
913
-    {
914
-        /** @var Domain $domain */
915
-        $domain = DomainFactory::getShared(
916
-            new FullyQualifiedName(
917
-                'EventEspresso\core\domain\Domain'
918
-            ),
919
-            array(
920
-                new FilePath(EVENT_ESPRESSO_MAIN_FILE),
921
-                Version::fromString(espresso_version()),
922
-            )
923
-        );
924
-        if ($domain->isCaffeinated()) {
925
-            require_once EE_CAFF_PATH . 'brewing_regular.php';
926
-        }
927
-    }
928
-
929
-
930
-    /**
931
-     * register_shortcodes_modules_and_widgets
932
-     * generate lists of shortcodes and modules, then verify paths and classes
933
-     * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
934
-     * which runs during the WP 'plugins_loaded' action at priority 7
935
-     *
936
-     * @access public
937
-     * @return void
938
-     * @throws Exception
939
-     */
940
-    public function register_shortcodes_modules_and_widgets()
941
-    {
942
-        if ($this->request->isFrontend() || $this->request->isIframe()) {
943
-            try {
944
-                // load, register, and add shortcodes the new way
945
-                $this->loader->getShared(
946
-                    'EventEspresso\core\services\shortcodes\ShortcodesManager',
947
-                    array(
948
-                        // and the old way, but we'll put it under control of the new system
949
-                        EE_Config::getLegacyShortcodesManager(),
950
-                    )
951
-                );
952
-            } catch (Exception $exception) {
953
-                new ExceptionStackTraceDisplay($exception);
954
-            }
955
-        }
956
-        do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
957
-        // check for addons using old hook point
958
-        if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
959
-            $this->_incompatible_addon_error();
960
-        }
961
-    }
962
-
963
-
964
-    /**
965
-     * _incompatible_addon_error
966
-     *
967
-     * @access public
968
-     * @return void
969
-     */
970
-    private function _incompatible_addon_error()
971
-    {
972
-        // get array of classes hooking into here
973
-        $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
974
-            'AHEE__EE_System__register_shortcodes_modules_and_addons'
975
-        );
976
-        if (! empty($class_names)) {
977
-            $msg = __(
978
-                'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
979
-                'event_espresso'
980
-            );
981
-            $msg .= '<ul>';
982
-            foreach ($class_names as $class_name) {
983
-                $msg .= '<li><b>Event Espresso - '
984
-                        . str_replace(
985
-                            array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'),
986
-                            '',
987
-                            $class_name
988
-                        ) . '</b></li>';
989
-            }
990
-            $msg .= '</ul>';
991
-            $msg .= __(
992
-                'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
993
-                'event_espresso'
994
-            );
995
-            // save list of incompatible addons to wp-options for later use
996
-            add_option('ee_incompatible_addons', $class_names, '', 'no');
997
-            if (is_admin()) {
998
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
999
-            }
1000
-        }
1001
-    }
1002
-
1003
-
1004
-    /**
1005
-     * brew_espresso
1006
-     * begins the process of setting hooks for initializing EE in the correct order
1007
-     * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
1008
-     * which runs during the WP 'plugins_loaded' action at priority 9
1009
-     *
1010
-     * @return void
1011
-     */
1012
-    public function brew_espresso()
1013
-    {
1014
-        do_action('AHEE__EE_System__brew_espresso__begin', $this);
1015
-        // load some final core systems
1016
-        add_action('init', array($this, 'set_hooks_for_core'), 1);
1017
-        add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
1018
-        add_action('init', array($this, 'load_CPTs_and_session'), 5);
1019
-        add_action('init', array($this, 'load_controllers'), 7);
1020
-        add_action('init', array($this, 'core_loaded_and_ready'), 9);
1021
-        add_action('init', array($this, 'initialize'), 10);
1022
-        add_action('init', array($this, 'initialize_last'), 100);
1023
-        if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
1024
-            // pew pew pew
1025
-            $this->loader->getShared('EventEspresso\core\services\licensing\LicenseService');
1026
-            do_action('AHEE__EE_System__brew_espresso__after_pue_init');
1027
-        }
1028
-        do_action('AHEE__EE_System__brew_espresso__complete', $this);
1029
-    }
1030
-
1031
-
1032
-    /**
1033
-     *    set_hooks_for_core
1034
-     *
1035
-     * @access public
1036
-     * @return    void
1037
-     * @throws EE_Error
1038
-     */
1039
-    public function set_hooks_for_core()
1040
-    {
1041
-        $this->_deactivate_incompatible_addons();
1042
-        do_action('AHEE__EE_System__set_hooks_for_core');
1043
-        $this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan');
1044
-        // caps need to be initialized on every request so that capability maps are set.
1045
-        // @see https://events.codebasehq.com/projects/event-espresso/tickets/8674
1046
-        $this->registry->CAP->init_caps();
1047
-    }
1048
-
1049
-
1050
-    /**
1051
-     * Using the information gathered in EE_System::_incompatible_addon_error,
1052
-     * deactivates any addons considered incompatible with the current version of EE
1053
-     */
1054
-    private function _deactivate_incompatible_addons()
1055
-    {
1056
-        $incompatible_addons = get_option('ee_incompatible_addons', array());
1057
-        if (! empty($incompatible_addons)) {
1058
-            $active_plugins = get_option('active_plugins', array());
1059
-            foreach ($active_plugins as $active_plugin) {
1060
-                foreach ($incompatible_addons as $incompatible_addon) {
1061
-                    if (strpos($active_plugin, $incompatible_addon) !== false) {
1062
-                        unset($_GET['activate']);
1063
-                        espresso_deactivate_plugin($active_plugin);
1064
-                    }
1065
-                }
1066
-            }
1067
-        }
1068
-    }
1069
-
1070
-
1071
-    /**
1072
-     *    perform_activations_upgrades_and_migrations
1073
-     *
1074
-     * @access public
1075
-     * @return    void
1076
-     */
1077
-    public function perform_activations_upgrades_and_migrations()
1078
-    {
1079
-        do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
1080
-    }
1081
-
1082
-
1083
-    /**
1084
-     * @return void
1085
-     * @throws DomainException
1086
-     */
1087
-    public function load_CPTs_and_session()
1088
-    {
1089
-        do_action('AHEE__EE_System__load_CPTs_and_session__start');
1090
-        /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies $register_custom_taxonomies */
1091
-        $register_custom_taxonomies = $this->loader->getShared(
1092
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'
1093
-        );
1094
-        $register_custom_taxonomies->registerCustomTaxonomies();
1095
-        /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes $register_custom_post_types */
1096
-        $register_custom_post_types = $this->loader->getShared(
1097
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'
1098
-        );
1099
-        $register_custom_post_types->registerCustomPostTypes();
1100
-        /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms */
1101
-        $register_custom_taxonomy_terms = $this->loader->getShared(
1102
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms'
1103
-        );
1104
-        $register_custom_taxonomy_terms->registerCustomTaxonomyTerms();
1105
-        // load legacy Custom Post Types and Taxonomies
1106
-        $this->loader->getShared('EE_Register_CPTs');
1107
-        do_action('AHEE__EE_System__load_CPTs_and_session__complete');
1108
-    }
1109
-
1110
-
1111
-    /**
1112
-     * load_controllers
1113
-     * this is the best place to load any additional controllers that needs access to EE core.
1114
-     * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
1115
-     * time
1116
-     *
1117
-     * @access public
1118
-     * @return void
1119
-     */
1120
-    public function load_controllers()
1121
-    {
1122
-        do_action('AHEE__EE_System__load_controllers__start');
1123
-        // let's get it started
1124
-        if (! $this->maintenance_mode->level()
1125
-            && ($this->request->isFrontend() || $this->request->isFrontAjax())
1126
-        ) {
1127
-            do_action('AHEE__EE_System__load_controllers__load_front_controllers');
1128
-            $this->loader->getShared('EE_Front_Controller');
1129
-        } elseif ($this->request->isAdmin() || $this->request->isAdminAjax()) {
1130
-            do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1131
-            $this->loader->getShared('EE_Admin');
1132
-        }
1133
-        do_action('AHEE__EE_System__load_controllers__complete');
1134
-    }
1135
-
1136
-
1137
-    /**
1138
-     * core_loaded_and_ready
1139
-     * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1140
-     *
1141
-     * @access public
1142
-     * @return void
1143
-     * @throws Exception
1144
-     */
1145
-    public function core_loaded_and_ready()
1146
-    {
1147
-        if ($this->request->isAdmin() || $this->request->isFrontend() || $this->request->isIframe()) {
1148
-            try {
1149
-                $this->loader->getShared('EventEspresso\core\services\assets\Registry');
1150
-                $this->loader->getShared('EventEspresso\core\domain\services\assets\CoreAssetManager');
1151
-            } catch (Exception $exception) {
1152
-                new ExceptionStackTraceDisplay($exception);
1153
-            }
1154
-        }
1155
-        if ($this->request->isAdmin()
1156
-            || $this->request->isEeAjax()
1157
-            || $this->request->isFrontend()
1158
-        ) {
1159
-            $this->loader->getShared('EE_Session');
1160
-        }
1161
-        do_action('AHEE__EE_System__core_loaded_and_ready');
1162
-        // load_espresso_template_tags
1163
-        if (is_readable(EE_PUBLIC . 'template_tags.php')
1164
-            && ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isFeed())
1165
-        ) {
1166
-            require_once EE_PUBLIC . 'template_tags.php';
1167
-        }
1168
-        do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1169
-    }
1170
-
1171
-
1172
-    /**
1173
-     * initialize
1174
-     * this is the best place to begin initializing client code
1175
-     *
1176
-     * @access public
1177
-     * @return void
1178
-     */
1179
-    public function initialize()
1180
-    {
1181
-        do_action('AHEE__EE_System__initialize');
1182
-    }
1183
-
1184
-
1185
-    /**
1186
-     * initialize_last
1187
-     * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1188
-     * initialize has done so
1189
-     *
1190
-     * @access public
1191
-     * @return void
1192
-     */
1193
-    public function initialize_last()
1194
-    {
1195
-        do_action('AHEE__EE_System__initialize_last');
1196
-        /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
1197
-        $rewrite_rules = $this->loader->getShared(
1198
-            'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
1199
-        );
1200
-        $rewrite_rules->flushRewriteRules();
1201
-        add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1202
-        if (($this->request->isAjax() || $this->request->isAdmin())
1203
-            && $this->maintenance_mode->models_can_query()) {
1204
-            $this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager');
1205
-            $this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager');
1206
-        }
1207
-    }
1208
-
1209
-
1210
-    /**
1211
-     * @return void
1212
-     * @throws EE_Error
1213
-     */
1214
-    public function addEspressoToolbar()
1215
-    {
1216
-        $this->loader->getShared(
1217
-            'EventEspresso\core\domain\services\admin\AdminToolBar',
1218
-            array($this->registry->CAP)
1219
-        );
1220
-    }
1221
-
1222
-
1223
-    /**
1224
-     * do_not_cache
1225
-     * sets no cache headers and defines no cache constants for WP plugins
1226
-     *
1227
-     * @access public
1228
-     * @return void
1229
-     */
1230
-    public static function do_not_cache()
1231
-    {
1232
-        // set no cache constants
1233
-        if (! defined('DONOTCACHEPAGE')) {
1234
-            define('DONOTCACHEPAGE', true);
1235
-        }
1236
-        if (! defined('DONOTCACHCEOBJECT')) {
1237
-            define('DONOTCACHCEOBJECT', true);
1238
-        }
1239
-        if (! defined('DONOTCACHEDB')) {
1240
-            define('DONOTCACHEDB', true);
1241
-        }
1242
-        // add no cache headers
1243
-        add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1244
-        // plus a little extra for nginx and Google Chrome
1245
-        add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1246
-        // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1247
-        remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1248
-    }
1249
-
1250
-
1251
-    /**
1252
-     *    extra_nocache_headers
1253
-     *
1254
-     * @access    public
1255
-     * @param $headers
1256
-     * @return    array
1257
-     */
1258
-    public static function extra_nocache_headers($headers)
1259
-    {
1260
-        // for NGINX
1261
-        $headers['X-Accel-Expires'] = 0;
1262
-        // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1263
-        $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1264
-        return $headers;
1265
-    }
1266
-
1267
-
1268
-    /**
1269
-     *    nocache_headers
1270
-     *
1271
-     * @access    public
1272
-     * @return    void
1273
-     */
1274
-    public static function nocache_headers()
1275
-    {
1276
-        nocache_headers();
1277
-    }
1278
-
1279
-
1280
-    /**
1281
-     * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1282
-     * never returned with the function.
1283
-     *
1284
-     * @param  array $exclude_array any existing pages being excluded are in this array.
1285
-     * @return array
1286
-     */
1287
-    public function remove_pages_from_wp_list_pages($exclude_array)
1288
-    {
1289
-        return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1290
-    }
30
+	/**
31
+	 * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
32
+	 * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
33
+	 */
34
+	const req_type_normal = 0;
35
+
36
+	/**
37
+	 * Indicates this is a brand new installation of EE so we should install
38
+	 * tables and default data etc
39
+	 */
40
+	const req_type_new_activation = 1;
41
+
42
+	/**
43
+	 * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
44
+	 * and we just exited maintenance mode). We MUST check the database is setup properly
45
+	 * and that default data is setup too
46
+	 */
47
+	const req_type_reactivation = 2;
48
+
49
+	/**
50
+	 * indicates that EE has been upgraded since its previous request.
51
+	 * We may have data migration scripts to call and will want to trigger maintenance mode
52
+	 */
53
+	const req_type_upgrade = 3;
54
+
55
+	/**
56
+	 * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
57
+	 */
58
+	const req_type_downgrade = 4;
59
+
60
+	/**
61
+	 * @deprecated since version 4.6.0.dev.006
62
+	 * Now whenever a new_activation is detected the request type is still just
63
+	 * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
64
+	 * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
65
+	 * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
66
+	 * (Specifically, when the migration manager indicates migrations are finished
67
+	 * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
68
+	 */
69
+	const req_type_activation_but_not_installed = 5;
70
+
71
+	/**
72
+	 * option prefix for recording the activation history (like core's "espresso_db_update") of addons
73
+	 */
74
+	const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
75
+
76
+	/**
77
+	 * @var EE_System $_instance
78
+	 */
79
+	private static $_instance;
80
+
81
+	/**
82
+	 * @var EE_Registry $registry
83
+	 */
84
+	private $registry;
85
+
86
+	/**
87
+	 * @var LoaderInterface $loader
88
+	 */
89
+	private $loader;
90
+
91
+	/**
92
+	 * @var EE_Capabilities $capabilities
93
+	 */
94
+	private $capabilities;
95
+
96
+	/**
97
+	 * @var RequestInterface $request
98
+	 */
99
+	private $request;
100
+
101
+	/**
102
+	 * @var EE_Maintenance_Mode $maintenance_mode
103
+	 */
104
+	private $maintenance_mode;
105
+
106
+	/**
107
+	 * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
108
+	 * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
109
+	 *
110
+	 * @var int $_req_type
111
+	 */
112
+	private $_req_type;
113
+
114
+	/**
115
+	 * Whether or not there was a non-micro version change in EE core version during this request
116
+	 *
117
+	 * @var boolean $_major_version_change
118
+	 */
119
+	private $_major_version_change = false;
120
+
121
+	/**
122
+	 * A Context DTO dedicated solely to identifying the current request type.
123
+	 *
124
+	 * @var RequestTypeContextCheckerInterface $request_type
125
+	 */
126
+	private $request_type;
127
+
128
+
129
+	/**
130
+	 * @singleton method used to instantiate class object
131
+	 * @param EE_Registry|null         $registry
132
+	 * @param LoaderInterface|null     $loader
133
+	 * @param RequestInterface|null    $request
134
+	 * @param EE_Maintenance_Mode|null $maintenance_mode
135
+	 * @return EE_System
136
+	 */
137
+	public static function instance(
138
+		EE_Registry $registry = null,
139
+		LoaderInterface $loader = null,
140
+		RequestInterface $request = null,
141
+		EE_Maintenance_Mode $maintenance_mode = null
142
+	) {
143
+		// check if class object is instantiated
144
+		if (! self::$_instance instanceof EE_System) {
145
+			self::$_instance = new self($registry, $loader, $request, $maintenance_mode);
146
+		}
147
+		return self::$_instance;
148
+	}
149
+
150
+
151
+	/**
152
+	 * resets the instance and returns it
153
+	 *
154
+	 * @return EE_System
155
+	 */
156
+	public static function reset()
157
+	{
158
+		self::$_instance->_req_type = null;
159
+		// make sure none of the old hooks are left hanging around
160
+		remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
161
+		// we need to reset the migration manager in order for it to detect DMSs properly
162
+		EE_Data_Migration_Manager::reset();
163
+		self::instance()->detect_activations_or_upgrades();
164
+		self::instance()->perform_activations_upgrades_and_migrations();
165
+		return self::instance();
166
+	}
167
+
168
+
169
+	/**
170
+	 * sets hooks for running rest of system
171
+	 * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
172
+	 * starting EE Addons from any other point may lead to problems
173
+	 *
174
+	 * @param EE_Registry         $registry
175
+	 * @param LoaderInterface     $loader
176
+	 * @param RequestInterface    $request
177
+	 * @param EE_Maintenance_Mode $maintenance_mode
178
+	 */
179
+	private function __construct(
180
+		EE_Registry $registry,
181
+		LoaderInterface $loader,
182
+		RequestInterface $request,
183
+		EE_Maintenance_Mode $maintenance_mode
184
+	) {
185
+		$this->registry = $registry;
186
+		$this->loader = $loader;
187
+		$this->request = $request;
188
+		$this->maintenance_mode = $maintenance_mode;
189
+		do_action('AHEE__EE_System__construct__begin', $this);
190
+		add_action(
191
+			'AHEE__EE_Bootstrap__load_espresso_addons',
192
+			array($this, 'loadCapabilities'),
193
+			5
194
+		);
195
+		add_action(
196
+			'AHEE__EE_Bootstrap__load_espresso_addons',
197
+			array($this, 'loadCommandBus'),
198
+			7
199
+		);
200
+		add_action(
201
+			'AHEE__EE_Bootstrap__load_espresso_addons',
202
+			array($this, 'loadPluginApi'),
203
+			9
204
+		);
205
+		// allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
206
+		add_action(
207
+			'AHEE__EE_Bootstrap__load_espresso_addons',
208
+			array($this, 'load_espresso_addons')
209
+		);
210
+		// when an ee addon is activated, we want to call the core hook(s) again
211
+		// because the newly-activated addon didn't get a chance to run at all
212
+		add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
213
+		// detect whether install or upgrade
214
+		add_action(
215
+			'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
216
+			array($this, 'detect_activations_or_upgrades'),
217
+			3
218
+		);
219
+		// load EE_Config, EE_Textdomain, etc
220
+		add_action(
221
+			'AHEE__EE_Bootstrap__load_core_configuration',
222
+			array($this, 'load_core_configuration'),
223
+			5
224
+		);
225
+		// load EE_Config, EE_Textdomain, etc
226
+		add_action(
227
+			'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
228
+			array($this, 'register_shortcodes_modules_and_widgets'),
229
+			7
230
+		);
231
+		// you wanna get going? I wanna get going... let's get going!
232
+		add_action(
233
+			'AHEE__EE_Bootstrap__brew_espresso',
234
+			array($this, 'brew_espresso'),
235
+			9
236
+		);
237
+		// other housekeeping
238
+		// exclude EE critical pages from wp_list_pages
239
+		add_filter(
240
+			'wp_list_pages_excludes',
241
+			array($this, 'remove_pages_from_wp_list_pages'),
242
+			10
243
+		);
244
+		// ALL EE Addons should use the following hook point to attach their initial setup too
245
+		// it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
246
+		do_action('AHEE__EE_System__construct__complete', $this);
247
+	}
248
+
249
+
250
+	/**
251
+	 * load and setup EE_Capabilities
252
+	 *
253
+	 * @return void
254
+	 * @throws EE_Error
255
+	 */
256
+	public function loadCapabilities()
257
+	{
258
+		$this->capabilities = $this->loader->getShared('EE_Capabilities');
259
+		add_action(
260
+			'AHEE__EE_Capabilities__init_caps__before_initialization',
261
+			function () {
262
+				LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
263
+			}
264
+		);
265
+	}
266
+
267
+
268
+	/**
269
+	 * create and cache the CommandBus, and also add middleware
270
+	 * The CapChecker middleware requires the use of EE_Capabilities
271
+	 * which is why we need to load the CommandBus after Caps are set up
272
+	 *
273
+	 * @return void
274
+	 * @throws EE_Error
275
+	 */
276
+	public function loadCommandBus()
277
+	{
278
+		$this->loader->getShared(
279
+			'CommandBusInterface',
280
+			array(
281
+				null,
282
+				apply_filters(
283
+					'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
284
+					array(
285
+						$this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'),
286
+						$this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'),
287
+					)
288
+				),
289
+			)
290
+		);
291
+	}
292
+
293
+
294
+	/**
295
+	 * @return void
296
+	 * @throws EE_Error
297
+	 */
298
+	public function loadPluginApi()
299
+	{
300
+		// set autoloaders for all of the classes implementing EEI_Plugin_API
301
+		// which provide helpers for EE plugin authors to more easily register certain components with EE.
302
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
303
+		$this->loader->getShared('EE_Request_Handler');
304
+	}
305
+
306
+
307
+	/**
308
+	 * @param string $addon_name
309
+	 * @param string $version_constant
310
+	 * @param string $min_version_required
311
+	 * @param string $load_callback
312
+	 * @param string $plugin_file_constant
313
+	 * @return void
314
+	 */
315
+	private function deactivateIncompatibleAddon(
316
+		$addon_name,
317
+		$version_constant,
318
+		$min_version_required,
319
+		$load_callback,
320
+		$plugin_file_constant
321
+	) {
322
+		if (! defined($version_constant)) {
323
+			return;
324
+		}
325
+		$addon_version = constant($version_constant);
326
+		if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
327
+			remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
328
+			if (! function_exists('deactivate_plugins')) {
329
+				require_once ABSPATH . 'wp-admin/includes/plugin.php';
330
+			}
331
+			deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
332
+			unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
333
+			EE_Error::add_error(
334
+				sprintf(
335
+					esc_html__(
336
+						'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.',
337
+						'event_espresso'
338
+					),
339
+					$addon_name,
340
+					$min_version_required
341
+				),
342
+				__FILE__,
343
+				__FUNCTION__ . "({$addon_name})",
344
+				__LINE__
345
+			);
346
+			EE_Error::get_notices(false, true);
347
+		}
348
+	}
349
+
350
+
351
+	/**
352
+	 * load_espresso_addons
353
+	 * allow addons to load first so that they can set hooks for running DMS's, etc
354
+	 * this is hooked into both:
355
+	 *    'AHEE__EE_Bootstrap__load_core_configuration'
356
+	 *        which runs during the WP 'plugins_loaded' action at priority 5
357
+	 *    and the WP 'activate_plugin' hook point
358
+	 *
359
+	 * @access public
360
+	 * @return void
361
+	 */
362
+	public function load_espresso_addons()
363
+	{
364
+		$this->deactivateIncompatibleAddon(
365
+			'Wait Lists',
366
+			'EE_WAIT_LISTS_VERSION',
367
+			'1.0.0.beta.074',
368
+			'load_espresso_wait_lists',
369
+			'EE_WAIT_LISTS_PLUGIN_FILE'
370
+		);
371
+		$this->deactivateIncompatibleAddon(
372
+			'Automated Upcoming Event Notifications',
373
+			'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION',
374
+			'1.0.0.beta.091',
375
+			'load_espresso_automated_upcoming_event_notification',
376
+			'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE'
377
+		);
378
+		do_action('AHEE__EE_System__load_espresso_addons');
379
+		// if the WP API basic auth plugin isn't already loaded, load it now.
380
+		// We want it for mobile apps. Just include the entire plugin
381
+		// also, don't load the basic auth when a plugin is getting activated, because
382
+		// it could be the basic auth plugin, and it doesn't check if its methods are already defined
383
+		// and causes a fatal error
384
+		if ($this->request->getRequestParam('activate') !== 'true'
385
+			&& ! function_exists('json_basic_auth_handler')
386
+			&& ! function_exists('json_basic_auth_error')
387
+			&& ! in_array(
388
+				$this->request->getRequestParam('action'),
389
+				array('activate', 'activate-selected'),
390
+				true
391
+			)
392
+		) {
393
+			include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
394
+		}
395
+		do_action('AHEE__EE_System__load_espresso_addons__complete');
396
+	}
397
+
398
+
399
+	/**
400
+	 * detect_activations_or_upgrades
401
+	 * Checks for activation or upgrade of core first;
402
+	 * then also checks if any registered addons have been activated or upgraded
403
+	 * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
404
+	 * which runs during the WP 'plugins_loaded' action at priority 3
405
+	 *
406
+	 * @access public
407
+	 * @return void
408
+	 */
409
+	public function detect_activations_or_upgrades()
410
+	{
411
+		// first off: let's make sure to handle core
412
+		$this->detect_if_activation_or_upgrade();
413
+		foreach ($this->registry->addons as $addon) {
414
+			if ($addon instanceof EE_Addon) {
415
+				// detect teh request type for that addon
416
+				$addon->detect_activation_or_upgrade();
417
+			}
418
+		}
419
+	}
420
+
421
+
422
+	/**
423
+	 * detect_if_activation_or_upgrade
424
+	 * Takes care of detecting whether this is a brand new install or code upgrade,
425
+	 * and either setting up the DB or setting up maintenance mode etc.
426
+	 *
427
+	 * @access public
428
+	 * @return void
429
+	 */
430
+	public function detect_if_activation_or_upgrade()
431
+	{
432
+		do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
433
+		// check if db has been updated, or if its a brand-new installation
434
+		$espresso_db_update = $this->fix_espresso_db_upgrade_option();
435
+		$request_type = $this->detect_req_type($espresso_db_update);
436
+		// EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
437
+		switch ($request_type) {
438
+			case EE_System::req_type_new_activation:
439
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
440
+				$this->_handle_core_version_change($espresso_db_update);
441
+				break;
442
+			case EE_System::req_type_reactivation:
443
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
444
+				$this->_handle_core_version_change($espresso_db_update);
445
+				break;
446
+			case EE_System::req_type_upgrade:
447
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
448
+				// migrations may be required now that we've upgraded
449
+				$this->maintenance_mode->set_maintenance_mode_if_db_old();
450
+				$this->_handle_core_version_change($espresso_db_update);
451
+				break;
452
+			case EE_System::req_type_downgrade:
453
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
454
+				// its possible migrations are no longer required
455
+				$this->maintenance_mode->set_maintenance_mode_if_db_old();
456
+				$this->_handle_core_version_change($espresso_db_update);
457
+				break;
458
+			case EE_System::req_type_normal:
459
+			default:
460
+				break;
461
+		}
462
+		do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
463
+	}
464
+
465
+
466
+	/**
467
+	 * Updates the list of installed versions and sets hooks for
468
+	 * initializing the database later during the request
469
+	 *
470
+	 * @param array $espresso_db_update
471
+	 */
472
+	private function _handle_core_version_change($espresso_db_update)
473
+	{
474
+		$this->update_list_of_installed_versions($espresso_db_update);
475
+		// get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
476
+		add_action(
477
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
478
+			array($this, 'initialize_db_if_no_migrations_required')
479
+		);
480
+	}
481
+
482
+
483
+	/**
484
+	 * standardizes the wp option 'espresso_db_upgrade' which actually stores
485
+	 * information about what versions of EE have been installed and activated,
486
+	 * NOT necessarily the state of the database
487
+	 *
488
+	 * @param mixed $espresso_db_update           the value of the WordPress option.
489
+	 *                                            If not supplied, fetches it from the options table
490
+	 * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
491
+	 */
492
+	private function fix_espresso_db_upgrade_option($espresso_db_update = null)
493
+	{
494
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
495
+		if (! $espresso_db_update) {
496
+			$espresso_db_update = get_option('espresso_db_update');
497
+		}
498
+		// check that option is an array
499
+		if (! is_array($espresso_db_update)) {
500
+			// if option is FALSE, then it never existed
501
+			if ($espresso_db_update === false) {
502
+				// make $espresso_db_update an array and save option with autoload OFF
503
+				$espresso_db_update = array();
504
+				add_option('espresso_db_update', $espresso_db_update, '', 'no');
505
+			} else {
506
+				// option is NOT FALSE but also is NOT an array, so make it an array and save it
507
+				$espresso_db_update = array($espresso_db_update => array());
508
+				update_option('espresso_db_update', $espresso_db_update);
509
+			}
510
+		} else {
511
+			$corrected_db_update = array();
512
+			// if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
513
+			foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
514
+				if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
515
+					// the key is an int, and the value IS NOT an array
516
+					// so it must be numerically-indexed, where values are versions installed...
517
+					// fix it!
518
+					$version_string = $should_be_array;
519
+					$corrected_db_update[ $version_string ] = array('unknown-date');
520
+				} else {
521
+					// ok it checks out
522
+					$corrected_db_update[ $should_be_version_string ] = $should_be_array;
523
+				}
524
+			}
525
+			$espresso_db_update = $corrected_db_update;
526
+			update_option('espresso_db_update', $espresso_db_update);
527
+		}
528
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
529
+		return $espresso_db_update;
530
+	}
531
+
532
+
533
+	/**
534
+	 * Does the traditional work of setting up the plugin's database and adding default data.
535
+	 * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
536
+	 * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
537
+	 * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
538
+	 * so that it will be done when migrations are finished
539
+	 *
540
+	 * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
541
+	 * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
542
+	 *                                       This is a resource-intensive job
543
+	 *                                       so we prefer to only do it when necessary
544
+	 * @return void
545
+	 * @throws EE_Error
546
+	 */
547
+	public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
548
+	{
549
+		$request_type = $this->detect_req_type();
550
+		// only initialize system if we're not in maintenance mode.
551
+		if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
552
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
553
+			$rewrite_rules = $this->loader->getShared(
554
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
555
+			);
556
+			$rewrite_rules->flush();
557
+			if ($verify_schema) {
558
+				EEH_Activation::initialize_db_and_folders();
559
+			}
560
+			EEH_Activation::initialize_db_content();
561
+			EEH_Activation::system_initialization();
562
+			if ($initialize_addons_too) {
563
+				$this->initialize_addons();
564
+			}
565
+		} else {
566
+			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
567
+		}
568
+		if ($request_type === EE_System::req_type_new_activation
569
+			|| $request_type === EE_System::req_type_reactivation
570
+			|| (
571
+				$request_type === EE_System::req_type_upgrade
572
+				&& $this->is_major_version_change()
573
+			)
574
+		) {
575
+			add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
576
+		}
577
+	}
578
+
579
+
580
+	/**
581
+	 * Initializes the db for all registered addons
582
+	 *
583
+	 * @throws EE_Error
584
+	 */
585
+	public function initialize_addons()
586
+	{
587
+		// foreach registered addon, make sure its db is up-to-date too
588
+		foreach ($this->registry->addons as $addon) {
589
+			if ($addon instanceof EE_Addon) {
590
+				$addon->initialize_db_if_no_migrations_required();
591
+			}
592
+		}
593
+	}
594
+
595
+
596
+	/**
597
+	 * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
598
+	 *
599
+	 * @param    array  $version_history
600
+	 * @param    string $current_version_to_add version to be added to the version history
601
+	 * @return    boolean success as to whether or not this option was changed
602
+	 */
603
+	public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
604
+	{
605
+		if (! $version_history) {
606
+			$version_history = $this->fix_espresso_db_upgrade_option($version_history);
607
+		}
608
+		if ($current_version_to_add === null) {
609
+			$current_version_to_add = espresso_version();
610
+		}
611
+		$version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
612
+		// re-save
613
+		return update_option('espresso_db_update', $version_history);
614
+	}
615
+
616
+
617
+	/**
618
+	 * Detects if the current version indicated in the has existed in the list of
619
+	 * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
620
+	 *
621
+	 * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
622
+	 *                                  If not supplied, fetches it from the options table.
623
+	 *                                  Also, caches its result so later parts of the code can also know whether
624
+	 *                                  there's been an update or not. This way we can add the current version to
625
+	 *                                  espresso_db_update, but still know if this is a new install or not
626
+	 * @return int one of the constants on EE_System::req_type_
627
+	 */
628
+	public function detect_req_type($espresso_db_update = null)
629
+	{
630
+		if ($this->_req_type === null) {
631
+			$espresso_db_update = ! empty($espresso_db_update)
632
+				? $espresso_db_update
633
+				: $this->fix_espresso_db_upgrade_option();
634
+			$this->_req_type = EE_System::detect_req_type_given_activation_history(
635
+				$espresso_db_update,
636
+				'ee_espresso_activation',
637
+				espresso_version()
638
+			);
639
+			$this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
640
+			$this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal);
641
+		}
642
+		return $this->_req_type;
643
+	}
644
+
645
+
646
+	/**
647
+	 * Returns whether or not there was a non-micro version change (ie, change in either
648
+	 * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
649
+	 * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
650
+	 *
651
+	 * @param $activation_history
652
+	 * @return bool
653
+	 */
654
+	private function _detect_major_version_change($activation_history)
655
+	{
656
+		$previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
657
+		$previous_version_parts = explode('.', $previous_version);
658
+		$current_version_parts = explode('.', espresso_version());
659
+		return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
660
+			   && ($previous_version_parts[0] !== $current_version_parts[0]
661
+				   || $previous_version_parts[1] !== $current_version_parts[1]
662
+			   );
663
+	}
664
+
665
+
666
+	/**
667
+	 * Returns true if either the major or minor version of EE changed during this request.
668
+	 * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001
669
+	 *
670
+	 * @return bool
671
+	 */
672
+	public function is_major_version_change()
673
+	{
674
+		return $this->_major_version_change;
675
+	}
676
+
677
+
678
+	/**
679
+	 * Determines the request type for any ee addon, given three piece of info: the current array of activation
680
+	 * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
681
+	 * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
682
+	 * just activated to (for core that will always be espresso_version())
683
+	 *
684
+	 * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
685
+	 *                                                 ee plugin. for core that's 'espresso_db_update'
686
+	 * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
687
+	 *                                                 indicate that this plugin was just activated
688
+	 * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
689
+	 *                                                 espresso_version())
690
+	 * @return int one of the constants on EE_System::req_type_*
691
+	 */
692
+	public static function detect_req_type_given_activation_history(
693
+		$activation_history_for_addon,
694
+		$activation_indicator_option_name,
695
+		$version_to_upgrade_to
696
+	) {
697
+		$version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
698
+		if ($activation_history_for_addon) {
699
+			// it exists, so this isn't a completely new install
700
+			// check if this version already in that list of previously installed versions
701
+			if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) {
702
+				// it a version we haven't seen before
703
+				if ($version_is_higher === 1) {
704
+					$req_type = EE_System::req_type_upgrade;
705
+				} else {
706
+					$req_type = EE_System::req_type_downgrade;
707
+				}
708
+				delete_option($activation_indicator_option_name);
709
+			} else {
710
+				// its not an update. maybe a reactivation?
711
+				if (get_option($activation_indicator_option_name, false)) {
712
+					if ($version_is_higher === -1) {
713
+						$req_type = EE_System::req_type_downgrade;
714
+					} elseif ($version_is_higher === 0) {
715
+						// we've seen this version before, but it's an activation. must be a reactivation
716
+						$req_type = EE_System::req_type_reactivation;
717
+					} else {// $version_is_higher === 1
718
+						$req_type = EE_System::req_type_upgrade;
719
+					}
720
+					delete_option($activation_indicator_option_name);
721
+				} else {
722
+					// we've seen this version before and the activation indicate doesn't show it was just activated
723
+					if ($version_is_higher === -1) {
724
+						$req_type = EE_System::req_type_downgrade;
725
+					} elseif ($version_is_higher === 0) {
726
+						// we've seen this version before and it's not an activation. its normal request
727
+						$req_type = EE_System::req_type_normal;
728
+					} else {// $version_is_higher === 1
729
+						$req_type = EE_System::req_type_upgrade;
730
+					}
731
+				}
732
+			}
733
+		} else {
734
+			// brand new install
735
+			$req_type = EE_System::req_type_new_activation;
736
+			delete_option($activation_indicator_option_name);
737
+		}
738
+		return $req_type;
739
+	}
740
+
741
+
742
+	/**
743
+	 * Detects if the $version_to_upgrade_to is higher than the most recent version in
744
+	 * the $activation_history_for_addon
745
+	 *
746
+	 * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
747
+	 *                                             sometimes containing 'unknown-date'
748
+	 * @param string $version_to_upgrade_to        (current version)
749
+	 * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
750
+	 *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
751
+	 *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
752
+	 *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
753
+	 */
754
+	private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
755
+	{
756
+		// find the most recently-activated version
757
+		$most_recently_active_version =
758
+			EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
759
+		return version_compare($version_to_upgrade_to, $most_recently_active_version);
760
+	}
761
+
762
+
763
+	/**
764
+	 * Gets the most recently active version listed in the activation history,
765
+	 * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
766
+	 *
767
+	 * @param array $activation_history  (keys are versions, values are arrays of times activated,
768
+	 *                                   sometimes containing 'unknown-date'
769
+	 * @return string
770
+	 */
771
+	private static function _get_most_recently_active_version_from_activation_history($activation_history)
772
+	{
773
+		$most_recently_active_version_activation = '1970-01-01 00:00:00';
774
+		$most_recently_active_version = '0.0.0.dev.000';
775
+		if (is_array($activation_history)) {
776
+			foreach ($activation_history as $version => $times_activated) {
777
+				// check there is a record of when this version was activated. Otherwise,
778
+				// mark it as unknown
779
+				if (! $times_activated) {
780
+					$times_activated = array('unknown-date');
781
+				}
782
+				if (is_string($times_activated)) {
783
+					$times_activated = array($times_activated);
784
+				}
785
+				foreach ($times_activated as $an_activation) {
786
+					if ($an_activation !== 'unknown-date'
787
+						&& $an_activation
788
+						   > $most_recently_active_version_activation) {
789
+						$most_recently_active_version = $version;
790
+						$most_recently_active_version_activation = $an_activation === 'unknown-date'
791
+							? '1970-01-01 00:00:00'
792
+							: $an_activation;
793
+					}
794
+				}
795
+			}
796
+		}
797
+		return $most_recently_active_version;
798
+	}
799
+
800
+
801
+	/**
802
+	 * This redirects to the about EE page after activation
803
+	 *
804
+	 * @return void
805
+	 */
806
+	public function redirect_to_about_ee()
807
+	{
808
+		$notices = EE_Error::get_notices(false);
809
+		// if current user is an admin and it's not an ajax or rest request
810
+		if (! isset($notices['errors'])
811
+			&& $this->request->isAdmin()
812
+			&& apply_filters(
813
+				'FHEE__EE_System__redirect_to_about_ee__do_redirect',
814
+				$this->capabilities->current_user_can('manage_options', 'espresso_about_default')
815
+			)
816
+		) {
817
+			$query_params = array('page' => 'espresso_about');
818
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
819
+				$query_params['new_activation'] = true;
820
+			}
821
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
822
+				$query_params['reactivation'] = true;
823
+			}
824
+			$url = add_query_arg($query_params, admin_url('admin.php'));
825
+			wp_safe_redirect($url);
826
+			exit();
827
+		}
828
+	}
829
+
830
+
831
+	/**
832
+	 * load_core_configuration
833
+	 * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
834
+	 * which runs during the WP 'plugins_loaded' action at priority 5
835
+	 *
836
+	 * @return void
837
+	 * @throws ReflectionException
838
+	 */
839
+	public function load_core_configuration()
840
+	{
841
+		do_action('AHEE__EE_System__load_core_configuration__begin', $this);
842
+		$this->loader->getShared('EE_Load_Textdomain');
843
+		// load textdomain
844
+		EE_Load_Textdomain::load_textdomain();
845
+		// load and setup EE_Config and EE_Network_Config
846
+		$config = $this->loader->getShared('EE_Config');
847
+		$this->loader->getShared('EE_Network_Config');
848
+		// setup autoloaders
849
+		// enable logging?
850
+		if ($config->admin->use_full_logging) {
851
+			$this->loader->getShared('EE_Log');
852
+		}
853
+		// check for activation errors
854
+		$activation_errors = get_option('ee_plugin_activation_errors', false);
855
+		if ($activation_errors) {
856
+			EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
857
+			update_option('ee_plugin_activation_errors', false);
858
+		}
859
+		// get model names
860
+		$this->_parse_model_names();
861
+		// load caf stuff a chance to play during the activation process too.
862
+		$this->_maybe_brew_regular();
863
+		// configure custom post type definitions
864
+		$this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions');
865
+		$this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions');
866
+		do_action('AHEE__EE_System__load_core_configuration__complete', $this);
867
+	}
868
+
869
+
870
+	/**
871
+	 * cycles through all of the models/*.model.php files, and assembles an array of model names
872
+	 *
873
+	 * @return void
874
+	 * @throws ReflectionException
875
+	 */
876
+	private function _parse_model_names()
877
+	{
878
+		// get all the files in the EE_MODELS folder that end in .model.php
879
+		$models = glob(EE_MODELS . '*.model.php');
880
+		$model_names = array();
881
+		$non_abstract_db_models = array();
882
+		foreach ($models as $model) {
883
+			// get model classname
884
+			$classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
885
+			$short_name = str_replace('EEM_', '', $classname);
886
+			$reflectionClass = new ReflectionClass($classname);
887
+			if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
888
+				$non_abstract_db_models[ $short_name ] = $classname;
889
+			}
890
+			$model_names[ $short_name ] = $classname;
891
+		}
892
+		$this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
893
+		$this->registry->non_abstract_db_models = apply_filters(
894
+			'FHEE__EE_System__parse_implemented_model_names',
895
+			$non_abstract_db_models
896
+		);
897
+	}
898
+
899
+
900
+	/**
901
+	 * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
902
+	 * that need to be setup before our EE_System launches.
903
+	 *
904
+	 * @return void
905
+	 * @throws DomainException
906
+	 * @throws InvalidArgumentException
907
+	 * @throws InvalidDataTypeException
908
+	 * @throws InvalidInterfaceException
909
+	 * @throws InvalidClassException
910
+	 * @throws InvalidFilePathException
911
+	 */
912
+	private function _maybe_brew_regular()
913
+	{
914
+		/** @var Domain $domain */
915
+		$domain = DomainFactory::getShared(
916
+			new FullyQualifiedName(
917
+				'EventEspresso\core\domain\Domain'
918
+			),
919
+			array(
920
+				new FilePath(EVENT_ESPRESSO_MAIN_FILE),
921
+				Version::fromString(espresso_version()),
922
+			)
923
+		);
924
+		if ($domain->isCaffeinated()) {
925
+			require_once EE_CAFF_PATH . 'brewing_regular.php';
926
+		}
927
+	}
928
+
929
+
930
+	/**
931
+	 * register_shortcodes_modules_and_widgets
932
+	 * generate lists of shortcodes and modules, then verify paths and classes
933
+	 * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
934
+	 * which runs during the WP 'plugins_loaded' action at priority 7
935
+	 *
936
+	 * @access public
937
+	 * @return void
938
+	 * @throws Exception
939
+	 */
940
+	public function register_shortcodes_modules_and_widgets()
941
+	{
942
+		if ($this->request->isFrontend() || $this->request->isIframe()) {
943
+			try {
944
+				// load, register, and add shortcodes the new way
945
+				$this->loader->getShared(
946
+					'EventEspresso\core\services\shortcodes\ShortcodesManager',
947
+					array(
948
+						// and the old way, but we'll put it under control of the new system
949
+						EE_Config::getLegacyShortcodesManager(),
950
+					)
951
+				);
952
+			} catch (Exception $exception) {
953
+				new ExceptionStackTraceDisplay($exception);
954
+			}
955
+		}
956
+		do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
957
+		// check for addons using old hook point
958
+		if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
959
+			$this->_incompatible_addon_error();
960
+		}
961
+	}
962
+
963
+
964
+	/**
965
+	 * _incompatible_addon_error
966
+	 *
967
+	 * @access public
968
+	 * @return void
969
+	 */
970
+	private function _incompatible_addon_error()
971
+	{
972
+		// get array of classes hooking into here
973
+		$class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
974
+			'AHEE__EE_System__register_shortcodes_modules_and_addons'
975
+		);
976
+		if (! empty($class_names)) {
977
+			$msg = __(
978
+				'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
979
+				'event_espresso'
980
+			);
981
+			$msg .= '<ul>';
982
+			foreach ($class_names as $class_name) {
983
+				$msg .= '<li><b>Event Espresso - '
984
+						. str_replace(
985
+							array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'),
986
+							'',
987
+							$class_name
988
+						) . '</b></li>';
989
+			}
990
+			$msg .= '</ul>';
991
+			$msg .= __(
992
+				'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
993
+				'event_espresso'
994
+			);
995
+			// save list of incompatible addons to wp-options for later use
996
+			add_option('ee_incompatible_addons', $class_names, '', 'no');
997
+			if (is_admin()) {
998
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
999
+			}
1000
+		}
1001
+	}
1002
+
1003
+
1004
+	/**
1005
+	 * brew_espresso
1006
+	 * begins the process of setting hooks for initializing EE in the correct order
1007
+	 * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
1008
+	 * which runs during the WP 'plugins_loaded' action at priority 9
1009
+	 *
1010
+	 * @return void
1011
+	 */
1012
+	public function brew_espresso()
1013
+	{
1014
+		do_action('AHEE__EE_System__brew_espresso__begin', $this);
1015
+		// load some final core systems
1016
+		add_action('init', array($this, 'set_hooks_for_core'), 1);
1017
+		add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
1018
+		add_action('init', array($this, 'load_CPTs_and_session'), 5);
1019
+		add_action('init', array($this, 'load_controllers'), 7);
1020
+		add_action('init', array($this, 'core_loaded_and_ready'), 9);
1021
+		add_action('init', array($this, 'initialize'), 10);
1022
+		add_action('init', array($this, 'initialize_last'), 100);
1023
+		if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
1024
+			// pew pew pew
1025
+			$this->loader->getShared('EventEspresso\core\services\licensing\LicenseService');
1026
+			do_action('AHEE__EE_System__brew_espresso__after_pue_init');
1027
+		}
1028
+		do_action('AHEE__EE_System__brew_espresso__complete', $this);
1029
+	}
1030
+
1031
+
1032
+	/**
1033
+	 *    set_hooks_for_core
1034
+	 *
1035
+	 * @access public
1036
+	 * @return    void
1037
+	 * @throws EE_Error
1038
+	 */
1039
+	public function set_hooks_for_core()
1040
+	{
1041
+		$this->_deactivate_incompatible_addons();
1042
+		do_action('AHEE__EE_System__set_hooks_for_core');
1043
+		$this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan');
1044
+		// caps need to be initialized on every request so that capability maps are set.
1045
+		// @see https://events.codebasehq.com/projects/event-espresso/tickets/8674
1046
+		$this->registry->CAP->init_caps();
1047
+	}
1048
+
1049
+
1050
+	/**
1051
+	 * Using the information gathered in EE_System::_incompatible_addon_error,
1052
+	 * deactivates any addons considered incompatible with the current version of EE
1053
+	 */
1054
+	private function _deactivate_incompatible_addons()
1055
+	{
1056
+		$incompatible_addons = get_option('ee_incompatible_addons', array());
1057
+		if (! empty($incompatible_addons)) {
1058
+			$active_plugins = get_option('active_plugins', array());
1059
+			foreach ($active_plugins as $active_plugin) {
1060
+				foreach ($incompatible_addons as $incompatible_addon) {
1061
+					if (strpos($active_plugin, $incompatible_addon) !== false) {
1062
+						unset($_GET['activate']);
1063
+						espresso_deactivate_plugin($active_plugin);
1064
+					}
1065
+				}
1066
+			}
1067
+		}
1068
+	}
1069
+
1070
+
1071
+	/**
1072
+	 *    perform_activations_upgrades_and_migrations
1073
+	 *
1074
+	 * @access public
1075
+	 * @return    void
1076
+	 */
1077
+	public function perform_activations_upgrades_and_migrations()
1078
+	{
1079
+		do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
1080
+	}
1081
+
1082
+
1083
+	/**
1084
+	 * @return void
1085
+	 * @throws DomainException
1086
+	 */
1087
+	public function load_CPTs_and_session()
1088
+	{
1089
+		do_action('AHEE__EE_System__load_CPTs_and_session__start');
1090
+		/** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies $register_custom_taxonomies */
1091
+		$register_custom_taxonomies = $this->loader->getShared(
1092
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'
1093
+		);
1094
+		$register_custom_taxonomies->registerCustomTaxonomies();
1095
+		/** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes $register_custom_post_types */
1096
+		$register_custom_post_types = $this->loader->getShared(
1097
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'
1098
+		);
1099
+		$register_custom_post_types->registerCustomPostTypes();
1100
+		/** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms */
1101
+		$register_custom_taxonomy_terms = $this->loader->getShared(
1102
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms'
1103
+		);
1104
+		$register_custom_taxonomy_terms->registerCustomTaxonomyTerms();
1105
+		// load legacy Custom Post Types and Taxonomies
1106
+		$this->loader->getShared('EE_Register_CPTs');
1107
+		do_action('AHEE__EE_System__load_CPTs_and_session__complete');
1108
+	}
1109
+
1110
+
1111
+	/**
1112
+	 * load_controllers
1113
+	 * this is the best place to load any additional controllers that needs access to EE core.
1114
+	 * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
1115
+	 * time
1116
+	 *
1117
+	 * @access public
1118
+	 * @return void
1119
+	 */
1120
+	public function load_controllers()
1121
+	{
1122
+		do_action('AHEE__EE_System__load_controllers__start');
1123
+		// let's get it started
1124
+		if (! $this->maintenance_mode->level()
1125
+			&& ($this->request->isFrontend() || $this->request->isFrontAjax())
1126
+		) {
1127
+			do_action('AHEE__EE_System__load_controllers__load_front_controllers');
1128
+			$this->loader->getShared('EE_Front_Controller');
1129
+		} elseif ($this->request->isAdmin() || $this->request->isAdminAjax()) {
1130
+			do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1131
+			$this->loader->getShared('EE_Admin');
1132
+		}
1133
+		do_action('AHEE__EE_System__load_controllers__complete');
1134
+	}
1135
+
1136
+
1137
+	/**
1138
+	 * core_loaded_and_ready
1139
+	 * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1140
+	 *
1141
+	 * @access public
1142
+	 * @return void
1143
+	 * @throws Exception
1144
+	 */
1145
+	public function core_loaded_and_ready()
1146
+	{
1147
+		if ($this->request->isAdmin() || $this->request->isFrontend() || $this->request->isIframe()) {
1148
+			try {
1149
+				$this->loader->getShared('EventEspresso\core\services\assets\Registry');
1150
+				$this->loader->getShared('EventEspresso\core\domain\services\assets\CoreAssetManager');
1151
+			} catch (Exception $exception) {
1152
+				new ExceptionStackTraceDisplay($exception);
1153
+			}
1154
+		}
1155
+		if ($this->request->isAdmin()
1156
+			|| $this->request->isEeAjax()
1157
+			|| $this->request->isFrontend()
1158
+		) {
1159
+			$this->loader->getShared('EE_Session');
1160
+		}
1161
+		do_action('AHEE__EE_System__core_loaded_and_ready');
1162
+		// load_espresso_template_tags
1163
+		if (is_readable(EE_PUBLIC . 'template_tags.php')
1164
+			&& ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isFeed())
1165
+		) {
1166
+			require_once EE_PUBLIC . 'template_tags.php';
1167
+		}
1168
+		do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1169
+	}
1170
+
1171
+
1172
+	/**
1173
+	 * initialize
1174
+	 * this is the best place to begin initializing client code
1175
+	 *
1176
+	 * @access public
1177
+	 * @return void
1178
+	 */
1179
+	public function initialize()
1180
+	{
1181
+		do_action('AHEE__EE_System__initialize');
1182
+	}
1183
+
1184
+
1185
+	/**
1186
+	 * initialize_last
1187
+	 * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1188
+	 * initialize has done so
1189
+	 *
1190
+	 * @access public
1191
+	 * @return void
1192
+	 */
1193
+	public function initialize_last()
1194
+	{
1195
+		do_action('AHEE__EE_System__initialize_last');
1196
+		/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
1197
+		$rewrite_rules = $this->loader->getShared(
1198
+			'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
1199
+		);
1200
+		$rewrite_rules->flushRewriteRules();
1201
+		add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1202
+		if (($this->request->isAjax() || $this->request->isAdmin())
1203
+			&& $this->maintenance_mode->models_can_query()) {
1204
+			$this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager');
1205
+			$this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager');
1206
+		}
1207
+	}
1208
+
1209
+
1210
+	/**
1211
+	 * @return void
1212
+	 * @throws EE_Error
1213
+	 */
1214
+	public function addEspressoToolbar()
1215
+	{
1216
+		$this->loader->getShared(
1217
+			'EventEspresso\core\domain\services\admin\AdminToolBar',
1218
+			array($this->registry->CAP)
1219
+		);
1220
+	}
1221
+
1222
+
1223
+	/**
1224
+	 * do_not_cache
1225
+	 * sets no cache headers and defines no cache constants for WP plugins
1226
+	 *
1227
+	 * @access public
1228
+	 * @return void
1229
+	 */
1230
+	public static function do_not_cache()
1231
+	{
1232
+		// set no cache constants
1233
+		if (! defined('DONOTCACHEPAGE')) {
1234
+			define('DONOTCACHEPAGE', true);
1235
+		}
1236
+		if (! defined('DONOTCACHCEOBJECT')) {
1237
+			define('DONOTCACHCEOBJECT', true);
1238
+		}
1239
+		if (! defined('DONOTCACHEDB')) {
1240
+			define('DONOTCACHEDB', true);
1241
+		}
1242
+		// add no cache headers
1243
+		add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1244
+		// plus a little extra for nginx and Google Chrome
1245
+		add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1246
+		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1247
+		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1248
+	}
1249
+
1250
+
1251
+	/**
1252
+	 *    extra_nocache_headers
1253
+	 *
1254
+	 * @access    public
1255
+	 * @param $headers
1256
+	 * @return    array
1257
+	 */
1258
+	public static function extra_nocache_headers($headers)
1259
+	{
1260
+		// for NGINX
1261
+		$headers['X-Accel-Expires'] = 0;
1262
+		// plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1263
+		$headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1264
+		return $headers;
1265
+	}
1266
+
1267
+
1268
+	/**
1269
+	 *    nocache_headers
1270
+	 *
1271
+	 * @access    public
1272
+	 * @return    void
1273
+	 */
1274
+	public static function nocache_headers()
1275
+	{
1276
+		nocache_headers();
1277
+	}
1278
+
1279
+
1280
+	/**
1281
+	 * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1282
+	 * never returned with the function.
1283
+	 *
1284
+	 * @param  array $exclude_array any existing pages being excluded are in this array.
1285
+	 * @return array
1286
+	 */
1287
+	public function remove_pages_from_wp_list_pages($exclude_array)
1288
+	{
1289
+		return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1290
+	}
1291 1291
 }
Please login to merge, or discard this patch.
core/domain/services/admin/privacy/policy/privacy_policy.template.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
 ?>
8 8
 <h2><?php esc_html_e('Event Registration Data', 'event_espresso'); ?></h2>
9 9
 <p><?php
10
-    esc_html_e(
11
-        'We collect information about you during event registration. This information may include but is not limited to:',
12
-        'event_espresso'
13
-    ); ?></p>
10
+	esc_html_e(
11
+		'We collect information about you during event registration. This information may include but is not limited to:',
12
+		'event_espresso'
13
+	); ?></p>
14 14
 <ul>
15 15
     <li><?php esc_html_e('Your names', 'event_espresso'); ?></li>
16 16
     <li><?php esc_html_e('Billing address', 'event_espresso'); ?></li>
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
     <li><?php esc_html_e('Phone number', 'event_espresso'); ?></li>
20 20
     <li><?php esc_html_e('Location and traffic data (including partial IP address and browser type)', 'event_espresso'); ?></li>
21 21
     <li><?php
22
-        esc_html_e(
23
-            'Any other details that might be requested from you for the purpose of processing your registration or ticket purchase',
24
-            'event_espresso'
25
-        ); ?></li>
22
+		esc_html_e(
23
+			'Any other details that might be requested from you for the purpose of processing your registration or ticket purchase',
24
+			'event_espresso'
25
+		); ?></li>
26 26
 </ul>
27 27
 
28 28
 <p><?php esc_html_e('Handling this data also allows us to:', 'event_espresso'); ?></p>
@@ -30,102 +30,102 @@  discard block
 block discarded – undo
30 30
     <li><?php esc_html_e('Send you important account/purchase/service information.', 'event_espresso'); ?></li>
31 31
     <li><?php esc_html_e('Respond to your queries, refund requests, or complaints.', 'event_espresso'); ?></li>
32 32
     <li><?php
33
-        esc_html_e(
34
-            'Process payments and prevent fraudulent transactions. We do this on the basis of our legitimate business interests.',
35
-            'event_espresso'
36
-        ); ?></li>
33
+		esc_html_e(
34
+			'Process payments and prevent fraudulent transactions. We do this on the basis of our legitimate business interests.',
35
+			'event_espresso'
36
+		); ?></li>
37 37
     <li><?php
38
-        esc_html_e(
39
-            'Set up and administer your account, provide technical and customer support, and to verify your identity.',
40
-            'event_espresso'
41
-        ); ?></li>
38
+		esc_html_e(
39
+			'Set up and administer your account, provide technical and customer support, and to verify your identity.',
40
+			'event_espresso'
41
+		); ?></li>
42 42
 </ul>
43 43
 
44 44
 <?php if (! empty($active_onsite_payment_methods) || ! empty($active_offsite_payment_methods)) { ?>
45 45
     <h2><?php esc_html_e('Billing Information', 'event_espresso'); ?> </h2>
46 46
     <?php
47 47
 // if onsite or offsite payment methods are active
48
-    if (! empty($active_onsite_payment_methods)) { ?>
48
+	if (! empty($active_onsite_payment_methods)) { ?>
49 49
         <p><?php
50
-            esc_html_e(
51
-                'In order to process payments, we collect billing information on-site. Sensitive billing information is not stored on our server, but may be handled while in-transit to the payment processing server.',
52
-                'event_espresso'
53
-            ); ?></p>
50
+			esc_html_e(
51
+				'In order to process payments, we collect billing information on-site. Sensitive billing information is not stored on our server, but may be handled while in-transit to the payment processing server.',
52
+				'event_espresso'
53
+			); ?></p>
54 54
         <p><?php
55
-            printf(
56
-                esc_html_x(
57
-                    'Please see the privacy policy of %1$s.',
58
-                    'Please see the privacy policy of PayPal Pro',
59
-                    'event_espresso'
60
-                ),
61
-                implode(
62
-                    ', ',
63
-                    array_merge(
64
-                        $active_onsite_payment_methods,
65
-                        $active_offsite_payment_methods
66
-                    )
67
-                )
68
-            ); ?></p>
55
+			printf(
56
+				esc_html_x(
57
+					'Please see the privacy policy of %1$s.',
58
+					'Please see the privacy policy of PayPal Pro',
59
+					'event_espresso'
60
+				),
61
+				implode(
62
+					', ',
63
+					array_merge(
64
+						$active_onsite_payment_methods,
65
+						$active_offsite_payment_methods
66
+					)
67
+				)
68
+			); ?></p>
69 69
         <p><?php
70
-            esc_html_e(
71
-                'Masked billing information may be stored on our servers (eg only the last 4 digits of credit card numbers are stored: **** **** **** 1234).',
72
-                'event_espresso'
73
-            ); ?></p>
70
+			esc_html_e(
71
+				'Masked billing information may be stored on our servers (eg only the last 4 digits of credit card numbers are stored: **** **** **** 1234).',
72
+				'event_espresso'
73
+			); ?></p>
74 74
     <?php } // IF OFFSITE PAYMENT METHOD ACTIVE
75
-    elseif (! empty($active_offsite_payment_methods)) { ?>
75
+	elseif (! empty($active_offsite_payment_methods)) { ?>
76 76
         <p><?php
77
-            printf(
78
-                esc_html_x(
79
-                    'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of %1$s.',
80
-                    'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of PayPal Pro.',
81
-                    'event_espresso'
82
-                ),
83
-                implode(', ', $active_offsite_payment_methods)
84
-            ); ?></p>
77
+			printf(
78
+				esc_html_x(
79
+					'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of %1$s.',
80
+					'Billing information is sent directly to the payment processor, and is not handled by our servers. Please see the privacy policy of PayPal Pro.',
81
+					'event_espresso'
82
+				),
83
+				implode(', ', $active_offsite_payment_methods)
84
+			); ?></p>
85 85
     <?php } ?>
86 86
     <h2><?php esc_html_e('Payment Logging', 'event_espresso'); ?></h2>
87 87
     <p><?php
88
-        esc_html_e(
89
-            'Site administrators may keep a log of communications with the payment processors in order to verify payments are being processed correctly. These logs are automatically deleted after a week.',
90
-            'event_espresso'
91
-        ); ?></p>
88
+		esc_html_e(
89
+			'Site administrators may keep a log of communications with the payment processors in order to verify payments are being processed correctly. These logs are automatically deleted after a week.',
90
+			'event_espresso'
91
+		); ?></p>
92 92
 <?php } ?>
93 93
 
94 94
 <h2><?php esc_html_e('Event Registration Cookies', 'event_espresso'); ?></h2>
95 95
 <p><?php
96
-    printf(
97
-        esc_html_x(
98
-            'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts %1$s.',
99
-            'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts 2 hours.',
100
-            'event_espresso'
101
-        ),
102
-        $session_lifespan
103
-    ); ?></p>
96
+	printf(
97
+		esc_html_x(
98
+			'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts %1$s.',
99
+			'When you begin registering for an event and select a ticket quantity, a cookie will be used to track your registration. This cookie lasts 2 hours.',
100
+			'event_espresso'
101
+		),
102
+		$session_lifespan
103
+	); ?></p>
104 104
 
105 105
 <h2><?php esc_html_e('Email History Data', 'event_espresso'); ?></h2>
106 106
 <p><?php
107
-    esc_html_e(
108
-        'We keep a record of the emails sent to you. This is to ensure communication is successfully sent and its information is accurate.',
109
-        'event_espresso'
110
-    ); ?></p>
107
+	esc_html_e(
108
+		'We keep a record of the emails sent to you. This is to ensure communication is successfully sent and its information is accurate.',
109
+		'event_espresso'
110
+	); ?></p>
111 111
 
112 112
 <h2><?php esc_html_e('Event Check-In Record', 'event_espresso'); ?></h2>
113 113
 <p><?php
114
-    esc_html_e(
115
-        'When you attend an event, an event manager may record the time you check in or out of the event.',
116
-        'event_espresso'
117
-    ); ?></p>
114
+	esc_html_e(
115
+		'When you attend an event, an event manager may record the time you check in or out of the event.',
116
+		'event_espresso'
117
+	); ?></p>
118 118
 
119 119
 <h2><?php esc_html_e('Event Registration Data Retention', 'event_espresso'); ?></h2>
120 120
 <p><?php
121
-    esc_html_e(
122
-        'Personal data is stored at least until the date of the event, and may be kept indefinitely in case of future registrations.',
123
-        'event_espresso'
124
-    ); ?></p>
121
+	esc_html_e(
122
+		'Personal data is stored at least until the date of the event, and may be kept indefinitely in case of future registrations.',
123
+		'event_espresso'
124
+	); ?></p>
125 125
 
126 126
 <h2><?php esc_html_e('Event Registration Data Erasure and Export', 'event_espresso'); ?></h2>
127 127
 <p><?php
128
-    esc_html_e(
129
-        'You have the right to request your personal data be sent to you electronically, and the right to request your registration data be erased after the event. To do so, please contact the event manager or site administrator.',
130
-        'event_espresso'
131
-    ); ?></p>
128
+	esc_html_e(
129
+		'You have the right to request your personal data be sent to you electronically, and the right to request your registration data be erased after the event. To do so, please contact the event manager or site administrator.',
130
+		'event_espresso'
131
+	); ?></p>
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
         ); ?></li>
42 42
 </ul>
43 43
 
44
-<?php if (! empty($active_onsite_payment_methods) || ! empty($active_offsite_payment_methods)) { ?>
44
+<?php if ( ! empty($active_onsite_payment_methods) || ! empty($active_offsite_payment_methods)) { ?>
45 45
     <h2><?php esc_html_e('Billing Information', 'event_espresso'); ?> </h2>
46 46
     <?php
47 47
 // if onsite or offsite payment methods are active
48
-    if (! empty($active_onsite_payment_methods)) { ?>
48
+    if ( ! empty($active_onsite_payment_methods)) { ?>
49 49
         <p><?php
50 50
             esc_html_e(
51 51
                 'In order to process payments, we collect billing information on-site. Sensitive billing information is not stored on our server, but may be handled while in-transit to the payment processing server.',
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 'event_espresso'
73 73
             ); ?></p>
74 74
     <?php } // IF OFFSITE PAYMENT METHOD ACTIVE
75
-    elseif (! empty($active_offsite_payment_methods)) { ?>
75
+    elseif ( ! empty($active_offsite_payment_methods)) { ?>
76 76
         <p><?php
77 77
             printf(
78 78
                 esc_html_x(
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 1 patch
Indentation   +3824 added lines, -3824 removed lines patch added patch discarded remove patch
@@ -19,2399 +19,2399 @@  discard block
 block discarded – undo
19 19
 class Registrations_Admin_Page extends EE_Admin_Page_CPT
20 20
 {
21 21
 
22
-    /**
23
-     * @var EE_Registration
24
-     */
25
-    private $_registration;
26
-
27
-    /**
28
-     * @var EE_Event
29
-     */
30
-    private $_reg_event;
31
-
32
-    /**
33
-     * @var EE_Session
34
-     */
35
-    private $_session;
36
-
37
-    private static $_reg_status;
38
-
39
-    /**
40
-     * Form for displaying the custom questions for this registration.
41
-     * This gets used a few times throughout the request so its best to cache it
42
-     *
43
-     * @var EE_Registration_Custom_Questions_Form
44
-     */
45
-    protected $_reg_custom_questions_form = null;
46
-
47
-
48
-    /**
49
-     *        constructor
50
-     *
51
-     * @Constructor
52
-     * @access public
53
-     * @param bool $routing
54
-     * @return Registrations_Admin_Page
55
-     */
56
-    public function __construct($routing = true)
57
-    {
58
-        parent::__construct($routing);
59
-        add_action('wp_loaded', array($this, 'wp_loaded'));
60
-    }
61
-
62
-
63
-    public function wp_loaded()
64
-    {
65
-        // when adding a new registration...
66
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
67
-            EE_System::do_not_cache();
68
-            if (! isset($this->_req_data['processing_registration'])
69
-                || absint($this->_req_data['processing_registration']) !== 1
70
-            ) {
71
-                // and it's NOT the attendee information reg step
72
-                // force cookie expiration by setting time to last week
73
-                setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
74
-                // and update the global
75
-                $_COOKIE['ee_registration_added'] = 0;
76
-            }
77
-        }
78
-    }
79
-
80
-
81
-    protected function _init_page_props()
82
-    {
83
-        $this->page_slug = REG_PG_SLUG;
84
-        $this->_admin_base_url = REG_ADMIN_URL;
85
-        $this->_admin_base_path = REG_ADMIN;
86
-        $this->page_label = esc_html__('Registrations', 'event_espresso');
87
-        $this->_cpt_routes = array(
88
-            'add_new_attendee' => 'espresso_attendees',
89
-            'edit_attendee'    => 'espresso_attendees',
90
-            'insert_attendee'  => 'espresso_attendees',
91
-            'update_attendee'  => 'espresso_attendees',
92
-        );
93
-        $this->_cpt_model_names = array(
94
-            'add_new_attendee' => 'EEM_Attendee',
95
-            'edit_attendee'    => 'EEM_Attendee',
96
-        );
97
-        $this->_cpt_edit_routes = array(
98
-            'espresso_attendees' => 'edit_attendee',
99
-        );
100
-        $this->_pagenow_map = array(
101
-            'add_new_attendee' => 'post-new.php',
102
-            'edit_attendee'    => 'post.php',
103
-            'trash'            => 'post.php',
104
-        );
105
-        add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
106
-        // add filters so that the comment urls don't take users to a confusing 404 page
107
-        add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
108
-    }
109
-
110
-
111
-    public function clear_comment_link($link, $comment, $args)
112
-    {
113
-        // gotta make sure this only happens on this route
114
-        $post_type = get_post_type($comment->comment_post_ID);
115
-        if ($post_type === 'espresso_attendees') {
116
-            return '#commentsdiv';
117
-        }
118
-        return $link;
119
-    }
120
-
121
-
122
-    protected function _ajax_hooks()
123
-    {
124
-        // todo: all hooks for registrations ajax goes in here
125
-        add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
126
-    }
127
-
128
-
129
-    protected function _define_page_props()
130
-    {
131
-        $this->_admin_page_title = $this->page_label;
132
-        $this->_labels = array(
133
-            'buttons'                      => array(
134
-                'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
135
-                'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
136
-                'edit'                => esc_html__('Edit Contact', 'event_espresso'),
137
-                'report'              => esc_html__("Event Registrations CSV Report", "event_espresso"),
138
-                'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
139
-                'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
140
-                'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
141
-                'contact_list_export' => esc_html__("Export Data", "event_espresso"),
142
-            ),
143
-            'publishbox'                   => array(
144
-                'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'),
145
-                'edit_attendee'    => esc_html__("Update Contact Record", 'event_espresso'),
146
-            ),
147
-            'hide_add_button_on_cpt_route' => array(
148
-                'edit_attendee' => true,
149
-            ),
150
-        );
151
-    }
152
-
153
-
154
-    /**
155
-     *        grab url requests and route them
156
-     *
157
-     * @access private
158
-     * @return void
159
-     */
160
-    public function _set_page_routes()
161
-    {
162
-        $this->_get_registration_status_array();
163
-        $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
164
-            ? $this->_req_data['_REG_ID'] : 0;
165
-        $reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID'])
166
-            ? $this->_req_data['reg_status_change_form']['REG_ID']
167
-            : $reg_id;
168
-        $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
169
-            ? $this->_req_data['ATT_ID'] : 0;
170
-        $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post'])
171
-            ? $this->_req_data['post']
172
-            : $att_id;
173
-        $this->_page_routes = array(
174
-            'default'                             => array(
175
-                'func'       => '_registrations_overview_list_table',
176
-                'capability' => 'ee_read_registrations',
177
-            ),
178
-            'view_registration'                   => array(
179
-                'func'       => '_registration_details',
180
-                'capability' => 'ee_read_registration',
181
-                'obj_id'     => $reg_id,
182
-            ),
183
-            'edit_registration'                   => array(
184
-                'func'               => '_update_attendee_registration_form',
185
-                'noheader'           => true,
186
-                'headers_sent_route' => 'view_registration',
187
-                'capability'         => 'ee_edit_registration',
188
-                'obj_id'             => $reg_id,
189
-                '_REG_ID'            => $reg_id,
190
-            ),
191
-            'trash_registrations'                 => array(
192
-                'func'       => '_trash_or_restore_registrations',
193
-                'args'       => array('trash' => true),
194
-                'noheader'   => true,
195
-                'capability' => 'ee_delete_registrations',
196
-            ),
197
-            'restore_registrations'               => array(
198
-                'func'       => '_trash_or_restore_registrations',
199
-                'args'       => array('trash' => false),
200
-                'noheader'   => true,
201
-                'capability' => 'ee_delete_registrations',
202
-            ),
203
-            'delete_registrations'                => array(
204
-                'func'       => '_delete_registrations',
205
-                'noheader'   => true,
206
-                'capability' => 'ee_delete_registrations',
207
-            ),
208
-            'new_registration'                    => array(
209
-                'func'       => 'new_registration',
210
-                'capability' => 'ee_edit_registrations',
211
-            ),
212
-            'process_reg_step'                    => array(
213
-                'func'       => 'process_reg_step',
214
-                'noheader'   => true,
215
-                'capability' => 'ee_edit_registrations',
216
-            ),
217
-            'redirect_to_txn'                     => array(
218
-                'func'       => 'redirect_to_txn',
219
-                'noheader'   => true,
220
-                'capability' => 'ee_edit_registrations',
221
-            ),
222
-            'change_reg_status'                   => array(
223
-                'func'       => '_change_reg_status',
224
-                'noheader'   => true,
225
-                'capability' => 'ee_edit_registration',
226
-                'obj_id'     => $reg_id,
227
-            ),
228
-            'approve_registration'                => array(
229
-                'func'       => 'approve_registration',
230
-                'noheader'   => true,
231
-                'capability' => 'ee_edit_registration',
232
-                'obj_id'     => $reg_id,
233
-            ),
234
-            'approve_and_notify_registration'     => array(
235
-                'func'       => 'approve_registration',
236
-                'noheader'   => true,
237
-                'args'       => array(true),
238
-                'capability' => 'ee_edit_registration',
239
-                'obj_id'     => $reg_id,
240
-            ),
241
-            'approve_registrations'               => array(
242
-                'func'       => 'bulk_action_on_registrations',
243
-                'noheader'   => true,
244
-                'capability' => 'ee_edit_registrations',
245
-                'args'       => array('approve'),
246
-            ),
247
-            'approve_and_notify_registrations'    => array(
248
-                'func'       => 'bulk_action_on_registrations',
249
-                'noheader'   => true,
250
-                'capability' => 'ee_edit_registrations',
251
-                'args'       => array('approve', true),
252
-            ),
253
-            'decline_registration'                => array(
254
-                'func'       => 'decline_registration',
255
-                'noheader'   => true,
256
-                'capability' => 'ee_edit_registration',
257
-                'obj_id'     => $reg_id,
258
-            ),
259
-            'decline_and_notify_registration'     => array(
260
-                'func'       => 'decline_registration',
261
-                'noheader'   => true,
262
-                'args'       => array(true),
263
-                'capability' => 'ee_edit_registration',
264
-                'obj_id'     => $reg_id,
265
-            ),
266
-            'decline_registrations'               => array(
267
-                'func'       => 'bulk_action_on_registrations',
268
-                'noheader'   => true,
269
-                'capability' => 'ee_edit_registrations',
270
-                'args'       => array('decline'),
271
-            ),
272
-            'decline_and_notify_registrations'    => array(
273
-                'func'       => 'bulk_action_on_registrations',
274
-                'noheader'   => true,
275
-                'capability' => 'ee_edit_registrations',
276
-                'args'       => array('decline', true),
277
-            ),
278
-            'pending_registration'                => array(
279
-                'func'       => 'pending_registration',
280
-                'noheader'   => true,
281
-                'capability' => 'ee_edit_registration',
282
-                'obj_id'     => $reg_id,
283
-            ),
284
-            'pending_and_notify_registration'     => array(
285
-                'func'       => 'pending_registration',
286
-                'noheader'   => true,
287
-                'args'       => array(true),
288
-                'capability' => 'ee_edit_registration',
289
-                'obj_id'     => $reg_id,
290
-            ),
291
-            'pending_registrations'               => array(
292
-                'func'       => 'bulk_action_on_registrations',
293
-                'noheader'   => true,
294
-                'capability' => 'ee_edit_registrations',
295
-                'args'       => array('pending'),
296
-            ),
297
-            'pending_and_notify_registrations'    => array(
298
-                'func'       => 'bulk_action_on_registrations',
299
-                'noheader'   => true,
300
-                'capability' => 'ee_edit_registrations',
301
-                'args'       => array('pending', true),
302
-            ),
303
-            'no_approve_registration'             => array(
304
-                'func'       => 'not_approve_registration',
305
-                'noheader'   => true,
306
-                'capability' => 'ee_edit_registration',
307
-                'obj_id'     => $reg_id,
308
-            ),
309
-            'no_approve_and_notify_registration'  => array(
310
-                'func'       => 'not_approve_registration',
311
-                'noheader'   => true,
312
-                'args'       => array(true),
313
-                'capability' => 'ee_edit_registration',
314
-                'obj_id'     => $reg_id,
315
-            ),
316
-            'no_approve_registrations'            => array(
317
-                'func'       => 'bulk_action_on_registrations',
318
-                'noheader'   => true,
319
-                'capability' => 'ee_edit_registrations',
320
-                'args'       => array('not_approve'),
321
-            ),
322
-            'no_approve_and_notify_registrations' => array(
323
-                'func'       => 'bulk_action_on_registrations',
324
-                'noheader'   => true,
325
-                'capability' => 'ee_edit_registrations',
326
-                'args'       => array('not_approve', true),
327
-            ),
328
-            'cancel_registration'                 => array(
329
-                'func'       => 'cancel_registration',
330
-                'noheader'   => true,
331
-                'capability' => 'ee_edit_registration',
332
-                'obj_id'     => $reg_id,
333
-            ),
334
-            'cancel_and_notify_registration'      => array(
335
-                'func'       => 'cancel_registration',
336
-                'noheader'   => true,
337
-                'args'       => array(true),
338
-                'capability' => 'ee_edit_registration',
339
-                'obj_id'     => $reg_id,
340
-            ),
341
-            'cancel_registrations'                => array(
342
-                'func'       => 'bulk_action_on_registrations',
343
-                'noheader'   => true,
344
-                'capability' => 'ee_edit_registrations',
345
-                'args'       => array('cancel'),
346
-            ),
347
-            'cancel_and_notify_registrations'     => array(
348
-                'func'       => 'bulk_action_on_registrations',
349
-                'noheader'   => true,
350
-                'capability' => 'ee_edit_registrations',
351
-                'args'       => array('cancel', true),
352
-            ),
353
-            'wait_list_registration'              => array(
354
-                'func'       => 'wait_list_registration',
355
-                'noheader'   => true,
356
-                'capability' => 'ee_edit_registration',
357
-                'obj_id'     => $reg_id,
358
-            ),
359
-            'wait_list_and_notify_registration'   => array(
360
-                'func'       => 'wait_list_registration',
361
-                'noheader'   => true,
362
-                'args'       => array(true),
363
-                'capability' => 'ee_edit_registration',
364
-                'obj_id'     => $reg_id,
365
-            ),
366
-            'contact_list'                        => array(
367
-                'func'       => '_attendee_contact_list_table',
368
-                'capability' => 'ee_read_contacts',
369
-            ),
370
-            'add_new_attendee'                    => array(
371
-                'func' => '_create_new_cpt_item',
372
-                'args' => array(
373
-                    'new_attendee' => true,
374
-                    'capability'   => 'ee_edit_contacts',
375
-                ),
376
-            ),
377
-            'edit_attendee'                       => array(
378
-                'func'       => '_edit_cpt_item',
379
-                'capability' => 'ee_edit_contacts',
380
-                'obj_id'     => $att_id,
381
-            ),
382
-            'duplicate_attendee'                  => array(
383
-                'func'       => '_duplicate_attendee',
384
-                'noheader'   => true,
385
-                'capability' => 'ee_edit_contacts',
386
-                'obj_id'     => $att_id,
387
-            ),
388
-            'insert_attendee'                     => array(
389
-                'func'       => '_insert_or_update_attendee',
390
-                'args'       => array(
391
-                    'new_attendee' => true,
392
-                ),
393
-                'noheader'   => true,
394
-                'capability' => 'ee_edit_contacts',
395
-            ),
396
-            'update_attendee'                     => array(
397
-                'func'       => '_insert_or_update_attendee',
398
-                'args'       => array(
399
-                    'new_attendee' => false,
400
-                ),
401
-                'noheader'   => true,
402
-                'capability' => 'ee_edit_contacts',
403
-                'obj_id'     => $att_id,
404
-            ),
405
-            'trash_attendees'                     => array(
406
-                'func'       => '_trash_or_restore_attendees',
407
-                'args'       => array(
408
-                    'trash' => 'true',
409
-                ),
410
-                'noheader'   => true,
411
-                'capability' => 'ee_delete_contacts',
412
-            ),
413
-            'trash_attendee'                      => array(
414
-                'func'       => '_trash_or_restore_attendees',
415
-                'args'       => array(
416
-                    'trash' => true,
417
-                ),
418
-                'noheader'   => true,
419
-                'capability' => 'ee_delete_contacts',
420
-                'obj_id'     => $att_id,
421
-            ),
422
-            'restore_attendees'                   => array(
423
-                'func'       => '_trash_or_restore_attendees',
424
-                'args'       => array(
425
-                    'trash' => false,
426
-                ),
427
-                'noheader'   => true,
428
-                'capability' => 'ee_delete_contacts',
429
-                'obj_id'     => $att_id,
430
-            ),
431
-            'resend_registration'                 => array(
432
-                'func'       => '_resend_registration',
433
-                'noheader'   => true,
434
-                'capability' => 'ee_send_message',
435
-            ),
436
-            'registrations_report'                => array(
437
-                'func'       => '_registrations_report',
438
-                'noheader'   => true,
439
-                'capability' => 'ee_read_registrations',
440
-            ),
441
-            'contact_list_export'                 => array(
442
-                'func'       => '_contact_list_export',
443
-                'noheader'   => true,
444
-                'capability' => 'export',
445
-            ),
446
-            'contact_list_report'                 => array(
447
-                'func'       => '_contact_list_report',
448
-                'noheader'   => true,
449
-                'capability' => 'ee_read_contacts',
450
-            ),
451
-        );
452
-    }
453
-
454
-
455
-    protected function _set_page_config()
456
-    {
457
-        $this->_page_config = array(
458
-            'default'           => array(
459
-                'nav'           => array(
460
-                    'label' => esc_html__('Overview', 'event_espresso'),
461
-                    'order' => 5,
462
-                ),
463
-                'help_tabs'     => array(
464
-                    'registrations_overview_help_tab'                       => array(
465
-                        'title'    => esc_html__('Registrations Overview', 'event_espresso'),
466
-                        'filename' => 'registrations_overview',
467
-                    ),
468
-                    'registrations_overview_table_column_headings_help_tab' => array(
469
-                        'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
470
-                        'filename' => 'registrations_overview_table_column_headings',
471
-                    ),
472
-                    'registrations_overview_filters_help_tab'               => array(
473
-                        'title'    => esc_html__('Registration Filters', 'event_espresso'),
474
-                        'filename' => 'registrations_overview_filters',
475
-                    ),
476
-                    'registrations_overview_views_help_tab'                 => array(
477
-                        'title'    => esc_html__('Registration Views', 'event_espresso'),
478
-                        'filename' => 'registrations_overview_views',
479
-                    ),
480
-                    'registrations_regoverview_other_help_tab'              => array(
481
-                        'title'    => esc_html__('Registrations Other', 'event_espresso'),
482
-                        'filename' => 'registrations_overview_other',
483
-                    ),
484
-                ),
485
-                'help_tour'     => array('Registration_Overview_Help_Tour'),
486
-                'qtips'         => array('Registration_List_Table_Tips'),
487
-                'list_table'    => 'EE_Registrations_List_Table',
488
-                'require_nonce' => false,
489
-            ),
490
-            'view_registration' => array(
491
-                'nav'           => array(
492
-                    'label'      => esc_html__('REG Details', 'event_espresso'),
493
-                    'order'      => 15,
494
-                    'url'        => isset($this->_req_data['_REG_ID'])
495
-                        ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
496
-                        : $this->_admin_base_url,
497
-                    'persistent' => false,
498
-                ),
499
-                'help_tabs'     => array(
500
-                    'registrations_details_help_tab'                    => array(
501
-                        'title'    => esc_html__('Registration Details', 'event_espresso'),
502
-                        'filename' => 'registrations_details',
503
-                    ),
504
-                    'registrations_details_table_help_tab'              => array(
505
-                        'title'    => esc_html__('Registration Details Table', 'event_espresso'),
506
-                        'filename' => 'registrations_details_table',
507
-                    ),
508
-                    'registrations_details_form_answers_help_tab'       => array(
509
-                        'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
510
-                        'filename' => 'registrations_details_form_answers',
511
-                    ),
512
-                    'registrations_details_registrant_details_help_tab' => array(
513
-                        'title'    => esc_html__('Contact Details', 'event_espresso'),
514
-                        'filename' => 'registrations_details_registrant_details',
515
-                    ),
516
-                ),
517
-                'help_tour'     => array('Registration_Details_Help_Tour'),
518
-                'metaboxes'     => array_merge(
519
-                    $this->_default_espresso_metaboxes,
520
-                    array('_registration_details_metaboxes')
521
-                ),
522
-                'require_nonce' => false,
523
-            ),
524
-            'new_registration'  => array(
525
-                'nav'           => array(
526
-                    'label'      => esc_html__('Add New Registration', 'event_espresso'),
527
-                    'url'        => '#',
528
-                    'order'      => 15,
529
-                    'persistent' => false,
530
-                ),
531
-                'metaboxes'     => $this->_default_espresso_metaboxes,
532
-                'labels'        => array(
533
-                    'publishbox' => esc_html__('Save Registration', 'event_espresso'),
534
-                ),
535
-                'require_nonce' => false,
536
-            ),
537
-            'add_new_attendee'  => array(
538
-                'nav'           => array(
539
-                    'label'      => esc_html__('Add Contact', 'event_espresso'),
540
-                    'order'      => 15,
541
-                    'persistent' => false,
542
-                ),
543
-                'metaboxes'     => array_merge(
544
-                    $this->_default_espresso_metaboxes,
545
-                    array('_publish_post_box', 'attendee_editor_metaboxes')
546
-                ),
547
-                'require_nonce' => false,
548
-            ),
549
-            'edit_attendee'     => array(
550
-                'nav'           => array(
551
-                    'label'      => esc_html__('Edit Contact', 'event_espresso'),
552
-                    'order'      => 15,
553
-                    'persistent' => false,
554
-                    'url'        => isset($this->_req_data['ATT_ID'])
555
-                        ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
556
-                        : $this->_admin_base_url,
557
-                ),
558
-                'metaboxes'     => array('attendee_editor_metaboxes'),
559
-                'require_nonce' => false,
560
-            ),
561
-            'contact_list'      => array(
562
-                'nav'           => array(
563
-                    'label' => esc_html__('Contact List', 'event_espresso'),
564
-                    'order' => 20,
565
-                ),
566
-                'list_table'    => 'EE_Attendee_Contact_List_Table',
567
-                'help_tabs'     => array(
568
-                    'registrations_contact_list_help_tab'                       => array(
569
-                        'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
570
-                        'filename' => 'registrations_contact_list',
571
-                    ),
572
-                    'registrations_contact-list_table_column_headings_help_tab' => array(
573
-                        'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
574
-                        'filename' => 'registrations_contact_list_table_column_headings',
575
-                    ),
576
-                    'registrations_contact_list_views_help_tab'                 => array(
577
-                        'title'    => esc_html__('Contact List Views', 'event_espresso'),
578
-                        'filename' => 'registrations_contact_list_views',
579
-                    ),
580
-                    'registrations_contact_list_other_help_tab'                 => array(
581
-                        'title'    => esc_html__('Contact List Other', 'event_espresso'),
582
-                        'filename' => 'registrations_contact_list_other',
583
-                    ),
584
-                ),
585
-                'help_tour'     => array('Contact_List_Help_Tour'),
586
-                'metaboxes'     => array(),
587
-                'require_nonce' => false,
588
-            ),
589
-            // override default cpt routes
590
-            'create_new'        => '',
591
-            'edit'              => '',
592
-        );
593
-    }
594
-
595
-
596
-    /**
597
-     * The below methods aren't used by this class currently
598
-     */
599
-    protected function _add_screen_options()
600
-    {
601
-    }
602
-
603
-
604
-    protected function _add_feature_pointers()
605
-    {
606
-    }
607
-
608
-
609
-    public function admin_init()
610
-    {
611
-        EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
612
-            'click "Update Registration Questions" to save your changes',
613
-            'event_espresso'
614
-        );
615
-    }
616
-
617
-
618
-    public function admin_notices()
619
-    {
620
-    }
621
-
622
-
623
-    public function admin_footer_scripts()
624
-    {
625
-    }
626
-
627
-
628
-    /**
629
-     *        get list of registration statuses
630
-     *
631
-     * @access private
632
-     * @return void
633
-     * @throws EE_Error
634
-     */
635
-    private function _get_registration_status_array()
636
-    {
637
-        self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
638
-    }
639
-
640
-
641
-    protected function _add_screen_options_default()
642
-    {
643
-        $this->_per_page_screen_option();
644
-    }
645
-
646
-
647
-    protected function _add_screen_options_contact_list()
648
-    {
649
-        $page_title = $this->_admin_page_title;
650
-        $this->_admin_page_title = esc_html__("Contacts", 'event_espresso');
651
-        $this->_per_page_screen_option();
652
-        $this->_admin_page_title = $page_title;
653
-    }
654
-
655
-
656
-    public function load_scripts_styles()
657
-    {
658
-        // style
659
-        wp_register_style(
660
-            'espresso_reg',
661
-            REG_ASSETS_URL . 'espresso_registrations_admin.css',
662
-            array('ee-admin-css'),
663
-            EVENT_ESPRESSO_VERSION
664
-        );
665
-        wp_enqueue_style('espresso_reg');
666
-        // script
667
-        wp_register_script(
668
-            'espresso_reg',
669
-            REG_ASSETS_URL . 'espresso_registrations_admin.js',
670
-            array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
671
-            EVENT_ESPRESSO_VERSION,
672
-            true
673
-        );
674
-        wp_enqueue_script('espresso_reg');
675
-    }
676
-
677
-
678
-    public function load_scripts_styles_edit_attendee()
679
-    {
680
-        // stuff to only show up on our attendee edit details page.
681
-        $attendee_details_translations = array(
682
-            'att_publish_text' => sprintf(
683
-                esc_html__('Created on: <b>%1$s</b>', 'event_espresso'),
684
-                $this->_cpt_model_obj->get_datetime('ATT_created')
685
-            ),
686
-        );
687
-        wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
688
-        wp_enqueue_script('jquery-validate');
689
-    }
690
-
691
-
692
-    public function load_scripts_styles_view_registration()
693
-    {
694
-        // styles
695
-        wp_enqueue_style('espresso-ui-theme');
696
-        // scripts
697
-        $this->_get_reg_custom_questions_form($this->_registration->ID());
698
-        $this->_reg_custom_questions_form->wp_enqueue_scripts(true);
699
-    }
700
-
701
-
702
-    public function load_scripts_styles_contact_list()
703
-    {
704
-        wp_dequeue_style('espresso_reg');
705
-        wp_register_style(
706
-            'espresso_att',
707
-            REG_ASSETS_URL . 'espresso_attendees_admin.css',
708
-            array('ee-admin-css'),
709
-            EVENT_ESPRESSO_VERSION
710
-        );
711
-        wp_enqueue_style('espresso_att');
712
-    }
713
-
714
-
715
-    public function load_scripts_styles_new_registration()
716
-    {
717
-        wp_register_script(
718
-            'ee-spco-for-admin',
719
-            REG_ASSETS_URL . 'spco_for_admin.js',
720
-            array('underscore', 'jquery'),
721
-            EVENT_ESPRESSO_VERSION,
722
-            true
723
-        );
724
-        wp_enqueue_script('ee-spco-for-admin');
725
-        add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
726
-        EE_Form_Section_Proper::wp_enqueue_scripts();
727
-        EED_Ticket_Selector::load_tckt_slctr_assets();
728
-        EE_Datepicker_Input::enqueue_styles_and_scripts();
729
-    }
730
-
731
-
732
-    public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
733
-    {
734
-        add_filter('FHEE_load_EE_messages', '__return_true');
735
-    }
736
-
737
-
738
-    public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
739
-    {
740
-        add_filter('FHEE_load_EE_messages', '__return_true');
741
-    }
742
-
743
-
744
-    protected function _set_list_table_views_default()
745
-    {
746
-        // for notification related bulk actions we need to make sure only active messengers have an option.
747
-        EED_Messages::set_autoloaders();
748
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
749
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
750
-        $active_mts = $message_resource_manager->list_of_active_message_types();
751
-        // key= bulk_action_slug, value= message type.
752
-        $match_array = array(
753
-            'approve_registrations'    => 'registration',
754
-            'decline_registrations'    => 'declined_registration',
755
-            'pending_registrations'    => 'pending_approval',
756
-            'no_approve_registrations' => 'not_approved_registration',
757
-            'cancel_registrations'     => 'cancelled_registration',
758
-        );
759
-        $can_send = EE_Registry::instance()->CAP->current_user_can(
760
-            'ee_send_message',
761
-            'batch_send_messages'
762
-        );
763
-        /** setup reg status bulk actions **/
764
-        $def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
765
-        if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
766
-            $def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
767
-                'Approve and Notify Registrations',
768
-                'event_espresso'
769
-            );
770
-        }
771
-        $def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
772
-        if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
773
-            $def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
774
-                'Decline and Notify Registrations',
775
-                'event_espresso'
776
-            );
777
-        }
778
-        $def_reg_status_actions['pending_registrations'] = esc_html__(
779
-            'Set Registrations to Pending Payment',
780
-            'event_espresso'
781
-        );
782
-        if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
783
-            $def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
784
-                'Set Registrations to Pending Payment and Notify',
785
-                'event_espresso'
786
-            );
787
-        }
788
-        $def_reg_status_actions['no_approve_registrations'] = esc_html__(
789
-            'Set Registrations to Not Approved',
790
-            'event_espresso'
791
-        );
792
-        if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
793
-            $def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
794
-                'Set Registrations to Not Approved and Notify',
795
-                'event_espresso'
796
-            );
797
-        }
798
-        $def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
799
-        if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
800
-            $def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
801
-                'Cancel Registrations and Notify',
802
-                'event_espresso'
803
-            );
804
-        }
805
-        $def_reg_status_actions = apply_filters(
806
-            'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
807
-            $def_reg_status_actions,
808
-            $active_mts,
809
-            $can_send
810
-        );
811
-
812
-        $this->_views = array(
813
-            'all'   => array(
814
-                'slug'        => 'all',
815
-                'label'       => esc_html__('View All Registrations', 'event_espresso'),
816
-                'count'       => 0,
817
-                'bulk_action' => array_merge(
818
-                    $def_reg_status_actions,
819
-                    array(
820
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
821
-                    )
822
-                ),
823
-            ),
824
-            'month' => array(
825
-                'slug'        => 'month',
826
-                'label'       => esc_html__('This Month', 'event_espresso'),
827
-                'count'       => 0,
828
-                'bulk_action' => array_merge(
829
-                    $def_reg_status_actions,
830
-                    array(
831
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
832
-                    )
833
-                ),
834
-            ),
835
-            'today' => array(
836
-                'slug'        => 'today',
837
-                'label'       => sprintf(
838
-                    esc_html__('Today - %s', 'event_espresso'),
839
-                    date('M d, Y', current_time('timestamp'))
840
-                ),
841
-                'count'       => 0,
842
-                'bulk_action' => array_merge(
843
-                    $def_reg_status_actions,
844
-                    array(
845
-                        'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
846
-                    )
847
-                ),
848
-            ),
849
-        );
850
-        if (EE_Registry::instance()->CAP->current_user_can(
851
-            'ee_delete_registrations',
852
-            'espresso_registrations_delete_registration'
853
-        )) {
854
-            $this->_views['incomplete'] = array(
855
-                'slug'        => 'incomplete',
856
-                'label'       => esc_html__('Incomplete', 'event_espresso'),
857
-                'count'       => 0,
858
-                'bulk_action' => array(
859
-                    'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
860
-                ),
861
-            );
862
-            $this->_views['trash'] = array(
863
-                'slug'        => 'trash',
864
-                'label'       => esc_html__('Trash', 'event_espresso'),
865
-                'count'       => 0,
866
-                'bulk_action' => array(
867
-                    'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
868
-                    'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
869
-                ),
870
-            );
871
-        }
872
-    }
873
-
874
-
875
-    protected function _set_list_table_views_contact_list()
876
-    {
877
-        $this->_views = array(
878
-            'in_use' => array(
879
-                'slug'        => 'in_use',
880
-                'label'       => esc_html__('In Use', 'event_espresso'),
881
-                'count'       => 0,
882
-                'bulk_action' => array(
883
-                    'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
884
-                ),
885
-            ),
886
-        );
887
-        if (EE_Registry::instance()->CAP->current_user_can(
888
-            'ee_delete_contacts',
889
-            'espresso_registrations_trash_attendees'
890
-        )
891
-        ) {
892
-            $this->_views['trash'] = array(
893
-                'slug'        => 'trash',
894
-                'label'       => esc_html__('Trash', 'event_espresso'),
895
-                'count'       => 0,
896
-                'bulk_action' => array(
897
-                    'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
898
-                ),
899
-            );
900
-        }
901
-    }
902
-
903
-
904
-    protected function _registration_legend_items()
905
-    {
906
-        $fc_items = array(
907
-            'star-icon'        => array(
908
-                'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
909
-                'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
910
-            ),
911
-            'view_details'     => array(
912
-                'class' => 'dashicons dashicons-clipboard',
913
-                'desc'  => esc_html__('View Registration Details', 'event_espresso'),
914
-            ),
915
-            'edit_attendee'    => array(
916
-                'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
917
-                'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
918
-            ),
919
-            'view_transaction' => array(
920
-                'class' => 'dashicons dashicons-cart',
921
-                'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
922
-            ),
923
-            'view_invoice'     => array(
924
-                'class' => 'dashicons dashicons-media-spreadsheet',
925
-                'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
926
-            ),
927
-        );
928
-        if (EE_Registry::instance()->CAP->current_user_can(
929
-            'ee_send_message',
930
-            'espresso_registrations_resend_registration'
931
-        )) {
932
-            $fc_items['resend_registration'] = array(
933
-                'class' => 'dashicons dashicons-email-alt',
934
-                'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
935
-            );
936
-        } else {
937
-            $fc_items['blank'] = array('class' => 'blank', 'desc' => '');
938
-        }
939
-        if (EE_Registry::instance()->CAP->current_user_can(
940
-            'ee_read_global_messages',
941
-            'view_filtered_messages'
942
-        )) {
943
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
944
-            if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
945
-                $fc_items['view_related_messages'] = array(
946
-                    'class' => $related_for_icon['css_class'],
947
-                    'desc'  => $related_for_icon['label'],
948
-                );
949
-            }
950
-        }
951
-        $sc_items = array(
952
-            'approved_status'   => array(
953
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
954
-                'desc'  => EEH_Template::pretty_status(
955
-                    EEM_Registration::status_id_approved,
956
-                    false,
957
-                    'sentence'
958
-                ),
959
-            ),
960
-            'pending_status'    => array(
961
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
962
-                'desc'  => EEH_Template::pretty_status(
963
-                    EEM_Registration::status_id_pending_payment,
964
-                    false,
965
-                    'sentence'
966
-                ),
967
-            ),
968
-            'wait_list'         => array(
969
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
970
-                'desc'  => EEH_Template::pretty_status(
971
-                    EEM_Registration::status_id_wait_list,
972
-                    false,
973
-                    'sentence'
974
-                ),
975
-            ),
976
-            'incomplete_status' => array(
977
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
978
-                'desc'  => EEH_Template::pretty_status(
979
-                    EEM_Registration::status_id_incomplete,
980
-                    false,
981
-                    'sentence'
982
-                ),
983
-            ),
984
-            'not_approved'      => array(
985
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
986
-                'desc'  => EEH_Template::pretty_status(
987
-                    EEM_Registration::status_id_not_approved,
988
-                    false,
989
-                    'sentence'
990
-                ),
991
-            ),
992
-            'declined_status'   => array(
993
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
994
-                'desc'  => EEH_Template::pretty_status(
995
-                    EEM_Registration::status_id_declined,
996
-                    false,
997
-                    'sentence'
998
-                ),
999
-            ),
1000
-            'cancelled_status'  => array(
1001
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1002
-                'desc'  => EEH_Template::pretty_status(
1003
-                    EEM_Registration::status_id_cancelled,
1004
-                    false,
1005
-                    'sentence'
1006
-                ),
1007
-            ),
1008
-        );
1009
-        return array_merge($fc_items, $sc_items);
1010
-    }
1011
-
1012
-
1013
-
1014
-    /***************************************        REGISTRATION OVERVIEW        **************************************/
1015
-    /**
1016
-     * @throws \EE_Error
1017
-     */
1018
-    protected function _registrations_overview_list_table()
1019
-    {
1020
-        $this->_template_args['admin_page_header'] = '';
1021
-        $EVT_ID = ! empty($this->_req_data['event_id'])
1022
-            ? absint($this->_req_data['event_id'])
1023
-            : 0;
1024
-        $ATT_ID = ! empty($this->_req_data['ATT_ID'])
1025
-            ? absint($this->_req_data['ATT_ID'])
1026
-            : 0;
1027
-        if ($ATT_ID) {
1028
-            $attendee = EEM_Attendee::instance()->get_one_by_ID($ATT_ID);
1029
-            if ($attendee instanceof EE_Attendee) {
1030
-                $this->_template_args['admin_page_header'] = sprintf(
1031
-                    esc_html__(
1032
-                        '%1$s Viewing registrations for %2$s%3$s',
1033
-                        'event_espresso'
1034
-                    ),
1035
-                    '<h3 style="line-height:1.5em;">',
1036
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
1037
-                        array(
1038
-                            'action' => 'edit_attendee',
1039
-                            'post'   => $ATT_ID,
1040
-                        ),
1041
-                        REG_ADMIN_URL
1042
-                    ) . '">' . $attendee->full_name() . '</a>',
1043
-                    '</h3>'
1044
-                );
1045
-            }
1046
-        }
1047
-        if ($EVT_ID) {
1048
-            if (EE_Registry::instance()->CAP->current_user_can(
1049
-                'ee_edit_registrations',
1050
-                'espresso_registrations_new_registration',
1051
-                $EVT_ID
1052
-            )) {
1053
-                $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1054
-                    'new_registration',
1055
-                    'add-registrant',
1056
-                    array('event_id' => $EVT_ID),
1057
-                    'add-new-h2'
1058
-                );
1059
-            }
1060
-            $event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1061
-            if ($event instanceof EE_Event) {
1062
-                $this->_template_args['admin_page_header'] = sprintf(
1063
-                    esc_html__(
1064
-                        '%s Viewing registrations for the event: %s%s',
1065
-                        'event_espresso'
1066
-                    ),
1067
-                    '<h3 style="line-height:1.5em;">',
1068
-                    '<br /><a href="'
1069
-                    . EE_Admin_Page::add_query_args_and_nonce(
1070
-                        array(
1071
-                            'action' => 'edit',
1072
-                            'post'   => $event->ID(),
1073
-                        ),
1074
-                        EVENTS_ADMIN_URL
1075
-                    )
1076
-                    . '">&nbsp;'
1077
-                    . $event->get('EVT_name')
1078
-                    . '&nbsp;</a>&nbsp;',
1079
-                    '</h3>'
1080
-                );
1081
-            }
1082
-            $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
1083
-            $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1084
-            if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
1085
-                $this->_template_args['admin_page_header'] = substr(
1086
-                    $this->_template_args['admin_page_header'],
1087
-                    0,
1088
-                    -5
1089
-                );
1090
-                $this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
1091
-                $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
1092
-                $this->_template_args['admin_page_header'] .= $datetime->name();
1093
-                $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
1094
-                $this->_template_args['admin_page_header'] .= '</span></h3>';
1095
-            }
1096
-        }
1097
-        $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1098
-        $this->display_admin_list_table_page_with_no_sidebar();
1099
-    }
1100
-
1101
-
1102
-    /**
1103
-     * This sets the _registration property for the registration details screen
1104
-     *
1105
-     * @access private
1106
-     * @return bool
1107
-     * @throws EE_Error
1108
-     * @throws InvalidArgumentException
1109
-     * @throws InvalidDataTypeException
1110
-     * @throws InvalidInterfaceException
1111
-     */
1112
-    private function _set_registration_object()
1113
-    {
1114
-        // get out if we've already set the object
1115
-        if ($this->_registration instanceof EE_Registration) {
1116
-            return true;
1117
-        }
1118
-        $REG = EEM_Registration::instance();
1119
-        $REG_ID = (! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1120
-        if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
1121
-            return true;
1122
-        } else {
1123
-            $error_msg = sprintf(
1124
-                esc_html__(
1125
-                    'An error occurred and the details for Registration ID #%s could not be retrieved.',
1126
-                    'event_espresso'
1127
-                ),
1128
-                $REG_ID
1129
-            );
1130
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1131
-            $this->_registration = null;
1132
-            return false;
1133
-        }
1134
-    }
1135
-
1136
-
1137
-    /**
1138
-     * Used to retrieve registrations for the list table.
1139
-     *
1140
-     * @param int  $per_page
1141
-     * @param bool $count
1142
-     * @param bool $this_month
1143
-     * @param bool $today
1144
-     * @return EE_Registration[]|int
1145
-     * @throws EE_Error
1146
-     * @throws InvalidArgumentException
1147
-     * @throws InvalidDataTypeException
1148
-     * @throws InvalidInterfaceException
1149
-     */
1150
-    public function get_registrations(
1151
-        $per_page = 10,
1152
-        $count = false,
1153
-        $this_month = false,
1154
-        $today = false
1155
-    ) {
1156
-        if ($this_month) {
1157
-            $this->_req_data['status'] = 'month';
1158
-        }
1159
-        if ($today) {
1160
-            $this->_req_data['status'] = 'today';
1161
-        }
1162
-        $query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count);
1163
-        /**
1164
-         * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1165
-         *
1166
-         * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1167
-         * @see  EEM_Base::get_all()
1168
-         */
1169
-        $query_params['group_by'] = '';
1170
-
1171
-        return $count
1172
-            ? EEM_Registration::instance()->count($query_params)
1173
-            /** @type EE_Registration[] */
1174
-            : EEM_Registration::instance()->get_all($query_params);
1175
-    }
1176
-
1177
-
1178
-    /**
1179
-     * Retrieves the query parameters to be used by the Registration model for getting registrations.
1180
-     * Note: this listens to values on the request for some of the query parameters.
1181
-     *
1182
-     * @param array $request
1183
-     * @param int   $per_page
1184
-     * @param bool  $count
1185
-     * @return array
1186
-     * @throws EE_Error
1187
-     */
1188
-    protected function _get_registration_query_parameters(
1189
-        $request = array(),
1190
-        $per_page = 10,
1191
-        $count = false
1192
-    ) {
1193
-
1194
-        $query_params = array(
1195
-            0                          => $this->_get_where_conditions_for_registrations_query(
1196
-                $request
1197
-            ),
1198
-            'caps'                     => EEM_Registration::caps_read_admin,
1199
-            'default_where_conditions' => 'this_model_only',
1200
-        );
1201
-        if (! $count) {
1202
-            $query_params = array_merge(
1203
-                $query_params,
1204
-                $this->_get_orderby_for_registrations_query(),
1205
-                $this->_get_limit($per_page)
1206
-            );
1207
-        }
1208
-
1209
-        return $query_params;
1210
-    }
1211
-
1212
-
1213
-    /**
1214
-     * This will add ATT_ID to the provided $where array for EE model query parameters.
1215
-     *
1216
-     * @param array $request usually the same as $this->_req_data but not necessarily
1217
-     * @return array
1218
-     */
1219
-    protected function addAttendeeIdToWhereConditions(array $request)
1220
-    {
1221
-        $where = array();
1222
-        if (! empty($request['ATT_ID'])) {
1223
-            $where['ATT_ID'] = absint($request['ATT_ID']);
1224
-        }
1225
-        return $where;
1226
-    }
1227
-
1228
-
1229
-    /**
1230
-     * This will add EVT_ID to the provided $where array for EE model query parameters.
1231
-     *
1232
-     * @param array $request usually the same as $this->_req_data but not necessarily
1233
-     * @return array
1234
-     */
1235
-    protected function _add_event_id_to_where_conditions(array $request)
1236
-    {
1237
-        $where = array();
1238
-        if (! empty($request['event_id'])) {
1239
-            $where['EVT_ID'] = absint($request['event_id']);
1240
-        }
1241
-        return $where;
1242
-    }
1243
-
1244
-
1245
-    /**
1246
-     * Adds category ID if it exists in the request to the where conditions for the registrations query.
1247
-     *
1248
-     * @param array $request usually the same as $this->_req_data but not necessarily
1249
-     * @return array
1250
-     */
1251
-    protected function _add_category_id_to_where_conditions(array $request)
1252
-    {
1253
-        $where = array();
1254
-        if (! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) {
1255
-            $where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']);
1256
-        }
1257
-        return $where;
1258
-    }
1259
-
1260
-
1261
-    /**
1262
-     * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
1263
-     *
1264
-     * @param array $request usually the same as $this->_req_data but not necessarily
1265
-     * @return array
1266
-     */
1267
-    protected function _add_datetime_id_to_where_conditions(array $request)
1268
-    {
1269
-        $where = array();
1270
-        if (! empty($request['datetime_id'])) {
1271
-            $where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']);
1272
-        }
1273
-        if (! empty($request['DTT_ID'])) {
1274
-            $where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']);
1275
-        }
1276
-        return $where;
1277
-    }
1278
-
1279
-
1280
-    /**
1281
-     * Adds the correct registration status to the where conditions for the registrations query.
1282
-     *
1283
-     * @param array $request usually the same as $this->_req_data but not necessarily
1284
-     * @return array
1285
-     */
1286
-    protected function _add_registration_status_to_where_conditions(array $request)
1287
-    {
1288
-        $where = array();
1289
-        $view = EEH_Array::is_set($request, 'status', '');
1290
-        $registration_status = ! empty($request['_reg_status'])
1291
-            ? sanitize_text_field($request['_reg_status'])
1292
-            : '';
1293
-
1294
-        /*
22
+	/**
23
+	 * @var EE_Registration
24
+	 */
25
+	private $_registration;
26
+
27
+	/**
28
+	 * @var EE_Event
29
+	 */
30
+	private $_reg_event;
31
+
32
+	/**
33
+	 * @var EE_Session
34
+	 */
35
+	private $_session;
36
+
37
+	private static $_reg_status;
38
+
39
+	/**
40
+	 * Form for displaying the custom questions for this registration.
41
+	 * This gets used a few times throughout the request so its best to cache it
42
+	 *
43
+	 * @var EE_Registration_Custom_Questions_Form
44
+	 */
45
+	protected $_reg_custom_questions_form = null;
46
+
47
+
48
+	/**
49
+	 *        constructor
50
+	 *
51
+	 * @Constructor
52
+	 * @access public
53
+	 * @param bool $routing
54
+	 * @return Registrations_Admin_Page
55
+	 */
56
+	public function __construct($routing = true)
57
+	{
58
+		parent::__construct($routing);
59
+		add_action('wp_loaded', array($this, 'wp_loaded'));
60
+	}
61
+
62
+
63
+	public function wp_loaded()
64
+	{
65
+		// when adding a new registration...
66
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'new_registration') {
67
+			EE_System::do_not_cache();
68
+			if (! isset($this->_req_data['processing_registration'])
69
+				|| absint($this->_req_data['processing_registration']) !== 1
70
+			) {
71
+				// and it's NOT the attendee information reg step
72
+				// force cookie expiration by setting time to last week
73
+				setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/');
74
+				// and update the global
75
+				$_COOKIE['ee_registration_added'] = 0;
76
+			}
77
+		}
78
+	}
79
+
80
+
81
+	protected function _init_page_props()
82
+	{
83
+		$this->page_slug = REG_PG_SLUG;
84
+		$this->_admin_base_url = REG_ADMIN_URL;
85
+		$this->_admin_base_path = REG_ADMIN;
86
+		$this->page_label = esc_html__('Registrations', 'event_espresso');
87
+		$this->_cpt_routes = array(
88
+			'add_new_attendee' => 'espresso_attendees',
89
+			'edit_attendee'    => 'espresso_attendees',
90
+			'insert_attendee'  => 'espresso_attendees',
91
+			'update_attendee'  => 'espresso_attendees',
92
+		);
93
+		$this->_cpt_model_names = array(
94
+			'add_new_attendee' => 'EEM_Attendee',
95
+			'edit_attendee'    => 'EEM_Attendee',
96
+		);
97
+		$this->_cpt_edit_routes = array(
98
+			'espresso_attendees' => 'edit_attendee',
99
+		);
100
+		$this->_pagenow_map = array(
101
+			'add_new_attendee' => 'post-new.php',
102
+			'edit_attendee'    => 'post.php',
103
+			'trash'            => 'post.php',
104
+		);
105
+		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
106
+		// add filters so that the comment urls don't take users to a confusing 404 page
107
+		add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
108
+	}
109
+
110
+
111
+	public function clear_comment_link($link, $comment, $args)
112
+	{
113
+		// gotta make sure this only happens on this route
114
+		$post_type = get_post_type($comment->comment_post_ID);
115
+		if ($post_type === 'espresso_attendees') {
116
+			return '#commentsdiv';
117
+		}
118
+		return $link;
119
+	}
120
+
121
+
122
+	protected function _ajax_hooks()
123
+	{
124
+		// todo: all hooks for registrations ajax goes in here
125
+		add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
126
+	}
127
+
128
+
129
+	protected function _define_page_props()
130
+	{
131
+		$this->_admin_page_title = $this->page_label;
132
+		$this->_labels = array(
133
+			'buttons'                      => array(
134
+				'add-registrant'      => esc_html__('Add New Registration', 'event_espresso'),
135
+				'add-attendee'        => esc_html__('Add Contact', 'event_espresso'),
136
+				'edit'                => esc_html__('Edit Contact', 'event_espresso'),
137
+				'report'              => esc_html__("Event Registrations CSV Report", "event_espresso"),
138
+				'report_all'          => esc_html__('All Registrations CSV Report', 'event_espresso'),
139
+				'report_filtered'     => esc_html__('Filtered CSV Report', 'event_espresso'),
140
+				'contact_list_report' => esc_html__('Contact List Report', 'event_espresso'),
141
+				'contact_list_export' => esc_html__("Export Data", "event_espresso"),
142
+			),
143
+			'publishbox'                   => array(
144
+				'add_new_attendee' => esc_html__("Add Contact Record", 'event_espresso'),
145
+				'edit_attendee'    => esc_html__("Update Contact Record", 'event_espresso'),
146
+			),
147
+			'hide_add_button_on_cpt_route' => array(
148
+				'edit_attendee' => true,
149
+			),
150
+		);
151
+	}
152
+
153
+
154
+	/**
155
+	 *        grab url requests and route them
156
+	 *
157
+	 * @access private
158
+	 * @return void
159
+	 */
160
+	public function _set_page_routes()
161
+	{
162
+		$this->_get_registration_status_array();
163
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID'])
164
+			? $this->_req_data['_REG_ID'] : 0;
165
+		$reg_id = empty($reg_id) && ! empty($this->_req_data['reg_status_change_form']['REG_ID'])
166
+			? $this->_req_data['reg_status_change_form']['REG_ID']
167
+			: $reg_id;
168
+		$att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID'])
169
+			? $this->_req_data['ATT_ID'] : 0;
170
+		$att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post'])
171
+			? $this->_req_data['post']
172
+			: $att_id;
173
+		$this->_page_routes = array(
174
+			'default'                             => array(
175
+				'func'       => '_registrations_overview_list_table',
176
+				'capability' => 'ee_read_registrations',
177
+			),
178
+			'view_registration'                   => array(
179
+				'func'       => '_registration_details',
180
+				'capability' => 'ee_read_registration',
181
+				'obj_id'     => $reg_id,
182
+			),
183
+			'edit_registration'                   => array(
184
+				'func'               => '_update_attendee_registration_form',
185
+				'noheader'           => true,
186
+				'headers_sent_route' => 'view_registration',
187
+				'capability'         => 'ee_edit_registration',
188
+				'obj_id'             => $reg_id,
189
+				'_REG_ID'            => $reg_id,
190
+			),
191
+			'trash_registrations'                 => array(
192
+				'func'       => '_trash_or_restore_registrations',
193
+				'args'       => array('trash' => true),
194
+				'noheader'   => true,
195
+				'capability' => 'ee_delete_registrations',
196
+			),
197
+			'restore_registrations'               => array(
198
+				'func'       => '_trash_or_restore_registrations',
199
+				'args'       => array('trash' => false),
200
+				'noheader'   => true,
201
+				'capability' => 'ee_delete_registrations',
202
+			),
203
+			'delete_registrations'                => array(
204
+				'func'       => '_delete_registrations',
205
+				'noheader'   => true,
206
+				'capability' => 'ee_delete_registrations',
207
+			),
208
+			'new_registration'                    => array(
209
+				'func'       => 'new_registration',
210
+				'capability' => 'ee_edit_registrations',
211
+			),
212
+			'process_reg_step'                    => array(
213
+				'func'       => 'process_reg_step',
214
+				'noheader'   => true,
215
+				'capability' => 'ee_edit_registrations',
216
+			),
217
+			'redirect_to_txn'                     => array(
218
+				'func'       => 'redirect_to_txn',
219
+				'noheader'   => true,
220
+				'capability' => 'ee_edit_registrations',
221
+			),
222
+			'change_reg_status'                   => array(
223
+				'func'       => '_change_reg_status',
224
+				'noheader'   => true,
225
+				'capability' => 'ee_edit_registration',
226
+				'obj_id'     => $reg_id,
227
+			),
228
+			'approve_registration'                => array(
229
+				'func'       => 'approve_registration',
230
+				'noheader'   => true,
231
+				'capability' => 'ee_edit_registration',
232
+				'obj_id'     => $reg_id,
233
+			),
234
+			'approve_and_notify_registration'     => array(
235
+				'func'       => 'approve_registration',
236
+				'noheader'   => true,
237
+				'args'       => array(true),
238
+				'capability' => 'ee_edit_registration',
239
+				'obj_id'     => $reg_id,
240
+			),
241
+			'approve_registrations'               => array(
242
+				'func'       => 'bulk_action_on_registrations',
243
+				'noheader'   => true,
244
+				'capability' => 'ee_edit_registrations',
245
+				'args'       => array('approve'),
246
+			),
247
+			'approve_and_notify_registrations'    => array(
248
+				'func'       => 'bulk_action_on_registrations',
249
+				'noheader'   => true,
250
+				'capability' => 'ee_edit_registrations',
251
+				'args'       => array('approve', true),
252
+			),
253
+			'decline_registration'                => array(
254
+				'func'       => 'decline_registration',
255
+				'noheader'   => true,
256
+				'capability' => 'ee_edit_registration',
257
+				'obj_id'     => $reg_id,
258
+			),
259
+			'decline_and_notify_registration'     => array(
260
+				'func'       => 'decline_registration',
261
+				'noheader'   => true,
262
+				'args'       => array(true),
263
+				'capability' => 'ee_edit_registration',
264
+				'obj_id'     => $reg_id,
265
+			),
266
+			'decline_registrations'               => array(
267
+				'func'       => 'bulk_action_on_registrations',
268
+				'noheader'   => true,
269
+				'capability' => 'ee_edit_registrations',
270
+				'args'       => array('decline'),
271
+			),
272
+			'decline_and_notify_registrations'    => array(
273
+				'func'       => 'bulk_action_on_registrations',
274
+				'noheader'   => true,
275
+				'capability' => 'ee_edit_registrations',
276
+				'args'       => array('decline', true),
277
+			),
278
+			'pending_registration'                => array(
279
+				'func'       => 'pending_registration',
280
+				'noheader'   => true,
281
+				'capability' => 'ee_edit_registration',
282
+				'obj_id'     => $reg_id,
283
+			),
284
+			'pending_and_notify_registration'     => array(
285
+				'func'       => 'pending_registration',
286
+				'noheader'   => true,
287
+				'args'       => array(true),
288
+				'capability' => 'ee_edit_registration',
289
+				'obj_id'     => $reg_id,
290
+			),
291
+			'pending_registrations'               => array(
292
+				'func'       => 'bulk_action_on_registrations',
293
+				'noheader'   => true,
294
+				'capability' => 'ee_edit_registrations',
295
+				'args'       => array('pending'),
296
+			),
297
+			'pending_and_notify_registrations'    => array(
298
+				'func'       => 'bulk_action_on_registrations',
299
+				'noheader'   => true,
300
+				'capability' => 'ee_edit_registrations',
301
+				'args'       => array('pending', true),
302
+			),
303
+			'no_approve_registration'             => array(
304
+				'func'       => 'not_approve_registration',
305
+				'noheader'   => true,
306
+				'capability' => 'ee_edit_registration',
307
+				'obj_id'     => $reg_id,
308
+			),
309
+			'no_approve_and_notify_registration'  => array(
310
+				'func'       => 'not_approve_registration',
311
+				'noheader'   => true,
312
+				'args'       => array(true),
313
+				'capability' => 'ee_edit_registration',
314
+				'obj_id'     => $reg_id,
315
+			),
316
+			'no_approve_registrations'            => array(
317
+				'func'       => 'bulk_action_on_registrations',
318
+				'noheader'   => true,
319
+				'capability' => 'ee_edit_registrations',
320
+				'args'       => array('not_approve'),
321
+			),
322
+			'no_approve_and_notify_registrations' => array(
323
+				'func'       => 'bulk_action_on_registrations',
324
+				'noheader'   => true,
325
+				'capability' => 'ee_edit_registrations',
326
+				'args'       => array('not_approve', true),
327
+			),
328
+			'cancel_registration'                 => array(
329
+				'func'       => 'cancel_registration',
330
+				'noheader'   => true,
331
+				'capability' => 'ee_edit_registration',
332
+				'obj_id'     => $reg_id,
333
+			),
334
+			'cancel_and_notify_registration'      => array(
335
+				'func'       => 'cancel_registration',
336
+				'noheader'   => true,
337
+				'args'       => array(true),
338
+				'capability' => 'ee_edit_registration',
339
+				'obj_id'     => $reg_id,
340
+			),
341
+			'cancel_registrations'                => array(
342
+				'func'       => 'bulk_action_on_registrations',
343
+				'noheader'   => true,
344
+				'capability' => 'ee_edit_registrations',
345
+				'args'       => array('cancel'),
346
+			),
347
+			'cancel_and_notify_registrations'     => array(
348
+				'func'       => 'bulk_action_on_registrations',
349
+				'noheader'   => true,
350
+				'capability' => 'ee_edit_registrations',
351
+				'args'       => array('cancel', true),
352
+			),
353
+			'wait_list_registration'              => array(
354
+				'func'       => 'wait_list_registration',
355
+				'noheader'   => true,
356
+				'capability' => 'ee_edit_registration',
357
+				'obj_id'     => $reg_id,
358
+			),
359
+			'wait_list_and_notify_registration'   => array(
360
+				'func'       => 'wait_list_registration',
361
+				'noheader'   => true,
362
+				'args'       => array(true),
363
+				'capability' => 'ee_edit_registration',
364
+				'obj_id'     => $reg_id,
365
+			),
366
+			'contact_list'                        => array(
367
+				'func'       => '_attendee_contact_list_table',
368
+				'capability' => 'ee_read_contacts',
369
+			),
370
+			'add_new_attendee'                    => array(
371
+				'func' => '_create_new_cpt_item',
372
+				'args' => array(
373
+					'new_attendee' => true,
374
+					'capability'   => 'ee_edit_contacts',
375
+				),
376
+			),
377
+			'edit_attendee'                       => array(
378
+				'func'       => '_edit_cpt_item',
379
+				'capability' => 'ee_edit_contacts',
380
+				'obj_id'     => $att_id,
381
+			),
382
+			'duplicate_attendee'                  => array(
383
+				'func'       => '_duplicate_attendee',
384
+				'noheader'   => true,
385
+				'capability' => 'ee_edit_contacts',
386
+				'obj_id'     => $att_id,
387
+			),
388
+			'insert_attendee'                     => array(
389
+				'func'       => '_insert_or_update_attendee',
390
+				'args'       => array(
391
+					'new_attendee' => true,
392
+				),
393
+				'noheader'   => true,
394
+				'capability' => 'ee_edit_contacts',
395
+			),
396
+			'update_attendee'                     => array(
397
+				'func'       => '_insert_or_update_attendee',
398
+				'args'       => array(
399
+					'new_attendee' => false,
400
+				),
401
+				'noheader'   => true,
402
+				'capability' => 'ee_edit_contacts',
403
+				'obj_id'     => $att_id,
404
+			),
405
+			'trash_attendees'                     => array(
406
+				'func'       => '_trash_or_restore_attendees',
407
+				'args'       => array(
408
+					'trash' => 'true',
409
+				),
410
+				'noheader'   => true,
411
+				'capability' => 'ee_delete_contacts',
412
+			),
413
+			'trash_attendee'                      => array(
414
+				'func'       => '_trash_or_restore_attendees',
415
+				'args'       => array(
416
+					'trash' => true,
417
+				),
418
+				'noheader'   => true,
419
+				'capability' => 'ee_delete_contacts',
420
+				'obj_id'     => $att_id,
421
+			),
422
+			'restore_attendees'                   => array(
423
+				'func'       => '_trash_or_restore_attendees',
424
+				'args'       => array(
425
+					'trash' => false,
426
+				),
427
+				'noheader'   => true,
428
+				'capability' => 'ee_delete_contacts',
429
+				'obj_id'     => $att_id,
430
+			),
431
+			'resend_registration'                 => array(
432
+				'func'       => '_resend_registration',
433
+				'noheader'   => true,
434
+				'capability' => 'ee_send_message',
435
+			),
436
+			'registrations_report'                => array(
437
+				'func'       => '_registrations_report',
438
+				'noheader'   => true,
439
+				'capability' => 'ee_read_registrations',
440
+			),
441
+			'contact_list_export'                 => array(
442
+				'func'       => '_contact_list_export',
443
+				'noheader'   => true,
444
+				'capability' => 'export',
445
+			),
446
+			'contact_list_report'                 => array(
447
+				'func'       => '_contact_list_report',
448
+				'noheader'   => true,
449
+				'capability' => 'ee_read_contacts',
450
+			),
451
+		);
452
+	}
453
+
454
+
455
+	protected function _set_page_config()
456
+	{
457
+		$this->_page_config = array(
458
+			'default'           => array(
459
+				'nav'           => array(
460
+					'label' => esc_html__('Overview', 'event_espresso'),
461
+					'order' => 5,
462
+				),
463
+				'help_tabs'     => array(
464
+					'registrations_overview_help_tab'                       => array(
465
+						'title'    => esc_html__('Registrations Overview', 'event_espresso'),
466
+						'filename' => 'registrations_overview',
467
+					),
468
+					'registrations_overview_table_column_headings_help_tab' => array(
469
+						'title'    => esc_html__('Registrations Table Column Headings', 'event_espresso'),
470
+						'filename' => 'registrations_overview_table_column_headings',
471
+					),
472
+					'registrations_overview_filters_help_tab'               => array(
473
+						'title'    => esc_html__('Registration Filters', 'event_espresso'),
474
+						'filename' => 'registrations_overview_filters',
475
+					),
476
+					'registrations_overview_views_help_tab'                 => array(
477
+						'title'    => esc_html__('Registration Views', 'event_espresso'),
478
+						'filename' => 'registrations_overview_views',
479
+					),
480
+					'registrations_regoverview_other_help_tab'              => array(
481
+						'title'    => esc_html__('Registrations Other', 'event_espresso'),
482
+						'filename' => 'registrations_overview_other',
483
+					),
484
+				),
485
+				'help_tour'     => array('Registration_Overview_Help_Tour'),
486
+				'qtips'         => array('Registration_List_Table_Tips'),
487
+				'list_table'    => 'EE_Registrations_List_Table',
488
+				'require_nonce' => false,
489
+			),
490
+			'view_registration' => array(
491
+				'nav'           => array(
492
+					'label'      => esc_html__('REG Details', 'event_espresso'),
493
+					'order'      => 15,
494
+					'url'        => isset($this->_req_data['_REG_ID'])
495
+						? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url)
496
+						: $this->_admin_base_url,
497
+					'persistent' => false,
498
+				),
499
+				'help_tabs'     => array(
500
+					'registrations_details_help_tab'                    => array(
501
+						'title'    => esc_html__('Registration Details', 'event_espresso'),
502
+						'filename' => 'registrations_details',
503
+					),
504
+					'registrations_details_table_help_tab'              => array(
505
+						'title'    => esc_html__('Registration Details Table', 'event_espresso'),
506
+						'filename' => 'registrations_details_table',
507
+					),
508
+					'registrations_details_form_answers_help_tab'       => array(
509
+						'title'    => esc_html__('Registration Form Answers', 'event_espresso'),
510
+						'filename' => 'registrations_details_form_answers',
511
+					),
512
+					'registrations_details_registrant_details_help_tab' => array(
513
+						'title'    => esc_html__('Contact Details', 'event_espresso'),
514
+						'filename' => 'registrations_details_registrant_details',
515
+					),
516
+				),
517
+				'help_tour'     => array('Registration_Details_Help_Tour'),
518
+				'metaboxes'     => array_merge(
519
+					$this->_default_espresso_metaboxes,
520
+					array('_registration_details_metaboxes')
521
+				),
522
+				'require_nonce' => false,
523
+			),
524
+			'new_registration'  => array(
525
+				'nav'           => array(
526
+					'label'      => esc_html__('Add New Registration', 'event_espresso'),
527
+					'url'        => '#',
528
+					'order'      => 15,
529
+					'persistent' => false,
530
+				),
531
+				'metaboxes'     => $this->_default_espresso_metaboxes,
532
+				'labels'        => array(
533
+					'publishbox' => esc_html__('Save Registration', 'event_espresso'),
534
+				),
535
+				'require_nonce' => false,
536
+			),
537
+			'add_new_attendee'  => array(
538
+				'nav'           => array(
539
+					'label'      => esc_html__('Add Contact', 'event_espresso'),
540
+					'order'      => 15,
541
+					'persistent' => false,
542
+				),
543
+				'metaboxes'     => array_merge(
544
+					$this->_default_espresso_metaboxes,
545
+					array('_publish_post_box', 'attendee_editor_metaboxes')
546
+				),
547
+				'require_nonce' => false,
548
+			),
549
+			'edit_attendee'     => array(
550
+				'nav'           => array(
551
+					'label'      => esc_html__('Edit Contact', 'event_espresso'),
552
+					'order'      => 15,
553
+					'persistent' => false,
554
+					'url'        => isset($this->_req_data['ATT_ID'])
555
+						? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url)
556
+						: $this->_admin_base_url,
557
+				),
558
+				'metaboxes'     => array('attendee_editor_metaboxes'),
559
+				'require_nonce' => false,
560
+			),
561
+			'contact_list'      => array(
562
+				'nav'           => array(
563
+					'label' => esc_html__('Contact List', 'event_espresso'),
564
+					'order' => 20,
565
+				),
566
+				'list_table'    => 'EE_Attendee_Contact_List_Table',
567
+				'help_tabs'     => array(
568
+					'registrations_contact_list_help_tab'                       => array(
569
+						'title'    => esc_html__('Registrations Contact List', 'event_espresso'),
570
+						'filename' => 'registrations_contact_list',
571
+					),
572
+					'registrations_contact-list_table_column_headings_help_tab' => array(
573
+						'title'    => esc_html__('Contact List Table Column Headings', 'event_espresso'),
574
+						'filename' => 'registrations_contact_list_table_column_headings',
575
+					),
576
+					'registrations_contact_list_views_help_tab'                 => array(
577
+						'title'    => esc_html__('Contact List Views', 'event_espresso'),
578
+						'filename' => 'registrations_contact_list_views',
579
+					),
580
+					'registrations_contact_list_other_help_tab'                 => array(
581
+						'title'    => esc_html__('Contact List Other', 'event_espresso'),
582
+						'filename' => 'registrations_contact_list_other',
583
+					),
584
+				),
585
+				'help_tour'     => array('Contact_List_Help_Tour'),
586
+				'metaboxes'     => array(),
587
+				'require_nonce' => false,
588
+			),
589
+			// override default cpt routes
590
+			'create_new'        => '',
591
+			'edit'              => '',
592
+		);
593
+	}
594
+
595
+
596
+	/**
597
+	 * The below methods aren't used by this class currently
598
+	 */
599
+	protected function _add_screen_options()
600
+	{
601
+	}
602
+
603
+
604
+	protected function _add_feature_pointers()
605
+	{
606
+	}
607
+
608
+
609
+	public function admin_init()
610
+	{
611
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = esc_html__(
612
+			'click "Update Registration Questions" to save your changes',
613
+			'event_espresso'
614
+		);
615
+	}
616
+
617
+
618
+	public function admin_notices()
619
+	{
620
+	}
621
+
622
+
623
+	public function admin_footer_scripts()
624
+	{
625
+	}
626
+
627
+
628
+	/**
629
+	 *        get list of registration statuses
630
+	 *
631
+	 * @access private
632
+	 * @return void
633
+	 * @throws EE_Error
634
+	 */
635
+	private function _get_registration_status_array()
636
+	{
637
+		self::$_reg_status = EEM_Registration::reg_status_array(array(), true);
638
+	}
639
+
640
+
641
+	protected function _add_screen_options_default()
642
+	{
643
+		$this->_per_page_screen_option();
644
+	}
645
+
646
+
647
+	protected function _add_screen_options_contact_list()
648
+	{
649
+		$page_title = $this->_admin_page_title;
650
+		$this->_admin_page_title = esc_html__("Contacts", 'event_espresso');
651
+		$this->_per_page_screen_option();
652
+		$this->_admin_page_title = $page_title;
653
+	}
654
+
655
+
656
+	public function load_scripts_styles()
657
+	{
658
+		// style
659
+		wp_register_style(
660
+			'espresso_reg',
661
+			REG_ASSETS_URL . 'espresso_registrations_admin.css',
662
+			array('ee-admin-css'),
663
+			EVENT_ESPRESSO_VERSION
664
+		);
665
+		wp_enqueue_style('espresso_reg');
666
+		// script
667
+		wp_register_script(
668
+			'espresso_reg',
669
+			REG_ASSETS_URL . 'espresso_registrations_admin.js',
670
+			array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'),
671
+			EVENT_ESPRESSO_VERSION,
672
+			true
673
+		);
674
+		wp_enqueue_script('espresso_reg');
675
+	}
676
+
677
+
678
+	public function load_scripts_styles_edit_attendee()
679
+	{
680
+		// stuff to only show up on our attendee edit details page.
681
+		$attendee_details_translations = array(
682
+			'att_publish_text' => sprintf(
683
+				esc_html__('Created on: <b>%1$s</b>', 'event_espresso'),
684
+				$this->_cpt_model_obj->get_datetime('ATT_created')
685
+			),
686
+		);
687
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
688
+		wp_enqueue_script('jquery-validate');
689
+	}
690
+
691
+
692
+	public function load_scripts_styles_view_registration()
693
+	{
694
+		// styles
695
+		wp_enqueue_style('espresso-ui-theme');
696
+		// scripts
697
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
698
+		$this->_reg_custom_questions_form->wp_enqueue_scripts(true);
699
+	}
700
+
701
+
702
+	public function load_scripts_styles_contact_list()
703
+	{
704
+		wp_dequeue_style('espresso_reg');
705
+		wp_register_style(
706
+			'espresso_att',
707
+			REG_ASSETS_URL . 'espresso_attendees_admin.css',
708
+			array('ee-admin-css'),
709
+			EVENT_ESPRESSO_VERSION
710
+		);
711
+		wp_enqueue_style('espresso_att');
712
+	}
713
+
714
+
715
+	public function load_scripts_styles_new_registration()
716
+	{
717
+		wp_register_script(
718
+			'ee-spco-for-admin',
719
+			REG_ASSETS_URL . 'spco_for_admin.js',
720
+			array('underscore', 'jquery'),
721
+			EVENT_ESPRESSO_VERSION,
722
+			true
723
+		);
724
+		wp_enqueue_script('ee-spco-for-admin');
725
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
726
+		EE_Form_Section_Proper::wp_enqueue_scripts();
727
+		EED_Ticket_Selector::load_tckt_slctr_assets();
728
+		EE_Datepicker_Input::enqueue_styles_and_scripts();
729
+	}
730
+
731
+
732
+	public function AHEE__EE_Admin_Page__route_admin_request_resend_registration()
733
+	{
734
+		add_filter('FHEE_load_EE_messages', '__return_true');
735
+	}
736
+
737
+
738
+	public function AHEE__EE_Admin_Page__route_admin_request_approve_registration()
739
+	{
740
+		add_filter('FHEE_load_EE_messages', '__return_true');
741
+	}
742
+
743
+
744
+	protected function _set_list_table_views_default()
745
+	{
746
+		// for notification related bulk actions we need to make sure only active messengers have an option.
747
+		EED_Messages::set_autoloaders();
748
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
749
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
750
+		$active_mts = $message_resource_manager->list_of_active_message_types();
751
+		// key= bulk_action_slug, value= message type.
752
+		$match_array = array(
753
+			'approve_registrations'    => 'registration',
754
+			'decline_registrations'    => 'declined_registration',
755
+			'pending_registrations'    => 'pending_approval',
756
+			'no_approve_registrations' => 'not_approved_registration',
757
+			'cancel_registrations'     => 'cancelled_registration',
758
+		);
759
+		$can_send = EE_Registry::instance()->CAP->current_user_can(
760
+			'ee_send_message',
761
+			'batch_send_messages'
762
+		);
763
+		/** setup reg status bulk actions **/
764
+		$def_reg_status_actions['approve_registrations'] = esc_html__('Approve Registrations', 'event_espresso');
765
+		if ($can_send && in_array($match_array['approve_registrations'], $active_mts, true)) {
766
+			$def_reg_status_actions['approve_and_notify_registrations'] = esc_html__(
767
+				'Approve and Notify Registrations',
768
+				'event_espresso'
769
+			);
770
+		}
771
+		$def_reg_status_actions['decline_registrations'] = esc_html__('Decline Registrations', 'event_espresso');
772
+		if ($can_send && in_array($match_array['decline_registrations'], $active_mts, true)) {
773
+			$def_reg_status_actions['decline_and_notify_registrations'] = esc_html__(
774
+				'Decline and Notify Registrations',
775
+				'event_espresso'
776
+			);
777
+		}
778
+		$def_reg_status_actions['pending_registrations'] = esc_html__(
779
+			'Set Registrations to Pending Payment',
780
+			'event_espresso'
781
+		);
782
+		if ($can_send && in_array($match_array['pending_registrations'], $active_mts, true)) {
783
+			$def_reg_status_actions['pending_and_notify_registrations'] = esc_html__(
784
+				'Set Registrations to Pending Payment and Notify',
785
+				'event_espresso'
786
+			);
787
+		}
788
+		$def_reg_status_actions['no_approve_registrations'] = esc_html__(
789
+			'Set Registrations to Not Approved',
790
+			'event_espresso'
791
+		);
792
+		if ($can_send && in_array($match_array['no_approve_registrations'], $active_mts, true)) {
793
+			$def_reg_status_actions['no_approve_and_notify_registrations'] = esc_html__(
794
+				'Set Registrations to Not Approved and Notify',
795
+				'event_espresso'
796
+			);
797
+		}
798
+		$def_reg_status_actions['cancel_registrations'] = esc_html__('Cancel Registrations', 'event_espresso');
799
+		if ($can_send && in_array($match_array['cancel_registrations'], $active_mts, true)) {
800
+			$def_reg_status_actions['cancel_and_notify_registrations'] = esc_html__(
801
+				'Cancel Registrations and Notify',
802
+				'event_espresso'
803
+			);
804
+		}
805
+		$def_reg_status_actions = apply_filters(
806
+			'FHEE__Registrations_Admin_Page___set_list_table_views_default__def_reg_status_actions_array',
807
+			$def_reg_status_actions,
808
+			$active_mts,
809
+			$can_send
810
+		);
811
+
812
+		$this->_views = array(
813
+			'all'   => array(
814
+				'slug'        => 'all',
815
+				'label'       => esc_html__('View All Registrations', 'event_espresso'),
816
+				'count'       => 0,
817
+				'bulk_action' => array_merge(
818
+					$def_reg_status_actions,
819
+					array(
820
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
821
+					)
822
+				),
823
+			),
824
+			'month' => array(
825
+				'slug'        => 'month',
826
+				'label'       => esc_html__('This Month', 'event_espresso'),
827
+				'count'       => 0,
828
+				'bulk_action' => array_merge(
829
+					$def_reg_status_actions,
830
+					array(
831
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
832
+					)
833
+				),
834
+			),
835
+			'today' => array(
836
+				'slug'        => 'today',
837
+				'label'       => sprintf(
838
+					esc_html__('Today - %s', 'event_espresso'),
839
+					date('M d, Y', current_time('timestamp'))
840
+				),
841
+				'count'       => 0,
842
+				'bulk_action' => array_merge(
843
+					$def_reg_status_actions,
844
+					array(
845
+						'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
846
+					)
847
+				),
848
+			),
849
+		);
850
+		if (EE_Registry::instance()->CAP->current_user_can(
851
+			'ee_delete_registrations',
852
+			'espresso_registrations_delete_registration'
853
+		)) {
854
+			$this->_views['incomplete'] = array(
855
+				'slug'        => 'incomplete',
856
+				'label'       => esc_html__('Incomplete', 'event_espresso'),
857
+				'count'       => 0,
858
+				'bulk_action' => array(
859
+					'trash_registrations' => esc_html__('Trash Registrations', 'event_espresso'),
860
+				),
861
+			);
862
+			$this->_views['trash'] = array(
863
+				'slug'        => 'trash',
864
+				'label'       => esc_html__('Trash', 'event_espresso'),
865
+				'count'       => 0,
866
+				'bulk_action' => array(
867
+					'restore_registrations' => esc_html__('Restore Registrations', 'event_espresso'),
868
+					'delete_registrations'  => esc_html__('Delete Registrations Permanently', 'event_espresso'),
869
+				),
870
+			);
871
+		}
872
+	}
873
+
874
+
875
+	protected function _set_list_table_views_contact_list()
876
+	{
877
+		$this->_views = array(
878
+			'in_use' => array(
879
+				'slug'        => 'in_use',
880
+				'label'       => esc_html__('In Use', 'event_espresso'),
881
+				'count'       => 0,
882
+				'bulk_action' => array(
883
+					'trash_attendees' => esc_html__('Move to Trash', 'event_espresso'),
884
+				),
885
+			),
886
+		);
887
+		if (EE_Registry::instance()->CAP->current_user_can(
888
+			'ee_delete_contacts',
889
+			'espresso_registrations_trash_attendees'
890
+		)
891
+		) {
892
+			$this->_views['trash'] = array(
893
+				'slug'        => 'trash',
894
+				'label'       => esc_html__('Trash', 'event_espresso'),
895
+				'count'       => 0,
896
+				'bulk_action' => array(
897
+					'restore_attendees' => esc_html__('Restore from Trash', 'event_espresso'),
898
+				),
899
+			);
900
+		}
901
+	}
902
+
903
+
904
+	protected function _registration_legend_items()
905
+	{
906
+		$fc_items = array(
907
+			'star-icon'        => array(
908
+				'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8',
909
+				'desc'  => esc_html__('This is the Primary Registrant', 'event_espresso'),
910
+			),
911
+			'view_details'     => array(
912
+				'class' => 'dashicons dashicons-clipboard',
913
+				'desc'  => esc_html__('View Registration Details', 'event_espresso'),
914
+			),
915
+			'edit_attendee'    => array(
916
+				'class' => 'ee-icon ee-icon-user-edit ee-icon-size-16',
917
+				'desc'  => esc_html__('Edit Contact Details', 'event_espresso'),
918
+			),
919
+			'view_transaction' => array(
920
+				'class' => 'dashicons dashicons-cart',
921
+				'desc'  => esc_html__('View Transaction Details', 'event_espresso'),
922
+			),
923
+			'view_invoice'     => array(
924
+				'class' => 'dashicons dashicons-media-spreadsheet',
925
+				'desc'  => esc_html__('View Transaction Invoice', 'event_espresso'),
926
+			),
927
+		);
928
+		if (EE_Registry::instance()->CAP->current_user_can(
929
+			'ee_send_message',
930
+			'espresso_registrations_resend_registration'
931
+		)) {
932
+			$fc_items['resend_registration'] = array(
933
+				'class' => 'dashicons dashicons-email-alt',
934
+				'desc'  => esc_html__('Resend Registration Details', 'event_espresso'),
935
+			);
936
+		} else {
937
+			$fc_items['blank'] = array('class' => 'blank', 'desc' => '');
938
+		}
939
+		if (EE_Registry::instance()->CAP->current_user_can(
940
+			'ee_read_global_messages',
941
+			'view_filtered_messages'
942
+		)) {
943
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
944
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
945
+				$fc_items['view_related_messages'] = array(
946
+					'class' => $related_for_icon['css_class'],
947
+					'desc'  => $related_for_icon['label'],
948
+				);
949
+			}
950
+		}
951
+		$sc_items = array(
952
+			'approved_status'   => array(
953
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
954
+				'desc'  => EEH_Template::pretty_status(
955
+					EEM_Registration::status_id_approved,
956
+					false,
957
+					'sentence'
958
+				),
959
+			),
960
+			'pending_status'    => array(
961
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
962
+				'desc'  => EEH_Template::pretty_status(
963
+					EEM_Registration::status_id_pending_payment,
964
+					false,
965
+					'sentence'
966
+				),
967
+			),
968
+			'wait_list'         => array(
969
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list,
970
+				'desc'  => EEH_Template::pretty_status(
971
+					EEM_Registration::status_id_wait_list,
972
+					false,
973
+					'sentence'
974
+				),
975
+			),
976
+			'incomplete_status' => array(
977
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
978
+				'desc'  => EEH_Template::pretty_status(
979
+					EEM_Registration::status_id_incomplete,
980
+					false,
981
+					'sentence'
982
+				),
983
+			),
984
+			'not_approved'      => array(
985
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
986
+				'desc'  => EEH_Template::pretty_status(
987
+					EEM_Registration::status_id_not_approved,
988
+					false,
989
+					'sentence'
990
+				),
991
+			),
992
+			'declined_status'   => array(
993
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
994
+				'desc'  => EEH_Template::pretty_status(
995
+					EEM_Registration::status_id_declined,
996
+					false,
997
+					'sentence'
998
+				),
999
+			),
1000
+			'cancelled_status'  => array(
1001
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
1002
+				'desc'  => EEH_Template::pretty_status(
1003
+					EEM_Registration::status_id_cancelled,
1004
+					false,
1005
+					'sentence'
1006
+				),
1007
+			),
1008
+		);
1009
+		return array_merge($fc_items, $sc_items);
1010
+	}
1011
+
1012
+
1013
+
1014
+	/***************************************        REGISTRATION OVERVIEW        **************************************/
1015
+	/**
1016
+	 * @throws \EE_Error
1017
+	 */
1018
+	protected function _registrations_overview_list_table()
1019
+	{
1020
+		$this->_template_args['admin_page_header'] = '';
1021
+		$EVT_ID = ! empty($this->_req_data['event_id'])
1022
+			? absint($this->_req_data['event_id'])
1023
+			: 0;
1024
+		$ATT_ID = ! empty($this->_req_data['ATT_ID'])
1025
+			? absint($this->_req_data['ATT_ID'])
1026
+			: 0;
1027
+		if ($ATT_ID) {
1028
+			$attendee = EEM_Attendee::instance()->get_one_by_ID($ATT_ID);
1029
+			if ($attendee instanceof EE_Attendee) {
1030
+				$this->_template_args['admin_page_header'] = sprintf(
1031
+					esc_html__(
1032
+						'%1$s Viewing registrations for %2$s%3$s',
1033
+						'event_espresso'
1034
+					),
1035
+					'<h3 style="line-height:1.5em;">',
1036
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
1037
+						array(
1038
+							'action' => 'edit_attendee',
1039
+							'post'   => $ATT_ID,
1040
+						),
1041
+						REG_ADMIN_URL
1042
+					) . '">' . $attendee->full_name() . '</a>',
1043
+					'</h3>'
1044
+				);
1045
+			}
1046
+		}
1047
+		if ($EVT_ID) {
1048
+			if (EE_Registry::instance()->CAP->current_user_can(
1049
+				'ee_edit_registrations',
1050
+				'espresso_registrations_new_registration',
1051
+				$EVT_ID
1052
+			)) {
1053
+				$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1054
+					'new_registration',
1055
+					'add-registrant',
1056
+					array('event_id' => $EVT_ID),
1057
+					'add-new-h2'
1058
+				);
1059
+			}
1060
+			$event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1061
+			if ($event instanceof EE_Event) {
1062
+				$this->_template_args['admin_page_header'] = sprintf(
1063
+					esc_html__(
1064
+						'%s Viewing registrations for the event: %s%s',
1065
+						'event_espresso'
1066
+					),
1067
+					'<h3 style="line-height:1.5em;">',
1068
+					'<br /><a href="'
1069
+					. EE_Admin_Page::add_query_args_and_nonce(
1070
+						array(
1071
+							'action' => 'edit',
1072
+							'post'   => $event->ID(),
1073
+						),
1074
+						EVENTS_ADMIN_URL
1075
+					)
1076
+					. '">&nbsp;'
1077
+					. $event->get('EVT_name')
1078
+					. '&nbsp;</a>&nbsp;',
1079
+					'</h3>'
1080
+				);
1081
+			}
1082
+			$DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0;
1083
+			$datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID);
1084
+			if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') {
1085
+				$this->_template_args['admin_page_header'] = substr(
1086
+					$this->_template_args['admin_page_header'],
1087
+					0,
1088
+					-5
1089
+				);
1090
+				$this->_template_args['admin_page_header'] .= ' &nbsp;<span class="drk-grey-text">';
1091
+				$this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>';
1092
+				$this->_template_args['admin_page_header'] .= $datetime->name();
1093
+				$this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )';
1094
+				$this->_template_args['admin_page_header'] .= '</span></h3>';
1095
+			}
1096
+		}
1097
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
1098
+		$this->display_admin_list_table_page_with_no_sidebar();
1099
+	}
1100
+
1101
+
1102
+	/**
1103
+	 * This sets the _registration property for the registration details screen
1104
+	 *
1105
+	 * @access private
1106
+	 * @return bool
1107
+	 * @throws EE_Error
1108
+	 * @throws InvalidArgumentException
1109
+	 * @throws InvalidDataTypeException
1110
+	 * @throws InvalidInterfaceException
1111
+	 */
1112
+	private function _set_registration_object()
1113
+	{
1114
+		// get out if we've already set the object
1115
+		if ($this->_registration instanceof EE_Registration) {
1116
+			return true;
1117
+		}
1118
+		$REG = EEM_Registration::instance();
1119
+		$REG_ID = (! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : false;
1120
+		if ($this->_registration = $REG->get_one_by_ID($REG_ID)) {
1121
+			return true;
1122
+		} else {
1123
+			$error_msg = sprintf(
1124
+				esc_html__(
1125
+					'An error occurred and the details for Registration ID #%s could not be retrieved.',
1126
+					'event_espresso'
1127
+				),
1128
+				$REG_ID
1129
+			);
1130
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
1131
+			$this->_registration = null;
1132
+			return false;
1133
+		}
1134
+	}
1135
+
1136
+
1137
+	/**
1138
+	 * Used to retrieve registrations for the list table.
1139
+	 *
1140
+	 * @param int  $per_page
1141
+	 * @param bool $count
1142
+	 * @param bool $this_month
1143
+	 * @param bool $today
1144
+	 * @return EE_Registration[]|int
1145
+	 * @throws EE_Error
1146
+	 * @throws InvalidArgumentException
1147
+	 * @throws InvalidDataTypeException
1148
+	 * @throws InvalidInterfaceException
1149
+	 */
1150
+	public function get_registrations(
1151
+		$per_page = 10,
1152
+		$count = false,
1153
+		$this_month = false,
1154
+		$today = false
1155
+	) {
1156
+		if ($this_month) {
1157
+			$this->_req_data['status'] = 'month';
1158
+		}
1159
+		if ($today) {
1160
+			$this->_req_data['status'] = 'today';
1161
+		}
1162
+		$query_params = $this->_get_registration_query_parameters($this->_req_data, $per_page, $count);
1163
+		/**
1164
+		 * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected
1165
+		 *
1166
+		 * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093
1167
+		 * @see  EEM_Base::get_all()
1168
+		 */
1169
+		$query_params['group_by'] = '';
1170
+
1171
+		return $count
1172
+			? EEM_Registration::instance()->count($query_params)
1173
+			/** @type EE_Registration[] */
1174
+			: EEM_Registration::instance()->get_all($query_params);
1175
+	}
1176
+
1177
+
1178
+	/**
1179
+	 * Retrieves the query parameters to be used by the Registration model for getting registrations.
1180
+	 * Note: this listens to values on the request for some of the query parameters.
1181
+	 *
1182
+	 * @param array $request
1183
+	 * @param int   $per_page
1184
+	 * @param bool  $count
1185
+	 * @return array
1186
+	 * @throws EE_Error
1187
+	 */
1188
+	protected function _get_registration_query_parameters(
1189
+		$request = array(),
1190
+		$per_page = 10,
1191
+		$count = false
1192
+	) {
1193
+
1194
+		$query_params = array(
1195
+			0                          => $this->_get_where_conditions_for_registrations_query(
1196
+				$request
1197
+			),
1198
+			'caps'                     => EEM_Registration::caps_read_admin,
1199
+			'default_where_conditions' => 'this_model_only',
1200
+		);
1201
+		if (! $count) {
1202
+			$query_params = array_merge(
1203
+				$query_params,
1204
+				$this->_get_orderby_for_registrations_query(),
1205
+				$this->_get_limit($per_page)
1206
+			);
1207
+		}
1208
+
1209
+		return $query_params;
1210
+	}
1211
+
1212
+
1213
+	/**
1214
+	 * This will add ATT_ID to the provided $where array for EE model query parameters.
1215
+	 *
1216
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1217
+	 * @return array
1218
+	 */
1219
+	protected function addAttendeeIdToWhereConditions(array $request)
1220
+	{
1221
+		$where = array();
1222
+		if (! empty($request['ATT_ID'])) {
1223
+			$where['ATT_ID'] = absint($request['ATT_ID']);
1224
+		}
1225
+		return $where;
1226
+	}
1227
+
1228
+
1229
+	/**
1230
+	 * This will add EVT_ID to the provided $where array for EE model query parameters.
1231
+	 *
1232
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1233
+	 * @return array
1234
+	 */
1235
+	protected function _add_event_id_to_where_conditions(array $request)
1236
+	{
1237
+		$where = array();
1238
+		if (! empty($request['event_id'])) {
1239
+			$where['EVT_ID'] = absint($request['event_id']);
1240
+		}
1241
+		return $where;
1242
+	}
1243
+
1244
+
1245
+	/**
1246
+	 * Adds category ID if it exists in the request to the where conditions for the registrations query.
1247
+	 *
1248
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1249
+	 * @return array
1250
+	 */
1251
+	protected function _add_category_id_to_where_conditions(array $request)
1252
+	{
1253
+		$where = array();
1254
+		if (! empty($request['EVT_CAT']) && (int) $request['EVT_CAT'] !== -1) {
1255
+			$where['Event.Term_Taxonomy.term_id'] = absint($request['EVT_CAT']);
1256
+		}
1257
+		return $where;
1258
+	}
1259
+
1260
+
1261
+	/**
1262
+	 * Adds the datetime ID if it exists in the request to the where conditions for the registrations query.
1263
+	 *
1264
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1265
+	 * @return array
1266
+	 */
1267
+	protected function _add_datetime_id_to_where_conditions(array $request)
1268
+	{
1269
+		$where = array();
1270
+		if (! empty($request['datetime_id'])) {
1271
+			$where['Ticket.Datetime.DTT_ID'] = absint($request['datetime_id']);
1272
+		}
1273
+		if (! empty($request['DTT_ID'])) {
1274
+			$where['Ticket.Datetime.DTT_ID'] = absint($request['DTT_ID']);
1275
+		}
1276
+		return $where;
1277
+	}
1278
+
1279
+
1280
+	/**
1281
+	 * Adds the correct registration status to the where conditions for the registrations query.
1282
+	 *
1283
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1284
+	 * @return array
1285
+	 */
1286
+	protected function _add_registration_status_to_where_conditions(array $request)
1287
+	{
1288
+		$where = array();
1289
+		$view = EEH_Array::is_set($request, 'status', '');
1290
+		$registration_status = ! empty($request['_reg_status'])
1291
+			? sanitize_text_field($request['_reg_status'])
1292
+			: '';
1293
+
1294
+		/*
1295 1295
          * If filtering by registration status, then we show registrations matching that status.
1296 1296
          * If not filtering by specified status, then we show all registrations excluding incomplete registrations
1297 1297
          * UNLESS viewing trashed registrations.
1298 1298
          */
1299
-        if (! empty($registration_status)) {
1300
-            $where['STS_ID'] = $registration_status;
1301
-        } else {
1302
-            // make sure we exclude incomplete registrations, but only if not trashed.
1303
-            if ($view === 'trash') {
1304
-                $where['REG_deleted'] = true;
1305
-            } elseif ($view === 'incomplete') {
1306
-                $where['STS_ID'] = EEM_Registration::status_id_incomplete;
1307
-            } else {
1308
-                $where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1309
-            }
1310
-        }
1311
-        return $where;
1312
-    }
1313
-
1314
-
1315
-    /**
1316
-     * Adds any provided date restraints to the where conditions for the registrations query.
1317
-     *
1318
-     * @param array $request usually the same as $this->_req_data but not necessarily
1319
-     * @return array
1320
-     * @throws EE_Error
1321
-     * @throws InvalidArgumentException
1322
-     * @throws InvalidDataTypeException
1323
-     * @throws InvalidInterfaceException
1324
-     */
1325
-    protected function _add_date_to_where_conditions(array $request)
1326
-    {
1327
-        $where = array();
1328
-        $view = EEH_Array::is_set($request, 'status', '');
1329
-        $month_range = ! empty($request['month_range'])
1330
-            ? sanitize_text_field($request['month_range'])
1331
-            : '';
1332
-        $retrieve_for_today = $view === 'today';
1333
-        $retrieve_for_this_month = $view === 'month';
1334
-
1335
-        if ($retrieve_for_today) {
1336
-            $now = date('Y-m-d', current_time('timestamp'));
1337
-            $where['REG_date'] = array(
1338
-                'BETWEEN',
1339
-                array(
1340
-                    EEM_Registration::instance()->convert_datetime_for_query(
1341
-                        'REG_date',
1342
-                        $now . ' 00:00:00',
1343
-                        'Y-m-d H:i:s'
1344
-                    ),
1345
-                    EEM_Registration::instance()->convert_datetime_for_query(
1346
-                        'REG_date',
1347
-                        $now . ' 23:59:59',
1348
-                        'Y-m-d H:i:s'
1349
-                    ),
1350
-                ),
1351
-            );
1352
-        } elseif ($retrieve_for_this_month) {
1353
-            $current_year_and_month = date('Y-m', current_time('timestamp'));
1354
-            $days_this_month = date('t', current_time('timestamp'));
1355
-            $where['REG_date'] = array(
1356
-                'BETWEEN',
1357
-                array(
1358
-                    EEM_Registration::instance()->convert_datetime_for_query(
1359
-                        'REG_date',
1360
-                        $current_year_and_month . '-01 00:00:00',
1361
-                        'Y-m-d H:i:s'
1362
-                    ),
1363
-                    EEM_Registration::instance()->convert_datetime_for_query(
1364
-                        'REG_date',
1365
-                        $current_year_and_month . '-' . $days_this_month . ' 23:59:59',
1366
-                        'Y-m-d H:i:s'
1367
-                    ),
1368
-                ),
1369
-            );
1370
-        } elseif ($month_range) {
1371
-            $pieces = explode(' ', $month_range, 3);
1372
-            $month_requested = ! empty($pieces[0])
1373
-                ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
1374
-                : '';
1375
-            $year_requested = ! empty($pieces[1])
1376
-                ? $pieces[1]
1377
-                : '';
1378
-            // if there is not a month or year then we can't go further
1379
-            if ($month_requested && $year_requested) {
1380
-                $days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
1381
-                $where['REG_date'] = array(
1382
-                    'BETWEEN',
1383
-                    array(
1384
-                        EEM_Registration::instance()->convert_datetime_for_query(
1385
-                            'REG_date',
1386
-                            $year_requested . '-' . $month_requested . '-01 00:00:00',
1387
-                            'Y-m-d H:i:s'
1388
-                        ),
1389
-                        EEM_Registration::instance()->convert_datetime_for_query(
1390
-                            'REG_date',
1391
-                            $year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
1392
-                            'Y-m-d H:i:s'
1393
-                        ),
1394
-                    ),
1395
-                );
1396
-            }
1397
-        }
1398
-        return $where;
1399
-    }
1400
-
1401
-
1402
-    /**
1403
-     * Adds any provided search restraints to the where conditions for the registrations query
1404
-     *
1405
-     * @param array $request usually the same as $this->_req_data but not necessarily
1406
-     * @return array
1407
-     */
1408
-    protected function _add_search_to_where_conditions(array $request)
1409
-    {
1410
-        $where = array();
1411
-        if (! empty($request['s'])) {
1412
-            $search_string = '%' . sanitize_text_field($request['s']) . '%';
1413
-            $where['OR*search_conditions'] = array(
1414
-                'Event.EVT_name'                          => array('LIKE', $search_string),
1415
-                'Event.EVT_desc'                          => array('LIKE', $search_string),
1416
-                'Event.EVT_short_desc'                    => array('LIKE', $search_string),
1417
-                'Attendee.ATT_full_name'                  => array('LIKE', $search_string),
1418
-                'Attendee.ATT_fname'                      => array('LIKE', $search_string),
1419
-                'Attendee.ATT_lname'                      => array('LIKE', $search_string),
1420
-                'Attendee.ATT_short_bio'                  => array('LIKE', $search_string),
1421
-                'Attendee.ATT_email'                      => array('LIKE', $search_string),
1422
-                'Attendee.ATT_address'                    => array('LIKE', $search_string),
1423
-                'Attendee.ATT_address2'                   => array('LIKE', $search_string),
1424
-                'Attendee.ATT_city'                       => array('LIKE', $search_string),
1425
-                'REG_final_price'                         => array('LIKE', $search_string),
1426
-                'REG_code'                                => array('LIKE', $search_string),
1427
-                'REG_count'                               => array('LIKE', $search_string),
1428
-                'REG_group_size'                          => array('LIKE', $search_string),
1429
-                'Ticket.TKT_name'                         => array('LIKE', $search_string),
1430
-                'Ticket.TKT_description'                  => array('LIKE', $search_string),
1431
-                'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string),
1432
-            );
1433
-        }
1434
-        return $where;
1435
-    }
1436
-
1437
-
1438
-    /**
1439
-     * Sets up the where conditions for the registrations query.
1440
-     *
1441
-     * @param array $request
1442
-     * @return array
1443
-     * @throws EE_Error
1444
-     */
1445
-    protected function _get_where_conditions_for_registrations_query($request)
1446
-    {
1447
-        return apply_filters(
1448
-            'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
1449
-            array_merge(
1450
-                $this->addAttendeeIdToWhereConditions($request),
1451
-                $this->_add_event_id_to_where_conditions($request),
1452
-                $this->_add_category_id_to_where_conditions($request),
1453
-                $this->_add_datetime_id_to_where_conditions($request),
1454
-                $this->_add_registration_status_to_where_conditions($request),
1455
-                $this->_add_date_to_where_conditions($request),
1456
-                $this->_add_search_to_where_conditions($request)
1457
-            ),
1458
-            $request
1459
-        );
1460
-    }
1461
-
1462
-
1463
-    /**
1464
-     * Sets up the orderby for the registrations query.
1465
-     *
1466
-     * @return array
1467
-     */
1468
-    protected function _get_orderby_for_registrations_query()
1469
-    {
1470
-        $orderby_field = ! empty($this->_req_data['orderby'])
1471
-            ? sanitize_text_field($this->_req_data['orderby'])
1472
-            : '_REG_date';
1473
-        switch ($orderby_field) {
1474
-            case '_REG_ID':
1475
-                $orderby = array('REG_ID');
1476
-                break;
1477
-            case '_Reg_status':
1478
-                $orderby = array('STS_ID');
1479
-                break;
1480
-            case 'ATT_fname':
1481
-                $orderby = array('Attendee.ATT_fname', 'Attendee.ATT_lname');
1482
-                break;
1483
-            case 'ATT_lname':
1484
-                $orderby = array('Attendee.ATT_lname', 'Attendee.ATT_fname');
1485
-                break;
1486
-            case 'event_name':
1487
-                $orderby = array('Event.EVT_name');
1488
-                break;
1489
-            case 'DTT_EVT_start':
1490
-                $orderby = array('Event.Datetime.DTT_EVT_start');
1491
-                break;
1492
-            case '_REG_date':
1493
-                $orderby = array('REG_date');
1494
-                break;
1495
-            default:
1496
-                $orderby = array($orderby_field);
1497
-                break;
1498
-        }
1499
-
1500
-        // order
1501
-        $order = ! empty($this->_req_data['order'])
1502
-            ? sanitize_text_field($this->_req_data['order'])
1503
-            : 'DESC';
1504
-        $orderby = array_combine(
1505
-            $orderby,
1506
-            array_fill(0, count($orderby), $order)
1507
-        );
1508
-        // because there are many registrations with the same date, define
1509
-        // a secondary way to order them, otherwise MySQL seems to be a bit random
1510
-        if (empty($orderby['REG_ID'])) {
1511
-            $orderby['REG_ID'] = $order;
1512
-        }
1513
-
1514
-        $orderby = apply_filters(
1515
-            'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
1516
-            $orderby,
1517
-            $this->_req_data
1518
-        );
1519
-
1520
-        return array('order_by' => $orderby);
1521
-    }
1522
-
1523
-
1524
-    /**
1525
-     * Sets up the limit for the registrations query.
1526
-     *
1527
-     * @param $per_page
1528
-     * @return array
1529
-     */
1530
-    protected function _get_limit($per_page)
1531
-    {
1532
-        $current_page = ! empty($this->_req_data['paged'])
1533
-            ? absint($this->_req_data['paged'])
1534
-            : 1;
1535
-        $per_page = ! empty($this->_req_data['perpage'])
1536
-            ? $this->_req_data['perpage']
1537
-            : $per_page;
1538
-
1539
-        // -1 means return all results so get out if that's set.
1540
-        if ((int) $per_page === -1) {
1541
-            return array();
1542
-        }
1543
-        $per_page = absint($per_page);
1544
-        $offset = ($current_page - 1) * $per_page;
1545
-        return array('limit' => array($offset, $per_page));
1546
-    }
1547
-
1548
-
1549
-    public function get_registration_status_array()
1550
-    {
1551
-        return self::$_reg_status;
1552
-    }
1553
-
1554
-
1555
-
1556
-
1557
-    /***************************************        REGISTRATION DETAILS        ***************************************/
1558
-    /**
1559
-     *        generates HTML for the View Registration Details Admin page
1560
-     *
1561
-     * @access protected
1562
-     * @return void
1563
-     * @throws DomainException
1564
-     * @throws EE_Error
1565
-     * @throws InvalidArgumentException
1566
-     * @throws InvalidDataTypeException
1567
-     * @throws InvalidInterfaceException
1568
-     * @throws EntityNotFoundException
1569
-     */
1570
-    protected function _registration_details()
1571
-    {
1572
-        $this->_template_args = array();
1573
-        $this->_set_registration_object();
1574
-        if (is_object($this->_registration)) {
1575
-            $transaction = $this->_registration->transaction()
1576
-                ? $this->_registration->transaction()
1577
-                : EE_Transaction::new_instance();
1578
-            $this->_session = $transaction->session_data();
1579
-            $event_id = $this->_registration->event_ID();
1580
-            $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1581
-            $this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso');
1582
-            $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1583
-            $this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1584
-            $this->_template_args['grand_total'] = $transaction->total();
1585
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1586
-            // link back to overview
1587
-            $this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1588
-            $this->_template_args['registration'] = $this->_registration;
1589
-            $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1590
-                array(
1591
-                    'action'   => 'default',
1592
-                    'event_id' => $event_id,
1593
-                ),
1594
-                REG_ADMIN_URL
1595
-            );
1596
-            $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1597
-                array(
1598
-                    'action' => 'default',
1599
-                    'EVT_ID' => $event_id,
1600
-                    'page'   => 'espresso_transactions',
1601
-                ),
1602
-                admin_url('admin.php')
1603
-            );
1604
-            $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1605
-                array(
1606
-                    'page'   => 'espresso_events',
1607
-                    'action' => 'edit',
1608
-                    'post'   => $event_id,
1609
-                ),
1610
-                admin_url('admin.php')
1611
-            );
1612
-            // next and previous links
1613
-            $next_reg = $this->_registration->next(
1614
-                null,
1615
-                array(),
1616
-                'REG_ID'
1617
-            );
1618
-            $this->_template_args['next_registration'] = $next_reg
1619
-                ? $this->_next_link(
1620
-                    EE_Admin_Page::add_query_args_and_nonce(
1621
-                        array(
1622
-                            'action'  => 'view_registration',
1623
-                            '_REG_ID' => $next_reg['REG_ID'],
1624
-                        ),
1625
-                        REG_ADMIN_URL
1626
-                    ),
1627
-                    'dashicons dashicons-arrow-right ee-icon-size-22'
1628
-                )
1629
-                : '';
1630
-            $previous_reg = $this->_registration->previous(
1631
-                null,
1632
-                array(),
1633
-                'REG_ID'
1634
-            );
1635
-            $this->_template_args['previous_registration'] = $previous_reg
1636
-                ? $this->_previous_link(
1637
-                    EE_Admin_Page::add_query_args_and_nonce(
1638
-                        array(
1639
-                            'action'  => 'view_registration',
1640
-                            '_REG_ID' => $previous_reg['REG_ID'],
1641
-                        ),
1642
-                        REG_ADMIN_URL
1643
-                    ),
1644
-                    'dashicons dashicons-arrow-left ee-icon-size-22'
1645
-                )
1646
-                : '';
1647
-            // grab header
1648
-            $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1649
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
1650
-            $this->_template_args['admin_page_header'] = EEH_Template::display_template(
1651
-                $template_path,
1652
-                $this->_template_args,
1653
-                true
1654
-            );
1655
-        } else {
1656
-            $this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1657
-        }
1658
-        // the details template wrapper
1659
-        $this->display_admin_page_with_sidebar();
1660
-    }
1661
-
1662
-
1663
-    protected function _registration_details_metaboxes()
1664
-    {
1665
-        do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1666
-        $this->_set_registration_object();
1667
-        $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1668
-        add_meta_box(
1669
-            'edit-reg-status-mbox',
1670
-            esc_html__('Registration Status', 'event_espresso'),
1671
-            array($this, 'set_reg_status_buttons_metabox'),
1672
-            $this->wp_page_slug,
1673
-            'normal',
1674
-            'high'
1675
-        );
1676
-        add_meta_box(
1677
-            'edit-reg-details-mbox',
1678
-            esc_html__('Registration Details', 'event_espresso'),
1679
-            array($this, '_reg_details_meta_box'),
1680
-            $this->wp_page_slug,
1681
-            'normal',
1682
-            'high'
1683
-        );
1684
-        if ($attendee instanceof EE_Attendee
1685
-            && EE_Registry::instance()->CAP->current_user_can(
1686
-                'ee_edit_registration',
1687
-                'edit-reg-questions-mbox',
1688
-                $this->_registration->ID()
1689
-            )
1690
-        ) {
1691
-            add_meta_box(
1692
-                'edit-reg-questions-mbox',
1693
-                esc_html__('Registration Form Answers', 'event_espresso'),
1694
-                array($this, '_reg_questions_meta_box'),
1695
-                $this->wp_page_slug,
1696
-                'normal',
1697
-                'high'
1698
-            );
1699
-        }
1700
-        add_meta_box(
1701
-            'edit-reg-registrant-mbox',
1702
-            esc_html__('Contact Details', 'event_espresso'),
1703
-            array($this, '_reg_registrant_side_meta_box'),
1704
-            $this->wp_page_slug,
1705
-            'side',
1706
-            'high'
1707
-        );
1708
-        if ($this->_registration->group_size() > 1) {
1709
-            add_meta_box(
1710
-                'edit-reg-attendees-mbox',
1711
-                esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1712
-                array($this, '_reg_attendees_meta_box'),
1713
-                $this->wp_page_slug,
1714
-                'normal',
1715
-                'high'
1716
-            );
1717
-        }
1718
-    }
1719
-
1720
-
1721
-    /**
1722
-     * set_reg_status_buttons_metabox
1723
-     *
1724
-     * @access protected
1725
-     * @return string
1726
-     * @throws \EE_Error
1727
-     */
1728
-    public function set_reg_status_buttons_metabox()
1729
-    {
1730
-        $this->_set_registration_object();
1731
-        $change_reg_status_form = $this->_generate_reg_status_change_form();
1732
-        echo $change_reg_status_form->form_open(
1733
-            self::add_query_args_and_nonce(
1734
-                array(
1735
-                    'action' => 'change_reg_status',
1736
-                ),
1737
-                REG_ADMIN_URL
1738
-            )
1739
-        );
1740
-        echo $change_reg_status_form->get_html();
1741
-        echo $change_reg_status_form->form_close();
1742
-    }
1743
-
1744
-
1745
-    /**
1746
-     * @return EE_Form_Section_Proper
1747
-     * @throws EE_Error
1748
-     * @throws InvalidArgumentException
1749
-     * @throws InvalidDataTypeException
1750
-     * @throws InvalidInterfaceException
1751
-     * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1752
-     */
1753
-    protected function _generate_reg_status_change_form()
1754
-    {
1755
-        return new EE_Form_Section_Proper(
1756
-            array(
1757
-                'name'            => 'reg_status_change_form',
1758
-                'html_id'         => 'reg-status-change-form',
1759
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1760
-                'subsections'     => array(
1761
-                    'return'             => new EE_Hidden_Input(
1762
-                        array(
1763
-                            'name'    => 'return',
1764
-                            'default' => 'view_registration',
1765
-                        )
1766
-                    ),
1767
-                    'REG_ID'             => new EE_Hidden_Input(
1768
-                        array(
1769
-                            'name'    => 'REG_ID',
1770
-                            'default' => $this->_registration->ID(),
1771
-                        )
1772
-                    ),
1773
-                    'current_status'     => new EE_Form_Section_HTML(
1774
-                        EEH_HTML::tr(
1775
-                            EEH_HTML::th(
1776
-                                EEH_HTML::label(
1777
-                                    EEH_HTML::strong(
1778
-                                        esc_html__('Current Registration Status', 'event_espresso')
1779
-                                    )
1780
-                                )
1781
-                            )
1782
-                            . EEH_HTML::td(
1783
-                                EEH_HTML::strong(
1784
-                                    $this->_registration->pretty_status(),
1785
-                                    '',
1786
-                                    'status-' . $this->_registration->status_ID(),
1787
-                                    'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1788
-                                )
1789
-                            )
1790
-                        )
1791
-                    ),
1792
-                    'reg_status'         => new EE_Select_Input(
1793
-                        $this->_get_reg_statuses(),
1794
-                        array(
1795
-                            'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1796
-                            'default'         => $this->_registration->status_ID(),
1797
-                        )
1798
-                    ),
1799
-                    'send_notifications' => new EE_Yes_No_Input(
1800
-                        array(
1801
-                            'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1802
-                            'default'         => false,
1803
-                            'html_help_text'  => esc_html__(
1804
-                                'If set to "Yes", then the related messages will be sent to the registrant.',
1805
-                                'event_espresso'
1806
-                            ),
1807
-                        )
1808
-                    ),
1809
-                    'submit'             => new EE_Submit_Input(
1810
-                        array(
1811
-                            'html_class'      => 'button-primary',
1812
-                            'html_label_text' => '&nbsp;',
1813
-                            'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1814
-                        )
1815
-                    ),
1816
-                ),
1817
-            )
1818
-        );
1819
-    }
1820
-
1821
-
1822
-    /**
1823
-     * Returns an array of all the buttons for the various statuses and switch status actions
1824
-     *
1825
-     * @return array
1826
-     * @throws EE_Error
1827
-     * @throws InvalidArgumentException
1828
-     * @throws InvalidDataTypeException
1829
-     * @throws InvalidInterfaceException
1830
-     * @throws EntityNotFoundException
1831
-     */
1832
-    protected function _get_reg_statuses()
1833
-    {
1834
-        $reg_status_array = EEM_Registration::instance()->reg_status_array();
1835
-        unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1836
-        // get current reg status
1837
-        $current_status = $this->_registration->status_ID();
1838
-        // is registration for free event? This will determine whether to display the pending payment option
1839
-        if ($current_status !== EEM_Registration::status_id_pending_payment
1840
-            && EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1841
-        ) {
1842
-            unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1843
-        }
1844
-        return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1845
-    }
1846
-
1847
-
1848
-    /**
1849
-     * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1850
-     *
1851
-     * @param bool $status REG status given for changing registrations to.
1852
-     * @param bool $notify Whether to send messages notifications or not.
1853
-     * @return array (array with reg_id(s) updated and whether update was successful.
1854
-     * @throws EE_Error
1855
-     * @throws InvalidArgumentException
1856
-     * @throws InvalidDataTypeException
1857
-     * @throws InvalidInterfaceException
1858
-     * @throws ReflectionException
1859
-     * @throws RuntimeException
1860
-     * @throws EntityNotFoundException
1861
-     */
1862
-    protected function _set_registration_status_from_request($status = false, $notify = false)
1863
-    {
1864
-        if (isset($this->_req_data['reg_status_change_form'])) {
1865
-            $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1866
-                ? (array) $this->_req_data['reg_status_change_form']['REG_ID']
1867
-                : array();
1868
-        } else {
1869
-            $REG_IDs = isset($this->_req_data['_REG_ID'])
1870
-                ? (array) $this->_req_data['_REG_ID']
1871
-                : array();
1872
-        }
1873
-        // sanitize $REG_IDs
1874
-        $REG_IDs = array_map('absint', $REG_IDs);
1875
-        // and remove empty entries
1876
-        $REG_IDs = array_filter($REG_IDs);
1877
-
1878
-        $result = $this->_set_registration_status($REG_IDs, $status, $notify);
1879
-
1880
-        /**
1881
-         * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1882
-         * Currently this value is used downstream by the _process_resend_registration method.
1883
-         *
1884
-         * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1885
-         * @param bool                     $status           The status registrations were changed to.
1886
-         * @param bool                     $success          If the status was changed successfully for all registrations.
1887
-         * @param Registrations_Admin_Page $admin_page_object
1888
-         */
1889
-        $this->_req_data['_REG_ID'] = apply_filters(
1890
-            'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1891
-            $result['REG_ID'],
1892
-            $status,
1893
-            $result['success'],
1894
-            $this
1895
-        );
1896
-
1897
-        // notify?
1898
-        if ($notify
1899
-            && $result['success']
1900
-            && ! empty($this->_req_data['_REG_ID'])
1901
-            && EE_Registry::instance()->CAP->current_user_can(
1902
-                'ee_send_message',
1903
-                'espresso_registrations_resend_registration'
1904
-            )
1905
-        ) {
1906
-            $this->_process_resend_registration();
1907
-        }
1908
-        return $result;
1909
-    }
1910
-
1911
-
1912
-    /**
1913
-     * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1914
-     * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1915
-     *
1916
-     * @param array  $REG_IDs
1917
-     * @param string $status
1918
-     * @param bool   $notify  Used to indicate whether notification was requested or not.  This determines the context
1919
-     *                        slug sent with setting the registration status.
1920
-     * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1921
-     * @throws EE_Error
1922
-     * @throws InvalidArgumentException
1923
-     * @throws InvalidDataTypeException
1924
-     * @throws InvalidInterfaceException
1925
-     * @throws ReflectionException
1926
-     * @throws RuntimeException
1927
-     * @throws EntityNotFoundException
1928
-     */
1929
-    protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false)
1930
-    {
1931
-        $success = false;
1932
-        // typecast $REG_IDs
1933
-        $REG_IDs = (array) $REG_IDs;
1934
-        if (! empty($REG_IDs)) {
1935
-            $success = true;
1936
-            // set default status if none is passed
1937
-            $status = $status ? $status : EEM_Registration::status_id_pending_payment;
1938
-            $status_context = $notify
1939
-                ? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1940
-                : Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1941
-            // loop through REG_ID's and change status
1942
-            foreach ($REG_IDs as $REG_ID) {
1943
-                $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1944
-                if ($registration instanceof EE_Registration) {
1945
-                    $registration->set_status(
1946
-                        $status,
1947
-                        false,
1948
-                        new Context(
1949
-                            $status_context,
1950
-                            esc_html__(
1951
-                                'Manually triggered status change on a Registration Admin Page route.',
1952
-                                'event_espresso'
1953
-                            )
1954
-                        )
1955
-                    );
1956
-                    $result = $registration->save();
1957
-                    // verifying explicit fails because update *may* just return 0 for 0 rows affected
1958
-                    $success = $result !== false ? $success : false;
1959
-                }
1960
-            }
1961
-        }
1962
-
1963
-        // return $success and processed registrations
1964
-        return array('REG_ID' => $REG_IDs, 'success' => $success);
1965
-    }
1966
-
1967
-
1968
-    /**
1969
-     * Common logic for setting up success message and redirecting to appropriate route
1970
-     *
1971
-     * @param  string $STS_ID status id for the registration changed to
1972
-     * @param   bool  $notify indicates whether the _set_registration_status_from_request does notifications or not.
1973
-     * @return void
1974
-     * @throws EE_Error
1975
-     */
1976
-    protected function _reg_status_change_return($STS_ID, $notify = false)
1977
-    {
1978
-        $result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1979
-            : array('success' => false);
1980
-        $success = isset($result['success']) && $result['success'];
1981
-        // setup success message
1982
-        if ($success) {
1983
-            if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1984
-                $msg = sprintf(
1985
-                    esc_html__('Registration status has been set to %s', 'event_espresso'),
1986
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1987
-                );
1988
-            } else {
1989
-                $msg = sprintf(
1990
-                    esc_html__('Registrations have been set to %s.', 'event_espresso'),
1991
-                    EEH_Template::pretty_status($STS_ID, false, 'lower')
1992
-                );
1993
-            }
1994
-            EE_Error::add_success($msg);
1995
-        } else {
1996
-            EE_Error::add_error(
1997
-                esc_html__(
1998
-                    'Something went wrong, and the status was not changed',
1999
-                    'event_espresso'
2000
-                ),
2001
-                __FILE__,
2002
-                __LINE__,
2003
-                __FUNCTION__
2004
-            );
2005
-        }
2006
-        if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
2007
-            $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
2008
-        } else {
2009
-            $route = array('action' => 'default');
2010
-        }
2011
-        // unset nonces
2012
-        foreach ($this->_req_data as $ref => $value) {
2013
-            if (strpos($ref, 'nonce') !== false) {
2014
-                unset($this->_req_data[ $ref ]);
2015
-                continue;
2016
-            }
2017
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
2018
-            $this->_req_data[ $ref ] = $value;
2019
-        }
2020
-        // merge request vars so that the reloaded list table contains any existing filter query params
2021
-        $route = array_merge($this->_req_data, $route);
2022
-        $this->_redirect_after_action($success, '', '', $route, true);
2023
-    }
2024
-
2025
-
2026
-    /**
2027
-     * incoming reg status change from reg details page.
2028
-     *
2029
-     * @return void
2030
-     */
2031
-    protected function _change_reg_status()
2032
-    {
2033
-        $this->_req_data['return'] = 'view_registration';
2034
-        // set notify based on whether the send notifications toggle is set or not
2035
-        $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
2036
-        // $notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
2037
-        $this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
2038
-            ? $this->_req_data['reg_status_change_form']['reg_status'] : '';
2039
-        switch ($this->_req_data['reg_status_change_form']['reg_status']) {
2040
-            case EEM_Registration::status_id_approved:
2041
-            case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
2042
-                $this->approve_registration($notify);
2043
-                break;
2044
-            case EEM_Registration::status_id_pending_payment:
2045
-            case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
2046
-                $this->pending_registration($notify);
2047
-                break;
2048
-            case EEM_Registration::status_id_not_approved:
2049
-            case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
2050
-                $this->not_approve_registration($notify);
2051
-                break;
2052
-            case EEM_Registration::status_id_declined:
2053
-            case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
2054
-                $this->decline_registration($notify);
2055
-                break;
2056
-            case EEM_Registration::status_id_cancelled:
2057
-            case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
2058
-                $this->cancel_registration($notify);
2059
-                break;
2060
-            case EEM_Registration::status_id_wait_list:
2061
-            case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
2062
-                $this->wait_list_registration($notify);
2063
-                break;
2064
-            case EEM_Registration::status_id_incomplete:
2065
-            default:
2066
-                $result['success'] = false;
2067
-                unset($this->_req_data['return']);
2068
-                $this->_reg_status_change_return('', false);
2069
-                break;
2070
-        }
2071
-    }
2072
-
2073
-
2074
-    /**
2075
-     * Callback for bulk action routes.
2076
-     * Note: although we could just register the singular route callbacks for each bulk action route as well, this
2077
-     * method was chosen so there is one central place all the registration status bulk actions are going through.
2078
-     * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
2079
-     * when an action is happening on just a single registration).
2080
-     *
2081
-     * @param      $action
2082
-     * @param bool $notify
2083
-     */
2084
-    protected function bulk_action_on_registrations($action, $notify = false)
2085
-    {
2086
-        do_action(
2087
-            'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
2088
-            $this,
2089
-            $action,
2090
-            $notify
2091
-        );
2092
-        $method = $action . '_registration';
2093
-        if (method_exists($this, $method)) {
2094
-            $this->$method($notify);
2095
-        }
2096
-    }
2097
-
2098
-
2099
-    /**
2100
-     * approve_registration
2101
-     *
2102
-     * @access protected
2103
-     * @param bool $notify whether or not to notify the registrant about their approval.
2104
-     * @return void
2105
-     */
2106
-    protected function approve_registration($notify = false)
2107
-    {
2108
-        $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
2109
-    }
2110
-
2111
-
2112
-    /**
2113
-     *        decline_registration
2114
-     *
2115
-     * @access protected
2116
-     * @param bool $notify whether or not to notify the registrant about their status change.
2117
-     * @return void
2118
-     */
2119
-    protected function decline_registration($notify = false)
2120
-    {
2121
-        $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
2122
-    }
2123
-
2124
-
2125
-    /**
2126
-     *        cancel_registration
2127
-     *
2128
-     * @access protected
2129
-     * @param bool $notify whether or not to notify the registrant about their status change.
2130
-     * @return void
2131
-     */
2132
-    protected function cancel_registration($notify = false)
2133
-    {
2134
-        $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
2135
-    }
2136
-
2137
-
2138
-    /**
2139
-     *        not_approve_registration
2140
-     *
2141
-     * @access protected
2142
-     * @param bool $notify whether or not to notify the registrant about their status change.
2143
-     * @return void
2144
-     */
2145
-    protected function not_approve_registration($notify = false)
2146
-    {
2147
-        $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
2148
-    }
2149
-
2150
-
2151
-    /**
2152
-     *        decline_registration
2153
-     *
2154
-     * @access protected
2155
-     * @param bool $notify whether or not to notify the registrant about their status change.
2156
-     * @return void
2157
-     */
2158
-    protected function pending_registration($notify = false)
2159
-    {
2160
-        $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
2161
-    }
2162
-
2163
-
2164
-    /**
2165
-     * waitlist_registration
2166
-     *
2167
-     * @access protected
2168
-     * @param bool $notify whether or not to notify the registrant about their status change.
2169
-     * @return void
2170
-     */
2171
-    protected function wait_list_registration($notify = false)
2172
-    {
2173
-        $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2174
-    }
2175
-
2176
-
2177
-    /**
2178
-     *        generates HTML for the Registration main meta box
2179
-     *
2180
-     * @access public
2181
-     * @return void
2182
-     * @throws DomainException
2183
-     * @throws EE_Error
2184
-     * @throws InvalidArgumentException
2185
-     * @throws InvalidDataTypeException
2186
-     * @throws InvalidInterfaceException
2187
-     * @throws ReflectionException
2188
-     * @throws EntityNotFoundException
2189
-     */
2190
-    public function _reg_details_meta_box()
2191
-    {
2192
-        EEH_Autoloader::register_line_item_display_autoloaders();
2193
-        EEH_Autoloader::register_line_item_filter_autoloaders();
2194
-        EE_Registry::instance()->load_helper('Line_Item');
2195
-        $transaction = $this->_registration->transaction() ? $this->_registration->transaction()
2196
-            : EE_Transaction::new_instance();
2197
-        $this->_session = $transaction->session_data();
2198
-        $filters = new EE_Line_Item_Filter_Collection();
2199
-        // $filters->add( new EE_Non_Zero_Line_Item_Filter() );
2200
-        $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2201
-        $line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2202
-            $filters,
2203
-            $transaction->total_line_item()
2204
-        );
2205
-        $filtered_line_item_tree = $line_item_filter_processor->process();
2206
-        $line_item_display = new EE_Line_Item_Display(
2207
-            'reg_admin_table',
2208
-            'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2209
-        );
2210
-        $this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2211
-            $filtered_line_item_tree,
2212
-            array('EE_Registration' => $this->_registration)
2213
-        );
2214
-        $attendee = $this->_registration->attendee();
2215
-        if (EE_Registry::instance()->CAP->current_user_can(
2216
-            'ee_read_transaction',
2217
-            'espresso_transactions_view_transaction'
2218
-        )) {
2219
-            $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2220
-                EE_Admin_Page::add_query_args_and_nonce(
2221
-                    array(
2222
-                        'action' => 'view_transaction',
2223
-                        'TXN_ID' => $transaction->ID(),
2224
-                    ),
2225
-                    TXN_ADMIN_URL
2226
-                ),
2227
-                esc_html__(' View Transaction', 'event_espresso'),
2228
-                'button secondary-button right',
2229
-                'dashicons dashicons-cart'
2230
-            );
2231
-        } else {
2232
-            $this->_template_args['view_transaction_button'] = '';
2233
-        }
2234
-        if ($attendee instanceof EE_Attendee
2235
-            && EE_Registry::instance()->CAP->current_user_can(
2236
-                'ee_send_message',
2237
-                'espresso_registrations_resend_registration'
2238
-            )
2239
-        ) {
2240
-            $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2241
-                EE_Admin_Page::add_query_args_and_nonce(
2242
-                    array(
2243
-                        'action'      => 'resend_registration',
2244
-                        '_REG_ID'     => $this->_registration->ID(),
2245
-                        'redirect_to' => 'view_registration',
2246
-                    ),
2247
-                    REG_ADMIN_URL
2248
-                ),
2249
-                esc_html__(' Resend Registration', 'event_espresso'),
2250
-                'button secondary-button right',
2251
-                'dashicons dashicons-email-alt'
2252
-            );
2253
-        } else {
2254
-            $this->_template_args['resend_registration_button'] = '';
2255
-        }
2256
-        $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2257
-        $payment = $transaction->get_first_related('Payment');
2258
-        $payment = ! $payment instanceof EE_Payment
2259
-            ? EE_Payment::new_instance()
2260
-            : $payment;
2261
-        $payment_method = $payment->get_first_related('Payment_Method');
2262
-        $payment_method = ! $payment_method instanceof EE_Payment_Method
2263
-            ? EE_Payment_Method::new_instance()
2264
-            : $payment_method;
2265
-        $reg_details = array(
2266
-            'payment_method'       => $payment_method->name(),
2267
-            'response_msg'         => $payment->gateway_response(),
2268
-            'registration_id'      => $this->_registration->get('REG_code'),
2269
-            'registration_session' => $this->_registration->session_ID(),
2270
-            'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2271
-            'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2272
-        );
2273
-        if (isset($reg_details['registration_id'])) {
2274
-            $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2275
-            $this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2276
-                'Registration ID',
2277
-                'event_espresso'
2278
-            );
2279
-            $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2280
-        }
2281
-        if (isset($reg_details['payment_method'])) {
2282
-            $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2283
-            $this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2284
-                'Most Recent Payment Method',
2285
-                'event_espresso'
2286
-            );
2287
-            $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2288
-            $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
2289
-            $this->_template_args['reg_details']['response_msg']['label'] = esc_html__(
2290
-                'Payment method response',
2291
-                'event_espresso'
2292
-            );
2293
-            $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2294
-        }
2295
-        $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2296
-        $this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2297
-            'Registration Session',
2298
-            'event_espresso'
2299
-        );
2300
-        $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2301
-        $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
2302
-        $this->_template_args['reg_details']['ip_address']['label'] = esc_html__(
2303
-            'Registration placed from IP',
2304
-            'event_espresso'
2305
-        );
2306
-        $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
2307
-        $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
2308
-        $this->_template_args['reg_details']['user_agent']['label'] = esc_html__(
2309
-            'Registrant User Agent',
2310
-            'event_espresso'
2311
-        );
2312
-        $this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
2313
-        $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
2314
-            array(
2315
-                'action'   => 'default',
2316
-                'event_id' => $this->_registration->event_ID(),
2317
-            ),
2318
-            REG_ADMIN_URL
2319
-        );
2320
-        $this->_template_args['REG_ID'] = $this->_registration->ID();
2321
-        $this->_template_args['event_id'] = $this->_registration->event_ID();
2322
-        $template_path =
2323
-            REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2324
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2325
-    }
2326
-
2327
-
2328
-    /**
2329
-     * generates HTML for the Registration Questions meta box.
2330
-     * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2331
-     * otherwise uses new forms system
2332
-     *
2333
-     * @access public
2334
-     * @return void
2335
-     * @throws DomainException
2336
-     * @throws EE_Error
2337
-     */
2338
-    public function _reg_questions_meta_box()
2339
-    {
2340
-        // allow someone to override this method entirely
2341
-        if (apply_filters(
2342
-            'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2343
-            true,
2344
-            $this,
2345
-            $this->_registration
2346
-        )) {
2347
-            $form = $this->_get_reg_custom_questions_form(
2348
-                $this->_registration->ID()
2349
-            );
2350
-            $this->_template_args['att_questions'] = count($form->subforms()) > 0
2351
-                ? $form->get_html_and_js()
2352
-                : '';
2353
-            $this->_template_args['reg_questions_form_action'] = 'edit_registration';
2354
-            $this->_template_args['REG_ID'] = $this->_registration->ID();
2355
-            $template_path =
2356
-                REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2357
-            echo EEH_Template::display_template($template_path, $this->_template_args, true);
2358
-        }
2359
-    }
2360
-
2361
-
2362
-    /**
2363
-     * form_before_question_group
2364
-     *
2365
-     * @deprecated    as of 4.8.32.rc.000
2366
-     * @access        public
2367
-     * @param        string $output
2368
-     * @return        string
2369
-     */
2370
-    public function form_before_question_group($output)
2371
-    {
2372
-        EE_Error::doing_it_wrong(
2373
-            __CLASS__ . '::' . __FUNCTION__,
2374
-            esc_html__(
2375
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2376
-                'event_espresso'
2377
-            ),
2378
-            '4.8.32.rc.000'
2379
-        );
2380
-        return '
1299
+		if (! empty($registration_status)) {
1300
+			$where['STS_ID'] = $registration_status;
1301
+		} else {
1302
+			// make sure we exclude incomplete registrations, but only if not trashed.
1303
+			if ($view === 'trash') {
1304
+				$where['REG_deleted'] = true;
1305
+			} elseif ($view === 'incomplete') {
1306
+				$where['STS_ID'] = EEM_Registration::status_id_incomplete;
1307
+			} else {
1308
+				$where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
1309
+			}
1310
+		}
1311
+		return $where;
1312
+	}
1313
+
1314
+
1315
+	/**
1316
+	 * Adds any provided date restraints to the where conditions for the registrations query.
1317
+	 *
1318
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1319
+	 * @return array
1320
+	 * @throws EE_Error
1321
+	 * @throws InvalidArgumentException
1322
+	 * @throws InvalidDataTypeException
1323
+	 * @throws InvalidInterfaceException
1324
+	 */
1325
+	protected function _add_date_to_where_conditions(array $request)
1326
+	{
1327
+		$where = array();
1328
+		$view = EEH_Array::is_set($request, 'status', '');
1329
+		$month_range = ! empty($request['month_range'])
1330
+			? sanitize_text_field($request['month_range'])
1331
+			: '';
1332
+		$retrieve_for_today = $view === 'today';
1333
+		$retrieve_for_this_month = $view === 'month';
1334
+
1335
+		if ($retrieve_for_today) {
1336
+			$now = date('Y-m-d', current_time('timestamp'));
1337
+			$where['REG_date'] = array(
1338
+				'BETWEEN',
1339
+				array(
1340
+					EEM_Registration::instance()->convert_datetime_for_query(
1341
+						'REG_date',
1342
+						$now . ' 00:00:00',
1343
+						'Y-m-d H:i:s'
1344
+					),
1345
+					EEM_Registration::instance()->convert_datetime_for_query(
1346
+						'REG_date',
1347
+						$now . ' 23:59:59',
1348
+						'Y-m-d H:i:s'
1349
+					),
1350
+				),
1351
+			);
1352
+		} elseif ($retrieve_for_this_month) {
1353
+			$current_year_and_month = date('Y-m', current_time('timestamp'));
1354
+			$days_this_month = date('t', current_time('timestamp'));
1355
+			$where['REG_date'] = array(
1356
+				'BETWEEN',
1357
+				array(
1358
+					EEM_Registration::instance()->convert_datetime_for_query(
1359
+						'REG_date',
1360
+						$current_year_and_month . '-01 00:00:00',
1361
+						'Y-m-d H:i:s'
1362
+					),
1363
+					EEM_Registration::instance()->convert_datetime_for_query(
1364
+						'REG_date',
1365
+						$current_year_and_month . '-' . $days_this_month . ' 23:59:59',
1366
+						'Y-m-d H:i:s'
1367
+					),
1368
+				),
1369
+			);
1370
+		} elseif ($month_range) {
1371
+			$pieces = explode(' ', $month_range, 3);
1372
+			$month_requested = ! empty($pieces[0])
1373
+				? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0]))
1374
+				: '';
1375
+			$year_requested = ! empty($pieces[1])
1376
+				? $pieces[1]
1377
+				: '';
1378
+			// if there is not a month or year then we can't go further
1379
+			if ($month_requested && $year_requested) {
1380
+				$days_in_month = date('t', strtotime($year_requested . '-' . $month_requested . '-' . '01'));
1381
+				$where['REG_date'] = array(
1382
+					'BETWEEN',
1383
+					array(
1384
+						EEM_Registration::instance()->convert_datetime_for_query(
1385
+							'REG_date',
1386
+							$year_requested . '-' . $month_requested . '-01 00:00:00',
1387
+							'Y-m-d H:i:s'
1388
+						),
1389
+						EEM_Registration::instance()->convert_datetime_for_query(
1390
+							'REG_date',
1391
+							$year_requested . '-' . $month_requested . '-' . $days_in_month . ' 23:59:59',
1392
+							'Y-m-d H:i:s'
1393
+						),
1394
+					),
1395
+				);
1396
+			}
1397
+		}
1398
+		return $where;
1399
+	}
1400
+
1401
+
1402
+	/**
1403
+	 * Adds any provided search restraints to the where conditions for the registrations query
1404
+	 *
1405
+	 * @param array $request usually the same as $this->_req_data but not necessarily
1406
+	 * @return array
1407
+	 */
1408
+	protected function _add_search_to_where_conditions(array $request)
1409
+	{
1410
+		$where = array();
1411
+		if (! empty($request['s'])) {
1412
+			$search_string = '%' . sanitize_text_field($request['s']) . '%';
1413
+			$where['OR*search_conditions'] = array(
1414
+				'Event.EVT_name'                          => array('LIKE', $search_string),
1415
+				'Event.EVT_desc'                          => array('LIKE', $search_string),
1416
+				'Event.EVT_short_desc'                    => array('LIKE', $search_string),
1417
+				'Attendee.ATT_full_name'                  => array('LIKE', $search_string),
1418
+				'Attendee.ATT_fname'                      => array('LIKE', $search_string),
1419
+				'Attendee.ATT_lname'                      => array('LIKE', $search_string),
1420
+				'Attendee.ATT_short_bio'                  => array('LIKE', $search_string),
1421
+				'Attendee.ATT_email'                      => array('LIKE', $search_string),
1422
+				'Attendee.ATT_address'                    => array('LIKE', $search_string),
1423
+				'Attendee.ATT_address2'                   => array('LIKE', $search_string),
1424
+				'Attendee.ATT_city'                       => array('LIKE', $search_string),
1425
+				'REG_final_price'                         => array('LIKE', $search_string),
1426
+				'REG_code'                                => array('LIKE', $search_string),
1427
+				'REG_count'                               => array('LIKE', $search_string),
1428
+				'REG_group_size'                          => array('LIKE', $search_string),
1429
+				'Ticket.TKT_name'                         => array('LIKE', $search_string),
1430
+				'Ticket.TKT_description'                  => array('LIKE', $search_string),
1431
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string),
1432
+			);
1433
+		}
1434
+		return $where;
1435
+	}
1436
+
1437
+
1438
+	/**
1439
+	 * Sets up the where conditions for the registrations query.
1440
+	 *
1441
+	 * @param array $request
1442
+	 * @return array
1443
+	 * @throws EE_Error
1444
+	 */
1445
+	protected function _get_where_conditions_for_registrations_query($request)
1446
+	{
1447
+		return apply_filters(
1448
+			'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
1449
+			array_merge(
1450
+				$this->addAttendeeIdToWhereConditions($request),
1451
+				$this->_add_event_id_to_where_conditions($request),
1452
+				$this->_add_category_id_to_where_conditions($request),
1453
+				$this->_add_datetime_id_to_where_conditions($request),
1454
+				$this->_add_registration_status_to_where_conditions($request),
1455
+				$this->_add_date_to_where_conditions($request),
1456
+				$this->_add_search_to_where_conditions($request)
1457
+			),
1458
+			$request
1459
+		);
1460
+	}
1461
+
1462
+
1463
+	/**
1464
+	 * Sets up the orderby for the registrations query.
1465
+	 *
1466
+	 * @return array
1467
+	 */
1468
+	protected function _get_orderby_for_registrations_query()
1469
+	{
1470
+		$orderby_field = ! empty($this->_req_data['orderby'])
1471
+			? sanitize_text_field($this->_req_data['orderby'])
1472
+			: '_REG_date';
1473
+		switch ($orderby_field) {
1474
+			case '_REG_ID':
1475
+				$orderby = array('REG_ID');
1476
+				break;
1477
+			case '_Reg_status':
1478
+				$orderby = array('STS_ID');
1479
+				break;
1480
+			case 'ATT_fname':
1481
+				$orderby = array('Attendee.ATT_fname', 'Attendee.ATT_lname');
1482
+				break;
1483
+			case 'ATT_lname':
1484
+				$orderby = array('Attendee.ATT_lname', 'Attendee.ATT_fname');
1485
+				break;
1486
+			case 'event_name':
1487
+				$orderby = array('Event.EVT_name');
1488
+				break;
1489
+			case 'DTT_EVT_start':
1490
+				$orderby = array('Event.Datetime.DTT_EVT_start');
1491
+				break;
1492
+			case '_REG_date':
1493
+				$orderby = array('REG_date');
1494
+				break;
1495
+			default:
1496
+				$orderby = array($orderby_field);
1497
+				break;
1498
+		}
1499
+
1500
+		// order
1501
+		$order = ! empty($this->_req_data['order'])
1502
+			? sanitize_text_field($this->_req_data['order'])
1503
+			: 'DESC';
1504
+		$orderby = array_combine(
1505
+			$orderby,
1506
+			array_fill(0, count($orderby), $order)
1507
+		);
1508
+		// because there are many registrations with the same date, define
1509
+		// a secondary way to order them, otherwise MySQL seems to be a bit random
1510
+		if (empty($orderby['REG_ID'])) {
1511
+			$orderby['REG_ID'] = $order;
1512
+		}
1513
+
1514
+		$orderby = apply_filters(
1515
+			'FHEE__Registrations_Admin_Page___get_orderby_for_registrations_query',
1516
+			$orderby,
1517
+			$this->_req_data
1518
+		);
1519
+
1520
+		return array('order_by' => $orderby);
1521
+	}
1522
+
1523
+
1524
+	/**
1525
+	 * Sets up the limit for the registrations query.
1526
+	 *
1527
+	 * @param $per_page
1528
+	 * @return array
1529
+	 */
1530
+	protected function _get_limit($per_page)
1531
+	{
1532
+		$current_page = ! empty($this->_req_data['paged'])
1533
+			? absint($this->_req_data['paged'])
1534
+			: 1;
1535
+		$per_page = ! empty($this->_req_data['perpage'])
1536
+			? $this->_req_data['perpage']
1537
+			: $per_page;
1538
+
1539
+		// -1 means return all results so get out if that's set.
1540
+		if ((int) $per_page === -1) {
1541
+			return array();
1542
+		}
1543
+		$per_page = absint($per_page);
1544
+		$offset = ($current_page - 1) * $per_page;
1545
+		return array('limit' => array($offset, $per_page));
1546
+	}
1547
+
1548
+
1549
+	public function get_registration_status_array()
1550
+	{
1551
+		return self::$_reg_status;
1552
+	}
1553
+
1554
+
1555
+
1556
+
1557
+	/***************************************        REGISTRATION DETAILS        ***************************************/
1558
+	/**
1559
+	 *        generates HTML for the View Registration Details Admin page
1560
+	 *
1561
+	 * @access protected
1562
+	 * @return void
1563
+	 * @throws DomainException
1564
+	 * @throws EE_Error
1565
+	 * @throws InvalidArgumentException
1566
+	 * @throws InvalidDataTypeException
1567
+	 * @throws InvalidInterfaceException
1568
+	 * @throws EntityNotFoundException
1569
+	 */
1570
+	protected function _registration_details()
1571
+	{
1572
+		$this->_template_args = array();
1573
+		$this->_set_registration_object();
1574
+		if (is_object($this->_registration)) {
1575
+			$transaction = $this->_registration->transaction()
1576
+				? $this->_registration->transaction()
1577
+				: EE_Transaction::new_instance();
1578
+			$this->_session = $transaction->session_data();
1579
+			$event_id = $this->_registration->event_ID();
1580
+			$this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1581
+			$this->_template_args['reg_nmbr']['label'] = esc_html__('Registration Number', 'event_espresso');
1582
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date');
1583
+			$this->_template_args['reg_datetime']['label'] = esc_html__('Date', 'event_espresso');
1584
+			$this->_template_args['grand_total'] = $transaction->total();
1585
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1586
+			// link back to overview
1587
+			$this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1588
+			$this->_template_args['registration'] = $this->_registration;
1589
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(
1590
+				array(
1591
+					'action'   => 'default',
1592
+					'event_id' => $event_id,
1593
+				),
1594
+				REG_ADMIN_URL
1595
+			);
1596
+			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(
1597
+				array(
1598
+					'action' => 'default',
1599
+					'EVT_ID' => $event_id,
1600
+					'page'   => 'espresso_transactions',
1601
+				),
1602
+				admin_url('admin.php')
1603
+			);
1604
+			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
1605
+				array(
1606
+					'page'   => 'espresso_events',
1607
+					'action' => 'edit',
1608
+					'post'   => $event_id,
1609
+				),
1610
+				admin_url('admin.php')
1611
+			);
1612
+			// next and previous links
1613
+			$next_reg = $this->_registration->next(
1614
+				null,
1615
+				array(),
1616
+				'REG_ID'
1617
+			);
1618
+			$this->_template_args['next_registration'] = $next_reg
1619
+				? $this->_next_link(
1620
+					EE_Admin_Page::add_query_args_and_nonce(
1621
+						array(
1622
+							'action'  => 'view_registration',
1623
+							'_REG_ID' => $next_reg['REG_ID'],
1624
+						),
1625
+						REG_ADMIN_URL
1626
+					),
1627
+					'dashicons dashicons-arrow-right ee-icon-size-22'
1628
+				)
1629
+				: '';
1630
+			$previous_reg = $this->_registration->previous(
1631
+				null,
1632
+				array(),
1633
+				'REG_ID'
1634
+			);
1635
+			$this->_template_args['previous_registration'] = $previous_reg
1636
+				? $this->_previous_link(
1637
+					EE_Admin_Page::add_query_args_and_nonce(
1638
+						array(
1639
+							'action'  => 'view_registration',
1640
+							'_REG_ID' => $previous_reg['REG_ID'],
1641
+						),
1642
+						REG_ADMIN_URL
1643
+					),
1644
+					'dashicons dashicons-arrow-left ee-icon-size-22'
1645
+				)
1646
+				: '';
1647
+			// grab header
1648
+			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1649
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
1650
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template(
1651
+				$template_path,
1652
+				$this->_template_args,
1653
+				true
1654
+			);
1655
+		} else {
1656
+			$this->_template_args['admin_page_header'] = $this->display_espresso_notices();
1657
+		}
1658
+		// the details template wrapper
1659
+		$this->display_admin_page_with_sidebar();
1660
+	}
1661
+
1662
+
1663
+	protected function _registration_details_metaboxes()
1664
+	{
1665
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1666
+		$this->_set_registration_object();
1667
+		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1668
+		add_meta_box(
1669
+			'edit-reg-status-mbox',
1670
+			esc_html__('Registration Status', 'event_espresso'),
1671
+			array($this, 'set_reg_status_buttons_metabox'),
1672
+			$this->wp_page_slug,
1673
+			'normal',
1674
+			'high'
1675
+		);
1676
+		add_meta_box(
1677
+			'edit-reg-details-mbox',
1678
+			esc_html__('Registration Details', 'event_espresso'),
1679
+			array($this, '_reg_details_meta_box'),
1680
+			$this->wp_page_slug,
1681
+			'normal',
1682
+			'high'
1683
+		);
1684
+		if ($attendee instanceof EE_Attendee
1685
+			&& EE_Registry::instance()->CAP->current_user_can(
1686
+				'ee_edit_registration',
1687
+				'edit-reg-questions-mbox',
1688
+				$this->_registration->ID()
1689
+			)
1690
+		) {
1691
+			add_meta_box(
1692
+				'edit-reg-questions-mbox',
1693
+				esc_html__('Registration Form Answers', 'event_espresso'),
1694
+				array($this, '_reg_questions_meta_box'),
1695
+				$this->wp_page_slug,
1696
+				'normal',
1697
+				'high'
1698
+			);
1699
+		}
1700
+		add_meta_box(
1701
+			'edit-reg-registrant-mbox',
1702
+			esc_html__('Contact Details', 'event_espresso'),
1703
+			array($this, '_reg_registrant_side_meta_box'),
1704
+			$this->wp_page_slug,
1705
+			'side',
1706
+			'high'
1707
+		);
1708
+		if ($this->_registration->group_size() > 1) {
1709
+			add_meta_box(
1710
+				'edit-reg-attendees-mbox',
1711
+				esc_html__('Other Registrations in this Transaction', 'event_espresso'),
1712
+				array($this, '_reg_attendees_meta_box'),
1713
+				$this->wp_page_slug,
1714
+				'normal',
1715
+				'high'
1716
+			);
1717
+		}
1718
+	}
1719
+
1720
+
1721
+	/**
1722
+	 * set_reg_status_buttons_metabox
1723
+	 *
1724
+	 * @access protected
1725
+	 * @return string
1726
+	 * @throws \EE_Error
1727
+	 */
1728
+	public function set_reg_status_buttons_metabox()
1729
+	{
1730
+		$this->_set_registration_object();
1731
+		$change_reg_status_form = $this->_generate_reg_status_change_form();
1732
+		echo $change_reg_status_form->form_open(
1733
+			self::add_query_args_and_nonce(
1734
+				array(
1735
+					'action' => 'change_reg_status',
1736
+				),
1737
+				REG_ADMIN_URL
1738
+			)
1739
+		);
1740
+		echo $change_reg_status_form->get_html();
1741
+		echo $change_reg_status_form->form_close();
1742
+	}
1743
+
1744
+
1745
+	/**
1746
+	 * @return EE_Form_Section_Proper
1747
+	 * @throws EE_Error
1748
+	 * @throws InvalidArgumentException
1749
+	 * @throws InvalidDataTypeException
1750
+	 * @throws InvalidInterfaceException
1751
+	 * @throws \EventEspresso\core\exceptions\EntityNotFoundException
1752
+	 */
1753
+	protected function _generate_reg_status_change_form()
1754
+	{
1755
+		return new EE_Form_Section_Proper(
1756
+			array(
1757
+				'name'            => 'reg_status_change_form',
1758
+				'html_id'         => 'reg-status-change-form',
1759
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1760
+				'subsections'     => array(
1761
+					'return'             => new EE_Hidden_Input(
1762
+						array(
1763
+							'name'    => 'return',
1764
+							'default' => 'view_registration',
1765
+						)
1766
+					),
1767
+					'REG_ID'             => new EE_Hidden_Input(
1768
+						array(
1769
+							'name'    => 'REG_ID',
1770
+							'default' => $this->_registration->ID(),
1771
+						)
1772
+					),
1773
+					'current_status'     => new EE_Form_Section_HTML(
1774
+						EEH_HTML::tr(
1775
+							EEH_HTML::th(
1776
+								EEH_HTML::label(
1777
+									EEH_HTML::strong(
1778
+										esc_html__('Current Registration Status', 'event_espresso')
1779
+									)
1780
+								)
1781
+							)
1782
+							. EEH_HTML::td(
1783
+								EEH_HTML::strong(
1784
+									$this->_registration->pretty_status(),
1785
+									'',
1786
+									'status-' . $this->_registration->status_ID(),
1787
+									'line-height: 1em; font-size: 1.5em; font-weight: bold;'
1788
+								)
1789
+							)
1790
+						)
1791
+					),
1792
+					'reg_status'         => new EE_Select_Input(
1793
+						$this->_get_reg_statuses(),
1794
+						array(
1795
+							'html_label_text' => esc_html__('Change Registration Status to', 'event_espresso'),
1796
+							'default'         => $this->_registration->status_ID(),
1797
+						)
1798
+					),
1799
+					'send_notifications' => new EE_Yes_No_Input(
1800
+						array(
1801
+							'html_label_text' => esc_html__('Send Related Messages', 'event_espresso'),
1802
+							'default'         => false,
1803
+							'html_help_text'  => esc_html__(
1804
+								'If set to "Yes", then the related messages will be sent to the registrant.',
1805
+								'event_espresso'
1806
+							),
1807
+						)
1808
+					),
1809
+					'submit'             => new EE_Submit_Input(
1810
+						array(
1811
+							'html_class'      => 'button-primary',
1812
+							'html_label_text' => '&nbsp;',
1813
+							'default'         => esc_html__('Update Registration Status', 'event_espresso'),
1814
+						)
1815
+					),
1816
+				),
1817
+			)
1818
+		);
1819
+	}
1820
+
1821
+
1822
+	/**
1823
+	 * Returns an array of all the buttons for the various statuses and switch status actions
1824
+	 *
1825
+	 * @return array
1826
+	 * @throws EE_Error
1827
+	 * @throws InvalidArgumentException
1828
+	 * @throws InvalidDataTypeException
1829
+	 * @throws InvalidInterfaceException
1830
+	 * @throws EntityNotFoundException
1831
+	 */
1832
+	protected function _get_reg_statuses()
1833
+	{
1834
+		$reg_status_array = EEM_Registration::instance()->reg_status_array();
1835
+		unset($reg_status_array[ EEM_Registration::status_id_incomplete ]);
1836
+		// get current reg status
1837
+		$current_status = $this->_registration->status_ID();
1838
+		// is registration for free event? This will determine whether to display the pending payment option
1839
+		if ($current_status !== EEM_Registration::status_id_pending_payment
1840
+			&& EEH_Money::compare_floats($this->_registration->ticket()->price(), 0.00)
1841
+		) {
1842
+			unset($reg_status_array[ EEM_Registration::status_id_pending_payment ]);
1843
+		}
1844
+		return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence');
1845
+	}
1846
+
1847
+
1848
+	/**
1849
+	 * This method is used when using _REG_ID from request which may or may not be an array of reg_ids.
1850
+	 *
1851
+	 * @param bool $status REG status given for changing registrations to.
1852
+	 * @param bool $notify Whether to send messages notifications or not.
1853
+	 * @return array (array with reg_id(s) updated and whether update was successful.
1854
+	 * @throws EE_Error
1855
+	 * @throws InvalidArgumentException
1856
+	 * @throws InvalidDataTypeException
1857
+	 * @throws InvalidInterfaceException
1858
+	 * @throws ReflectionException
1859
+	 * @throws RuntimeException
1860
+	 * @throws EntityNotFoundException
1861
+	 */
1862
+	protected function _set_registration_status_from_request($status = false, $notify = false)
1863
+	{
1864
+		if (isset($this->_req_data['reg_status_change_form'])) {
1865
+			$REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID'])
1866
+				? (array) $this->_req_data['reg_status_change_form']['REG_ID']
1867
+				: array();
1868
+		} else {
1869
+			$REG_IDs = isset($this->_req_data['_REG_ID'])
1870
+				? (array) $this->_req_data['_REG_ID']
1871
+				: array();
1872
+		}
1873
+		// sanitize $REG_IDs
1874
+		$REG_IDs = array_map('absint', $REG_IDs);
1875
+		// and remove empty entries
1876
+		$REG_IDs = array_filter($REG_IDs);
1877
+
1878
+		$result = $this->_set_registration_status($REG_IDs, $status, $notify);
1879
+
1880
+		/**
1881
+		 * Set and filter $_req_data['_REG_ID'] for any potential future messages notifications.
1882
+		 * Currently this value is used downstream by the _process_resend_registration method.
1883
+		 *
1884
+		 * @param int|array                $registration_ids The registration ids that have had their status changed successfully.
1885
+		 * @param bool                     $status           The status registrations were changed to.
1886
+		 * @param bool                     $success          If the status was changed successfully for all registrations.
1887
+		 * @param Registrations_Admin_Page $admin_page_object
1888
+		 */
1889
+		$this->_req_data['_REG_ID'] = apply_filters(
1890
+			'FHEE__Registrations_Admin_Page___set_registration_status_from_request__REG_IDs',
1891
+			$result['REG_ID'],
1892
+			$status,
1893
+			$result['success'],
1894
+			$this
1895
+		);
1896
+
1897
+		// notify?
1898
+		if ($notify
1899
+			&& $result['success']
1900
+			&& ! empty($this->_req_data['_REG_ID'])
1901
+			&& EE_Registry::instance()->CAP->current_user_can(
1902
+				'ee_send_message',
1903
+				'espresso_registrations_resend_registration'
1904
+			)
1905
+		) {
1906
+			$this->_process_resend_registration();
1907
+		}
1908
+		return $result;
1909
+	}
1910
+
1911
+
1912
+	/**
1913
+	 * Set the registration status for the given reg_id (which may or may not be an array, it gets typecast to an
1914
+	 * array). Note, this method does NOT take care of possible notifications.  That is required by calling code.
1915
+	 *
1916
+	 * @param array  $REG_IDs
1917
+	 * @param string $status
1918
+	 * @param bool   $notify  Used to indicate whether notification was requested or not.  This determines the context
1919
+	 *                        slug sent with setting the registration status.
1920
+	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as
1921
+	 * @throws EE_Error
1922
+	 * @throws InvalidArgumentException
1923
+	 * @throws InvalidDataTypeException
1924
+	 * @throws InvalidInterfaceException
1925
+	 * @throws ReflectionException
1926
+	 * @throws RuntimeException
1927
+	 * @throws EntityNotFoundException
1928
+	 */
1929
+	protected function _set_registration_status($REG_IDs = array(), $status = '', $notify = false)
1930
+	{
1931
+		$success = false;
1932
+		// typecast $REG_IDs
1933
+		$REG_IDs = (array) $REG_IDs;
1934
+		if (! empty($REG_IDs)) {
1935
+			$success = true;
1936
+			// set default status if none is passed
1937
+			$status = $status ? $status : EEM_Registration::status_id_pending_payment;
1938
+			$status_context = $notify
1939
+				? Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
1940
+				: Domain::CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN;
1941
+			// loop through REG_ID's and change status
1942
+			foreach ($REG_IDs as $REG_ID) {
1943
+				$registration = EEM_Registration::instance()->get_one_by_ID($REG_ID);
1944
+				if ($registration instanceof EE_Registration) {
1945
+					$registration->set_status(
1946
+						$status,
1947
+						false,
1948
+						new Context(
1949
+							$status_context,
1950
+							esc_html__(
1951
+								'Manually triggered status change on a Registration Admin Page route.',
1952
+								'event_espresso'
1953
+							)
1954
+						)
1955
+					);
1956
+					$result = $registration->save();
1957
+					// verifying explicit fails because update *may* just return 0 for 0 rows affected
1958
+					$success = $result !== false ? $success : false;
1959
+				}
1960
+			}
1961
+		}
1962
+
1963
+		// return $success and processed registrations
1964
+		return array('REG_ID' => $REG_IDs, 'success' => $success);
1965
+	}
1966
+
1967
+
1968
+	/**
1969
+	 * Common logic for setting up success message and redirecting to appropriate route
1970
+	 *
1971
+	 * @param  string $STS_ID status id for the registration changed to
1972
+	 * @param   bool  $notify indicates whether the _set_registration_status_from_request does notifications or not.
1973
+	 * @return void
1974
+	 * @throws EE_Error
1975
+	 */
1976
+	protected function _reg_status_change_return($STS_ID, $notify = false)
1977
+	{
1978
+		$result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify)
1979
+			: array('success' => false);
1980
+		$success = isset($result['success']) && $result['success'];
1981
+		// setup success message
1982
+		if ($success) {
1983
+			if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) {
1984
+				$msg = sprintf(
1985
+					esc_html__('Registration status has been set to %s', 'event_espresso'),
1986
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1987
+				);
1988
+			} else {
1989
+				$msg = sprintf(
1990
+					esc_html__('Registrations have been set to %s.', 'event_espresso'),
1991
+					EEH_Template::pretty_status($STS_ID, false, 'lower')
1992
+				);
1993
+			}
1994
+			EE_Error::add_success($msg);
1995
+		} else {
1996
+			EE_Error::add_error(
1997
+				esc_html__(
1998
+					'Something went wrong, and the status was not changed',
1999
+					'event_espresso'
2000
+				),
2001
+				__FILE__,
2002
+				__LINE__,
2003
+				__FUNCTION__
2004
+			);
2005
+		}
2006
+		if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') {
2007
+			$route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID']));
2008
+		} else {
2009
+			$route = array('action' => 'default');
2010
+		}
2011
+		// unset nonces
2012
+		foreach ($this->_req_data as $ref => $value) {
2013
+			if (strpos($ref, 'nonce') !== false) {
2014
+				unset($this->_req_data[ $ref ]);
2015
+				continue;
2016
+			}
2017
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
2018
+			$this->_req_data[ $ref ] = $value;
2019
+		}
2020
+		// merge request vars so that the reloaded list table contains any existing filter query params
2021
+		$route = array_merge($this->_req_data, $route);
2022
+		$this->_redirect_after_action($success, '', '', $route, true);
2023
+	}
2024
+
2025
+
2026
+	/**
2027
+	 * incoming reg status change from reg details page.
2028
+	 *
2029
+	 * @return void
2030
+	 */
2031
+	protected function _change_reg_status()
2032
+	{
2033
+		$this->_req_data['return'] = 'view_registration';
2034
+		// set notify based on whether the send notifications toggle is set or not
2035
+		$notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']);
2036
+		// $notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
2037
+		$this->_req_data['reg_status_change_form']['reg_status'] = isset($this->_req_data['reg_status_change_form']['reg_status'])
2038
+			? $this->_req_data['reg_status_change_form']['reg_status'] : '';
2039
+		switch ($this->_req_data['reg_status_change_form']['reg_status']) {
2040
+			case EEM_Registration::status_id_approved:
2041
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'):
2042
+				$this->approve_registration($notify);
2043
+				break;
2044
+			case EEM_Registration::status_id_pending_payment:
2045
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'):
2046
+				$this->pending_registration($notify);
2047
+				break;
2048
+			case EEM_Registration::status_id_not_approved:
2049
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'):
2050
+				$this->not_approve_registration($notify);
2051
+				break;
2052
+			case EEM_Registration::status_id_declined:
2053
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'):
2054
+				$this->decline_registration($notify);
2055
+				break;
2056
+			case EEM_Registration::status_id_cancelled:
2057
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'):
2058
+				$this->cancel_registration($notify);
2059
+				break;
2060
+			case EEM_Registration::status_id_wait_list:
2061
+			case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'):
2062
+				$this->wait_list_registration($notify);
2063
+				break;
2064
+			case EEM_Registration::status_id_incomplete:
2065
+			default:
2066
+				$result['success'] = false;
2067
+				unset($this->_req_data['return']);
2068
+				$this->_reg_status_change_return('', false);
2069
+				break;
2070
+		}
2071
+	}
2072
+
2073
+
2074
+	/**
2075
+	 * Callback for bulk action routes.
2076
+	 * Note: although we could just register the singular route callbacks for each bulk action route as well, this
2077
+	 * method was chosen so there is one central place all the registration status bulk actions are going through.
2078
+	 * Potentially, this provides an easier place to locate logic that is specific to these bulk actions (as opposed to
2079
+	 * when an action is happening on just a single registration).
2080
+	 *
2081
+	 * @param      $action
2082
+	 * @param bool $notify
2083
+	 */
2084
+	protected function bulk_action_on_registrations($action, $notify = false)
2085
+	{
2086
+		do_action(
2087
+			'AHEE__Registrations_Admin_Page__bulk_action_on_registrations__before_execution',
2088
+			$this,
2089
+			$action,
2090
+			$notify
2091
+		);
2092
+		$method = $action . '_registration';
2093
+		if (method_exists($this, $method)) {
2094
+			$this->$method($notify);
2095
+		}
2096
+	}
2097
+
2098
+
2099
+	/**
2100
+	 * approve_registration
2101
+	 *
2102
+	 * @access protected
2103
+	 * @param bool $notify whether or not to notify the registrant about their approval.
2104
+	 * @return void
2105
+	 */
2106
+	protected function approve_registration($notify = false)
2107
+	{
2108
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
2109
+	}
2110
+
2111
+
2112
+	/**
2113
+	 *        decline_registration
2114
+	 *
2115
+	 * @access protected
2116
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2117
+	 * @return void
2118
+	 */
2119
+	protected function decline_registration($notify = false)
2120
+	{
2121
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
2122
+	}
2123
+
2124
+
2125
+	/**
2126
+	 *        cancel_registration
2127
+	 *
2128
+	 * @access protected
2129
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2130
+	 * @return void
2131
+	 */
2132
+	protected function cancel_registration($notify = false)
2133
+	{
2134
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
2135
+	}
2136
+
2137
+
2138
+	/**
2139
+	 *        not_approve_registration
2140
+	 *
2141
+	 * @access protected
2142
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2143
+	 * @return void
2144
+	 */
2145
+	protected function not_approve_registration($notify = false)
2146
+	{
2147
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
2148
+	}
2149
+
2150
+
2151
+	/**
2152
+	 *        decline_registration
2153
+	 *
2154
+	 * @access protected
2155
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2156
+	 * @return void
2157
+	 */
2158
+	protected function pending_registration($notify = false)
2159
+	{
2160
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
2161
+	}
2162
+
2163
+
2164
+	/**
2165
+	 * waitlist_registration
2166
+	 *
2167
+	 * @access protected
2168
+	 * @param bool $notify whether or not to notify the registrant about their status change.
2169
+	 * @return void
2170
+	 */
2171
+	protected function wait_list_registration($notify = false)
2172
+	{
2173
+		$this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify);
2174
+	}
2175
+
2176
+
2177
+	/**
2178
+	 *        generates HTML for the Registration main meta box
2179
+	 *
2180
+	 * @access public
2181
+	 * @return void
2182
+	 * @throws DomainException
2183
+	 * @throws EE_Error
2184
+	 * @throws InvalidArgumentException
2185
+	 * @throws InvalidDataTypeException
2186
+	 * @throws InvalidInterfaceException
2187
+	 * @throws ReflectionException
2188
+	 * @throws EntityNotFoundException
2189
+	 */
2190
+	public function _reg_details_meta_box()
2191
+	{
2192
+		EEH_Autoloader::register_line_item_display_autoloaders();
2193
+		EEH_Autoloader::register_line_item_filter_autoloaders();
2194
+		EE_Registry::instance()->load_helper('Line_Item');
2195
+		$transaction = $this->_registration->transaction() ? $this->_registration->transaction()
2196
+			: EE_Transaction::new_instance();
2197
+		$this->_session = $transaction->session_data();
2198
+		$filters = new EE_Line_Item_Filter_Collection();
2199
+		// $filters->add( new EE_Non_Zero_Line_Item_Filter() );
2200
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
2201
+		$line_item_filter_processor = new EE_Line_Item_Filter_Processor(
2202
+			$filters,
2203
+			$transaction->total_line_item()
2204
+		);
2205
+		$filtered_line_item_tree = $line_item_filter_processor->process();
2206
+		$line_item_display = new EE_Line_Item_Display(
2207
+			'reg_admin_table',
2208
+			'EE_Admin_Table_Registration_Line_Item_Display_Strategy'
2209
+		);
2210
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item(
2211
+			$filtered_line_item_tree,
2212
+			array('EE_Registration' => $this->_registration)
2213
+		);
2214
+		$attendee = $this->_registration->attendee();
2215
+		if (EE_Registry::instance()->CAP->current_user_can(
2216
+			'ee_read_transaction',
2217
+			'espresso_transactions_view_transaction'
2218
+		)) {
2219
+			$this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link(
2220
+				EE_Admin_Page::add_query_args_and_nonce(
2221
+					array(
2222
+						'action' => 'view_transaction',
2223
+						'TXN_ID' => $transaction->ID(),
2224
+					),
2225
+					TXN_ADMIN_URL
2226
+				),
2227
+				esc_html__(' View Transaction', 'event_espresso'),
2228
+				'button secondary-button right',
2229
+				'dashicons dashicons-cart'
2230
+			);
2231
+		} else {
2232
+			$this->_template_args['view_transaction_button'] = '';
2233
+		}
2234
+		if ($attendee instanceof EE_Attendee
2235
+			&& EE_Registry::instance()->CAP->current_user_can(
2236
+				'ee_send_message',
2237
+				'espresso_registrations_resend_registration'
2238
+			)
2239
+		) {
2240
+			$this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link(
2241
+				EE_Admin_Page::add_query_args_and_nonce(
2242
+					array(
2243
+						'action'      => 'resend_registration',
2244
+						'_REG_ID'     => $this->_registration->ID(),
2245
+						'redirect_to' => 'view_registration',
2246
+					),
2247
+					REG_ADMIN_URL
2248
+				),
2249
+				esc_html__(' Resend Registration', 'event_espresso'),
2250
+				'button secondary-button right',
2251
+				'dashicons dashicons-email-alt'
2252
+			);
2253
+		} else {
2254
+			$this->_template_args['resend_registration_button'] = '';
2255
+		}
2256
+		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2257
+		$payment = $transaction->get_first_related('Payment');
2258
+		$payment = ! $payment instanceof EE_Payment
2259
+			? EE_Payment::new_instance()
2260
+			: $payment;
2261
+		$payment_method = $payment->get_first_related('Payment_Method');
2262
+		$payment_method = ! $payment_method instanceof EE_Payment_Method
2263
+			? EE_Payment_Method::new_instance()
2264
+			: $payment_method;
2265
+		$reg_details = array(
2266
+			'payment_method'       => $payment_method->name(),
2267
+			'response_msg'         => $payment->gateway_response(),
2268
+			'registration_id'      => $this->_registration->get('REG_code'),
2269
+			'registration_session' => $this->_registration->session_ID(),
2270
+			'ip_address'           => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
2271
+			'user_agent'           => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
2272
+		);
2273
+		if (isset($reg_details['registration_id'])) {
2274
+			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
2275
+			$this->_template_args['reg_details']['registration_id']['label'] = esc_html__(
2276
+				'Registration ID',
2277
+				'event_espresso'
2278
+			);
2279
+			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
2280
+		}
2281
+		if (isset($reg_details['payment_method'])) {
2282
+			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
2283
+			$this->_template_args['reg_details']['payment_method']['label'] = esc_html__(
2284
+				'Most Recent Payment Method',
2285
+				'event_espresso'
2286
+			);
2287
+			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
2288
+			$this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
2289
+			$this->_template_args['reg_details']['response_msg']['label'] = esc_html__(
2290
+				'Payment method response',
2291
+				'event_espresso'
2292
+			);
2293
+			$this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
2294
+		}
2295
+		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
2296
+		$this->_template_args['reg_details']['registration_session']['label'] = esc_html__(
2297
+			'Registration Session',
2298
+			'event_espresso'
2299
+		);
2300
+		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
2301
+		$this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
2302
+		$this->_template_args['reg_details']['ip_address']['label'] = esc_html__(
2303
+			'Registration placed from IP',
2304
+			'event_espresso'
2305
+		);
2306
+		$this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
2307
+		$this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
2308
+		$this->_template_args['reg_details']['user_agent']['label'] = esc_html__(
2309
+			'Registrant User Agent',
2310
+			'event_espresso'
2311
+		);
2312
+		$this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
2313
+		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(
2314
+			array(
2315
+				'action'   => 'default',
2316
+				'event_id' => $this->_registration->event_ID(),
2317
+			),
2318
+			REG_ADMIN_URL
2319
+		);
2320
+		$this->_template_args['REG_ID'] = $this->_registration->ID();
2321
+		$this->_template_args['event_id'] = $this->_registration->event_ID();
2322
+		$template_path =
2323
+			REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
2324
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2325
+	}
2326
+
2327
+
2328
+	/**
2329
+	 * generates HTML for the Registration Questions meta box.
2330
+	 * If pre-4.8.32.rc.000 hooks are used, uses old methods (with its filters),
2331
+	 * otherwise uses new forms system
2332
+	 *
2333
+	 * @access public
2334
+	 * @return void
2335
+	 * @throws DomainException
2336
+	 * @throws EE_Error
2337
+	 */
2338
+	public function _reg_questions_meta_box()
2339
+	{
2340
+		// allow someone to override this method entirely
2341
+		if (apply_filters(
2342
+			'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
2343
+			true,
2344
+			$this,
2345
+			$this->_registration
2346
+		)) {
2347
+			$form = $this->_get_reg_custom_questions_form(
2348
+				$this->_registration->ID()
2349
+			);
2350
+			$this->_template_args['att_questions'] = count($form->subforms()) > 0
2351
+				? $form->get_html_and_js()
2352
+				: '';
2353
+			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
2354
+			$this->_template_args['REG_ID'] = $this->_registration->ID();
2355
+			$template_path =
2356
+				REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
2357
+			echo EEH_Template::display_template($template_path, $this->_template_args, true);
2358
+		}
2359
+	}
2360
+
2361
+
2362
+	/**
2363
+	 * form_before_question_group
2364
+	 *
2365
+	 * @deprecated    as of 4.8.32.rc.000
2366
+	 * @access        public
2367
+	 * @param        string $output
2368
+	 * @return        string
2369
+	 */
2370
+	public function form_before_question_group($output)
2371
+	{
2372
+		EE_Error::doing_it_wrong(
2373
+			__CLASS__ . '::' . __FUNCTION__,
2374
+			esc_html__(
2375
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2376
+				'event_espresso'
2377
+			),
2378
+			'4.8.32.rc.000'
2379
+		);
2380
+		return '
2381 2381
 	<table class="form-table ee-width-100">
2382 2382
 		<tbody>
2383 2383
 			';
2384
-    }
2385
-
2386
-
2387
-    /**
2388
-     * form_after_question_group
2389
-     *
2390
-     * @deprecated    as of 4.8.32.rc.000
2391
-     * @access        public
2392
-     * @param        string $output
2393
-     * @return        string
2394
-     */
2395
-    public function form_after_question_group($output)
2396
-    {
2397
-        EE_Error::doing_it_wrong(
2398
-            __CLASS__ . '::' . __FUNCTION__,
2399
-            esc_html__(
2400
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2401
-                'event_espresso'
2402
-            ),
2403
-            '4.8.32.rc.000'
2404
-        );
2405
-        return '
2384
+	}
2385
+
2386
+
2387
+	/**
2388
+	 * form_after_question_group
2389
+	 *
2390
+	 * @deprecated    as of 4.8.32.rc.000
2391
+	 * @access        public
2392
+	 * @param        string $output
2393
+	 * @return        string
2394
+	 */
2395
+	public function form_after_question_group($output)
2396
+	{
2397
+		EE_Error::doing_it_wrong(
2398
+			__CLASS__ . '::' . __FUNCTION__,
2399
+			esc_html__(
2400
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2401
+				'event_espresso'
2402
+			),
2403
+			'4.8.32.rc.000'
2404
+		);
2405
+		return '
2406 2406
 			<tr class="hide-if-no-js">
2407 2407
 				<th> </th>
2408 2408
 				<td class="reg-admin-edit-attendee-question-td">
2409 2409
 					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="'
2410
-               . esc_attr__('click to edit question', 'event_espresso')
2411
-               . '">
2410
+			   . esc_attr__('click to edit question', 'event_espresso')
2411
+			   . '">
2412 2412
 						<span class="reg-admin-edit-question-group-spn lt-grey-txt">'
2413
-               . esc_html__('edit the above question group', 'event_espresso')
2414
-               . '</span>
2413
+			   . esc_html__('edit the above question group', 'event_espresso')
2414
+			   . '</span>
2415 2415
 						<div class="dashicons dashicons-edit"></div>
2416 2416
 					</a>
2417 2417
 				</td>
@@ -2419,606 +2419,606 @@  discard block
 block discarded – undo
2419 2419
 		</tbody>
2420 2420
 	</table>
2421 2421
 ';
2422
-    }
2423
-
2424
-
2425
-    /**
2426
-     * form_form_field_label_wrap
2427
-     *
2428
-     * @deprecated    as of 4.8.32.rc.000
2429
-     * @access        public
2430
-     * @param        string $label
2431
-     * @return        string
2432
-     */
2433
-    public function form_form_field_label_wrap($label)
2434
-    {
2435
-        EE_Error::doing_it_wrong(
2436
-            __CLASS__ . '::' . __FUNCTION__,
2437
-            esc_html__(
2438
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2439
-                'event_espresso'
2440
-            ),
2441
-            '4.8.32.rc.000'
2442
-        );
2443
-        return '
2422
+	}
2423
+
2424
+
2425
+	/**
2426
+	 * form_form_field_label_wrap
2427
+	 *
2428
+	 * @deprecated    as of 4.8.32.rc.000
2429
+	 * @access        public
2430
+	 * @param        string $label
2431
+	 * @return        string
2432
+	 */
2433
+	public function form_form_field_label_wrap($label)
2434
+	{
2435
+		EE_Error::doing_it_wrong(
2436
+			__CLASS__ . '::' . __FUNCTION__,
2437
+			esc_html__(
2438
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2439
+				'event_espresso'
2440
+			),
2441
+			'4.8.32.rc.000'
2442
+		);
2443
+		return '
2444 2444
 			<tr>
2445 2445
 				<th>
2446 2446
 					' . $label . '
2447 2447
 				</th>';
2448
-    }
2449
-
2450
-
2451
-    /**
2452
-     * form_form_field_input__wrap
2453
-     *
2454
-     * @deprecated    as of 4.8.32.rc.000
2455
-     * @access        public
2456
-     * @param        string $input
2457
-     * @return        string
2458
-     */
2459
-    public function form_form_field_input__wrap($input)
2460
-    {
2461
-        EE_Error::doing_it_wrong(
2462
-            __CLASS__ . '::' . __FUNCTION__,
2463
-            esc_html__(
2464
-                'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2465
-                'event_espresso'
2466
-            ),
2467
-            '4.8.32.rc.000'
2468
-        );
2469
-        return '
2448
+	}
2449
+
2450
+
2451
+	/**
2452
+	 * form_form_field_input__wrap
2453
+	 *
2454
+	 * @deprecated    as of 4.8.32.rc.000
2455
+	 * @access        public
2456
+	 * @param        string $input
2457
+	 * @return        string
2458
+	 */
2459
+	public function form_form_field_input__wrap($input)
2460
+	{
2461
+		EE_Error::doing_it_wrong(
2462
+			__CLASS__ . '::' . __FUNCTION__,
2463
+			esc_html__(
2464
+				'This method would have been protected but was used on a filter callback so needed to be public. Please discontinue usage as it will be removed soon.',
2465
+				'event_espresso'
2466
+			),
2467
+			'4.8.32.rc.000'
2468
+		);
2469
+		return '
2470 2470
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
2471 2471
 					' . $input . '
2472 2472
 				</td>
2473 2473
 			</tr>';
2474
-    }
2475
-
2476
-
2477
-    /**
2478
-     * Updates the registration's custom questions according to the form info, if the form is submitted.
2479
-     * If it's not a post, the "view_registrations" route will be called next on the SAME request
2480
-     * to display the page
2481
-     *
2482
-     * @access protected
2483
-     * @return void
2484
-     * @throws EE_Error
2485
-     */
2486
-    protected function _update_attendee_registration_form()
2487
-    {
2488
-        do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2489
-        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2490
-            $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
2491
-            $success = $this->_save_reg_custom_questions_form($REG_ID);
2492
-            if ($success) {
2493
-                $what = esc_html__('Registration Form', 'event_espresso');
2494
-                $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
2495
-                    : array('action' => 'default');
2496
-                $this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
2497
-            }
2498
-        }
2499
-    }
2500
-
2501
-
2502
-    /**
2503
-     * Gets the form for saving registrations custom questions (if done
2504
-     * previously retrieves the cached form object, which may have validation errors in it)
2505
-     *
2506
-     * @param int $REG_ID
2507
-     * @return EE_Registration_Custom_Questions_Form
2508
-     * @throws EE_Error
2509
-     * @throws InvalidArgumentException
2510
-     * @throws InvalidDataTypeException
2511
-     * @throws InvalidInterfaceException
2512
-     */
2513
-    protected function _get_reg_custom_questions_form($REG_ID)
2514
-    {
2515
-        if (! $this->_reg_custom_questions_form) {
2516
-            require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
2517
-            $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2518
-                EEM_Registration::instance()->get_one_by_ID($REG_ID)
2519
-            );
2520
-            $this->_reg_custom_questions_form->_construct_finalize(null, null);
2521
-        }
2522
-        return $this->_reg_custom_questions_form;
2523
-    }
2524
-
2525
-
2526
-    /**
2527
-     * Saves
2528
-     *
2529
-     * @access private
2530
-     * @param bool $REG_ID
2531
-     * @return bool
2532
-     * @throws EE_Error
2533
-     * @throws InvalidArgumentException
2534
-     * @throws InvalidDataTypeException
2535
-     * @throws InvalidInterfaceException
2536
-     */
2537
-    private function _save_reg_custom_questions_form($REG_ID = false)
2538
-    {
2539
-        if (! $REG_ID) {
2540
-            EE_Error::add_error(
2541
-                esc_html__(
2542
-                    'An error occurred. No registration ID was received.',
2543
-                    'event_espresso'
2544
-                ),
2545
-                __FILE__,
2546
-                __FUNCTION__,
2547
-                __LINE__
2548
-            );
2549
-        }
2550
-        $form = $this->_get_reg_custom_questions_form($REG_ID);
2551
-        $form->receive_form_submission($this->_req_data);
2552
-        $success = false;
2553
-        if ($form->is_valid()) {
2554
-            foreach ($form->subforms() as $question_group_id => $question_group_form) {
2555
-                foreach ($question_group_form->inputs() as $question_id => $input) {
2556
-                    $where_conditions = array(
2557
-                        'QST_ID' => $question_id,
2558
-                        'REG_ID' => $REG_ID,
2559
-                    );
2560
-                    $possibly_new_values = array(
2561
-                        'ANS_value' => $input->normalized_value(),
2562
-                    );
2563
-                    $answer = EEM_Answer::instance()->get_one(array($where_conditions));
2564
-                    if ($answer instanceof EE_Answer) {
2565
-                        $success = $answer->save($possibly_new_values);
2566
-                    } else {
2567
-                        // insert it then
2568
-                        $cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2569
-                        $answer = EE_Answer::new_instance($cols_n_vals);
2570
-                        $success = $answer->save();
2571
-                    }
2572
-                }
2573
-            }
2574
-        } else {
2575
-            EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2576
-        }
2577
-        return $success;
2578
-    }
2579
-
2580
-
2581
-    /**
2582
-     *        generates HTML for the Registration main meta box
2583
-     *
2584
-     * @access public
2585
-     * @return void
2586
-     * @throws DomainException
2587
-     * @throws EE_Error
2588
-     * @throws InvalidArgumentException
2589
-     * @throws InvalidDataTypeException
2590
-     * @throws InvalidInterfaceException
2591
-     */
2592
-    public function _reg_attendees_meta_box()
2593
-    {
2594
-        $REG = EEM_Registration::instance();
2595
-        // get all other registrations on this transaction, and cache
2596
-        // the attendees for them so we don't have to run another query using force_join
2597
-        $registrations = $REG->get_all(
2598
-            array(
2599
-                array(
2600
-                    'TXN_ID' => $this->_registration->transaction_ID(),
2601
-                    'REG_ID' => array('!=', $this->_registration->ID()),
2602
-                ),
2603
-                'force_join' => array('Attendee'),
2604
-            )
2605
-        );
2606
-        $this->_template_args['attendees'] = array();
2607
-        $this->_template_args['attendee_notice'] = '';
2608
-        if (empty($registrations)
2609
-            || (is_array($registrations)
2610
-                && ! EEH_Array::get_one_item_from_array($registrations))
2611
-        ) {
2612
-            EE_Error::add_error(
2613
-                esc_html__(
2614
-                    'There are no records attached to this registration. Something may have gone wrong with the registration',
2615
-                    'event_espresso'
2616
-                ),
2617
-                __FILE__,
2618
-                __FUNCTION__,
2619
-                __LINE__
2620
-            );
2621
-            $this->_template_args['attendee_notice'] = EE_Error::get_notices();
2622
-        } else {
2623
-            $att_nmbr = 1;
2624
-            foreach ($registrations as $registration) {
2625
-                /* @var $registration EE_Registration */
2626
-                $attendee = $registration->attendee()
2627
-                    ? $registration->attendee()
2628
-                    : EEM_Attendee::instance()
2629
-                                  ->create_default_object();
2630
-                $this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2631
-                $this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2632
-                $this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2633
-                $this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2634
-                $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2635
-                $this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2636
-                    ', ',
2637
-                    $attendee->full_address_as_array()
2638
-                );
2639
-                $this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2640
-                    array(
2641
-                        'action' => 'edit_attendee',
2642
-                        'post'   => $attendee->ID(),
2643
-                    ),
2644
-                    REG_ADMIN_URL
2645
-                );
2646
-                $this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj()->name();
2647
-                $att_nmbr++;
2648
-            }
2649
-            $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2650
-        }
2651
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2652
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2653
-    }
2654
-
2655
-
2656
-    /**
2657
-     *        generates HTML for the Edit Registration side meta box
2658
-     *
2659
-     * @access public
2660
-     * @return void
2661
-     * @throws DomainException
2662
-     * @throws EE_Error
2663
-     * @throws InvalidArgumentException
2664
-     * @throws InvalidDataTypeException
2665
-     * @throws InvalidInterfaceException
2666
-     */
2667
-    public function _reg_registrant_side_meta_box()
2668
-    {
2669
-        /*@var $attendee EE_Attendee */
2670
-        $att_check = $this->_registration->attendee();
2671
-        $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2672
-        // now let's determine if this is not the primary registration.  If it isn't then we set the
2673
-        // primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2674
-        // primary registration object (that way we know if we need to show create button or not)
2675
-        if (! $this->_registration->is_primary_registrant()) {
2676
-            $primary_registration = $this->_registration->get_primary_registration();
2677
-            $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2678
-                : null;
2679
-            if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2680
-                // in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2681
-                // custom attendee object so let's not worry about the primary reg.
2682
-                $primary_registration = null;
2683
-            }
2684
-        } else {
2685
-            $primary_registration = null;
2686
-        }
2687
-        $this->_template_args['ATT_ID'] = $attendee->ID();
2688
-        $this->_template_args['fname'] = $attendee->fname();
2689
-        $this->_template_args['lname'] = $attendee->lname();
2690
-        $this->_template_args['email'] = $attendee->email();
2691
-        $this->_template_args['phone'] = $attendee->phone();
2692
-        $this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2693
-        // edit link
2694
-        $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2695
-            array(
2696
-                'action' => 'edit_attendee',
2697
-                'post'   => $attendee->ID(),
2698
-            ),
2699
-            REG_ADMIN_URL
2700
-        );
2701
-        $this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2702
-        // create link
2703
-        $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2704
-            ? EE_Admin_Page::add_query_args_and_nonce(
2705
-                array(
2706
-                    'action'  => 'duplicate_attendee',
2707
-                    '_REG_ID' => $this->_registration->ID(),
2708
-                ),
2709
-                REG_ADMIN_URL
2710
-            ) : '';
2711
-        $this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2712
-        $this->_template_args['att_check'] = $att_check;
2713
-        $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2714
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2715
-    }
2716
-
2717
-
2718
-    /**
2719
-     * trash or restore registrations
2720
-     *
2721
-     * @param  boolean $trash whether to archive or restore
2722
-     * @return void
2723
-     * @throws EE_Error
2724
-     * @throws InvalidArgumentException
2725
-     * @throws InvalidDataTypeException
2726
-     * @throws InvalidInterfaceException
2727
-     * @throws RuntimeException
2728
-     * @access protected
2729
-     */
2730
-    protected function _trash_or_restore_registrations($trash = true)
2731
-    {
2732
-        // if empty _REG_ID then get out because there's nothing to do
2733
-        if (empty($this->_req_data['_REG_ID'])) {
2734
-            EE_Error::add_error(
2735
-                sprintf(
2736
-                    esc_html__(
2737
-                        'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2738
-                        'event_espresso'
2739
-                    ),
2740
-                    $trash ? 'trash' : 'restore'
2741
-                ),
2742
-                __FILE__,
2743
-                __LINE__,
2744
-                __FUNCTION__
2745
-            );
2746
-            $this->_redirect_after_action(false, '', '', array(), true);
2747
-        }
2748
-        $success = 0;
2749
-        $overwrite_msgs = false;
2750
-        // Checkboxes
2751
-        if (! is_array($this->_req_data['_REG_ID'])) {
2752
-            $this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']);
2753
-        }
2754
-        $reg_count = count($this->_req_data['_REG_ID']);
2755
-        // cycle thru checkboxes
2756
-        foreach ($this->_req_data['_REG_ID'] as $REG_ID) {
2757
-            /** @var EE_Registration $REG */
2758
-            $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
2759
-            $payments = $REG->registration_payments();
2760
-            if (! empty($payments)) {
2761
-                $name = $REG->attendee() instanceof EE_Attendee
2762
-                    ? $REG->attendee()->full_name()
2763
-                    : esc_html__('Unknown Attendee', 'event_espresso');
2764
-                $overwrite_msgs = true;
2765
-                EE_Error::add_error(
2766
-                    sprintf(
2767
-                        esc_html__(
2768
-                            'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2769
-                            'event_espresso'
2770
-                        ),
2771
-                        $name
2772
-                    ),
2773
-                    __FILE__,
2774
-                    __FUNCTION__,
2775
-                    __LINE__
2776
-                );
2777
-                // can't trash this registration because it has payments.
2778
-                continue;
2779
-            }
2780
-            $updated = $trash ? $REG->delete() : $REG->restore();
2781
-            if ($updated) {
2782
-                $success++;
2783
-            }
2784
-        }
2785
-        $this->_redirect_after_action(
2786
-            $success === $reg_count, // were ALL registrations affected?
2787
-            $success > 1
2788
-                ? esc_html__('Registrations', 'event_espresso')
2789
-                : esc_html__('Registration', 'event_espresso'),
2790
-            $trash
2791
-                ? esc_html__('moved to the trash', 'event_espresso')
2792
-                : esc_html__('restored', 'event_espresso'),
2793
-            array('action' => 'default'),
2794
-            $overwrite_msgs
2795
-        );
2796
-    }
2797
-
2798
-
2799
-    /**
2800
-     * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2801
-     * registration but also.
2802
-     * 1. Removing relations to EE_Attendee
2803
-     * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2804
-     * ALSO trashed.
2805
-     * 3. Deleting permanently any related Line items but only if the above conditions are met.
2806
-     * 4. Removing relationships between all tickets and the related registrations
2807
-     * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2808
-     * 6. Deleting permanently any related Checkins.
2809
-     *
2810
-     * @return void
2811
-     * @throws EE_Error
2812
-     * @throws InvalidArgumentException
2813
-     * @throws InvalidDataTypeException
2814
-     * @throws InvalidInterfaceException
2815
-     */
2816
-    protected function _delete_registrations()
2817
-    {
2818
-        $REG_MDL = EEM_Registration::instance();
2819
-        $success = 1;
2820
-        // Checkboxes
2821
-        if (! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2822
-            // if array has more than one element than success message should be plural
2823
-            $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2824
-            // cycle thru checkboxes
2825
-            while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2826
-                $REG = $REG_MDL->get_one_by_ID($REG_ID);
2827
-                if (! $REG instanceof EE_Registration) {
2828
-                    continue;
2829
-                }
2830
-                $deleted = $this->_delete_registration($REG);
2831
-                if (! $deleted) {
2832
-                    $success = 0;
2833
-                }
2834
-            }
2835
-        } else {
2836
-            // grab single id and delete
2837
-            $REG_ID = $this->_req_data['_REG_ID'];
2838
-            $REG = $REG_MDL->get_one_by_ID($REG_ID);
2839
-            $deleted = $this->_delete_registration($REG);
2840
-            if (! $deleted) {
2841
-                $success = 0;
2842
-            }
2843
-        }
2844
-        $what = $success > 1
2845
-            ? esc_html__('Registrations', 'event_espresso')
2846
-            : esc_html__('Registration', 'event_espresso');
2847
-        $action_desc = esc_html__('permanently deleted.', 'event_espresso');
2848
-        $this->_redirect_after_action(
2849
-            $success,
2850
-            $what,
2851
-            $action_desc,
2852
-            array('action' => 'default'),
2853
-            true
2854
-        );
2855
-    }
2856
-
2857
-
2858
-    /**
2859
-     * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2860
-     * models get affected.
2861
-     *
2862
-     * @param  EE_Registration $REG registration to be deleted permenantly
2863
-     * @return bool true = successful deletion, false = fail.
2864
-     * @throws EE_Error
2865
-     */
2866
-    protected function _delete_registration(EE_Registration $REG)
2867
-    {
2868
-        // first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2869
-        // registrations on the transaction that are NOT trashed.
2870
-        $TXN = $REG->get_first_related('Transaction');
2871
-        $REGS = $TXN->get_many_related('Registration');
2872
-        $all_trashed = true;
2873
-        foreach ($REGS as $registration) {
2874
-            if (! $registration->get('REG_deleted')) {
2875
-                $all_trashed = false;
2876
-            }
2877
-        }
2878
-        if (! $all_trashed) {
2879
-            EE_Error::add_error(
2880
-                esc_html__(
2881
-                    'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2882
-                    'event_espresso'
2883
-                ),
2884
-                __FILE__,
2885
-                __FUNCTION__,
2886
-                __LINE__
2887
-            );
2888
-            return false;
2889
-        }
2890
-        // k made it here so that means we can delete all the related transactions and their answers (but let's do them
2891
-        // separately from THIS one).
2892
-        foreach ($REGS as $registration) {
2893
-            // delete related answers
2894
-            $registration->delete_related_permanently('Answer');
2895
-            // remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2896
-            $attendee = $registration->get_first_related('Attendee');
2897
-            if ($attendee instanceof EE_Attendee) {
2898
-                $registration->_remove_relation_to($attendee, 'Attendee');
2899
-            }
2900
-            // now remove relationships to tickets on this registration.
2901
-            $registration->_remove_relations('Ticket');
2902
-            // now delete permanently the checkins related to this registration.
2903
-            $registration->delete_related_permanently('Checkin');
2904
-            if ($registration->ID() === $REG->ID()) {
2905
-                continue;
2906
-            } //we don't want to delete permanently the existing registration just yet.
2907
-            // remove relation to transaction for these registrations if NOT the existing registrations
2908
-            $registration->_remove_relations('Transaction');
2909
-            // delete permanently any related messages.
2910
-            $registration->delete_related_permanently('Message');
2911
-            // now delete this registration permanently
2912
-            $registration->delete_permanently();
2913
-        }
2914
-        // now all related registrations on the transaction are handled.  So let's just handle this registration itself
2915
-        // (the transaction and line items should be all that's left).
2916
-        // delete the line items related to the transaction for this registration.
2917
-        $TXN->delete_related_permanently('Line_Item');
2918
-        // we need to remove all the relationships on the transaction
2919
-        $TXN->delete_related_permanently('Payment');
2920
-        $TXN->delete_related_permanently('Extra_Meta');
2921
-        $TXN->delete_related_permanently('Message');
2922
-        // now we can delete this REG permanently (and the transaction of course)
2923
-        $REG->delete_related_permanently('Transaction');
2924
-        return $REG->delete_permanently();
2925
-    }
2926
-
2927
-
2928
-    /**
2929
-     *    generates HTML for the Register New Attendee Admin page
2930
-     *
2931
-     * @access private
2932
-     * @throws DomainException
2933
-     * @throws EE_Error
2934
-     */
2935
-    public function new_registration()
2936
-    {
2937
-        if (! $this->_set_reg_event()) {
2938
-            throw new EE_Error(
2939
-                esc_html__(
2940
-                    'Unable to continue with registering because there is no Event ID in the request',
2941
-                    'event_espresso'
2942
-                )
2943
-            );
2944
-        }
2945
-        EE_Registry::instance()->REQ->set_espresso_page(true);
2946
-        // gotta start with a clean slate if we're not coming here via ajax
2947
-        if (! defined('DOING_AJAX')
2948
-            && (! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2949
-        ) {
2950
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2951
-        }
2952
-        $this->_template_args['event_name'] = '';
2953
-        // event name
2954
-        if ($this->_reg_event) {
2955
-            $this->_template_args['event_name'] = $this->_reg_event->name();
2956
-            $edit_event_url = self::add_query_args_and_nonce(
2957
-                array(
2958
-                    'action' => 'edit',
2959
-                    'post'   => $this->_reg_event->ID(),
2960
-                ),
2961
-                EVENTS_ADMIN_URL
2962
-            );
2963
-            $edit_event_lnk = '<a href="'
2964
-                              . $edit_event_url
2965
-                              . '" title="'
2966
-                              . esc_attr__('Edit ', 'event_espresso')
2967
-                              . $this->_reg_event->name()
2968
-                              . '">'
2969
-                              . esc_html__('Edit Event', 'event_espresso')
2970
-                              . '</a>';
2971
-            $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2972
-                                                   . $edit_event_lnk
2973
-                                                   . '</span>';
2974
-        }
2975
-        $this->_template_args['step_content'] = $this->_get_registration_step_content();
2976
-        if (defined('DOING_AJAX')) {
2977
-            $this->_return_json();
2978
-        }
2979
-        // grab header
2980
-        $template_path =
2981
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2982
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2983
-            $template_path,
2984
-            $this->_template_args,
2985
-            true
2986
-        );
2987
-        // $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2988
-        // the details template wrapper
2989
-        $this->display_admin_page_with_sidebar();
2990
-    }
2991
-
2992
-
2993
-    /**
2994
-     * This returns the content for a registration step
2995
-     *
2996
-     * @access protected
2997
-     * @return string html
2998
-     * @throws DomainException
2999
-     * @throws EE_Error
3000
-     * @throws InvalidArgumentException
3001
-     * @throws InvalidDataTypeException
3002
-     * @throws InvalidInterfaceException
3003
-     */
3004
-    protected function _get_registration_step_content()
3005
-    {
3006
-        if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
3007
-            $warning_msg = sprintf(
3008
-                esc_html__(
3009
-                    '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
3010
-                    'event_espresso'
3011
-                ),
3012
-                '<br />',
3013
-                '<h3 class="important-notice">',
3014
-                '</h3>',
3015
-                '<div class="float-right">',
3016
-                '<span id="redirect_timer" class="important-notice">30</span>',
3017
-                '</div>',
3018
-                '<b>',
3019
-                '</b>'
3020
-            );
3021
-            return '
2474
+	}
2475
+
2476
+
2477
+	/**
2478
+	 * Updates the registration's custom questions according to the form info, if the form is submitted.
2479
+	 * If it's not a post, the "view_registrations" route will be called next on the SAME request
2480
+	 * to display the page
2481
+	 *
2482
+	 * @access protected
2483
+	 * @return void
2484
+	 * @throws EE_Error
2485
+	 */
2486
+	protected function _update_attendee_registration_form()
2487
+	{
2488
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
2489
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2490
+			$REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : false;
2491
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
2492
+			if ($success) {
2493
+				$what = esc_html__('Registration Form', 'event_espresso');
2494
+				$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID)
2495
+					: array('action' => 'default');
2496
+				$this->_redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
2497
+			}
2498
+		}
2499
+	}
2500
+
2501
+
2502
+	/**
2503
+	 * Gets the form for saving registrations custom questions (if done
2504
+	 * previously retrieves the cached form object, which may have validation errors in it)
2505
+	 *
2506
+	 * @param int $REG_ID
2507
+	 * @return EE_Registration_Custom_Questions_Form
2508
+	 * @throws EE_Error
2509
+	 * @throws InvalidArgumentException
2510
+	 * @throws InvalidDataTypeException
2511
+	 * @throws InvalidInterfaceException
2512
+	 */
2513
+	protected function _get_reg_custom_questions_form($REG_ID)
2514
+	{
2515
+		if (! $this->_reg_custom_questions_form) {
2516
+			require_once(REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php');
2517
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(
2518
+				EEM_Registration::instance()->get_one_by_ID($REG_ID)
2519
+			);
2520
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
2521
+		}
2522
+		return $this->_reg_custom_questions_form;
2523
+	}
2524
+
2525
+
2526
+	/**
2527
+	 * Saves
2528
+	 *
2529
+	 * @access private
2530
+	 * @param bool $REG_ID
2531
+	 * @return bool
2532
+	 * @throws EE_Error
2533
+	 * @throws InvalidArgumentException
2534
+	 * @throws InvalidDataTypeException
2535
+	 * @throws InvalidInterfaceException
2536
+	 */
2537
+	private function _save_reg_custom_questions_form($REG_ID = false)
2538
+	{
2539
+		if (! $REG_ID) {
2540
+			EE_Error::add_error(
2541
+				esc_html__(
2542
+					'An error occurred. No registration ID was received.',
2543
+					'event_espresso'
2544
+				),
2545
+				__FILE__,
2546
+				__FUNCTION__,
2547
+				__LINE__
2548
+			);
2549
+		}
2550
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
2551
+		$form->receive_form_submission($this->_req_data);
2552
+		$success = false;
2553
+		if ($form->is_valid()) {
2554
+			foreach ($form->subforms() as $question_group_id => $question_group_form) {
2555
+				foreach ($question_group_form->inputs() as $question_id => $input) {
2556
+					$where_conditions = array(
2557
+						'QST_ID' => $question_id,
2558
+						'REG_ID' => $REG_ID,
2559
+					);
2560
+					$possibly_new_values = array(
2561
+						'ANS_value' => $input->normalized_value(),
2562
+					);
2563
+					$answer = EEM_Answer::instance()->get_one(array($where_conditions));
2564
+					if ($answer instanceof EE_Answer) {
2565
+						$success = $answer->save($possibly_new_values);
2566
+					} else {
2567
+						// insert it then
2568
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
2569
+						$answer = EE_Answer::new_instance($cols_n_vals);
2570
+						$success = $answer->save();
2571
+					}
2572
+				}
2573
+			}
2574
+		} else {
2575
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
2576
+		}
2577
+		return $success;
2578
+	}
2579
+
2580
+
2581
+	/**
2582
+	 *        generates HTML for the Registration main meta box
2583
+	 *
2584
+	 * @access public
2585
+	 * @return void
2586
+	 * @throws DomainException
2587
+	 * @throws EE_Error
2588
+	 * @throws InvalidArgumentException
2589
+	 * @throws InvalidDataTypeException
2590
+	 * @throws InvalidInterfaceException
2591
+	 */
2592
+	public function _reg_attendees_meta_box()
2593
+	{
2594
+		$REG = EEM_Registration::instance();
2595
+		// get all other registrations on this transaction, and cache
2596
+		// the attendees for them so we don't have to run another query using force_join
2597
+		$registrations = $REG->get_all(
2598
+			array(
2599
+				array(
2600
+					'TXN_ID' => $this->_registration->transaction_ID(),
2601
+					'REG_ID' => array('!=', $this->_registration->ID()),
2602
+				),
2603
+				'force_join' => array('Attendee'),
2604
+			)
2605
+		);
2606
+		$this->_template_args['attendees'] = array();
2607
+		$this->_template_args['attendee_notice'] = '';
2608
+		if (empty($registrations)
2609
+			|| (is_array($registrations)
2610
+				&& ! EEH_Array::get_one_item_from_array($registrations))
2611
+		) {
2612
+			EE_Error::add_error(
2613
+				esc_html__(
2614
+					'There are no records attached to this registration. Something may have gone wrong with the registration',
2615
+					'event_espresso'
2616
+				),
2617
+				__FILE__,
2618
+				__FUNCTION__,
2619
+				__LINE__
2620
+			);
2621
+			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
2622
+		} else {
2623
+			$att_nmbr = 1;
2624
+			foreach ($registrations as $registration) {
2625
+				/* @var $registration EE_Registration */
2626
+				$attendee = $registration->attendee()
2627
+					? $registration->attendee()
2628
+					: EEM_Attendee::instance()
2629
+								  ->create_default_object();
2630
+				$this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID();
2631
+				$this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();
2632
+				$this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();
2633
+				$this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();
2634
+				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();
2635
+				$this->_template_args['attendees'][ $att_nmbr ]['address'] = implode(
2636
+					', ',
2637
+					$attendee->full_address_as_array()
2638
+				);
2639
+				$this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce(
2640
+					array(
2641
+						'action' => 'edit_attendee',
2642
+						'post'   => $attendee->ID(),
2643
+					),
2644
+					REG_ADMIN_URL
2645
+				);
2646
+				$this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj()->name();
2647
+				$att_nmbr++;
2648
+			}
2649
+			$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
2650
+		}
2651
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
2652
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2653
+	}
2654
+
2655
+
2656
+	/**
2657
+	 *        generates HTML for the Edit Registration side meta box
2658
+	 *
2659
+	 * @access public
2660
+	 * @return void
2661
+	 * @throws DomainException
2662
+	 * @throws EE_Error
2663
+	 * @throws InvalidArgumentException
2664
+	 * @throws InvalidDataTypeException
2665
+	 * @throws InvalidInterfaceException
2666
+	 */
2667
+	public function _reg_registrant_side_meta_box()
2668
+	{
2669
+		/*@var $attendee EE_Attendee */
2670
+		$att_check = $this->_registration->attendee();
2671
+		$attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
2672
+		// now let's determine if this is not the primary registration.  If it isn't then we set the
2673
+		// primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the
2674
+		// primary registration object (that way we know if we need to show create button or not)
2675
+		if (! $this->_registration->is_primary_registrant()) {
2676
+			$primary_registration = $this->_registration->get_primary_registration();
2677
+			$primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee()
2678
+				: null;
2679
+			if (! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
2680
+				// in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own
2681
+				// custom attendee object so let's not worry about the primary reg.
2682
+				$primary_registration = null;
2683
+			}
2684
+		} else {
2685
+			$primary_registration = null;
2686
+		}
2687
+		$this->_template_args['ATT_ID'] = $attendee->ID();
2688
+		$this->_template_args['fname'] = $attendee->fname();
2689
+		$this->_template_args['lname'] = $attendee->lname();
2690
+		$this->_template_args['email'] = $attendee->email();
2691
+		$this->_template_args['phone'] = $attendee->phone();
2692
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
2693
+		// edit link
2694
+		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(
2695
+			array(
2696
+				'action' => 'edit_attendee',
2697
+				'post'   => $attendee->ID(),
2698
+			),
2699
+			REG_ADMIN_URL
2700
+		);
2701
+		$this->_template_args['att_edit_label'] = esc_html__('View/Edit Contact', 'event_espresso');
2702
+		// create link
2703
+		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration
2704
+			? EE_Admin_Page::add_query_args_and_nonce(
2705
+				array(
2706
+					'action'  => 'duplicate_attendee',
2707
+					'_REG_ID' => $this->_registration->ID(),
2708
+				),
2709
+				REG_ADMIN_URL
2710
+			) : '';
2711
+		$this->_template_args['create_label'] = esc_html__('Create Contact', 'event_espresso');
2712
+		$this->_template_args['att_check'] = $att_check;
2713
+		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
2714
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2715
+	}
2716
+
2717
+
2718
+	/**
2719
+	 * trash or restore registrations
2720
+	 *
2721
+	 * @param  boolean $trash whether to archive or restore
2722
+	 * @return void
2723
+	 * @throws EE_Error
2724
+	 * @throws InvalidArgumentException
2725
+	 * @throws InvalidDataTypeException
2726
+	 * @throws InvalidInterfaceException
2727
+	 * @throws RuntimeException
2728
+	 * @access protected
2729
+	 */
2730
+	protected function _trash_or_restore_registrations($trash = true)
2731
+	{
2732
+		// if empty _REG_ID then get out because there's nothing to do
2733
+		if (empty($this->_req_data['_REG_ID'])) {
2734
+			EE_Error::add_error(
2735
+				sprintf(
2736
+					esc_html__(
2737
+						'In order to %1$s registrations you must select which ones you wish to %1$s by clicking the checkboxes.',
2738
+						'event_espresso'
2739
+					),
2740
+					$trash ? 'trash' : 'restore'
2741
+				),
2742
+				__FILE__,
2743
+				__LINE__,
2744
+				__FUNCTION__
2745
+			);
2746
+			$this->_redirect_after_action(false, '', '', array(), true);
2747
+		}
2748
+		$success = 0;
2749
+		$overwrite_msgs = false;
2750
+		// Checkboxes
2751
+		if (! is_array($this->_req_data['_REG_ID'])) {
2752
+			$this->_req_data['_REG_ID'] = array($this->_req_data['_REG_ID']);
2753
+		}
2754
+		$reg_count = count($this->_req_data['_REG_ID']);
2755
+		// cycle thru checkboxes
2756
+		foreach ($this->_req_data['_REG_ID'] as $REG_ID) {
2757
+			/** @var EE_Registration $REG */
2758
+			$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
2759
+			$payments = $REG->registration_payments();
2760
+			if (! empty($payments)) {
2761
+				$name = $REG->attendee() instanceof EE_Attendee
2762
+					? $REG->attendee()->full_name()
2763
+					: esc_html__('Unknown Attendee', 'event_espresso');
2764
+				$overwrite_msgs = true;
2765
+				EE_Error::add_error(
2766
+					sprintf(
2767
+						esc_html__(
2768
+							'The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.',
2769
+							'event_espresso'
2770
+						),
2771
+						$name
2772
+					),
2773
+					__FILE__,
2774
+					__FUNCTION__,
2775
+					__LINE__
2776
+				);
2777
+				// can't trash this registration because it has payments.
2778
+				continue;
2779
+			}
2780
+			$updated = $trash ? $REG->delete() : $REG->restore();
2781
+			if ($updated) {
2782
+				$success++;
2783
+			}
2784
+		}
2785
+		$this->_redirect_after_action(
2786
+			$success === $reg_count, // were ALL registrations affected?
2787
+			$success > 1
2788
+				? esc_html__('Registrations', 'event_espresso')
2789
+				: esc_html__('Registration', 'event_espresso'),
2790
+			$trash
2791
+				? esc_html__('moved to the trash', 'event_espresso')
2792
+				: esc_html__('restored', 'event_espresso'),
2793
+			array('action' => 'default'),
2794
+			$overwrite_msgs
2795
+		);
2796
+	}
2797
+
2798
+
2799
+	/**
2800
+	 * This is used to permanently delete registrations.  Note, this will handle not only deleting permanently the
2801
+	 * registration but also.
2802
+	 * 1. Removing relations to EE_Attendee
2803
+	 * 2. Deleting permanently the related transaction, but ONLY if all related registrations to the transaction are
2804
+	 * ALSO trashed.
2805
+	 * 3. Deleting permanently any related Line items but only if the above conditions are met.
2806
+	 * 4. Removing relationships between all tickets and the related registrations
2807
+	 * 5. Deleting permanently any related Answers (and the answers for other related registrations that were deleted.)
2808
+	 * 6. Deleting permanently any related Checkins.
2809
+	 *
2810
+	 * @return void
2811
+	 * @throws EE_Error
2812
+	 * @throws InvalidArgumentException
2813
+	 * @throws InvalidDataTypeException
2814
+	 * @throws InvalidInterfaceException
2815
+	 */
2816
+	protected function _delete_registrations()
2817
+	{
2818
+		$REG_MDL = EEM_Registration::instance();
2819
+		$success = 1;
2820
+		// Checkboxes
2821
+		if (! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
2822
+			// if array has more than one element than success message should be plural
2823
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
2824
+			// cycle thru checkboxes
2825
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
2826
+				$REG = $REG_MDL->get_one_by_ID($REG_ID);
2827
+				if (! $REG instanceof EE_Registration) {
2828
+					continue;
2829
+				}
2830
+				$deleted = $this->_delete_registration($REG);
2831
+				if (! $deleted) {
2832
+					$success = 0;
2833
+				}
2834
+			}
2835
+		} else {
2836
+			// grab single id and delete
2837
+			$REG_ID = $this->_req_data['_REG_ID'];
2838
+			$REG = $REG_MDL->get_one_by_ID($REG_ID);
2839
+			$deleted = $this->_delete_registration($REG);
2840
+			if (! $deleted) {
2841
+				$success = 0;
2842
+			}
2843
+		}
2844
+		$what = $success > 1
2845
+			? esc_html__('Registrations', 'event_espresso')
2846
+			: esc_html__('Registration', 'event_espresso');
2847
+		$action_desc = esc_html__('permanently deleted.', 'event_espresso');
2848
+		$this->_redirect_after_action(
2849
+			$success,
2850
+			$what,
2851
+			$action_desc,
2852
+			array('action' => 'default'),
2853
+			true
2854
+		);
2855
+	}
2856
+
2857
+
2858
+	/**
2859
+	 * handles the permanent deletion of a registration.  See comments with _delete_registrations() for details on what
2860
+	 * models get affected.
2861
+	 *
2862
+	 * @param  EE_Registration $REG registration to be deleted permenantly
2863
+	 * @return bool true = successful deletion, false = fail.
2864
+	 * @throws EE_Error
2865
+	 */
2866
+	protected function _delete_registration(EE_Registration $REG)
2867
+	{
2868
+		// first we start with the transaction... ultimately, we WILL not delete permanently if there are any related
2869
+		// registrations on the transaction that are NOT trashed.
2870
+		$TXN = $REG->get_first_related('Transaction');
2871
+		$REGS = $TXN->get_many_related('Registration');
2872
+		$all_trashed = true;
2873
+		foreach ($REGS as $registration) {
2874
+			if (! $registration->get('REG_deleted')) {
2875
+				$all_trashed = false;
2876
+			}
2877
+		}
2878
+		if (! $all_trashed) {
2879
+			EE_Error::add_error(
2880
+				esc_html__(
2881
+					'Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.',
2882
+					'event_espresso'
2883
+				),
2884
+				__FILE__,
2885
+				__FUNCTION__,
2886
+				__LINE__
2887
+			);
2888
+			return false;
2889
+		}
2890
+		// k made it here so that means we can delete all the related transactions and their answers (but let's do them
2891
+		// separately from THIS one).
2892
+		foreach ($REGS as $registration) {
2893
+			// delete related answers
2894
+			$registration->delete_related_permanently('Answer');
2895
+			// remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
2896
+			$attendee = $registration->get_first_related('Attendee');
2897
+			if ($attendee instanceof EE_Attendee) {
2898
+				$registration->_remove_relation_to($attendee, 'Attendee');
2899
+			}
2900
+			// now remove relationships to tickets on this registration.
2901
+			$registration->_remove_relations('Ticket');
2902
+			// now delete permanently the checkins related to this registration.
2903
+			$registration->delete_related_permanently('Checkin');
2904
+			if ($registration->ID() === $REG->ID()) {
2905
+				continue;
2906
+			} //we don't want to delete permanently the existing registration just yet.
2907
+			// remove relation to transaction for these registrations if NOT the existing registrations
2908
+			$registration->_remove_relations('Transaction');
2909
+			// delete permanently any related messages.
2910
+			$registration->delete_related_permanently('Message');
2911
+			// now delete this registration permanently
2912
+			$registration->delete_permanently();
2913
+		}
2914
+		// now all related registrations on the transaction are handled.  So let's just handle this registration itself
2915
+		// (the transaction and line items should be all that's left).
2916
+		// delete the line items related to the transaction for this registration.
2917
+		$TXN->delete_related_permanently('Line_Item');
2918
+		// we need to remove all the relationships on the transaction
2919
+		$TXN->delete_related_permanently('Payment');
2920
+		$TXN->delete_related_permanently('Extra_Meta');
2921
+		$TXN->delete_related_permanently('Message');
2922
+		// now we can delete this REG permanently (and the transaction of course)
2923
+		$REG->delete_related_permanently('Transaction');
2924
+		return $REG->delete_permanently();
2925
+	}
2926
+
2927
+
2928
+	/**
2929
+	 *    generates HTML for the Register New Attendee Admin page
2930
+	 *
2931
+	 * @access private
2932
+	 * @throws DomainException
2933
+	 * @throws EE_Error
2934
+	 */
2935
+	public function new_registration()
2936
+	{
2937
+		if (! $this->_set_reg_event()) {
2938
+			throw new EE_Error(
2939
+				esc_html__(
2940
+					'Unable to continue with registering because there is no Event ID in the request',
2941
+					'event_espresso'
2942
+				)
2943
+			);
2944
+		}
2945
+		EE_Registry::instance()->REQ->set_espresso_page(true);
2946
+		// gotta start with a clean slate if we're not coming here via ajax
2947
+		if (! defined('DOING_AJAX')
2948
+			&& (! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))
2949
+		) {
2950
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2951
+		}
2952
+		$this->_template_args['event_name'] = '';
2953
+		// event name
2954
+		if ($this->_reg_event) {
2955
+			$this->_template_args['event_name'] = $this->_reg_event->name();
2956
+			$edit_event_url = self::add_query_args_and_nonce(
2957
+				array(
2958
+					'action' => 'edit',
2959
+					'post'   => $this->_reg_event->ID(),
2960
+				),
2961
+				EVENTS_ADMIN_URL
2962
+			);
2963
+			$edit_event_lnk = '<a href="'
2964
+							  . $edit_event_url
2965
+							  . '" title="'
2966
+							  . esc_attr__('Edit ', 'event_espresso')
2967
+							  . $this->_reg_event->name()
2968
+							  . '">'
2969
+							  . esc_html__('Edit Event', 'event_espresso')
2970
+							  . '</a>';
2971
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'
2972
+												   . $edit_event_lnk
2973
+												   . '</span>';
2974
+		}
2975
+		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2976
+		if (defined('DOING_AJAX')) {
2977
+			$this->_return_json();
2978
+		}
2979
+		// grab header
2980
+		$template_path =
2981
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2982
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2983
+			$template_path,
2984
+			$this->_template_args,
2985
+			true
2986
+		);
2987
+		// $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2988
+		// the details template wrapper
2989
+		$this->display_admin_page_with_sidebar();
2990
+	}
2991
+
2992
+
2993
+	/**
2994
+	 * This returns the content for a registration step
2995
+	 *
2996
+	 * @access protected
2997
+	 * @return string html
2998
+	 * @throws DomainException
2999
+	 * @throws EE_Error
3000
+	 * @throws InvalidArgumentException
3001
+	 * @throws InvalidDataTypeException
3002
+	 * @throws InvalidInterfaceException
3003
+	 */
3004
+	protected function _get_registration_step_content()
3005
+	{
3006
+		if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) {
3007
+			$warning_msg = sprintf(
3008
+				esc_html__(
3009
+					'%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s',
3010
+					'event_espresso'
3011
+				),
3012
+				'<br />',
3013
+				'<h3 class="important-notice">',
3014
+				'</h3>',
3015
+				'<div class="float-right">',
3016
+				'<span id="redirect_timer" class="important-notice">30</span>',
3017
+				'</div>',
3018
+				'<b>',
3019
+				'</b>'
3020
+			);
3021
+			return '
3022 3022
 	<div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div>
3023 3023
 	<script >
3024 3024
 		// WHOAH !!! it appears that someone is using the back button from the Transaction admin page
@@ -3031,855 +3031,855 @@  discard block
 block discarded – undo
3031 3031
 	        }
3032 3032
 	    }, 800 );
3033 3033
 	</script >';
3034
-        }
3035
-        $template_args = array(
3036
-            'title'                    => '',
3037
-            'content'                  => '',
3038
-            'step_button_text'         => '',
3039
-            'show_notification_toggle' => false,
3040
-        );
3041
-        // to indicate we're processing a new registration
3042
-        $hidden_fields = array(
3043
-            'processing_registration' => array(
3044
-                'type'  => 'hidden',
3045
-                'value' => 0,
3046
-            ),
3047
-            'event_id'                => array(
3048
-                'type'  => 'hidden',
3049
-                'value' => $this->_reg_event->ID(),
3050
-            ),
3051
-        );
3052
-        // if the cart is empty then we know we're at step one so we'll display ticket selector
3053
-        $cart = EE_Registry::instance()->SSN->cart();
3054
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3055
-        switch ($step) {
3056
-            case 'ticket':
3057
-                $hidden_fields['processing_registration']['value'] = 1;
3058
-                $template_args['title'] = esc_html__(
3059
-                    'Step One: Select the Ticket for this registration',
3060
-                    'event_espresso'
3061
-                );
3062
-                $template_args['content'] =
3063
-                    EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
3064
-                $template_args['step_button_text'] = esc_html__(
3065
-                    'Add Tickets and Continue to Registrant Details',
3066
-                    'event_espresso'
3067
-                );
3068
-                $template_args['show_notification_toggle'] = false;
3069
-                break;
3070
-            case 'questions':
3071
-                $hidden_fields['processing_registration']['value'] = 2;
3072
-                $template_args['title'] = esc_html__(
3073
-                    'Step Two: Add Registrant Details for this Registration',
3074
-                    'event_espresso'
3075
-                );
3076
-                // in theory we should be able to run EED_SPCO at this point because the cart should have been setup
3077
-                // properly by the first process_reg_step run.
3078
-                $template_args['content'] =
3079
-                    EED_Single_Page_Checkout::registration_checkout_for_admin();
3080
-                $template_args['step_button_text'] = esc_html__(
3081
-                    'Save Registration and Continue to Details',
3082
-                    'event_espresso'
3083
-                );
3084
-                $template_args['show_notification_toggle'] = true;
3085
-                break;
3086
-        }
3087
-        // we come back to the process_registration_step route.
3088
-        $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
3089
-        return EEH_Template::display_template(
3090
-            REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
3091
-            $template_args,
3092
-            true
3093
-        );
3094
-    }
3095
-
3096
-
3097
-    /**
3098
-     *        set_reg_event
3099
-     *
3100
-     * @access private
3101
-     * @return bool
3102
-     * @throws EE_Error
3103
-     * @throws InvalidArgumentException
3104
-     * @throws InvalidDataTypeException
3105
-     * @throws InvalidInterfaceException
3106
-     */
3107
-    private function _set_reg_event()
3108
-    {
3109
-        if (is_object($this->_reg_event)) {
3110
-            return true;
3111
-        }
3112
-        $EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3113
-        if (! $EVT_ID) {
3114
-            return false;
3115
-        }
3116
-        $this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
3117
-        return true;
3118
-    }
3119
-
3120
-
3121
-    /**
3122
-     * process_reg_step
3123
-     *
3124
-     * @access        public
3125
-     * @return string
3126
-     * @throws DomainException
3127
-     * @throws EE_Error
3128
-     * @throws InvalidArgumentException
3129
-     * @throws InvalidDataTypeException
3130
-     * @throws InvalidInterfaceException
3131
-     * @throws ReflectionException
3132
-     * @throws RuntimeException
3133
-     */
3134
-    public function process_reg_step()
3135
-    {
3136
-        EE_System::do_not_cache();
3137
-        $this->_set_reg_event();
3138
-        EE_Registry::instance()->REQ->set_espresso_page(true);
3139
-        EE_Registry::instance()->REQ->set('uts', time());
3140
-        // what step are we on?
3141
-        $cart = EE_Registry::instance()->SSN->cart();
3142
-        $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3143
-        // if doing ajax then we need to verify the nonce
3144
-        if (defined('DOING_AJAX')) {
3145
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
3146
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ]) : '';
3147
-            $this->_verify_nonce($nonce, $this->_req_nonce);
3148
-        }
3149
-        switch ($step) {
3150
-            case 'ticket':
3151
-                // process ticket selection
3152
-                $success = EED_Ticket_Selector::instance()->process_ticket_selections();
3153
-                if ($success) {
3154
-                    EE_Error::add_success(
3155
-                        esc_html__(
3156
-                            'Tickets Selected. Now complete the registration.',
3157
-                            'event_espresso'
3158
-                        )
3159
-                    );
3160
-                } else {
3161
-                    $query_args['step_error'] = $this->_req_data['step_error'] = true;
3162
-                }
3163
-                if (defined('DOING_AJAX')) {
3164
-                    $this->new_registration(); // display next step
3165
-                } else {
3166
-                    $query_args = array(
3167
-                        'action'                  => 'new_registration',
3168
-                        'processing_registration' => 1,
3169
-                        'event_id'                => $this->_reg_event->ID(),
3170
-                        'uts'                     => time(),
3171
-                    );
3172
-                    $this->_redirect_after_action(
3173
-                        false,
3174
-                        '',
3175
-                        '',
3176
-                        $query_args,
3177
-                        true
3178
-                    );
3179
-                }
3180
-                break;
3181
-            case 'questions':
3182
-                if (! isset(
3183
-                    $this->_req_data['txn_reg_status_change'],
3184
-                    $this->_req_data['txn_reg_status_change']['send_notifications']
3185
-                )
3186
-                ) {
3187
-                    add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3188
-                }
3189
-                // process registration
3190
-                $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3191
-                if ($cart instanceof EE_Cart) {
3192
-                    $grand_total = $cart->get_cart_grand_total();
3193
-                    if ($grand_total instanceof EE_Line_Item) {
3194
-                        $grand_total->save_this_and_descendants_to_txn();
3195
-                    }
3196
-                }
3197
-                if (! $transaction instanceof EE_Transaction) {
3198
-                    $query_args = array(
3199
-                        'action'                  => 'new_registration',
3200
-                        'processing_registration' => 2,
3201
-                        'event_id'                => $this->_reg_event->ID(),
3202
-                        'uts'                     => time(),
3203
-                    );
3204
-                    if (defined('DOING_AJAX')) {
3205
-                        // display registration form again because there are errors (maybe validation?)
3206
-                        $this->new_registration();
3207
-                        return;
3208
-                    } else {
3209
-                        $this->_redirect_after_action(
3210
-                            false,
3211
-                            '',
3212
-                            '',
3213
-                            $query_args,
3214
-                            true
3215
-                        );
3216
-                        return;
3217
-                    }
3218
-                }
3219
-                // maybe update status, and make sure to save transaction if not done already
3220
-                if (! $transaction->update_status_based_on_total_paid()) {
3221
-                    $transaction->save();
3222
-                }
3223
-                EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3224
-                $this->_req_data = array();
3225
-                $query_args = array(
3226
-                    'action'        => 'redirect_to_txn',
3227
-                    'TXN_ID'        => $transaction->ID(),
3228
-                    'EVT_ID'        => $this->_reg_event->ID(),
3229
-                    'event_name'    => urlencode($this->_reg_event->name()),
3230
-                    'redirect_from' => 'new_registration',
3231
-                );
3232
-                $this->_redirect_after_action(false, '', '', $query_args, true);
3233
-                break;
3234
-        }
3235
-        // what are you looking here for?  Should be nothing to do at this point.
3236
-    }
3237
-
3238
-
3239
-    /**
3240
-     * redirect_to_txn
3241
-     *
3242
-     * @access public
3243
-     * @return void
3244
-     * @throws EE_Error
3245
-     * @throws InvalidArgumentException
3246
-     * @throws InvalidDataTypeException
3247
-     * @throws InvalidInterfaceException
3248
-     */
3249
-    public function redirect_to_txn()
3250
-    {
3251
-        EE_System::do_not_cache();
3252
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3253
-        $query_args = array(
3254
-            'action' => 'view_transaction',
3255
-            'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
3256
-            'page'   => 'espresso_transactions',
3257
-        );
3258
-        if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
3259
-            $query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
3260
-            $query_args['event_name'] = urlencode($this->_req_data['event_name']);
3261
-            $query_args['redirect_from'] = $this->_req_data['redirect_from'];
3262
-        }
3263
-        EE_Error::add_success(
3264
-            esc_html__(
3265
-                'Registration Created.  Please review the transaction and add any payments as necessary',
3266
-                'event_espresso'
3267
-            )
3268
-        );
3269
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3270
-    }
3271
-
3272
-
3273
-    /**
3274
-     *        generates HTML for the Attendee Contact List
3275
-     *
3276
-     * @access protected
3277
-     * @return void
3278
-     */
3279
-    protected function _attendee_contact_list_table()
3280
-    {
3281
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3282
-        $this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3283
-        $this->display_admin_list_table_page_with_no_sidebar();
3284
-    }
3285
-
3286
-
3287
-    /**
3288
-     *        get_attendees
3289
-     *
3290
-     * @param      $per_page
3291
-     * @param bool $count whether to return count or data.
3292
-     * @param bool $trash
3293
-     * @return array
3294
-     * @throws EE_Error
3295
-     * @throws InvalidArgumentException
3296
-     * @throws InvalidDataTypeException
3297
-     * @throws InvalidInterfaceException
3298
-     * @access public
3299
-     */
3300
-    public function get_attendees($per_page, $count = false, $trash = false)
3301
-    {
3302
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3303
-        require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3304
-        $ATT_MDL = EEM_Attendee::instance();
3305
-        $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3306
-        switch ($this->_req_data['orderby']) {
3307
-            case 'ATT_ID':
3308
-                $orderby = 'ATT_ID';
3309
-                break;
3310
-            case 'ATT_fname':
3311
-                $orderby = 'ATT_fname';
3312
-                break;
3313
-            case 'ATT_email':
3314
-                $orderby = 'ATT_email';
3315
-                break;
3316
-            case 'ATT_city':
3317
-                $orderby = 'ATT_city';
3318
-                break;
3319
-            case 'STA_ID':
3320
-                $orderby = 'STA_ID';
3321
-                break;
3322
-            case 'CNT_ID':
3323
-                $orderby = 'CNT_ID';
3324
-                break;
3325
-            case 'Registration_Count':
3326
-                $orderby = 'Registration_Count';
3327
-                break;
3328
-            default:
3329
-                $orderby = 'ATT_lname';
3330
-        }
3331
-        $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
3332
-            ? $this->_req_data['order']
3333
-            : 'ASC';
3334
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
3335
-            ? $this->_req_data['paged']
3336
-            : 1;
3337
-        $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
3338
-        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
3339
-            ? $this->_req_data['perpage']
3340
-            : $per_page;
3341
-        $_where = array();
3342
-        if (! empty($this->_req_data['s'])) {
3343
-            $sstr = '%' . $this->_req_data['s'] . '%';
3344
-            $_where['OR'] = array(
3345
-                'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3346
-                'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
3347
-                'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
3348
-                'ATT_fname'                         => array('LIKE', $sstr),
3349
-                'ATT_lname'                         => array('LIKE', $sstr),
3350
-                'ATT_short_bio'                     => array('LIKE', $sstr),
3351
-                'ATT_email'                         => array('LIKE', $sstr),
3352
-                'ATT_address'                       => array('LIKE', $sstr),
3353
-                'ATT_address2'                      => array('LIKE', $sstr),
3354
-                'ATT_city'                          => array('LIKE', $sstr),
3355
-                'Country.CNT_name'                  => array('LIKE', $sstr),
3356
-                'State.STA_name'                    => array('LIKE', $sstr),
3357
-                'ATT_phone'                         => array('LIKE', $sstr),
3358
-                'Registration.REG_final_price'      => array('LIKE', $sstr),
3359
-                'Registration.REG_code'             => array('LIKE', $sstr),
3360
-                'Registration.REG_group_size'       => array('LIKE', $sstr),
3361
-            );
3362
-        }
3363
-        $offset = ($current_page - 1) * $per_page;
3364
-        $limit = $count ? null : array($offset, $per_page);
3365
-        $query_args = array(
3366
-            $_where,
3367
-            'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3368
-            'limit'         => $limit,
3369
-        );
3370
-        if (! $count) {
3371
-            $query_args['order_by'] = array($orderby => $sort);
3372
-        }
3373
-        if ($trash) {
3374
-            $query_args[0]['status'] = array('!=', 'publish');
3375
-            $all_attendees = $count
3376
-                ? $ATT_MDL->count($query_args, 'ATT_ID', true)
3377
-                : $ATT_MDL->get_all($query_args);
3378
-        } else {
3379
-            $query_args[0]['status'] = array('IN', array('publish'));
3380
-            $all_attendees = $count
3381
-                ? $ATT_MDL->count($query_args, 'ATT_ID', true)
3382
-                : $ATT_MDL->get_all($query_args);
3383
-        }
3384
-        return $all_attendees;
3385
-    }
3386
-
3387
-
3388
-    /**
3389
-     * This is just taking care of resending the registration confirmation
3390
-     *
3391
-     * @access protected
3392
-     * @return void
3393
-     */
3394
-    protected function _resend_registration()
3395
-    {
3396
-        $this->_process_resend_registration();
3397
-        $query_args = isset($this->_req_data['redirect_to'])
3398
-            ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
3399
-            : array('action' => 'default');
3400
-        $this->_redirect_after_action(false, '', '', $query_args, true);
3401
-    }
3402
-
3403
-    /**
3404
-     * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3405
-     * to use when selecting registrations
3406
-     *
3407
-     * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3408
-     *                                                     the query parameters from the request
3409
-     * @return void ends the request with a redirect or download
3410
-     */
3411
-    public function _registrations_report_base($method_name_for_getting_query_params)
3412
-    {
3413
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3414
-            wp_redirect(
3415
-                EE_Admin_Page::add_query_args_and_nonce(
3416
-                    array(
3417
-                        'page'        => 'espresso_batch',
3418
-                        'batch'       => 'file',
3419
-                        'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3420
-                        'filters'     => urlencode(
3421
-                            serialize(
3422
-                                call_user_func(
3423
-                                    array($this, $method_name_for_getting_query_params),
3424
-                                    EEH_Array::is_set(
3425
-                                        $this->_req_data,
3426
-                                        'filters',
3427
-                                        array()
3428
-                                    )
3429
-                                )
3430
-                            )
3431
-                        ),
3432
-                        'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false),
3433
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3434
-                        'return_url'  => urlencode($this->_req_data['return_url']),
3435
-                    )
3436
-                )
3437
-            );
3438
-        } else {
3439
-            $new_request_args = array(
3440
-                'export' => 'report',
3441
-                'action' => 'registrations_report_for_event',
3442
-                'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3443
-            );
3444
-            $this->_req_data = array_merge($this->_req_data, $new_request_args);
3445
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3446
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3447
-                $EE_Export = EE_Export::instance($this->_req_data);
3448
-                $EE_Export->export();
3449
-            }
3450
-        }
3451
-    }
3452
-
3453
-
3454
-    /**
3455
-     * Creates a registration report using only query parameters in the request
3456
-     *
3457
-     * @return void
3458
-     */
3459
-    public function _registrations_report()
3460
-    {
3461
-        $this->_registrations_report_base('_get_registration_query_parameters');
3462
-    }
3463
-
3464
-
3465
-    public function _contact_list_export()
3466
-    {
3467
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3468
-            require_once(EE_CLASSES . 'EE_Export.class.php');
3469
-            $EE_Export = EE_Export::instance($this->_req_data);
3470
-            $EE_Export->export_attendees();
3471
-        }
3472
-    }
3473
-
3474
-
3475
-    public function _contact_list_report()
3476
-    {
3477
-        if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3478
-            wp_redirect(
3479
-                EE_Admin_Page::add_query_args_and_nonce(
3480
-                    array(
3481
-                        'page'        => 'espresso_batch',
3482
-                        'batch'       => 'file',
3483
-                        'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3484
-                        'return_url'  => urlencode($this->_req_data['return_url']),
3485
-                    )
3486
-                )
3487
-            );
3488
-        } else {
3489
-            if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3490
-                require_once(EE_CLASSES . 'EE_Export.class.php');
3491
-                $EE_Export = EE_Export::instance($this->_req_data);
3492
-                $EE_Export->report_attendees();
3493
-            }
3494
-        }
3495
-    }
3496
-
3497
-
3498
-
3499
-
3500
-
3501
-    /***************************************        ATTENDEE DETAILS        ***************************************/
3502
-    /**
3503
-     * This duplicates the attendee object for the given incoming registration id and attendee_id.
3504
-     *
3505
-     * @return void
3506
-     * @throws EE_Error
3507
-     * @throws InvalidArgumentException
3508
-     * @throws InvalidDataTypeException
3509
-     * @throws InvalidInterfaceException
3510
-     */
3511
-    protected function _duplicate_attendee()
3512
-    {
3513
-        $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
3514
-        // verify we have necessary info
3515
-        if (empty($this->_req_data['_REG_ID'])) {
3516
-            EE_Error::add_error(
3517
-                esc_html__(
3518
-                    'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3519
-                    'event_espresso'
3520
-                ),
3521
-                __FILE__,
3522
-                __LINE__,
3523
-                __FUNCTION__
3524
-            );
3525
-            $query_args = array('action' => $action);
3526
-            $this->_redirect_after_action('', '', '', $query_args, true);
3527
-        }
3528
-        // okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3529
-        $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
3530
-        $attendee = $registration->attendee();
3531
-        // remove relation of existing attendee on registration
3532
-        $registration->_remove_relation_to($attendee, 'Attendee');
3533
-        // new attendee
3534
-        $new_attendee = clone $attendee;
3535
-        $new_attendee->set('ATT_ID', 0);
3536
-        $new_attendee->save();
3537
-        // add new attendee to reg
3538
-        $registration->_add_relation_to($new_attendee, 'Attendee');
3539
-        EE_Error::add_success(
3540
-            esc_html__(
3541
-                'New Contact record created.  Now make any edits you wish to make for this contact.',
3542
-                'event_espresso'
3543
-            )
3544
-        );
3545
-        // redirect to edit page for attendee
3546
-        $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
3547
-        $this->_redirect_after_action('', '', '', $query_args, true);
3548
-    }
3549
-
3550
-
3551
-    /**
3552
-     * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3553
-     *
3554
-     * @param int     $post_id
3555
-     * @param WP_POST $post
3556
-     * @throws DomainException
3557
-     * @throws EE_Error
3558
-     * @throws InvalidArgumentException
3559
-     * @throws InvalidDataTypeException
3560
-     * @throws InvalidInterfaceException
3561
-     * @throws LogicException
3562
-     * @throws InvalidFormSubmissionException
3563
-     */
3564
-    protected function _insert_update_cpt_item($post_id, $post)
3565
-    {
3566
-        $success = true;
3567
-        $attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3568
-            ? EEM_Attendee::instance()->get_one_by_ID($post_id)
3569
-            : null;
3570
-        // for attendee updates
3571
-        if ($attendee instanceof EE_Attendee) {
3572
-            // note we should only be UPDATING attendees at this point.
3573
-            $updated_fields = array(
3574
-                'ATT_fname'     => $this->_req_data['ATT_fname'],
3575
-                'ATT_lname'     => $this->_req_data['ATT_lname'],
3576
-                'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3577
-                'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3578
-                'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3579
-                'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
3580
-                'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
3581
-                'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
3582
-                'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
3583
-            );
3584
-            foreach ($updated_fields as $field => $value) {
3585
-                $attendee->set($field, $value);
3586
-            }
3587
-
3588
-            // process contact details metabox form handler (which will also save the attendee)
3589
-            $contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3590
-            $success = $contact_details_form->process($this->_req_data);
3591
-
3592
-            $attendee_update_callbacks = apply_filters(
3593
-                'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3594
-                array()
3595
-            );
3596
-            foreach ($attendee_update_callbacks as $a_callback) {
3597
-                if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
3598
-                    throw new EE_Error(
3599
-                        sprintf(
3600
-                            esc_html__(
3601
-                                'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3602
-                                'event_espresso'
3603
-                            ),
3604
-                            $a_callback
3605
-                        )
3606
-                    );
3607
-                }
3608
-            }
3609
-        }
3610
-
3611
-        if ($success === false) {
3612
-            EE_Error::add_error(
3613
-                esc_html__(
3614
-                    'Something went wrong with updating the meta table data for the registration.',
3615
-                    'event_espresso'
3616
-                ),
3617
-                __FILE__,
3618
-                __FUNCTION__,
3619
-                __LINE__
3620
-            );
3621
-        }
3622
-    }
3623
-
3624
-
3625
-    public function trash_cpt_item($post_id)
3626
-    {
3627
-    }
3628
-
3629
-
3630
-    public function delete_cpt_item($post_id)
3631
-    {
3632
-    }
3633
-
3634
-
3635
-    public function restore_cpt_item($post_id)
3636
-    {
3637
-    }
3638
-
3639
-
3640
-    protected function _restore_cpt_item($post_id, $revision_id)
3641
-    {
3642
-    }
3643
-
3644
-
3645
-    public function attendee_editor_metaboxes()
3646
-    {
3647
-        $this->verify_cpt_object();
3648
-        remove_meta_box(
3649
-            'postexcerpt',
3650
-            esc_html__('Excerpt', 'event_espresso'),
3651
-            'post_excerpt_meta_box',
3652
-            $this->_cpt_routes[ $this->_req_action ],
3653
-            'normal',
3654
-            'core'
3655
-        );
3656
-        remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3657
-        if (post_type_supports('espresso_attendees', 'excerpt')) {
3658
-            add_meta_box(
3659
-                'postexcerpt',
3660
-                esc_html__('Short Biography', 'event_espresso'),
3661
-                'post_excerpt_meta_box',
3662
-                $this->_cpt_routes[ $this->_req_action ],
3663
-                'normal'
3664
-            );
3665
-        }
3666
-        if (post_type_supports('espresso_attendees', 'comments')) {
3667
-            add_meta_box(
3668
-                'commentsdiv',
3669
-                esc_html__('Notes on the Contact', 'event_espresso'),
3670
-                'post_comment_meta_box',
3671
-                $this->_cpt_routes[ $this->_req_action ],
3672
-                'normal',
3673
-                'core'
3674
-            );
3675
-        }
3676
-        add_meta_box(
3677
-            'attendee_contact_info',
3678
-            esc_html__('Contact Info', 'event_espresso'),
3679
-            array($this, 'attendee_contact_info'),
3680
-            $this->_cpt_routes[ $this->_req_action ],
3681
-            'side',
3682
-            'core'
3683
-        );
3684
-        add_meta_box(
3685
-            'attendee_details_address',
3686
-            esc_html__('Address Details', 'event_espresso'),
3687
-            array($this, 'attendee_address_details'),
3688
-            $this->_cpt_routes[ $this->_req_action ],
3689
-            'normal',
3690
-            'core'
3691
-        );
3692
-        add_meta_box(
3693
-            'attendee_registrations',
3694
-            esc_html__('Registrations for this Contact', 'event_espresso'),
3695
-            array($this, 'attendee_registrations_meta_box'),
3696
-            $this->_cpt_routes[ $this->_req_action ],
3697
-            'normal',
3698
-            'high'
3699
-        );
3700
-    }
3701
-
3702
-
3703
-    /**
3704
-     * Metabox for attendee contact info
3705
-     *
3706
-     * @param  WP_Post $post wp post object
3707
-     * @return string attendee contact info ( and form )
3708
-     * @throws EE_Error
3709
-     * @throws InvalidArgumentException
3710
-     * @throws InvalidDataTypeException
3711
-     * @throws InvalidInterfaceException
3712
-     * @throws LogicException
3713
-     * @throws DomainException
3714
-     */
3715
-    public function attendee_contact_info($post)
3716
-    {
3717
-        // get attendee object ( should already have it )
3718
-        $form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3719
-        $form->enqueueStylesAndScripts();
3720
-        echo $form->display();
3721
-    }
3722
-
3723
-
3724
-    /**
3725
-     * Return form handler for the contact details metabox
3726
-     *
3727
-     * @param EE_Attendee $attendee
3728
-     * @return AttendeeContactDetailsMetaboxFormHandler
3729
-     * @throws DomainException
3730
-     * @throws InvalidArgumentException
3731
-     * @throws InvalidDataTypeException
3732
-     * @throws InvalidInterfaceException
3733
-     */
3734
-    protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3735
-    {
3736
-        return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3737
-    }
3738
-
3739
-
3740
-    /**
3741
-     * Metabox for attendee details
3742
-     *
3743
-     * @param  WP_Post $post wp post object
3744
-     * @throws DomainException
3745
-     */
3746
-    public function attendee_address_details($post)
3747
-    {
3748
-        // get attendee object (should already have it)
3749
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
3750
-        $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
3751
-            new EE_Question_Form_Input(
3752
-                EE_Question::new_instance(
3753
-                    array(
3754
-                        'QST_ID'           => 0,
3755
-                        'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3756
-                        'QST_system'       => 'admin-state',
3757
-                    )
3758
-                ),
3759
-                EE_Answer::new_instance(
3760
-                    array(
3761
-                        'ANS_ID'    => 0,
3762
-                        'ANS_value' => $this->_cpt_model_obj->state_ID(),
3763
-                    )
3764
-                ),
3765
-                array(
3766
-                    'input_id'       => 'STA_ID',
3767
-                    'input_name'     => 'STA_ID',
3768
-                    'input_prefix'   => '',
3769
-                    'append_qstn_id' => false,
3770
-                )
3771
-            )
3772
-        );
3773
-        $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3774
-            new EE_Question_Form_Input(
3775
-                EE_Question::new_instance(
3776
-                    array(
3777
-                        'QST_ID'           => 0,
3778
-                        'QST_display_text' => esc_html__('Country', 'event_espresso'),
3779
-                        'QST_system'       => 'admin-country',
3780
-                    )
3781
-                ),
3782
-                EE_Answer::new_instance(
3783
-                    array(
3784
-                        'ANS_ID'    => 0,
3785
-                        'ANS_value' => $this->_cpt_model_obj->country_ID(),
3786
-                    )
3787
-                ),
3788
-                array(
3789
-                    'input_id'       => 'CNT_ISO',
3790
-                    'input_name'     => 'CNT_ISO',
3791
-                    'input_prefix'   => '',
3792
-                    'append_qstn_id' => false,
3793
-                )
3794
-            )
3795
-        );
3796
-        $template =
3797
-            REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3798
-        EEH_Template::display_template($template, $this->_template_args);
3799
-    }
3800
-
3801
-
3802
-    /**
3803
-     *        _attendee_details
3804
-     *
3805
-     * @access protected
3806
-     * @param $post
3807
-     * @return void
3808
-     * @throws DomainException
3809
-     * @throws EE_Error
3810
-     */
3811
-    public function attendee_registrations_meta_box($post)
3812
-    {
3813
-        $this->_template_args['attendee'] = $this->_cpt_model_obj;
3814
-        $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3815
-        $template =
3816
-            REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3817
-        EEH_Template::display_template($template, $this->_template_args);
3818
-    }
3819
-
3820
-
3821
-    /**
3822
-     * add in the form fields for the attendee edit
3823
-     *
3824
-     * @param  WP_Post $post wp post object
3825
-     * @return string html for new form.
3826
-     * @throws DomainException
3827
-     */
3828
-    public function after_title_form_fields($post)
3829
-    {
3830
-        if ($post->post_type == 'espresso_attendees') {
3831
-            $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3832
-            $template_args['attendee'] = $this->_cpt_model_obj;
3833
-            EEH_Template::display_template($template, $template_args);
3834
-        }
3835
-    }
3836
-
3837
-
3838
-    /**
3839
-     *        _trash_or_restore_attendee
3840
-     *
3841
-     * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3842
-     * @return void
3843
-     * @throws EE_Error
3844
-     * @throws InvalidArgumentException
3845
-     * @throws InvalidDataTypeException
3846
-     * @throws InvalidInterfaceException
3847
-     * @access protected
3848
-     */
3849
-    protected function _trash_or_restore_attendees($trash = true)
3850
-    {
3851
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3852
-        $ATT_MDL = EEM_Attendee::instance();
3853
-        $success = 1;
3854
-        // Checkboxes
3855
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3856
-            // if array has more than one element than success message should be plural
3857
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3858
-            // cycle thru checkboxes
3859
-            while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
3860
-                $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
3861
-                    : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
3862
-                if (! $updated) {
3863
-                    $success = 0;
3864
-                }
3865
-            }
3866
-        } else {
3867
-            // grab single id and delete
3868
-            $ATT_ID = absint($this->_req_data['ATT_ID']);
3869
-            // get attendee
3870
-            $att = $ATT_MDL->get_one_by_ID($ATT_ID);
3871
-            $updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
3872
-            $updated = $att->save();
3873
-            if (! $updated) {
3874
-                $success = 0;
3875
-            }
3876
-        }
3877
-        $what = $success > 1
3878
-            ? esc_html__('Contacts', 'event_espresso')
3879
-            : esc_html__('Contact', 'event_espresso');
3880
-        $action_desc = $trash
3881
-            ? esc_html__('moved to the trash', 'event_espresso')
3882
-            : esc_html__('restored', 'event_espresso');
3883
-        $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
3884
-    }
3034
+		}
3035
+		$template_args = array(
3036
+			'title'                    => '',
3037
+			'content'                  => '',
3038
+			'step_button_text'         => '',
3039
+			'show_notification_toggle' => false,
3040
+		);
3041
+		// to indicate we're processing a new registration
3042
+		$hidden_fields = array(
3043
+			'processing_registration' => array(
3044
+				'type'  => 'hidden',
3045
+				'value' => 0,
3046
+			),
3047
+			'event_id'                => array(
3048
+				'type'  => 'hidden',
3049
+				'value' => $this->_reg_event->ID(),
3050
+			),
3051
+		);
3052
+		// if the cart is empty then we know we're at step one so we'll display ticket selector
3053
+		$cart = EE_Registry::instance()->SSN->cart();
3054
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3055
+		switch ($step) {
3056
+			case 'ticket':
3057
+				$hidden_fields['processing_registration']['value'] = 1;
3058
+				$template_args['title'] = esc_html__(
3059
+					'Step One: Select the Ticket for this registration',
3060
+					'event_espresso'
3061
+				);
3062
+				$template_args['content'] =
3063
+					EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
3064
+				$template_args['step_button_text'] = esc_html__(
3065
+					'Add Tickets and Continue to Registrant Details',
3066
+					'event_espresso'
3067
+				);
3068
+				$template_args['show_notification_toggle'] = false;
3069
+				break;
3070
+			case 'questions':
3071
+				$hidden_fields['processing_registration']['value'] = 2;
3072
+				$template_args['title'] = esc_html__(
3073
+					'Step Two: Add Registrant Details for this Registration',
3074
+					'event_espresso'
3075
+				);
3076
+				// in theory we should be able to run EED_SPCO at this point because the cart should have been setup
3077
+				// properly by the first process_reg_step run.
3078
+				$template_args['content'] =
3079
+					EED_Single_Page_Checkout::registration_checkout_for_admin();
3080
+				$template_args['step_button_text'] = esc_html__(
3081
+					'Save Registration and Continue to Details',
3082
+					'event_espresso'
3083
+				);
3084
+				$template_args['show_notification_toggle'] = true;
3085
+				break;
3086
+		}
3087
+		// we come back to the process_registration_step route.
3088
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields);
3089
+		return EEH_Template::display_template(
3090
+			REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php',
3091
+			$template_args,
3092
+			true
3093
+		);
3094
+	}
3095
+
3096
+
3097
+	/**
3098
+	 *        set_reg_event
3099
+	 *
3100
+	 * @access private
3101
+	 * @return bool
3102
+	 * @throws EE_Error
3103
+	 * @throws InvalidArgumentException
3104
+	 * @throws InvalidDataTypeException
3105
+	 * @throws InvalidInterfaceException
3106
+	 */
3107
+	private function _set_reg_event()
3108
+	{
3109
+		if (is_object($this->_reg_event)) {
3110
+			return true;
3111
+		}
3112
+		$EVT_ID = (! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : false;
3113
+		if (! $EVT_ID) {
3114
+			return false;
3115
+		}
3116
+		$this->_reg_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
3117
+		return true;
3118
+	}
3119
+
3120
+
3121
+	/**
3122
+	 * process_reg_step
3123
+	 *
3124
+	 * @access        public
3125
+	 * @return string
3126
+	 * @throws DomainException
3127
+	 * @throws EE_Error
3128
+	 * @throws InvalidArgumentException
3129
+	 * @throws InvalidDataTypeException
3130
+	 * @throws InvalidInterfaceException
3131
+	 * @throws ReflectionException
3132
+	 * @throws RuntimeException
3133
+	 */
3134
+	public function process_reg_step()
3135
+	{
3136
+		EE_System::do_not_cache();
3137
+		$this->_set_reg_event();
3138
+		EE_Registry::instance()->REQ->set_espresso_page(true);
3139
+		EE_Registry::instance()->REQ->set('uts', time());
3140
+		// what step are we on?
3141
+		$cart = EE_Registry::instance()->SSN->cart();
3142
+		$step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions';
3143
+		// if doing ajax then we need to verify the nonce
3144
+		if (defined('DOING_AJAX')) {
3145
+			$nonce = isset($this->_req_data[ $this->_req_nonce ])
3146
+				? sanitize_text_field($this->_req_data[ $this->_req_nonce ]) : '';
3147
+			$this->_verify_nonce($nonce, $this->_req_nonce);
3148
+		}
3149
+		switch ($step) {
3150
+			case 'ticket':
3151
+				// process ticket selection
3152
+				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
3153
+				if ($success) {
3154
+					EE_Error::add_success(
3155
+						esc_html__(
3156
+							'Tickets Selected. Now complete the registration.',
3157
+							'event_espresso'
3158
+						)
3159
+					);
3160
+				} else {
3161
+					$query_args['step_error'] = $this->_req_data['step_error'] = true;
3162
+				}
3163
+				if (defined('DOING_AJAX')) {
3164
+					$this->new_registration(); // display next step
3165
+				} else {
3166
+					$query_args = array(
3167
+						'action'                  => 'new_registration',
3168
+						'processing_registration' => 1,
3169
+						'event_id'                => $this->_reg_event->ID(),
3170
+						'uts'                     => time(),
3171
+					);
3172
+					$this->_redirect_after_action(
3173
+						false,
3174
+						'',
3175
+						'',
3176
+						$query_args,
3177
+						true
3178
+					);
3179
+				}
3180
+				break;
3181
+			case 'questions':
3182
+				if (! isset(
3183
+					$this->_req_data['txn_reg_status_change'],
3184
+					$this->_req_data['txn_reg_status_change']['send_notifications']
3185
+				)
3186
+				) {
3187
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
3188
+				}
3189
+				// process registration
3190
+				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
3191
+				if ($cart instanceof EE_Cart) {
3192
+					$grand_total = $cart->get_cart_grand_total();
3193
+					if ($grand_total instanceof EE_Line_Item) {
3194
+						$grand_total->save_this_and_descendants_to_txn();
3195
+					}
3196
+				}
3197
+				if (! $transaction instanceof EE_Transaction) {
3198
+					$query_args = array(
3199
+						'action'                  => 'new_registration',
3200
+						'processing_registration' => 2,
3201
+						'event_id'                => $this->_reg_event->ID(),
3202
+						'uts'                     => time(),
3203
+					);
3204
+					if (defined('DOING_AJAX')) {
3205
+						// display registration form again because there are errors (maybe validation?)
3206
+						$this->new_registration();
3207
+						return;
3208
+					} else {
3209
+						$this->_redirect_after_action(
3210
+							false,
3211
+							'',
3212
+							'',
3213
+							$query_args,
3214
+							true
3215
+						);
3216
+						return;
3217
+					}
3218
+				}
3219
+				// maybe update status, and make sure to save transaction if not done already
3220
+				if (! $transaction->update_status_based_on_total_paid()) {
3221
+					$transaction->save();
3222
+				}
3223
+				EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3224
+				$this->_req_data = array();
3225
+				$query_args = array(
3226
+					'action'        => 'redirect_to_txn',
3227
+					'TXN_ID'        => $transaction->ID(),
3228
+					'EVT_ID'        => $this->_reg_event->ID(),
3229
+					'event_name'    => urlencode($this->_reg_event->name()),
3230
+					'redirect_from' => 'new_registration',
3231
+				);
3232
+				$this->_redirect_after_action(false, '', '', $query_args, true);
3233
+				break;
3234
+		}
3235
+		// what are you looking here for?  Should be nothing to do at this point.
3236
+	}
3237
+
3238
+
3239
+	/**
3240
+	 * redirect_to_txn
3241
+	 *
3242
+	 * @access public
3243
+	 * @return void
3244
+	 * @throws EE_Error
3245
+	 * @throws InvalidArgumentException
3246
+	 * @throws InvalidDataTypeException
3247
+	 * @throws InvalidInterfaceException
3248
+	 */
3249
+	public function redirect_to_txn()
3250
+	{
3251
+		EE_System::do_not_cache();
3252
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
3253
+		$query_args = array(
3254
+			'action' => 'view_transaction',
3255
+			'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0,
3256
+			'page'   => 'espresso_transactions',
3257
+		);
3258
+		if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) {
3259
+			$query_args['EVT_ID'] = $this->_req_data['EVT_ID'];
3260
+			$query_args['event_name'] = urlencode($this->_req_data['event_name']);
3261
+			$query_args['redirect_from'] = $this->_req_data['redirect_from'];
3262
+		}
3263
+		EE_Error::add_success(
3264
+			esc_html__(
3265
+				'Registration Created.  Please review the transaction and add any payments as necessary',
3266
+				'event_espresso'
3267
+			)
3268
+		);
3269
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3270
+	}
3271
+
3272
+
3273
+	/**
3274
+	 *        generates HTML for the Attendee Contact List
3275
+	 *
3276
+	 * @access protected
3277
+	 * @return void
3278
+	 */
3279
+	protected function _attendee_contact_list_table()
3280
+	{
3281
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3282
+		$this->_search_btn_label = esc_html__('Contacts', 'event_espresso');
3283
+		$this->display_admin_list_table_page_with_no_sidebar();
3284
+	}
3285
+
3286
+
3287
+	/**
3288
+	 *        get_attendees
3289
+	 *
3290
+	 * @param      $per_page
3291
+	 * @param bool $count whether to return count or data.
3292
+	 * @param bool $trash
3293
+	 * @return array
3294
+	 * @throws EE_Error
3295
+	 * @throws InvalidArgumentException
3296
+	 * @throws InvalidDataTypeException
3297
+	 * @throws InvalidInterfaceException
3298
+	 * @access public
3299
+	 */
3300
+	public function get_attendees($per_page, $count = false, $trash = false)
3301
+	{
3302
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3303
+		require_once(REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php');
3304
+		$ATT_MDL = EEM_Attendee::instance();
3305
+		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
3306
+		switch ($this->_req_data['orderby']) {
3307
+			case 'ATT_ID':
3308
+				$orderby = 'ATT_ID';
3309
+				break;
3310
+			case 'ATT_fname':
3311
+				$orderby = 'ATT_fname';
3312
+				break;
3313
+			case 'ATT_email':
3314
+				$orderby = 'ATT_email';
3315
+				break;
3316
+			case 'ATT_city':
3317
+				$orderby = 'ATT_city';
3318
+				break;
3319
+			case 'STA_ID':
3320
+				$orderby = 'STA_ID';
3321
+				break;
3322
+			case 'CNT_ID':
3323
+				$orderby = 'CNT_ID';
3324
+				break;
3325
+			case 'Registration_Count':
3326
+				$orderby = 'Registration_Count';
3327
+				break;
3328
+			default:
3329
+				$orderby = 'ATT_lname';
3330
+		}
3331
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
3332
+			? $this->_req_data['order']
3333
+			: 'ASC';
3334
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
3335
+			? $this->_req_data['paged']
3336
+			: 1;
3337
+		$per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
3338
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
3339
+			? $this->_req_data['perpage']
3340
+			: $per_page;
3341
+		$_where = array();
3342
+		if (! empty($this->_req_data['s'])) {
3343
+			$sstr = '%' . $this->_req_data['s'] . '%';
3344
+			$_where['OR'] = array(
3345
+				'Registration.Event.EVT_name'       => array('LIKE', $sstr),
3346
+				'Registration.Event.EVT_desc'       => array('LIKE', $sstr),
3347
+				'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
3348
+				'ATT_fname'                         => array('LIKE', $sstr),
3349
+				'ATT_lname'                         => array('LIKE', $sstr),
3350
+				'ATT_short_bio'                     => array('LIKE', $sstr),
3351
+				'ATT_email'                         => array('LIKE', $sstr),
3352
+				'ATT_address'                       => array('LIKE', $sstr),
3353
+				'ATT_address2'                      => array('LIKE', $sstr),
3354
+				'ATT_city'                          => array('LIKE', $sstr),
3355
+				'Country.CNT_name'                  => array('LIKE', $sstr),
3356
+				'State.STA_name'                    => array('LIKE', $sstr),
3357
+				'ATT_phone'                         => array('LIKE', $sstr),
3358
+				'Registration.REG_final_price'      => array('LIKE', $sstr),
3359
+				'Registration.REG_code'             => array('LIKE', $sstr),
3360
+				'Registration.REG_group_size'       => array('LIKE', $sstr),
3361
+			);
3362
+		}
3363
+		$offset = ($current_page - 1) * $per_page;
3364
+		$limit = $count ? null : array($offset, $per_page);
3365
+		$query_args = array(
3366
+			$_where,
3367
+			'extra_selects' => array('Registration_Count' => array('Registration.REG_ID', 'count', '%d')),
3368
+			'limit'         => $limit,
3369
+		);
3370
+		if (! $count) {
3371
+			$query_args['order_by'] = array($orderby => $sort);
3372
+		}
3373
+		if ($trash) {
3374
+			$query_args[0]['status'] = array('!=', 'publish');
3375
+			$all_attendees = $count
3376
+				? $ATT_MDL->count($query_args, 'ATT_ID', true)
3377
+				: $ATT_MDL->get_all($query_args);
3378
+		} else {
3379
+			$query_args[0]['status'] = array('IN', array('publish'));
3380
+			$all_attendees = $count
3381
+				? $ATT_MDL->count($query_args, 'ATT_ID', true)
3382
+				: $ATT_MDL->get_all($query_args);
3383
+		}
3384
+		return $all_attendees;
3385
+	}
3386
+
3387
+
3388
+	/**
3389
+	 * This is just taking care of resending the registration confirmation
3390
+	 *
3391
+	 * @access protected
3392
+	 * @return void
3393
+	 */
3394
+	protected function _resend_registration()
3395
+	{
3396
+		$this->_process_resend_registration();
3397
+		$query_args = isset($this->_req_data['redirect_to'])
3398
+			? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'])
3399
+			: array('action' => 'default');
3400
+		$this->_redirect_after_action(false, '', '', $query_args, true);
3401
+	}
3402
+
3403
+	/**
3404
+	 * Creates a registration report, but accepts the name of a method to use for preparing the query parameters
3405
+	 * to use when selecting registrations
3406
+	 *
3407
+	 * @param string $method_name_for_getting_query_params the name of the method (on this class) to use for preparing
3408
+	 *                                                     the query parameters from the request
3409
+	 * @return void ends the request with a redirect or download
3410
+	 */
3411
+	public function _registrations_report_base($method_name_for_getting_query_params)
3412
+	{
3413
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3414
+			wp_redirect(
3415
+				EE_Admin_Page::add_query_args_and_nonce(
3416
+					array(
3417
+						'page'        => 'espresso_batch',
3418
+						'batch'       => 'file',
3419
+						'EVT_ID'      => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3420
+						'filters'     => urlencode(
3421
+							serialize(
3422
+								call_user_func(
3423
+									array($this, $method_name_for_getting_query_params),
3424
+									EEH_Array::is_set(
3425
+										$this->_req_data,
3426
+										'filters',
3427
+										array()
3428
+									)
3429
+								)
3430
+							)
3431
+						),
3432
+						'use_filters' => EEH_Array::is_set($this->_req_data, 'use_filters', false),
3433
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
3434
+						'return_url'  => urlencode($this->_req_data['return_url']),
3435
+					)
3436
+				)
3437
+			);
3438
+		} else {
3439
+			$new_request_args = array(
3440
+				'export' => 'report',
3441
+				'action' => 'registrations_report_for_event',
3442
+				'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : null,
3443
+			);
3444
+			$this->_req_data = array_merge($this->_req_data, $new_request_args);
3445
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3446
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3447
+				$EE_Export = EE_Export::instance($this->_req_data);
3448
+				$EE_Export->export();
3449
+			}
3450
+		}
3451
+	}
3452
+
3453
+
3454
+	/**
3455
+	 * Creates a registration report using only query parameters in the request
3456
+	 *
3457
+	 * @return void
3458
+	 */
3459
+	public function _registrations_report()
3460
+	{
3461
+		$this->_registrations_report_base('_get_registration_query_parameters');
3462
+	}
3463
+
3464
+
3465
+	public function _contact_list_export()
3466
+	{
3467
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3468
+			require_once(EE_CLASSES . 'EE_Export.class.php');
3469
+			$EE_Export = EE_Export::instance($this->_req_data);
3470
+			$EE_Export->export_attendees();
3471
+		}
3472
+	}
3473
+
3474
+
3475
+	public function _contact_list_report()
3476
+	{
3477
+		if (! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
3478
+			wp_redirect(
3479
+				EE_Admin_Page::add_query_args_and_nonce(
3480
+					array(
3481
+						'page'        => 'espresso_batch',
3482
+						'batch'       => 'file',
3483
+						'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
3484
+						'return_url'  => urlencode($this->_req_data['return_url']),
3485
+					)
3486
+				)
3487
+			);
3488
+		} else {
3489
+			if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
3490
+				require_once(EE_CLASSES . 'EE_Export.class.php');
3491
+				$EE_Export = EE_Export::instance($this->_req_data);
3492
+				$EE_Export->report_attendees();
3493
+			}
3494
+		}
3495
+	}
3496
+
3497
+
3498
+
3499
+
3500
+
3501
+	/***************************************        ATTENDEE DETAILS        ***************************************/
3502
+	/**
3503
+	 * This duplicates the attendee object for the given incoming registration id and attendee_id.
3504
+	 *
3505
+	 * @return void
3506
+	 * @throws EE_Error
3507
+	 * @throws InvalidArgumentException
3508
+	 * @throws InvalidDataTypeException
3509
+	 * @throws InvalidInterfaceException
3510
+	 */
3511
+	protected function _duplicate_attendee()
3512
+	{
3513
+		$action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
3514
+		// verify we have necessary info
3515
+		if (empty($this->_req_data['_REG_ID'])) {
3516
+			EE_Error::add_error(
3517
+				esc_html__(
3518
+					'Unable to create the contact for the registration because the required parameters are not present (_REG_ID )',
3519
+					'event_espresso'
3520
+				),
3521
+				__FILE__,
3522
+				__LINE__,
3523
+				__FUNCTION__
3524
+			);
3525
+			$query_args = array('action' => $action);
3526
+			$this->_redirect_after_action('', '', '', $query_args, true);
3527
+		}
3528
+		// okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
3529
+		$registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
3530
+		$attendee = $registration->attendee();
3531
+		// remove relation of existing attendee on registration
3532
+		$registration->_remove_relation_to($attendee, 'Attendee');
3533
+		// new attendee
3534
+		$new_attendee = clone $attendee;
3535
+		$new_attendee->set('ATT_ID', 0);
3536
+		$new_attendee->save();
3537
+		// add new attendee to reg
3538
+		$registration->_add_relation_to($new_attendee, 'Attendee');
3539
+		EE_Error::add_success(
3540
+			esc_html__(
3541
+				'New Contact record created.  Now make any edits you wish to make for this contact.',
3542
+				'event_espresso'
3543
+			)
3544
+		);
3545
+		// redirect to edit page for attendee
3546
+		$query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
3547
+		$this->_redirect_after_action('', '', '', $query_args, true);
3548
+	}
3549
+
3550
+
3551
+	/**
3552
+	 * Callback invoked by parent EE_Admin_CPT class hooked in on `save_post` wp hook.
3553
+	 *
3554
+	 * @param int     $post_id
3555
+	 * @param WP_POST $post
3556
+	 * @throws DomainException
3557
+	 * @throws EE_Error
3558
+	 * @throws InvalidArgumentException
3559
+	 * @throws InvalidDataTypeException
3560
+	 * @throws InvalidInterfaceException
3561
+	 * @throws LogicException
3562
+	 * @throws InvalidFormSubmissionException
3563
+	 */
3564
+	protected function _insert_update_cpt_item($post_id, $post)
3565
+	{
3566
+		$success = true;
3567
+		$attendee = $post instanceof WP_Post && $post->post_type === 'espresso_attendees'
3568
+			? EEM_Attendee::instance()->get_one_by_ID($post_id)
3569
+			: null;
3570
+		// for attendee updates
3571
+		if ($attendee instanceof EE_Attendee) {
3572
+			// note we should only be UPDATING attendees at this point.
3573
+			$updated_fields = array(
3574
+				'ATT_fname'     => $this->_req_data['ATT_fname'],
3575
+				'ATT_lname'     => $this->_req_data['ATT_lname'],
3576
+				'ATT_full_name' => $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
3577
+				'ATT_address'   => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
3578
+				'ATT_address2'  => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
3579
+				'ATT_city'      => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
3580
+				'STA_ID'        => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
3581
+				'CNT_ISO'       => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
3582
+				'ATT_zip'       => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
3583
+			);
3584
+			foreach ($updated_fields as $field => $value) {
3585
+				$attendee->set($field, $value);
3586
+			}
3587
+
3588
+			// process contact details metabox form handler (which will also save the attendee)
3589
+			$contact_details_form = $this->getAttendeeContactDetailsMetaboxFormHandler($attendee);
3590
+			$success = $contact_details_form->process($this->_req_data);
3591
+
3592
+			$attendee_update_callbacks = apply_filters(
3593
+				'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update',
3594
+				array()
3595
+			);
3596
+			foreach ($attendee_update_callbacks as $a_callback) {
3597
+				if (false === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
3598
+					throw new EE_Error(
3599
+						sprintf(
3600
+							esc_html__(
3601
+								'The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.',
3602
+								'event_espresso'
3603
+							),
3604
+							$a_callback
3605
+						)
3606
+					);
3607
+				}
3608
+			}
3609
+		}
3610
+
3611
+		if ($success === false) {
3612
+			EE_Error::add_error(
3613
+				esc_html__(
3614
+					'Something went wrong with updating the meta table data for the registration.',
3615
+					'event_espresso'
3616
+				),
3617
+				__FILE__,
3618
+				__FUNCTION__,
3619
+				__LINE__
3620
+			);
3621
+		}
3622
+	}
3623
+
3624
+
3625
+	public function trash_cpt_item($post_id)
3626
+	{
3627
+	}
3628
+
3629
+
3630
+	public function delete_cpt_item($post_id)
3631
+	{
3632
+	}
3633
+
3634
+
3635
+	public function restore_cpt_item($post_id)
3636
+	{
3637
+	}
3638
+
3639
+
3640
+	protected function _restore_cpt_item($post_id, $revision_id)
3641
+	{
3642
+	}
3643
+
3644
+
3645
+	public function attendee_editor_metaboxes()
3646
+	{
3647
+		$this->verify_cpt_object();
3648
+		remove_meta_box(
3649
+			'postexcerpt',
3650
+			esc_html__('Excerpt', 'event_espresso'),
3651
+			'post_excerpt_meta_box',
3652
+			$this->_cpt_routes[ $this->_req_action ],
3653
+			'normal',
3654
+			'core'
3655
+		);
3656
+		remove_meta_box('commentstatusdiv', $this->_cpt_routes[ $this->_req_action ], 'normal', 'core');
3657
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
3658
+			add_meta_box(
3659
+				'postexcerpt',
3660
+				esc_html__('Short Biography', 'event_espresso'),
3661
+				'post_excerpt_meta_box',
3662
+				$this->_cpt_routes[ $this->_req_action ],
3663
+				'normal'
3664
+			);
3665
+		}
3666
+		if (post_type_supports('espresso_attendees', 'comments')) {
3667
+			add_meta_box(
3668
+				'commentsdiv',
3669
+				esc_html__('Notes on the Contact', 'event_espresso'),
3670
+				'post_comment_meta_box',
3671
+				$this->_cpt_routes[ $this->_req_action ],
3672
+				'normal',
3673
+				'core'
3674
+			);
3675
+		}
3676
+		add_meta_box(
3677
+			'attendee_contact_info',
3678
+			esc_html__('Contact Info', 'event_espresso'),
3679
+			array($this, 'attendee_contact_info'),
3680
+			$this->_cpt_routes[ $this->_req_action ],
3681
+			'side',
3682
+			'core'
3683
+		);
3684
+		add_meta_box(
3685
+			'attendee_details_address',
3686
+			esc_html__('Address Details', 'event_espresso'),
3687
+			array($this, 'attendee_address_details'),
3688
+			$this->_cpt_routes[ $this->_req_action ],
3689
+			'normal',
3690
+			'core'
3691
+		);
3692
+		add_meta_box(
3693
+			'attendee_registrations',
3694
+			esc_html__('Registrations for this Contact', 'event_espresso'),
3695
+			array($this, 'attendee_registrations_meta_box'),
3696
+			$this->_cpt_routes[ $this->_req_action ],
3697
+			'normal',
3698
+			'high'
3699
+		);
3700
+	}
3701
+
3702
+
3703
+	/**
3704
+	 * Metabox for attendee contact info
3705
+	 *
3706
+	 * @param  WP_Post $post wp post object
3707
+	 * @return string attendee contact info ( and form )
3708
+	 * @throws EE_Error
3709
+	 * @throws InvalidArgumentException
3710
+	 * @throws InvalidDataTypeException
3711
+	 * @throws InvalidInterfaceException
3712
+	 * @throws LogicException
3713
+	 * @throws DomainException
3714
+	 */
3715
+	public function attendee_contact_info($post)
3716
+	{
3717
+		// get attendee object ( should already have it )
3718
+		$form = $this->getAttendeeContactDetailsMetaboxFormHandler($this->_cpt_model_obj);
3719
+		$form->enqueueStylesAndScripts();
3720
+		echo $form->display();
3721
+	}
3722
+
3723
+
3724
+	/**
3725
+	 * Return form handler for the contact details metabox
3726
+	 *
3727
+	 * @param EE_Attendee $attendee
3728
+	 * @return AttendeeContactDetailsMetaboxFormHandler
3729
+	 * @throws DomainException
3730
+	 * @throws InvalidArgumentException
3731
+	 * @throws InvalidDataTypeException
3732
+	 * @throws InvalidInterfaceException
3733
+	 */
3734
+	protected function getAttendeeContactDetailsMetaboxFormHandler(EE_Attendee $attendee)
3735
+	{
3736
+		return new AttendeeContactDetailsMetaboxFormHandler($attendee, EE_Registry::instance());
3737
+	}
3738
+
3739
+
3740
+	/**
3741
+	 * Metabox for attendee details
3742
+	 *
3743
+	 * @param  WP_Post $post wp post object
3744
+	 * @throws DomainException
3745
+	 */
3746
+	public function attendee_address_details($post)
3747
+	{
3748
+		// get attendee object (should already have it)
3749
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
3750
+		$this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
3751
+			new EE_Question_Form_Input(
3752
+				EE_Question::new_instance(
3753
+					array(
3754
+						'QST_ID'           => 0,
3755
+						'QST_display_text' => esc_html__('State/Province', 'event_espresso'),
3756
+						'QST_system'       => 'admin-state',
3757
+					)
3758
+				),
3759
+				EE_Answer::new_instance(
3760
+					array(
3761
+						'ANS_ID'    => 0,
3762
+						'ANS_value' => $this->_cpt_model_obj->state_ID(),
3763
+					)
3764
+				),
3765
+				array(
3766
+					'input_id'       => 'STA_ID',
3767
+					'input_name'     => 'STA_ID',
3768
+					'input_prefix'   => '',
3769
+					'append_qstn_id' => false,
3770
+				)
3771
+			)
3772
+		);
3773
+		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
3774
+			new EE_Question_Form_Input(
3775
+				EE_Question::new_instance(
3776
+					array(
3777
+						'QST_ID'           => 0,
3778
+						'QST_display_text' => esc_html__('Country', 'event_espresso'),
3779
+						'QST_system'       => 'admin-country',
3780
+					)
3781
+				),
3782
+				EE_Answer::new_instance(
3783
+					array(
3784
+						'ANS_ID'    => 0,
3785
+						'ANS_value' => $this->_cpt_model_obj->country_ID(),
3786
+					)
3787
+				),
3788
+				array(
3789
+					'input_id'       => 'CNT_ISO',
3790
+					'input_name'     => 'CNT_ISO',
3791
+					'input_prefix'   => '',
3792
+					'append_qstn_id' => false,
3793
+				)
3794
+			)
3795
+		);
3796
+		$template =
3797
+			REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
3798
+		EEH_Template::display_template($template, $this->_template_args);
3799
+	}
3800
+
3801
+
3802
+	/**
3803
+	 *        _attendee_details
3804
+	 *
3805
+	 * @access protected
3806
+	 * @param $post
3807
+	 * @return void
3808
+	 * @throws DomainException
3809
+	 * @throws EE_Error
3810
+	 */
3811
+	public function attendee_registrations_meta_box($post)
3812
+	{
3813
+		$this->_template_args['attendee'] = $this->_cpt_model_obj;
3814
+		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
3815
+		$template =
3816
+			REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
3817
+		EEH_Template::display_template($template, $this->_template_args);
3818
+	}
3819
+
3820
+
3821
+	/**
3822
+	 * add in the form fields for the attendee edit
3823
+	 *
3824
+	 * @param  WP_Post $post wp post object
3825
+	 * @return string html for new form.
3826
+	 * @throws DomainException
3827
+	 */
3828
+	public function after_title_form_fields($post)
3829
+	{
3830
+		if ($post->post_type == 'espresso_attendees') {
3831
+			$template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
3832
+			$template_args['attendee'] = $this->_cpt_model_obj;
3833
+			EEH_Template::display_template($template, $template_args);
3834
+		}
3835
+	}
3836
+
3837
+
3838
+	/**
3839
+	 *        _trash_or_restore_attendee
3840
+	 *
3841
+	 * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE)
3842
+	 * @return void
3843
+	 * @throws EE_Error
3844
+	 * @throws InvalidArgumentException
3845
+	 * @throws InvalidDataTypeException
3846
+	 * @throws InvalidInterfaceException
3847
+	 * @access protected
3848
+	 */
3849
+	protected function _trash_or_restore_attendees($trash = true)
3850
+	{
3851
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3852
+		$ATT_MDL = EEM_Attendee::instance();
3853
+		$success = 1;
3854
+		// Checkboxes
3855
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3856
+			// if array has more than one element than success message should be plural
3857
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3858
+			// cycle thru checkboxes
3859
+			while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
3860
+				$updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID)
3861
+					: $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
3862
+				if (! $updated) {
3863
+					$success = 0;
3864
+				}
3865
+			}
3866
+		} else {
3867
+			// grab single id and delete
3868
+			$ATT_ID = absint($this->_req_data['ATT_ID']);
3869
+			// get attendee
3870
+			$att = $ATT_MDL->get_one_by_ID($ATT_ID);
3871
+			$updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
3872
+			$updated = $att->save();
3873
+			if (! $updated) {
3874
+				$success = 0;
3875
+			}
3876
+		}
3877
+		$what = $success > 1
3878
+			? esc_html__('Contacts', 'event_espresso')
3879
+			: esc_html__('Contact', 'event_espresso');
3880
+		$action_desc = $trash
3881
+			? esc_html__('moved to the trash', 'event_espresso')
3882
+			: esc_html__('restored', 'event_espresso');
3883
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
3884
+	}
3885 3885
 }
Please login to merge, or discard this patch.
core/domain/DomainBase.php 1 patch
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -16,153 +16,153 @@
 block discarded – undo
16 16
 abstract class DomainBase implements DomainInterface
17 17
 {
18 18
 
19
-    /**
20
-     * Equivalent to `__FILE__` for main plugin file.
21
-     *
22
-     * @var FilePath
23
-     */
24
-    private $plugin_file;
25
-
26
-    /**
27
-     * String indicating version for plugin
28
-     *
29
-     * @var string
30
-     */
31
-    private $version;
32
-
33
-    /**
34
-     * @var string $plugin_basename
35
-     */
36
-    private $plugin_basename;
37
-
38
-    /**
39
-     * @var string $plugin_path
40
-     */
41
-    private $plugin_path;
42
-
43
-    /**
44
-     * @var string $plugin_url
45
-     */
46
-    private $plugin_url;
47
-
48
-    /**
49
-     * @var string $asset_namespace
50
-     */
51
-    private $asset_namespace;
52
-
53
-
54
-
55
-    /**
56
-     * Initializes internal properties.
57
-     *
58
-     * @param FilePath $plugin_file
59
-     * @param Version  $version
60
-     */
61
-    public function __construct(FilePath $plugin_file, Version $version)
62
-    {
63
-        $this->plugin_file = $plugin_file;
64
-        $this->version = $version;
65
-        $this->plugin_basename = plugin_basename($this->pluginFile());
66
-        $this->plugin_path = plugin_dir_path($this->pluginFile());
67
-        $this->plugin_url = plugin_dir_url($this->pluginFile());
68
-        $this->setAssetNamespace();
69
-    }
70
-
71
-
72
-    /**
73
-     * @return string
74
-     */
75
-    public function pluginFile()
76
-    {
77
-        return (string) $this->plugin_file;
78
-    }
79
-
80
-
81
-
82
-    /**
83
-     * @return string
84
-     */
85
-    public function pluginBasename()
86
-    {
87
-        return $this->plugin_basename;
88
-    }
89
-
90
-
91
-
92
-    /**
93
-     * @return string
94
-     */
95
-    public function pluginPath()
96
-    {
97
-        return $this->plugin_path;
98
-    }
99
-
100
-
101
-
102
-    /**
103
-     * @return string
104
-     */
105
-    public function pluginUrl()
106
-    {
107
-        return $this->plugin_url;
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * @return string
114
-     */
115
-    public function version()
116
-    {
117
-        return (string) $this->version;
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * @return Version
124
-     */
125
-    public function versionValueObject()
126
-    {
127
-        return $this->version;
128
-    }
129
-
130
-
131
-    /**
132
-     * @return string
133
-     */
134
-    public function distributionAssetsPath()
135
-    {
136
-        return $this->pluginPath() . 'assets/dist/';
137
-    }
138
-
139
-
140
-    /**
141
-     * @return string
142
-     */
143
-    public function distributionAssetsUrl()
144
-    {
145
-        return $this->pluginUrl() . 'assets/dist/';
146
-    }
147
-
148
-
149
-    /**
150
-     * @return string
151
-     */
152
-    public function assetNamespace()
153
-    {
154
-        return $this->asset_namespace;
155
-    }
156
-
157
-
158
-    /**
159
-     * @return void
160
-     */
161
-    private function setAssetNamespace()
162
-    {
163
-        $this->asset_namespace = sanitize_key(
164
-            // convert directory separators to dashes and remove file extension
165
-            str_replace(array('/', '.php'), array('-', ''), $this->plugin_basename)
166
-        );
167
-    }
19
+	/**
20
+	 * Equivalent to `__FILE__` for main plugin file.
21
+	 *
22
+	 * @var FilePath
23
+	 */
24
+	private $plugin_file;
25
+
26
+	/**
27
+	 * String indicating version for plugin
28
+	 *
29
+	 * @var string
30
+	 */
31
+	private $version;
32
+
33
+	/**
34
+	 * @var string $plugin_basename
35
+	 */
36
+	private $plugin_basename;
37
+
38
+	/**
39
+	 * @var string $plugin_path
40
+	 */
41
+	private $plugin_path;
42
+
43
+	/**
44
+	 * @var string $plugin_url
45
+	 */
46
+	private $plugin_url;
47
+
48
+	/**
49
+	 * @var string $asset_namespace
50
+	 */
51
+	private $asset_namespace;
52
+
53
+
54
+
55
+	/**
56
+	 * Initializes internal properties.
57
+	 *
58
+	 * @param FilePath $plugin_file
59
+	 * @param Version  $version
60
+	 */
61
+	public function __construct(FilePath $plugin_file, Version $version)
62
+	{
63
+		$this->plugin_file = $plugin_file;
64
+		$this->version = $version;
65
+		$this->plugin_basename = plugin_basename($this->pluginFile());
66
+		$this->plugin_path = plugin_dir_path($this->pluginFile());
67
+		$this->plugin_url = plugin_dir_url($this->pluginFile());
68
+		$this->setAssetNamespace();
69
+	}
70
+
71
+
72
+	/**
73
+	 * @return string
74
+	 */
75
+	public function pluginFile()
76
+	{
77
+		return (string) $this->plugin_file;
78
+	}
79
+
80
+
81
+
82
+	/**
83
+	 * @return string
84
+	 */
85
+	public function pluginBasename()
86
+	{
87
+		return $this->plugin_basename;
88
+	}
89
+
90
+
91
+
92
+	/**
93
+	 * @return string
94
+	 */
95
+	public function pluginPath()
96
+	{
97
+		return $this->plugin_path;
98
+	}
99
+
100
+
101
+
102
+	/**
103
+	 * @return string
104
+	 */
105
+	public function pluginUrl()
106
+	{
107
+		return $this->plugin_url;
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * @return string
114
+	 */
115
+	public function version()
116
+	{
117
+		return (string) $this->version;
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * @return Version
124
+	 */
125
+	public function versionValueObject()
126
+	{
127
+		return $this->version;
128
+	}
129
+
130
+
131
+	/**
132
+	 * @return string
133
+	 */
134
+	public function distributionAssetsPath()
135
+	{
136
+		return $this->pluginPath() . 'assets/dist/';
137
+	}
138
+
139
+
140
+	/**
141
+	 * @return string
142
+	 */
143
+	public function distributionAssetsUrl()
144
+	{
145
+		return $this->pluginUrl() . 'assets/dist/';
146
+	}
147
+
148
+
149
+	/**
150
+	 * @return string
151
+	 */
152
+	public function assetNamespace()
153
+	{
154
+		return $this->asset_namespace;
155
+	}
156
+
157
+
158
+	/**
159
+	 * @return void
160
+	 */
161
+	private function setAssetNamespace()
162
+	{
163
+		$this->asset_namespace = sanitize_key(
164
+			// convert directory separators to dashes and remove file extension
165
+			str_replace(array('/', '.php'), array('-', ''), $this->plugin_basename)
166
+		);
167
+	}
168 168
 }
Please login to merge, or discard this patch.
core/services/assets/Registry.php 2 patches
Indentation   +573 added lines, -573 removed lines patch added patch discarded remove patch
@@ -23,584 +23,584 @@
 block discarded – undo
23 23
 class Registry
24 24
 {
25 25
 
26
-    const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json';
27
-
28
-    /**
29
-     * @var AssetCollection $assets
30
-     */
31
-    protected $assets;
32
-
33
-    /**
34
-     * @var I18nRegistry
35
-     */
36
-    private $i18n_registry;
37
-
38
-    /**
39
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
40
-     *
41
-     * @var array
42
-     */
43
-    protected $jsdata = array();
44
-
45
-    /**
46
-     * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
47
-     * page source.
48
-     *
49
-     * @var array
50
-     */
51
-    private $script_handles_with_data = array();
52
-
53
-    /**
54
-     * Holds the manifest data obtained from registered manifest files.
55
-     * Manifests are maps of asset chunk name to actual built asset file names.
56
-     * Shape of this array is:
57
-     * array(
58
-     *  'some_namespace_slug' => array(
59
-     *      'some_chunk_name' => array(
60
-     *          'js' => 'filename.js'
61
-     *          'css' => 'filename.js'
62
-     *      ),
63
-     *      'url_base' => 'https://baseurl.com/to/assets
64
-     *  )
65
-     * )
66
-     *
67
-     * @var array
68
-     */
69
-    private $manifest_data = array();
70
-
71
-
72
-    /**
73
-     * Registry constructor.
74
-     * Hooking into WP actions for script registry.
75
-     *
76
-     * @param AssetCollection $assets
77
-     * @param I18nRegistry    $i18n_registry
78
-     */
79
-    public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry)
80
-    {
81
-        $this->assets = $assets;
82
-        $this->i18n_registry = $i18n_registry;
83
-        add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
84
-        add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
85
-        add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
86
-        add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
87
-        add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 4);
88
-        add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 4);
89
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
90
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
91
-    }
92
-
93
-
94
-    /**
95
-     * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
96
-     * translation handling.
97
-     *
98
-     * @return I18nRegistry
99
-     */
100
-    public function getI18nRegistry()
101
-    {
102
-        return $this->i18n_registry;
103
-    }
104
-
105
-
106
-    /**
107
-     * Callback for the wp_enqueue_scripts actions used to register assets.
108
-     *
109
-     * @since 4.9.62.p
110
-     * @throws Exception
111
-     */
112
-    public function registerScriptsAndStyles()
113
-    {
114
-        try {
115
-            $this->registerScripts($this->assets->getJavascriptAssets());
116
-            $this->registerStyles($this->assets->getStylesheetAssets());
117
-        } catch (Exception $exception) {
118
-            new ExceptionStackTraceDisplay($exception);
119
-        }
120
-    }
121
-
122
-
123
-    /**
124
-     * Registers JS assets with WP core
125
-     *
126
-     * @since 4.9.62.p
127
-     * @param JavascriptAsset[] $scripts
128
-     * @throws AssetRegistrationException
129
-     * @throws InvalidDataTypeException
130
-     */
131
-    public function registerScripts(array $scripts)
132
-    {
133
-        foreach ($scripts as $script) {
134
-            // skip to next script if this has already been done
135
-            if ($script->isRegistered()) {
136
-                continue;
137
-            }
138
-            do_action(
139
-                'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
140
-                $script
141
-            );
142
-            $registered = wp_register_script(
143
-                $script->handle(),
144
-                $script->source(),
145
-                $script->dependencies(),
146
-                $script->version(),
147
-                $script->loadInFooter()
148
-            );
149
-            if (! $registered && $this->debug()) {
150
-                throw new AssetRegistrationException($script->handle());
151
-            }
152
-            $script->setRegistered($registered);
153
-            if ($script->requiresTranslation()) {
154
-                $this->registerTranslation($script->handle());
155
-            }
156
-            do_action(
157
-                'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script',
158
-                $script
159
-            );
160
-        }
161
-    }
162
-
163
-
164
-    /**
165
-     * Registers CSS assets with WP core
166
-     *
167
-     * @since 4.9.62.p
168
-     * @param StylesheetAsset[] $styles
169
-     * @throws InvalidDataTypeException
170
-     */
171
-    public function registerStyles(array $styles)
172
-    {
173
-        foreach ($styles as $style) {
174
-            // skip to next style if this has already been done
175
-            if ($style->isRegistered()) {
176
-                continue;
177
-            }
178
-            do_action(
179
-                'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style',
180
-                $style
181
-            );
182
-            wp_register_style(
183
-                $style->handle(),
184
-                $style->source(),
185
-                $style->dependencies(),
186
-                $style->version(),
187
-                $style->media()
188
-            );
189
-            $style->setRegistered();
190
-            do_action(
191
-                'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style',
192
-                $style
193
-            );
194
-        }
195
-    }
196
-
197
-
198
-    /**
199
-     * Call back for the script print in frontend and backend.
200
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
201
-     *
202
-     * @since 4.9.31.rc.015
203
-     */
204
-    public function enqueueData()
205
-    {
206
-        $this->removeAlreadyRegisteredDataForScriptHandles();
207
-        wp_add_inline_script(
208
-            'eejs-core',
209
-            'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
210
-            'before'
211
-        );
212
-        $scripts = $this->assets->getJavascriptAssetsWithData();
213
-        foreach ($scripts as $script) {
214
-            $this->addRegisteredScriptHandlesWithData($script->handle());
215
-            if ($script->hasInlineDataCallback()) {
216
-                $localize = $script->inlineDataCallback();
217
-                $localize();
218
-            }
219
-        }
220
-    }
221
-
222
-
223
-    /**
224
-     * Used to add data to eejs.data object.
225
-     * Note:  Overriding existing data is not allowed.
226
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
227
-     * If the data you add is something like this:
228
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
229
-     * It will be exposed in the page source as:
230
-     *  eejs.data.my_plugin_data.foo == gar
231
-     *
232
-     * @param string       $key   Key used to access your data
233
-     * @param string|array $value Value to attach to key
234
-     * @throws InvalidArgumentException
235
-     */
236
-    public function addData($key, $value)
237
-    {
238
-        if ($this->verifyDataNotExisting($key)) {
239
-            $this->jsdata[ $key ] = $value;
240
-        }
241
-    }
242
-
243
-
244
-    /**
245
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
246
-     * elements in an array.
247
-     * When you use this method, the value you include will be appended to the end of an array on $key.
248
-     * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
249
-     * object like this, eejs.data.test = [ my_data,
250
-     * ]
251
-     * If there has already been a scalar value attached to the data object given key, then
252
-     * this will throw an exception.
253
-     *
254
-     * @param string       $key   Key to attach data to.
255
-     * @param string|array $value Value being registered.
256
-     * @throws InvalidArgumentException
257
-     */
258
-    public function pushData($key, $value)
259
-    {
260
-        if (isset($this->jsdata[ $key ])
261
-            && ! is_array($this->jsdata[ $key ])
262
-        ) {
263
-            if (! $this->debug()) {
264
-                return;
265
-            }
266
-            throw new InvalidArgumentException(
267
-                sprintf(
268
-                    __(
269
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
26
+	const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json';
27
+
28
+	/**
29
+	 * @var AssetCollection $assets
30
+	 */
31
+	protected $assets;
32
+
33
+	/**
34
+	 * @var I18nRegistry
35
+	 */
36
+	private $i18n_registry;
37
+
38
+	/**
39
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
40
+	 *
41
+	 * @var array
42
+	 */
43
+	protected $jsdata = array();
44
+
45
+	/**
46
+	 * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
47
+	 * page source.
48
+	 *
49
+	 * @var array
50
+	 */
51
+	private $script_handles_with_data = array();
52
+
53
+	/**
54
+	 * Holds the manifest data obtained from registered manifest files.
55
+	 * Manifests are maps of asset chunk name to actual built asset file names.
56
+	 * Shape of this array is:
57
+	 * array(
58
+	 *  'some_namespace_slug' => array(
59
+	 *      'some_chunk_name' => array(
60
+	 *          'js' => 'filename.js'
61
+	 *          'css' => 'filename.js'
62
+	 *      ),
63
+	 *      'url_base' => 'https://baseurl.com/to/assets
64
+	 *  )
65
+	 * )
66
+	 *
67
+	 * @var array
68
+	 */
69
+	private $manifest_data = array();
70
+
71
+
72
+	/**
73
+	 * Registry constructor.
74
+	 * Hooking into WP actions for script registry.
75
+	 *
76
+	 * @param AssetCollection $assets
77
+	 * @param I18nRegistry    $i18n_registry
78
+	 */
79
+	public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry)
80
+	{
81
+		$this->assets = $assets;
82
+		$this->i18n_registry = $i18n_registry;
83
+		add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
84
+		add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
85
+		add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
86
+		add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
87
+		add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 4);
88
+		add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 4);
89
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
90
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
91
+	}
92
+
93
+
94
+	/**
95
+	 * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
96
+	 * translation handling.
97
+	 *
98
+	 * @return I18nRegistry
99
+	 */
100
+	public function getI18nRegistry()
101
+	{
102
+		return $this->i18n_registry;
103
+	}
104
+
105
+
106
+	/**
107
+	 * Callback for the wp_enqueue_scripts actions used to register assets.
108
+	 *
109
+	 * @since 4.9.62.p
110
+	 * @throws Exception
111
+	 */
112
+	public function registerScriptsAndStyles()
113
+	{
114
+		try {
115
+			$this->registerScripts($this->assets->getJavascriptAssets());
116
+			$this->registerStyles($this->assets->getStylesheetAssets());
117
+		} catch (Exception $exception) {
118
+			new ExceptionStackTraceDisplay($exception);
119
+		}
120
+	}
121
+
122
+
123
+	/**
124
+	 * Registers JS assets with WP core
125
+	 *
126
+	 * @since 4.9.62.p
127
+	 * @param JavascriptAsset[] $scripts
128
+	 * @throws AssetRegistrationException
129
+	 * @throws InvalidDataTypeException
130
+	 */
131
+	public function registerScripts(array $scripts)
132
+	{
133
+		foreach ($scripts as $script) {
134
+			// skip to next script if this has already been done
135
+			if ($script->isRegistered()) {
136
+				continue;
137
+			}
138
+			do_action(
139
+				'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
140
+				$script
141
+			);
142
+			$registered = wp_register_script(
143
+				$script->handle(),
144
+				$script->source(),
145
+				$script->dependencies(),
146
+				$script->version(),
147
+				$script->loadInFooter()
148
+			);
149
+			if (! $registered && $this->debug()) {
150
+				throw new AssetRegistrationException($script->handle());
151
+			}
152
+			$script->setRegistered($registered);
153
+			if ($script->requiresTranslation()) {
154
+				$this->registerTranslation($script->handle());
155
+			}
156
+			do_action(
157
+				'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script',
158
+				$script
159
+			);
160
+		}
161
+	}
162
+
163
+
164
+	/**
165
+	 * Registers CSS assets with WP core
166
+	 *
167
+	 * @since 4.9.62.p
168
+	 * @param StylesheetAsset[] $styles
169
+	 * @throws InvalidDataTypeException
170
+	 */
171
+	public function registerStyles(array $styles)
172
+	{
173
+		foreach ($styles as $style) {
174
+			// skip to next style if this has already been done
175
+			if ($style->isRegistered()) {
176
+				continue;
177
+			}
178
+			do_action(
179
+				'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style',
180
+				$style
181
+			);
182
+			wp_register_style(
183
+				$style->handle(),
184
+				$style->source(),
185
+				$style->dependencies(),
186
+				$style->version(),
187
+				$style->media()
188
+			);
189
+			$style->setRegistered();
190
+			do_action(
191
+				'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style',
192
+				$style
193
+			);
194
+		}
195
+	}
196
+
197
+
198
+	/**
199
+	 * Call back for the script print in frontend and backend.
200
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
201
+	 *
202
+	 * @since 4.9.31.rc.015
203
+	 */
204
+	public function enqueueData()
205
+	{
206
+		$this->removeAlreadyRegisteredDataForScriptHandles();
207
+		wp_add_inline_script(
208
+			'eejs-core',
209
+			'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
210
+			'before'
211
+		);
212
+		$scripts = $this->assets->getJavascriptAssetsWithData();
213
+		foreach ($scripts as $script) {
214
+			$this->addRegisteredScriptHandlesWithData($script->handle());
215
+			if ($script->hasInlineDataCallback()) {
216
+				$localize = $script->inlineDataCallback();
217
+				$localize();
218
+			}
219
+		}
220
+	}
221
+
222
+
223
+	/**
224
+	 * Used to add data to eejs.data object.
225
+	 * Note:  Overriding existing data is not allowed.
226
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
227
+	 * If the data you add is something like this:
228
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
229
+	 * It will be exposed in the page source as:
230
+	 *  eejs.data.my_plugin_data.foo == gar
231
+	 *
232
+	 * @param string       $key   Key used to access your data
233
+	 * @param string|array $value Value to attach to key
234
+	 * @throws InvalidArgumentException
235
+	 */
236
+	public function addData($key, $value)
237
+	{
238
+		if ($this->verifyDataNotExisting($key)) {
239
+			$this->jsdata[ $key ] = $value;
240
+		}
241
+	}
242
+
243
+
244
+	/**
245
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
246
+	 * elements in an array.
247
+	 * When you use this method, the value you include will be appended to the end of an array on $key.
248
+	 * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
249
+	 * object like this, eejs.data.test = [ my_data,
250
+	 * ]
251
+	 * If there has already been a scalar value attached to the data object given key, then
252
+	 * this will throw an exception.
253
+	 *
254
+	 * @param string       $key   Key to attach data to.
255
+	 * @param string|array $value Value being registered.
256
+	 * @throws InvalidArgumentException
257
+	 */
258
+	public function pushData($key, $value)
259
+	{
260
+		if (isset($this->jsdata[ $key ])
261
+			&& ! is_array($this->jsdata[ $key ])
262
+		) {
263
+			if (! $this->debug()) {
264
+				return;
265
+			}
266
+			throw new InvalidArgumentException(
267
+				sprintf(
268
+					__(
269
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
270 270
                          push values to this data element when it is an array.',
271
-                        'event_espresso'
272
-                    ),
273
-                    $key,
274
-                    __METHOD__
275
-                )
276
-            );
277
-        }
278
-        $this->jsdata[ $key ][] = $value;
279
-    }
280
-
281
-
282
-    /**
283
-     * Used to set content used by javascript for a template.
284
-     * Note: Overrides of existing registered templates are not allowed.
285
-     *
286
-     * @param string $template_reference
287
-     * @param string $template_content
288
-     * @throws InvalidArgumentException
289
-     */
290
-    public function addTemplate($template_reference, $template_content)
291
-    {
292
-        if (! isset($this->jsdata['templates'])) {
293
-            $this->jsdata['templates'] = array();
294
-        }
295
-        //no overrides allowed.
296
-        if (isset($this->jsdata['templates'][ $template_reference ])) {
297
-            if (! $this->debug()) {
298
-                return;
299
-            }
300
-            throw new InvalidArgumentException(
301
-                sprintf(
302
-                    __(
303
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
304
-                        'event_espresso'
305
-                    ),
306
-                    $template_reference
307
-                )
308
-            );
309
-        }
310
-        $this->jsdata['templates'][ $template_reference ] = $template_content;
311
-    }
312
-
313
-
314
-    /**
315
-     * Retrieve the template content already registered for the given reference.
316
-     *
317
-     * @param string $template_reference
318
-     * @return string
319
-     */
320
-    public function getTemplate($template_reference)
321
-    {
322
-        return isset($this->jsdata['templates'][ $template_reference ])
323
-            ? $this->jsdata['templates'][ $template_reference ]
324
-            : '';
325
-    }
326
-
327
-
328
-    /**
329
-     * Retrieve registered data.
330
-     *
331
-     * @param string $key Name of key to attach data to.
332
-     * @return mixed                If there is no for the given key, then false is returned.
333
-     */
334
-    public function getData($key)
335
-    {
336
-        return isset($this->jsdata[ $key ])
337
-            ? $this->jsdata[ $key ]
338
-            : false;
339
-    }
340
-
341
-
342
-    /**
343
-     * Verifies whether the given data exists already on the jsdata array.
344
-     * Overriding data is not allowed.
345
-     *
346
-     * @param string $key Index for data.
347
-     * @return bool        If valid then return true.
348
-     * @throws InvalidArgumentException if data already exists.
349
-     */
350
-    protected function verifyDataNotExisting($key)
351
-    {
352
-        if (isset($this->jsdata[ $key ])) {
353
-            if (! $this->debug()) {
354
-                return false;
355
-            }
356
-            if (is_array($this->jsdata[ $key ])) {
357
-                throw new InvalidArgumentException(
358
-                    sprintf(
359
-                        __(
360
-                            'The value for %1$s already exists in the Registry::eejs object.
271
+						'event_espresso'
272
+					),
273
+					$key,
274
+					__METHOD__
275
+				)
276
+			);
277
+		}
278
+		$this->jsdata[ $key ][] = $value;
279
+	}
280
+
281
+
282
+	/**
283
+	 * Used to set content used by javascript for a template.
284
+	 * Note: Overrides of existing registered templates are not allowed.
285
+	 *
286
+	 * @param string $template_reference
287
+	 * @param string $template_content
288
+	 * @throws InvalidArgumentException
289
+	 */
290
+	public function addTemplate($template_reference, $template_content)
291
+	{
292
+		if (! isset($this->jsdata['templates'])) {
293
+			$this->jsdata['templates'] = array();
294
+		}
295
+		//no overrides allowed.
296
+		if (isset($this->jsdata['templates'][ $template_reference ])) {
297
+			if (! $this->debug()) {
298
+				return;
299
+			}
300
+			throw new InvalidArgumentException(
301
+				sprintf(
302
+					__(
303
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
304
+						'event_espresso'
305
+					),
306
+					$template_reference
307
+				)
308
+			);
309
+		}
310
+		$this->jsdata['templates'][ $template_reference ] = $template_content;
311
+	}
312
+
313
+
314
+	/**
315
+	 * Retrieve the template content already registered for the given reference.
316
+	 *
317
+	 * @param string $template_reference
318
+	 * @return string
319
+	 */
320
+	public function getTemplate($template_reference)
321
+	{
322
+		return isset($this->jsdata['templates'][ $template_reference ])
323
+			? $this->jsdata['templates'][ $template_reference ]
324
+			: '';
325
+	}
326
+
327
+
328
+	/**
329
+	 * Retrieve registered data.
330
+	 *
331
+	 * @param string $key Name of key to attach data to.
332
+	 * @return mixed                If there is no for the given key, then false is returned.
333
+	 */
334
+	public function getData($key)
335
+	{
336
+		return isset($this->jsdata[ $key ])
337
+			? $this->jsdata[ $key ]
338
+			: false;
339
+	}
340
+
341
+
342
+	/**
343
+	 * Verifies whether the given data exists already on the jsdata array.
344
+	 * Overriding data is not allowed.
345
+	 *
346
+	 * @param string $key Index for data.
347
+	 * @return bool        If valid then return true.
348
+	 * @throws InvalidArgumentException if data already exists.
349
+	 */
350
+	protected function verifyDataNotExisting($key)
351
+	{
352
+		if (isset($this->jsdata[ $key ])) {
353
+			if (! $this->debug()) {
354
+				return false;
355
+			}
356
+			if (is_array($this->jsdata[ $key ])) {
357
+				throw new InvalidArgumentException(
358
+					sprintf(
359
+						__(
360
+							'The value for %1$s already exists in the Registry::eejs object.
361 361
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
362 362
                             %2$s method to push your value to the array.',
363
-                            'event_espresso'
364
-                        ),
365
-                        $key,
366
-                        'pushData()'
367
-                    )
368
-                );
369
-            }
370
-            throw new InvalidArgumentException(
371
-                sprintf(
372
-                    __(
373
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
363
+							'event_espresso'
364
+						),
365
+						$key,
366
+						'pushData()'
367
+					)
368
+				);
369
+			}
370
+			throw new InvalidArgumentException(
371
+				sprintf(
372
+					__(
373
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
374 374
                         allowed.  Consider attaching your value to a different key',
375
-                        'event_espresso'
376
-                    ),
377
-                    $key
378
-                )
379
-            );
380
-        }
381
-        return true;
382
-    }
383
-
384
-
385
-    /**
386
-     * Get the actual asset path for asset manifests.
387
-     * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
388
-     *
389
-     * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
390
-     *                           asset file location.
391
-     * @param string $chunk_name
392
-     * @param string $asset_type
393
-     * @return string
394
-     * @since 4.9.59.p
395
-     */
396
-    public function getAssetUrl($namespace, $chunk_name, $asset_type)
397
-    {
398
-        $url = isset(
399
-            $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ],
400
-            $this->manifest_data[ $namespace ]['url_base']
401
-        )
402
-            ? $this->manifest_data[ $namespace ]['url_base']
403
-              . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ]
404
-            : $chunk_name;
405
-        return apply_filters(
406
-            'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
407
-            $url,
408
-            $namespace,
409
-            $chunk_name,
410
-            $asset_type
411
-        );
412
-    }
413
-
414
-
415
-    /**
416
-     * Return the url to a js file for the given namespace and chunk name.
417
-     *
418
-     * @param string $namespace
419
-     * @param string $chunk_name
420
-     * @return string
421
-     */
422
-    public function getJsUrl($namespace, $chunk_name)
423
-    {
424
-        return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS);
425
-    }
426
-
427
-
428
-    /**
429
-     * Return the url to a css file for the given namespace and chunk name.
430
-     *
431
-     * @param string $namespace
432
-     * @param string $chunk_name
433
-     * @return string
434
-     */
435
-    public function getCssUrl($namespace, $chunk_name)
436
-    {
437
-        return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS);
438
-    }
439
-
440
-
441
-    /**
442
-     * @since 4.9.62.p
443
-     * @throws InvalidArgumentException
444
-     * @throws InvalidFilePathException
445
-     */
446
-    public function registerManifestFiles()
447
-    {
448
-        $manifest_files = $this->assets->getManifestFiles();
449
-        foreach ($manifest_files as $manifest_file) {
450
-            $this->registerManifestFile(
451
-                $manifest_file->assetNamespace(),
452
-                $manifest_file->urlBase(),
453
-                $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST
454
-            );
455
-        }
456
-    }
457
-
458
-
459
-    /**
460
-     * Used to register a js/css manifest file with the registered_manifest_files property.
461
-     *
462
-     * @param string $namespace     Provided to associate the manifest file with a specific namespace.
463
-     * @param string $url_base      The url base for the manifest file location.
464
-     * @param string $manifest_file The absolute path to the manifest file.
465
-     * @throws InvalidArgumentException
466
-     * @throws InvalidFilePathException
467
-     * @since 4.9.59.p
468
-     */
469
-    public function registerManifestFile($namespace, $url_base, $manifest_file)
470
-    {
471
-        if (isset($this->manifest_data[ $namespace ])) {
472
-            if (! $this->debug()) {
473
-                return;
474
-            }
475
-            throw new InvalidArgumentException(
476
-                sprintf(
477
-                    esc_html__(
478
-                        'The namespace for this manifest file has already been registered, choose a namespace other than %s',
479
-                        'event_espresso'
480
-                    ),
481
-                    $namespace
482
-                )
483
-            );
484
-        }
485
-        if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
486
-            if (is_admin()) {
487
-                EE_Error::add_error(
488
-                    sprintf(
489
-                        esc_html__(
490
-                            'The url given for %1$s assets is invalid.  The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant',
491
-                            'event_espresso'
492
-                        ),
493
-                        'Event Espresso',
494
-                        $url_base,
495
-                        'plugins_url',
496
-                        'WP_PLUGIN_URL'
497
-                    ),
498
-                    __FILE__,
499
-                    __FUNCTION__,
500
-                    __LINE__
501
-                );
502
-            }
503
-            return;
504
-        }
505
-        $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
506
-        if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
507
-            $this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base);
508
-        }
509
-    }
510
-
511
-
512
-    /**
513
-     * Decodes json from the provided manifest file.
514
-     *
515
-     * @since 4.9.59.p
516
-     * @param string $manifest_file Path to manifest file.
517
-     * @return array
518
-     * @throws InvalidFilePathException
519
-     */
520
-    private function decodeManifestFile($manifest_file)
521
-    {
522
-        if (! file_exists($manifest_file)) {
523
-            throw new InvalidFilePathException($manifest_file);
524
-        }
525
-        return json_decode(file_get_contents($manifest_file), true);
526
-    }
527
-
528
-
529
-    /**
530
-     * This is used to set registered script handles that have data.
531
-     *
532
-     * @param string $script_handle
533
-     */
534
-    private function addRegisteredScriptHandlesWithData($script_handle)
535
-    {
536
-        $this->script_handles_with_data[ $script_handle ] = $script_handle;
537
-    }
538
-
539
-
540
-    /**i
375
+						'event_espresso'
376
+					),
377
+					$key
378
+				)
379
+			);
380
+		}
381
+		return true;
382
+	}
383
+
384
+
385
+	/**
386
+	 * Get the actual asset path for asset manifests.
387
+	 * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
388
+	 *
389
+	 * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
390
+	 *                           asset file location.
391
+	 * @param string $chunk_name
392
+	 * @param string $asset_type
393
+	 * @return string
394
+	 * @since 4.9.59.p
395
+	 */
396
+	public function getAssetUrl($namespace, $chunk_name, $asset_type)
397
+	{
398
+		$url = isset(
399
+			$this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ],
400
+			$this->manifest_data[ $namespace ]['url_base']
401
+		)
402
+			? $this->manifest_data[ $namespace ]['url_base']
403
+			  . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ]
404
+			: $chunk_name;
405
+		return apply_filters(
406
+			'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
407
+			$url,
408
+			$namespace,
409
+			$chunk_name,
410
+			$asset_type
411
+		);
412
+	}
413
+
414
+
415
+	/**
416
+	 * Return the url to a js file for the given namespace and chunk name.
417
+	 *
418
+	 * @param string $namespace
419
+	 * @param string $chunk_name
420
+	 * @return string
421
+	 */
422
+	public function getJsUrl($namespace, $chunk_name)
423
+	{
424
+		return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS);
425
+	}
426
+
427
+
428
+	/**
429
+	 * Return the url to a css file for the given namespace and chunk name.
430
+	 *
431
+	 * @param string $namespace
432
+	 * @param string $chunk_name
433
+	 * @return string
434
+	 */
435
+	public function getCssUrl($namespace, $chunk_name)
436
+	{
437
+		return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS);
438
+	}
439
+
440
+
441
+	/**
442
+	 * @since 4.9.62.p
443
+	 * @throws InvalidArgumentException
444
+	 * @throws InvalidFilePathException
445
+	 */
446
+	public function registerManifestFiles()
447
+	{
448
+		$manifest_files = $this->assets->getManifestFiles();
449
+		foreach ($manifest_files as $manifest_file) {
450
+			$this->registerManifestFile(
451
+				$manifest_file->assetNamespace(),
452
+				$manifest_file->urlBase(),
453
+				$manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST
454
+			);
455
+		}
456
+	}
457
+
458
+
459
+	/**
460
+	 * Used to register a js/css manifest file with the registered_manifest_files property.
461
+	 *
462
+	 * @param string $namespace     Provided to associate the manifest file with a specific namespace.
463
+	 * @param string $url_base      The url base for the manifest file location.
464
+	 * @param string $manifest_file The absolute path to the manifest file.
465
+	 * @throws InvalidArgumentException
466
+	 * @throws InvalidFilePathException
467
+	 * @since 4.9.59.p
468
+	 */
469
+	public function registerManifestFile($namespace, $url_base, $manifest_file)
470
+	{
471
+		if (isset($this->manifest_data[ $namespace ])) {
472
+			if (! $this->debug()) {
473
+				return;
474
+			}
475
+			throw new InvalidArgumentException(
476
+				sprintf(
477
+					esc_html__(
478
+						'The namespace for this manifest file has already been registered, choose a namespace other than %s',
479
+						'event_espresso'
480
+					),
481
+					$namespace
482
+				)
483
+			);
484
+		}
485
+		if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
486
+			if (is_admin()) {
487
+				EE_Error::add_error(
488
+					sprintf(
489
+						esc_html__(
490
+							'The url given for %1$s assets is invalid.  The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant',
491
+							'event_espresso'
492
+						),
493
+						'Event Espresso',
494
+						$url_base,
495
+						'plugins_url',
496
+						'WP_PLUGIN_URL'
497
+					),
498
+					__FILE__,
499
+					__FUNCTION__,
500
+					__LINE__
501
+				);
502
+			}
503
+			return;
504
+		}
505
+		$this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
506
+		if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
507
+			$this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base);
508
+		}
509
+	}
510
+
511
+
512
+	/**
513
+	 * Decodes json from the provided manifest file.
514
+	 *
515
+	 * @since 4.9.59.p
516
+	 * @param string $manifest_file Path to manifest file.
517
+	 * @return array
518
+	 * @throws InvalidFilePathException
519
+	 */
520
+	private function decodeManifestFile($manifest_file)
521
+	{
522
+		if (! file_exists($manifest_file)) {
523
+			throw new InvalidFilePathException($manifest_file);
524
+		}
525
+		return json_decode(file_get_contents($manifest_file), true);
526
+	}
527
+
528
+
529
+	/**
530
+	 * This is used to set registered script handles that have data.
531
+	 *
532
+	 * @param string $script_handle
533
+	 */
534
+	private function addRegisteredScriptHandlesWithData($script_handle)
535
+	{
536
+		$this->script_handles_with_data[ $script_handle ] = $script_handle;
537
+	}
538
+
539
+
540
+	/**i
541 541
      * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
542 542
      * Dependency stored in WP_Scripts if its set.
543 543
      */
544
-    private function removeAlreadyRegisteredDataForScriptHandles()
545
-    {
546
-        if (empty($this->script_handles_with_data)) {
547
-            return;
548
-        }
549
-        foreach ($this->script_handles_with_data as $script_handle) {
550
-            $this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
551
-        }
552
-    }
553
-
554
-
555
-    /**
556
-     * Removes any data dependency registered in WP_Scripts if its set.
557
-     *
558
-     * @param string $script_handle
559
-     */
560
-    private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
561
-    {
562
-        if (isset($this->script_handles_with_data[ $script_handle ])) {
563
-            global $wp_scripts;
564
-            $unset_handle = false;
565
-            if ($wp_scripts->get_data($script_handle, 'data')) {
566
-                unset($wp_scripts->registered[ $script_handle ]->extra['data']);
567
-                $unset_handle = true;
568
-            }
569
-            //deal with inline_scripts
570
-            if ($wp_scripts->get_data($script_handle, 'before')) {
571
-                unset($wp_scripts->registered[ $script_handle ]->extra['before']);
572
-                $unset_handle = true;
573
-            }
574
-            if ($wp_scripts->get_data($script_handle, 'after')) {
575
-                unset($wp_scripts->registered[ $script_handle ]->extra['after']);
576
-            }
577
-            if ($unset_handle) {
578
-                unset($this->script_handles_with_data[ $script_handle ]);
579
-            }
580
-        }
581
-    }
582
-
583
-
584
-    /**
585
-     * register translations for a registered script
586
-     *
587
-     * @param string $handle
588
-     */
589
-    public function registerTranslation($handle)
590
-    {
591
-        $this->i18n_registry->registerScriptI18n($handle);
592
-    }
593
-
594
-
595
-    /**
596
-     * @since $VID:$
597
-     * @return bool
598
-     */
599
-    private function debug()
600
-    {
601
-        return apply_filters(
602
-            'FHEE__EventEspresso_core_services_assets_Registry__debug',
603
-            defined('EE_DEBUG') && EE_DEBUG
604
-        );
605
-    }
544
+	private function removeAlreadyRegisteredDataForScriptHandles()
545
+	{
546
+		if (empty($this->script_handles_with_data)) {
547
+			return;
548
+		}
549
+		foreach ($this->script_handles_with_data as $script_handle) {
550
+			$this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
551
+		}
552
+	}
553
+
554
+
555
+	/**
556
+	 * Removes any data dependency registered in WP_Scripts if its set.
557
+	 *
558
+	 * @param string $script_handle
559
+	 */
560
+	private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
561
+	{
562
+		if (isset($this->script_handles_with_data[ $script_handle ])) {
563
+			global $wp_scripts;
564
+			$unset_handle = false;
565
+			if ($wp_scripts->get_data($script_handle, 'data')) {
566
+				unset($wp_scripts->registered[ $script_handle ]->extra['data']);
567
+				$unset_handle = true;
568
+			}
569
+			//deal with inline_scripts
570
+			if ($wp_scripts->get_data($script_handle, 'before')) {
571
+				unset($wp_scripts->registered[ $script_handle ]->extra['before']);
572
+				$unset_handle = true;
573
+			}
574
+			if ($wp_scripts->get_data($script_handle, 'after')) {
575
+				unset($wp_scripts->registered[ $script_handle ]->extra['after']);
576
+			}
577
+			if ($unset_handle) {
578
+				unset($this->script_handles_with_data[ $script_handle ]);
579
+			}
580
+		}
581
+	}
582
+
583
+
584
+	/**
585
+	 * register translations for a registered script
586
+	 *
587
+	 * @param string $handle
588
+	 */
589
+	public function registerTranslation($handle)
590
+	{
591
+		$this->i18n_registry->registerScriptI18n($handle);
592
+	}
593
+
594
+
595
+	/**
596
+	 * @since $VID:$
597
+	 * @return bool
598
+	 */
599
+	private function debug()
600
+	{
601
+		return apply_filters(
602
+			'FHEE__EventEspresso_core_services_assets_Registry__debug',
603
+			defined('EE_DEBUG') && EE_DEBUG
604
+		);
605
+	}
606 606
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
                 $script->version(),
147 147
                 $script->loadInFooter()
148 148
             );
149
-            if (! $registered && $this->debug()) {
149
+            if ( ! $registered && $this->debug()) {
150 150
                 throw new AssetRegistrationException($script->handle());
151 151
             }
152 152
             $script->setRegistered($registered);
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         $this->removeAlreadyRegisteredDataForScriptHandles();
207 207
         wp_add_inline_script(
208 208
             'eejs-core',
209
-            'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
209
+            'var eejsdata='.wp_json_encode(array('data' => $this->jsdata)),
210 210
             'before'
211 211
         );
212 212
         $scripts = $this->assets->getJavascriptAssetsWithData();
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
     public function addData($key, $value)
237 237
     {
238 238
         if ($this->verifyDataNotExisting($key)) {
239
-            $this->jsdata[ $key ] = $value;
239
+            $this->jsdata[$key] = $value;
240 240
         }
241 241
     }
242 242
 
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public function pushData($key, $value)
259 259
     {
260
-        if (isset($this->jsdata[ $key ])
261
-            && ! is_array($this->jsdata[ $key ])
260
+        if (isset($this->jsdata[$key])
261
+            && ! is_array($this->jsdata[$key])
262 262
         ) {
263
-            if (! $this->debug()) {
263
+            if ( ! $this->debug()) {
264 264
                 return;
265 265
             }
266 266
             throw new InvalidArgumentException(
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
                 )
276 276
             );
277 277
         }
278
-        $this->jsdata[ $key ][] = $value;
278
+        $this->jsdata[$key][] = $value;
279 279
     }
280 280
 
281 281
 
@@ -289,12 +289,12 @@  discard block
 block discarded – undo
289 289
      */
290 290
     public function addTemplate($template_reference, $template_content)
291 291
     {
292
-        if (! isset($this->jsdata['templates'])) {
292
+        if ( ! isset($this->jsdata['templates'])) {
293 293
             $this->jsdata['templates'] = array();
294 294
         }
295 295
         //no overrides allowed.
296
-        if (isset($this->jsdata['templates'][ $template_reference ])) {
297
-            if (! $this->debug()) {
296
+        if (isset($this->jsdata['templates'][$template_reference])) {
297
+            if ( ! $this->debug()) {
298 298
                 return;
299 299
             }
300 300
             throw new InvalidArgumentException(
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
                 )
308 308
             );
309 309
         }
310
-        $this->jsdata['templates'][ $template_reference ] = $template_content;
310
+        $this->jsdata['templates'][$template_reference] = $template_content;
311 311
     }
312 312
 
313 313
 
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
      */
320 320
     public function getTemplate($template_reference)
321 321
     {
322
-        return isset($this->jsdata['templates'][ $template_reference ])
323
-            ? $this->jsdata['templates'][ $template_reference ]
322
+        return isset($this->jsdata['templates'][$template_reference])
323
+            ? $this->jsdata['templates'][$template_reference]
324 324
             : '';
325 325
     }
326 326
 
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
      */
334 334
     public function getData($key)
335 335
     {
336
-        return isset($this->jsdata[ $key ])
337
-            ? $this->jsdata[ $key ]
336
+        return isset($this->jsdata[$key])
337
+            ? $this->jsdata[$key]
338 338
             : false;
339 339
     }
340 340
 
@@ -349,11 +349,11 @@  discard block
 block discarded – undo
349 349
      */
350 350
     protected function verifyDataNotExisting($key)
351 351
     {
352
-        if (isset($this->jsdata[ $key ])) {
353
-            if (! $this->debug()) {
352
+        if (isset($this->jsdata[$key])) {
353
+            if ( ! $this->debug()) {
354 354
                 return false;
355 355
             }
356
-            if (is_array($this->jsdata[ $key ])) {
356
+            if (is_array($this->jsdata[$key])) {
357 357
                 throw new InvalidArgumentException(
358 358
                     sprintf(
359 359
                         __(
@@ -396,11 +396,11 @@  discard block
 block discarded – undo
396 396
     public function getAssetUrl($namespace, $chunk_name, $asset_type)
397 397
     {
398 398
         $url = isset(
399
-            $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ],
400
-            $this->manifest_data[ $namespace ]['url_base']
399
+            $this->manifest_data[$namespace][$chunk_name.'.'.$asset_type],
400
+            $this->manifest_data[$namespace]['url_base']
401 401
         )
402
-            ? $this->manifest_data[ $namespace ]['url_base']
403
-              . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ]
402
+            ? $this->manifest_data[$namespace]['url_base']
403
+              . $this->manifest_data[$namespace][$chunk_name.'.'.$asset_type]
404 404
             : $chunk_name;
405 405
         return apply_filters(
406 406
             'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
             $this->registerManifestFile(
451 451
                 $manifest_file->assetNamespace(),
452 452
                 $manifest_file->urlBase(),
453
-                $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST
453
+                $manifest_file->filepath().Registry::FILE_NAME_BUILD_MANIFEST
454 454
             );
455 455
         }
456 456
     }
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
      */
469 469
     public function registerManifestFile($namespace, $url_base, $manifest_file)
470 470
     {
471
-        if (isset($this->manifest_data[ $namespace ])) {
472
-            if (! $this->debug()) {
471
+        if (isset($this->manifest_data[$namespace])) {
472
+            if ( ! $this->debug()) {
473 473
                 return;
474 474
             }
475 475
             throw new InvalidArgumentException(
@@ -502,9 +502,9 @@  discard block
 block discarded – undo
502 502
             }
503 503
             return;
504 504
         }
505
-        $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
506
-        if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
507
-            $this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base);
505
+        $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
506
+        if ( ! isset($this->manifest_data[$namespace]['url_base'])) {
507
+            $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
508 508
         }
509 509
     }
510 510
 
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
      */
520 520
     private function decodeManifestFile($manifest_file)
521 521
     {
522
-        if (! file_exists($manifest_file)) {
522
+        if ( ! file_exists($manifest_file)) {
523 523
             throw new InvalidFilePathException($manifest_file);
524 524
         }
525 525
         return json_decode(file_get_contents($manifest_file), true);
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
      */
534 534
     private function addRegisteredScriptHandlesWithData($script_handle)
535 535
     {
536
-        $this->script_handles_with_data[ $script_handle ] = $script_handle;
536
+        $this->script_handles_with_data[$script_handle] = $script_handle;
537 537
     }
538 538
 
539 539
 
@@ -559,23 +559,23 @@  discard block
 block discarded – undo
559 559
      */
560 560
     private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
561 561
     {
562
-        if (isset($this->script_handles_with_data[ $script_handle ])) {
562
+        if (isset($this->script_handles_with_data[$script_handle])) {
563 563
             global $wp_scripts;
564 564
             $unset_handle = false;
565 565
             if ($wp_scripts->get_data($script_handle, 'data')) {
566
-                unset($wp_scripts->registered[ $script_handle ]->extra['data']);
566
+                unset($wp_scripts->registered[$script_handle]->extra['data']);
567 567
                 $unset_handle = true;
568 568
             }
569 569
             //deal with inline_scripts
570 570
             if ($wp_scripts->get_data($script_handle, 'before')) {
571
-                unset($wp_scripts->registered[ $script_handle ]->extra['before']);
571
+                unset($wp_scripts->registered[$script_handle]->extra['before']);
572 572
                 $unset_handle = true;
573 573
             }
574 574
             if ($wp_scripts->get_data($script_handle, 'after')) {
575
-                unset($wp_scripts->registered[ $script_handle ]->extra['after']);
575
+                unset($wp_scripts->registered[$script_handle]->extra['after']);
576 576
             }
577 577
             if ($unset_handle) {
578
-                unset($this->script_handles_with_data[ $script_handle ]);
578
+                unset($this->script_handles_with_data[$script_handle]);
579 579
             }
580 580
         }
581 581
     }
Please login to merge, or discard this patch.
core/EE_Config.core.php 2 patches
Indentation   +3135 added lines, -3135 removed lines patch added patch discarded remove patch
@@ -14,2524 +14,2524 @@  discard block
 block discarded – undo
14 14
 final class EE_Config implements ResettableInterface
15 15
 {
16 16
 
17
-    const OPTION_NAME = 'ee_config';
18
-
19
-    const LOG_NAME = 'ee_config_log';
20
-
21
-    const LOG_LENGTH = 100;
22
-
23
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
24
-
25
-    /**
26
-     *    instance of the EE_Config object
27
-     *
28
-     * @var    EE_Config $_instance
29
-     * @access    private
30
-     */
31
-    private static $_instance;
32
-
33
-    /**
34
-     * @var boolean $_logging_enabled
35
-     */
36
-    private static $_logging_enabled = false;
37
-
38
-    /**
39
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
40
-     */
41
-    private $legacy_shortcodes_manager;
42
-
43
-    /**
44
-     * An StdClass whose property names are addon slugs,
45
-     * and values are their config classes
46
-     *
47
-     * @var StdClass
48
-     */
49
-    public $addons;
50
-
51
-    /**
52
-     * @var EE_Admin_Config
53
-     */
54
-    public $admin;
55
-
56
-    /**
57
-     * @var EE_Core_Config
58
-     */
59
-    public $core;
60
-
61
-    /**
62
-     * @var EE_Currency_Config
63
-     */
64
-    public $currency;
65
-
66
-    /**
67
-     * @var EE_Organization_Config
68
-     */
69
-    public $organization;
70
-
71
-    /**
72
-     * @var EE_Registration_Config
73
-     */
74
-    public $registration;
75
-
76
-    /**
77
-     * @var EE_Template_Config
78
-     */
79
-    public $template_settings;
80
-
81
-    /**
82
-     * Holds EE environment values.
83
-     *
84
-     * @var EE_Environment_Config
85
-     */
86
-    public $environment;
87
-
88
-    /**
89
-     * settings pertaining to Google maps
90
-     *
91
-     * @var EE_Map_Config
92
-     */
93
-    public $map_settings;
94
-
95
-    /**
96
-     * settings pertaining to Taxes
97
-     *
98
-     * @var EE_Tax_Config
99
-     */
100
-    public $tax_settings;
101
-
102
-    /**
103
-     * Settings pertaining to global messages settings.
104
-     *
105
-     * @var EE_Messages_Config
106
-     */
107
-    public $messages;
108
-
109
-    /**
110
-     * @deprecated
111
-     * @var EE_Gateway_Config
112
-     */
113
-    public $gateway;
114
-
115
-    /**
116
-     * @var    array $_addon_option_names
117
-     * @access    private
118
-     */
119
-    private $_addon_option_names = array();
120
-
121
-    /**
122
-     * @var    array $_module_route_map
123
-     * @access    private
124
-     */
125
-    private static $_module_route_map = array();
126
-
127
-    /**
128
-     * @var    array $_module_forward_map
129
-     * @access    private
130
-     */
131
-    private static $_module_forward_map = array();
132
-
133
-    /**
134
-     * @var    array $_module_view_map
135
-     * @access    private
136
-     */
137
-    private static $_module_view_map = array();
138
-
139
-
140
-    /**
141
-     * @singleton method used to instantiate class object
142
-     * @access    public
143
-     * @return EE_Config instance
144
-     */
145
-    public static function instance()
146
-    {
147
-        // check if class object is instantiated, and instantiated properly
148
-        if (! self::$_instance instanceof EE_Config) {
149
-            self::$_instance = new self();
150
-        }
151
-        return self::$_instance;
152
-    }
153
-
154
-
155
-    /**
156
-     * Resets the config
157
-     *
158
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
159
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
160
-     *                               reflect its state in the database
161
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
162
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
163
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
164
-     *                               site was put into maintenance mode)
165
-     * @return EE_Config
166
-     */
167
-    public static function reset($hard_reset = false, $reinstantiate = true)
168
-    {
169
-        if (self::$_instance instanceof EE_Config) {
170
-            if ($hard_reset) {
171
-                self::$_instance->legacy_shortcodes_manager = null;
172
-                self::$_instance->_addon_option_names = array();
173
-                self::$_instance->_initialize_config();
174
-                self::$_instance->update_espresso_config();
175
-            }
176
-            self::$_instance->update_addon_option_names();
177
-        }
178
-        self::$_instance = null;
179
-        // we don't need to reset the static properties imo because those should
180
-        // only change when a module is added or removed. Currently we don't
181
-        // support removing a module during a request when it previously existed
182
-        if ($reinstantiate) {
183
-            return self::instance();
184
-        } else {
185
-            return null;
186
-        }
187
-    }
188
-
189
-
190
-    /**
191
-     *    class constructor
192
-     *
193
-     * @access    private
194
-     */
195
-    private function __construct()
196
-    {
197
-        do_action('AHEE__EE_Config__construct__begin', $this);
198
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
199
-        // setup empty config classes
200
-        $this->_initialize_config();
201
-        // load existing EE site settings
202
-        $this->_load_core_config();
203
-        // confirm everything loaded correctly and set filtered defaults if not
204
-        $this->_verify_config();
205
-        //  register shortcodes and modules
206
-        add_action(
207
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
208
-            array($this, 'register_shortcodes_and_modules'),
209
-            999
210
-        );
211
-        //  initialize shortcodes and modules
212
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
213
-        // register widgets
214
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
215
-        // shutdown
216
-        add_action('shutdown', array($this, 'shutdown'), 10);
217
-        // construct__end hook
218
-        do_action('AHEE__EE_Config__construct__end', $this);
219
-        // hardcoded hack
220
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
221
-    }
222
-
223
-
224
-    /**
225
-     * @return boolean
226
-     */
227
-    public static function logging_enabled()
228
-    {
229
-        return self::$_logging_enabled;
230
-    }
231
-
232
-
233
-    /**
234
-     * use to get the current theme if needed from static context
235
-     *
236
-     * @return string current theme set.
237
-     */
238
-    public static function get_current_theme()
239
-    {
240
-        return isset(self::$_instance->template_settings->current_espresso_theme)
241
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
242
-    }
243
-
244
-
245
-    /**
246
-     *        _initialize_config
247
-     *
248
-     * @access private
249
-     * @return void
250
-     */
251
-    private function _initialize_config()
252
-    {
253
-        EE_Config::trim_log();
254
-        // set defaults
255
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
256
-        $this->addons = new stdClass();
257
-        // set _module_route_map
258
-        EE_Config::$_module_route_map = array();
259
-        // set _module_forward_map
260
-        EE_Config::$_module_forward_map = array();
261
-        // set _module_view_map
262
-        EE_Config::$_module_view_map = array();
263
-    }
264
-
265
-
266
-    /**
267
-     *        load core plugin configuration
268
-     *
269
-     * @access private
270
-     * @return void
271
-     */
272
-    private function _load_core_config()
273
-    {
274
-        // load_core_config__start hook
275
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
276
-        $espresso_config = $this->get_espresso_config();
277
-        foreach ($espresso_config as $config => $settings) {
278
-            // load_core_config__start hook
279
-            $settings = apply_filters(
280
-                'FHEE__EE_Config___load_core_config__config_settings',
281
-                $settings,
282
-                $config,
283
-                $this
284
-            );
285
-            if (is_object($settings) && property_exists($this, $config)) {
286
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
287
-                // call configs populate method to ensure any defaults are set for empty values.
288
-                if (method_exists($settings, 'populate')) {
289
-                    $this->{$config}->populate();
290
-                }
291
-                if (method_exists($settings, 'do_hooks')) {
292
-                    $this->{$config}->do_hooks();
293
-                }
294
-            }
295
-        }
296
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
297
-            $this->update_espresso_config();
298
-        }
299
-        // load_core_config__end hook
300
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
301
-    }
302
-
303
-
304
-    /**
305
-     *    _verify_config
306
-     *
307
-     * @access    protected
308
-     * @return    void
309
-     */
310
-    protected function _verify_config()
311
-    {
312
-        $this->core = $this->core instanceof EE_Core_Config
313
-            ? $this->core
314
-            : new EE_Core_Config();
315
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
316
-        $this->organization = $this->organization instanceof EE_Organization_Config
317
-            ? $this->organization
318
-            : new EE_Organization_Config();
319
-        $this->organization = apply_filters(
320
-            'FHEE__EE_Config___initialize_config__organization',
321
-            $this->organization
322
-        );
323
-        $this->currency = $this->currency instanceof EE_Currency_Config
324
-            ? $this->currency
325
-            : new EE_Currency_Config();
326
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
327
-        $this->registration = $this->registration instanceof EE_Registration_Config
328
-            ? $this->registration
329
-            : new EE_Registration_Config();
330
-        $this->registration = apply_filters(
331
-            'FHEE__EE_Config___initialize_config__registration',
332
-            $this->registration
333
-        );
334
-        $this->admin = $this->admin instanceof EE_Admin_Config
335
-            ? $this->admin
336
-            : new EE_Admin_Config();
337
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
338
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
339
-            ? $this->template_settings
340
-            : new EE_Template_Config();
341
-        $this->template_settings = apply_filters(
342
-            'FHEE__EE_Config___initialize_config__template_settings',
343
-            $this->template_settings
344
-        );
345
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
346
-            ? $this->map_settings
347
-            : new EE_Map_Config();
348
-        $this->map_settings = apply_filters(
349
-            'FHEE__EE_Config___initialize_config__map_settings',
350
-            $this->map_settings
351
-        );
352
-        $this->environment = $this->environment instanceof EE_Environment_Config
353
-            ? $this->environment
354
-            : new EE_Environment_Config();
355
-        $this->environment = apply_filters(
356
-            'FHEE__EE_Config___initialize_config__environment',
357
-            $this->environment
358
-        );
359
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
360
-            ? $this->tax_settings
361
-            : new EE_Tax_Config();
362
-        $this->tax_settings = apply_filters(
363
-            'FHEE__EE_Config___initialize_config__tax_settings',
364
-            $this->tax_settings
365
-        );
366
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
367
-        $this->messages = $this->messages instanceof EE_Messages_Config
368
-            ? $this->messages
369
-            : new EE_Messages_Config();
370
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
371
-            ? $this->gateway
372
-            : new EE_Gateway_Config();
373
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
374
-        $this->legacy_shortcodes_manager = null;
375
-    }
376
-
377
-
378
-    /**
379
-     *    get_espresso_config
380
-     *
381
-     * @access    public
382
-     * @return    array of espresso config stuff
383
-     */
384
-    public function get_espresso_config()
385
-    {
386
-        // grab espresso configuration
387
-        return apply_filters(
388
-            'FHEE__EE_Config__get_espresso_config__CFG',
389
-            get_option(EE_Config::OPTION_NAME, array())
390
-        );
391
-    }
392
-
393
-
394
-    /**
395
-     *    double_check_config_comparison
396
-     *
397
-     * @access    public
398
-     * @param string $option
399
-     * @param        $old_value
400
-     * @param        $value
401
-     */
402
-    public function double_check_config_comparison($option = '', $old_value, $value)
403
-    {
404
-        // make sure we're checking the ee config
405
-        if ($option === EE_Config::OPTION_NAME) {
406
-            // run a loose comparison of the old value against the new value for type and properties,
407
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
408
-            if ($value != $old_value) {
409
-                // if they are NOT the same, then remove the hook,
410
-                // which means the subsequent update results will be based solely on the update query results
411
-                // the reason we do this is because, as stated above,
412
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
413
-                // this happens PRIOR to serialization and any subsequent update.
414
-                // If values are found to match their previous old value,
415
-                // then WP bails before performing any update.
416
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
417
-                // it just pulled from the db, with the one being passed to it (which will not match).
418
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
419
-                // MySQL MAY ALSO NOT perform the update because
420
-                // the string it sees in the db looks the same as the new one it has been passed!!!
421
-                // This results in the query returning an "affected rows" value of ZERO,
422
-                // which gets returned immediately by WP update_option and looks like an error.
423
-                remove_action('update_option', array($this, 'check_config_updated'));
424
-            }
425
-        }
426
-    }
427
-
428
-
429
-    /**
430
-     *    update_espresso_config
431
-     *
432
-     * @access   public
433
-     */
434
-    protected function _reset_espresso_addon_config()
435
-    {
436
-        $this->_addon_option_names = array();
437
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
438
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
439
-            if ($addon_config_obj instanceof EE_Config_Base) {
440
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
441
-            }
442
-            $this->addons->{$addon_name} = null;
443
-        }
444
-    }
445
-
446
-
447
-    /**
448
-     *    update_espresso_config
449
-     *
450
-     * @access   public
451
-     * @param   bool $add_success
452
-     * @param   bool $add_error
453
-     * @return   bool
454
-     */
455
-    public function update_espresso_config($add_success = false, $add_error = true)
456
-    {
457
-        // don't allow config updates during WP heartbeats
458
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
459
-            return false;
460
-        }
461
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
462
-        // $clone = clone( self::$_instance );
463
-        // self::$_instance = NULL;
464
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
465
-        $this->_reset_espresso_addon_config();
466
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
467
-        // but BEFORE the actual update occurs
468
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
469
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
470
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
471
-        $this->legacy_shortcodes_manager = null;
472
-        // now update "ee_config"
473
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
474
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
475
-        EE_Config::log(EE_Config::OPTION_NAME);
476
-        // if not saved... check if the hook we just added still exists;
477
-        // if it does, it means one of two things:
478
-        // that update_option bailed at the($value === $old_value) conditional,
479
-        // or...
480
-        // the db update query returned 0 rows affected
481
-        // (probably because the data  value was the same from it's perspective)
482
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
483
-        // but just means no update occurred, so don't display an error to the user.
484
-        // BUT... if update_option returns FALSE, AND the hook is missing,
485
-        // then it means that something truly went wrong
486
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
487
-        // remove our action since we don't want it in the system anymore
488
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
489
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
490
-        // self::$_instance = $clone;
491
-        // unset( $clone );
492
-        // if config remains the same or was updated successfully
493
-        if ($saved) {
494
-            if ($add_success) {
495
-                EE_Error::add_success(
496
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
497
-                    __FILE__,
498
-                    __FUNCTION__,
499
-                    __LINE__
500
-                );
501
-            }
502
-            return true;
503
-        } else {
504
-            if ($add_error) {
505
-                EE_Error::add_error(
506
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
507
-                    __FILE__,
508
-                    __FUNCTION__,
509
-                    __LINE__
510
-                );
511
-            }
512
-            return false;
513
-        }
514
-    }
515
-
516
-
517
-    /**
518
-     *    _verify_config_params
519
-     *
520
-     * @access    private
521
-     * @param    string         $section
522
-     * @param    string         $name
523
-     * @param    string         $config_class
524
-     * @param    EE_Config_Base $config_obj
525
-     * @param    array          $tests_to_run
526
-     * @param    bool           $display_errors
527
-     * @return    bool    TRUE on success, FALSE on fail
528
-     */
529
-    private function _verify_config_params(
530
-        $section = '',
531
-        $name = '',
532
-        $config_class = '',
533
-        $config_obj = null,
534
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
535
-        $display_errors = true
536
-    ) {
537
-        try {
538
-            foreach ($tests_to_run as $test) {
539
-                switch ($test) {
540
-                    // TEST #1 : check that section was set
541
-                    case 1:
542
-                        if (empty($section)) {
543
-                            if ($display_errors) {
544
-                                throw new EE_Error(
545
-                                    sprintf(
546
-                                        __(
547
-                                            'No configuration section has been provided while attempting to save "%s".',
548
-                                            'event_espresso'
549
-                                        ),
550
-                                        $config_class
551
-                                    )
552
-                                );
553
-                            }
554
-                            return false;
555
-                        }
556
-                        break;
557
-                    // TEST #2 : check that settings section exists
558
-                    case 2:
559
-                        if (! isset($this->{$section})) {
560
-                            if ($display_errors) {
561
-                                throw new EE_Error(
562
-                                    sprintf(
563
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
564
-                                        $section
565
-                                    )
566
-                                );
567
-                            }
568
-                            return false;
569
-                        }
570
-                        break;
571
-                    // TEST #3 : check that section is the proper format
572
-                    case 3:
573
-                        if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
574
-                        ) {
575
-                            if ($display_errors) {
576
-                                throw new EE_Error(
577
-                                    sprintf(
578
-                                        __(
579
-                                            'The "%s" configuration settings have not been formatted correctly.',
580
-                                            'event_espresso'
581
-                                        ),
582
-                                        $section
583
-                                    )
584
-                                );
585
-                            }
586
-                            return false;
587
-                        }
588
-                        break;
589
-                    // TEST #4 : check that config section name has been set
590
-                    case 4:
591
-                        if (empty($name)) {
592
-                            if ($display_errors) {
593
-                                throw new EE_Error(
594
-                                    __(
595
-                                        'No name has been provided for the specific configuration section.',
596
-                                        'event_espresso'
597
-                                    )
598
-                                );
599
-                            }
600
-                            return false;
601
-                        }
602
-                        break;
603
-                    // TEST #5 : check that a config class name has been set
604
-                    case 5:
605
-                        if (empty($config_class)) {
606
-                            if ($display_errors) {
607
-                                throw new EE_Error(
608
-                                    __(
609
-                                        'No class name has been provided for the specific configuration section.',
610
-                                        'event_espresso'
611
-                                    )
612
-                                );
613
-                            }
614
-                            return false;
615
-                        }
616
-                        break;
617
-                    // TEST #6 : verify config class is accessible
618
-                    case 6:
619
-                        if (! class_exists($config_class)) {
620
-                            if ($display_errors) {
621
-                                throw new EE_Error(
622
-                                    sprintf(
623
-                                        __(
624
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
625
-                                            'event_espresso'
626
-                                        ),
627
-                                        $config_class
628
-                                    )
629
-                                );
630
-                            }
631
-                            return false;
632
-                        }
633
-                        break;
634
-                    // TEST #7 : check that config has even been set
635
-                    case 7:
636
-                        if (! isset($this->{$section}->{$name})) {
637
-                            if ($display_errors) {
638
-                                throw new EE_Error(
639
-                                    sprintf(
640
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
641
-                                        $section,
642
-                                        $name
643
-                                    )
644
-                                );
645
-                            }
646
-                            return false;
647
-                        } else {
648
-                            // and make sure it's not serialized
649
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
650
-                        }
651
-                        break;
652
-                    // TEST #8 : check that config is the requested type
653
-                    case 8:
654
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
655
-                            if ($display_errors) {
656
-                                throw new EE_Error(
657
-                                    sprintf(
658
-                                        __(
659
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
660
-                                            'event_espresso'
661
-                                        ),
662
-                                        $section,
663
-                                        $name,
664
-                                        $config_class
665
-                                    )
666
-                                );
667
-                            }
668
-                            return false;
669
-                        }
670
-                        break;
671
-                    // TEST #9 : verify config object
672
-                    case 9:
673
-                        if (! $config_obj instanceof EE_Config_Base) {
674
-                            if ($display_errors) {
675
-                                throw new EE_Error(
676
-                                    sprintf(
677
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
678
-                                        print_r($config_obj, true)
679
-                                    )
680
-                                );
681
-                            }
682
-                            return false;
683
-                        }
684
-                        break;
685
-                }
686
-            }
687
-        } catch (EE_Error $e) {
688
-            $e->get_error();
689
-        }
690
-        // you have successfully run the gauntlet
691
-        return true;
692
-    }
693
-
694
-
695
-    /**
696
-     *    _generate_config_option_name
697
-     *
698
-     * @access        protected
699
-     * @param        string $section
700
-     * @param        string $name
701
-     * @return        string
702
-     */
703
-    private function _generate_config_option_name($section = '', $name = '')
704
-    {
705
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
706
-    }
707
-
708
-
709
-    /**
710
-     *    _set_config_class
711
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
712
-     *
713
-     * @access    private
714
-     * @param    string $config_class
715
-     * @param    string $name
716
-     * @return    string
717
-     */
718
-    private function _set_config_class($config_class = '', $name = '')
719
-    {
720
-        return ! empty($config_class)
721
-            ? $config_class
722
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
723
-    }
724
-
725
-
726
-    /**
727
-     *    set_config
728
-     *
729
-     * @access    protected
730
-     * @param    string         $section
731
-     * @param    string         $name
732
-     * @param    string         $config_class
733
-     * @param    EE_Config_Base $config_obj
734
-     * @return    EE_Config_Base
735
-     */
736
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
737
-    {
738
-        // ensure config class is set to something
739
-        $config_class = $this->_set_config_class($config_class, $name);
740
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
741
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
742
-            return null;
743
-        }
744
-        $config_option_name = $this->_generate_config_option_name($section, $name);
745
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
746
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
747
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
748
-            $this->update_addon_option_names();
749
-        }
750
-        // verify the incoming config object but suppress errors
751
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
752
-            $config_obj = new $config_class();
753
-        }
754
-        if (get_option($config_option_name)) {
755
-            EE_Config::log($config_option_name);
756
-            update_option($config_option_name, $config_obj);
757
-            $this->{$section}->{$name} = $config_obj;
758
-            return $this->{$section}->{$name};
759
-        } else {
760
-            // create a wp-option for this config
761
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
762
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
763
-                return $this->{$section}->{$name};
764
-            } else {
765
-                EE_Error::add_error(
766
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
767
-                    __FILE__,
768
-                    __FUNCTION__,
769
-                    __LINE__
770
-                );
771
-                return null;
772
-            }
773
-        }
774
-    }
775
-
776
-
777
-    /**
778
-     *    update_config
779
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
780
-     *
781
-     * @access    public
782
-     * @param    string                $section
783
-     * @param    string                $name
784
-     * @param    EE_Config_Base|string $config_obj
785
-     * @param    bool                  $throw_errors
786
-     * @return    bool
787
-     */
788
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
789
-    {
790
-        // don't allow config updates during WP heartbeats
791
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
792
-            return false;
793
-        }
794
-        $config_obj = maybe_unserialize($config_obj);
795
-        // get class name of the incoming object
796
-        $config_class = get_class($config_obj);
797
-        // run tests 1-5 and 9 to verify config
798
-        if (! $this->_verify_config_params(
799
-            $section,
800
-            $name,
801
-            $config_class,
802
-            $config_obj,
803
-            array(1, 2, 3, 4, 7, 9)
804
-        )
805
-        ) {
806
-            return false;
807
-        }
808
-        $config_option_name = $this->_generate_config_option_name($section, $name);
809
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
810
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
811
-            // save new config to db
812
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
813
-                return true;
814
-            }
815
-        } else {
816
-            // first check if the record already exists
817
-            $existing_config = get_option($config_option_name);
818
-            $config_obj = serialize($config_obj);
819
-            // just return if db record is already up to date (NOT type safe comparison)
820
-            if ($existing_config == $config_obj) {
821
-                $this->{$section}->{$name} = $config_obj;
822
-                return true;
823
-            } elseif (update_option($config_option_name, $config_obj)) {
824
-                EE_Config::log($config_option_name);
825
-                // update wp-option for this config class
826
-                $this->{$section}->{$name} = $config_obj;
827
-                return true;
828
-            } elseif ($throw_errors) {
829
-                EE_Error::add_error(
830
-                    sprintf(
831
-                        __(
832
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
833
-                            'event_espresso'
834
-                        ),
835
-                        $config_class,
836
-                        'EE_Config->' . $section . '->' . $name
837
-                    ),
838
-                    __FILE__,
839
-                    __FUNCTION__,
840
-                    __LINE__
841
-                );
842
-            }
843
-        }
844
-        return false;
845
-    }
846
-
847
-
848
-    /**
849
-     *    get_config
850
-     *
851
-     * @access    public
852
-     * @param    string $section
853
-     * @param    string $name
854
-     * @param    string $config_class
855
-     * @return    mixed EE_Config_Base | NULL
856
-     */
857
-    public function get_config($section = '', $name = '', $config_class = '')
858
-    {
859
-        // ensure config class is set to something
860
-        $config_class = $this->_set_config_class($config_class, $name);
861
-        // run tests 1-4, 6 and 7 to verify that all params have been set
862
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
863
-            return null;
864
-        }
865
-        // now test if the requested config object exists, but suppress errors
866
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
867
-            // config already exists, so pass it back
868
-            return $this->{$section}->{$name};
869
-        }
870
-        // load config option from db if it exists
871
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
872
-        // verify the newly retrieved config object, but suppress errors
873
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
874
-            // config is good, so set it and pass it back
875
-            $this->{$section}->{$name} = $config_obj;
876
-            return $this->{$section}->{$name};
877
-        }
878
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
879
-        $config_obj = $this->set_config($section, $name, $config_class);
880
-        // verify the newly created config object
881
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
882
-            return $this->{$section}->{$name};
883
-        } else {
884
-            EE_Error::add_error(
885
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
886
-                __FILE__,
887
-                __FUNCTION__,
888
-                __LINE__
889
-            );
890
-        }
891
-        return null;
892
-    }
893
-
894
-
895
-    /**
896
-     *    get_config_option
897
-     *
898
-     * @access    public
899
-     * @param    string $config_option_name
900
-     * @return    mixed EE_Config_Base | FALSE
901
-     */
902
-    public function get_config_option($config_option_name = '')
903
-    {
904
-        // retrieve the wp-option for this config class.
905
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
906
-        if (empty($config_option)) {
907
-            EE_Config::log($config_option_name . '-NOT-FOUND');
908
-        }
909
-        return $config_option;
910
-    }
911
-
912
-
913
-    /**
914
-     * log
915
-     *
916
-     * @param string $config_option_name
917
-     */
918
-    public static function log($config_option_name = '')
919
-    {
920
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
921
-            $config_log = get_option(EE_Config::LOG_NAME, array());
922
-            // copy incoming $_REQUEST and sanitize it so we can save it
923
-            $_request = $_REQUEST;
924
-            array_walk_recursive($_request, 'sanitize_text_field');
925
-            $config_log[ (string) microtime(true) ] = array(
926
-                'config_name' => $config_option_name,
927
-                'request'     => $_request,
928
-            );
929
-            update_option(EE_Config::LOG_NAME, $config_log);
930
-        }
931
-    }
932
-
933
-
934
-    /**
935
-     * trim_log
936
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
937
-     */
938
-    public static function trim_log()
939
-    {
940
-        if (! EE_Config::logging_enabled()) {
941
-            return;
942
-        }
943
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
944
-        $log_length = count($config_log);
945
-        if ($log_length > EE_Config::LOG_LENGTH) {
946
-            ksort($config_log);
947
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
948
-            update_option(EE_Config::LOG_NAME, $config_log);
949
-        }
950
-    }
951
-
952
-
953
-    /**
954
-     *    get_page_for_posts
955
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
956
-     *    wp-option "page_for_posts", or "posts" if no page is selected
957
-     *
958
-     * @access    public
959
-     * @return    string
960
-     */
961
-    public static function get_page_for_posts()
962
-    {
963
-        $page_for_posts = get_option('page_for_posts');
964
-        if (! $page_for_posts) {
965
-            return 'posts';
966
-        }
967
-        /** @type WPDB $wpdb */
968
-        global $wpdb;
969
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
970
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
971
-    }
972
-
973
-
974
-    /**
975
-     *    register_shortcodes_and_modules.
976
-     *    At this point, it's too early to tell if we're maintenance mode or not.
977
-     *    In fact, this is where we give modules a chance to let core know they exist
978
-     *    so they can help trigger maintenance mode if it's needed
979
-     *
980
-     * @access    public
981
-     * @return    void
982
-     */
983
-    public function register_shortcodes_and_modules()
984
-    {
985
-        // allow modules to set hooks for the rest of the system
986
-        EE_Registry::instance()->modules = $this->_register_modules();
987
-    }
988
-
989
-
990
-    /**
991
-     *    initialize_shortcodes_and_modules
992
-     *    meaning they can start adding their hooks to get stuff done
993
-     *
994
-     * @access    public
995
-     * @return    void
996
-     */
997
-    public function initialize_shortcodes_and_modules()
998
-    {
999
-        // allow modules to set hooks for the rest of the system
1000
-        $this->_initialize_modules();
1001
-    }
1002
-
1003
-
1004
-    /**
1005
-     *    widgets_init
1006
-     *
1007
-     * @access private
1008
-     * @return void
1009
-     */
1010
-    public function widgets_init()
1011
-    {
1012
-        // only init widgets on admin pages when not in complete maintenance, and
1013
-        // on frontend when not in any maintenance mode
1014
-        if (! EE_Maintenance_Mode::instance()->level()
1015
-            || (
1016
-                is_admin()
1017
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1018
-            )
1019
-        ) {
1020
-            // grab list of installed widgets
1021
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1022
-            // filter list of modules to register
1023
-            $widgets_to_register = apply_filters(
1024
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1025
-                $widgets_to_register
1026
-            );
1027
-            if (! empty($widgets_to_register)) {
1028
-                // cycle thru widget folders
1029
-                foreach ($widgets_to_register as $widget_path) {
1030
-                    // add to list of installed widget modules
1031
-                    EE_Config::register_ee_widget($widget_path);
1032
-                }
1033
-            }
1034
-            // filter list of installed modules
1035
-            EE_Registry::instance()->widgets = apply_filters(
1036
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1037
-                EE_Registry::instance()->widgets
1038
-            );
1039
-        }
1040
-    }
1041
-
1042
-
1043
-    /**
1044
-     *    register_ee_widget - makes core aware of this widget
1045
-     *
1046
-     * @access    public
1047
-     * @param    string $widget_path - full path up to and including widget folder
1048
-     * @return    void
1049
-     */
1050
-    public static function register_ee_widget($widget_path = null)
1051
-    {
1052
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1053
-        $widget_ext = '.widget.php';
1054
-        // make all separators match
1055
-        $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1056
-        // does the file path INCLUDE the actual file name as part of the path ?
1057
-        if (strpos($widget_path, $widget_ext) !== false) {
1058
-            // grab and shortcode file name from directory name and break apart at dots
1059
-            $file_name = explode('.', basename($widget_path));
1060
-            // take first segment from file name pieces and remove class prefix if it exists
1061
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1062
-            // sanitize shortcode directory name
1063
-            $widget = sanitize_key($widget);
1064
-            // now we need to rebuild the shortcode path
1065
-            $widget_path = explode(DS, $widget_path);
1066
-            // remove last segment
1067
-            array_pop($widget_path);
1068
-            // glue it back together
1069
-            $widget_path = implode(DS, $widget_path);
1070
-        } else {
1071
-            // grab and sanitize widget directory name
1072
-            $widget = sanitize_key(basename($widget_path));
1073
-        }
1074
-        // create classname from widget directory name
1075
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1076
-        // add class prefix
1077
-        $widget_class = 'EEW_' . $widget;
1078
-        // does the widget exist ?
1079
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1080
-            $msg = sprintf(
1081
-                __(
1082
-                    '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',
1083
-                    'event_espresso'
1084
-                ),
1085
-                $widget_class,
1086
-                $widget_path . DS . $widget_class . $widget_ext
1087
-            );
1088
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1089
-            return;
1090
-        }
1091
-        // load the widget class file
1092
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1093
-        // verify that class exists
1094
-        if (! class_exists($widget_class)) {
1095
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1096
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1097
-            return;
1098
-        }
1099
-        register_widget($widget_class);
1100
-        // add to array of registered widgets
1101
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1102
-    }
1103
-
1104
-
1105
-    /**
1106
-     *        _register_modules
1107
-     *
1108
-     * @access private
1109
-     * @return array
1110
-     */
1111
-    private function _register_modules()
1112
-    {
1113
-        // grab list of installed modules
1114
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1115
-        // filter list of modules to register
1116
-        $modules_to_register = apply_filters(
1117
-            'FHEE__EE_Config__register_modules__modules_to_register',
1118
-            $modules_to_register
1119
-        );
1120
-        if (! empty($modules_to_register)) {
1121
-            // loop through folders
1122
-            foreach ($modules_to_register as $module_path) {
1123
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1124
-                if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1125
-                    && $module_path !== EE_MODULES . 'gateways'
1126
-                ) {
1127
-                    // add to list of installed modules
1128
-                    EE_Config::register_module($module_path);
1129
-                }
1130
-            }
1131
-        }
1132
-        // filter list of installed modules
1133
-        return apply_filters(
1134
-            'FHEE__EE_Config___register_modules__installed_modules',
1135
-            EE_Registry::instance()->modules
1136
-        );
1137
-    }
1138
-
1139
-
1140
-    /**
1141
-     *    register_module - makes core aware of this module
1142
-     *
1143
-     * @access    public
1144
-     * @param    string $module_path - full path up to and including module folder
1145
-     * @return    bool
1146
-     */
1147
-    public static function register_module($module_path = null)
1148
-    {
1149
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1150
-        $module_ext = '.module.php';
1151
-        // make all separators match
1152
-        $module_path = str_replace(array('\\', '/'), DS, $module_path);
1153
-        // does the file path INCLUDE the actual file name as part of the path ?
1154
-        if (strpos($module_path, $module_ext) !== false) {
1155
-            // grab and shortcode file name from directory name and break apart at dots
1156
-            $module_file = explode('.', basename($module_path));
1157
-            // now we need to rebuild the shortcode path
1158
-            $module_path = explode(DS, $module_path);
1159
-            // remove last segment
1160
-            array_pop($module_path);
1161
-            // glue it back together
1162
-            $module_path = implode(DS, $module_path) . DS;
1163
-            // take first segment from file name pieces and sanitize it
1164
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1165
-            // ensure class prefix is added
1166
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1167
-        } else {
1168
-            // we need to generate the filename based off of the folder name
1169
-            // grab and sanitize module name
1170
-            $module = strtolower(basename($module_path));
1171
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1172
-            // like trailingslashit()
1173
-            $module_path = rtrim($module_path, DS) . DS;
1174
-            // create classname from module directory name
1175
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1176
-            // add class prefix
1177
-            $module_class = 'EED_' . $module;
1178
-        }
1179
-        // does the module exist ?
1180
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1181
-            $msg = sprintf(
1182
-                __(
1183
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1184
-                    'event_espresso'
1185
-                ),
1186
-                $module
1187
-            );
1188
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1189
-            return false;
1190
-        }
1191
-        // load the module class file
1192
-        require_once($module_path . $module_class . $module_ext);
1193
-        // verify that class exists
1194
-        if (! class_exists($module_class)) {
1195
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1196
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1197
-            return false;
1198
-        }
1199
-        // add to array of registered modules
1200
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1201
-        do_action(
1202
-            'AHEE__EE_Config__register_module__complete',
1203
-            $module_class,
1204
-            EE_Registry::instance()->modules->{$module_class}
1205
-        );
1206
-        return true;
1207
-    }
1208
-
1209
-
1210
-    /**
1211
-     *    _initialize_modules
1212
-     *    allow modules to set hooks for the rest of the system
1213
-     *
1214
-     * @access private
1215
-     * @return void
1216
-     */
1217
-    private function _initialize_modules()
1218
-    {
1219
-        // cycle thru shortcode folders
1220
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1221
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1222
-            // which set hooks ?
1223
-            if (is_admin()) {
1224
-                // fire immediately
1225
-                call_user_func(array($module_class, 'set_hooks_admin'));
1226
-            } else {
1227
-                // delay until other systems are online
1228
-                add_action(
1229
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1230
-                    array($module_class, 'set_hooks')
1231
-                );
1232
-            }
1233
-        }
1234
-    }
1235
-
1236
-
1237
-    /**
1238
-     *    register_route - adds module method routes to route_map
1239
-     *
1240
-     * @access    public
1241
-     * @param    string $route       - "pretty" public alias for module method
1242
-     * @param    string $module      - module name (classname without EED_ prefix)
1243
-     * @param    string $method_name - the actual module method to be routed to
1244
-     * @param    string $key         - url param key indicating a route is being called
1245
-     * @return    bool
1246
-     */
1247
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1248
-    {
1249
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1250
-        $module = str_replace('EED_', '', $module);
1251
-        $module_class = 'EED_' . $module;
1252
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1253
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1254
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1255
-            return false;
1256
-        }
1257
-        if (empty($route)) {
1258
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1259
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1260
-            return false;
1261
-        }
1262
-        if (! method_exists('EED_' . $module, $method_name)) {
1263
-            $msg = sprintf(
1264
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1265
-                $route
1266
-            );
1267
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1268
-            return false;
1269
-        }
1270
-        EE_Config::$_module_route_map[ $key ][ $route ] = array('EED_' . $module, $method_name);
1271
-        return true;
1272
-    }
1273
-
1274
-
1275
-    /**
1276
-     *    get_route - get module method route
1277
-     *
1278
-     * @access    public
1279
-     * @param    string $route - "pretty" public alias for module method
1280
-     * @param    string $key   - url param key indicating a route is being called
1281
-     * @return    string
1282
-     */
1283
-    public static function get_route($route = null, $key = 'ee')
1284
-    {
1285
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1286
-        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1287
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1288
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1289
-        }
1290
-        return null;
1291
-    }
1292
-
1293
-
1294
-    /**
1295
-     *    get_routes - get ALL module method routes
1296
-     *
1297
-     * @access    public
1298
-     * @return    array
1299
-     */
1300
-    public static function get_routes()
1301
-    {
1302
-        return EE_Config::$_module_route_map;
1303
-    }
1304
-
1305
-
1306
-    /**
1307
-     *    register_forward - allows modules to forward request to another module for further processing
1308
-     *
1309
-     * @access    public
1310
-     * @param    string       $route   - "pretty" public alias for module method
1311
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1312
-     *                                 class, allows different forwards to be served based on status
1313
-     * @param    array|string $forward - function name or array( class, method )
1314
-     * @param    string       $key     - url param key indicating a route is being called
1315
-     * @return    bool
1316
-     */
1317
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1318
-    {
1319
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1320
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1321
-            $msg = sprintf(
1322
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1323
-                $route
1324
-            );
1325
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1326
-            return false;
1327
-        }
1328
-        if (empty($forward)) {
1329
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1330
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1331
-            return false;
1332
-        }
1333
-        if (is_array($forward)) {
1334
-            if (! isset($forward[1])) {
1335
-                $msg = sprintf(
1336
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1337
-                    $route
1338
-                );
1339
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1340
-                return false;
1341
-            }
1342
-            if (! method_exists($forward[0], $forward[1])) {
1343
-                $msg = sprintf(
1344
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1345
-                    $forward[1],
1346
-                    $route
1347
-                );
1348
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1349
-                return false;
1350
-            }
1351
-        } elseif (! function_exists($forward)) {
1352
-            $msg = sprintf(
1353
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1354
-                $forward,
1355
-                $route
1356
-            );
1357
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1358
-            return false;
1359
-        }
1360
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1361
-        return true;
1362
-    }
1363
-
1364
-
1365
-    /**
1366
-     *    get_forward - get forwarding route
1367
-     *
1368
-     * @access    public
1369
-     * @param    string  $route  - "pretty" public alias for module method
1370
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1371
-     *                           allows different forwards to be served based on status
1372
-     * @param    string  $key    - url param key indicating a route is being called
1373
-     * @return    string
1374
-     */
1375
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1376
-    {
1377
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1378
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1379
-            return apply_filters(
1380
-                'FHEE__EE_Config__get_forward',
1381
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1382
-                $route,
1383
-                $status
1384
-            );
1385
-        }
1386
-        return null;
1387
-    }
1388
-
1389
-
1390
-    /**
1391
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1392
-     *    results
1393
-     *
1394
-     * @access    public
1395
-     * @param    string  $route  - "pretty" public alias for module method
1396
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1397
-     *                           allows different views to be served based on status
1398
-     * @param    string  $view
1399
-     * @param    string  $key    - url param key indicating a route is being called
1400
-     * @return    bool
1401
-     */
1402
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1403
-    {
1404
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1405
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1406
-            $msg = sprintf(
1407
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1408
-                $route
1409
-            );
1410
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1411
-            return false;
1412
-        }
1413
-        if (! is_readable($view)) {
1414
-            $msg = sprintf(
1415
-                __(
1416
-                    'The %s view file could not be found or is not readable due to file permissions.',
1417
-                    'event_espresso'
1418
-                ),
1419
-                $view
1420
-            );
1421
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1422
-            return false;
1423
-        }
1424
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1425
-        return true;
1426
-    }
1427
-
1428
-
1429
-    /**
1430
-     *    get_view - get view for route and status
1431
-     *
1432
-     * @access    public
1433
-     * @param    string  $route  - "pretty" public alias for module method
1434
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1435
-     *                           allows different views to be served based on status
1436
-     * @param    string  $key    - url param key indicating a route is being called
1437
-     * @return    string
1438
-     */
1439
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1440
-    {
1441
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1442
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1443
-            return apply_filters(
1444
-                'FHEE__EE_Config__get_view',
1445
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1446
-                $route,
1447
-                $status
1448
-            );
1449
-        }
1450
-        return null;
1451
-    }
1452
-
1453
-
1454
-    public function update_addon_option_names()
1455
-    {
1456
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1457
-    }
1458
-
1459
-
1460
-    public function shutdown()
1461
-    {
1462
-        $this->update_addon_option_names();
1463
-    }
1464
-
1465
-
1466
-    /**
1467
-     * @return LegacyShortcodesManager
1468
-     */
1469
-    public static function getLegacyShortcodesManager()
1470
-    {
1471
-
1472
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1473
-            EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1474
-                EE_Registry::instance()
1475
-            );
1476
-        }
1477
-        return EE_Config::instance()->legacy_shortcodes_manager;
1478
-    }
1479
-
1480
-
1481
-    /**
1482
-     * register_shortcode - makes core aware of this shortcode
1483
-     *
1484
-     * @deprecated 4.9.26
1485
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1486
-     * @return    bool
1487
-     */
1488
-    public static function register_shortcode($shortcode_path = null)
1489
-    {
1490
-        EE_Error::doing_it_wrong(
1491
-            __METHOD__,
1492
-            __(
1493
-                '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.',
1494
-                'event_espresso'
1495
-            ),
1496
-            '4.9.26'
1497
-        );
1498
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1499
-    }
1500
-}
1501
-
1502
-/**
1503
- * Base class used for config classes. These classes should generally not have
1504
- * magic functions in use, except we'll allow them to magically set and get stuff...
1505
- * basically, they should just be well-defined stdClasses
1506
- */
1507
-class EE_Config_Base
1508
-{
1509
-
1510
-    /**
1511
-     * Utility function for escaping the value of a property and returning.
1512
-     *
1513
-     * @param string $property property name (checks to see if exists).
1514
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1515
-     * @throws \EE_Error
1516
-     */
1517
-    public function get_pretty($property)
1518
-    {
1519
-        if (! property_exists($this, $property)) {
1520
-            throw new EE_Error(
1521
-                sprintf(
1522
-                    __(
1523
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1524
-                        'event_espresso'
1525
-                    ),
1526
-                    get_class($this),
1527
-                    $property
1528
-                )
1529
-            );
1530
-        }
1531
-        // just handling escaping of strings for now.
1532
-        if (is_string($this->{$property})) {
1533
-            return stripslashes($this->{$property});
1534
-        }
1535
-        return $this->{$property};
1536
-    }
1537
-
1538
-
1539
-    public function populate()
1540
-    {
1541
-        // grab defaults via a new instance of this class.
1542
-        $class_name = get_class($this);
1543
-        $defaults = new $class_name;
1544
-        // loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1545
-        // default from our $defaults object.
1546
-        foreach (get_object_vars($defaults) as $property => $value) {
1547
-            if ($this->{$property} === null) {
1548
-                $this->{$property} = $value;
1549
-            }
1550
-        }
1551
-        // cleanup
1552
-        unset($defaults);
1553
-    }
1554
-
1555
-
1556
-    /**
1557
-     *        __isset
1558
-     *
1559
-     * @param $a
1560
-     * @return bool
1561
-     */
1562
-    public function __isset($a)
1563
-    {
1564
-        return false;
1565
-    }
1566
-
1567
-
1568
-    /**
1569
-     *        __unset
1570
-     *
1571
-     * @param $a
1572
-     * @return bool
1573
-     */
1574
-    public function __unset($a)
1575
-    {
1576
-        return false;
1577
-    }
1578
-
1579
-
1580
-    /**
1581
-     *        __clone
1582
-     */
1583
-    public function __clone()
1584
-    {
1585
-    }
1586
-
1587
-
1588
-    /**
1589
-     *        __wakeup
1590
-     */
1591
-    public function __wakeup()
1592
-    {
1593
-    }
1594
-
1595
-
1596
-    /**
1597
-     *        __destruct
1598
-     */
1599
-    public function __destruct()
1600
-    {
1601
-    }
1602
-}
1603
-
1604
-/**
1605
- * Class for defining what's in the EE_Config relating to registration settings
1606
- */
1607
-class EE_Core_Config extends EE_Config_Base
1608
-{
1609
-
1610
-    const OPTION_NAME_UXIP = 'ee_ueip_optin';
1611
-
1612
-
1613
-    public $current_blog_id;
1614
-
1615
-    public $ee_ueip_optin;
1616
-
1617
-    public $ee_ueip_has_notified;
1618
-
1619
-    /**
1620
-     * Not to be confused with the 4 critical page variables (See
1621
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1622
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1623
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1624
-     *
1625
-     * @var array
1626
-     */
1627
-    public $post_shortcodes;
1628
-
1629
-    public $module_route_map;
1630
-
1631
-    public $module_forward_map;
1632
-
1633
-    public $module_view_map;
1634
-
1635
-    /**
1636
-     * The next 4 vars are the IDs of critical EE pages.
1637
-     *
1638
-     * @var int
1639
-     */
1640
-    public $reg_page_id;
1641
-
1642
-    public $txn_page_id;
1643
-
1644
-    public $thank_you_page_id;
1645
-
1646
-    public $cancel_page_id;
1647
-
1648
-    /**
1649
-     * The next 4 vars are the URLs of critical EE pages.
1650
-     *
1651
-     * @var int
1652
-     */
1653
-    public $reg_page_url;
1654
-
1655
-    public $txn_page_url;
1656
-
1657
-    public $thank_you_page_url;
1658
-
1659
-    public $cancel_page_url;
1660
-
1661
-    /**
1662
-     * The next vars relate to the custom slugs for EE CPT routes
1663
-     */
1664
-    public $event_cpt_slug;
1665
-
1666
-    /**
1667
-     * This caches the _ee_ueip_option in case this config is reset in the same
1668
-     * request across blog switches in a multisite context.
1669
-     * Avoids extra queries to the db for this option.
1670
-     *
1671
-     * @var bool
1672
-     */
1673
-    public static $ee_ueip_option;
1674
-
1675
-
1676
-    /**
1677
-     *    class constructor
1678
-     *
1679
-     * @access    public
1680
-     */
1681
-    public function __construct()
1682
-    {
1683
-        // set default organization settings
1684
-        $this->current_blog_id = get_current_blog_id();
1685
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1686
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1687
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1688
-        $this->post_shortcodes = array();
1689
-        $this->module_route_map = array();
1690
-        $this->module_forward_map = array();
1691
-        $this->module_view_map = array();
1692
-        // critical EE page IDs
1693
-        $this->reg_page_id = 0;
1694
-        $this->txn_page_id = 0;
1695
-        $this->thank_you_page_id = 0;
1696
-        $this->cancel_page_id = 0;
1697
-        // critical EE page URLs
1698
-        $this->reg_page_url = '';
1699
-        $this->txn_page_url = '';
1700
-        $this->thank_you_page_url = '';
1701
-        $this->cancel_page_url = '';
1702
-        // cpt slugs
1703
-        $this->event_cpt_slug = __('events', 'event_espresso');
1704
-        // ueip constant check
1705
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1706
-            $this->ee_ueip_optin = false;
1707
-            $this->ee_ueip_has_notified = true;
1708
-        }
1709
-    }
1710
-
1711
-
1712
-    /**
1713
-     * @return array
1714
-     */
1715
-    public function get_critical_pages_array()
1716
-    {
1717
-        return array(
1718
-            $this->reg_page_id,
1719
-            $this->txn_page_id,
1720
-            $this->thank_you_page_id,
1721
-            $this->cancel_page_id,
1722
-        );
1723
-    }
1724
-
1725
-
1726
-    /**
1727
-     * @return array
1728
-     */
1729
-    public function get_critical_pages_shortcodes_array()
1730
-    {
1731
-        return array(
1732
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1733
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1734
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1735
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1736
-        );
1737
-    }
1738
-
1739
-
1740
-    /**
1741
-     *  gets/returns URL for EE reg_page
1742
-     *
1743
-     * @access    public
1744
-     * @return    string
1745
-     */
1746
-    public function reg_page_url()
1747
-    {
1748
-        if (! $this->reg_page_url) {
1749
-            $this->reg_page_url = add_query_arg(
1750
-                array('uts' => time()),
1751
-                get_permalink($this->reg_page_id)
1752
-            ) . '#checkout';
1753
-        }
1754
-        return $this->reg_page_url;
1755
-    }
1756
-
1757
-
1758
-    /**
1759
-     *  gets/returns URL for EE txn_page
1760
-     *
1761
-     * @param array $query_args like what gets passed to
1762
-     *                          add_query_arg() as the first argument
1763
-     * @access    public
1764
-     * @return    string
1765
-     */
1766
-    public function txn_page_url($query_args = array())
1767
-    {
1768
-        if (! $this->txn_page_url) {
1769
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1770
-        }
1771
-        if ($query_args) {
1772
-            return add_query_arg($query_args, $this->txn_page_url);
1773
-        } else {
1774
-            return $this->txn_page_url;
1775
-        }
1776
-    }
1777
-
1778
-
1779
-    /**
1780
-     *  gets/returns URL for EE thank_you_page
1781
-     *
1782
-     * @param array $query_args like what gets passed to
1783
-     *                          add_query_arg() as the first argument
1784
-     * @access    public
1785
-     * @return    string
1786
-     */
1787
-    public function thank_you_page_url($query_args = array())
1788
-    {
1789
-        if (! $this->thank_you_page_url) {
1790
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1791
-        }
1792
-        if ($query_args) {
1793
-            return add_query_arg($query_args, $this->thank_you_page_url);
1794
-        } else {
1795
-            return $this->thank_you_page_url;
1796
-        }
1797
-    }
1798
-
1799
-
1800
-    /**
1801
-     *  gets/returns URL for EE cancel_page
1802
-     *
1803
-     * @access    public
1804
-     * @return    string
1805
-     */
1806
-    public function cancel_page_url()
1807
-    {
1808
-        if (! $this->cancel_page_url) {
1809
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1810
-        }
1811
-        return $this->cancel_page_url;
1812
-    }
1813
-
1814
-
1815
-    /**
1816
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1817
-     *
1818
-     * @since 4.7.5
1819
-     */
1820
-    protected function _reset_urls()
1821
-    {
1822
-        $this->reg_page_url = '';
1823
-        $this->txn_page_url = '';
1824
-        $this->cancel_page_url = '';
1825
-        $this->thank_you_page_url = '';
1826
-    }
1827
-
1828
-
1829
-    /**
1830
-     * Used to return what the optin value is set for the EE User Experience Program.
1831
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1832
-     * on the main site only.
1833
-     *
1834
-     * @return bool
1835
-     */
1836
-    protected function _get_main_ee_ueip_optin()
1837
-    {
1838
-        // if this is the main site then we can just bypass our direct query.
1839
-        if (is_main_site()) {
1840
-            return get_option(self::OPTION_NAME_UXIP, false);
1841
-        }
1842
-        // is this already cached for this request?  If so use it.
1843
-        if (EE_Core_Config::$ee_ueip_option !== null) {
1844
-            return EE_Core_Config::$ee_ueip_option;
1845
-        }
1846
-        global $wpdb;
1847
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1848
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1849
-        $option = self::OPTION_NAME_UXIP;
1850
-        // set correct table for query
1851
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1852
-        // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1853
-        // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1854
-        // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1855
-        // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1856
-        // for the purpose of caching.
1857
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1858
-        if (false !== $pre) {
1859
-            EE_Core_Config::$ee_ueip_option = $pre;
1860
-            return EE_Core_Config::$ee_ueip_option;
1861
-        }
1862
-        $row = $wpdb->get_row(
1863
-            $wpdb->prepare(
1864
-                "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1865
-                $option
1866
-            )
1867
-        );
1868
-        if (is_object($row)) {
1869
-            $value = $row->option_value;
1870
-        } else { // option does not exist so use default.
1871
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1872
-            return EE_Core_Config::$ee_ueip_option;
1873
-        }
1874
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1875
-        return EE_Core_Config::$ee_ueip_option;
1876
-    }
1877
-
1878
-
1879
-    /**
1880
-     * Utility function for escaping the value of a property and returning.
1881
-     *
1882
-     * @param string $property property name (checks to see if exists).
1883
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1884
-     * @throws \EE_Error
1885
-     */
1886
-    public function get_pretty($property)
1887
-    {
1888
-        if ($property === self::OPTION_NAME_UXIP) {
1889
-            return $this->ee_ueip_optin ? 'yes' : 'no';
1890
-        }
1891
-        return parent::get_pretty($property);
1892
-    }
1893
-
1894
-
1895
-    /**
1896
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1897
-     * on the object.
1898
-     *
1899
-     * @return array
1900
-     */
1901
-    public function __sleep()
1902
-    {
1903
-        // reset all url properties
1904
-        $this->_reset_urls();
1905
-        // return what to save to db
1906
-        return array_keys(get_object_vars($this));
1907
-    }
1908
-}
1909
-
1910
-/**
1911
- * Config class for storing info on the Organization
1912
- */
1913
-class EE_Organization_Config extends EE_Config_Base
1914
-{
1915
-
1916
-    /**
1917
-     * @var string $name
1918
-     * eg EE4.1
1919
-     */
1920
-    public $name;
1921
-
1922
-    /**
1923
-     * @var string $address_1
1924
-     * eg 123 Onna Road
1925
-     */
1926
-    public $address_1;
1927
-
1928
-    /**
1929
-     * @var string $address_2
1930
-     * eg PO Box 123
1931
-     */
1932
-    public $address_2;
1933
-
1934
-    /**
1935
-     * @var string $city
1936
-     * eg Inna City
1937
-     */
1938
-    public $city;
1939
-
1940
-    /**
1941
-     * @var int $STA_ID
1942
-     * eg 4
1943
-     */
1944
-    public $STA_ID;
1945
-
1946
-    /**
1947
-     * @var string $CNT_ISO
1948
-     * eg US
1949
-     */
1950
-    public $CNT_ISO;
1951
-
1952
-    /**
1953
-     * @var string $zip
1954
-     * eg 12345  or V1A 2B3
1955
-     */
1956
-    public $zip;
1957
-
1958
-    /**
1959
-     * @var string $email
1960
-     * eg [email protected]
1961
-     */
1962
-    public $email;
1963
-
1964
-    /**
1965
-     * @var string $phone
1966
-     * eg. 111-111-1111
1967
-     */
1968
-    public $phone;
1969
-
1970
-    /**
1971
-     * @var string $vat
1972
-     * VAT/Tax Number
1973
-     */
1974
-    public $vat;
1975
-
1976
-    /**
1977
-     * @var string $logo_url
1978
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1979
-     */
1980
-    public $logo_url;
1981
-
1982
-    /**
1983
-     * The below are all various properties for holding links to organization social network profiles
1984
-     *
1985
-     * @var string
1986
-     */
1987
-    /**
1988
-     * facebook (facebook.com/profile.name)
1989
-     *
1990
-     * @var string
1991
-     */
1992
-    public $facebook;
1993
-
1994
-    /**
1995
-     * twitter (twitter.com/twitter_handle)
1996
-     *
1997
-     * @var string
1998
-     */
1999
-    public $twitter;
2000
-
2001
-    /**
2002
-     * linkedin (linkedin.com/in/profile_name)
2003
-     *
2004
-     * @var string
2005
-     */
2006
-    public $linkedin;
2007
-
2008
-    /**
2009
-     * pinterest (www.pinterest.com/profile_name)
2010
-     *
2011
-     * @var string
2012
-     */
2013
-    public $pinterest;
2014
-
2015
-    /**
2016
-     * google+ (google.com/+profileName)
2017
-     *
2018
-     * @var string
2019
-     */
2020
-    public $google;
2021
-
2022
-    /**
2023
-     * instagram (instagram.com/handle)
2024
-     *
2025
-     * @var string
2026
-     */
2027
-    public $instagram;
2028
-
2029
-
2030
-    /**
2031
-     *    class constructor
2032
-     *
2033
-     * @access    public
2034
-     */
2035
-    public function __construct()
2036
-    {
2037
-        // set default organization settings
2038
-        // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2039
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2040
-        $this->address_1 = '123 Onna Road';
2041
-        $this->address_2 = 'PO Box 123';
2042
-        $this->city = 'Inna City';
2043
-        $this->STA_ID = 4;
2044
-        $this->CNT_ISO = 'US';
2045
-        $this->zip = '12345';
2046
-        $this->email = get_bloginfo('admin_email');
2047
-        $this->phone = '';
2048
-        $this->vat = '123456789';
2049
-        $this->logo_url = '';
2050
-        $this->facebook = '';
2051
-        $this->twitter = '';
2052
-        $this->linkedin = '';
2053
-        $this->pinterest = '';
2054
-        $this->google = '';
2055
-        $this->instagram = '';
2056
-    }
2057
-}
2058
-
2059
-/**
2060
- * Class for defining what's in the EE_Config relating to currency
2061
- */
2062
-class EE_Currency_Config extends EE_Config_Base
2063
-{
2064
-
2065
-    /**
2066
-     * @var string $code
2067
-     * eg 'US'
2068
-     */
2069
-    public $code;
2070
-
2071
-    /**
2072
-     * @var string $name
2073
-     * eg 'Dollar'
2074
-     */
2075
-    public $name;
2076
-
2077
-    /**
2078
-     * plural name
2079
-     *
2080
-     * @var string $plural
2081
-     * eg 'Dollars'
2082
-     */
2083
-    public $plural;
2084
-
2085
-    /**
2086
-     * currency sign
2087
-     *
2088
-     * @var string $sign
2089
-     * eg '$'
2090
-     */
2091
-    public $sign;
2092
-
2093
-    /**
2094
-     * Whether the currency sign should come before the number or not
2095
-     *
2096
-     * @var boolean $sign_b4
2097
-     */
2098
-    public $sign_b4;
2099
-
2100
-    /**
2101
-     * How many digits should come after the decimal place
2102
-     *
2103
-     * @var int $dec_plc
2104
-     */
2105
-    public $dec_plc;
2106
-
2107
-    /**
2108
-     * Symbol to use for decimal mark
2109
-     *
2110
-     * @var string $dec_mrk
2111
-     * eg '.'
2112
-     */
2113
-    public $dec_mrk;
2114
-
2115
-    /**
2116
-     * Symbol to use for thousands
2117
-     *
2118
-     * @var string $thsnds
2119
-     * eg ','
2120
-     */
2121
-    public $thsnds;
2122
-
2123
-
2124
-    /**
2125
-     *    class constructor
2126
-     *
2127
-     * @access    public
2128
-     * @param string $CNT_ISO
2129
-     * @throws \EE_Error
2130
-     */
2131
-    public function __construct($CNT_ISO = '')
2132
-    {
2133
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2134
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2135
-        // get country code from organization settings or use default
2136
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2137
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2138
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2139
-            : '';
2140
-        // but override if requested
2141
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2142
-        // 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
2143
-        if (! empty($CNT_ISO)
2144
-            && EE_Maintenance_Mode::instance()->models_can_query()
2145
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2146
-        ) {
2147
-            // retrieve the country settings from the db, just in case they have been customized
2148
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2149
-            if ($country instanceof EE_Country) {
2150
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2151
-                $this->name = $country->currency_name_single();    // Dollar
2152
-                $this->plural = $country->currency_name_plural();    // Dollars
2153
-                $this->sign = $country->currency_sign();            // currency sign: $
2154
-                $this->sign_b4 = $country->currency_sign_before(
2155
-                );        // currency sign before or after: $TRUE  or  FALSE$
2156
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2157
-                $this->dec_mrk = $country->currency_decimal_mark(
2158
-                );    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2159
-                $this->thsnds = $country->currency_thousands_separator(
2160
-                );    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2161
-            }
2162
-        }
2163
-        // fallback to hardcoded defaults, in case the above failed
2164
-        if (empty($this->code)) {
2165
-            // set default currency settings
2166
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2167
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2168
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2169
-            $this->sign = '$';    // currency sign: $
2170
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2171
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2172
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2173
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2174
-        }
2175
-    }
2176
-}
2177
-
2178
-/**
2179
- * Class for defining what's in the EE_Config relating to registration settings
2180
- */
2181
-class EE_Registration_Config extends EE_Config_Base
2182
-{
2183
-
2184
-    /**
2185
-     * Default registration status
2186
-     *
2187
-     * @var string $default_STS_ID
2188
-     * eg 'RPP'
2189
-     */
2190
-    public $default_STS_ID;
2191
-
2192
-    /**
2193
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2194
-     * registrations)
2195
-     *
2196
-     * @var int
2197
-     */
2198
-    public $default_maximum_number_of_tickets;
2199
-
2200
-    /**
2201
-     * level of validation to apply to email addresses
2202
-     *
2203
-     * @var string $email_validation_level
2204
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2205
-     */
2206
-    public $email_validation_level;
2207
-
2208
-    /**
2209
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2210
-     *
2211
-     * @var boolean $show_pending_payment_options
2212
-     */
2213
-    public $show_pending_payment_options;
2214
-
2215
-    /**
2216
-     * Whether to skip the registration confirmation page
2217
-     *
2218
-     * @var boolean $skip_reg_confirmation
2219
-     */
2220
-    public $skip_reg_confirmation;
2221
-
2222
-    /**
2223
-     * an array of SPCO reg steps where:
2224
-     *        the keys denotes the reg step order
2225
-     *        each element consists of an array with the following elements:
2226
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2227
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2228
-     *            "slug" => the URL param used to trigger the reg step
2229
-     *
2230
-     * @var array $reg_steps
2231
-     */
2232
-    public $reg_steps;
2233
-
2234
-    /**
2235
-     * Whether registration confirmation should be the last page of SPCO
2236
-     *
2237
-     * @var boolean $reg_confirmation_last
2238
-     */
2239
-    public $reg_confirmation_last;
2240
-
2241
-    /**
2242
-     * Whether or not to enable the EE Bot Trap
2243
-     *
2244
-     * @var boolean $use_bot_trap
2245
-     */
2246
-    public $use_bot_trap;
2247
-
2248
-    /**
2249
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2250
-     *
2251
-     * @var boolean $use_encryption
2252
-     */
2253
-    public $use_encryption;
2254
-
2255
-    /**
2256
-     * Whether or not to use ReCaptcha
2257
-     *
2258
-     * @var boolean $use_captcha
2259
-     */
2260
-    public $use_captcha;
2261
-
2262
-    /**
2263
-     * ReCaptcha Theme
2264
-     *
2265
-     * @var string $recaptcha_theme
2266
-     *    options: 'dark', 'light', 'invisible'
2267
-     */
2268
-    public $recaptcha_theme;
2269
-
2270
-    /**
2271
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2272
-     *
2273
-     * @var string $recaptcha_badge
2274
-     *    options: 'bottomright', 'bottomleft', 'inline'
2275
-     */
2276
-    public $recaptcha_badge;
17
+	const OPTION_NAME = 'ee_config';
18
+
19
+	const LOG_NAME = 'ee_config_log';
20
+
21
+	const LOG_LENGTH = 100;
22
+
23
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
24
+
25
+	/**
26
+	 *    instance of the EE_Config object
27
+	 *
28
+	 * @var    EE_Config $_instance
29
+	 * @access    private
30
+	 */
31
+	private static $_instance;
32
+
33
+	/**
34
+	 * @var boolean $_logging_enabled
35
+	 */
36
+	private static $_logging_enabled = false;
37
+
38
+	/**
39
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
40
+	 */
41
+	private $legacy_shortcodes_manager;
42
+
43
+	/**
44
+	 * An StdClass whose property names are addon slugs,
45
+	 * and values are their config classes
46
+	 *
47
+	 * @var StdClass
48
+	 */
49
+	public $addons;
50
+
51
+	/**
52
+	 * @var EE_Admin_Config
53
+	 */
54
+	public $admin;
55
+
56
+	/**
57
+	 * @var EE_Core_Config
58
+	 */
59
+	public $core;
60
+
61
+	/**
62
+	 * @var EE_Currency_Config
63
+	 */
64
+	public $currency;
65
+
66
+	/**
67
+	 * @var EE_Organization_Config
68
+	 */
69
+	public $organization;
70
+
71
+	/**
72
+	 * @var EE_Registration_Config
73
+	 */
74
+	public $registration;
75
+
76
+	/**
77
+	 * @var EE_Template_Config
78
+	 */
79
+	public $template_settings;
80
+
81
+	/**
82
+	 * Holds EE environment values.
83
+	 *
84
+	 * @var EE_Environment_Config
85
+	 */
86
+	public $environment;
87
+
88
+	/**
89
+	 * settings pertaining to Google maps
90
+	 *
91
+	 * @var EE_Map_Config
92
+	 */
93
+	public $map_settings;
94
+
95
+	/**
96
+	 * settings pertaining to Taxes
97
+	 *
98
+	 * @var EE_Tax_Config
99
+	 */
100
+	public $tax_settings;
101
+
102
+	/**
103
+	 * Settings pertaining to global messages settings.
104
+	 *
105
+	 * @var EE_Messages_Config
106
+	 */
107
+	public $messages;
108
+
109
+	/**
110
+	 * @deprecated
111
+	 * @var EE_Gateway_Config
112
+	 */
113
+	public $gateway;
114
+
115
+	/**
116
+	 * @var    array $_addon_option_names
117
+	 * @access    private
118
+	 */
119
+	private $_addon_option_names = array();
120
+
121
+	/**
122
+	 * @var    array $_module_route_map
123
+	 * @access    private
124
+	 */
125
+	private static $_module_route_map = array();
126
+
127
+	/**
128
+	 * @var    array $_module_forward_map
129
+	 * @access    private
130
+	 */
131
+	private static $_module_forward_map = array();
132
+
133
+	/**
134
+	 * @var    array $_module_view_map
135
+	 * @access    private
136
+	 */
137
+	private static $_module_view_map = array();
138
+
139
+
140
+	/**
141
+	 * @singleton method used to instantiate class object
142
+	 * @access    public
143
+	 * @return EE_Config instance
144
+	 */
145
+	public static function instance()
146
+	{
147
+		// check if class object is instantiated, and instantiated properly
148
+		if (! self::$_instance instanceof EE_Config) {
149
+			self::$_instance = new self();
150
+		}
151
+		return self::$_instance;
152
+	}
153
+
154
+
155
+	/**
156
+	 * Resets the config
157
+	 *
158
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
159
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
160
+	 *                               reflect its state in the database
161
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
162
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
163
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
164
+	 *                               site was put into maintenance mode)
165
+	 * @return EE_Config
166
+	 */
167
+	public static function reset($hard_reset = false, $reinstantiate = true)
168
+	{
169
+		if (self::$_instance instanceof EE_Config) {
170
+			if ($hard_reset) {
171
+				self::$_instance->legacy_shortcodes_manager = null;
172
+				self::$_instance->_addon_option_names = array();
173
+				self::$_instance->_initialize_config();
174
+				self::$_instance->update_espresso_config();
175
+			}
176
+			self::$_instance->update_addon_option_names();
177
+		}
178
+		self::$_instance = null;
179
+		// we don't need to reset the static properties imo because those should
180
+		// only change when a module is added or removed. Currently we don't
181
+		// support removing a module during a request when it previously existed
182
+		if ($reinstantiate) {
183
+			return self::instance();
184
+		} else {
185
+			return null;
186
+		}
187
+	}
188
+
189
+
190
+	/**
191
+	 *    class constructor
192
+	 *
193
+	 * @access    private
194
+	 */
195
+	private function __construct()
196
+	{
197
+		do_action('AHEE__EE_Config__construct__begin', $this);
198
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
199
+		// setup empty config classes
200
+		$this->_initialize_config();
201
+		// load existing EE site settings
202
+		$this->_load_core_config();
203
+		// confirm everything loaded correctly and set filtered defaults if not
204
+		$this->_verify_config();
205
+		//  register shortcodes and modules
206
+		add_action(
207
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
208
+			array($this, 'register_shortcodes_and_modules'),
209
+			999
210
+		);
211
+		//  initialize shortcodes and modules
212
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
213
+		// register widgets
214
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
215
+		// shutdown
216
+		add_action('shutdown', array($this, 'shutdown'), 10);
217
+		// construct__end hook
218
+		do_action('AHEE__EE_Config__construct__end', $this);
219
+		// hardcoded hack
220
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
221
+	}
222
+
223
+
224
+	/**
225
+	 * @return boolean
226
+	 */
227
+	public static function logging_enabled()
228
+	{
229
+		return self::$_logging_enabled;
230
+	}
231
+
232
+
233
+	/**
234
+	 * use to get the current theme if needed from static context
235
+	 *
236
+	 * @return string current theme set.
237
+	 */
238
+	public static function get_current_theme()
239
+	{
240
+		return isset(self::$_instance->template_settings->current_espresso_theme)
241
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
242
+	}
243
+
244
+
245
+	/**
246
+	 *        _initialize_config
247
+	 *
248
+	 * @access private
249
+	 * @return void
250
+	 */
251
+	private function _initialize_config()
252
+	{
253
+		EE_Config::trim_log();
254
+		// set defaults
255
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
256
+		$this->addons = new stdClass();
257
+		// set _module_route_map
258
+		EE_Config::$_module_route_map = array();
259
+		// set _module_forward_map
260
+		EE_Config::$_module_forward_map = array();
261
+		// set _module_view_map
262
+		EE_Config::$_module_view_map = array();
263
+	}
264
+
265
+
266
+	/**
267
+	 *        load core plugin configuration
268
+	 *
269
+	 * @access private
270
+	 * @return void
271
+	 */
272
+	private function _load_core_config()
273
+	{
274
+		// load_core_config__start hook
275
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
276
+		$espresso_config = $this->get_espresso_config();
277
+		foreach ($espresso_config as $config => $settings) {
278
+			// load_core_config__start hook
279
+			$settings = apply_filters(
280
+				'FHEE__EE_Config___load_core_config__config_settings',
281
+				$settings,
282
+				$config,
283
+				$this
284
+			);
285
+			if (is_object($settings) && property_exists($this, $config)) {
286
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
287
+				// call configs populate method to ensure any defaults are set for empty values.
288
+				if (method_exists($settings, 'populate')) {
289
+					$this->{$config}->populate();
290
+				}
291
+				if (method_exists($settings, 'do_hooks')) {
292
+					$this->{$config}->do_hooks();
293
+				}
294
+			}
295
+		}
296
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
297
+			$this->update_espresso_config();
298
+		}
299
+		// load_core_config__end hook
300
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
301
+	}
302
+
303
+
304
+	/**
305
+	 *    _verify_config
306
+	 *
307
+	 * @access    protected
308
+	 * @return    void
309
+	 */
310
+	protected function _verify_config()
311
+	{
312
+		$this->core = $this->core instanceof EE_Core_Config
313
+			? $this->core
314
+			: new EE_Core_Config();
315
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
316
+		$this->organization = $this->organization instanceof EE_Organization_Config
317
+			? $this->organization
318
+			: new EE_Organization_Config();
319
+		$this->organization = apply_filters(
320
+			'FHEE__EE_Config___initialize_config__organization',
321
+			$this->organization
322
+		);
323
+		$this->currency = $this->currency instanceof EE_Currency_Config
324
+			? $this->currency
325
+			: new EE_Currency_Config();
326
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
327
+		$this->registration = $this->registration instanceof EE_Registration_Config
328
+			? $this->registration
329
+			: new EE_Registration_Config();
330
+		$this->registration = apply_filters(
331
+			'FHEE__EE_Config___initialize_config__registration',
332
+			$this->registration
333
+		);
334
+		$this->admin = $this->admin instanceof EE_Admin_Config
335
+			? $this->admin
336
+			: new EE_Admin_Config();
337
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
338
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
339
+			? $this->template_settings
340
+			: new EE_Template_Config();
341
+		$this->template_settings = apply_filters(
342
+			'FHEE__EE_Config___initialize_config__template_settings',
343
+			$this->template_settings
344
+		);
345
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
346
+			? $this->map_settings
347
+			: new EE_Map_Config();
348
+		$this->map_settings = apply_filters(
349
+			'FHEE__EE_Config___initialize_config__map_settings',
350
+			$this->map_settings
351
+		);
352
+		$this->environment = $this->environment instanceof EE_Environment_Config
353
+			? $this->environment
354
+			: new EE_Environment_Config();
355
+		$this->environment = apply_filters(
356
+			'FHEE__EE_Config___initialize_config__environment',
357
+			$this->environment
358
+		);
359
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
360
+			? $this->tax_settings
361
+			: new EE_Tax_Config();
362
+		$this->tax_settings = apply_filters(
363
+			'FHEE__EE_Config___initialize_config__tax_settings',
364
+			$this->tax_settings
365
+		);
366
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
367
+		$this->messages = $this->messages instanceof EE_Messages_Config
368
+			? $this->messages
369
+			: new EE_Messages_Config();
370
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
371
+			? $this->gateway
372
+			: new EE_Gateway_Config();
373
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
374
+		$this->legacy_shortcodes_manager = null;
375
+	}
376
+
377
+
378
+	/**
379
+	 *    get_espresso_config
380
+	 *
381
+	 * @access    public
382
+	 * @return    array of espresso config stuff
383
+	 */
384
+	public function get_espresso_config()
385
+	{
386
+		// grab espresso configuration
387
+		return apply_filters(
388
+			'FHEE__EE_Config__get_espresso_config__CFG',
389
+			get_option(EE_Config::OPTION_NAME, array())
390
+		);
391
+	}
392
+
393
+
394
+	/**
395
+	 *    double_check_config_comparison
396
+	 *
397
+	 * @access    public
398
+	 * @param string $option
399
+	 * @param        $old_value
400
+	 * @param        $value
401
+	 */
402
+	public function double_check_config_comparison($option = '', $old_value, $value)
403
+	{
404
+		// make sure we're checking the ee config
405
+		if ($option === EE_Config::OPTION_NAME) {
406
+			// run a loose comparison of the old value against the new value for type and properties,
407
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
408
+			if ($value != $old_value) {
409
+				// if they are NOT the same, then remove the hook,
410
+				// which means the subsequent update results will be based solely on the update query results
411
+				// the reason we do this is because, as stated above,
412
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
413
+				// this happens PRIOR to serialization and any subsequent update.
414
+				// If values are found to match their previous old value,
415
+				// then WP bails before performing any update.
416
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
417
+				// it just pulled from the db, with the one being passed to it (which will not match).
418
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
419
+				// MySQL MAY ALSO NOT perform the update because
420
+				// the string it sees in the db looks the same as the new one it has been passed!!!
421
+				// This results in the query returning an "affected rows" value of ZERO,
422
+				// which gets returned immediately by WP update_option and looks like an error.
423
+				remove_action('update_option', array($this, 'check_config_updated'));
424
+			}
425
+		}
426
+	}
427
+
428
+
429
+	/**
430
+	 *    update_espresso_config
431
+	 *
432
+	 * @access   public
433
+	 */
434
+	protected function _reset_espresso_addon_config()
435
+	{
436
+		$this->_addon_option_names = array();
437
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
438
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
439
+			if ($addon_config_obj instanceof EE_Config_Base) {
440
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
441
+			}
442
+			$this->addons->{$addon_name} = null;
443
+		}
444
+	}
445
+
446
+
447
+	/**
448
+	 *    update_espresso_config
449
+	 *
450
+	 * @access   public
451
+	 * @param   bool $add_success
452
+	 * @param   bool $add_error
453
+	 * @return   bool
454
+	 */
455
+	public function update_espresso_config($add_success = false, $add_error = true)
456
+	{
457
+		// don't allow config updates during WP heartbeats
458
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
459
+			return false;
460
+		}
461
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
462
+		// $clone = clone( self::$_instance );
463
+		// self::$_instance = NULL;
464
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
465
+		$this->_reset_espresso_addon_config();
466
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
467
+		// but BEFORE the actual update occurs
468
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
469
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
470
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
471
+		$this->legacy_shortcodes_manager = null;
472
+		// now update "ee_config"
473
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
474
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
475
+		EE_Config::log(EE_Config::OPTION_NAME);
476
+		// if not saved... check if the hook we just added still exists;
477
+		// if it does, it means one of two things:
478
+		// that update_option bailed at the($value === $old_value) conditional,
479
+		// or...
480
+		// the db update query returned 0 rows affected
481
+		// (probably because the data  value was the same from it's perspective)
482
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
483
+		// but just means no update occurred, so don't display an error to the user.
484
+		// BUT... if update_option returns FALSE, AND the hook is missing,
485
+		// then it means that something truly went wrong
486
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
487
+		// remove our action since we don't want it in the system anymore
488
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
489
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
490
+		// self::$_instance = $clone;
491
+		// unset( $clone );
492
+		// if config remains the same or was updated successfully
493
+		if ($saved) {
494
+			if ($add_success) {
495
+				EE_Error::add_success(
496
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
497
+					__FILE__,
498
+					__FUNCTION__,
499
+					__LINE__
500
+				);
501
+			}
502
+			return true;
503
+		} else {
504
+			if ($add_error) {
505
+				EE_Error::add_error(
506
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
507
+					__FILE__,
508
+					__FUNCTION__,
509
+					__LINE__
510
+				);
511
+			}
512
+			return false;
513
+		}
514
+	}
515
+
516
+
517
+	/**
518
+	 *    _verify_config_params
519
+	 *
520
+	 * @access    private
521
+	 * @param    string         $section
522
+	 * @param    string         $name
523
+	 * @param    string         $config_class
524
+	 * @param    EE_Config_Base $config_obj
525
+	 * @param    array          $tests_to_run
526
+	 * @param    bool           $display_errors
527
+	 * @return    bool    TRUE on success, FALSE on fail
528
+	 */
529
+	private function _verify_config_params(
530
+		$section = '',
531
+		$name = '',
532
+		$config_class = '',
533
+		$config_obj = null,
534
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
535
+		$display_errors = true
536
+	) {
537
+		try {
538
+			foreach ($tests_to_run as $test) {
539
+				switch ($test) {
540
+					// TEST #1 : check that section was set
541
+					case 1:
542
+						if (empty($section)) {
543
+							if ($display_errors) {
544
+								throw new EE_Error(
545
+									sprintf(
546
+										__(
547
+											'No configuration section has been provided while attempting to save "%s".',
548
+											'event_espresso'
549
+										),
550
+										$config_class
551
+									)
552
+								);
553
+							}
554
+							return false;
555
+						}
556
+						break;
557
+					// TEST #2 : check that settings section exists
558
+					case 2:
559
+						if (! isset($this->{$section})) {
560
+							if ($display_errors) {
561
+								throw new EE_Error(
562
+									sprintf(
563
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
564
+										$section
565
+									)
566
+								);
567
+							}
568
+							return false;
569
+						}
570
+						break;
571
+					// TEST #3 : check that section is the proper format
572
+					case 3:
573
+						if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
574
+						) {
575
+							if ($display_errors) {
576
+								throw new EE_Error(
577
+									sprintf(
578
+										__(
579
+											'The "%s" configuration settings have not been formatted correctly.',
580
+											'event_espresso'
581
+										),
582
+										$section
583
+									)
584
+								);
585
+							}
586
+							return false;
587
+						}
588
+						break;
589
+					// TEST #4 : check that config section name has been set
590
+					case 4:
591
+						if (empty($name)) {
592
+							if ($display_errors) {
593
+								throw new EE_Error(
594
+									__(
595
+										'No name has been provided for the specific configuration section.',
596
+										'event_espresso'
597
+									)
598
+								);
599
+							}
600
+							return false;
601
+						}
602
+						break;
603
+					// TEST #5 : check that a config class name has been set
604
+					case 5:
605
+						if (empty($config_class)) {
606
+							if ($display_errors) {
607
+								throw new EE_Error(
608
+									__(
609
+										'No class name has been provided for the specific configuration section.',
610
+										'event_espresso'
611
+									)
612
+								);
613
+							}
614
+							return false;
615
+						}
616
+						break;
617
+					// TEST #6 : verify config class is accessible
618
+					case 6:
619
+						if (! class_exists($config_class)) {
620
+							if ($display_errors) {
621
+								throw new EE_Error(
622
+									sprintf(
623
+										__(
624
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
625
+											'event_espresso'
626
+										),
627
+										$config_class
628
+									)
629
+								);
630
+							}
631
+							return false;
632
+						}
633
+						break;
634
+					// TEST #7 : check that config has even been set
635
+					case 7:
636
+						if (! isset($this->{$section}->{$name})) {
637
+							if ($display_errors) {
638
+								throw new EE_Error(
639
+									sprintf(
640
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
641
+										$section,
642
+										$name
643
+									)
644
+								);
645
+							}
646
+							return false;
647
+						} else {
648
+							// and make sure it's not serialized
649
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
650
+						}
651
+						break;
652
+					// TEST #8 : check that config is the requested type
653
+					case 8:
654
+						if (! $this->{$section}->{$name} instanceof $config_class) {
655
+							if ($display_errors) {
656
+								throw new EE_Error(
657
+									sprintf(
658
+										__(
659
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
660
+											'event_espresso'
661
+										),
662
+										$section,
663
+										$name,
664
+										$config_class
665
+									)
666
+								);
667
+							}
668
+							return false;
669
+						}
670
+						break;
671
+					// TEST #9 : verify config object
672
+					case 9:
673
+						if (! $config_obj instanceof EE_Config_Base) {
674
+							if ($display_errors) {
675
+								throw new EE_Error(
676
+									sprintf(
677
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
678
+										print_r($config_obj, true)
679
+									)
680
+								);
681
+							}
682
+							return false;
683
+						}
684
+						break;
685
+				}
686
+			}
687
+		} catch (EE_Error $e) {
688
+			$e->get_error();
689
+		}
690
+		// you have successfully run the gauntlet
691
+		return true;
692
+	}
693
+
694
+
695
+	/**
696
+	 *    _generate_config_option_name
697
+	 *
698
+	 * @access        protected
699
+	 * @param        string $section
700
+	 * @param        string $name
701
+	 * @return        string
702
+	 */
703
+	private function _generate_config_option_name($section = '', $name = '')
704
+	{
705
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
706
+	}
707
+
708
+
709
+	/**
710
+	 *    _set_config_class
711
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
712
+	 *
713
+	 * @access    private
714
+	 * @param    string $config_class
715
+	 * @param    string $name
716
+	 * @return    string
717
+	 */
718
+	private function _set_config_class($config_class = '', $name = '')
719
+	{
720
+		return ! empty($config_class)
721
+			? $config_class
722
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
723
+	}
724
+
725
+
726
+	/**
727
+	 *    set_config
728
+	 *
729
+	 * @access    protected
730
+	 * @param    string         $section
731
+	 * @param    string         $name
732
+	 * @param    string         $config_class
733
+	 * @param    EE_Config_Base $config_obj
734
+	 * @return    EE_Config_Base
735
+	 */
736
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
737
+	{
738
+		// ensure config class is set to something
739
+		$config_class = $this->_set_config_class($config_class, $name);
740
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
741
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
742
+			return null;
743
+		}
744
+		$config_option_name = $this->_generate_config_option_name($section, $name);
745
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
746
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
747
+			$this->_addon_option_names[ $config_option_name ] = $config_class;
748
+			$this->update_addon_option_names();
749
+		}
750
+		// verify the incoming config object but suppress errors
751
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
752
+			$config_obj = new $config_class();
753
+		}
754
+		if (get_option($config_option_name)) {
755
+			EE_Config::log($config_option_name);
756
+			update_option($config_option_name, $config_obj);
757
+			$this->{$section}->{$name} = $config_obj;
758
+			return $this->{$section}->{$name};
759
+		} else {
760
+			// create a wp-option for this config
761
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
762
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
763
+				return $this->{$section}->{$name};
764
+			} else {
765
+				EE_Error::add_error(
766
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
767
+					__FILE__,
768
+					__FUNCTION__,
769
+					__LINE__
770
+				);
771
+				return null;
772
+			}
773
+		}
774
+	}
775
+
776
+
777
+	/**
778
+	 *    update_config
779
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
780
+	 *
781
+	 * @access    public
782
+	 * @param    string                $section
783
+	 * @param    string                $name
784
+	 * @param    EE_Config_Base|string $config_obj
785
+	 * @param    bool                  $throw_errors
786
+	 * @return    bool
787
+	 */
788
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
789
+	{
790
+		// don't allow config updates during WP heartbeats
791
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
792
+			return false;
793
+		}
794
+		$config_obj = maybe_unserialize($config_obj);
795
+		// get class name of the incoming object
796
+		$config_class = get_class($config_obj);
797
+		// run tests 1-5 and 9 to verify config
798
+		if (! $this->_verify_config_params(
799
+			$section,
800
+			$name,
801
+			$config_class,
802
+			$config_obj,
803
+			array(1, 2, 3, 4, 7, 9)
804
+		)
805
+		) {
806
+			return false;
807
+		}
808
+		$config_option_name = $this->_generate_config_option_name($section, $name);
809
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
810
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
811
+			// save new config to db
812
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
813
+				return true;
814
+			}
815
+		} else {
816
+			// first check if the record already exists
817
+			$existing_config = get_option($config_option_name);
818
+			$config_obj = serialize($config_obj);
819
+			// just return if db record is already up to date (NOT type safe comparison)
820
+			if ($existing_config == $config_obj) {
821
+				$this->{$section}->{$name} = $config_obj;
822
+				return true;
823
+			} elseif (update_option($config_option_name, $config_obj)) {
824
+				EE_Config::log($config_option_name);
825
+				// update wp-option for this config class
826
+				$this->{$section}->{$name} = $config_obj;
827
+				return true;
828
+			} elseif ($throw_errors) {
829
+				EE_Error::add_error(
830
+					sprintf(
831
+						__(
832
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
833
+							'event_espresso'
834
+						),
835
+						$config_class,
836
+						'EE_Config->' . $section . '->' . $name
837
+					),
838
+					__FILE__,
839
+					__FUNCTION__,
840
+					__LINE__
841
+				);
842
+			}
843
+		}
844
+		return false;
845
+	}
846
+
847
+
848
+	/**
849
+	 *    get_config
850
+	 *
851
+	 * @access    public
852
+	 * @param    string $section
853
+	 * @param    string $name
854
+	 * @param    string $config_class
855
+	 * @return    mixed EE_Config_Base | NULL
856
+	 */
857
+	public function get_config($section = '', $name = '', $config_class = '')
858
+	{
859
+		// ensure config class is set to something
860
+		$config_class = $this->_set_config_class($config_class, $name);
861
+		// run tests 1-4, 6 and 7 to verify that all params have been set
862
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
863
+			return null;
864
+		}
865
+		// now test if the requested config object exists, but suppress errors
866
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
867
+			// config already exists, so pass it back
868
+			return $this->{$section}->{$name};
869
+		}
870
+		// load config option from db if it exists
871
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
872
+		// verify the newly retrieved config object, but suppress errors
873
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
874
+			// config is good, so set it and pass it back
875
+			$this->{$section}->{$name} = $config_obj;
876
+			return $this->{$section}->{$name};
877
+		}
878
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
879
+		$config_obj = $this->set_config($section, $name, $config_class);
880
+		// verify the newly created config object
881
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
882
+			return $this->{$section}->{$name};
883
+		} else {
884
+			EE_Error::add_error(
885
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
886
+				__FILE__,
887
+				__FUNCTION__,
888
+				__LINE__
889
+			);
890
+		}
891
+		return null;
892
+	}
893
+
894
+
895
+	/**
896
+	 *    get_config_option
897
+	 *
898
+	 * @access    public
899
+	 * @param    string $config_option_name
900
+	 * @return    mixed EE_Config_Base | FALSE
901
+	 */
902
+	public function get_config_option($config_option_name = '')
903
+	{
904
+		// retrieve the wp-option for this config class.
905
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
906
+		if (empty($config_option)) {
907
+			EE_Config::log($config_option_name . '-NOT-FOUND');
908
+		}
909
+		return $config_option;
910
+	}
911
+
912
+
913
+	/**
914
+	 * log
915
+	 *
916
+	 * @param string $config_option_name
917
+	 */
918
+	public static function log($config_option_name = '')
919
+	{
920
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
921
+			$config_log = get_option(EE_Config::LOG_NAME, array());
922
+			// copy incoming $_REQUEST and sanitize it so we can save it
923
+			$_request = $_REQUEST;
924
+			array_walk_recursive($_request, 'sanitize_text_field');
925
+			$config_log[ (string) microtime(true) ] = array(
926
+				'config_name' => $config_option_name,
927
+				'request'     => $_request,
928
+			);
929
+			update_option(EE_Config::LOG_NAME, $config_log);
930
+		}
931
+	}
932
+
933
+
934
+	/**
935
+	 * trim_log
936
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
937
+	 */
938
+	public static function trim_log()
939
+	{
940
+		if (! EE_Config::logging_enabled()) {
941
+			return;
942
+		}
943
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
944
+		$log_length = count($config_log);
945
+		if ($log_length > EE_Config::LOG_LENGTH) {
946
+			ksort($config_log);
947
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
948
+			update_option(EE_Config::LOG_NAME, $config_log);
949
+		}
950
+	}
951
+
952
+
953
+	/**
954
+	 *    get_page_for_posts
955
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
956
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
957
+	 *
958
+	 * @access    public
959
+	 * @return    string
960
+	 */
961
+	public static function get_page_for_posts()
962
+	{
963
+		$page_for_posts = get_option('page_for_posts');
964
+		if (! $page_for_posts) {
965
+			return 'posts';
966
+		}
967
+		/** @type WPDB $wpdb */
968
+		global $wpdb;
969
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
970
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
971
+	}
972
+
973
+
974
+	/**
975
+	 *    register_shortcodes_and_modules.
976
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
977
+	 *    In fact, this is where we give modules a chance to let core know they exist
978
+	 *    so they can help trigger maintenance mode if it's needed
979
+	 *
980
+	 * @access    public
981
+	 * @return    void
982
+	 */
983
+	public function register_shortcodes_and_modules()
984
+	{
985
+		// allow modules to set hooks for the rest of the system
986
+		EE_Registry::instance()->modules = $this->_register_modules();
987
+	}
988
+
989
+
990
+	/**
991
+	 *    initialize_shortcodes_and_modules
992
+	 *    meaning they can start adding their hooks to get stuff done
993
+	 *
994
+	 * @access    public
995
+	 * @return    void
996
+	 */
997
+	public function initialize_shortcodes_and_modules()
998
+	{
999
+		// allow modules to set hooks for the rest of the system
1000
+		$this->_initialize_modules();
1001
+	}
1002
+
1003
+
1004
+	/**
1005
+	 *    widgets_init
1006
+	 *
1007
+	 * @access private
1008
+	 * @return void
1009
+	 */
1010
+	public function widgets_init()
1011
+	{
1012
+		// only init widgets on admin pages when not in complete maintenance, and
1013
+		// on frontend when not in any maintenance mode
1014
+		if (! EE_Maintenance_Mode::instance()->level()
1015
+			|| (
1016
+				is_admin()
1017
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1018
+			)
1019
+		) {
1020
+			// grab list of installed widgets
1021
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1022
+			// filter list of modules to register
1023
+			$widgets_to_register = apply_filters(
1024
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1025
+				$widgets_to_register
1026
+			);
1027
+			if (! empty($widgets_to_register)) {
1028
+				// cycle thru widget folders
1029
+				foreach ($widgets_to_register as $widget_path) {
1030
+					// add to list of installed widget modules
1031
+					EE_Config::register_ee_widget($widget_path);
1032
+				}
1033
+			}
1034
+			// filter list of installed modules
1035
+			EE_Registry::instance()->widgets = apply_filters(
1036
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1037
+				EE_Registry::instance()->widgets
1038
+			);
1039
+		}
1040
+	}
1041
+
1042
+
1043
+	/**
1044
+	 *    register_ee_widget - makes core aware of this widget
1045
+	 *
1046
+	 * @access    public
1047
+	 * @param    string $widget_path - full path up to and including widget folder
1048
+	 * @return    void
1049
+	 */
1050
+	public static function register_ee_widget($widget_path = null)
1051
+	{
1052
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1053
+		$widget_ext = '.widget.php';
1054
+		// make all separators match
1055
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1056
+		// does the file path INCLUDE the actual file name as part of the path ?
1057
+		if (strpos($widget_path, $widget_ext) !== false) {
1058
+			// grab and shortcode file name from directory name and break apart at dots
1059
+			$file_name = explode('.', basename($widget_path));
1060
+			// take first segment from file name pieces and remove class prefix if it exists
1061
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1062
+			// sanitize shortcode directory name
1063
+			$widget = sanitize_key($widget);
1064
+			// now we need to rebuild the shortcode path
1065
+			$widget_path = explode(DS, $widget_path);
1066
+			// remove last segment
1067
+			array_pop($widget_path);
1068
+			// glue it back together
1069
+			$widget_path = implode(DS, $widget_path);
1070
+		} else {
1071
+			// grab and sanitize widget directory name
1072
+			$widget = sanitize_key(basename($widget_path));
1073
+		}
1074
+		// create classname from widget directory name
1075
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1076
+		// add class prefix
1077
+		$widget_class = 'EEW_' . $widget;
1078
+		// does the widget exist ?
1079
+		if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1080
+			$msg = sprintf(
1081
+				__(
1082
+					'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',
1083
+					'event_espresso'
1084
+				),
1085
+				$widget_class,
1086
+				$widget_path . DS . $widget_class . $widget_ext
1087
+			);
1088
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1089
+			return;
1090
+		}
1091
+		// load the widget class file
1092
+		require_once($widget_path . DS . $widget_class . $widget_ext);
1093
+		// verify that class exists
1094
+		if (! class_exists($widget_class)) {
1095
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1096
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1097
+			return;
1098
+		}
1099
+		register_widget($widget_class);
1100
+		// add to array of registered widgets
1101
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1102
+	}
1103
+
1104
+
1105
+	/**
1106
+	 *        _register_modules
1107
+	 *
1108
+	 * @access private
1109
+	 * @return array
1110
+	 */
1111
+	private function _register_modules()
1112
+	{
1113
+		// grab list of installed modules
1114
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1115
+		// filter list of modules to register
1116
+		$modules_to_register = apply_filters(
1117
+			'FHEE__EE_Config__register_modules__modules_to_register',
1118
+			$modules_to_register
1119
+		);
1120
+		if (! empty($modules_to_register)) {
1121
+			// loop through folders
1122
+			foreach ($modules_to_register as $module_path) {
1123
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1124
+				if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1125
+					&& $module_path !== EE_MODULES . 'gateways'
1126
+				) {
1127
+					// add to list of installed modules
1128
+					EE_Config::register_module($module_path);
1129
+				}
1130
+			}
1131
+		}
1132
+		// filter list of installed modules
1133
+		return apply_filters(
1134
+			'FHEE__EE_Config___register_modules__installed_modules',
1135
+			EE_Registry::instance()->modules
1136
+		);
1137
+	}
1138
+
1139
+
1140
+	/**
1141
+	 *    register_module - makes core aware of this module
1142
+	 *
1143
+	 * @access    public
1144
+	 * @param    string $module_path - full path up to and including module folder
1145
+	 * @return    bool
1146
+	 */
1147
+	public static function register_module($module_path = null)
1148
+	{
1149
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1150
+		$module_ext = '.module.php';
1151
+		// make all separators match
1152
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1153
+		// does the file path INCLUDE the actual file name as part of the path ?
1154
+		if (strpos($module_path, $module_ext) !== false) {
1155
+			// grab and shortcode file name from directory name and break apart at dots
1156
+			$module_file = explode('.', basename($module_path));
1157
+			// now we need to rebuild the shortcode path
1158
+			$module_path = explode(DS, $module_path);
1159
+			// remove last segment
1160
+			array_pop($module_path);
1161
+			// glue it back together
1162
+			$module_path = implode(DS, $module_path) . DS;
1163
+			// take first segment from file name pieces and sanitize it
1164
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1165
+			// ensure class prefix is added
1166
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1167
+		} else {
1168
+			// we need to generate the filename based off of the folder name
1169
+			// grab and sanitize module name
1170
+			$module = strtolower(basename($module_path));
1171
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1172
+			// like trailingslashit()
1173
+			$module_path = rtrim($module_path, DS) . DS;
1174
+			// create classname from module directory name
1175
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1176
+			// add class prefix
1177
+			$module_class = 'EED_' . $module;
1178
+		}
1179
+		// does the module exist ?
1180
+		if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1181
+			$msg = sprintf(
1182
+				__(
1183
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1184
+					'event_espresso'
1185
+				),
1186
+				$module
1187
+			);
1188
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1189
+			return false;
1190
+		}
1191
+		// load the module class file
1192
+		require_once($module_path . $module_class . $module_ext);
1193
+		// verify that class exists
1194
+		if (! class_exists($module_class)) {
1195
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1196
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1197
+			return false;
1198
+		}
1199
+		// add to array of registered modules
1200
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1201
+		do_action(
1202
+			'AHEE__EE_Config__register_module__complete',
1203
+			$module_class,
1204
+			EE_Registry::instance()->modules->{$module_class}
1205
+		);
1206
+		return true;
1207
+	}
1208
+
1209
+
1210
+	/**
1211
+	 *    _initialize_modules
1212
+	 *    allow modules to set hooks for the rest of the system
1213
+	 *
1214
+	 * @access private
1215
+	 * @return void
1216
+	 */
1217
+	private function _initialize_modules()
1218
+	{
1219
+		// cycle thru shortcode folders
1220
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1221
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1222
+			// which set hooks ?
1223
+			if (is_admin()) {
1224
+				// fire immediately
1225
+				call_user_func(array($module_class, 'set_hooks_admin'));
1226
+			} else {
1227
+				// delay until other systems are online
1228
+				add_action(
1229
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1230
+					array($module_class, 'set_hooks')
1231
+				);
1232
+			}
1233
+		}
1234
+	}
1235
+
1236
+
1237
+	/**
1238
+	 *    register_route - adds module method routes to route_map
1239
+	 *
1240
+	 * @access    public
1241
+	 * @param    string $route       - "pretty" public alias for module method
1242
+	 * @param    string $module      - module name (classname without EED_ prefix)
1243
+	 * @param    string $method_name - the actual module method to be routed to
1244
+	 * @param    string $key         - url param key indicating a route is being called
1245
+	 * @return    bool
1246
+	 */
1247
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1248
+	{
1249
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1250
+		$module = str_replace('EED_', '', $module);
1251
+		$module_class = 'EED_' . $module;
1252
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1253
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1254
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1255
+			return false;
1256
+		}
1257
+		if (empty($route)) {
1258
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1259
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1260
+			return false;
1261
+		}
1262
+		if (! method_exists('EED_' . $module, $method_name)) {
1263
+			$msg = sprintf(
1264
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1265
+				$route
1266
+			);
1267
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1268
+			return false;
1269
+		}
1270
+		EE_Config::$_module_route_map[ $key ][ $route ] = array('EED_' . $module, $method_name);
1271
+		return true;
1272
+	}
1273
+
1274
+
1275
+	/**
1276
+	 *    get_route - get module method route
1277
+	 *
1278
+	 * @access    public
1279
+	 * @param    string $route - "pretty" public alias for module method
1280
+	 * @param    string $key   - url param key indicating a route is being called
1281
+	 * @return    string
1282
+	 */
1283
+	public static function get_route($route = null, $key = 'ee')
1284
+	{
1285
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1286
+		$route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1287
+		if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1288
+			return EE_Config::$_module_route_map[ $key ][ $route ];
1289
+		}
1290
+		return null;
1291
+	}
1292
+
1293
+
1294
+	/**
1295
+	 *    get_routes - get ALL module method routes
1296
+	 *
1297
+	 * @access    public
1298
+	 * @return    array
1299
+	 */
1300
+	public static function get_routes()
1301
+	{
1302
+		return EE_Config::$_module_route_map;
1303
+	}
1304
+
1305
+
1306
+	/**
1307
+	 *    register_forward - allows modules to forward request to another module for further processing
1308
+	 *
1309
+	 * @access    public
1310
+	 * @param    string       $route   - "pretty" public alias for module method
1311
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1312
+	 *                                 class, allows different forwards to be served based on status
1313
+	 * @param    array|string $forward - function name or array( class, method )
1314
+	 * @param    string       $key     - url param key indicating a route is being called
1315
+	 * @return    bool
1316
+	 */
1317
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1318
+	{
1319
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1320
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1321
+			$msg = sprintf(
1322
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1323
+				$route
1324
+			);
1325
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1326
+			return false;
1327
+		}
1328
+		if (empty($forward)) {
1329
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1330
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1331
+			return false;
1332
+		}
1333
+		if (is_array($forward)) {
1334
+			if (! isset($forward[1])) {
1335
+				$msg = sprintf(
1336
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1337
+					$route
1338
+				);
1339
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1340
+				return false;
1341
+			}
1342
+			if (! method_exists($forward[0], $forward[1])) {
1343
+				$msg = sprintf(
1344
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1345
+					$forward[1],
1346
+					$route
1347
+				);
1348
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1349
+				return false;
1350
+			}
1351
+		} elseif (! function_exists($forward)) {
1352
+			$msg = sprintf(
1353
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1354
+				$forward,
1355
+				$route
1356
+			);
1357
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1358
+			return false;
1359
+		}
1360
+		EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1361
+		return true;
1362
+	}
1363
+
1364
+
1365
+	/**
1366
+	 *    get_forward - get forwarding route
1367
+	 *
1368
+	 * @access    public
1369
+	 * @param    string  $route  - "pretty" public alias for module method
1370
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1371
+	 *                           allows different forwards to be served based on status
1372
+	 * @param    string  $key    - url param key indicating a route is being called
1373
+	 * @return    string
1374
+	 */
1375
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1376
+	{
1377
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1378
+		if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1379
+			return apply_filters(
1380
+				'FHEE__EE_Config__get_forward',
1381
+				EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1382
+				$route,
1383
+				$status
1384
+			);
1385
+		}
1386
+		return null;
1387
+	}
1388
+
1389
+
1390
+	/**
1391
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1392
+	 *    results
1393
+	 *
1394
+	 * @access    public
1395
+	 * @param    string  $route  - "pretty" public alias for module method
1396
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1397
+	 *                           allows different views to be served based on status
1398
+	 * @param    string  $view
1399
+	 * @param    string  $key    - url param key indicating a route is being called
1400
+	 * @return    bool
1401
+	 */
1402
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1403
+	{
1404
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1405
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1406
+			$msg = sprintf(
1407
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1408
+				$route
1409
+			);
1410
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1411
+			return false;
1412
+		}
1413
+		if (! is_readable($view)) {
1414
+			$msg = sprintf(
1415
+				__(
1416
+					'The %s view file could not be found or is not readable due to file permissions.',
1417
+					'event_espresso'
1418
+				),
1419
+				$view
1420
+			);
1421
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1422
+			return false;
1423
+		}
1424
+		EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1425
+		return true;
1426
+	}
1427
+
1428
+
1429
+	/**
1430
+	 *    get_view - get view for route and status
1431
+	 *
1432
+	 * @access    public
1433
+	 * @param    string  $route  - "pretty" public alias for module method
1434
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1435
+	 *                           allows different views to be served based on status
1436
+	 * @param    string  $key    - url param key indicating a route is being called
1437
+	 * @return    string
1438
+	 */
1439
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1440
+	{
1441
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1442
+		if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1443
+			return apply_filters(
1444
+				'FHEE__EE_Config__get_view',
1445
+				EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1446
+				$route,
1447
+				$status
1448
+			);
1449
+		}
1450
+		return null;
1451
+	}
1452
+
1453
+
1454
+	public function update_addon_option_names()
1455
+	{
1456
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1457
+	}
1458
+
1459
+
1460
+	public function shutdown()
1461
+	{
1462
+		$this->update_addon_option_names();
1463
+	}
1464
+
1465
+
1466
+	/**
1467
+	 * @return LegacyShortcodesManager
1468
+	 */
1469
+	public static function getLegacyShortcodesManager()
1470
+	{
1471
+
1472
+		if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1473
+			EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1474
+				EE_Registry::instance()
1475
+			);
1476
+		}
1477
+		return EE_Config::instance()->legacy_shortcodes_manager;
1478
+	}
1479
+
1480
+
1481
+	/**
1482
+	 * register_shortcode - makes core aware of this shortcode
1483
+	 *
1484
+	 * @deprecated 4.9.26
1485
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1486
+	 * @return    bool
1487
+	 */
1488
+	public static function register_shortcode($shortcode_path = null)
1489
+	{
1490
+		EE_Error::doing_it_wrong(
1491
+			__METHOD__,
1492
+			__(
1493
+				'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.',
1494
+				'event_espresso'
1495
+			),
1496
+			'4.9.26'
1497
+		);
1498
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1499
+	}
1500
+}
2277 1501
 
2278
-    /**
2279
-     * ReCaptcha Type
2280
-     *
2281
-     * @var string $recaptcha_type
2282
-     *    options: 'audio', 'image'
2283
-     */
2284
-    public $recaptcha_type;
1502
+/**
1503
+ * Base class used for config classes. These classes should generally not have
1504
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1505
+ * basically, they should just be well-defined stdClasses
1506
+ */
1507
+class EE_Config_Base
1508
+{
2285 1509
 
2286
-    /**
2287
-     * ReCaptcha language
2288
-     *
2289
-     * @var string $recaptcha_language
2290
-     * eg 'en'
2291
-     */
2292
-    public $recaptcha_language;
1510
+	/**
1511
+	 * Utility function for escaping the value of a property and returning.
1512
+	 *
1513
+	 * @param string $property property name (checks to see if exists).
1514
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1515
+	 * @throws \EE_Error
1516
+	 */
1517
+	public function get_pretty($property)
1518
+	{
1519
+		if (! property_exists($this, $property)) {
1520
+			throw new EE_Error(
1521
+				sprintf(
1522
+					__(
1523
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1524
+						'event_espresso'
1525
+					),
1526
+					get_class($this),
1527
+					$property
1528
+				)
1529
+			);
1530
+		}
1531
+		// just handling escaping of strings for now.
1532
+		if (is_string($this->{$property})) {
1533
+			return stripslashes($this->{$property});
1534
+		}
1535
+		return $this->{$property};
1536
+	}
1537
+
1538
+
1539
+	public function populate()
1540
+	{
1541
+		// grab defaults via a new instance of this class.
1542
+		$class_name = get_class($this);
1543
+		$defaults = new $class_name;
1544
+		// loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1545
+		// default from our $defaults object.
1546
+		foreach (get_object_vars($defaults) as $property => $value) {
1547
+			if ($this->{$property} === null) {
1548
+				$this->{$property} = $value;
1549
+			}
1550
+		}
1551
+		// cleanup
1552
+		unset($defaults);
1553
+	}
1554
+
1555
+
1556
+	/**
1557
+	 *        __isset
1558
+	 *
1559
+	 * @param $a
1560
+	 * @return bool
1561
+	 */
1562
+	public function __isset($a)
1563
+	{
1564
+		return false;
1565
+	}
1566
+
1567
+
1568
+	/**
1569
+	 *        __unset
1570
+	 *
1571
+	 * @param $a
1572
+	 * @return bool
1573
+	 */
1574
+	public function __unset($a)
1575
+	{
1576
+		return false;
1577
+	}
1578
+
1579
+
1580
+	/**
1581
+	 *        __clone
1582
+	 */
1583
+	public function __clone()
1584
+	{
1585
+	}
1586
+
1587
+
1588
+	/**
1589
+	 *        __wakeup
1590
+	 */
1591
+	public function __wakeup()
1592
+	{
1593
+	}
1594
+
1595
+
1596
+	/**
1597
+	 *        __destruct
1598
+	 */
1599
+	public function __destruct()
1600
+	{
1601
+	}
1602
+}
2293 1603
 
2294
-    /**
2295
-     * ReCaptcha public key
2296
-     *
2297
-     * @var string $recaptcha_publickey
2298
-     */
2299
-    public $recaptcha_publickey;
1604
+/**
1605
+ * Class for defining what's in the EE_Config relating to registration settings
1606
+ */
1607
+class EE_Core_Config extends EE_Config_Base
1608
+{
2300 1609
 
2301
-    /**
2302
-     * ReCaptcha private key
2303
-     *
2304
-     * @var string $recaptcha_privatekey
2305
-     */
2306
-    public $recaptcha_privatekey;
1610
+	const OPTION_NAME_UXIP = 'ee_ueip_optin';
1611
+
1612
+
1613
+	public $current_blog_id;
1614
+
1615
+	public $ee_ueip_optin;
1616
+
1617
+	public $ee_ueip_has_notified;
1618
+
1619
+	/**
1620
+	 * Not to be confused with the 4 critical page variables (See
1621
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1622
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1623
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1624
+	 *
1625
+	 * @var array
1626
+	 */
1627
+	public $post_shortcodes;
1628
+
1629
+	public $module_route_map;
1630
+
1631
+	public $module_forward_map;
1632
+
1633
+	public $module_view_map;
1634
+
1635
+	/**
1636
+	 * The next 4 vars are the IDs of critical EE pages.
1637
+	 *
1638
+	 * @var int
1639
+	 */
1640
+	public $reg_page_id;
1641
+
1642
+	public $txn_page_id;
1643
+
1644
+	public $thank_you_page_id;
1645
+
1646
+	public $cancel_page_id;
1647
+
1648
+	/**
1649
+	 * The next 4 vars are the URLs of critical EE pages.
1650
+	 *
1651
+	 * @var int
1652
+	 */
1653
+	public $reg_page_url;
1654
+
1655
+	public $txn_page_url;
1656
+
1657
+	public $thank_you_page_url;
1658
+
1659
+	public $cancel_page_url;
1660
+
1661
+	/**
1662
+	 * The next vars relate to the custom slugs for EE CPT routes
1663
+	 */
1664
+	public $event_cpt_slug;
1665
+
1666
+	/**
1667
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1668
+	 * request across blog switches in a multisite context.
1669
+	 * Avoids extra queries to the db for this option.
1670
+	 *
1671
+	 * @var bool
1672
+	 */
1673
+	public static $ee_ueip_option;
1674
+
1675
+
1676
+	/**
1677
+	 *    class constructor
1678
+	 *
1679
+	 * @access    public
1680
+	 */
1681
+	public function __construct()
1682
+	{
1683
+		// set default organization settings
1684
+		$this->current_blog_id = get_current_blog_id();
1685
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1686
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1687
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1688
+		$this->post_shortcodes = array();
1689
+		$this->module_route_map = array();
1690
+		$this->module_forward_map = array();
1691
+		$this->module_view_map = array();
1692
+		// critical EE page IDs
1693
+		$this->reg_page_id = 0;
1694
+		$this->txn_page_id = 0;
1695
+		$this->thank_you_page_id = 0;
1696
+		$this->cancel_page_id = 0;
1697
+		// critical EE page URLs
1698
+		$this->reg_page_url = '';
1699
+		$this->txn_page_url = '';
1700
+		$this->thank_you_page_url = '';
1701
+		$this->cancel_page_url = '';
1702
+		// cpt slugs
1703
+		$this->event_cpt_slug = __('events', 'event_espresso');
1704
+		// ueip constant check
1705
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1706
+			$this->ee_ueip_optin = false;
1707
+			$this->ee_ueip_has_notified = true;
1708
+		}
1709
+	}
1710
+
1711
+
1712
+	/**
1713
+	 * @return array
1714
+	 */
1715
+	public function get_critical_pages_array()
1716
+	{
1717
+		return array(
1718
+			$this->reg_page_id,
1719
+			$this->txn_page_id,
1720
+			$this->thank_you_page_id,
1721
+			$this->cancel_page_id,
1722
+		);
1723
+	}
1724
+
1725
+
1726
+	/**
1727
+	 * @return array
1728
+	 */
1729
+	public function get_critical_pages_shortcodes_array()
1730
+	{
1731
+		return array(
1732
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1733
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1734
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1735
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1736
+		);
1737
+	}
1738
+
1739
+
1740
+	/**
1741
+	 *  gets/returns URL for EE reg_page
1742
+	 *
1743
+	 * @access    public
1744
+	 * @return    string
1745
+	 */
1746
+	public function reg_page_url()
1747
+	{
1748
+		if (! $this->reg_page_url) {
1749
+			$this->reg_page_url = add_query_arg(
1750
+				array('uts' => time()),
1751
+				get_permalink($this->reg_page_id)
1752
+			) . '#checkout';
1753
+		}
1754
+		return $this->reg_page_url;
1755
+	}
1756
+
1757
+
1758
+	/**
1759
+	 *  gets/returns URL for EE txn_page
1760
+	 *
1761
+	 * @param array $query_args like what gets passed to
1762
+	 *                          add_query_arg() as the first argument
1763
+	 * @access    public
1764
+	 * @return    string
1765
+	 */
1766
+	public function txn_page_url($query_args = array())
1767
+	{
1768
+		if (! $this->txn_page_url) {
1769
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1770
+		}
1771
+		if ($query_args) {
1772
+			return add_query_arg($query_args, $this->txn_page_url);
1773
+		} else {
1774
+			return $this->txn_page_url;
1775
+		}
1776
+	}
1777
+
1778
+
1779
+	/**
1780
+	 *  gets/returns URL for EE thank_you_page
1781
+	 *
1782
+	 * @param array $query_args like what gets passed to
1783
+	 *                          add_query_arg() as the first argument
1784
+	 * @access    public
1785
+	 * @return    string
1786
+	 */
1787
+	public function thank_you_page_url($query_args = array())
1788
+	{
1789
+		if (! $this->thank_you_page_url) {
1790
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1791
+		}
1792
+		if ($query_args) {
1793
+			return add_query_arg($query_args, $this->thank_you_page_url);
1794
+		} else {
1795
+			return $this->thank_you_page_url;
1796
+		}
1797
+	}
1798
+
1799
+
1800
+	/**
1801
+	 *  gets/returns URL for EE cancel_page
1802
+	 *
1803
+	 * @access    public
1804
+	 * @return    string
1805
+	 */
1806
+	public function cancel_page_url()
1807
+	{
1808
+		if (! $this->cancel_page_url) {
1809
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1810
+		}
1811
+		return $this->cancel_page_url;
1812
+	}
1813
+
1814
+
1815
+	/**
1816
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1817
+	 *
1818
+	 * @since 4.7.5
1819
+	 */
1820
+	protected function _reset_urls()
1821
+	{
1822
+		$this->reg_page_url = '';
1823
+		$this->txn_page_url = '';
1824
+		$this->cancel_page_url = '';
1825
+		$this->thank_you_page_url = '';
1826
+	}
1827
+
1828
+
1829
+	/**
1830
+	 * Used to return what the optin value is set for the EE User Experience Program.
1831
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1832
+	 * on the main site only.
1833
+	 *
1834
+	 * @return bool
1835
+	 */
1836
+	protected function _get_main_ee_ueip_optin()
1837
+	{
1838
+		// if this is the main site then we can just bypass our direct query.
1839
+		if (is_main_site()) {
1840
+			return get_option(self::OPTION_NAME_UXIP, false);
1841
+		}
1842
+		// is this already cached for this request?  If so use it.
1843
+		if (EE_Core_Config::$ee_ueip_option !== null) {
1844
+			return EE_Core_Config::$ee_ueip_option;
1845
+		}
1846
+		global $wpdb;
1847
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1848
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1849
+		$option = self::OPTION_NAME_UXIP;
1850
+		// set correct table for query
1851
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1852
+		// rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1853
+		// get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1854
+		// re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1855
+		// this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1856
+		// for the purpose of caching.
1857
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1858
+		if (false !== $pre) {
1859
+			EE_Core_Config::$ee_ueip_option = $pre;
1860
+			return EE_Core_Config::$ee_ueip_option;
1861
+		}
1862
+		$row = $wpdb->get_row(
1863
+			$wpdb->prepare(
1864
+				"SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1865
+				$option
1866
+			)
1867
+		);
1868
+		if (is_object($row)) {
1869
+			$value = $row->option_value;
1870
+		} else { // option does not exist so use default.
1871
+			EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1872
+			return EE_Core_Config::$ee_ueip_option;
1873
+		}
1874
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1875
+		return EE_Core_Config::$ee_ueip_option;
1876
+	}
1877
+
1878
+
1879
+	/**
1880
+	 * Utility function for escaping the value of a property and returning.
1881
+	 *
1882
+	 * @param string $property property name (checks to see if exists).
1883
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1884
+	 * @throws \EE_Error
1885
+	 */
1886
+	public function get_pretty($property)
1887
+	{
1888
+		if ($property === self::OPTION_NAME_UXIP) {
1889
+			return $this->ee_ueip_optin ? 'yes' : 'no';
1890
+		}
1891
+		return parent::get_pretty($property);
1892
+	}
1893
+
1894
+
1895
+	/**
1896
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1897
+	 * on the object.
1898
+	 *
1899
+	 * @return array
1900
+	 */
1901
+	public function __sleep()
1902
+	{
1903
+		// reset all url properties
1904
+		$this->_reset_urls();
1905
+		// return what to save to db
1906
+		return array_keys(get_object_vars($this));
1907
+	}
1908
+}
2307 1909
 
2308
-    /**
2309
-     * array of form names protected by ReCaptcha
2310
-     *
2311
-     * @var array $recaptcha_protected_forms
2312
-     */
2313
-    public $recaptcha_protected_forms;
1910
+/**
1911
+ * Config class for storing info on the Organization
1912
+ */
1913
+class EE_Organization_Config extends EE_Config_Base
1914
+{
2314 1915
 
2315
-    /**
2316
-     * ReCaptcha width
2317
-     *
2318
-     * @var int $recaptcha_width
2319
-     * @deprecated
2320
-     */
2321
-    public $recaptcha_width;
1916
+	/**
1917
+	 * @var string $name
1918
+	 * eg EE4.1
1919
+	 */
1920
+	public $name;
1921
+
1922
+	/**
1923
+	 * @var string $address_1
1924
+	 * eg 123 Onna Road
1925
+	 */
1926
+	public $address_1;
1927
+
1928
+	/**
1929
+	 * @var string $address_2
1930
+	 * eg PO Box 123
1931
+	 */
1932
+	public $address_2;
1933
+
1934
+	/**
1935
+	 * @var string $city
1936
+	 * eg Inna City
1937
+	 */
1938
+	public $city;
1939
+
1940
+	/**
1941
+	 * @var int $STA_ID
1942
+	 * eg 4
1943
+	 */
1944
+	public $STA_ID;
1945
+
1946
+	/**
1947
+	 * @var string $CNT_ISO
1948
+	 * eg US
1949
+	 */
1950
+	public $CNT_ISO;
1951
+
1952
+	/**
1953
+	 * @var string $zip
1954
+	 * eg 12345  or V1A 2B3
1955
+	 */
1956
+	public $zip;
1957
+
1958
+	/**
1959
+	 * @var string $email
1960
+	 * eg [email protected]
1961
+	 */
1962
+	public $email;
1963
+
1964
+	/**
1965
+	 * @var string $phone
1966
+	 * eg. 111-111-1111
1967
+	 */
1968
+	public $phone;
1969
+
1970
+	/**
1971
+	 * @var string $vat
1972
+	 * VAT/Tax Number
1973
+	 */
1974
+	public $vat;
1975
+
1976
+	/**
1977
+	 * @var string $logo_url
1978
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1979
+	 */
1980
+	public $logo_url;
1981
+
1982
+	/**
1983
+	 * The below are all various properties for holding links to organization social network profiles
1984
+	 *
1985
+	 * @var string
1986
+	 */
1987
+	/**
1988
+	 * facebook (facebook.com/profile.name)
1989
+	 *
1990
+	 * @var string
1991
+	 */
1992
+	public $facebook;
1993
+
1994
+	/**
1995
+	 * twitter (twitter.com/twitter_handle)
1996
+	 *
1997
+	 * @var string
1998
+	 */
1999
+	public $twitter;
2000
+
2001
+	/**
2002
+	 * linkedin (linkedin.com/in/profile_name)
2003
+	 *
2004
+	 * @var string
2005
+	 */
2006
+	public $linkedin;
2007
+
2008
+	/**
2009
+	 * pinterest (www.pinterest.com/profile_name)
2010
+	 *
2011
+	 * @var string
2012
+	 */
2013
+	public $pinterest;
2014
+
2015
+	/**
2016
+	 * google+ (google.com/+profileName)
2017
+	 *
2018
+	 * @var string
2019
+	 */
2020
+	public $google;
2021
+
2022
+	/**
2023
+	 * instagram (instagram.com/handle)
2024
+	 *
2025
+	 * @var string
2026
+	 */
2027
+	public $instagram;
2028
+
2029
+
2030
+	/**
2031
+	 *    class constructor
2032
+	 *
2033
+	 * @access    public
2034
+	 */
2035
+	public function __construct()
2036
+	{
2037
+		// set default organization settings
2038
+		// decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2039
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2040
+		$this->address_1 = '123 Onna Road';
2041
+		$this->address_2 = 'PO Box 123';
2042
+		$this->city = 'Inna City';
2043
+		$this->STA_ID = 4;
2044
+		$this->CNT_ISO = 'US';
2045
+		$this->zip = '12345';
2046
+		$this->email = get_bloginfo('admin_email');
2047
+		$this->phone = '';
2048
+		$this->vat = '123456789';
2049
+		$this->logo_url = '';
2050
+		$this->facebook = '';
2051
+		$this->twitter = '';
2052
+		$this->linkedin = '';
2053
+		$this->pinterest = '';
2054
+		$this->google = '';
2055
+		$this->instagram = '';
2056
+	}
2057
+}
2322 2058
 
2323
-    /**
2324
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2325
-     *
2326
-     * @var boolean $track_invalid_checkout_access
2327
-     */
2328
-    protected $track_invalid_checkout_access = true;
2059
+/**
2060
+ * Class for defining what's in the EE_Config relating to currency
2061
+ */
2062
+class EE_Currency_Config extends EE_Config_Base
2063
+{
2329 2064
 
2330
-    /**
2331
-     * Whether or not to show the privacy policy consent checkbox
2332
-     *
2333
-     * @var bool
2334
-     */
2335
-    public $consent_checkbox_enabled;
2065
+	/**
2066
+	 * @var string $code
2067
+	 * eg 'US'
2068
+	 */
2069
+	public $code;
2070
+
2071
+	/**
2072
+	 * @var string $name
2073
+	 * eg 'Dollar'
2074
+	 */
2075
+	public $name;
2076
+
2077
+	/**
2078
+	 * plural name
2079
+	 *
2080
+	 * @var string $plural
2081
+	 * eg 'Dollars'
2082
+	 */
2083
+	public $plural;
2084
+
2085
+	/**
2086
+	 * currency sign
2087
+	 *
2088
+	 * @var string $sign
2089
+	 * eg '$'
2090
+	 */
2091
+	public $sign;
2092
+
2093
+	/**
2094
+	 * Whether the currency sign should come before the number or not
2095
+	 *
2096
+	 * @var boolean $sign_b4
2097
+	 */
2098
+	public $sign_b4;
2099
+
2100
+	/**
2101
+	 * How many digits should come after the decimal place
2102
+	 *
2103
+	 * @var int $dec_plc
2104
+	 */
2105
+	public $dec_plc;
2106
+
2107
+	/**
2108
+	 * Symbol to use for decimal mark
2109
+	 *
2110
+	 * @var string $dec_mrk
2111
+	 * eg '.'
2112
+	 */
2113
+	public $dec_mrk;
2114
+
2115
+	/**
2116
+	 * Symbol to use for thousands
2117
+	 *
2118
+	 * @var string $thsnds
2119
+	 * eg ','
2120
+	 */
2121
+	public $thsnds;
2122
+
2123
+
2124
+	/**
2125
+	 *    class constructor
2126
+	 *
2127
+	 * @access    public
2128
+	 * @param string $CNT_ISO
2129
+	 * @throws \EE_Error
2130
+	 */
2131
+	public function __construct($CNT_ISO = '')
2132
+	{
2133
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2134
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2135
+		// get country code from organization settings or use default
2136
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2137
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2138
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2139
+			: '';
2140
+		// but override if requested
2141
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2142
+		// 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
2143
+		if (! empty($CNT_ISO)
2144
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2145
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2146
+		) {
2147
+			// retrieve the country settings from the db, just in case they have been customized
2148
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2149
+			if ($country instanceof EE_Country) {
2150
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2151
+				$this->name = $country->currency_name_single();    // Dollar
2152
+				$this->plural = $country->currency_name_plural();    // Dollars
2153
+				$this->sign = $country->currency_sign();            // currency sign: $
2154
+				$this->sign_b4 = $country->currency_sign_before(
2155
+				);        // currency sign before or after: $TRUE  or  FALSE$
2156
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2157
+				$this->dec_mrk = $country->currency_decimal_mark(
2158
+				);    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2159
+				$this->thsnds = $country->currency_thousands_separator(
2160
+				);    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2161
+			}
2162
+		}
2163
+		// fallback to hardcoded defaults, in case the above failed
2164
+		if (empty($this->code)) {
2165
+			// set default currency settings
2166
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2167
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2168
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2169
+			$this->sign = '$';    // currency sign: $
2170
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2171
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2172
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2173
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2174
+		}
2175
+	}
2176
+}
2336 2177
 
2337
-    /**
2338
-     * Label text to show on the checkbox
2339
-     *
2340
-     * @var string
2341
-     */
2342
-    public $consent_checkbox_label_text;
2178
+/**
2179
+ * Class for defining what's in the EE_Config relating to registration settings
2180
+ */
2181
+class EE_Registration_Config extends EE_Config_Base
2182
+{
2343 2183
 
2344
-    /*
2184
+	/**
2185
+	 * Default registration status
2186
+	 *
2187
+	 * @var string $default_STS_ID
2188
+	 * eg 'RPP'
2189
+	 */
2190
+	public $default_STS_ID;
2191
+
2192
+	/**
2193
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2194
+	 * registrations)
2195
+	 *
2196
+	 * @var int
2197
+	 */
2198
+	public $default_maximum_number_of_tickets;
2199
+
2200
+	/**
2201
+	 * level of validation to apply to email addresses
2202
+	 *
2203
+	 * @var string $email_validation_level
2204
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2205
+	 */
2206
+	public $email_validation_level;
2207
+
2208
+	/**
2209
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2210
+	 *
2211
+	 * @var boolean $show_pending_payment_options
2212
+	 */
2213
+	public $show_pending_payment_options;
2214
+
2215
+	/**
2216
+	 * Whether to skip the registration confirmation page
2217
+	 *
2218
+	 * @var boolean $skip_reg_confirmation
2219
+	 */
2220
+	public $skip_reg_confirmation;
2221
+
2222
+	/**
2223
+	 * an array of SPCO reg steps where:
2224
+	 *        the keys denotes the reg step order
2225
+	 *        each element consists of an array with the following elements:
2226
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2227
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2228
+	 *            "slug" => the URL param used to trigger the reg step
2229
+	 *
2230
+	 * @var array $reg_steps
2231
+	 */
2232
+	public $reg_steps;
2233
+
2234
+	/**
2235
+	 * Whether registration confirmation should be the last page of SPCO
2236
+	 *
2237
+	 * @var boolean $reg_confirmation_last
2238
+	 */
2239
+	public $reg_confirmation_last;
2240
+
2241
+	/**
2242
+	 * Whether or not to enable the EE Bot Trap
2243
+	 *
2244
+	 * @var boolean $use_bot_trap
2245
+	 */
2246
+	public $use_bot_trap;
2247
+
2248
+	/**
2249
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2250
+	 *
2251
+	 * @var boolean $use_encryption
2252
+	 */
2253
+	public $use_encryption;
2254
+
2255
+	/**
2256
+	 * Whether or not to use ReCaptcha
2257
+	 *
2258
+	 * @var boolean $use_captcha
2259
+	 */
2260
+	public $use_captcha;
2261
+
2262
+	/**
2263
+	 * ReCaptcha Theme
2264
+	 *
2265
+	 * @var string $recaptcha_theme
2266
+	 *    options: 'dark', 'light', 'invisible'
2267
+	 */
2268
+	public $recaptcha_theme;
2269
+
2270
+	/**
2271
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2272
+	 *
2273
+	 * @var string $recaptcha_badge
2274
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2275
+	 */
2276
+	public $recaptcha_badge;
2277
+
2278
+	/**
2279
+	 * ReCaptcha Type
2280
+	 *
2281
+	 * @var string $recaptcha_type
2282
+	 *    options: 'audio', 'image'
2283
+	 */
2284
+	public $recaptcha_type;
2285
+
2286
+	/**
2287
+	 * ReCaptcha language
2288
+	 *
2289
+	 * @var string $recaptcha_language
2290
+	 * eg 'en'
2291
+	 */
2292
+	public $recaptcha_language;
2293
+
2294
+	/**
2295
+	 * ReCaptcha public key
2296
+	 *
2297
+	 * @var string $recaptcha_publickey
2298
+	 */
2299
+	public $recaptcha_publickey;
2300
+
2301
+	/**
2302
+	 * ReCaptcha private key
2303
+	 *
2304
+	 * @var string $recaptcha_privatekey
2305
+	 */
2306
+	public $recaptcha_privatekey;
2307
+
2308
+	/**
2309
+	 * array of form names protected by ReCaptcha
2310
+	 *
2311
+	 * @var array $recaptcha_protected_forms
2312
+	 */
2313
+	public $recaptcha_protected_forms;
2314
+
2315
+	/**
2316
+	 * ReCaptcha width
2317
+	 *
2318
+	 * @var int $recaptcha_width
2319
+	 * @deprecated
2320
+	 */
2321
+	public $recaptcha_width;
2322
+
2323
+	/**
2324
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2325
+	 *
2326
+	 * @var boolean $track_invalid_checkout_access
2327
+	 */
2328
+	protected $track_invalid_checkout_access = true;
2329
+
2330
+	/**
2331
+	 * Whether or not to show the privacy policy consent checkbox
2332
+	 *
2333
+	 * @var bool
2334
+	 */
2335
+	public $consent_checkbox_enabled;
2336
+
2337
+	/**
2338
+	 * Label text to show on the checkbox
2339
+	 *
2340
+	 * @var string
2341
+	 */
2342
+	public $consent_checkbox_label_text;
2343
+
2344
+	/*
2345 2345
      * String describing how long to keep payment logs. Passed into DateTime constructor
2346 2346
      * @var string
2347 2347
      */
2348
-    public $gateway_log_lifespan = '1 week';
2349
-
2350
-
2351
-    /**
2352
-     *    class constructor
2353
-     *
2354
-     * @access    public
2355
-     */
2356
-    public function __construct()
2357
-    {
2358
-        // set default registration settings
2359
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2360
-        $this->email_validation_level = 'wp_default';
2361
-        $this->show_pending_payment_options = true;
2362
-        $this->skip_reg_confirmation = true;
2363
-        $this->reg_steps = array();
2364
-        $this->reg_confirmation_last = false;
2365
-        $this->use_bot_trap = true;
2366
-        $this->use_encryption = true;
2367
-        $this->use_captcha = false;
2368
-        $this->recaptcha_theme = 'light';
2369
-        $this->recaptcha_badge = 'bottomleft';
2370
-        $this->recaptcha_type = 'image';
2371
-        $this->recaptcha_language = 'en';
2372
-        $this->recaptcha_publickey = null;
2373
-        $this->recaptcha_privatekey = null;
2374
-        $this->recaptcha_protected_forms = array();
2375
-        $this->recaptcha_width = 500;
2376
-        $this->default_maximum_number_of_tickets = 10;
2377
-        $this->consent_checkbox_enabled = false;
2378
-        $this->consent_checkbox_label_text = '';
2379
-        $this->gateway_log_lifespan = '7 days';
2380
-    }
2381
-
2382
-
2383
-    /**
2384
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2385
-     *
2386
-     * @since 4.8.8.rc.019
2387
-     */
2388
-    public function do_hooks()
2389
-    {
2390
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2391
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2392
-        add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2393
-    }
2394
-
2395
-
2396
-    /**
2397
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2398
-     * EVT_default_registration_status field matches the config setting for default_STS_ID.
2399
-     */
2400
-    public function set_default_reg_status_on_EEM_Event()
2401
-    {
2402
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2403
-    }
2404
-
2405
-
2406
-    /**
2407
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2408
-     * for Events matches the config setting for default_maximum_number_of_tickets
2409
-     */
2410
-    public function set_default_max_ticket_on_EEM_Event()
2411
-    {
2412
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2413
-    }
2414
-
2415
-
2416
-    /**
2417
-     * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2418
-     * constructed because that happens before we can get the privacy policy page's permalink.
2419
-     *
2420
-     * @throws InvalidArgumentException
2421
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2422
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2423
-     */
2424
-    public function setDefaultCheckboxLabelText()
2425
-    {
2426
-        if ($this->getConsentCheckboxLabelText() === null
2427
-            || $this->getConsentCheckboxLabelText() === '') {
2428
-            $opening_a_tag = '';
2429
-            $closing_a_tag = '';
2430
-            if (function_exists('get_privacy_policy_url')) {
2431
-                $privacy_page_url = get_privacy_policy_url();
2432
-                if (! empty($privacy_page_url)) {
2433
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2434
-                    $closing_a_tag = '</a>';
2435
-                }
2436
-            }
2437
-            $loader = LoaderFactory::getLoader();
2438
-            $org_config = $loader->getShared('EE_Organization_Config');
2439
-            /**
2440
-             * @var $org_config EE_Organization_Config
2441
-             */
2442
-
2443
-            $this->setConsentCheckboxLabelText(
2444
-                sprintf(
2445
-                    esc_html__(
2446
-                        'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2447
-                        'event_espresso'
2448
-                    ),
2449
-                    $org_config->name,
2450
-                    $opening_a_tag,
2451
-                    $closing_a_tag
2452
-                )
2453
-            );
2454
-        }
2455
-    }
2456
-
2457
-
2458
-    /**
2459
-     * @return boolean
2460
-     */
2461
-    public function track_invalid_checkout_access()
2462
-    {
2463
-        return $this->track_invalid_checkout_access;
2464
-    }
2465
-
2466
-
2467
-    /**
2468
-     * @param boolean $track_invalid_checkout_access
2469
-     */
2470
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2471
-    {
2472
-        $this->track_invalid_checkout_access = filter_var(
2473
-            $track_invalid_checkout_access,
2474
-            FILTER_VALIDATE_BOOLEAN
2475
-        );
2476
-    }
2477
-
2478
-
2479
-    /**
2480
-     * Gets the options to make availalbe for the gateway log lifespan
2481
-     * @return array
2482
-     */
2483
-    public function gatewayLogLifespanOptions()
2484
-    {
2485
-        return (array) apply_filters(
2486
-            'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2487
-            array(
2488
-                '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2489
-                '1 day' => esc_html__('1 Day', 'event_espresso'),
2490
-                '7 days' => esc_html__('7 Days', 'event_espresso'),
2491
-                '14 days' => esc_html__('14 Days', 'event_espresso'),
2492
-                '30 days' => esc_html__('30 Days', 'event_espresso')
2493
-            )
2494
-        );
2495
-    }
2496
-
2497
-
2498
-    /**
2499
-     * @return bool
2500
-     */
2501
-    public function isConsentCheckboxEnabled()
2502
-    {
2503
-        return $this->consent_checkbox_enabled;
2504
-    }
2505
-
2506
-
2507
-    /**
2508
-     * @param bool $consent_checkbox_enabled
2509
-     */
2510
-    public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2511
-    {
2512
-        $this->consent_checkbox_enabled = filter_var(
2513
-            $consent_checkbox_enabled,
2514
-            FILTER_VALIDATE_BOOLEAN
2515
-        );
2516
-    }
2517
-
2518
-
2519
-    /**
2520
-     * @return string
2521
-     */
2522
-    public function getConsentCheckboxLabelText()
2523
-    {
2524
-        return $this->consent_checkbox_label_text;
2525
-    }
2526
-
2527
-
2528
-    /**
2529
-     * @param string $consent_checkbox_label_text
2530
-     */
2531
-    public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2532
-    {
2533
-        $this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2534
-    }
2348
+	public $gateway_log_lifespan = '1 week';
2349
+
2350
+
2351
+	/**
2352
+	 *    class constructor
2353
+	 *
2354
+	 * @access    public
2355
+	 */
2356
+	public function __construct()
2357
+	{
2358
+		// set default registration settings
2359
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2360
+		$this->email_validation_level = 'wp_default';
2361
+		$this->show_pending_payment_options = true;
2362
+		$this->skip_reg_confirmation = true;
2363
+		$this->reg_steps = array();
2364
+		$this->reg_confirmation_last = false;
2365
+		$this->use_bot_trap = true;
2366
+		$this->use_encryption = true;
2367
+		$this->use_captcha = false;
2368
+		$this->recaptcha_theme = 'light';
2369
+		$this->recaptcha_badge = 'bottomleft';
2370
+		$this->recaptcha_type = 'image';
2371
+		$this->recaptcha_language = 'en';
2372
+		$this->recaptcha_publickey = null;
2373
+		$this->recaptcha_privatekey = null;
2374
+		$this->recaptcha_protected_forms = array();
2375
+		$this->recaptcha_width = 500;
2376
+		$this->default_maximum_number_of_tickets = 10;
2377
+		$this->consent_checkbox_enabled = false;
2378
+		$this->consent_checkbox_label_text = '';
2379
+		$this->gateway_log_lifespan = '7 days';
2380
+	}
2381
+
2382
+
2383
+	/**
2384
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2385
+	 *
2386
+	 * @since 4.8.8.rc.019
2387
+	 */
2388
+	public function do_hooks()
2389
+	{
2390
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2391
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2392
+		add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2393
+	}
2394
+
2395
+
2396
+	/**
2397
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2398
+	 * EVT_default_registration_status field matches the config setting for default_STS_ID.
2399
+	 */
2400
+	public function set_default_reg_status_on_EEM_Event()
2401
+	{
2402
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2403
+	}
2404
+
2405
+
2406
+	/**
2407
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2408
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2409
+	 */
2410
+	public function set_default_max_ticket_on_EEM_Event()
2411
+	{
2412
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2413
+	}
2414
+
2415
+
2416
+	/**
2417
+	 * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2418
+	 * constructed because that happens before we can get the privacy policy page's permalink.
2419
+	 *
2420
+	 * @throws InvalidArgumentException
2421
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2422
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2423
+	 */
2424
+	public function setDefaultCheckboxLabelText()
2425
+	{
2426
+		if ($this->getConsentCheckboxLabelText() === null
2427
+			|| $this->getConsentCheckboxLabelText() === '') {
2428
+			$opening_a_tag = '';
2429
+			$closing_a_tag = '';
2430
+			if (function_exists('get_privacy_policy_url')) {
2431
+				$privacy_page_url = get_privacy_policy_url();
2432
+				if (! empty($privacy_page_url)) {
2433
+					$opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2434
+					$closing_a_tag = '</a>';
2435
+				}
2436
+			}
2437
+			$loader = LoaderFactory::getLoader();
2438
+			$org_config = $loader->getShared('EE_Organization_Config');
2439
+			/**
2440
+			 * @var $org_config EE_Organization_Config
2441
+			 */
2442
+
2443
+			$this->setConsentCheckboxLabelText(
2444
+				sprintf(
2445
+					esc_html__(
2446
+						'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2447
+						'event_espresso'
2448
+					),
2449
+					$org_config->name,
2450
+					$opening_a_tag,
2451
+					$closing_a_tag
2452
+				)
2453
+			);
2454
+		}
2455
+	}
2456
+
2457
+
2458
+	/**
2459
+	 * @return boolean
2460
+	 */
2461
+	public function track_invalid_checkout_access()
2462
+	{
2463
+		return $this->track_invalid_checkout_access;
2464
+	}
2465
+
2466
+
2467
+	/**
2468
+	 * @param boolean $track_invalid_checkout_access
2469
+	 */
2470
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2471
+	{
2472
+		$this->track_invalid_checkout_access = filter_var(
2473
+			$track_invalid_checkout_access,
2474
+			FILTER_VALIDATE_BOOLEAN
2475
+		);
2476
+	}
2477
+
2478
+
2479
+	/**
2480
+	 * Gets the options to make availalbe for the gateway log lifespan
2481
+	 * @return array
2482
+	 */
2483
+	public function gatewayLogLifespanOptions()
2484
+	{
2485
+		return (array) apply_filters(
2486
+			'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2487
+			array(
2488
+				'1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2489
+				'1 day' => esc_html__('1 Day', 'event_espresso'),
2490
+				'7 days' => esc_html__('7 Days', 'event_espresso'),
2491
+				'14 days' => esc_html__('14 Days', 'event_espresso'),
2492
+				'30 days' => esc_html__('30 Days', 'event_espresso')
2493
+			)
2494
+		);
2495
+	}
2496
+
2497
+
2498
+	/**
2499
+	 * @return bool
2500
+	 */
2501
+	public function isConsentCheckboxEnabled()
2502
+	{
2503
+		return $this->consent_checkbox_enabled;
2504
+	}
2505
+
2506
+
2507
+	/**
2508
+	 * @param bool $consent_checkbox_enabled
2509
+	 */
2510
+	public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2511
+	{
2512
+		$this->consent_checkbox_enabled = filter_var(
2513
+			$consent_checkbox_enabled,
2514
+			FILTER_VALIDATE_BOOLEAN
2515
+		);
2516
+	}
2517
+
2518
+
2519
+	/**
2520
+	 * @return string
2521
+	 */
2522
+	public function getConsentCheckboxLabelText()
2523
+	{
2524
+		return $this->consent_checkbox_label_text;
2525
+	}
2526
+
2527
+
2528
+	/**
2529
+	 * @param string $consent_checkbox_label_text
2530
+	 */
2531
+	public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2532
+	{
2533
+		$this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2534
+	}
2535 2535
 }
2536 2536
 
2537 2537
 /**
@@ -2540,154 +2540,154 @@  discard block
 block discarded – undo
2540 2540
 class EE_Admin_Config extends EE_Config_Base
2541 2541
 {
2542 2542
 
2543
-    /**
2544
-     * @var boolean $use_personnel_manager
2545
-     */
2546
-    public $use_personnel_manager;
2547
-
2548
-    /**
2549
-     * @var boolean $use_dashboard_widget
2550
-     */
2551
-    public $use_dashboard_widget;
2552
-
2553
-    /**
2554
-     * @var int $events_in_dashboard
2555
-     */
2556
-    public $events_in_dashboard;
2557
-
2558
-    /**
2559
-     * @var boolean $use_event_timezones
2560
-     */
2561
-    public $use_event_timezones;
2562
-
2563
-    /**
2564
-     * @var boolean $use_full_logging
2565
-     */
2566
-    public $use_full_logging;
2567
-
2568
-    /**
2569
-     * @var string $log_file_name
2570
-     */
2571
-    public $log_file_name;
2572
-
2573
-    /**
2574
-     * @var string $debug_file_name
2575
-     */
2576
-    public $debug_file_name;
2577
-
2578
-    /**
2579
-     * @var boolean $use_remote_logging
2580
-     */
2581
-    public $use_remote_logging;
2582
-
2583
-    /**
2584
-     * @var string $remote_logging_url
2585
-     */
2586
-    public $remote_logging_url;
2587
-
2588
-    /**
2589
-     * @var boolean $show_reg_footer
2590
-     */
2591
-    public $show_reg_footer;
2592
-
2593
-    /**
2594
-     * @var string $affiliate_id
2595
-     */
2596
-    public $affiliate_id;
2597
-
2598
-    /**
2599
-     * help tours on or off (global setting)
2600
-     *
2601
-     * @var boolean
2602
-     */
2603
-    public $help_tour_activation;
2604
-
2605
-    /**
2606
-     * adds extra layer of encoding to session data to prevent serialization errors
2607
-     * but is incompatible with some server configuration errors
2608
-     * if you get "500 internal server errors" during registration, try turning this on
2609
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2610
-     *
2611
-     * @var boolean $encode_session_data
2612
-     */
2613
-    private $encode_session_data = false;
2614
-
2615
-
2616
-    /**
2617
-     *    class constructor
2618
-     *
2619
-     * @access    public
2620
-     */
2621
-    public function __construct()
2622
-    {
2623
-        // set default general admin settings
2624
-        $this->use_personnel_manager = true;
2625
-        $this->use_dashboard_widget = true;
2626
-        $this->events_in_dashboard = 30;
2627
-        $this->use_event_timezones = false;
2628
-        $this->use_full_logging = false;
2629
-        $this->use_remote_logging = false;
2630
-        $this->remote_logging_url = null;
2631
-        $this->show_reg_footer = true;
2632
-        $this->affiliate_id = 'default';
2633
-        $this->help_tour_activation = true;
2634
-        $this->encode_session_data = false;
2635
-    }
2636
-
2637
-
2638
-    /**
2639
-     * @param bool $reset
2640
-     * @return string
2641
-     */
2642
-    public function log_file_name($reset = false)
2643
-    {
2644
-        if (empty($this->log_file_name) || $reset) {
2645
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2646
-            EE_Config::instance()->update_espresso_config(false, false);
2647
-        }
2648
-        return $this->log_file_name;
2649
-    }
2650
-
2651
-
2652
-    /**
2653
-     * @param bool $reset
2654
-     * @return string
2655
-     */
2656
-    public function debug_file_name($reset = false)
2657
-    {
2658
-        if (empty($this->debug_file_name) || $reset) {
2659
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2660
-            EE_Config::instance()->update_espresso_config(false, false);
2661
-        }
2662
-        return $this->debug_file_name;
2663
-    }
2664
-
2665
-
2666
-    /**
2667
-     * @return string
2668
-     */
2669
-    public function affiliate_id()
2670
-    {
2671
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2672
-    }
2673
-
2674
-
2675
-    /**
2676
-     * @return boolean
2677
-     */
2678
-    public function encode_session_data()
2679
-    {
2680
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2681
-    }
2682
-
2683
-
2684
-    /**
2685
-     * @param boolean $encode_session_data
2686
-     */
2687
-    public function set_encode_session_data($encode_session_data)
2688
-    {
2689
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2690
-    }
2543
+	/**
2544
+	 * @var boolean $use_personnel_manager
2545
+	 */
2546
+	public $use_personnel_manager;
2547
+
2548
+	/**
2549
+	 * @var boolean $use_dashboard_widget
2550
+	 */
2551
+	public $use_dashboard_widget;
2552
+
2553
+	/**
2554
+	 * @var int $events_in_dashboard
2555
+	 */
2556
+	public $events_in_dashboard;
2557
+
2558
+	/**
2559
+	 * @var boolean $use_event_timezones
2560
+	 */
2561
+	public $use_event_timezones;
2562
+
2563
+	/**
2564
+	 * @var boolean $use_full_logging
2565
+	 */
2566
+	public $use_full_logging;
2567
+
2568
+	/**
2569
+	 * @var string $log_file_name
2570
+	 */
2571
+	public $log_file_name;
2572
+
2573
+	/**
2574
+	 * @var string $debug_file_name
2575
+	 */
2576
+	public $debug_file_name;
2577
+
2578
+	/**
2579
+	 * @var boolean $use_remote_logging
2580
+	 */
2581
+	public $use_remote_logging;
2582
+
2583
+	/**
2584
+	 * @var string $remote_logging_url
2585
+	 */
2586
+	public $remote_logging_url;
2587
+
2588
+	/**
2589
+	 * @var boolean $show_reg_footer
2590
+	 */
2591
+	public $show_reg_footer;
2592
+
2593
+	/**
2594
+	 * @var string $affiliate_id
2595
+	 */
2596
+	public $affiliate_id;
2597
+
2598
+	/**
2599
+	 * help tours on or off (global setting)
2600
+	 *
2601
+	 * @var boolean
2602
+	 */
2603
+	public $help_tour_activation;
2604
+
2605
+	/**
2606
+	 * adds extra layer of encoding to session data to prevent serialization errors
2607
+	 * but is incompatible with some server configuration errors
2608
+	 * if you get "500 internal server errors" during registration, try turning this on
2609
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2610
+	 *
2611
+	 * @var boolean $encode_session_data
2612
+	 */
2613
+	private $encode_session_data = false;
2614
+
2615
+
2616
+	/**
2617
+	 *    class constructor
2618
+	 *
2619
+	 * @access    public
2620
+	 */
2621
+	public function __construct()
2622
+	{
2623
+		// set default general admin settings
2624
+		$this->use_personnel_manager = true;
2625
+		$this->use_dashboard_widget = true;
2626
+		$this->events_in_dashboard = 30;
2627
+		$this->use_event_timezones = false;
2628
+		$this->use_full_logging = false;
2629
+		$this->use_remote_logging = false;
2630
+		$this->remote_logging_url = null;
2631
+		$this->show_reg_footer = true;
2632
+		$this->affiliate_id = 'default';
2633
+		$this->help_tour_activation = true;
2634
+		$this->encode_session_data = false;
2635
+	}
2636
+
2637
+
2638
+	/**
2639
+	 * @param bool $reset
2640
+	 * @return string
2641
+	 */
2642
+	public function log_file_name($reset = false)
2643
+	{
2644
+		if (empty($this->log_file_name) || $reset) {
2645
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2646
+			EE_Config::instance()->update_espresso_config(false, false);
2647
+		}
2648
+		return $this->log_file_name;
2649
+	}
2650
+
2651
+
2652
+	/**
2653
+	 * @param bool $reset
2654
+	 * @return string
2655
+	 */
2656
+	public function debug_file_name($reset = false)
2657
+	{
2658
+		if (empty($this->debug_file_name) || $reset) {
2659
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2660
+			EE_Config::instance()->update_espresso_config(false, false);
2661
+		}
2662
+		return $this->debug_file_name;
2663
+	}
2664
+
2665
+
2666
+	/**
2667
+	 * @return string
2668
+	 */
2669
+	public function affiliate_id()
2670
+	{
2671
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2672
+	}
2673
+
2674
+
2675
+	/**
2676
+	 * @return boolean
2677
+	 */
2678
+	public function encode_session_data()
2679
+	{
2680
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2681
+	}
2682
+
2683
+
2684
+	/**
2685
+	 * @param boolean $encode_session_data
2686
+	 */
2687
+	public function set_encode_session_data($encode_session_data)
2688
+	{
2689
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2690
+	}
2691 2691
 }
2692 2692
 
2693 2693
 /**
@@ -2696,70 +2696,70 @@  discard block
 block discarded – undo
2696 2696
 class EE_Template_Config extends EE_Config_Base
2697 2697
 {
2698 2698
 
2699
-    /**
2700
-     * @var boolean $enable_default_style
2701
-     */
2702
-    public $enable_default_style;
2703
-
2704
-    /**
2705
-     * @var string $custom_style_sheet
2706
-     */
2707
-    public $custom_style_sheet;
2708
-
2709
-    /**
2710
-     * @var boolean $display_address_in_regform
2711
-     */
2712
-    public $display_address_in_regform;
2713
-
2714
-    /**
2715
-     * @var int $display_description_on_multi_reg_page
2716
-     */
2717
-    public $display_description_on_multi_reg_page;
2718
-
2719
-    /**
2720
-     * @var boolean $use_custom_templates
2721
-     */
2722
-    public $use_custom_templates;
2723
-
2724
-    /**
2725
-     * @var string $current_espresso_theme
2726
-     */
2727
-    public $current_espresso_theme;
2728
-
2729
-    /**
2730
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2731
-     */
2732
-    public $EED_Ticket_Selector;
2733
-
2734
-    /**
2735
-     * @var EE_Event_Single_Config $EED_Event_Single
2736
-     */
2737
-    public $EED_Event_Single;
2738
-
2739
-    /**
2740
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2741
-     */
2742
-    public $EED_Events_Archive;
2743
-
2744
-
2745
-    /**
2746
-     *    class constructor
2747
-     *
2748
-     * @access    public
2749
-     */
2750
-    public function __construct()
2751
-    {
2752
-        // set default template settings
2753
-        $this->enable_default_style = true;
2754
-        $this->custom_style_sheet = null;
2755
-        $this->display_address_in_regform = true;
2756
-        $this->display_description_on_multi_reg_page = false;
2757
-        $this->use_custom_templates = false;
2758
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2759
-        $this->EED_Event_Single = null;
2760
-        $this->EED_Events_Archive = null;
2761
-        $this->EED_Ticket_Selector = null;
2762
-    }
2699
+	/**
2700
+	 * @var boolean $enable_default_style
2701
+	 */
2702
+	public $enable_default_style;
2703
+
2704
+	/**
2705
+	 * @var string $custom_style_sheet
2706
+	 */
2707
+	public $custom_style_sheet;
2708
+
2709
+	/**
2710
+	 * @var boolean $display_address_in_regform
2711
+	 */
2712
+	public $display_address_in_regform;
2713
+
2714
+	/**
2715
+	 * @var int $display_description_on_multi_reg_page
2716
+	 */
2717
+	public $display_description_on_multi_reg_page;
2718
+
2719
+	/**
2720
+	 * @var boolean $use_custom_templates
2721
+	 */
2722
+	public $use_custom_templates;
2723
+
2724
+	/**
2725
+	 * @var string $current_espresso_theme
2726
+	 */
2727
+	public $current_espresso_theme;
2728
+
2729
+	/**
2730
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2731
+	 */
2732
+	public $EED_Ticket_Selector;
2733
+
2734
+	/**
2735
+	 * @var EE_Event_Single_Config $EED_Event_Single
2736
+	 */
2737
+	public $EED_Event_Single;
2738
+
2739
+	/**
2740
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2741
+	 */
2742
+	public $EED_Events_Archive;
2743
+
2744
+
2745
+	/**
2746
+	 *    class constructor
2747
+	 *
2748
+	 * @access    public
2749
+	 */
2750
+	public function __construct()
2751
+	{
2752
+		// set default template settings
2753
+		$this->enable_default_style = true;
2754
+		$this->custom_style_sheet = null;
2755
+		$this->display_address_in_regform = true;
2756
+		$this->display_description_on_multi_reg_page = false;
2757
+		$this->use_custom_templates = false;
2758
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2759
+		$this->EED_Event_Single = null;
2760
+		$this->EED_Events_Archive = null;
2761
+		$this->EED_Ticket_Selector = null;
2762
+	}
2763 2763
 }
2764 2764
 
2765 2765
 /**
@@ -2768,114 +2768,114 @@  discard block
 block discarded – undo
2768 2768
 class EE_Map_Config extends EE_Config_Base
2769 2769
 {
2770 2770
 
2771
-    /**
2772
-     * @var boolean $use_google_maps
2773
-     */
2774
-    public $use_google_maps;
2775
-
2776
-    /**
2777
-     * @var string $api_key
2778
-     */
2779
-    public $google_map_api_key;
2780
-
2781
-    /**
2782
-     * @var int $event_details_map_width
2783
-     */
2784
-    public $event_details_map_width;
2785
-
2786
-    /**
2787
-     * @var int $event_details_map_height
2788
-     */
2789
-    public $event_details_map_height;
2790
-
2791
-    /**
2792
-     * @var int $event_details_map_zoom
2793
-     */
2794
-    public $event_details_map_zoom;
2795
-
2796
-    /**
2797
-     * @var boolean $event_details_display_nav
2798
-     */
2799
-    public $event_details_display_nav;
2800
-
2801
-    /**
2802
-     * @var boolean $event_details_nav_size
2803
-     */
2804
-    public $event_details_nav_size;
2805
-
2806
-    /**
2807
-     * @var string $event_details_control_type
2808
-     */
2809
-    public $event_details_control_type;
2810
-
2811
-    /**
2812
-     * @var string $event_details_map_align
2813
-     */
2814
-    public $event_details_map_align;
2815
-
2816
-    /**
2817
-     * @var int $event_list_map_width
2818
-     */
2819
-    public $event_list_map_width;
2820
-
2821
-    /**
2822
-     * @var int $event_list_map_height
2823
-     */
2824
-    public $event_list_map_height;
2825
-
2826
-    /**
2827
-     * @var int $event_list_map_zoom
2828
-     */
2829
-    public $event_list_map_zoom;
2830
-
2831
-    /**
2832
-     * @var boolean $event_list_display_nav
2833
-     */
2834
-    public $event_list_display_nav;
2835
-
2836
-    /**
2837
-     * @var boolean $event_list_nav_size
2838
-     */
2839
-    public $event_list_nav_size;
2840
-
2841
-    /**
2842
-     * @var string $event_list_control_type
2843
-     */
2844
-    public $event_list_control_type;
2845
-
2846
-    /**
2847
-     * @var string $event_list_map_align
2848
-     */
2849
-    public $event_list_map_align;
2850
-
2851
-
2852
-    /**
2853
-     *    class constructor
2854
-     *
2855
-     * @access    public
2856
-     */
2857
-    public function __construct()
2858
-    {
2859
-        // set default map settings
2860
-        $this->use_google_maps = true;
2861
-        $this->google_map_api_key = '';
2862
-        // for event details pages (reg page)
2863
-        $this->event_details_map_width = 585;            // ee_map_width_single
2864
-        $this->event_details_map_height = 362;            // ee_map_height_single
2865
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2866
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2867
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2868
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2869
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2870
-        // for event list pages
2871
-        $this->event_list_map_width = 300;            // ee_map_width
2872
-        $this->event_list_map_height = 185;        // ee_map_height
2873
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2874
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2875
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2876
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2877
-        $this->event_list_map_align = 'center';            // ee_map_align
2878
-    }
2771
+	/**
2772
+	 * @var boolean $use_google_maps
2773
+	 */
2774
+	public $use_google_maps;
2775
+
2776
+	/**
2777
+	 * @var string $api_key
2778
+	 */
2779
+	public $google_map_api_key;
2780
+
2781
+	/**
2782
+	 * @var int $event_details_map_width
2783
+	 */
2784
+	public $event_details_map_width;
2785
+
2786
+	/**
2787
+	 * @var int $event_details_map_height
2788
+	 */
2789
+	public $event_details_map_height;
2790
+
2791
+	/**
2792
+	 * @var int $event_details_map_zoom
2793
+	 */
2794
+	public $event_details_map_zoom;
2795
+
2796
+	/**
2797
+	 * @var boolean $event_details_display_nav
2798
+	 */
2799
+	public $event_details_display_nav;
2800
+
2801
+	/**
2802
+	 * @var boolean $event_details_nav_size
2803
+	 */
2804
+	public $event_details_nav_size;
2805
+
2806
+	/**
2807
+	 * @var string $event_details_control_type
2808
+	 */
2809
+	public $event_details_control_type;
2810
+
2811
+	/**
2812
+	 * @var string $event_details_map_align
2813
+	 */
2814
+	public $event_details_map_align;
2815
+
2816
+	/**
2817
+	 * @var int $event_list_map_width
2818
+	 */
2819
+	public $event_list_map_width;
2820
+
2821
+	/**
2822
+	 * @var int $event_list_map_height
2823
+	 */
2824
+	public $event_list_map_height;
2825
+
2826
+	/**
2827
+	 * @var int $event_list_map_zoom
2828
+	 */
2829
+	public $event_list_map_zoom;
2830
+
2831
+	/**
2832
+	 * @var boolean $event_list_display_nav
2833
+	 */
2834
+	public $event_list_display_nav;
2835
+
2836
+	/**
2837
+	 * @var boolean $event_list_nav_size
2838
+	 */
2839
+	public $event_list_nav_size;
2840
+
2841
+	/**
2842
+	 * @var string $event_list_control_type
2843
+	 */
2844
+	public $event_list_control_type;
2845
+
2846
+	/**
2847
+	 * @var string $event_list_map_align
2848
+	 */
2849
+	public $event_list_map_align;
2850
+
2851
+
2852
+	/**
2853
+	 *    class constructor
2854
+	 *
2855
+	 * @access    public
2856
+	 */
2857
+	public function __construct()
2858
+	{
2859
+		// set default map settings
2860
+		$this->use_google_maps = true;
2861
+		$this->google_map_api_key = '';
2862
+		// for event details pages (reg page)
2863
+		$this->event_details_map_width = 585;            // ee_map_width_single
2864
+		$this->event_details_map_height = 362;            // ee_map_height_single
2865
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2866
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2867
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2868
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2869
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2870
+		// for event list pages
2871
+		$this->event_list_map_width = 300;            // ee_map_width
2872
+		$this->event_list_map_height = 185;        // ee_map_height
2873
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2874
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2875
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2876
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2877
+		$this->event_list_map_align = 'center';            // ee_map_align
2878
+	}
2879 2879
 }
2880 2880
 
2881 2881
 /**
@@ -2884,46 +2884,46 @@  discard block
 block discarded – undo
2884 2884
 class EE_Events_Archive_Config extends EE_Config_Base
2885 2885
 {
2886 2886
 
2887
-    public $display_status_banner;
2887
+	public $display_status_banner;
2888 2888
 
2889
-    public $display_description;
2889
+	public $display_description;
2890 2890
 
2891
-    public $display_ticket_selector;
2891
+	public $display_ticket_selector;
2892 2892
 
2893
-    public $display_datetimes;
2893
+	public $display_datetimes;
2894 2894
 
2895
-    public $display_venue;
2895
+	public $display_venue;
2896 2896
 
2897
-    public $display_expired_events;
2897
+	public $display_expired_events;
2898 2898
 
2899
-    public $use_sortable_display_order;
2899
+	public $use_sortable_display_order;
2900 2900
 
2901
-    public $display_order_tickets;
2901
+	public $display_order_tickets;
2902 2902
 
2903
-    public $display_order_datetimes;
2903
+	public $display_order_datetimes;
2904 2904
 
2905
-    public $display_order_event;
2905
+	public $display_order_event;
2906 2906
 
2907
-    public $display_order_venue;
2907
+	public $display_order_venue;
2908 2908
 
2909 2909
 
2910
-    /**
2911
-     *    class constructor
2912
-     */
2913
-    public function __construct()
2914
-    {
2915
-        $this->display_status_banner = 0;
2916
-        $this->display_description = 1;
2917
-        $this->display_ticket_selector = 0;
2918
-        $this->display_datetimes = 1;
2919
-        $this->display_venue = 0;
2920
-        $this->display_expired_events = 0;
2921
-        $this->use_sortable_display_order = false;
2922
-        $this->display_order_tickets = 100;
2923
-        $this->display_order_datetimes = 110;
2924
-        $this->display_order_event = 120;
2925
-        $this->display_order_venue = 130;
2926
-    }
2910
+	/**
2911
+	 *    class constructor
2912
+	 */
2913
+	public function __construct()
2914
+	{
2915
+		$this->display_status_banner = 0;
2916
+		$this->display_description = 1;
2917
+		$this->display_ticket_selector = 0;
2918
+		$this->display_datetimes = 1;
2919
+		$this->display_venue = 0;
2920
+		$this->display_expired_events = 0;
2921
+		$this->use_sortable_display_order = false;
2922
+		$this->display_order_tickets = 100;
2923
+		$this->display_order_datetimes = 110;
2924
+		$this->display_order_event = 120;
2925
+		$this->display_order_venue = 130;
2926
+	}
2927 2927
 }
2928 2928
 
2929 2929
 /**
@@ -2932,34 +2932,34 @@  discard block
 block discarded – undo
2932 2932
 class EE_Event_Single_Config extends EE_Config_Base
2933 2933
 {
2934 2934
 
2935
-    public $display_status_banner_single;
2935
+	public $display_status_banner_single;
2936 2936
 
2937
-    public $display_venue;
2937
+	public $display_venue;
2938 2938
 
2939
-    public $use_sortable_display_order;
2939
+	public $use_sortable_display_order;
2940 2940
 
2941
-    public $display_order_tickets;
2941
+	public $display_order_tickets;
2942 2942
 
2943
-    public $display_order_datetimes;
2943
+	public $display_order_datetimes;
2944 2944
 
2945
-    public $display_order_event;
2945
+	public $display_order_event;
2946 2946
 
2947
-    public $display_order_venue;
2947
+	public $display_order_venue;
2948 2948
 
2949 2949
 
2950
-    /**
2951
-     *    class constructor
2952
-     */
2953
-    public function __construct()
2954
-    {
2955
-        $this->display_status_banner_single = 0;
2956
-        $this->display_venue = 1;
2957
-        $this->use_sortable_display_order = false;
2958
-        $this->display_order_tickets = 100;
2959
-        $this->display_order_datetimes = 110;
2960
-        $this->display_order_event = 120;
2961
-        $this->display_order_venue = 130;
2962
-    }
2950
+	/**
2951
+	 *    class constructor
2952
+	 */
2953
+	public function __construct()
2954
+	{
2955
+		$this->display_status_banner_single = 0;
2956
+		$this->display_venue = 1;
2957
+		$this->use_sortable_display_order = false;
2958
+		$this->display_order_tickets = 100;
2959
+		$this->display_order_datetimes = 110;
2960
+		$this->display_order_event = 120;
2961
+		$this->display_order_venue = 130;
2962
+	}
2963 2963
 }
2964 2964
 
2965 2965
 /**
@@ -2968,146 +2968,146 @@  discard block
 block discarded – undo
2968 2968
 class EE_Ticket_Selector_Config extends EE_Config_Base
2969 2969
 {
2970 2970
 
2971
-    /**
2972
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2973
-     */
2974
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2975
-
2976
-    /**
2977
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2978
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2979
-     */
2980
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2981
-
2982
-    /**
2983
-     * @var boolean $show_ticket_sale_columns
2984
-     */
2985
-    public $show_ticket_sale_columns;
2986
-
2987
-    /**
2988
-     * @var boolean $show_ticket_details
2989
-     */
2990
-    public $show_ticket_details;
2991
-
2992
-    /**
2993
-     * @var boolean $show_expired_tickets
2994
-     */
2995
-    public $show_expired_tickets;
2996
-
2997
-    /**
2998
-     * whether or not to display a dropdown box populated with event datetimes
2999
-     * that toggles which tickets are displayed for a ticket selector.
3000
-     * uses one of the *_DATETIME_SELECTOR constants defined above
3001
-     *
3002
-     * @var string $show_datetime_selector
3003
-     */
3004
-    private $show_datetime_selector = 'no_datetime_selector';
3005
-
3006
-    /**
3007
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
3008
-     *
3009
-     * @var int $datetime_selector_threshold
3010
-     */
3011
-    private $datetime_selector_threshold = 3;
3012
-
3013
-
3014
-    /**
3015
-     *    class constructor
3016
-     */
3017
-    public function __construct()
3018
-    {
3019
-        $this->show_ticket_sale_columns = true;
3020
-        $this->show_ticket_details = true;
3021
-        $this->show_expired_tickets = true;
3022
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3023
-        $this->datetime_selector_threshold = 3;
3024
-    }
3025
-
3026
-
3027
-    /**
3028
-     * returns true if a datetime selector should be displayed
3029
-     *
3030
-     * @param array $datetimes
3031
-     * @return bool
3032
-     */
3033
-    public function showDatetimeSelector(array $datetimes)
3034
-    {
3035
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3036
-        return ! (
3037
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3038
-            || (
3039
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3040
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3041
-            )
3042
-        );
3043
-    }
3044
-
3045
-
3046
-    /**
3047
-     * @return string
3048
-     */
3049
-    public function getShowDatetimeSelector()
3050
-    {
3051
-        return $this->show_datetime_selector;
3052
-    }
3053
-
3054
-
3055
-    /**
3056
-     * @param bool $keys_only
3057
-     * @return array
3058
-     */
3059
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3060
-    {
3061
-        return $keys_only
3062
-            ? array(
3063
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3064
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3065
-            )
3066
-            : array(
3067
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3068
-                    'Do not show date & time filter',
3069
-                    'event_espresso'
3070
-                ),
3071
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3072
-                    'Maybe show date & time filter',
3073
-                    'event_espresso'
3074
-                ),
3075
-            );
3076
-    }
3077
-
3078
-
3079
-    /**
3080
-     * @param string $show_datetime_selector
3081
-     */
3082
-    public function setShowDatetimeSelector($show_datetime_selector)
3083
-    {
3084
-        $this->show_datetime_selector = in_array(
3085
-            $show_datetime_selector,
3086
-            $this->getShowDatetimeSelectorOptions(),
3087
-            true
3088
-        )
3089
-            ? $show_datetime_selector
3090
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3091
-    }
3092
-
3093
-
3094
-    /**
3095
-     * @return int
3096
-     */
3097
-    public function getDatetimeSelectorThreshold()
3098
-    {
3099
-        return $this->datetime_selector_threshold;
3100
-    }
3101
-
3102
-
3103
-    /**
3104
-     * @param int $datetime_selector_threshold
3105
-     */
3106
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3107
-    {
3108
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3109
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3110
-    }
2971
+	/**
2972
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2973
+	 */
2974
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2975
+
2976
+	/**
2977
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2978
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2979
+	 */
2980
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2981
+
2982
+	/**
2983
+	 * @var boolean $show_ticket_sale_columns
2984
+	 */
2985
+	public $show_ticket_sale_columns;
2986
+
2987
+	/**
2988
+	 * @var boolean $show_ticket_details
2989
+	 */
2990
+	public $show_ticket_details;
2991
+
2992
+	/**
2993
+	 * @var boolean $show_expired_tickets
2994
+	 */
2995
+	public $show_expired_tickets;
2996
+
2997
+	/**
2998
+	 * whether or not to display a dropdown box populated with event datetimes
2999
+	 * that toggles which tickets are displayed for a ticket selector.
3000
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
3001
+	 *
3002
+	 * @var string $show_datetime_selector
3003
+	 */
3004
+	private $show_datetime_selector = 'no_datetime_selector';
3005
+
3006
+	/**
3007
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
3008
+	 *
3009
+	 * @var int $datetime_selector_threshold
3010
+	 */
3011
+	private $datetime_selector_threshold = 3;
3012
+
3013
+
3014
+	/**
3015
+	 *    class constructor
3016
+	 */
3017
+	public function __construct()
3018
+	{
3019
+		$this->show_ticket_sale_columns = true;
3020
+		$this->show_ticket_details = true;
3021
+		$this->show_expired_tickets = true;
3022
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3023
+		$this->datetime_selector_threshold = 3;
3024
+	}
3025
+
3026
+
3027
+	/**
3028
+	 * returns true if a datetime selector should be displayed
3029
+	 *
3030
+	 * @param array $datetimes
3031
+	 * @return bool
3032
+	 */
3033
+	public function showDatetimeSelector(array $datetimes)
3034
+	{
3035
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3036
+		return ! (
3037
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3038
+			|| (
3039
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3040
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3041
+			)
3042
+		);
3043
+	}
3044
+
3045
+
3046
+	/**
3047
+	 * @return string
3048
+	 */
3049
+	public function getShowDatetimeSelector()
3050
+	{
3051
+		return $this->show_datetime_selector;
3052
+	}
3053
+
3054
+
3055
+	/**
3056
+	 * @param bool $keys_only
3057
+	 * @return array
3058
+	 */
3059
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3060
+	{
3061
+		return $keys_only
3062
+			? array(
3063
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3064
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3065
+			)
3066
+			: array(
3067
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3068
+					'Do not show date & time filter',
3069
+					'event_espresso'
3070
+				),
3071
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3072
+					'Maybe show date & time filter',
3073
+					'event_espresso'
3074
+				),
3075
+			);
3076
+	}
3077
+
3078
+
3079
+	/**
3080
+	 * @param string $show_datetime_selector
3081
+	 */
3082
+	public function setShowDatetimeSelector($show_datetime_selector)
3083
+	{
3084
+		$this->show_datetime_selector = in_array(
3085
+			$show_datetime_selector,
3086
+			$this->getShowDatetimeSelectorOptions(),
3087
+			true
3088
+		)
3089
+			? $show_datetime_selector
3090
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3091
+	}
3092
+
3093
+
3094
+	/**
3095
+	 * @return int
3096
+	 */
3097
+	public function getDatetimeSelectorThreshold()
3098
+	{
3099
+		return $this->datetime_selector_threshold;
3100
+	}
3101
+
3102
+
3103
+	/**
3104
+	 * @param int $datetime_selector_threshold
3105
+	 */
3106
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3107
+	{
3108
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3109
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3110
+	}
3111 3111
 }
3112 3112
 
3113 3113
 /**
@@ -3120,81 +3120,81 @@  discard block
 block discarded – undo
3120 3120
 class EE_Environment_Config extends EE_Config_Base
3121 3121
 {
3122 3122
 
3123
-    /**
3124
-     * Hold any php environment variables that we want to track.
3125
-     *
3126
-     * @var stdClass;
3127
-     */
3128
-    public $php;
3129
-
3130
-
3131
-    /**
3132
-     *    constructor
3133
-     */
3134
-    public function __construct()
3135
-    {
3136
-        $this->php = new stdClass();
3137
-        $this->_set_php_values();
3138
-    }
3139
-
3140
-
3141
-    /**
3142
-     * This sets the php environment variables.
3143
-     *
3144
-     * @since 4.4.0
3145
-     * @return void
3146
-     */
3147
-    protected function _set_php_values()
3148
-    {
3149
-        $this->php->max_input_vars = ini_get('max_input_vars');
3150
-        $this->php->version = phpversion();
3151
-    }
3152
-
3153
-
3154
-    /**
3155
-     * helper method for determining whether input_count is
3156
-     * reaching the potential maximum the server can handle
3157
-     * according to max_input_vars
3158
-     *
3159
-     * @param int   $input_count the count of input vars.
3160
-     * @return array {
3161
-     *                           An array that represents whether available space and if no available space the error
3162
-     *                           message.
3163
-     * @type bool   $has_space   whether more inputs can be added.
3164
-     * @type string $msg         Any message to be displayed.
3165
-     *                           }
3166
-     */
3167
-    public function max_input_vars_limit_check($input_count = 0)
3168
-    {
3169
-        if (! empty($this->php->max_input_vars)
3170
-            && ($input_count >= $this->php->max_input_vars)
3171
-            && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3172
-        ) {
3173
-            return sprintf(
3174
-                __(
3175
-                    'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3176
-                    'event_espresso'
3177
-                ),
3178
-                '<br>',
3179
-                $input_count,
3180
-                $this->php->max_input_vars
3181
-            );
3182
-        } else {
3183
-            return '';
3184
-        }
3185
-    }
3186
-
3187
-
3188
-    /**
3189
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3190
-     *
3191
-     * @since 4.4.1
3192
-     * @return void
3193
-     */
3194
-    public function recheck_values()
3195
-    {
3196
-        $this->_set_php_values();
3197
-    }
3123
+	/**
3124
+	 * Hold any php environment variables that we want to track.
3125
+	 *
3126
+	 * @var stdClass;
3127
+	 */
3128
+	public $php;
3129
+
3130
+
3131
+	/**
3132
+	 *    constructor
3133
+	 */
3134
+	public function __construct()
3135
+	{
3136
+		$this->php = new stdClass();
3137
+		$this->_set_php_values();
3138
+	}
3139
+
3140
+
3141
+	/**
3142
+	 * This sets the php environment variables.
3143
+	 *
3144
+	 * @since 4.4.0
3145
+	 * @return void
3146
+	 */
3147
+	protected function _set_php_values()
3148
+	{
3149
+		$this->php->max_input_vars = ini_get('max_input_vars');
3150
+		$this->php->version = phpversion();
3151
+	}
3152
+
3153
+
3154
+	/**
3155
+	 * helper method for determining whether input_count is
3156
+	 * reaching the potential maximum the server can handle
3157
+	 * according to max_input_vars
3158
+	 *
3159
+	 * @param int   $input_count the count of input vars.
3160
+	 * @return array {
3161
+	 *                           An array that represents whether available space and if no available space the error
3162
+	 *                           message.
3163
+	 * @type bool   $has_space   whether more inputs can be added.
3164
+	 * @type string $msg         Any message to be displayed.
3165
+	 *                           }
3166
+	 */
3167
+	public function max_input_vars_limit_check($input_count = 0)
3168
+	{
3169
+		if (! empty($this->php->max_input_vars)
3170
+			&& ($input_count >= $this->php->max_input_vars)
3171
+			&& (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3172
+		) {
3173
+			return sprintf(
3174
+				__(
3175
+					'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3176
+					'event_espresso'
3177
+				),
3178
+				'<br>',
3179
+				$input_count,
3180
+				$this->php->max_input_vars
3181
+			);
3182
+		} else {
3183
+			return '';
3184
+		}
3185
+	}
3186
+
3187
+
3188
+	/**
3189
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3190
+	 *
3191
+	 * @since 4.4.1
3192
+	 * @return void
3193
+	 */
3194
+	public function recheck_values()
3195
+	{
3196
+		$this->_set_php_values();
3197
+	}
3198 3198
 }
3199 3199
 
3200 3200
 /**
@@ -3207,21 +3207,21 @@  discard block
 block discarded – undo
3207 3207
 class EE_Tax_Config extends EE_Config_Base
3208 3208
 {
3209 3209
 
3210
-    /*
3210
+	/*
3211 3211
      * flag to indicate whether or not to display ticket prices with the taxes included
3212 3212
      *
3213 3213
      * @var boolean $prices_displayed_including_taxes
3214 3214
      */
3215
-    public $prices_displayed_including_taxes;
3215
+	public $prices_displayed_including_taxes;
3216 3216
 
3217 3217
 
3218
-    /**
3219
-     *    class constructor
3220
-     */
3221
-    public function __construct()
3222
-    {
3223
-        $this->prices_displayed_including_taxes = true;
3224
-    }
3218
+	/**
3219
+	 *    class constructor
3220
+	 */
3221
+	public function __construct()
3222
+	{
3223
+		$this->prices_displayed_including_taxes = true;
3224
+	}
3225 3225
 }
3226 3226
 
3227 3227
 /**
@@ -3235,19 +3235,19 @@  discard block
 block discarded – undo
3235 3235
 class EE_Messages_Config extends EE_Config_Base
3236 3236
 {
3237 3237
 
3238
-    /**
3239
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3240
-     * A value of 0 represents never deleting.  Default is 0.
3241
-     *
3242
-     * @var integer
3243
-     */
3244
-    public $delete_threshold;
3238
+	/**
3239
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3240
+	 * A value of 0 represents never deleting.  Default is 0.
3241
+	 *
3242
+	 * @var integer
3243
+	 */
3244
+	public $delete_threshold;
3245 3245
 
3246 3246
 
3247
-    public function __construct()
3248
-    {
3249
-        $this->delete_threshold = 0;
3250
-    }
3247
+	public function __construct()
3248
+	{
3249
+		$this->delete_threshold = 0;
3250
+	}
3251 3251
 }
3252 3252
 
3253 3253
 /**
@@ -3258,31 +3258,31 @@  discard block
 block discarded – undo
3258 3258
 class EE_Gateway_Config extends EE_Config_Base
3259 3259
 {
3260 3260
 
3261
-    /**
3262
-     * Array with keys that are payment gateways slugs, and values are arrays
3263
-     * with any config info the gateway wants to store
3264
-     *
3265
-     * @var array
3266
-     */
3267
-    public $payment_settings;
3268
-
3269
-    /**
3270
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3271
-     * the gateway is stored in the uploads directory
3272
-     *
3273
-     * @var array
3274
-     */
3275
-    public $active_gateways;
3276
-
3277
-
3278
-    /**
3279
-     *    class constructor
3280
-     *
3281
-     * @deprecated
3282
-     */
3283
-    public function __construct()
3284
-    {
3285
-        $this->payment_settings = array();
3286
-        $this->active_gateways = array('Invoice' => false);
3287
-    }
3261
+	/**
3262
+	 * Array with keys that are payment gateways slugs, and values are arrays
3263
+	 * with any config info the gateway wants to store
3264
+	 *
3265
+	 * @var array
3266
+	 */
3267
+	public $payment_settings;
3268
+
3269
+	/**
3270
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3271
+	 * the gateway is stored in the uploads directory
3272
+	 *
3273
+	 * @var array
3274
+	 */
3275
+	public $active_gateways;
3276
+
3277
+
3278
+	/**
3279
+	 *    class constructor
3280
+	 *
3281
+	 * @deprecated
3282
+	 */
3283
+	public function __construct()
3284
+	{
3285
+		$this->payment_settings = array();
3286
+		$this->active_gateways = array('Invoice' => false);
3287
+	}
3288 3288
 }
Please login to merge, or discard this patch.
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     public static function instance()
146 146
     {
147 147
         // check if class object is instantiated, and instantiated properly
148
-        if (! self::$_instance instanceof EE_Config) {
148
+        if ( ! self::$_instance instanceof EE_Config) {
149 149
             self::$_instance = new self();
150 150
         }
151 151
         return self::$_instance;
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                 $this
284 284
             );
285 285
             if (is_object($settings) && property_exists($this, $config)) {
286
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
286
+                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
287 287
                 // call configs populate method to ensure any defaults are set for empty values.
288 288
                 if (method_exists($settings, 'populate')) {
289 289
                     $this->{$config}->populate();
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
                         break;
557 557
                     // TEST #2 : check that settings section exists
558 558
                     case 2:
559
-                        if (! isset($this->{$section})) {
559
+                        if ( ! isset($this->{$section})) {
560 560
                             if ($display_errors) {
561 561
                                 throw new EE_Error(
562 562
                                     sprintf(
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
                         break;
571 571
                     // TEST #3 : check that section is the proper format
572 572
                     case 3:
573
-                        if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
573
+                        if ( ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
574 574
                         ) {
575 575
                             if ($display_errors) {
576 576
                                 throw new EE_Error(
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
                         break;
617 617
                     // TEST #6 : verify config class is accessible
618 618
                     case 6:
619
-                        if (! class_exists($config_class)) {
619
+                        if ( ! class_exists($config_class)) {
620 620
                             if ($display_errors) {
621 621
                                 throw new EE_Error(
622 622
                                     sprintf(
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
                         break;
634 634
                     // TEST #7 : check that config has even been set
635 635
                     case 7:
636
-                        if (! isset($this->{$section}->{$name})) {
636
+                        if ( ! isset($this->{$section}->{$name})) {
637 637
                             if ($display_errors) {
638 638
                                 throw new EE_Error(
639 639
                                     sprintf(
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
                         break;
652 652
                     // TEST #8 : check that config is the requested type
653 653
                     case 8:
654
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
654
+                        if ( ! $this->{$section}->{$name} instanceof $config_class) {
655 655
                             if ($display_errors) {
656 656
                                 throw new EE_Error(
657 657
                                     sprintf(
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
                         break;
671 671
                     // TEST #9 : verify config object
672 672
                     case 9:
673
-                        if (! $config_obj instanceof EE_Config_Base) {
673
+                        if ( ! $config_obj instanceof EE_Config_Base) {
674 674
                             if ($display_errors) {
675 675
                                 throw new EE_Error(
676 676
                                     sprintf(
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
      */
703 703
     private function _generate_config_option_name($section = '', $name = '')
704 704
     {
705
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
705
+        return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name));
706 706
     }
707 707
 
708 708
 
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
     {
720 720
         return ! empty($config_class)
721 721
             ? $config_class
722
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
722
+            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config';
723 723
     }
724 724
 
725 725
 
@@ -738,17 +738,17 @@  discard block
 block discarded – undo
738 738
         // ensure config class is set to something
739 739
         $config_class = $this->_set_config_class($config_class, $name);
740 740
         // run tests 1-4, 6, and 7 to verify all config params are set and valid
741
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
741
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
742 742
             return null;
743 743
         }
744 744
         $config_option_name = $this->_generate_config_option_name($section, $name);
745 745
         // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
746
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
747
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
746
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
747
+            $this->_addon_option_names[$config_option_name] = $config_class;
748 748
             $this->update_addon_option_names();
749 749
         }
750 750
         // verify the incoming config object but suppress errors
751
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
751
+        if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
752 752
             $config_obj = new $config_class();
753 753
         }
754 754
         if (get_option($config_option_name)) {
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
         // get class name of the incoming object
796 796
         $config_class = get_class($config_obj);
797 797
         // run tests 1-5 and 9 to verify config
798
-        if (! $this->_verify_config_params(
798
+        if ( ! $this->_verify_config_params(
799 799
             $section,
800 800
             $name,
801 801
             $config_class,
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
         }
808 808
         $config_option_name = $this->_generate_config_option_name($section, $name);
809 809
         // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
810
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
810
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
811 811
             // save new config to db
812 812
             if ($this->set_config($section, $name, $config_class, $config_obj)) {
813 813
                 return true;
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
                             'event_espresso'
834 834
                         ),
835 835
                         $config_class,
836
-                        'EE_Config->' . $section . '->' . $name
836
+                        'EE_Config->'.$section.'->'.$name
837 837
                     ),
838 838
                     __FILE__,
839 839
                     __FUNCTION__,
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
         // ensure config class is set to something
860 860
         $config_class = $this->_set_config_class($config_class, $name);
861 861
         // run tests 1-4, 6 and 7 to verify that all params have been set
862
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
862
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
863 863
             return null;
864 864
         }
865 865
         // now test if the requested config object exists, but suppress errors
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
         // retrieve the wp-option for this config class.
905 905
         $config_option = maybe_unserialize(get_option($config_option_name, array()));
906 906
         if (empty($config_option)) {
907
-            EE_Config::log($config_option_name . '-NOT-FOUND');
907
+            EE_Config::log($config_option_name.'-NOT-FOUND');
908 908
         }
909 909
         return $config_option;
910 910
     }
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
             // copy incoming $_REQUEST and sanitize it so we can save it
923 923
             $_request = $_REQUEST;
924 924
             array_walk_recursive($_request, 'sanitize_text_field');
925
-            $config_log[ (string) microtime(true) ] = array(
925
+            $config_log[(string) microtime(true)] = array(
926 926
                 'config_name' => $config_option_name,
927 927
                 'request'     => $_request,
928 928
             );
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
      */
938 938
     public static function trim_log()
939 939
     {
940
-        if (! EE_Config::logging_enabled()) {
940
+        if ( ! EE_Config::logging_enabled()) {
941 941
             return;
942 942
         }
943 943
         $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
     public static function get_page_for_posts()
962 962
     {
963 963
         $page_for_posts = get_option('page_for_posts');
964
-        if (! $page_for_posts) {
964
+        if ( ! $page_for_posts) {
965 965
             return 'posts';
966 966
         }
967 967
         /** @type WPDB $wpdb */
@@ -1011,20 +1011,20 @@  discard block
 block discarded – undo
1011 1011
     {
1012 1012
         // only init widgets on admin pages when not in complete maintenance, and
1013 1013
         // on frontend when not in any maintenance mode
1014
-        if (! EE_Maintenance_Mode::instance()->level()
1014
+        if ( ! EE_Maintenance_Mode::instance()->level()
1015 1015
             || (
1016 1016
                 is_admin()
1017 1017
                 && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1018 1018
             )
1019 1019
         ) {
1020 1020
             // grab list of installed widgets
1021
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1021
+            $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
1022 1022
             // filter list of modules to register
1023 1023
             $widgets_to_register = apply_filters(
1024 1024
                 'FHEE__EE_Config__register_widgets__widgets_to_register',
1025 1025
                 $widgets_to_register
1026 1026
             );
1027
-            if (! empty($widgets_to_register)) {
1027
+            if ( ! empty($widgets_to_register)) {
1028 1028
                 // cycle thru widget folders
1029 1029
                 foreach ($widgets_to_register as $widget_path) {
1030 1030
                     // add to list of installed widget modules
@@ -1074,31 +1074,31 @@  discard block
 block discarded – undo
1074 1074
         // create classname from widget directory name
1075 1075
         $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1076 1076
         // add class prefix
1077
-        $widget_class = 'EEW_' . $widget;
1077
+        $widget_class = 'EEW_'.$widget;
1078 1078
         // does the widget exist ?
1079
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1079
+        if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) {
1080 1080
             $msg = sprintf(
1081 1081
                 __(
1082 1082
                     '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',
1083 1083
                     'event_espresso'
1084 1084
                 ),
1085 1085
                 $widget_class,
1086
-                $widget_path . DS . $widget_class . $widget_ext
1086
+                $widget_path.DS.$widget_class.$widget_ext
1087 1087
             );
1088
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1088
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1089 1089
             return;
1090 1090
         }
1091 1091
         // load the widget class file
1092
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1092
+        require_once($widget_path.DS.$widget_class.$widget_ext);
1093 1093
         // verify that class exists
1094
-        if (! class_exists($widget_class)) {
1094
+        if ( ! class_exists($widget_class)) {
1095 1095
             $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1096
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1096
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1097 1097
             return;
1098 1098
         }
1099 1099
         register_widget($widget_class);
1100 1100
         // add to array of registered widgets
1101
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1101
+        EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext;
1102 1102
     }
1103 1103
 
1104 1104
 
@@ -1111,18 +1111,18 @@  discard block
 block discarded – undo
1111 1111
     private function _register_modules()
1112 1112
     {
1113 1113
         // grab list of installed modules
1114
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1114
+        $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1115 1115
         // filter list of modules to register
1116 1116
         $modules_to_register = apply_filters(
1117 1117
             'FHEE__EE_Config__register_modules__modules_to_register',
1118 1118
             $modules_to_register
1119 1119
         );
1120
-        if (! empty($modules_to_register)) {
1120
+        if ( ! empty($modules_to_register)) {
1121 1121
             // loop through folders
1122 1122
             foreach ($modules_to_register as $module_path) {
1123 1123
                 /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1124
-                if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1125
-                    && $module_path !== EE_MODULES . 'gateways'
1124
+                if ($module_path !== EE_MODULES.'zzz-copy-this-module-template'
1125
+                    && $module_path !== EE_MODULES.'gateways'
1126 1126
                 ) {
1127 1127
                     // add to list of installed modules
1128 1128
                     EE_Config::register_module($module_path);
@@ -1159,25 +1159,25 @@  discard block
 block discarded – undo
1159 1159
             // remove last segment
1160 1160
             array_pop($module_path);
1161 1161
             // glue it back together
1162
-            $module_path = implode(DS, $module_path) . DS;
1162
+            $module_path = implode(DS, $module_path).DS;
1163 1163
             // take first segment from file name pieces and sanitize it
1164 1164
             $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1165 1165
             // ensure class prefix is added
1166
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1166
+            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1167 1167
         } else {
1168 1168
             // we need to generate the filename based off of the folder name
1169 1169
             // grab and sanitize module name
1170 1170
             $module = strtolower(basename($module_path));
1171 1171
             $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1172 1172
             // like trailingslashit()
1173
-            $module_path = rtrim($module_path, DS) . DS;
1173
+            $module_path = rtrim($module_path, DS).DS;
1174 1174
             // create classname from module directory name
1175 1175
             $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1176 1176
             // add class prefix
1177
-            $module_class = 'EED_' . $module;
1177
+            $module_class = 'EED_'.$module;
1178 1178
         }
1179 1179
         // does the module exist ?
1180
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1180
+        if ( ! is_readable($module_path.DS.$module_class.$module_ext)) {
1181 1181
             $msg = sprintf(
1182 1182
                 __(
1183 1183
                     'The requested %s module file could not be found or is not readable due to file permissions.',
@@ -1185,19 +1185,19 @@  discard block
 block discarded – undo
1185 1185
                 ),
1186 1186
                 $module
1187 1187
             );
1188
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1188
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1189 1189
             return false;
1190 1190
         }
1191 1191
         // load the module class file
1192
-        require_once($module_path . $module_class . $module_ext);
1192
+        require_once($module_path.$module_class.$module_ext);
1193 1193
         // verify that class exists
1194
-        if (! class_exists($module_class)) {
1194
+        if ( ! class_exists($module_class)) {
1195 1195
             $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1196
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1196
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1197 1197
             return false;
1198 1198
         }
1199 1199
         // add to array of registered modules
1200
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1200
+        EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1201 1201
         do_action(
1202 1202
             'AHEE__EE_Config__register_module__complete',
1203 1203
             $module_class,
@@ -1248,26 +1248,26 @@  discard block
 block discarded – undo
1248 1248
     {
1249 1249
         do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1250 1250
         $module = str_replace('EED_', '', $module);
1251
-        $module_class = 'EED_' . $module;
1252
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1251
+        $module_class = 'EED_'.$module;
1252
+        if ( ! isset(EE_Registry::instance()->modules->{$module_class})) {
1253 1253
             $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1254
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1254
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1255 1255
             return false;
1256 1256
         }
1257 1257
         if (empty($route)) {
1258 1258
             $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1259
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1259
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1260 1260
             return false;
1261 1261
         }
1262
-        if (! method_exists('EED_' . $module, $method_name)) {
1262
+        if ( ! method_exists('EED_'.$module, $method_name)) {
1263 1263
             $msg = sprintf(
1264 1264
                 __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1265 1265
                 $route
1266 1266
             );
1267
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1267
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1268 1268
             return false;
1269 1269
         }
1270
-        EE_Config::$_module_route_map[ $key ][ $route ] = array('EED_' . $module, $method_name);
1270
+        EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name);
1271 1271
         return true;
1272 1272
     }
1273 1273
 
@@ -1284,8 +1284,8 @@  discard block
 block discarded – undo
1284 1284
     {
1285 1285
         do_action('AHEE__EE_Config__get_route__begin', $route);
1286 1286
         $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1287
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1288
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1287
+        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1288
+            return EE_Config::$_module_route_map[$key][$route];
1289 1289
         }
1290 1290
         return null;
1291 1291
     }
@@ -1317,47 +1317,47 @@  discard block
 block discarded – undo
1317 1317
     public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1318 1318
     {
1319 1319
         do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1320
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1320
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1321 1321
             $msg = sprintf(
1322 1322
                 __('The module route %s for this forward has not been registered.', 'event_espresso'),
1323 1323
                 $route
1324 1324
             );
1325
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1325
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1326 1326
             return false;
1327 1327
         }
1328 1328
         if (empty($forward)) {
1329 1329
             $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1330
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1330
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1331 1331
             return false;
1332 1332
         }
1333 1333
         if (is_array($forward)) {
1334
-            if (! isset($forward[1])) {
1334
+            if ( ! isset($forward[1])) {
1335 1335
                 $msg = sprintf(
1336 1336
                     __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1337 1337
                     $route
1338 1338
                 );
1339
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1339
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1340 1340
                 return false;
1341 1341
             }
1342
-            if (! method_exists($forward[0], $forward[1])) {
1342
+            if ( ! method_exists($forward[0], $forward[1])) {
1343 1343
                 $msg = sprintf(
1344 1344
                     __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1345 1345
                     $forward[1],
1346 1346
                     $route
1347 1347
                 );
1348
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1348
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1349 1349
                 return false;
1350 1350
             }
1351
-        } elseif (! function_exists($forward)) {
1351
+        } elseif ( ! function_exists($forward)) {
1352 1352
             $msg = sprintf(
1353 1353
                 __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1354 1354
                 $forward,
1355 1355
                 $route
1356 1356
             );
1357
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1357
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1358 1358
             return false;
1359 1359
         }
1360
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1360
+        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1361 1361
         return true;
1362 1362
     }
1363 1363
 
@@ -1375,10 +1375,10 @@  discard block
 block discarded – undo
1375 1375
     public static function get_forward($route = null, $status = 0, $key = 'ee')
1376 1376
     {
1377 1377
         do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1378
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1378
+        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1379 1379
             return apply_filters(
1380 1380
                 'FHEE__EE_Config__get_forward',
1381
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1381
+                EE_Config::$_module_forward_map[$key][$route][$status],
1382 1382
                 $route,
1383 1383
                 $status
1384 1384
             );
@@ -1402,15 +1402,15 @@  discard block
 block discarded – undo
1402 1402
     public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1403 1403
     {
1404 1404
         do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1405
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1405
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1406 1406
             $msg = sprintf(
1407 1407
                 __('The module route %s for this view has not been registered.', 'event_espresso'),
1408 1408
                 $route
1409 1409
             );
1410
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1410
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1411 1411
             return false;
1412 1412
         }
1413
-        if (! is_readable($view)) {
1413
+        if ( ! is_readable($view)) {
1414 1414
             $msg = sprintf(
1415 1415
                 __(
1416 1416
                     'The %s view file could not be found or is not readable due to file permissions.',
@@ -1418,10 +1418,10 @@  discard block
 block discarded – undo
1418 1418
                 ),
1419 1419
                 $view
1420 1420
             );
1421
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1421
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1422 1422
             return false;
1423 1423
         }
1424
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1424
+        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1425 1425
         return true;
1426 1426
     }
1427 1427
 
@@ -1439,10 +1439,10 @@  discard block
 block discarded – undo
1439 1439
     public static function get_view($route = null, $status = 0, $key = 'ee')
1440 1440
     {
1441 1441
         do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1442
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1442
+        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1443 1443
             return apply_filters(
1444 1444
                 'FHEE__EE_Config__get_view',
1445
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1445
+                EE_Config::$_module_view_map[$key][$route][$status],
1446 1446
                 $route,
1447 1447
                 $status
1448 1448
             );
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
     public static function getLegacyShortcodesManager()
1470 1470
     {
1471 1471
 
1472
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1472
+        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1473 1473
             EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1474 1474
                 EE_Registry::instance()
1475 1475
             );
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
      */
1517 1517
     public function get_pretty($property)
1518 1518
     {
1519
-        if (! property_exists($this, $property)) {
1519
+        if ( ! property_exists($this, $property)) {
1520 1520
             throw new EE_Error(
1521 1521
                 sprintf(
1522 1522
                     __(
@@ -1745,11 +1745,11 @@  discard block
 block discarded – undo
1745 1745
      */
1746 1746
     public function reg_page_url()
1747 1747
     {
1748
-        if (! $this->reg_page_url) {
1748
+        if ( ! $this->reg_page_url) {
1749 1749
             $this->reg_page_url = add_query_arg(
1750 1750
                 array('uts' => time()),
1751 1751
                 get_permalink($this->reg_page_id)
1752
-            ) . '#checkout';
1752
+            ).'#checkout';
1753 1753
         }
1754 1754
         return $this->reg_page_url;
1755 1755
     }
@@ -1765,7 +1765,7 @@  discard block
 block discarded – undo
1765 1765
      */
1766 1766
     public function txn_page_url($query_args = array())
1767 1767
     {
1768
-        if (! $this->txn_page_url) {
1768
+        if ( ! $this->txn_page_url) {
1769 1769
             $this->txn_page_url = get_permalink($this->txn_page_id);
1770 1770
         }
1771 1771
         if ($query_args) {
@@ -1786,7 +1786,7 @@  discard block
 block discarded – undo
1786 1786
      */
1787 1787
     public function thank_you_page_url($query_args = array())
1788 1788
     {
1789
-        if (! $this->thank_you_page_url) {
1789
+        if ( ! $this->thank_you_page_url) {
1790 1790
             $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1791 1791
         }
1792 1792
         if ($query_args) {
@@ -1805,7 +1805,7 @@  discard block
 block discarded – undo
1805 1805
      */
1806 1806
     public function cancel_page_url()
1807 1807
     {
1808
-        if (! $this->cancel_page_url) {
1808
+        if ( ! $this->cancel_page_url) {
1809 1809
             $this->cancel_page_url = get_permalink($this->cancel_page_id);
1810 1810
         }
1811 1811
         return $this->cancel_page_url;
@@ -1848,13 +1848,13 @@  discard block
 block discarded – undo
1848 1848
         $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1849 1849
         $option = self::OPTION_NAME_UXIP;
1850 1850
         // set correct table for query
1851
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1851
+        $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options';
1852 1852
         // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1853 1853
         // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1854 1854
         // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1855 1855
         // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1856 1856
         // for the purpose of caching.
1857
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1857
+        $pre = apply_filters('pre_option_'.$option, false, $option);
1858 1858
         if (false !== $pre) {
1859 1859
             EE_Core_Config::$ee_ueip_option = $pre;
1860 1860
             return EE_Core_Config::$ee_ueip_option;
@@ -1868,10 +1868,10 @@  discard block
 block discarded – undo
1868 1868
         if (is_object($row)) {
1869 1869
             $value = $row->option_value;
1870 1870
         } else { // option does not exist so use default.
1871
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1871
+            EE_Core_Config::$ee_ueip_option = apply_filters('default_option_'.$option, false, $option);
1872 1872
             return EE_Core_Config::$ee_ueip_option;
1873 1873
         }
1874
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1874
+        EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option);
1875 1875
         return EE_Core_Config::$ee_ueip_option;
1876 1876
     }
1877 1877
 
@@ -2140,37 +2140,37 @@  discard block
 block discarded – undo
2140 2140
         // but override if requested
2141 2141
         $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2142 2142
         // 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
2143
-        if (! empty($CNT_ISO)
2143
+        if ( ! empty($CNT_ISO)
2144 2144
             && EE_Maintenance_Mode::instance()->models_can_query()
2145 2145
             && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2146 2146
         ) {
2147 2147
             // retrieve the country settings from the db, just in case they have been customized
2148 2148
             $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2149 2149
             if ($country instanceof EE_Country) {
2150
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2151
-                $this->name = $country->currency_name_single();    // Dollar
2152
-                $this->plural = $country->currency_name_plural();    // Dollars
2153
-                $this->sign = $country->currency_sign();            // currency sign: $
2150
+                $this->code = $country->currency_code(); // currency code: USD, CAD, EUR
2151
+                $this->name = $country->currency_name_single(); // Dollar
2152
+                $this->plural = $country->currency_name_plural(); // Dollars
2153
+                $this->sign = $country->currency_sign(); // currency sign: $
2154 2154
                 $this->sign_b4 = $country->currency_sign_before(
2155
-                );        // currency sign before or after: $TRUE  or  FALSE$
2156
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2155
+                ); // currency sign before or after: $TRUE  or  FALSE$
2156
+                $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
2157 2157
                 $this->dec_mrk = $country->currency_decimal_mark(
2158
-                );    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2158
+                ); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2159 2159
                 $this->thsnds = $country->currency_thousands_separator(
2160
-                );    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2160
+                ); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2161 2161
             }
2162 2162
         }
2163 2163
         // fallback to hardcoded defaults, in case the above failed
2164 2164
         if (empty($this->code)) {
2165 2165
             // set default currency settings
2166
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2167
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2168
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2169
-            $this->sign = '$';    // currency sign: $
2170
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2171
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2172
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2173
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2166
+            $this->code = 'USD'; // currency code: USD, CAD, EUR
2167
+            $this->name = __('Dollar', 'event_espresso'); // Dollar
2168
+            $this->plural = __('Dollars', 'event_espresso'); // Dollars
2169
+            $this->sign = '$'; // currency sign: $
2170
+            $this->sign_b4 = true; // currency sign before or after: $TRUE  or  FALSE$
2171
+            $this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
2172
+            $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2173
+            $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2174 2174
         }
2175 2175
     }
2176 2176
 }
@@ -2429,8 +2429,8 @@  discard block
 block discarded – undo
2429 2429
             $closing_a_tag = '';
2430 2430
             if (function_exists('get_privacy_policy_url')) {
2431 2431
                 $privacy_page_url = get_privacy_policy_url();
2432
-                if (! empty($privacy_page_url)) {
2433
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2432
+                if ( ! empty($privacy_page_url)) {
2433
+                    $opening_a_tag = '<a href="'.$privacy_page_url.'" target="_blank">';
2434 2434
                     $closing_a_tag = '</a>';
2435 2435
                 }
2436 2436
             }
@@ -2642,7 +2642,7 @@  discard block
 block discarded – undo
2642 2642
     public function log_file_name($reset = false)
2643 2643
     {
2644 2644
         if (empty($this->log_file_name) || $reset) {
2645
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2645
+            $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt';
2646 2646
             EE_Config::instance()->update_espresso_config(false, false);
2647 2647
         }
2648 2648
         return $this->log_file_name;
@@ -2656,7 +2656,7 @@  discard block
 block discarded – undo
2656 2656
     public function debug_file_name($reset = false)
2657 2657
     {
2658 2658
         if (empty($this->debug_file_name) || $reset) {
2659
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2659
+            $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt';
2660 2660
             EE_Config::instance()->update_espresso_config(false, false);
2661 2661
         }
2662 2662
         return $this->debug_file_name;
@@ -2860,21 +2860,21 @@  discard block
 block discarded – undo
2860 2860
         $this->use_google_maps = true;
2861 2861
         $this->google_map_api_key = '';
2862 2862
         // for event details pages (reg page)
2863
-        $this->event_details_map_width = 585;            // ee_map_width_single
2864
-        $this->event_details_map_height = 362;            // ee_map_height_single
2865
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2866
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2867
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2868
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2869
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2863
+        $this->event_details_map_width = 585; // ee_map_width_single
2864
+        $this->event_details_map_height = 362; // ee_map_height_single
2865
+        $this->event_details_map_zoom = 14; // ee_map_zoom_single
2866
+        $this->event_details_display_nav = true; // ee_map_nav_display_single
2867
+        $this->event_details_nav_size = false; // ee_map_nav_size_single
2868
+        $this->event_details_control_type = 'default'; // ee_map_type_control_single
2869
+        $this->event_details_map_align = 'center'; // ee_map_align_single
2870 2870
         // for event list pages
2871
-        $this->event_list_map_width = 300;            // ee_map_width
2872
-        $this->event_list_map_height = 185;        // ee_map_height
2873
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2874
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2875
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2876
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2877
-        $this->event_list_map_align = 'center';            // ee_map_align
2871
+        $this->event_list_map_width = 300; // ee_map_width
2872
+        $this->event_list_map_height = 185; // ee_map_height
2873
+        $this->event_list_map_zoom = 12; // ee_map_zoom
2874
+        $this->event_list_display_nav = false; // ee_map_nav_display
2875
+        $this->event_list_nav_size = true; // ee_map_nav_size
2876
+        $this->event_list_control_type = 'dropdown'; // ee_map_type_control
2877
+        $this->event_list_map_align = 'center'; // ee_map_align
2878 2878
     }
2879 2879
 }
2880 2880
 
@@ -3166,7 +3166,7 @@  discard block
 block discarded – undo
3166 3166
      */
3167 3167
     public function max_input_vars_limit_check($input_count = 0)
3168 3168
     {
3169
-        if (! empty($this->php->max_input_vars)
3169
+        if ( ! empty($this->php->max_input_vars)
3170 3170
             && ($input_count >= $this->php->max_input_vars)
3171 3171
             && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3172 3172
         ) {
Please login to merge, or discard this patch.