Completed
Branch master (16aff5)
by
unknown
03:42
created
espresso.php 1 patch
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -37,138 +37,138 @@
 block discarded – undo
37 37
  * @since           4.0
38 38
  */
39 39
 if (function_exists('espresso_version')) {
40
-    if (! function_exists('espresso_duplicate_plugin_error')) {
41
-        /**
42
-         *    espresso_duplicate_plugin_error
43
-         *    displays if more than one version of EE is activated at the same time.
44
-         */
45
-        function espresso_duplicate_plugin_error()
46
-        {
47
-            ?>
40
+	if (! function_exists('espresso_duplicate_plugin_error')) {
41
+		/**
42
+		 *    espresso_duplicate_plugin_error
43
+		 *    displays if more than one version of EE is activated at the same time.
44
+		 */
45
+		function espresso_duplicate_plugin_error()
46
+		{
47
+			?>
48 48
 <div class="error">
49 49
 	<p>
50 50
 		<?php
51
-                    echo esc_html__(
52
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
53
-                        'event_espresso'
54
-                    ); ?>
51
+					echo esc_html__(
52
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
53
+						'event_espresso'
54
+					); ?>
55 55
 	</p>
56 56
 </div>
57 57
 <?php
58
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
59
-        }
60
-    }
61
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
58
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
59
+		}
60
+	}
61
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62 62
 } else {
63
-    define('EE_MIN_PHP_VER_REQUIRED', '7.4.0');
64
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
65
-        /**
66
-         * espresso_minimum_php_version_error
67
-         *
68
-         * @return void
69
-         */
70
-        function espresso_minimum_php_version_error()
71
-        {
72
-            ?>
63
+	define('EE_MIN_PHP_VER_REQUIRED', '7.4.0');
64
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
65
+		/**
66
+		 * espresso_minimum_php_version_error
67
+		 *
68
+		 * @return void
69
+		 */
70
+		function espresso_minimum_php_version_error()
71
+		{
72
+			?>
73 73
 <div class="error">
74 74
 	<p>
75 75
 		<?php
76
-                    printf(
77
-                        esc_html__(
78
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
79
-                            'event_espresso'
80
-                        ),
81
-                        EE_MIN_PHP_VER_REQUIRED,
82
-                        PHP_VERSION,
83
-                        '<br/>',
84
-                        '<a href="https://www.php.net/downloads.php">https://php.net/downloads.php</a>'
85
-                    );
86
-                    ?>
76
+					printf(
77
+						esc_html__(
78
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
79
+							'event_espresso'
80
+						),
81
+						EE_MIN_PHP_VER_REQUIRED,
82
+						PHP_VERSION,
83
+						'<br/>',
84
+						'<a href="https://www.php.net/downloads.php">https://php.net/downloads.php</a>'
85
+					);
86
+					?>
87 87
 	</p>
88 88
 </div>
89 89
 <?php
90
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
91
-        }
90
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
91
+		}
92 92
 
93
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
94
-    } else {
95
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
93
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
94
+	} else {
95
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
96 96
 
97
-        require_once __DIR__ . '/vendor/autoload.php';
97
+		require_once __DIR__ . '/vendor/autoload.php';
98 98
 
99
-        /**
100
-         * espresso_version
101
-         * Returns the plugin version
102
-         *
103
-         * @return string
104
-         */
105
-        function espresso_version(): string
106
-        {
107
-            return apply_filters('FHEE__espresso__espresso_version', '5.0.18.rc.000');
108
-        }
99
+		/**
100
+		 * espresso_version
101
+		 * Returns the plugin version
102
+		 *
103
+		 * @return string
104
+		 */
105
+		function espresso_version(): string
106
+		{
107
+			return apply_filters('FHEE__espresso__espresso_version', '5.0.18.rc.000');
108
+		}
109 109
 
110
-        /**
111
-         * espresso_plugin_activation
112
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
113
-         */
114
-        function espresso_plugin_activation()
115
-        {
116
-            update_option('ee_espresso_activation', true);
117
-            update_option('event-espresso-core_allow_tracking', 'no');
118
-            update_option('event-espresso-core_tracking_notice', 'hide');
119
-            // Run WP GraphQL activation callback
120
-            espressoLoadWpGraphQL();
121
-            graphql_activation_callback();
122
-        }
110
+		/**
111
+		 * espresso_plugin_activation
112
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
113
+		 */
114
+		function espresso_plugin_activation()
115
+		{
116
+			update_option('ee_espresso_activation', true);
117
+			update_option('event-espresso-core_allow_tracking', 'no');
118
+			update_option('event-espresso-core_tracking_notice', 'hide');
119
+			// Run WP GraphQL activation callback
120
+			espressoLoadWpGraphQL();
121
+			graphql_activation_callback();
122
+		}
123 123
 
124
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
124
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
125 125
 
126
-        /**
127
-         * espresso_plugin_deactivation
128
-         */
129
-        function espresso_plugin_deactivation()
130
-        {
131
-            // Run WP GraphQL deactivation callback
132
-            espressoLoadWpGraphQL();
133
-            graphql_deactivation_callback();
134
-            delete_option('event-espresso-core_allow_tracking');
135
-            delete_option('event-espresso-core_tracking_notice');
136
-        }
137
-        register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
126
+		/**
127
+		 * espresso_plugin_deactivation
128
+		 */
129
+		function espresso_plugin_deactivation()
130
+		{
131
+			// Run WP GraphQL deactivation callback
132
+			espressoLoadWpGraphQL();
133
+			graphql_deactivation_callback();
134
+			delete_option('event-espresso-core_allow_tracking');
135
+			delete_option('event-espresso-core_tracking_notice');
136
+		}
137
+		register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
138 138
 
139
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
140
-        bootstrap_espresso();
141
-    }
139
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
140
+		bootstrap_espresso();
141
+	}
142 142
 }
143 143
 
144 144
 if (! function_exists('espresso_deactivate_plugin')) {
145
-    /**
146
-     *    deactivate_plugin
147
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
148
-     *
149
-     * @access public
150
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
151
-     * @return    void
152
-     */
153
-    function espresso_deactivate_plugin(string $plugin_basename = '')
154
-    {
155
-        if (! function_exists('deactivate_plugins')) {
156
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
157
-        }
158
-        unset($_GET['activate'], $_REQUEST['activate']);
159
-        deactivate_plugins($plugin_basename);
160
-    }
145
+	/**
146
+	 *    deactivate_plugin
147
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
148
+	 *
149
+	 * @access public
150
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
151
+	 * @return    void
152
+	 */
153
+	function espresso_deactivate_plugin(string $plugin_basename = '')
154
+	{
155
+		if (! function_exists('deactivate_plugins')) {
156
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
157
+		}
158
+		unset($_GET['activate'], $_REQUEST['activate']);
159
+		deactivate_plugins($plugin_basename);
160
+	}
161 161
 }
162 162
 
163 163
 
164 164
 if (! function_exists('espressoLoadWpGraphQL')) {
165
-    function espressoLoadWpGraphQL()
166
-    {
167
-        if (
168
-            ! class_exists('WPGraphQL')
169
-            && is_readable(__DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php')
170
-        ) {
171
-            require_once __DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php';
172
-        }
173
-    }
165
+	function espressoLoadWpGraphQL()
166
+	{
167
+		if (
168
+			! class_exists('WPGraphQL')
169
+			&& is_readable(__DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php')
170
+		) {
171
+			require_once __DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php';
172
+		}
173
+	}
174 174
 }
Please login to merge, or discard this patch.
core/EE_Config.core.php 1 patch
Indentation   +3221 added lines, -3221 removed lines patch added patch discarded remove patch
@@ -20,2601 +20,2601 @@  discard block
 block discarded – undo
20 20
  */
21 21
 final class EE_Config implements ResettableInterface
22 22
 {
23
-    const OPTION_NAME = 'ee_config';
24
-
25
-    const LOG_NAME = 'ee_config_log';
26
-
27
-    const LOG_LENGTH = 100;
28
-
29
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
30
-
31
-    /**
32
-     *    instance of the EE_Config object
33
-     *
34
-     * @var    EE_Config $_instance
35
-     * @access    private
36
-     */
37
-    private static $_instance;
38
-
39
-    /**
40
-     * @var boolean $_logging_enabled
41
-     */
42
-    private static $_logging_enabled = false;
43
-
44
-    /**
45
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
46
-     */
47
-    private $legacy_shortcodes_manager;
48
-
49
-    /**
50
-     * An StdClass whose property names are addon slugs,
51
-     * and values are their config classes
52
-     *
53
-     * @var StdClass
54
-     */
55
-    public $addons;
56
-
57
-    /**
58
-     * @var EE_Admin_Config
59
-     */
60
-    public $admin;
61
-
62
-    /**
63
-     * @var EE_Core_Config
64
-     */
65
-    public $core;
66
-
67
-    /**
68
-     * @var EE_Currency_Config
69
-     */
70
-    public $currency;
71
-
72
-    /**
73
-     * @var EE_Organization_Config
74
-     */
75
-    public $organization;
76
-
77
-    /**
78
-     * @var EE_Registration_Config
79
-     */
80
-    public $registration;
81
-
82
-    /**
83
-     * @var EE_Template_Config
84
-     */
85
-    public $template_settings;
86
-
87
-    /**
88
-     * Holds EE environment values.
89
-     *
90
-     * @var EE_Environment_Config
91
-     */
92
-    public $environment;
93
-
94
-    /**
95
-     * settings pertaining to Google maps
96
-     *
97
-     * @var EE_Map_Config
98
-     */
99
-    public $map_settings;
100
-
101
-    /**
102
-     * settings pertaining to Taxes
103
-     *
104
-     * @var EE_Tax_Config
105
-     */
106
-    public $tax_settings;
107
-
108
-    /**
109
-     * Settings pertaining to global messages settings.
110
-     *
111
-     * @var EE_Messages_Config
112
-     */
113
-    public $messages;
114
-
115
-    /**
116
-     * @deprecated
117
-     * @var EE_Gateway_Config
118
-     */
119
-    public $gateway;
120
-
121
-    /**
122
-     * @var array
123
-     */
124
-    private $_addon_option_names = array();
125
-
126
-    /**
127
-     * @var array
128
-     */
129
-    private static $_module_route_map = array();
130
-
131
-    /**
132
-     * @var array
133
-     */
134
-    private static $_module_forward_map = array();
135
-
136
-    /**
137
-     * @var array
138
-     */
139
-    private static $_module_view_map = array();
140
-
141
-    /**
142
-     * @var bool
143
-     */
144
-    private static $initialized = false;
145
-
146
-
147
-    /**
148
-     * @singleton method used to instantiate class object
149
-     * @access    public
150
-     * @return EE_Config instance
151
-     */
152
-    public static function instance()
153
-    {
154
-        // check if class object is instantiated, and instantiated properly
155
-        if (! self::$_instance instanceof EE_Config) {
156
-            self::$_instance = new self();
157
-        }
158
-        return self::$_instance;
159
-    }
160
-
161
-
162
-    /**
163
-     * Resets the config
164
-     *
165
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
166
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
167
-     *                               reflect its state in the database
168
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
169
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
170
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
171
-     *                               site was put into maintenance mode)
172
-     * @return EE_Config
173
-     */
174
-    public static function reset($hard_reset = false, $reinstantiate = true)
175
-    {
176
-        if (self::$_instance instanceof EE_Config) {
177
-            if ($hard_reset) {
178
-                self::$_instance->legacy_shortcodes_manager = null;
179
-                self::$_instance->_addon_option_names = array();
180
-                self::$_instance->_initialize_config();
181
-                self::$_instance->update_espresso_config();
182
-            }
183
-            self::$_instance->update_addon_option_names();
184
-        }
185
-        self::$_instance = null;
186
-        self::$initialized = false;
187
-        // we don't need to reset the static properties imo because those should
188
-        // only change when a module is added or removed. Currently we don't
189
-        // support removing a module during a request when it previously existed
190
-        if ($reinstantiate) {
191
-            return self::instance();
192
-        } else {
193
-            return null;
194
-        }
195
-    }
196
-
197
-
198
-    private function __construct()
199
-    {
200
-        if (self::$initialized) {
201
-            return;
202
-        }
203
-        self::$initialized = true;
204
-        do_action('AHEE__EE_Config__construct__begin', $this);
205
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
206
-        // setup empty config classes
207
-        $this->_initialize_config();
208
-        // load existing EE site settings
209
-        $this->_load_core_config();
210
-        // confirm everything loaded correctly and set filtered defaults if not
211
-        $this->_verify_config();
212
-        //  register shortcodes and modules
213
-        add_action(
214
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
215
-            [$this, 'register_shortcodes_and_modules'],
216
-            999
217
-        );
218
-        //  initialize shortcodes and modules
219
-        add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'initialize_shortcodes_and_modules']);
220
-        // register widgets
221
-        add_action('widgets_init', [$this, 'widgets_init'], 10);
222
-        // shutdown
223
-        add_action('shutdown', [$this, 'shutdown'], 10);
224
-        // construct__end hook
225
-        do_action('AHEE__EE_Config__construct__end', $this);
226
-        // hardcoded hack
227
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
228
-    }
229
-
230
-
231
-    /**
232
-     * @return boolean
233
-     */
234
-    public static function logging_enabled()
235
-    {
236
-        return self::$_logging_enabled;
237
-    }
238
-
239
-
240
-    /**
241
-     * use to get the current theme if needed from static context
242
-     *
243
-     * @return string current theme set.
244
-     */
245
-    public static function get_current_theme()
246
-    {
247
-        return self::$_instance->template_settings->current_espresso_theme ?? 'Espresso_Arabica_2014';
248
-    }
249
-
250
-
251
-    /**
252
-     *        _initialize_config
253
-     *
254
-     * @access private
255
-     * @return void
256
-     */
257
-    private function _initialize_config()
258
-    {
259
-        EE_Config::trim_log();
260
-        // set defaults
261
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
262
-        $this->addons = new stdClass();
263
-        // set _module_route_map
264
-        EE_Config::$_module_route_map = array();
265
-        // set _module_forward_map
266
-        EE_Config::$_module_forward_map = array();
267
-        // set _module_view_map
268
-        EE_Config::$_module_view_map = array();
269
-    }
270
-
271
-
272
-    /**
273
-     *        load core plugin configuration
274
-     *
275
-     * @access private
276
-     * @return void
277
-     */
278
-    private function _load_core_config()
279
-    {
280
-        // load_core_config__start hook
281
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
282
-        $espresso_config = (array) $this->get_espresso_config();
283
-        // need to move the "addons" element to the end of the config array
284
-        // in case an addon config references one of the other config classes
285
-        $addons = $espresso_config['addons'] ?? new StdClass();
286
-        unset($espresso_config['addons']);
287
-        $espresso_config['addons'] = $addons;
288
-        foreach ($espresso_config as $config => $settings) {
289
-            // load_core_config__start hook
290
-            $settings = apply_filters(
291
-                'FHEE__EE_Config___load_core_config__config_settings',
292
-                $settings,
293
-                $config,
294
-                $this
295
-            );
296
-            if (is_object($settings) && property_exists($this, $config)) {
297
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
298
-                // call configs populate method to ensure any defaults are set for empty values.
299
-                if (method_exists($settings, 'populate')) {
300
-                    $this->{$config}->populate();
301
-                }
302
-                if (method_exists($settings, 'do_hooks')) {
303
-                    $this->{$config}->do_hooks();
304
-                }
305
-            }
306
-        }
307
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
308
-            $this->update_espresso_config();
309
-        }
310
-        // load_core_config__end hook
311
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
312
-    }
313
-
314
-
315
-    /**
316
-     *    _verify_config
317
-     *
318
-     * @access    protected
319
-     * @return    void
320
-     */
321
-    protected function _verify_config()
322
-    {
323
-        $this->core = $this->core instanceof EE_Core_Config
324
-            ? $this->core
325
-            : new EE_Core_Config();
326
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
327
-        $this->organization = $this->organization instanceof EE_Organization_Config
328
-            ? $this->organization
329
-            : new EE_Organization_Config();
330
-        $this->organization = apply_filters(
331
-            'FHEE__EE_Config___initialize_config__organization',
332
-            $this->organization
333
-        );
334
-        $this->currency = $this->currency instanceof EE_Currency_Config
335
-            ? $this->currency
336
-            : new EE_Currency_Config();
337
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
338
-        $this->registration = $this->registration instanceof EE_Registration_Config
339
-            ? $this->registration
340
-            : new EE_Registration_Config();
341
-        $this->registration = apply_filters(
342
-            'FHEE__EE_Config___initialize_config__registration',
343
-            $this->registration
344
-        );
345
-        $this->admin = $this->admin instanceof EE_Admin_Config
346
-            ? $this->admin
347
-            : new EE_Admin_Config();
348
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
349
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
350
-            ? $this->template_settings
351
-            : new EE_Template_Config();
352
-        $this->template_settings = apply_filters(
353
-            'FHEE__EE_Config___initialize_config__template_settings',
354
-            $this->template_settings
355
-        );
356
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
357
-            ? $this->map_settings
358
-            : new EE_Map_Config();
359
-        $this->map_settings = apply_filters(
360
-            'FHEE__EE_Config___initialize_config__map_settings',
361
-            $this->map_settings
362
-        );
363
-        $this->environment = $this->environment instanceof EE_Environment_Config
364
-            ? $this->environment
365
-            : new EE_Environment_Config();
366
-        $this->environment = apply_filters(
367
-            'FHEE__EE_Config___initialize_config__environment',
368
-            $this->environment
369
-        );
370
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
371
-            ? $this->tax_settings
372
-            : new EE_Tax_Config();
373
-        $this->tax_settings = apply_filters(
374
-            'FHEE__EE_Config___initialize_config__tax_settings',
375
-            $this->tax_settings
376
-        );
377
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
378
-        $this->messages = $this->messages instanceof EE_Messages_Config
379
-            ? $this->messages
380
-            : new EE_Messages_Config();
381
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
382
-            ? $this->gateway
383
-            : new EE_Gateway_Config();
384
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
385
-        $this->legacy_shortcodes_manager = null;
386
-    }
387
-
388
-
389
-    /**
390
-     *    get_espresso_config
391
-     *
392
-     * @access    public
393
-     * @return    array of espresso config stuff
394
-     */
395
-    public function get_espresso_config()
396
-    {
397
-        // grab espresso configuration
398
-        return apply_filters(
399
-            'FHEE__EE_Config__get_espresso_config__CFG',
400
-            get_option(EE_Config::OPTION_NAME, array())
401
-        );
402
-    }
403
-
404
-
405
-    /**
406
-     *    double_check_config_comparison
407
-     *
408
-     * @access    public
409
-     * @param string $option
410
-     * @param        $old_value
411
-     * @param        $value
412
-     */
413
-    public function double_check_config_comparison($option, $old_value, $value)
414
-    {
415
-        // make sure we're checking the ee config
416
-        if ($option === EE_Config::OPTION_NAME) {
417
-            // run a loose comparison of the old value against the new value for type and properties,
418
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
419
-            if ($value != $old_value) {
420
-                // if they are NOT the same, then remove the hook,
421
-                // which means the subsequent update results will be based solely on the update query results
422
-                // the reason we do this is because, as stated above,
423
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
424
-                // this happens PRIOR to serialization and any subsequent update.
425
-                // If values are found to match their previous old value,
426
-                // then WP bails before performing any update.
427
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
428
-                // it just pulled from the db, with the one being passed to it (which will not match).
429
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
430
-                // MySQL MAY ALSO NOT perform the update because
431
-                // the string it sees in the db looks the same as the new one it has been passed!!!
432
-                // This results in the query returning an "affected rows" value of ZERO,
433
-                // which gets returned immediately by WP update_option and looks like an error.
434
-                remove_action('update_option', array($this, 'check_config_updated'));
435
-            }
436
-        }
437
-    }
438
-
439
-
440
-    /**
441
-     *    update_espresso_config
442
-     *
443
-     * @access   public
444
-     */
445
-    protected function _reset_espresso_addon_config()
446
-    {
447
-        $this->_addon_option_names = array();
448
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
449
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
450
-            if ($addon_config_obj instanceof EE_Config_Base) {
451
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
452
-            }
453
-            $this->addons->{$addon_name} = null;
454
-        }
455
-    }
456
-
457
-
458
-    /**
459
-     *    update_espresso_config
460
-     *
461
-     * @access   public
462
-     * @param   bool $add_success
463
-     * @param   bool $add_error
464
-     * @return   bool
465
-     */
466
-    public function update_espresso_config($add_success = false, $add_error = true)
467
-    {
468
-        // don't allow config updates during WP heartbeats
469
-        /** @var RequestInterface $request */
470
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
471
-        if ($request->isWordPressHeartbeat()) {
472
-            return false;
473
-        }
474
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
475
-        // $clone = clone( self::$_instance );
476
-        // self::$_instance = NULL;
477
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
478
-        $this->_reset_espresso_addon_config();
479
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
480
-        // but BEFORE the actual update occurs
481
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
482
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
483
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
484
-        $this->legacy_shortcodes_manager = null;
485
-        // now update "ee_config"
486
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
487
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
488
-        EE_Config::log(EE_Config::OPTION_NAME);
489
-        // if not saved... check if the hook we just added still exists;
490
-        // if it does, it means one of two things:
491
-        // that update_option bailed at the($value === $old_value) conditional,
492
-        // or...
493
-        // the db update query returned 0 rows affected
494
-        // (probably because the data  value was the same from its perspective)
495
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
496
-        // but just means no update occurred, so don't display an error to the user.
497
-        // BUT... if update_option returns FALSE, AND the hook is missing,
498
-        // then it means that something truly went wrong
499
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
500
-        // remove our action since we don't want it in the system anymore
501
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
502
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
503
-        // self::$_instance = $clone;
504
-        // unset( $clone );
505
-        // if config remains the same or was updated successfully
506
-        if ($saved) {
507
-            if ($add_success) {
508
-                EE_Error::add_success(
509
-                    esc_html__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
510
-                    __FILE__,
511
-                    __FUNCTION__,
512
-                    __LINE__
513
-                );
514
-            }
515
-            return true;
516
-        } else {
517
-            if ($add_error) {
518
-                EE_Error::add_error(
519
-                    esc_html__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
520
-                    __FILE__,
521
-                    __FUNCTION__,
522
-                    __LINE__
523
-                );
524
-            }
525
-            return false;
526
-        }
527
-    }
528
-
529
-
530
-    /**
531
-     *    _verify_config_params
532
-     *
533
-     * @access    private
534
-     * @param    string         $section
535
-     * @param    string         $name
536
-     * @param    string         $config_class
537
-     * @param    EE_Config_Base $config_obj
538
-     * @param    array          $tests_to_run
539
-     * @param    bool           $display_errors
540
-     * @return    bool    TRUE on success, FALSE on fail
541
-     */
542
-    private function _verify_config_params(
543
-        $section = '',
544
-        $name = '',
545
-        $config_class = '',
546
-        $config_obj = null,
547
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
548
-        $display_errors = true
549
-    ) {
550
-        try {
551
-            foreach ($tests_to_run as $test) {
552
-                switch ($test) {
553
-                    // TEST #1 : check that section was set
554
-                    case 1:
555
-                        if (empty($section)) {
556
-                            if ($display_errors) {
557
-                                throw new EE_Error(
558
-                                    sprintf(
559
-                                        esc_html__(
560
-                                            'No configuration section has been provided while attempting to save "%s".',
561
-                                            'event_espresso'
562
-                                        ),
563
-                                        $config_class
564
-                                    )
565
-                                );
566
-                            }
567
-                            return false;
568
-                        }
569
-                        break;
570
-                    // TEST #2 : check that settings section exists
571
-                    case 2:
572
-                        if (! isset($this->{$section})) {
573
-                            if ($display_errors) {
574
-                                throw new EE_Error(
575
-                                    sprintf(
576
-                                        esc_html__('The "%s" configuration section does not exist.', 'event_espresso'),
577
-                                        $section
578
-                                    )
579
-                                );
580
-                            }
581
-                            return false;
582
-                        }
583
-                        break;
584
-                    // TEST #3 : check that section is the proper format
585
-                    case 3:
586
-                        if (
587
-                            ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
588
-                        ) {
589
-                            if ($display_errors) {
590
-                                throw new EE_Error(
591
-                                    sprintf(
592
-                                        esc_html__(
593
-                                            'The "%s" configuration settings have not been formatted correctly.',
594
-                                            'event_espresso'
595
-                                        ),
596
-                                        $section
597
-                                    )
598
-                                );
599
-                            }
600
-                            return false;
601
-                        }
602
-                        break;
603
-                    // TEST #4 : check that config section name has been set
604
-                    case 4:
605
-                        if (empty($name)) {
606
-                            if ($display_errors) {
607
-                                throw new EE_Error(
608
-                                    esc_html__(
609
-                                        'No name has been provided for the specific configuration section.',
610
-                                        'event_espresso'
611
-                                    )
612
-                                );
613
-                            }
614
-                            return false;
615
-                        }
616
-                        break;
617
-                    // TEST #5 : check that a config class name has been set
618
-                    case 5:
619
-                        if (empty($config_class)) {
620
-                            if ($display_errors) {
621
-                                throw new EE_Error(
622
-                                    esc_html__(
623
-                                        'No class name has been provided for the specific configuration section.',
624
-                                        'event_espresso'
625
-                                    )
626
-                                );
627
-                            }
628
-                            return false;
629
-                        }
630
-                        break;
631
-                    // TEST #6 : verify config class is accessible
632
-                    case 6:
633
-                        if (! class_exists($config_class)) {
634
-                            if ($display_errors) {
635
-                                throw new EE_Error(
636
-                                    sprintf(
637
-                                        esc_html__(
638
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
639
-                                            'event_espresso'
640
-                                        ),
641
-                                        $config_class
642
-                                    )
643
-                                );
644
-                            }
645
-                            return false;
646
-                        }
647
-                        break;
648
-                    // TEST #7 : check that config has even been set
649
-                    case 7:
650
-                        if (! isset($this->{$section}->{$name})) {
651
-                            if ($display_errors) {
652
-                                throw new EE_Error(
653
-                                    sprintf(
654
-                                        esc_html__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
655
-                                        $section,
656
-                                        $name
657
-                                    )
658
-                                );
659
-                            }
660
-                            return false;
661
-                        } else {
662
-                            // and make sure it's not serialized
663
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
664
-                        }
665
-                        break;
666
-                    // TEST #8 : check that config is the requested type
667
-                    case 8:
668
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
669
-                            if ($display_errors) {
670
-                                throw new EE_Error(
671
-                                    sprintf(
672
-                                        esc_html__(
673
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
674
-                                            'event_espresso'
675
-                                        ),
676
-                                        $section,
677
-                                        $name,
678
-                                        $config_class
679
-                                    )
680
-                                );
681
-                            }
682
-                            return false;
683
-                        }
684
-                        break;
685
-                    // TEST #9 : verify config object
686
-                    case 9:
687
-                        if (! $config_obj instanceof EE_Config_Base) {
688
-                            if ($display_errors) {
689
-                                throw new EE_Error(
690
-                                    sprintf(
691
-                                        esc_html__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
692
-                                        print_r($config_obj, true)
693
-                                    )
694
-                                );
695
-                            }
696
-                            return false;
697
-                        }
698
-                        break;
699
-                }
700
-            }
701
-        } catch (EE_Error $e) {
702
-            $e->get_error();
703
-        }
704
-        // you have successfully run the gauntlet
705
-        return true;
706
-    }
707
-
708
-
709
-    /**
710
-     *    _generate_config_option_name
711
-     *
712
-     * @access        protected
713
-     * @param        string $section
714
-     * @param        string $name
715
-     * @return        string
716
-     */
717
-    private function _generate_config_option_name($section = '', $name = '')
718
-    {
719
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
720
-    }
721
-
722
-
723
-    /**
724
-     *    _set_config_class
725
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
726
-     *
727
-     * @access    private
728
-     * @param    string $config_class
729
-     * @param    string $name
730
-     * @return    string
731
-     */
732
-    private function _set_config_class($config_class = '', $name = '')
733
-    {
734
-        return ! empty($config_class)
735
-            ? $config_class
736
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
737
-    }
738
-
739
-
740
-    /**
741
-     * @param string              $section
742
-     * @param string              $name
743
-     * @param string              $config_class
744
-     * @param EE_Config_Base|null $config_obj
745
-     * @return EE_Config_Base
746
-     */
747
-    public function set_config(
748
-        string $section = '',
749
-        string $name = '',
750
-        string $config_class = '',
751
-        EE_Config_Base $config_obj = null
752
-    ): ?EE_Config_Base {
753
-        // ensure config class is set to something
754
-        $config_class = $this->_set_config_class($config_class, $name);
755
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
756
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
757
-            return null;
758
-        }
759
-        $config_option_name = $this->_generate_config_option_name($section, $name);
760
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
761
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
762
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
763
-            $this->update_addon_option_names();
764
-        }
765
-        // verify the incoming config object but suppress errors
766
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
767
-            $config_obj = new $config_class();
768
-        }
769
-        if (get_option($config_option_name)) {
770
-            EE_Config::log($config_option_name);
771
-            try {
772
-                update_option($config_option_name, $config_obj);
773
-            } catch (Exception $exception) {
774
-                throw new DomainException(
775
-                    sprintf(
776
-                        esc_html__(
777
-                            'The following exception occurred while attempting to update the "%1$s" class for config section "%2$s->%3$s": %4$s',
778
-                            'event_espresso'
779
-                        ),
780
-                        $config_class,
781
-                        $section,
782
-                        $name,
783
-                        $exception->getMessage()
784
-                    )
785
-                );
786
-            }
787
-            $this->{$section}->{$name} = $config_obj;
788
-            return $this->{$section}->{$name};
789
-        } else {
790
-            // create a wp-option for this config
791
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
792
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
793
-                return $this->{$section}->{$name};
794
-            } else {
795
-                EE_Error::add_error(
796
-                    sprintf(esc_html__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
797
-                    __FILE__,
798
-                    __FUNCTION__,
799
-                    __LINE__
800
-                );
801
-                return null;
802
-            }
803
-        }
804
-    }
805
-
806
-
807
-    /**
808
-     *    update_config
809
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
810
-     *
811
-     * @access    public
812
-     * @param    string                $section
813
-     * @param    string                $name
814
-     * @param    EE_Config_Base|string $config_obj
815
-     * @param    bool                  $throw_errors
816
-     * @return    bool
817
-     */
818
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
819
-    {
820
-        // don't allow config updates during WP heartbeats
821
-        /** @var RequestInterface $request */
822
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
823
-        if ($request->isWordPressHeartbeat()) {
824
-            return false;
825
-        }
826
-        $config_obj = maybe_unserialize($config_obj);
827
-        // get class name of the incoming object
828
-        $config_class = get_class($config_obj);
829
-        // run tests 1-5 and 9 to verify config
830
-        if (
831
-            ! $this->_verify_config_params(
832
-                $section,
833
-                $name,
834
-                $config_class,
835
-                $config_obj,
836
-                array(1, 2, 3, 4, 7, 9)
837
-            )
838
-        ) {
839
-            return false;
840
-        }
841
-        $config_option_name = $this->_generate_config_option_name($section, $name);
842
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
843
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
844
-            // save new config to db
845
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
846
-                return true;
847
-            }
848
-        } else {
849
-            // first check if the record already exists
850
-            $existing_config = get_option($config_option_name);
851
-            $config_obj = serialize($config_obj);
852
-            // just return if db record is already up-to-date (NOT type safe comparison)
853
-            if ($existing_config == $config_obj) {
854
-                $this->{$section}->{$name} = $config_obj;
855
-                return true;
856
-            } elseif (update_option($config_option_name, $config_obj)) {
857
-                EE_Config::log($config_option_name);
858
-                // update wp-option for this config class
859
-                $this->{$section}->{$name} = $config_obj;
860
-                return true;
861
-            } elseif ($throw_errors) {
862
-                EE_Error::add_error(
863
-                    sprintf(
864
-                        esc_html__(
865
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
866
-                            'event_espresso'
867
-                        ),
868
-                        $config_class,
869
-                        'EE_Config->' . $section . '->' . $name
870
-                    ),
871
-                    __FILE__,
872
-                    __FUNCTION__,
873
-                    __LINE__
874
-                );
875
-            }
876
-        }
877
-        return false;
878
-    }
879
-
880
-
881
-    /**
882
-     *    get_config
883
-     *
884
-     * @access    public
885
-     * @param    string $section
886
-     * @param    string $name
887
-     * @param    string $config_class
888
-     * @return    mixed EE_Config_Base | NULL
889
-     */
890
-    public function get_config($section = '', $name = '', $config_class = '')
891
-    {
892
-        // ensure config class is set to something
893
-        $config_class = $this->_set_config_class($config_class, $name);
894
-        // run tests 1-4, 6 and 7 to verify that all params have been set
895
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
896
-            return null;
897
-        }
898
-        // now test if the requested config object exists, but suppress errors
899
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
900
-            // config already exists, so pass it back
901
-            return $this->{$section}->{$name};
902
-        }
903
-        // load config option from db if it exists
904
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
905
-        // verify the newly retrieved config object, but suppress errors
906
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
907
-            // config is good, so set it and pass it back
908
-            $this->{$section}->{$name} = $config_obj;
909
-            return $this->{$section}->{$name};
910
-        }
911
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
912
-        $config_obj = $this->set_config($section, $name, $config_class);
913
-        // verify the newly created config object
914
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
915
-            return $this->{$section}->{$name};
916
-        } else {
917
-            EE_Error::add_error(
918
-                sprintf(esc_html__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
919
-                __FILE__,
920
-                __FUNCTION__,
921
-                __LINE__
922
-            );
923
-        }
924
-        return null;
925
-    }
926
-
927
-
928
-    /**
929
-     *    get_config_option
930
-     *
931
-     * @access    public
932
-     * @param    string $config_option_name
933
-     * @return    mixed EE_Config_Base | FALSE
934
-     */
935
-    public function get_config_option($config_option_name = '')
936
-    {
937
-        // retrieve the wp-option for this config class.
938
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
939
-        if (empty($config_option)) {
940
-            EE_Config::log($config_option_name . '-NOT-FOUND');
941
-        }
942
-        return $config_option;
943
-    }
944
-
945
-
946
-    /**
947
-     * log
948
-     *
949
-     * @param string $config_option_name
950
-     */
951
-    public static function log($config_option_name = '')
952
-    {
953
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
954
-            $config_log = get_option(EE_Config::LOG_NAME, array());
955
-            /** @var RequestParams $request */
956
-            $request = LoaderFactory::getLoader()->getShared(RequestParams::class);
957
-            $config_log[ (string) microtime(true) ] = array(
958
-                'config_name' => $config_option_name,
959
-                'request'     => $request->requestParams(),
960
-            );
961
-            update_option(EE_Config::LOG_NAME, $config_log);
962
-        }
963
-    }
964
-
965
-
966
-    /**
967
-     * trim_log
968
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
969
-     */
970
-    public static function trim_log()
971
-    {
972
-        if (! EE_Config::logging_enabled()) {
973
-            return;
974
-        }
975
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
976
-        $log_length = count($config_log);
977
-        if ($log_length > EE_Config::LOG_LENGTH) {
978
-            ksort($config_log);
979
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
980
-            update_option(EE_Config::LOG_NAME, $config_log);
981
-        }
982
-    }
983
-
984
-
985
-    /**
986
-     *    get_page_for_posts
987
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
988
-     *    wp-option "page_for_posts", or "posts" if no page is selected
989
-     *
990
-     * @access    public
991
-     * @return    string
992
-     */
993
-    public static function get_page_for_posts()
994
-    {
995
-        $page_for_posts = get_option('page_for_posts');
996
-        if (! $page_for_posts) {
997
-            return 'posts';
998
-        }
999
-        global $wpdb;
1000
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
1001
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
1002
-    }
1003
-
1004
-
1005
-    /**
1006
-     *    register_shortcodes_and_modules.
1007
-     *    At this point, it's too early to tell if we're maintenance mode or not.
1008
-     *    In fact, this is where we give modules a chance to let core know they exist
1009
-     *    so they can help trigger maintenance mode if it's needed
1010
-     *
1011
-     * @access    public
1012
-     * @return    void
1013
-     */
1014
-    public function register_shortcodes_and_modules()
1015
-    {
1016
-        // allow modules to set hooks for the rest of the system
1017
-        EE_Registry::instance()->modules = $this->_register_modules();
1018
-    }
1019
-
1020
-
1021
-    /**
1022
-     *    initialize_shortcodes_and_modules
1023
-     *    meaning they can start adding their hooks to get stuff done
1024
-     *
1025
-     * @access    public
1026
-     * @return    void
1027
-     */
1028
-    public function initialize_shortcodes_and_modules()
1029
-    {
1030
-        // allow modules to set hooks for the rest of the system
1031
-        $this->_initialize_modules();
1032
-    }
1033
-
1034
-
1035
-    /**
1036
-     *    widgets_init
1037
-     *
1038
-     * @access private
1039
-     * @return void
1040
-     */
1041
-    public function widgets_init()
1042
-    {
1043
-        // only init widgets on admin pages when not in complete maintenance, and
1044
-        // on frontend when not in any maintenance mode
1045
-        if (
1046
-            MaintenanceStatus::isDisabled()
1047
-            || (is_admin() && MaintenanceStatus::isNotFullSite())
1048
-        ) {
1049
-            // grab list of installed widgets
1050
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1051
-            // filter list of modules to register
1052
-            $widgets_to_register = apply_filters(
1053
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1054
-                $widgets_to_register
1055
-            );
1056
-            if (! empty($widgets_to_register)) {
1057
-                // cycle thru widget folders
1058
-                foreach ($widgets_to_register as $widget_path) {
1059
-                    // add to list of installed widget modules
1060
-                    EE_Config::register_ee_widget($widget_path);
1061
-                }
1062
-            }
1063
-            // filter list of installed modules
1064
-            EE_Registry::instance()->widgets = apply_filters(
1065
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1066
-                EE_Registry::instance()->widgets
1067
-            );
1068
-        }
1069
-    }
1070
-
1071
-
1072
-    /**
1073
-     *    register_ee_widget - makes core aware of this widget
1074
-     *
1075
-     * @access    public
1076
-     * @param    string $widget_path - full path up to and including widget folder
1077
-     * @return    void
1078
-     */
1079
-    public static function register_ee_widget($widget_path = null)
1080
-    {
1081
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1082
-        $widget_ext = '.widget.php';
1083
-        // make all separators match
1084
-        $widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1085
-        // does the file path INCLUDE the actual file name as part of the path ?
1086
-        if (strpos($widget_path, $widget_ext) !== false) {
1087
-            // grab and shortcode file name from directory name and break apart at dots
1088
-            $file_name = explode('.', basename($widget_path));
1089
-            // take first segment from file name pieces and remove class prefix if it exists
1090
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1091
-            // sanitize shortcode directory name
1092
-            $widget = sanitize_key($widget);
1093
-            // now we need to rebuild the shortcode path
1094
-            $widget_path = explode('/', $widget_path);
1095
-            // remove last segment
1096
-            array_pop($widget_path);
1097
-            // glue it back together
1098
-            $widget_path = implode(DS, $widget_path);
1099
-        } else {
1100
-            // grab and sanitize widget directory name
1101
-            $widget = sanitize_key(basename($widget_path));
1102
-        }
1103
-        // create classname from widget directory name
1104
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1105
-        // add class prefix
1106
-        $widget_class = 'EEW_' . $widget;
1107
-        // does the widget exist ?
1108
-        if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1109
-            $msg = sprintf(
1110
-                esc_html__(
1111
-                    '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',
1112
-                    'event_espresso'
1113
-                ),
1114
-                $widget_class,
1115
-                $widget_path . '/' . $widget_class . $widget_ext
1116
-            );
1117
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1118
-            return;
1119
-        }
1120
-        // load the widget class file
1121
-        require_once($widget_path . '/' . $widget_class . $widget_ext);
1122
-        // verify that class exists
1123
-        if (! class_exists($widget_class)) {
1124
-            $msg = sprintf(esc_html__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1125
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1126
-            return;
1127
-        }
1128
-        register_widget($widget_class);
1129
-        // add to array of registered widgets
1130
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1131
-    }
1132
-
1133
-
1134
-    /**
1135
-     *        _register_modules
1136
-     *
1137
-     * @access private
1138
-     * @return array
1139
-     */
1140
-    private function _register_modules()
1141
-    {
1142
-        // grab list of installed modules
1143
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1144
-        // filter list of modules to register
1145
-        $modules_to_register = apply_filters(
1146
-            'FHEE__EE_Config__register_modules__modules_to_register',
1147
-            $modules_to_register
1148
-        );
1149
-        if (! empty($modules_to_register)) {
1150
-            // loop through folders
1151
-            foreach ($modules_to_register as $module_path) {
1152
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1153
-                if (
1154
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1155
-                    && $module_path !== EE_MODULES . 'gateways'
1156
-                ) {
1157
-                    // add to list of installed modules
1158
-                    EE_Config::register_module($module_path);
1159
-                }
1160
-            }
1161
-        }
1162
-        // filter list of installed modules
1163
-        return apply_filters(
1164
-            'FHEE__EE_Config___register_modules__installed_modules',
1165
-            EE_Registry::instance()->modules
1166
-        );
1167
-    }
1168
-
1169
-
1170
-    /**
1171
-     *    register_module - makes core aware of this module
1172
-     *
1173
-     * @access    public
1174
-     * @param    string $module_path - full path up to and including module folder
1175
-     * @return    bool
1176
-     */
1177
-    public static function register_module($module_path = null)
1178
-    {
1179
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1180
-        $module_ext = '.module.php';
1181
-        // make all separators match
1182
-        $module_path = str_replace(array('\\', '/'), '/', $module_path);
1183
-        // does the file path INCLUDE the actual file name as part of the path ?
1184
-        if (strpos($module_path, $module_ext) !== false) {
1185
-            // grab and shortcode file name from directory name and break apart at dots
1186
-            $module_file = explode('.', basename($module_path));
1187
-            // now we need to rebuild the shortcode path
1188
-            $module_path = explode('/', $module_path);
1189
-            // remove last segment
1190
-            array_pop($module_path);
1191
-            // glue it back together
1192
-            $module_path = implode('/', $module_path) . '/';
1193
-            // take first segment from file name pieces and sanitize it
1194
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1195
-            // ensure class prefix is added
1196
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1197
-        } else {
1198
-            // we need to generate the filename based off of the folder name
1199
-            // grab and sanitize module name
1200
-            $module = strtolower(basename($module_path));
1201
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1202
-            // like trailingslashit()
1203
-            $module_path = rtrim($module_path, '/') . '/';
1204
-            // create classname from module directory name
1205
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1206
-            // add class prefix
1207
-            $module_class = 'EED_' . $module;
1208
-        }
1209
-        // does the module exist ?
1210
-        if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1211
-            $msg = sprintf(
1212
-                esc_html__(
1213
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1214
-                    'event_espresso'
1215
-                ),
1216
-                $module
1217
-            );
1218
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1219
-            return false;
1220
-        }
1221
-        // load the module class file
1222
-        require_once($module_path . $module_class . $module_ext);
1223
-        // verify that class exists
1224
-        if (! class_exists($module_class)) {
1225
-            $msg = sprintf(esc_html__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1226
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1227
-            return false;
1228
-        }
1229
-        // add to array of registered modules
1230
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1231
-        do_action(
1232
-            'AHEE__EE_Config__register_module__complete',
1233
-            $module_class,
1234
-            EE_Registry::instance()->modules->{$module_class}
1235
-        );
1236
-        return true;
1237
-    }
1238
-
1239
-
1240
-    /**
1241
-     *    _initialize_modules
1242
-     *    allow modules to set hooks for the rest of the system
1243
-     *
1244
-     * @access private
1245
-     * @return void
1246
-     */
1247
-    private function _initialize_modules()
1248
-    {
1249
-        // cycle thru shortcode folders
1250
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1251
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1252
-            // which set hooks ?
1253
-            if (is_admin() && is_callable([$module_class, 'set_hooks_admin'])) {
1254
-                // fire immediately
1255
-                call_user_func([$module_class, 'set_hooks_admin']);
1256
-            } else {
1257
-                // delay until other systems are online
1258
-                add_action(
1259
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1260
-                    array($module_class, 'set_hooks')
1261
-                );
1262
-            }
1263
-        }
1264
-    }
1265
-
1266
-
1267
-    /**
1268
-     *    register_route - adds module method routes to route_map
1269
-     *
1270
-     * @access    public
1271
-     * @param    string $route       - "pretty" public alias for module method
1272
-     * @param    string $module      - module name (classname without EED_ prefix)
1273
-     * @param    string $method_name - the actual module method to be routed to
1274
-     * @param    string $key         - url param key indicating a route is being called
1275
-     * @return    bool
1276
-     */
1277
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1278
-    {
1279
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1280
-        $module = str_replace('EED_', '', $module);
1281
-        $module_class = 'EED_' . $module;
1282
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1283
-            $msg = sprintf(esc_html__('The module %s has not been registered.', 'event_espresso'), $module);
1284
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1285
-            return false;
1286
-        }
1287
-        if (empty($route)) {
1288
-            $msg = sprintf(esc_html__('No route has been supplied.', 'event_espresso'), $route);
1289
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1290
-            return false;
1291
-        }
1292
-        if (! method_exists('EED_' . $module, $method_name)) {
1293
-            $msg = sprintf(
1294
-                esc_html__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1295
-                $route
1296
-            );
1297
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1298
-            return false;
1299
-        }
1300
-        EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1301
-        return true;
1302
-    }
1303
-
1304
-
1305
-    /**
1306
-     *    get_route - get module method route
1307
-     *
1308
-     * @access    public
1309
-     * @param    string $route - "pretty" public alias for module method
1310
-     * @param    string $key   - url param key indicating a route is being called
1311
-     * @return    string
1312
-     */
1313
-    public static function get_route($route = null, $key = 'ee')
1314
-    {
1315
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1316
-        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1317
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1318
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1319
-        }
1320
-        return null;
1321
-    }
1322
-
1323
-
1324
-    /**
1325
-     *    get_routes - get ALL module method routes
1326
-     *
1327
-     * @access    public
1328
-     * @return    array
1329
-     */
1330
-    public static function get_routes()
1331
-    {
1332
-        return EE_Config::$_module_route_map;
1333
-    }
1334
-
1335
-
1336
-    /**
1337
-     *    register_forward - allows modules to forward request to another module for further processing
1338
-     *
1339
-     * @access    public
1340
-     * @param    string       $route   - "pretty" public alias for module method
1341
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1342
-     *                                 class, allows different forwards to be served based on status
1343
-     * @param    array|string $forward - function name or array( class, method )
1344
-     * @param    string       $key     - url param key indicating a route is being called
1345
-     * @return    bool
1346
-     */
1347
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1348
-    {
1349
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1350
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1351
-            $msg = sprintf(
1352
-                esc_html__('The module route %s for this forward has not been registered.', 'event_espresso'),
1353
-                $route
1354
-            );
1355
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1356
-            return false;
1357
-        }
1358
-        if (empty($forward)) {
1359
-            $msg = sprintf(esc_html__('No forwarding route has been supplied.', 'event_espresso'), $route);
1360
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1361
-            return false;
1362
-        }
1363
-        if (is_array($forward)) {
1364
-            if (! isset($forward[1])) {
1365
-                $msg = sprintf(
1366
-                    esc_html__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1367
-                    $route
1368
-                );
1369
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1370
-                return false;
1371
-            }
1372
-            if (! method_exists($forward[0], $forward[1])) {
1373
-                $msg = sprintf(
1374
-                    esc_html__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1375
-                    $forward[1],
1376
-                    $route
1377
-                );
1378
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1379
-                return false;
1380
-            }
1381
-        } elseif (! function_exists($forward)) {
1382
-            $msg = sprintf(
1383
-                esc_html__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1384
-                $forward,
1385
-                $route
1386
-            );
1387
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1388
-            return false;
1389
-        }
1390
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1391
-        return true;
1392
-    }
1393
-
1394
-
1395
-    /**
1396
-     *    get_forward - get forwarding route
1397
-     *
1398
-     * @access    public
1399
-     * @param    string  $route  - "pretty" public alias for module method
1400
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1401
-     *                           allows different forwards to be served based on status
1402
-     * @param    string  $key    - url param key indicating a route is being called
1403
-     * @return    string
1404
-     */
1405
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1406
-    {
1407
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1408
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1409
-            return apply_filters(
1410
-                'FHEE__EE_Config__get_forward',
1411
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1412
-                $route,
1413
-                $status
1414
-            );
1415
-        }
1416
-        return null;
1417
-    }
1418
-
1419
-
1420
-    /**
1421
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1422
-     *    results
1423
-     *
1424
-     * @access    public
1425
-     * @param    string  $route  - "pretty" public alias for module method
1426
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1427
-     *                           allows different views to be served based on status
1428
-     * @param    string  $view
1429
-     * @param    string  $key    - url param key indicating a route is being called
1430
-     * @return    bool
1431
-     */
1432
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1433
-    {
1434
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1435
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1436
-            $msg = sprintf(
1437
-                esc_html__('The module route %s for this view has not been registered.', 'event_espresso'),
1438
-                $route
1439
-            );
1440
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1441
-            return false;
1442
-        }
1443
-        if (! is_readable($view)) {
1444
-            $msg = sprintf(
1445
-                esc_html__(
1446
-                    'The %s view file could not be found or is not readable due to file permissions.',
1447
-                    'event_espresso'
1448
-                ),
1449
-                $view
1450
-            );
1451
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1452
-            return false;
1453
-        }
1454
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1455
-        return true;
1456
-    }
1457
-
1458
-
1459
-    /**
1460
-     *    get_view - get view for route and status
1461
-     *
1462
-     * @access    public
1463
-     * @param    string  $route  - "pretty" public alias for module method
1464
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1465
-     *                           allows different views to be served based on status
1466
-     * @param    string  $key    - url param key indicating a route is being called
1467
-     * @return    string
1468
-     */
1469
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1470
-    {
1471
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1472
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1473
-            return apply_filters(
1474
-                'FHEE__EE_Config__get_view',
1475
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1476
-                $route,
1477
-                $status
1478
-            );
1479
-        }
1480
-        return null;
1481
-    }
1482
-
1483
-
1484
-    public function update_addon_option_names()
1485
-    {
1486
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1487
-    }
1488
-
1489
-
1490
-    public function shutdown()
1491
-    {
1492
-        $this->update_addon_option_names();
1493
-    }
1494
-
1495
-
1496
-    /**
1497
-     * @return LegacyShortcodesManager
1498
-     */
1499
-    public static function getLegacyShortcodesManager()
1500
-    {
1501
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1502
-            EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1503
-                LegacyShortcodesManager::class
1504
-            );
1505
-        }
1506
-        return EE_Config::instance()->legacy_shortcodes_manager;
1507
-    }
1508
-
1509
-
1510
-    /**
1511
-     * register_shortcode - makes core aware of this shortcode
1512
-     *
1513
-     * @deprecated 4.9.26
1514
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1515
-     * @return    bool
1516
-     */
1517
-    public static function register_shortcode($shortcode_path = null)
1518
-    {
1519
-        EE_Error::doing_it_wrong(
1520
-            __METHOD__,
1521
-            esc_html__(
1522
-                '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.',
1523
-                'event_espresso'
1524
-            ),
1525
-            '4.9.26'
1526
-        );
1527
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1528
-    }
1529
-}
1530
-
1531
-/**
1532
- * Base class used for config classes. These classes should generally not have
1533
- * magic functions in use, except we'll allow them to magically set and get stuff...
1534
- * basically, they should just be well-defined stdClasses
1535
- */
1536
-class EE_Config_Base
1537
-{
1538
-    /**
1539
-     * Utility function for escaping the value of a property and returning.
1540
-     *
1541
-     * @param string $property property name (checks to see if exists).
1542
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1543
-     * @throws EE_Error
1544
-     */
1545
-    public function get_pretty($property)
1546
-    {
1547
-        if (! property_exists($this, $property)) {
1548
-            throw new EE_Error(
1549
-                sprintf(
1550
-                    esc_html__(
1551
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1552
-                        'event_espresso'
1553
-                    ),
1554
-                    get_class($this),
1555
-                    $property
1556
-                )
1557
-            );
1558
-        }
1559
-        // just handling escaping of strings for now.
1560
-        if (is_string($this->{$property})) {
1561
-            return stripslashes($this->{$property});
1562
-        }
1563
-        return $this->{$property};
1564
-    }
1565
-
1566
-
1567
-    public function populate()
1568
-    {
1569
-        // grab defaults via a new instance of this class.
1570
-        $class_name = get_class($this);
1571
-        $defaults = new $class_name();
1572
-        // loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1573
-        // default from our $defaults object.
1574
-        foreach (get_object_vars($defaults) as $property => $value) {
1575
-            if ($this->{$property} === null) {
1576
-                $this->{$property} = $value;
1577
-            }
1578
-        }
1579
-        // cleanup
1580
-        unset($defaults);
1581
-    }
1582
-
1583
-
1584
-    /**
1585
-     *        __isset
1586
-     *
1587
-     * @param $a
1588
-     * @return bool
1589
-     */
1590
-    public function __isset($a)
1591
-    {
1592
-        return false;
1593
-    }
1594
-
1595
-
1596
-    /**
1597
-     *        __unset
1598
-     *
1599
-     * @param $a
1600
-     * @return bool
1601
-     */
1602
-    public function __unset($a)
1603
-    {
1604
-        return false;
1605
-    }
1606
-
1607
-
1608
-    /**
1609
-     *        __clone
1610
-     */
1611
-    public function __clone()
1612
-    {
1613
-    }
1614
-
1615
-
1616
-    /**
1617
-     *        __wakeup
1618
-     */
1619
-    public function __wakeup()
1620
-    {
1621
-    }
1622
-
1623
-
1624
-    /**
1625
-     *        __destruct
1626
-     */
1627
-    public function __destruct()
1628
-    {
1629
-    }
1630
-}
1631
-
1632
-/**
1633
- * Class for defining what's in the EE_Config relating to registration settings
1634
- */
1635
-class EE_Core_Config extends EE_Config_Base
1636
-{
1637
-    const OPTION_NAME_UXIP = 'ee_ueip_optin';
1638
-
1639
-
1640
-    public $current_blog_id;
1641
-
1642
-    public $ee_ueip_optin;
1643
-
1644
-    public $ee_ueip_has_notified;
1645
-
1646
-    /**
1647
-     * Not to be confused with the 4 critical page variables (See
1648
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1649
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1650
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1651
-     *
1652
-     * @var array
1653
-     */
1654
-    public $post_shortcodes;
1655
-
1656
-    public $module_route_map;
1657
-
1658
-    public $module_forward_map;
1659
-
1660
-    public $module_view_map;
1661
-
1662
-    /**
1663
-     * The next 4 vars are the IDs of critical EE pages.
1664
-     *
1665
-     * @var int
1666
-     */
1667
-    public $reg_page_id;
1668
-
1669
-    public $txn_page_id;
1670
-
1671
-    public $thank_you_page_id;
1672
-
1673
-    public $cancel_page_id;
1674
-
1675
-    /**
1676
-     * The next 4 vars are the URLs of critical EE pages.
1677
-     *
1678
-     * @var int
1679
-     */
1680
-    public $reg_page_url;
1681
-
1682
-    public $txn_page_url;
1683
-
1684
-    public $thank_you_page_url;
1685
-
1686
-    public $cancel_page_url;
1687
-
1688
-    /**
1689
-     * The next vars relate to the custom slugs for EE CPT routes
1690
-     */
1691
-    public $event_cpt_slug;
1692
-
1693
-    /**
1694
-     * This caches the _ee_ueip_option in case this config is reset in the same
1695
-     * request across blog switches in a multisite context.
1696
-     * Avoids extra queries to the db for this option.
1697
-     *
1698
-     * @var bool
1699
-     */
1700
-    public static $ee_ueip_option;
1701
-
1702
-
1703
-    /**
1704
-     *    class constructor
1705
-     *
1706
-     * @access    public
1707
-     */
1708
-    public function __construct()
1709
-    {
1710
-        // set default organization settings
1711
-        $this->current_blog_id = get_current_blog_id();
1712
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1713
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1714
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1715
-        $this->post_shortcodes = array();
1716
-        $this->module_route_map = array();
1717
-        $this->module_forward_map = array();
1718
-        $this->module_view_map = array();
1719
-        // critical EE page IDs
1720
-        $this->reg_page_id = 0;
1721
-        $this->txn_page_id = 0;
1722
-        $this->thank_you_page_id = 0;
1723
-        $this->cancel_page_id = 0;
1724
-        // critical EE page URLs
1725
-        $this->reg_page_url = '';
1726
-        $this->txn_page_url = '';
1727
-        $this->thank_you_page_url = '';
1728
-        $this->cancel_page_url = '';
1729
-        // cpt slugs
1730
-        $this->event_cpt_slug = esc_html__('events', 'event_espresso');
1731
-        // ueip constant check
1732
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1733
-            $this->ee_ueip_optin = false;
1734
-            $this->ee_ueip_has_notified = true;
1735
-        }
1736
-    }
1737
-
1738
-
1739
-    /**
1740
-     * @return array
1741
-     */
1742
-    public function get_critical_pages_array()
1743
-    {
1744
-        return array(
1745
-            $this->reg_page_id,
1746
-            $this->txn_page_id,
1747
-            $this->thank_you_page_id,
1748
-            $this->cancel_page_id,
1749
-        );
1750
-    }
1751
-
1752
-
1753
-    /**
1754
-     * @return array
1755
-     */
1756
-    public function get_critical_pages_shortcodes_array()
1757
-    {
1758
-        return array(
1759
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1760
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1761
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1762
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1763
-        );
1764
-    }
1765
-
1766
-
1767
-    /**
1768
-     *  gets/returns URL for EE reg_page
1769
-     *
1770
-     * @access    public
1771
-     * @return    string
1772
-     */
1773
-    public function reg_page_url()
1774
-    {
1775
-        if (! $this->reg_page_url) {
1776
-            $this->reg_page_url = add_query_arg(
1777
-                array('uts' => time()),
1778
-                get_permalink($this->reg_page_id)
1779
-            ) . '#checkout';
1780
-        }
1781
-        return $this->reg_page_url;
1782
-    }
1783
-
1784
-
1785
-    /**
1786
-     *  gets/returns URL for EE txn_page
1787
-     *
1788
-     * @param array $query_args like what gets passed to
1789
-     *                          add_query_arg() as the first argument
1790
-     * @access    public
1791
-     * @return    string
1792
-     */
1793
-    public function txn_page_url($query_args = array())
1794
-    {
1795
-        if (! $this->txn_page_url) {
1796
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1797
-        }
1798
-        if ($query_args) {
1799
-            return add_query_arg($query_args, $this->txn_page_url);
1800
-        } else {
1801
-            return $this->txn_page_url;
1802
-        }
1803
-    }
1804
-
1805
-
1806
-    /**
1807
-     *  gets/returns URL for EE thank_you_page
1808
-     *
1809
-     * @param array $query_args like what gets passed to
1810
-     *                          add_query_arg() as the first argument
1811
-     * @access    public
1812
-     * @return    string
1813
-     */
1814
-    public function thank_you_page_url($query_args = array())
1815
-    {
1816
-        if (! $this->thank_you_page_url) {
1817
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1818
-        }
1819
-        if ($query_args) {
1820
-            return add_query_arg($query_args, $this->thank_you_page_url);
1821
-        } else {
1822
-            return $this->thank_you_page_url;
1823
-        }
1824
-    }
1825
-
1826
-
1827
-    /**
1828
-     *  gets/returns URL for EE cancel_page
1829
-     *
1830
-     * @access    public
1831
-     * @return    string
1832
-     */
1833
-    public function cancel_page_url()
1834
-    {
1835
-        if (! $this->cancel_page_url) {
1836
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1837
-        }
1838
-        return $this->cancel_page_url;
1839
-    }
1840
-
1841
-
1842
-    /**
1843
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1844
-     *
1845
-     * @since 4.7.5
1846
-     */
1847
-    protected function _reset_urls()
1848
-    {
1849
-        $this->reg_page_url = '';
1850
-        $this->txn_page_url = '';
1851
-        $this->cancel_page_url = '';
1852
-        $this->thank_you_page_url = '';
1853
-    }
1854
-
1855
-
1856
-    /**
1857
-     * Used to return what the optin value is set for the EE User Experience Program.
1858
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1859
-     * on the main site only.
1860
-     *
1861
-     * @return bool
1862
-     */
1863
-    protected function _get_main_ee_ueip_optin()
1864
-    {
1865
-        // if this is the main site then we can just bypass our direct query.
1866
-        if (is_main_site()) {
1867
-            return get_option(self::OPTION_NAME_UXIP, false);
1868
-        }
1869
-        // is this already cached for this request?  If so use it.
1870
-        if (EE_Core_Config::$ee_ueip_option !== null) {
1871
-            return EE_Core_Config::$ee_ueip_option;
1872
-        }
1873
-        global $wpdb;
1874
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1875
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1876
-        $option = self::OPTION_NAME_UXIP;
1877
-        // set correct table for query
1878
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1879
-        // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1880
-        // get_blog_option() does a switch_to_blog and that could cause infinite recursion because EE_Core_Config might be
1881
-        // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1882
-        // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1883
-        // for the purpose of caching.
1884
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1885
-        if (false !== $pre) {
1886
-            EE_Core_Config::$ee_ueip_option = $pre;
1887
-            return EE_Core_Config::$ee_ueip_option;
1888
-        }
1889
-        $row = $wpdb->get_row(
1890
-            $wpdb->prepare(
1891
-                "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1892
-                $option
1893
-            )
1894
-        );
1895
-        if (is_object($row)) {
1896
-            $value = $row->option_value;
1897
-        } else { // option does not exist so use default.
1898
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1899
-            return EE_Core_Config::$ee_ueip_option;
1900
-        }
1901
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1902
-        return EE_Core_Config::$ee_ueip_option;
1903
-    }
1904
-
1905
-
1906
-    /**
1907
-     * Utility function for escaping the value of a property and returning.
1908
-     *
1909
-     * @param string $property property name (checks to see if exists).
1910
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1911
-     * @throws EE_Error
1912
-     */
1913
-    public function get_pretty($property)
1914
-    {
1915
-        if ($property === self::OPTION_NAME_UXIP) {
1916
-            return $this->ee_ueip_optin ? 'yes' : 'no';
1917
-        }
1918
-        return parent::get_pretty($property);
1919
-    }
1920
-
1921
-
1922
-    /**
1923
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1924
-     * on the object.
1925
-     *
1926
-     * @return array
1927
-     */
1928
-    public function __sleep()
1929
-    {
1930
-        // reset all url properties
1931
-        $this->_reset_urls();
1932
-        // return what to save to db
1933
-        return array_keys(get_object_vars($this));
1934
-    }
1935
-}
1936
-
1937
-/**
1938
- * Config class for storing info on the Organization
1939
- */
1940
-class EE_Organization_Config extends EE_Config_Base
1941
-{
1942
-    /**
1943
-     * @var string $name
1944
-     * eg EE4.1
1945
-     */
1946
-    public $name;
1947
-
1948
-    /**
1949
-     * @var string $address_1
1950
-     * eg 123 Onna Road
1951
-     */
1952
-    public $address_1 = '';
1953
-
1954
-    /**
1955
-     * @var string $address_2
1956
-     * eg PO Box 123
1957
-     */
1958
-    public $address_2 = '';
1959
-
1960
-    /**
1961
-     * @var string $city
1962
-     * eg Inna City
1963
-     */
1964
-    public $city = '';
1965
-
1966
-    /**
1967
-     * @var int $STA_ID
1968
-     * eg 4
1969
-     */
1970
-    public $STA_ID = 0;
1971
-
1972
-    /**
1973
-     * @var string $CNT_ISO
1974
-     * eg US
1975
-     */
1976
-    public $CNT_ISO = 'US';
1977
-
1978
-    /**
1979
-     * @var string $zip
1980
-     * eg 12345  or V1A 2B3
1981
-     */
1982
-    public $zip = '';
1983
-
1984
-    /**
1985
-     * @var string $email
1986
-     * eg [email protected]
1987
-     */
1988
-    public $email;
1989
-
1990
-    /**
1991
-     * @var string $phone
1992
-     * eg. 111-111-1111
1993
-     */
1994
-    public $phone = '';
1995
-
1996
-    /**
1997
-     * @var string $vat
1998
-     * VAT/Tax Number
1999
-     */
2000
-    public $vat = '';
2001
-
2002
-    /**
2003
-     * @var string $logo_url
2004
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2005
-     */
2006
-    public $logo_url = '';
2007
-
2008
-    /**
2009
-     * The below are all various properties for holding links to organization social network profiles
2010
-     */
2011
-    /**
2012
-     * facebook (facebook.com/profile.name)
2013
-     *
2014
-     * @var string
2015
-     */
2016
-    public $facebook = '';
2017
-
2018
-    /**
2019
-     * twitter (twitter.com/twitter_handle)
2020
-     *
2021
-     * @var string
2022
-     */
2023
-    public $twitter = '';
2024
-
2025
-    /**
2026
-     * linkedin (linkedin.com/in/profile_name)
2027
-     *
2028
-     * @var string
2029
-     */
2030
-    public $linkedin = '';
2031
-
2032
-    /**
2033
-     * pinterest (www.pinterest.com/profile_name)
2034
-     *
2035
-     * @var string
2036
-     */
2037
-    public $pinterest = '';
2038
-
2039
-    /**
2040
-     * google+ (google.com/+profileName)
2041
-     *
2042
-     * @var string
2043
-     */
2044
-    public $google = '';
2045
-
2046
-    /**
2047
-     * instagram (instagram.com/handle)
2048
-     *
2049
-     * @var string
2050
-     */
2051
-    public $instagram = '';
2052
-
2053
-
2054
-    /**
2055
-     *    class constructor
2056
-     *
2057
-     * @access    public
2058
-     */
2059
-    public function __construct()
2060
-    {
2061
-        // set default organization settings
2062
-        // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2063
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2064
-        $this->email = get_bloginfo('admin_email');
2065
-    }
2066
-}
2067
-
2068
-/**
2069
- * Class for defining what's in the EE_Config relating to currency
2070
- */
2071
-class EE_Currency_Config extends EE_Config_Base
2072
-{
2073
-    /**
2074
-     * @var string $code
2075
-     * eg 'US'
2076
-     */
2077
-    public $code;
2078
-
2079
-    /**
2080
-     * @var string $name
2081
-     * eg 'Dollar'
2082
-     */
2083
-    public $name;
2084
-
2085
-    /**
2086
-     * plural name
2087
-     *
2088
-     * @var string $plural
2089
-     * eg 'Dollars'
2090
-     */
2091
-    public $plural;
2092
-
2093
-    /**
2094
-     * currency sign
2095
-     *
2096
-     * @var string $sign
2097
-     * eg '$'
2098
-     */
2099
-    public $sign;
2100
-
2101
-    /**
2102
-     * Whether the currency sign should come before the number or not
2103
-     *
2104
-     * @var boolean $sign_b4
2105
-     */
2106
-    public $sign_b4;
2107
-
2108
-    /**
2109
-     * How many digits should come after the decimal place
2110
-     *
2111
-     * @var int $dec_plc
2112
-     */
2113
-    public $dec_plc;
2114
-
2115
-    /**
2116
-     * Symbol to use for decimal mark
2117
-     *
2118
-     * @var string $dec_mrk
2119
-     * eg '.'
2120
-     */
2121
-    public $dec_mrk;
2122
-
2123
-    /**
2124
-     * Symbol to use for thousands
2125
-     *
2126
-     * @var string $thsnds
2127
-     * eg ','
2128
-     */
2129
-    public $thsnds;
2130
-
2131
-
2132
-    /**
2133
-     * @param string|null $CNT_ISO
2134
-     * @throws EE_Error
2135
-     * @throws ReflectionException
2136
-     */
2137
-    public function __construct(?string $CNT_ISO = 'US')
2138
-    {
2139
-        if ($CNT_ISO && $CNT_ISO === $this->code) {
2140
-            return;
2141
-        }
2142
-        // get country code from organization settings or use default
2143
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2144
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2145
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2146
-            : 'US';
2147
-        // but override if requested
2148
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2149
-        // 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
2150
-        $this->setCurrency($CNT_ISO);
2151
-        // fallback to hardcoded defaults, in case the above failed
2152
-        if (empty($this->code)) {
2153
-            $this->setFallbackCurrency();
2154
-        }
2155
-    }
2156
-
2157
-
2158
-    /**
2159
-     * @param string|null $CNT_ISO
2160
-     * @throws EE_Error
2161
-     * @throws ReflectionException
2162
-     */
2163
-    public function setCurrency(?string $CNT_ISO = 'US')
2164
-    {
2165
-        if (empty($CNT_ISO) || DbStatus::isOffline()) {
2166
-            return;
2167
-        }
2168
-
2169
-        /** @var TableAnalysis $table_analysis */
2170
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', [], true);
2171
-        if (! $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())) {
2172
-            return;
2173
-        }
2174
-        // retrieve the country settings from the db, just in case they have been customized
2175
-        $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2176
-        if (! $country instanceof EE_Country) {
2177
-            throw new DomainException(
2178
-                sprintf(
2179
-                    esc_html__('Invalid Country ISO Code: %1$s', 'event_espresso'),
2180
-                    $CNT_ISO
2181
-                )
2182
-            );
2183
-        }
2184
-        $this->code    = $country->currency_code();                  // currency code: USD, CAD, EUR
2185
-        $this->name    = $country->currency_name_single();           // Dollar
2186
-        $this->plural  = $country->currency_name_plural();           // Dollars
2187
-        $this->sign    = $country->currency_sign();                  // currency sign: $
2188
-        $this->sign_b4 = $country->currency_sign_before();           // currency sign before or after
2189
-        $this->dec_plc = $country->currency_decimal_places();        // decimal places: 2 = 0.00  3 = 0.000
2190
-        $this->dec_mrk = $country->currency_decimal_mark();          // decimal mark: ',' = 0,01 or '.' = 0.01
2191
-        $this->thsnds  = $country->currency_thousands_separator();   // thousands sep: ',' = 1,000 or '.' = 1.000
2192
-    }
2193
-
2194
-
2195
-    private function setFallbackCurrency()
2196
-    {
2197
-        // set default currency settings
2198
-        $this->code    = 'USD';
2199
-        $this->name    = esc_html__('Dollar', 'event_espresso');
2200
-        $this->plural  = esc_html__('Dollars', 'event_espresso');
2201
-        $this->sign    = '$';
2202
-        $this->sign_b4 = true;
2203
-        $this->dec_plc = 2;
2204
-        $this->dec_mrk = '.';
2205
-        $this->thsnds  = ',';
2206
-    }
2207
-
2208
-
2209
-    /**
2210
-     * @param string|null $CNT_ISO
2211
-     * @return EE_Currency_Config
2212
-     * @throws EE_Error
2213
-     * @throws ReflectionException
2214
-     */
2215
-    public static function getCurrencyConfig(?string $CNT_ISO = ''): EE_Currency_Config
2216
-    {
2217
-        // if CNT_ISO passed lets try to get currency settings for it.
2218
-        $currency_config = ! empty($CNT_ISO)
2219
-            ? new EE_Currency_Config($CNT_ISO)
2220
-            : null;
2221
-        // default currency settings for site if not set
2222
-        if ($currency_config instanceof EE_Currency_Config) {
2223
-            return $currency_config;
2224
-        }
2225
-        EE_Config::instance()->currency = EE_Config::instance()->currency instanceof EE_Currency_Config
2226
-            ? EE_Config::instance()->currency
2227
-            : new EE_Currency_Config();
2228
-        return EE_Config::instance()->currency;
2229
-    }
2230
-}
2231
-
2232
-/**
2233
- * Class for defining what's in the EE_Config relating to registration settings
2234
- */
2235
-class EE_Registration_Config extends EE_Config_Base
2236
-{
2237
-    /**
2238
-     * Default registration status
2239
-     *
2240
-     * @var string $default_STS_ID
2241
-     * eg 'RPP'
2242
-     */
2243
-    public $default_STS_ID;
2244
-
2245
-    /**
2246
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2247
-     * registrations)
2248
-     *
2249
-     * @var int
2250
-     */
2251
-    public $default_maximum_number_of_tickets;
2252
-
2253
-    /**
2254
-     * level of validation to apply to email addresses
2255
-     *
2256
-     * @var string $email_validation_level
2257
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2258
-     */
2259
-    public $email_validation_level;
2260
-
2261
-    /**
2262
-     * whether to show alternate payment options during the reg process if payment status is pending
2263
-     *
2264
-     * @var boolean $show_pending_payment_options
2265
-     */
2266
-    public $show_pending_payment_options;
2267
-
2268
-    /**
2269
-     * an array of SPCO reg steps where:
2270
-     *        the keys denotes the reg step order
2271
-     *        each element consists of an array with the following elements:
2272
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2273
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2274
-     *            "slug" => the URL param used to trigger the reg step
2275
-     *
2276
-     * @var array $reg_steps
2277
-     */
2278
-    public $reg_steps;
2279
-
2280
-    /**
2281
-     * Whether registration confirmation should be the last page of SPCO
2282
-     *
2283
-     * @var boolean $reg_confirmation_last
2284
-     */
2285
-    public $reg_confirmation_last;
2286
-
2287
-    /**
2288
-     * Whether to enable the EE Bot Trap
2289
-     *
2290
-     * @var boolean $use_bot_trap
2291
-     */
2292
-    public $use_bot_trap;
2293
-
2294
-    /**
2295
-     * Whether to encrypt some data sent by the EE Bot Trap
2296
-     *
2297
-     * @var boolean $use_encryption
2298
-     */
2299
-    public $use_encryption;
2300
-
2301
-    /**
2302
-     * Whether to use ReCaptcha
2303
-     *
2304
-     * @var boolean $use_captcha
2305
-     */
2306
-    public $use_captcha;
2307
-
2308
-    /**
2309
-     * ReCaptcha Theme
2310
-     *
2311
-     * @var string $recaptcha_theme
2312
-     *    options: 'dark', 'light', 'invisible'
2313
-     */
2314
-    public $recaptcha_theme;
2315
-
2316
-    /**
2317
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2318
-     *
2319
-     * @var string $recaptcha_badge
2320
-     *    options: 'bottomright', 'bottomleft', 'inline'
2321
-     */
2322
-    public $recaptcha_badge;
2323
-
2324
-    /**
2325
-     * ReCaptcha Type
2326
-     *
2327
-     * @var string $recaptcha_type
2328
-     *    options: 'audio', 'image'
2329
-     */
2330
-    public $recaptcha_type;
2331
-
2332
-    /**
2333
-     * ReCaptcha language
2334
-     *
2335
-     * @var string $recaptcha_language
2336
-     * eg 'en'
2337
-     */
2338
-    public $recaptcha_language;
2339
-
2340
-    /**
2341
-     * ReCaptcha public key
2342
-     *
2343
-     * @var string $recaptcha_publickey
2344
-     */
2345
-    public $recaptcha_publickey;
2346
-
2347
-    /**
2348
-     * ReCaptcha private key
2349
-     *
2350
-     * @var string $recaptcha_privatekey
2351
-     */
2352
-    public $recaptcha_privatekey;
2353
-
2354
-    /**
2355
-     * array of form names protected by ReCaptcha
2356
-     *
2357
-     * @var array $recaptcha_protected_forms
2358
-     */
2359
-    public $recaptcha_protected_forms;
23
+	const OPTION_NAME = 'ee_config';
24
+
25
+	const LOG_NAME = 'ee_config_log';
26
+
27
+	const LOG_LENGTH = 100;
28
+
29
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
30
+
31
+	/**
32
+	 *    instance of the EE_Config object
33
+	 *
34
+	 * @var    EE_Config $_instance
35
+	 * @access    private
36
+	 */
37
+	private static $_instance;
38
+
39
+	/**
40
+	 * @var boolean $_logging_enabled
41
+	 */
42
+	private static $_logging_enabled = false;
43
+
44
+	/**
45
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
46
+	 */
47
+	private $legacy_shortcodes_manager;
48
+
49
+	/**
50
+	 * An StdClass whose property names are addon slugs,
51
+	 * and values are their config classes
52
+	 *
53
+	 * @var StdClass
54
+	 */
55
+	public $addons;
56
+
57
+	/**
58
+	 * @var EE_Admin_Config
59
+	 */
60
+	public $admin;
61
+
62
+	/**
63
+	 * @var EE_Core_Config
64
+	 */
65
+	public $core;
66
+
67
+	/**
68
+	 * @var EE_Currency_Config
69
+	 */
70
+	public $currency;
71
+
72
+	/**
73
+	 * @var EE_Organization_Config
74
+	 */
75
+	public $organization;
76
+
77
+	/**
78
+	 * @var EE_Registration_Config
79
+	 */
80
+	public $registration;
81
+
82
+	/**
83
+	 * @var EE_Template_Config
84
+	 */
85
+	public $template_settings;
86
+
87
+	/**
88
+	 * Holds EE environment values.
89
+	 *
90
+	 * @var EE_Environment_Config
91
+	 */
92
+	public $environment;
93
+
94
+	/**
95
+	 * settings pertaining to Google maps
96
+	 *
97
+	 * @var EE_Map_Config
98
+	 */
99
+	public $map_settings;
100
+
101
+	/**
102
+	 * settings pertaining to Taxes
103
+	 *
104
+	 * @var EE_Tax_Config
105
+	 */
106
+	public $tax_settings;
107
+
108
+	/**
109
+	 * Settings pertaining to global messages settings.
110
+	 *
111
+	 * @var EE_Messages_Config
112
+	 */
113
+	public $messages;
114
+
115
+	/**
116
+	 * @deprecated
117
+	 * @var EE_Gateway_Config
118
+	 */
119
+	public $gateway;
120
+
121
+	/**
122
+	 * @var array
123
+	 */
124
+	private $_addon_option_names = array();
125
+
126
+	/**
127
+	 * @var array
128
+	 */
129
+	private static $_module_route_map = array();
130
+
131
+	/**
132
+	 * @var array
133
+	 */
134
+	private static $_module_forward_map = array();
135
+
136
+	/**
137
+	 * @var array
138
+	 */
139
+	private static $_module_view_map = array();
140
+
141
+	/**
142
+	 * @var bool
143
+	 */
144
+	private static $initialized = false;
145
+
146
+
147
+	/**
148
+	 * @singleton method used to instantiate class object
149
+	 * @access    public
150
+	 * @return EE_Config instance
151
+	 */
152
+	public static function instance()
153
+	{
154
+		// check if class object is instantiated, and instantiated properly
155
+		if (! self::$_instance instanceof EE_Config) {
156
+			self::$_instance = new self();
157
+		}
158
+		return self::$_instance;
159
+	}
160
+
161
+
162
+	/**
163
+	 * Resets the config
164
+	 *
165
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
166
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
167
+	 *                               reflect its state in the database
168
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
169
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
170
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
171
+	 *                               site was put into maintenance mode)
172
+	 * @return EE_Config
173
+	 */
174
+	public static function reset($hard_reset = false, $reinstantiate = true)
175
+	{
176
+		if (self::$_instance instanceof EE_Config) {
177
+			if ($hard_reset) {
178
+				self::$_instance->legacy_shortcodes_manager = null;
179
+				self::$_instance->_addon_option_names = array();
180
+				self::$_instance->_initialize_config();
181
+				self::$_instance->update_espresso_config();
182
+			}
183
+			self::$_instance->update_addon_option_names();
184
+		}
185
+		self::$_instance = null;
186
+		self::$initialized = false;
187
+		// we don't need to reset the static properties imo because those should
188
+		// only change when a module is added or removed. Currently we don't
189
+		// support removing a module during a request when it previously existed
190
+		if ($reinstantiate) {
191
+			return self::instance();
192
+		} else {
193
+			return null;
194
+		}
195
+	}
196
+
197
+
198
+	private function __construct()
199
+	{
200
+		if (self::$initialized) {
201
+			return;
202
+		}
203
+		self::$initialized = true;
204
+		do_action('AHEE__EE_Config__construct__begin', $this);
205
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
206
+		// setup empty config classes
207
+		$this->_initialize_config();
208
+		// load existing EE site settings
209
+		$this->_load_core_config();
210
+		// confirm everything loaded correctly and set filtered defaults if not
211
+		$this->_verify_config();
212
+		//  register shortcodes and modules
213
+		add_action(
214
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
215
+			[$this, 'register_shortcodes_and_modules'],
216
+			999
217
+		);
218
+		//  initialize shortcodes and modules
219
+		add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'initialize_shortcodes_and_modules']);
220
+		// register widgets
221
+		add_action('widgets_init', [$this, 'widgets_init'], 10);
222
+		// shutdown
223
+		add_action('shutdown', [$this, 'shutdown'], 10);
224
+		// construct__end hook
225
+		do_action('AHEE__EE_Config__construct__end', $this);
226
+		// hardcoded hack
227
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
228
+	}
229
+
230
+
231
+	/**
232
+	 * @return boolean
233
+	 */
234
+	public static function logging_enabled()
235
+	{
236
+		return self::$_logging_enabled;
237
+	}
238
+
239
+
240
+	/**
241
+	 * use to get the current theme if needed from static context
242
+	 *
243
+	 * @return string current theme set.
244
+	 */
245
+	public static function get_current_theme()
246
+	{
247
+		return self::$_instance->template_settings->current_espresso_theme ?? 'Espresso_Arabica_2014';
248
+	}
249
+
250
+
251
+	/**
252
+	 *        _initialize_config
253
+	 *
254
+	 * @access private
255
+	 * @return void
256
+	 */
257
+	private function _initialize_config()
258
+	{
259
+		EE_Config::trim_log();
260
+		// set defaults
261
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
262
+		$this->addons = new stdClass();
263
+		// set _module_route_map
264
+		EE_Config::$_module_route_map = array();
265
+		// set _module_forward_map
266
+		EE_Config::$_module_forward_map = array();
267
+		// set _module_view_map
268
+		EE_Config::$_module_view_map = array();
269
+	}
270
+
271
+
272
+	/**
273
+	 *        load core plugin configuration
274
+	 *
275
+	 * @access private
276
+	 * @return void
277
+	 */
278
+	private function _load_core_config()
279
+	{
280
+		// load_core_config__start hook
281
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
282
+		$espresso_config = (array) $this->get_espresso_config();
283
+		// need to move the "addons" element to the end of the config array
284
+		// in case an addon config references one of the other config classes
285
+		$addons = $espresso_config['addons'] ?? new StdClass();
286
+		unset($espresso_config['addons']);
287
+		$espresso_config['addons'] = $addons;
288
+		foreach ($espresso_config as $config => $settings) {
289
+			// load_core_config__start hook
290
+			$settings = apply_filters(
291
+				'FHEE__EE_Config___load_core_config__config_settings',
292
+				$settings,
293
+				$config,
294
+				$this
295
+			);
296
+			if (is_object($settings) && property_exists($this, $config)) {
297
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
298
+				// call configs populate method to ensure any defaults are set for empty values.
299
+				if (method_exists($settings, 'populate')) {
300
+					$this->{$config}->populate();
301
+				}
302
+				if (method_exists($settings, 'do_hooks')) {
303
+					$this->{$config}->do_hooks();
304
+				}
305
+			}
306
+		}
307
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
308
+			$this->update_espresso_config();
309
+		}
310
+		// load_core_config__end hook
311
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
312
+	}
313
+
314
+
315
+	/**
316
+	 *    _verify_config
317
+	 *
318
+	 * @access    protected
319
+	 * @return    void
320
+	 */
321
+	protected function _verify_config()
322
+	{
323
+		$this->core = $this->core instanceof EE_Core_Config
324
+			? $this->core
325
+			: new EE_Core_Config();
326
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
327
+		$this->organization = $this->organization instanceof EE_Organization_Config
328
+			? $this->organization
329
+			: new EE_Organization_Config();
330
+		$this->organization = apply_filters(
331
+			'FHEE__EE_Config___initialize_config__organization',
332
+			$this->organization
333
+		);
334
+		$this->currency = $this->currency instanceof EE_Currency_Config
335
+			? $this->currency
336
+			: new EE_Currency_Config();
337
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
338
+		$this->registration = $this->registration instanceof EE_Registration_Config
339
+			? $this->registration
340
+			: new EE_Registration_Config();
341
+		$this->registration = apply_filters(
342
+			'FHEE__EE_Config___initialize_config__registration',
343
+			$this->registration
344
+		);
345
+		$this->admin = $this->admin instanceof EE_Admin_Config
346
+			? $this->admin
347
+			: new EE_Admin_Config();
348
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
349
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
350
+			? $this->template_settings
351
+			: new EE_Template_Config();
352
+		$this->template_settings = apply_filters(
353
+			'FHEE__EE_Config___initialize_config__template_settings',
354
+			$this->template_settings
355
+		);
356
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
357
+			? $this->map_settings
358
+			: new EE_Map_Config();
359
+		$this->map_settings = apply_filters(
360
+			'FHEE__EE_Config___initialize_config__map_settings',
361
+			$this->map_settings
362
+		);
363
+		$this->environment = $this->environment instanceof EE_Environment_Config
364
+			? $this->environment
365
+			: new EE_Environment_Config();
366
+		$this->environment = apply_filters(
367
+			'FHEE__EE_Config___initialize_config__environment',
368
+			$this->environment
369
+		);
370
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
371
+			? $this->tax_settings
372
+			: new EE_Tax_Config();
373
+		$this->tax_settings = apply_filters(
374
+			'FHEE__EE_Config___initialize_config__tax_settings',
375
+			$this->tax_settings
376
+		);
377
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
378
+		$this->messages = $this->messages instanceof EE_Messages_Config
379
+			? $this->messages
380
+			: new EE_Messages_Config();
381
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
382
+			? $this->gateway
383
+			: new EE_Gateway_Config();
384
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
385
+		$this->legacy_shortcodes_manager = null;
386
+	}
387
+
388
+
389
+	/**
390
+	 *    get_espresso_config
391
+	 *
392
+	 * @access    public
393
+	 * @return    array of espresso config stuff
394
+	 */
395
+	public function get_espresso_config()
396
+	{
397
+		// grab espresso configuration
398
+		return apply_filters(
399
+			'FHEE__EE_Config__get_espresso_config__CFG',
400
+			get_option(EE_Config::OPTION_NAME, array())
401
+		);
402
+	}
403
+
404
+
405
+	/**
406
+	 *    double_check_config_comparison
407
+	 *
408
+	 * @access    public
409
+	 * @param string $option
410
+	 * @param        $old_value
411
+	 * @param        $value
412
+	 */
413
+	public function double_check_config_comparison($option, $old_value, $value)
414
+	{
415
+		// make sure we're checking the ee config
416
+		if ($option === EE_Config::OPTION_NAME) {
417
+			// run a loose comparison of the old value against the new value for type and properties,
418
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
419
+			if ($value != $old_value) {
420
+				// if they are NOT the same, then remove the hook,
421
+				// which means the subsequent update results will be based solely on the update query results
422
+				// the reason we do this is because, as stated above,
423
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
424
+				// this happens PRIOR to serialization and any subsequent update.
425
+				// If values are found to match their previous old value,
426
+				// then WP bails before performing any update.
427
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
428
+				// it just pulled from the db, with the one being passed to it (which will not match).
429
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
430
+				// MySQL MAY ALSO NOT perform the update because
431
+				// the string it sees in the db looks the same as the new one it has been passed!!!
432
+				// This results in the query returning an "affected rows" value of ZERO,
433
+				// which gets returned immediately by WP update_option and looks like an error.
434
+				remove_action('update_option', array($this, 'check_config_updated'));
435
+			}
436
+		}
437
+	}
438
+
439
+
440
+	/**
441
+	 *    update_espresso_config
442
+	 *
443
+	 * @access   public
444
+	 */
445
+	protected function _reset_espresso_addon_config()
446
+	{
447
+		$this->_addon_option_names = array();
448
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
449
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
450
+			if ($addon_config_obj instanceof EE_Config_Base) {
451
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
452
+			}
453
+			$this->addons->{$addon_name} = null;
454
+		}
455
+	}
456
+
457
+
458
+	/**
459
+	 *    update_espresso_config
460
+	 *
461
+	 * @access   public
462
+	 * @param   bool $add_success
463
+	 * @param   bool $add_error
464
+	 * @return   bool
465
+	 */
466
+	public function update_espresso_config($add_success = false, $add_error = true)
467
+	{
468
+		// don't allow config updates during WP heartbeats
469
+		/** @var RequestInterface $request */
470
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
471
+		if ($request->isWordPressHeartbeat()) {
472
+			return false;
473
+		}
474
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
475
+		// $clone = clone( self::$_instance );
476
+		// self::$_instance = NULL;
477
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
478
+		$this->_reset_espresso_addon_config();
479
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
480
+		// but BEFORE the actual update occurs
481
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
482
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
483
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
484
+		$this->legacy_shortcodes_manager = null;
485
+		// now update "ee_config"
486
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
487
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
488
+		EE_Config::log(EE_Config::OPTION_NAME);
489
+		// if not saved... check if the hook we just added still exists;
490
+		// if it does, it means one of two things:
491
+		// that update_option bailed at the($value === $old_value) conditional,
492
+		// or...
493
+		// the db update query returned 0 rows affected
494
+		// (probably because the data  value was the same from its perspective)
495
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
496
+		// but just means no update occurred, so don't display an error to the user.
497
+		// BUT... if update_option returns FALSE, AND the hook is missing,
498
+		// then it means that something truly went wrong
499
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
500
+		// remove our action since we don't want it in the system anymore
501
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
502
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
503
+		// self::$_instance = $clone;
504
+		// unset( $clone );
505
+		// if config remains the same or was updated successfully
506
+		if ($saved) {
507
+			if ($add_success) {
508
+				EE_Error::add_success(
509
+					esc_html__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
510
+					__FILE__,
511
+					__FUNCTION__,
512
+					__LINE__
513
+				);
514
+			}
515
+			return true;
516
+		} else {
517
+			if ($add_error) {
518
+				EE_Error::add_error(
519
+					esc_html__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
520
+					__FILE__,
521
+					__FUNCTION__,
522
+					__LINE__
523
+				);
524
+			}
525
+			return false;
526
+		}
527
+	}
528
+
529
+
530
+	/**
531
+	 *    _verify_config_params
532
+	 *
533
+	 * @access    private
534
+	 * @param    string         $section
535
+	 * @param    string         $name
536
+	 * @param    string         $config_class
537
+	 * @param    EE_Config_Base $config_obj
538
+	 * @param    array          $tests_to_run
539
+	 * @param    bool           $display_errors
540
+	 * @return    bool    TRUE on success, FALSE on fail
541
+	 */
542
+	private function _verify_config_params(
543
+		$section = '',
544
+		$name = '',
545
+		$config_class = '',
546
+		$config_obj = null,
547
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
548
+		$display_errors = true
549
+	) {
550
+		try {
551
+			foreach ($tests_to_run as $test) {
552
+				switch ($test) {
553
+					// TEST #1 : check that section was set
554
+					case 1:
555
+						if (empty($section)) {
556
+							if ($display_errors) {
557
+								throw new EE_Error(
558
+									sprintf(
559
+										esc_html__(
560
+											'No configuration section has been provided while attempting to save "%s".',
561
+											'event_espresso'
562
+										),
563
+										$config_class
564
+									)
565
+								);
566
+							}
567
+							return false;
568
+						}
569
+						break;
570
+					// TEST #2 : check that settings section exists
571
+					case 2:
572
+						if (! isset($this->{$section})) {
573
+							if ($display_errors) {
574
+								throw new EE_Error(
575
+									sprintf(
576
+										esc_html__('The "%s" configuration section does not exist.', 'event_espresso'),
577
+										$section
578
+									)
579
+								);
580
+							}
581
+							return false;
582
+						}
583
+						break;
584
+					// TEST #3 : check that section is the proper format
585
+					case 3:
586
+						if (
587
+							! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
588
+						) {
589
+							if ($display_errors) {
590
+								throw new EE_Error(
591
+									sprintf(
592
+										esc_html__(
593
+											'The "%s" configuration settings have not been formatted correctly.',
594
+											'event_espresso'
595
+										),
596
+										$section
597
+									)
598
+								);
599
+							}
600
+							return false;
601
+						}
602
+						break;
603
+					// TEST #4 : check that config section name has been set
604
+					case 4:
605
+						if (empty($name)) {
606
+							if ($display_errors) {
607
+								throw new EE_Error(
608
+									esc_html__(
609
+										'No name has been provided for the specific configuration section.',
610
+										'event_espresso'
611
+									)
612
+								);
613
+							}
614
+							return false;
615
+						}
616
+						break;
617
+					// TEST #5 : check that a config class name has been set
618
+					case 5:
619
+						if (empty($config_class)) {
620
+							if ($display_errors) {
621
+								throw new EE_Error(
622
+									esc_html__(
623
+										'No class name has been provided for the specific configuration section.',
624
+										'event_espresso'
625
+									)
626
+								);
627
+							}
628
+							return false;
629
+						}
630
+						break;
631
+					// TEST #6 : verify config class is accessible
632
+					case 6:
633
+						if (! class_exists($config_class)) {
634
+							if ($display_errors) {
635
+								throw new EE_Error(
636
+									sprintf(
637
+										esc_html__(
638
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
639
+											'event_espresso'
640
+										),
641
+										$config_class
642
+									)
643
+								);
644
+							}
645
+							return false;
646
+						}
647
+						break;
648
+					// TEST #7 : check that config has even been set
649
+					case 7:
650
+						if (! isset($this->{$section}->{$name})) {
651
+							if ($display_errors) {
652
+								throw new EE_Error(
653
+									sprintf(
654
+										esc_html__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
655
+										$section,
656
+										$name
657
+									)
658
+								);
659
+							}
660
+							return false;
661
+						} else {
662
+							// and make sure it's not serialized
663
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
664
+						}
665
+						break;
666
+					// TEST #8 : check that config is the requested type
667
+					case 8:
668
+						if (! $this->{$section}->{$name} instanceof $config_class) {
669
+							if ($display_errors) {
670
+								throw new EE_Error(
671
+									sprintf(
672
+										esc_html__(
673
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
674
+											'event_espresso'
675
+										),
676
+										$section,
677
+										$name,
678
+										$config_class
679
+									)
680
+								);
681
+							}
682
+							return false;
683
+						}
684
+						break;
685
+					// TEST #9 : verify config object
686
+					case 9:
687
+						if (! $config_obj instanceof EE_Config_Base) {
688
+							if ($display_errors) {
689
+								throw new EE_Error(
690
+									sprintf(
691
+										esc_html__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
692
+										print_r($config_obj, true)
693
+									)
694
+								);
695
+							}
696
+							return false;
697
+						}
698
+						break;
699
+				}
700
+			}
701
+		} catch (EE_Error $e) {
702
+			$e->get_error();
703
+		}
704
+		// you have successfully run the gauntlet
705
+		return true;
706
+	}
707
+
708
+
709
+	/**
710
+	 *    _generate_config_option_name
711
+	 *
712
+	 * @access        protected
713
+	 * @param        string $section
714
+	 * @param        string $name
715
+	 * @return        string
716
+	 */
717
+	private function _generate_config_option_name($section = '', $name = '')
718
+	{
719
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
720
+	}
721
+
722
+
723
+	/**
724
+	 *    _set_config_class
725
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
726
+	 *
727
+	 * @access    private
728
+	 * @param    string $config_class
729
+	 * @param    string $name
730
+	 * @return    string
731
+	 */
732
+	private function _set_config_class($config_class = '', $name = '')
733
+	{
734
+		return ! empty($config_class)
735
+			? $config_class
736
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
737
+	}
738
+
739
+
740
+	/**
741
+	 * @param string              $section
742
+	 * @param string              $name
743
+	 * @param string              $config_class
744
+	 * @param EE_Config_Base|null $config_obj
745
+	 * @return EE_Config_Base
746
+	 */
747
+	public function set_config(
748
+		string $section = '',
749
+		string $name = '',
750
+		string $config_class = '',
751
+		EE_Config_Base $config_obj = null
752
+	): ?EE_Config_Base {
753
+		// ensure config class is set to something
754
+		$config_class = $this->_set_config_class($config_class, $name);
755
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
756
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
757
+			return null;
758
+		}
759
+		$config_option_name = $this->_generate_config_option_name($section, $name);
760
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
761
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
762
+			$this->_addon_option_names[ $config_option_name ] = $config_class;
763
+			$this->update_addon_option_names();
764
+		}
765
+		// verify the incoming config object but suppress errors
766
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
767
+			$config_obj = new $config_class();
768
+		}
769
+		if (get_option($config_option_name)) {
770
+			EE_Config::log($config_option_name);
771
+			try {
772
+				update_option($config_option_name, $config_obj);
773
+			} catch (Exception $exception) {
774
+				throw new DomainException(
775
+					sprintf(
776
+						esc_html__(
777
+							'The following exception occurred while attempting to update the "%1$s" class for config section "%2$s->%3$s": %4$s',
778
+							'event_espresso'
779
+						),
780
+						$config_class,
781
+						$section,
782
+						$name,
783
+						$exception->getMessage()
784
+					)
785
+				);
786
+			}
787
+			$this->{$section}->{$name} = $config_obj;
788
+			return $this->{$section}->{$name};
789
+		} else {
790
+			// create a wp-option for this config
791
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
792
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
793
+				return $this->{$section}->{$name};
794
+			} else {
795
+				EE_Error::add_error(
796
+					sprintf(esc_html__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
797
+					__FILE__,
798
+					__FUNCTION__,
799
+					__LINE__
800
+				);
801
+				return null;
802
+			}
803
+		}
804
+	}
805
+
806
+
807
+	/**
808
+	 *    update_config
809
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
810
+	 *
811
+	 * @access    public
812
+	 * @param    string                $section
813
+	 * @param    string                $name
814
+	 * @param    EE_Config_Base|string $config_obj
815
+	 * @param    bool                  $throw_errors
816
+	 * @return    bool
817
+	 */
818
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
819
+	{
820
+		// don't allow config updates during WP heartbeats
821
+		/** @var RequestInterface $request */
822
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
823
+		if ($request->isWordPressHeartbeat()) {
824
+			return false;
825
+		}
826
+		$config_obj = maybe_unserialize($config_obj);
827
+		// get class name of the incoming object
828
+		$config_class = get_class($config_obj);
829
+		// run tests 1-5 and 9 to verify config
830
+		if (
831
+			! $this->_verify_config_params(
832
+				$section,
833
+				$name,
834
+				$config_class,
835
+				$config_obj,
836
+				array(1, 2, 3, 4, 7, 9)
837
+			)
838
+		) {
839
+			return false;
840
+		}
841
+		$config_option_name = $this->_generate_config_option_name($section, $name);
842
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
843
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
844
+			// save new config to db
845
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
846
+				return true;
847
+			}
848
+		} else {
849
+			// first check if the record already exists
850
+			$existing_config = get_option($config_option_name);
851
+			$config_obj = serialize($config_obj);
852
+			// just return if db record is already up-to-date (NOT type safe comparison)
853
+			if ($existing_config == $config_obj) {
854
+				$this->{$section}->{$name} = $config_obj;
855
+				return true;
856
+			} elseif (update_option($config_option_name, $config_obj)) {
857
+				EE_Config::log($config_option_name);
858
+				// update wp-option for this config class
859
+				$this->{$section}->{$name} = $config_obj;
860
+				return true;
861
+			} elseif ($throw_errors) {
862
+				EE_Error::add_error(
863
+					sprintf(
864
+						esc_html__(
865
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
866
+							'event_espresso'
867
+						),
868
+						$config_class,
869
+						'EE_Config->' . $section . '->' . $name
870
+					),
871
+					__FILE__,
872
+					__FUNCTION__,
873
+					__LINE__
874
+				);
875
+			}
876
+		}
877
+		return false;
878
+	}
879
+
880
+
881
+	/**
882
+	 *    get_config
883
+	 *
884
+	 * @access    public
885
+	 * @param    string $section
886
+	 * @param    string $name
887
+	 * @param    string $config_class
888
+	 * @return    mixed EE_Config_Base | NULL
889
+	 */
890
+	public function get_config($section = '', $name = '', $config_class = '')
891
+	{
892
+		// ensure config class is set to something
893
+		$config_class = $this->_set_config_class($config_class, $name);
894
+		// run tests 1-4, 6 and 7 to verify that all params have been set
895
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
896
+			return null;
897
+		}
898
+		// now test if the requested config object exists, but suppress errors
899
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
900
+			// config already exists, so pass it back
901
+			return $this->{$section}->{$name};
902
+		}
903
+		// load config option from db if it exists
904
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
905
+		// verify the newly retrieved config object, but suppress errors
906
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
907
+			// config is good, so set it and pass it back
908
+			$this->{$section}->{$name} = $config_obj;
909
+			return $this->{$section}->{$name};
910
+		}
911
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
912
+		$config_obj = $this->set_config($section, $name, $config_class);
913
+		// verify the newly created config object
914
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
915
+			return $this->{$section}->{$name};
916
+		} else {
917
+			EE_Error::add_error(
918
+				sprintf(esc_html__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
919
+				__FILE__,
920
+				__FUNCTION__,
921
+				__LINE__
922
+			);
923
+		}
924
+		return null;
925
+	}
926
+
927
+
928
+	/**
929
+	 *    get_config_option
930
+	 *
931
+	 * @access    public
932
+	 * @param    string $config_option_name
933
+	 * @return    mixed EE_Config_Base | FALSE
934
+	 */
935
+	public function get_config_option($config_option_name = '')
936
+	{
937
+		// retrieve the wp-option for this config class.
938
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
939
+		if (empty($config_option)) {
940
+			EE_Config::log($config_option_name . '-NOT-FOUND');
941
+		}
942
+		return $config_option;
943
+	}
944
+
945
+
946
+	/**
947
+	 * log
948
+	 *
949
+	 * @param string $config_option_name
950
+	 */
951
+	public static function log($config_option_name = '')
952
+	{
953
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
954
+			$config_log = get_option(EE_Config::LOG_NAME, array());
955
+			/** @var RequestParams $request */
956
+			$request = LoaderFactory::getLoader()->getShared(RequestParams::class);
957
+			$config_log[ (string) microtime(true) ] = array(
958
+				'config_name' => $config_option_name,
959
+				'request'     => $request->requestParams(),
960
+			);
961
+			update_option(EE_Config::LOG_NAME, $config_log);
962
+		}
963
+	}
964
+
965
+
966
+	/**
967
+	 * trim_log
968
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
969
+	 */
970
+	public static function trim_log()
971
+	{
972
+		if (! EE_Config::logging_enabled()) {
973
+			return;
974
+		}
975
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
976
+		$log_length = count($config_log);
977
+		if ($log_length > EE_Config::LOG_LENGTH) {
978
+			ksort($config_log);
979
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
980
+			update_option(EE_Config::LOG_NAME, $config_log);
981
+		}
982
+	}
983
+
984
+
985
+	/**
986
+	 *    get_page_for_posts
987
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
988
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
989
+	 *
990
+	 * @access    public
991
+	 * @return    string
992
+	 */
993
+	public static function get_page_for_posts()
994
+	{
995
+		$page_for_posts = get_option('page_for_posts');
996
+		if (! $page_for_posts) {
997
+			return 'posts';
998
+		}
999
+		global $wpdb;
1000
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
1001
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
1002
+	}
1003
+
1004
+
1005
+	/**
1006
+	 *    register_shortcodes_and_modules.
1007
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
1008
+	 *    In fact, this is where we give modules a chance to let core know they exist
1009
+	 *    so they can help trigger maintenance mode if it's needed
1010
+	 *
1011
+	 * @access    public
1012
+	 * @return    void
1013
+	 */
1014
+	public function register_shortcodes_and_modules()
1015
+	{
1016
+		// allow modules to set hooks for the rest of the system
1017
+		EE_Registry::instance()->modules = $this->_register_modules();
1018
+	}
1019
+
1020
+
1021
+	/**
1022
+	 *    initialize_shortcodes_and_modules
1023
+	 *    meaning they can start adding their hooks to get stuff done
1024
+	 *
1025
+	 * @access    public
1026
+	 * @return    void
1027
+	 */
1028
+	public function initialize_shortcodes_and_modules()
1029
+	{
1030
+		// allow modules to set hooks for the rest of the system
1031
+		$this->_initialize_modules();
1032
+	}
1033
+
1034
+
1035
+	/**
1036
+	 *    widgets_init
1037
+	 *
1038
+	 * @access private
1039
+	 * @return void
1040
+	 */
1041
+	public function widgets_init()
1042
+	{
1043
+		// only init widgets on admin pages when not in complete maintenance, and
1044
+		// on frontend when not in any maintenance mode
1045
+		if (
1046
+			MaintenanceStatus::isDisabled()
1047
+			|| (is_admin() && MaintenanceStatus::isNotFullSite())
1048
+		) {
1049
+			// grab list of installed widgets
1050
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1051
+			// filter list of modules to register
1052
+			$widgets_to_register = apply_filters(
1053
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1054
+				$widgets_to_register
1055
+			);
1056
+			if (! empty($widgets_to_register)) {
1057
+				// cycle thru widget folders
1058
+				foreach ($widgets_to_register as $widget_path) {
1059
+					// add to list of installed widget modules
1060
+					EE_Config::register_ee_widget($widget_path);
1061
+				}
1062
+			}
1063
+			// filter list of installed modules
1064
+			EE_Registry::instance()->widgets = apply_filters(
1065
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1066
+				EE_Registry::instance()->widgets
1067
+			);
1068
+		}
1069
+	}
1070
+
1071
+
1072
+	/**
1073
+	 *    register_ee_widget - makes core aware of this widget
1074
+	 *
1075
+	 * @access    public
1076
+	 * @param    string $widget_path - full path up to and including widget folder
1077
+	 * @return    void
1078
+	 */
1079
+	public static function register_ee_widget($widget_path = null)
1080
+	{
1081
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1082
+		$widget_ext = '.widget.php';
1083
+		// make all separators match
1084
+		$widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1085
+		// does the file path INCLUDE the actual file name as part of the path ?
1086
+		if (strpos($widget_path, $widget_ext) !== false) {
1087
+			// grab and shortcode file name from directory name and break apart at dots
1088
+			$file_name = explode('.', basename($widget_path));
1089
+			// take first segment from file name pieces and remove class prefix if it exists
1090
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1091
+			// sanitize shortcode directory name
1092
+			$widget = sanitize_key($widget);
1093
+			// now we need to rebuild the shortcode path
1094
+			$widget_path = explode('/', $widget_path);
1095
+			// remove last segment
1096
+			array_pop($widget_path);
1097
+			// glue it back together
1098
+			$widget_path = implode(DS, $widget_path);
1099
+		} else {
1100
+			// grab and sanitize widget directory name
1101
+			$widget = sanitize_key(basename($widget_path));
1102
+		}
1103
+		// create classname from widget directory name
1104
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1105
+		// add class prefix
1106
+		$widget_class = 'EEW_' . $widget;
1107
+		// does the widget exist ?
1108
+		if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1109
+			$msg = sprintf(
1110
+				esc_html__(
1111
+					'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',
1112
+					'event_espresso'
1113
+				),
1114
+				$widget_class,
1115
+				$widget_path . '/' . $widget_class . $widget_ext
1116
+			);
1117
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1118
+			return;
1119
+		}
1120
+		// load the widget class file
1121
+		require_once($widget_path . '/' . $widget_class . $widget_ext);
1122
+		// verify that class exists
1123
+		if (! class_exists($widget_class)) {
1124
+			$msg = sprintf(esc_html__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1125
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1126
+			return;
1127
+		}
1128
+		register_widget($widget_class);
1129
+		// add to array of registered widgets
1130
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1131
+	}
1132
+
1133
+
1134
+	/**
1135
+	 *        _register_modules
1136
+	 *
1137
+	 * @access private
1138
+	 * @return array
1139
+	 */
1140
+	private function _register_modules()
1141
+	{
1142
+		// grab list of installed modules
1143
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1144
+		// filter list of modules to register
1145
+		$modules_to_register = apply_filters(
1146
+			'FHEE__EE_Config__register_modules__modules_to_register',
1147
+			$modules_to_register
1148
+		);
1149
+		if (! empty($modules_to_register)) {
1150
+			// loop through folders
1151
+			foreach ($modules_to_register as $module_path) {
1152
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1153
+				if (
1154
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1155
+					&& $module_path !== EE_MODULES . 'gateways'
1156
+				) {
1157
+					// add to list of installed modules
1158
+					EE_Config::register_module($module_path);
1159
+				}
1160
+			}
1161
+		}
1162
+		// filter list of installed modules
1163
+		return apply_filters(
1164
+			'FHEE__EE_Config___register_modules__installed_modules',
1165
+			EE_Registry::instance()->modules
1166
+		);
1167
+	}
1168
+
1169
+
1170
+	/**
1171
+	 *    register_module - makes core aware of this module
1172
+	 *
1173
+	 * @access    public
1174
+	 * @param    string $module_path - full path up to and including module folder
1175
+	 * @return    bool
1176
+	 */
1177
+	public static function register_module($module_path = null)
1178
+	{
1179
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1180
+		$module_ext = '.module.php';
1181
+		// make all separators match
1182
+		$module_path = str_replace(array('\\', '/'), '/', $module_path);
1183
+		// does the file path INCLUDE the actual file name as part of the path ?
1184
+		if (strpos($module_path, $module_ext) !== false) {
1185
+			// grab and shortcode file name from directory name and break apart at dots
1186
+			$module_file = explode('.', basename($module_path));
1187
+			// now we need to rebuild the shortcode path
1188
+			$module_path = explode('/', $module_path);
1189
+			// remove last segment
1190
+			array_pop($module_path);
1191
+			// glue it back together
1192
+			$module_path = implode('/', $module_path) . '/';
1193
+			// take first segment from file name pieces and sanitize it
1194
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1195
+			// ensure class prefix is added
1196
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1197
+		} else {
1198
+			// we need to generate the filename based off of the folder name
1199
+			// grab and sanitize module name
1200
+			$module = strtolower(basename($module_path));
1201
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1202
+			// like trailingslashit()
1203
+			$module_path = rtrim($module_path, '/') . '/';
1204
+			// create classname from module directory name
1205
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1206
+			// add class prefix
1207
+			$module_class = 'EED_' . $module;
1208
+		}
1209
+		// does the module exist ?
1210
+		if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1211
+			$msg = sprintf(
1212
+				esc_html__(
1213
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1214
+					'event_espresso'
1215
+				),
1216
+				$module
1217
+			);
1218
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1219
+			return false;
1220
+		}
1221
+		// load the module class file
1222
+		require_once($module_path . $module_class . $module_ext);
1223
+		// verify that class exists
1224
+		if (! class_exists($module_class)) {
1225
+			$msg = sprintf(esc_html__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1226
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1227
+			return false;
1228
+		}
1229
+		// add to array of registered modules
1230
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1231
+		do_action(
1232
+			'AHEE__EE_Config__register_module__complete',
1233
+			$module_class,
1234
+			EE_Registry::instance()->modules->{$module_class}
1235
+		);
1236
+		return true;
1237
+	}
1238
+
1239
+
1240
+	/**
1241
+	 *    _initialize_modules
1242
+	 *    allow modules to set hooks for the rest of the system
1243
+	 *
1244
+	 * @access private
1245
+	 * @return void
1246
+	 */
1247
+	private function _initialize_modules()
1248
+	{
1249
+		// cycle thru shortcode folders
1250
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1251
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1252
+			// which set hooks ?
1253
+			if (is_admin() && is_callable([$module_class, 'set_hooks_admin'])) {
1254
+				// fire immediately
1255
+				call_user_func([$module_class, 'set_hooks_admin']);
1256
+			} else {
1257
+				// delay until other systems are online
1258
+				add_action(
1259
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1260
+					array($module_class, 'set_hooks')
1261
+				);
1262
+			}
1263
+		}
1264
+	}
1265
+
1266
+
1267
+	/**
1268
+	 *    register_route - adds module method routes to route_map
1269
+	 *
1270
+	 * @access    public
1271
+	 * @param    string $route       - "pretty" public alias for module method
1272
+	 * @param    string $module      - module name (classname without EED_ prefix)
1273
+	 * @param    string $method_name - the actual module method to be routed to
1274
+	 * @param    string $key         - url param key indicating a route is being called
1275
+	 * @return    bool
1276
+	 */
1277
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1278
+	{
1279
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1280
+		$module = str_replace('EED_', '', $module);
1281
+		$module_class = 'EED_' . $module;
1282
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1283
+			$msg = sprintf(esc_html__('The module %s has not been registered.', 'event_espresso'), $module);
1284
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1285
+			return false;
1286
+		}
1287
+		if (empty($route)) {
1288
+			$msg = sprintf(esc_html__('No route has been supplied.', 'event_espresso'), $route);
1289
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1290
+			return false;
1291
+		}
1292
+		if (! method_exists('EED_' . $module, $method_name)) {
1293
+			$msg = sprintf(
1294
+				esc_html__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1295
+				$route
1296
+			);
1297
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1298
+			return false;
1299
+		}
1300
+		EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1301
+		return true;
1302
+	}
1303
+
1304
+
1305
+	/**
1306
+	 *    get_route - get module method route
1307
+	 *
1308
+	 * @access    public
1309
+	 * @param    string $route - "pretty" public alias for module method
1310
+	 * @param    string $key   - url param key indicating a route is being called
1311
+	 * @return    string
1312
+	 */
1313
+	public static function get_route($route = null, $key = 'ee')
1314
+	{
1315
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1316
+		$route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1317
+		if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1318
+			return EE_Config::$_module_route_map[ $key ][ $route ];
1319
+		}
1320
+		return null;
1321
+	}
1322
+
1323
+
1324
+	/**
1325
+	 *    get_routes - get ALL module method routes
1326
+	 *
1327
+	 * @access    public
1328
+	 * @return    array
1329
+	 */
1330
+	public static function get_routes()
1331
+	{
1332
+		return EE_Config::$_module_route_map;
1333
+	}
1334
+
1335
+
1336
+	/**
1337
+	 *    register_forward - allows modules to forward request to another module for further processing
1338
+	 *
1339
+	 * @access    public
1340
+	 * @param    string       $route   - "pretty" public alias for module method
1341
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1342
+	 *                                 class, allows different forwards to be served based on status
1343
+	 * @param    array|string $forward - function name or array( class, method )
1344
+	 * @param    string       $key     - url param key indicating a route is being called
1345
+	 * @return    bool
1346
+	 */
1347
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1348
+	{
1349
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1350
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1351
+			$msg = sprintf(
1352
+				esc_html__('The module route %s for this forward has not been registered.', 'event_espresso'),
1353
+				$route
1354
+			);
1355
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1356
+			return false;
1357
+		}
1358
+		if (empty($forward)) {
1359
+			$msg = sprintf(esc_html__('No forwarding route has been supplied.', 'event_espresso'), $route);
1360
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1361
+			return false;
1362
+		}
1363
+		if (is_array($forward)) {
1364
+			if (! isset($forward[1])) {
1365
+				$msg = sprintf(
1366
+					esc_html__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1367
+					$route
1368
+				);
1369
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1370
+				return false;
1371
+			}
1372
+			if (! method_exists($forward[0], $forward[1])) {
1373
+				$msg = sprintf(
1374
+					esc_html__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1375
+					$forward[1],
1376
+					$route
1377
+				);
1378
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1379
+				return false;
1380
+			}
1381
+		} elseif (! function_exists($forward)) {
1382
+			$msg = sprintf(
1383
+				esc_html__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1384
+				$forward,
1385
+				$route
1386
+			);
1387
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1388
+			return false;
1389
+		}
1390
+		EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1391
+		return true;
1392
+	}
1393
+
1394
+
1395
+	/**
1396
+	 *    get_forward - get forwarding route
1397
+	 *
1398
+	 * @access    public
1399
+	 * @param    string  $route  - "pretty" public alias for module method
1400
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1401
+	 *                           allows different forwards to be served based on status
1402
+	 * @param    string  $key    - url param key indicating a route is being called
1403
+	 * @return    string
1404
+	 */
1405
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1406
+	{
1407
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1408
+		if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1409
+			return apply_filters(
1410
+				'FHEE__EE_Config__get_forward',
1411
+				EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1412
+				$route,
1413
+				$status
1414
+			);
1415
+		}
1416
+		return null;
1417
+	}
1418
+
1419
+
1420
+	/**
1421
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1422
+	 *    results
1423
+	 *
1424
+	 * @access    public
1425
+	 * @param    string  $route  - "pretty" public alias for module method
1426
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1427
+	 *                           allows different views to be served based on status
1428
+	 * @param    string  $view
1429
+	 * @param    string  $key    - url param key indicating a route is being called
1430
+	 * @return    bool
1431
+	 */
1432
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1433
+	{
1434
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1435
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1436
+			$msg = sprintf(
1437
+				esc_html__('The module route %s for this view has not been registered.', 'event_espresso'),
1438
+				$route
1439
+			);
1440
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1441
+			return false;
1442
+		}
1443
+		if (! is_readable($view)) {
1444
+			$msg = sprintf(
1445
+				esc_html__(
1446
+					'The %s view file could not be found or is not readable due to file permissions.',
1447
+					'event_espresso'
1448
+				),
1449
+				$view
1450
+			);
1451
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1452
+			return false;
1453
+		}
1454
+		EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1455
+		return true;
1456
+	}
1457
+
1458
+
1459
+	/**
1460
+	 *    get_view - get view for route and status
1461
+	 *
1462
+	 * @access    public
1463
+	 * @param    string  $route  - "pretty" public alias for module method
1464
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1465
+	 *                           allows different views to be served based on status
1466
+	 * @param    string  $key    - url param key indicating a route is being called
1467
+	 * @return    string
1468
+	 */
1469
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1470
+	{
1471
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1472
+		if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1473
+			return apply_filters(
1474
+				'FHEE__EE_Config__get_view',
1475
+				EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1476
+				$route,
1477
+				$status
1478
+			);
1479
+		}
1480
+		return null;
1481
+	}
1482
+
1483
+
1484
+	public function update_addon_option_names()
1485
+	{
1486
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1487
+	}
1488
+
1489
+
1490
+	public function shutdown()
1491
+	{
1492
+		$this->update_addon_option_names();
1493
+	}
1494
+
1495
+
1496
+	/**
1497
+	 * @return LegacyShortcodesManager
1498
+	 */
1499
+	public static function getLegacyShortcodesManager()
1500
+	{
1501
+		if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1502
+			EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1503
+				LegacyShortcodesManager::class
1504
+			);
1505
+		}
1506
+		return EE_Config::instance()->legacy_shortcodes_manager;
1507
+	}
1508
+
1509
+
1510
+	/**
1511
+	 * register_shortcode - makes core aware of this shortcode
1512
+	 *
1513
+	 * @deprecated 4.9.26
1514
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1515
+	 * @return    bool
1516
+	 */
1517
+	public static function register_shortcode($shortcode_path = null)
1518
+	{
1519
+		EE_Error::doing_it_wrong(
1520
+			__METHOD__,
1521
+			esc_html__(
1522
+				'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.',
1523
+				'event_espresso'
1524
+			),
1525
+			'4.9.26'
1526
+		);
1527
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1528
+	}
1529
+}
2360 1530
 
2361
-    /**
2362
-     * ReCaptcha width
2363
-     *
2364
-     * @var int $recaptcha_width
2365
-     * @deprecated
2366
-     */
2367
-    public $recaptcha_width;
1531
+/**
1532
+ * Base class used for config classes. These classes should generally not have
1533
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1534
+ * basically, they should just be well-defined stdClasses
1535
+ */
1536
+class EE_Config_Base
1537
+{
1538
+	/**
1539
+	 * Utility function for escaping the value of a property and returning.
1540
+	 *
1541
+	 * @param string $property property name (checks to see if exists).
1542
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1543
+	 * @throws EE_Error
1544
+	 */
1545
+	public function get_pretty($property)
1546
+	{
1547
+		if (! property_exists($this, $property)) {
1548
+			throw new EE_Error(
1549
+				sprintf(
1550
+					esc_html__(
1551
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1552
+						'event_espresso'
1553
+					),
1554
+					get_class($this),
1555
+					$property
1556
+				)
1557
+			);
1558
+		}
1559
+		// just handling escaping of strings for now.
1560
+		if (is_string($this->{$property})) {
1561
+			return stripslashes($this->{$property});
1562
+		}
1563
+		return $this->{$property};
1564
+	}
1565
+
1566
+
1567
+	public function populate()
1568
+	{
1569
+		// grab defaults via a new instance of this class.
1570
+		$class_name = get_class($this);
1571
+		$defaults = new $class_name();
1572
+		// loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1573
+		// default from our $defaults object.
1574
+		foreach (get_object_vars($defaults) as $property => $value) {
1575
+			if ($this->{$property} === null) {
1576
+				$this->{$property} = $value;
1577
+			}
1578
+		}
1579
+		// cleanup
1580
+		unset($defaults);
1581
+	}
1582
+
1583
+
1584
+	/**
1585
+	 *        __isset
1586
+	 *
1587
+	 * @param $a
1588
+	 * @return bool
1589
+	 */
1590
+	public function __isset($a)
1591
+	{
1592
+		return false;
1593
+	}
1594
+
1595
+
1596
+	/**
1597
+	 *        __unset
1598
+	 *
1599
+	 * @param $a
1600
+	 * @return bool
1601
+	 */
1602
+	public function __unset($a)
1603
+	{
1604
+		return false;
1605
+	}
1606
+
1607
+
1608
+	/**
1609
+	 *        __clone
1610
+	 */
1611
+	public function __clone()
1612
+	{
1613
+	}
1614
+
1615
+
1616
+	/**
1617
+	 *        __wakeup
1618
+	 */
1619
+	public function __wakeup()
1620
+	{
1621
+	}
1622
+
1623
+
1624
+	/**
1625
+	 *        __destruct
1626
+	 */
1627
+	public function __destruct()
1628
+	{
1629
+	}
1630
+}
2368 1631
 
2369
-    /**
2370
-     * Whether invalid attempts to directly access the registration checkout page should be tracked.
2371
-     *
2372
-     * @var boolean $track_invalid_checkout_access
2373
-     */
2374
-    protected $track_invalid_checkout_access = true;
1632
+/**
1633
+ * Class for defining what's in the EE_Config relating to registration settings
1634
+ */
1635
+class EE_Core_Config extends EE_Config_Base
1636
+{
1637
+	const OPTION_NAME_UXIP = 'ee_ueip_optin';
1638
+
1639
+
1640
+	public $current_blog_id;
1641
+
1642
+	public $ee_ueip_optin;
1643
+
1644
+	public $ee_ueip_has_notified;
1645
+
1646
+	/**
1647
+	 * Not to be confused with the 4 critical page variables (See
1648
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1649
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1650
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1651
+	 *
1652
+	 * @var array
1653
+	 */
1654
+	public $post_shortcodes;
1655
+
1656
+	public $module_route_map;
1657
+
1658
+	public $module_forward_map;
1659
+
1660
+	public $module_view_map;
1661
+
1662
+	/**
1663
+	 * The next 4 vars are the IDs of critical EE pages.
1664
+	 *
1665
+	 * @var int
1666
+	 */
1667
+	public $reg_page_id;
1668
+
1669
+	public $txn_page_id;
1670
+
1671
+	public $thank_you_page_id;
1672
+
1673
+	public $cancel_page_id;
1674
+
1675
+	/**
1676
+	 * The next 4 vars are the URLs of critical EE pages.
1677
+	 *
1678
+	 * @var int
1679
+	 */
1680
+	public $reg_page_url;
1681
+
1682
+	public $txn_page_url;
1683
+
1684
+	public $thank_you_page_url;
1685
+
1686
+	public $cancel_page_url;
1687
+
1688
+	/**
1689
+	 * The next vars relate to the custom slugs for EE CPT routes
1690
+	 */
1691
+	public $event_cpt_slug;
1692
+
1693
+	/**
1694
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1695
+	 * request across blog switches in a multisite context.
1696
+	 * Avoids extra queries to the db for this option.
1697
+	 *
1698
+	 * @var bool
1699
+	 */
1700
+	public static $ee_ueip_option;
1701
+
1702
+
1703
+	/**
1704
+	 *    class constructor
1705
+	 *
1706
+	 * @access    public
1707
+	 */
1708
+	public function __construct()
1709
+	{
1710
+		// set default organization settings
1711
+		$this->current_blog_id = get_current_blog_id();
1712
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1713
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1714
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1715
+		$this->post_shortcodes = array();
1716
+		$this->module_route_map = array();
1717
+		$this->module_forward_map = array();
1718
+		$this->module_view_map = array();
1719
+		// critical EE page IDs
1720
+		$this->reg_page_id = 0;
1721
+		$this->txn_page_id = 0;
1722
+		$this->thank_you_page_id = 0;
1723
+		$this->cancel_page_id = 0;
1724
+		// critical EE page URLs
1725
+		$this->reg_page_url = '';
1726
+		$this->txn_page_url = '';
1727
+		$this->thank_you_page_url = '';
1728
+		$this->cancel_page_url = '';
1729
+		// cpt slugs
1730
+		$this->event_cpt_slug = esc_html__('events', 'event_espresso');
1731
+		// ueip constant check
1732
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1733
+			$this->ee_ueip_optin = false;
1734
+			$this->ee_ueip_has_notified = true;
1735
+		}
1736
+	}
1737
+
1738
+
1739
+	/**
1740
+	 * @return array
1741
+	 */
1742
+	public function get_critical_pages_array()
1743
+	{
1744
+		return array(
1745
+			$this->reg_page_id,
1746
+			$this->txn_page_id,
1747
+			$this->thank_you_page_id,
1748
+			$this->cancel_page_id,
1749
+		);
1750
+	}
1751
+
1752
+
1753
+	/**
1754
+	 * @return array
1755
+	 */
1756
+	public function get_critical_pages_shortcodes_array()
1757
+	{
1758
+		return array(
1759
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1760
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1761
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1762
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1763
+		);
1764
+	}
1765
+
1766
+
1767
+	/**
1768
+	 *  gets/returns URL for EE reg_page
1769
+	 *
1770
+	 * @access    public
1771
+	 * @return    string
1772
+	 */
1773
+	public function reg_page_url()
1774
+	{
1775
+		if (! $this->reg_page_url) {
1776
+			$this->reg_page_url = add_query_arg(
1777
+				array('uts' => time()),
1778
+				get_permalink($this->reg_page_id)
1779
+			) . '#checkout';
1780
+		}
1781
+		return $this->reg_page_url;
1782
+	}
1783
+
1784
+
1785
+	/**
1786
+	 *  gets/returns URL for EE txn_page
1787
+	 *
1788
+	 * @param array $query_args like what gets passed to
1789
+	 *                          add_query_arg() as the first argument
1790
+	 * @access    public
1791
+	 * @return    string
1792
+	 */
1793
+	public function txn_page_url($query_args = array())
1794
+	{
1795
+		if (! $this->txn_page_url) {
1796
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1797
+		}
1798
+		if ($query_args) {
1799
+			return add_query_arg($query_args, $this->txn_page_url);
1800
+		} else {
1801
+			return $this->txn_page_url;
1802
+		}
1803
+	}
1804
+
1805
+
1806
+	/**
1807
+	 *  gets/returns URL for EE thank_you_page
1808
+	 *
1809
+	 * @param array $query_args like what gets passed to
1810
+	 *                          add_query_arg() as the first argument
1811
+	 * @access    public
1812
+	 * @return    string
1813
+	 */
1814
+	public function thank_you_page_url($query_args = array())
1815
+	{
1816
+		if (! $this->thank_you_page_url) {
1817
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1818
+		}
1819
+		if ($query_args) {
1820
+			return add_query_arg($query_args, $this->thank_you_page_url);
1821
+		} else {
1822
+			return $this->thank_you_page_url;
1823
+		}
1824
+	}
1825
+
1826
+
1827
+	/**
1828
+	 *  gets/returns URL for EE cancel_page
1829
+	 *
1830
+	 * @access    public
1831
+	 * @return    string
1832
+	 */
1833
+	public function cancel_page_url()
1834
+	{
1835
+		if (! $this->cancel_page_url) {
1836
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1837
+		}
1838
+		return $this->cancel_page_url;
1839
+	}
1840
+
1841
+
1842
+	/**
1843
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1844
+	 *
1845
+	 * @since 4.7.5
1846
+	 */
1847
+	protected function _reset_urls()
1848
+	{
1849
+		$this->reg_page_url = '';
1850
+		$this->txn_page_url = '';
1851
+		$this->cancel_page_url = '';
1852
+		$this->thank_you_page_url = '';
1853
+	}
1854
+
1855
+
1856
+	/**
1857
+	 * Used to return what the optin value is set for the EE User Experience Program.
1858
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1859
+	 * on the main site only.
1860
+	 *
1861
+	 * @return bool
1862
+	 */
1863
+	protected function _get_main_ee_ueip_optin()
1864
+	{
1865
+		// if this is the main site then we can just bypass our direct query.
1866
+		if (is_main_site()) {
1867
+			return get_option(self::OPTION_NAME_UXIP, false);
1868
+		}
1869
+		// is this already cached for this request?  If so use it.
1870
+		if (EE_Core_Config::$ee_ueip_option !== null) {
1871
+			return EE_Core_Config::$ee_ueip_option;
1872
+		}
1873
+		global $wpdb;
1874
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1875
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1876
+		$option = self::OPTION_NAME_UXIP;
1877
+		// set correct table for query
1878
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1879
+		// rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1880
+		// get_blog_option() does a switch_to_blog and that could cause infinite recursion because EE_Core_Config might be
1881
+		// re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1882
+		// this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1883
+		// for the purpose of caching.
1884
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1885
+		if (false !== $pre) {
1886
+			EE_Core_Config::$ee_ueip_option = $pre;
1887
+			return EE_Core_Config::$ee_ueip_option;
1888
+		}
1889
+		$row = $wpdb->get_row(
1890
+			$wpdb->prepare(
1891
+				"SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1892
+				$option
1893
+			)
1894
+		);
1895
+		if (is_object($row)) {
1896
+			$value = $row->option_value;
1897
+		} else { // option does not exist so use default.
1898
+			EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1899
+			return EE_Core_Config::$ee_ueip_option;
1900
+		}
1901
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1902
+		return EE_Core_Config::$ee_ueip_option;
1903
+	}
1904
+
1905
+
1906
+	/**
1907
+	 * Utility function for escaping the value of a property and returning.
1908
+	 *
1909
+	 * @param string $property property name (checks to see if exists).
1910
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1911
+	 * @throws EE_Error
1912
+	 */
1913
+	public function get_pretty($property)
1914
+	{
1915
+		if ($property === self::OPTION_NAME_UXIP) {
1916
+			return $this->ee_ueip_optin ? 'yes' : 'no';
1917
+		}
1918
+		return parent::get_pretty($property);
1919
+	}
1920
+
1921
+
1922
+	/**
1923
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1924
+	 * on the object.
1925
+	 *
1926
+	 * @return array
1927
+	 */
1928
+	public function __sleep()
1929
+	{
1930
+		// reset all url properties
1931
+		$this->_reset_urls();
1932
+		// return what to save to db
1933
+		return array_keys(get_object_vars($this));
1934
+	}
1935
+}
2375 1936
 
2376
-    /**
2377
-     * Whether to show the privacy policy consent checkbox
2378
-     *
2379
-     * @var bool
2380
-     */
2381
-    public $consent_checkbox_enabled;
1937
+/**
1938
+ * Config class for storing info on the Organization
1939
+ */
1940
+class EE_Organization_Config extends EE_Config_Base
1941
+{
1942
+	/**
1943
+	 * @var string $name
1944
+	 * eg EE4.1
1945
+	 */
1946
+	public $name;
1947
+
1948
+	/**
1949
+	 * @var string $address_1
1950
+	 * eg 123 Onna Road
1951
+	 */
1952
+	public $address_1 = '';
1953
+
1954
+	/**
1955
+	 * @var string $address_2
1956
+	 * eg PO Box 123
1957
+	 */
1958
+	public $address_2 = '';
1959
+
1960
+	/**
1961
+	 * @var string $city
1962
+	 * eg Inna City
1963
+	 */
1964
+	public $city = '';
1965
+
1966
+	/**
1967
+	 * @var int $STA_ID
1968
+	 * eg 4
1969
+	 */
1970
+	public $STA_ID = 0;
1971
+
1972
+	/**
1973
+	 * @var string $CNT_ISO
1974
+	 * eg US
1975
+	 */
1976
+	public $CNT_ISO = 'US';
1977
+
1978
+	/**
1979
+	 * @var string $zip
1980
+	 * eg 12345  or V1A 2B3
1981
+	 */
1982
+	public $zip = '';
1983
+
1984
+	/**
1985
+	 * @var string $email
1986
+	 * eg [email protected]
1987
+	 */
1988
+	public $email;
1989
+
1990
+	/**
1991
+	 * @var string $phone
1992
+	 * eg. 111-111-1111
1993
+	 */
1994
+	public $phone = '';
1995
+
1996
+	/**
1997
+	 * @var string $vat
1998
+	 * VAT/Tax Number
1999
+	 */
2000
+	public $vat = '';
2001
+
2002
+	/**
2003
+	 * @var string $logo_url
2004
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2005
+	 */
2006
+	public $logo_url = '';
2007
+
2008
+	/**
2009
+	 * The below are all various properties for holding links to organization social network profiles
2010
+	 */
2011
+	/**
2012
+	 * facebook (facebook.com/profile.name)
2013
+	 *
2014
+	 * @var string
2015
+	 */
2016
+	public $facebook = '';
2017
+
2018
+	/**
2019
+	 * twitter (twitter.com/twitter_handle)
2020
+	 *
2021
+	 * @var string
2022
+	 */
2023
+	public $twitter = '';
2024
+
2025
+	/**
2026
+	 * linkedin (linkedin.com/in/profile_name)
2027
+	 *
2028
+	 * @var string
2029
+	 */
2030
+	public $linkedin = '';
2031
+
2032
+	/**
2033
+	 * pinterest (www.pinterest.com/profile_name)
2034
+	 *
2035
+	 * @var string
2036
+	 */
2037
+	public $pinterest = '';
2038
+
2039
+	/**
2040
+	 * google+ (google.com/+profileName)
2041
+	 *
2042
+	 * @var string
2043
+	 */
2044
+	public $google = '';
2045
+
2046
+	/**
2047
+	 * instagram (instagram.com/handle)
2048
+	 *
2049
+	 * @var string
2050
+	 */
2051
+	public $instagram = '';
2052
+
2053
+
2054
+	/**
2055
+	 *    class constructor
2056
+	 *
2057
+	 * @access    public
2058
+	 */
2059
+	public function __construct()
2060
+	{
2061
+		// set default organization settings
2062
+		// decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2063
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2064
+		$this->email = get_bloginfo('admin_email');
2065
+	}
2066
+}
2382 2067
 
2383
-    /**
2384
-     * Label text to show on the checkbox
2385
-     *
2386
-     * @var string
2387
-     */
2388
-    public $consent_checkbox_label_text;
2068
+/**
2069
+ * Class for defining what's in the EE_Config relating to currency
2070
+ */
2071
+class EE_Currency_Config extends EE_Config_Base
2072
+{
2073
+	/**
2074
+	 * @var string $code
2075
+	 * eg 'US'
2076
+	 */
2077
+	public $code;
2078
+
2079
+	/**
2080
+	 * @var string $name
2081
+	 * eg 'Dollar'
2082
+	 */
2083
+	public $name;
2084
+
2085
+	/**
2086
+	 * plural name
2087
+	 *
2088
+	 * @var string $plural
2089
+	 * eg 'Dollars'
2090
+	 */
2091
+	public $plural;
2092
+
2093
+	/**
2094
+	 * currency sign
2095
+	 *
2096
+	 * @var string $sign
2097
+	 * eg '$'
2098
+	 */
2099
+	public $sign;
2100
+
2101
+	/**
2102
+	 * Whether the currency sign should come before the number or not
2103
+	 *
2104
+	 * @var boolean $sign_b4
2105
+	 */
2106
+	public $sign_b4;
2107
+
2108
+	/**
2109
+	 * How many digits should come after the decimal place
2110
+	 *
2111
+	 * @var int $dec_plc
2112
+	 */
2113
+	public $dec_plc;
2114
+
2115
+	/**
2116
+	 * Symbol to use for decimal mark
2117
+	 *
2118
+	 * @var string $dec_mrk
2119
+	 * eg '.'
2120
+	 */
2121
+	public $dec_mrk;
2122
+
2123
+	/**
2124
+	 * Symbol to use for thousands
2125
+	 *
2126
+	 * @var string $thsnds
2127
+	 * eg ','
2128
+	 */
2129
+	public $thsnds;
2130
+
2131
+
2132
+	/**
2133
+	 * @param string|null $CNT_ISO
2134
+	 * @throws EE_Error
2135
+	 * @throws ReflectionException
2136
+	 */
2137
+	public function __construct(?string $CNT_ISO = 'US')
2138
+	{
2139
+		if ($CNT_ISO && $CNT_ISO === $this->code) {
2140
+			return;
2141
+		}
2142
+		// get country code from organization settings or use default
2143
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2144
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2145
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2146
+			: 'US';
2147
+		// but override if requested
2148
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2149
+		// 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
2150
+		$this->setCurrency($CNT_ISO);
2151
+		// fallback to hardcoded defaults, in case the above failed
2152
+		if (empty($this->code)) {
2153
+			$this->setFallbackCurrency();
2154
+		}
2155
+	}
2156
+
2157
+
2158
+	/**
2159
+	 * @param string|null $CNT_ISO
2160
+	 * @throws EE_Error
2161
+	 * @throws ReflectionException
2162
+	 */
2163
+	public function setCurrency(?string $CNT_ISO = 'US')
2164
+	{
2165
+		if (empty($CNT_ISO) || DbStatus::isOffline()) {
2166
+			return;
2167
+		}
2168
+
2169
+		/** @var TableAnalysis $table_analysis */
2170
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', [], true);
2171
+		if (! $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())) {
2172
+			return;
2173
+		}
2174
+		// retrieve the country settings from the db, just in case they have been customized
2175
+		$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2176
+		if (! $country instanceof EE_Country) {
2177
+			throw new DomainException(
2178
+				sprintf(
2179
+					esc_html__('Invalid Country ISO Code: %1$s', 'event_espresso'),
2180
+					$CNT_ISO
2181
+				)
2182
+			);
2183
+		}
2184
+		$this->code    = $country->currency_code();                  // currency code: USD, CAD, EUR
2185
+		$this->name    = $country->currency_name_single();           // Dollar
2186
+		$this->plural  = $country->currency_name_plural();           // Dollars
2187
+		$this->sign    = $country->currency_sign();                  // currency sign: $
2188
+		$this->sign_b4 = $country->currency_sign_before();           // currency sign before or after
2189
+		$this->dec_plc = $country->currency_decimal_places();        // decimal places: 2 = 0.00  3 = 0.000
2190
+		$this->dec_mrk = $country->currency_decimal_mark();          // decimal mark: ',' = 0,01 or '.' = 0.01
2191
+		$this->thsnds  = $country->currency_thousands_separator();   // thousands sep: ',' = 1,000 or '.' = 1.000
2192
+	}
2193
+
2194
+
2195
+	private function setFallbackCurrency()
2196
+	{
2197
+		// set default currency settings
2198
+		$this->code    = 'USD';
2199
+		$this->name    = esc_html__('Dollar', 'event_espresso');
2200
+		$this->plural  = esc_html__('Dollars', 'event_espresso');
2201
+		$this->sign    = '$';
2202
+		$this->sign_b4 = true;
2203
+		$this->dec_plc = 2;
2204
+		$this->dec_mrk = '.';
2205
+		$this->thsnds  = ',';
2206
+	}
2207
+
2208
+
2209
+	/**
2210
+	 * @param string|null $CNT_ISO
2211
+	 * @return EE_Currency_Config
2212
+	 * @throws EE_Error
2213
+	 * @throws ReflectionException
2214
+	 */
2215
+	public static function getCurrencyConfig(?string $CNT_ISO = ''): EE_Currency_Config
2216
+	{
2217
+		// if CNT_ISO passed lets try to get currency settings for it.
2218
+		$currency_config = ! empty($CNT_ISO)
2219
+			? new EE_Currency_Config($CNT_ISO)
2220
+			: null;
2221
+		// default currency settings for site if not set
2222
+		if ($currency_config instanceof EE_Currency_Config) {
2223
+			return $currency_config;
2224
+		}
2225
+		EE_Config::instance()->currency = EE_Config::instance()->currency instanceof EE_Currency_Config
2226
+			? EE_Config::instance()->currency
2227
+			: new EE_Currency_Config();
2228
+		return EE_Config::instance()->currency;
2229
+	}
2230
+}
2389 2231
 
2390
-    /*
2232
+/**
2233
+ * Class for defining what's in the EE_Config relating to registration settings
2234
+ */
2235
+class EE_Registration_Config extends EE_Config_Base
2236
+{
2237
+	/**
2238
+	 * Default registration status
2239
+	 *
2240
+	 * @var string $default_STS_ID
2241
+	 * eg 'RPP'
2242
+	 */
2243
+	public $default_STS_ID;
2244
+
2245
+	/**
2246
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2247
+	 * registrations)
2248
+	 *
2249
+	 * @var int
2250
+	 */
2251
+	public $default_maximum_number_of_tickets;
2252
+
2253
+	/**
2254
+	 * level of validation to apply to email addresses
2255
+	 *
2256
+	 * @var string $email_validation_level
2257
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2258
+	 */
2259
+	public $email_validation_level;
2260
+
2261
+	/**
2262
+	 * whether to show alternate payment options during the reg process if payment status is pending
2263
+	 *
2264
+	 * @var boolean $show_pending_payment_options
2265
+	 */
2266
+	public $show_pending_payment_options;
2267
+
2268
+	/**
2269
+	 * an array of SPCO reg steps where:
2270
+	 *        the keys denotes the reg step order
2271
+	 *        each element consists of an array with the following elements:
2272
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2273
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2274
+	 *            "slug" => the URL param used to trigger the reg step
2275
+	 *
2276
+	 * @var array $reg_steps
2277
+	 */
2278
+	public $reg_steps;
2279
+
2280
+	/**
2281
+	 * Whether registration confirmation should be the last page of SPCO
2282
+	 *
2283
+	 * @var boolean $reg_confirmation_last
2284
+	 */
2285
+	public $reg_confirmation_last;
2286
+
2287
+	/**
2288
+	 * Whether to enable the EE Bot Trap
2289
+	 *
2290
+	 * @var boolean $use_bot_trap
2291
+	 */
2292
+	public $use_bot_trap;
2293
+
2294
+	/**
2295
+	 * Whether to encrypt some data sent by the EE Bot Trap
2296
+	 *
2297
+	 * @var boolean $use_encryption
2298
+	 */
2299
+	public $use_encryption;
2300
+
2301
+	/**
2302
+	 * Whether to use ReCaptcha
2303
+	 *
2304
+	 * @var boolean $use_captcha
2305
+	 */
2306
+	public $use_captcha;
2307
+
2308
+	/**
2309
+	 * ReCaptcha Theme
2310
+	 *
2311
+	 * @var string $recaptcha_theme
2312
+	 *    options: 'dark', 'light', 'invisible'
2313
+	 */
2314
+	public $recaptcha_theme;
2315
+
2316
+	/**
2317
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2318
+	 *
2319
+	 * @var string $recaptcha_badge
2320
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2321
+	 */
2322
+	public $recaptcha_badge;
2323
+
2324
+	/**
2325
+	 * ReCaptcha Type
2326
+	 *
2327
+	 * @var string $recaptcha_type
2328
+	 *    options: 'audio', 'image'
2329
+	 */
2330
+	public $recaptcha_type;
2331
+
2332
+	/**
2333
+	 * ReCaptcha language
2334
+	 *
2335
+	 * @var string $recaptcha_language
2336
+	 * eg 'en'
2337
+	 */
2338
+	public $recaptcha_language;
2339
+
2340
+	/**
2341
+	 * ReCaptcha public key
2342
+	 *
2343
+	 * @var string $recaptcha_publickey
2344
+	 */
2345
+	public $recaptcha_publickey;
2346
+
2347
+	/**
2348
+	 * ReCaptcha private key
2349
+	 *
2350
+	 * @var string $recaptcha_privatekey
2351
+	 */
2352
+	public $recaptcha_privatekey;
2353
+
2354
+	/**
2355
+	 * array of form names protected by ReCaptcha
2356
+	 *
2357
+	 * @var array $recaptcha_protected_forms
2358
+	 */
2359
+	public $recaptcha_protected_forms;
2360
+
2361
+	/**
2362
+	 * ReCaptcha width
2363
+	 *
2364
+	 * @var int $recaptcha_width
2365
+	 * @deprecated
2366
+	 */
2367
+	public $recaptcha_width;
2368
+
2369
+	/**
2370
+	 * Whether invalid attempts to directly access the registration checkout page should be tracked.
2371
+	 *
2372
+	 * @var boolean $track_invalid_checkout_access
2373
+	 */
2374
+	protected $track_invalid_checkout_access = true;
2375
+
2376
+	/**
2377
+	 * Whether to show the privacy policy consent checkbox
2378
+	 *
2379
+	 * @var bool
2380
+	 */
2381
+	public $consent_checkbox_enabled;
2382
+
2383
+	/**
2384
+	 * Label text to show on the checkbox
2385
+	 *
2386
+	 * @var string
2387
+	 */
2388
+	public $consent_checkbox_label_text;
2389
+
2390
+	/*
2391 2391
      * String describing how long to keep payment logs. Passed into DateTime constructor
2392 2392
      * @var string
2393 2393
      */
2394
-    public $gateway_log_lifespan = '1 week';
2395
-
2396
-    /**
2397
-     * Enable copy attendee info at form
2398
-     *
2399
-     * @var boolean $enable_copy_attendee
2400
-     */
2401
-    protected $copy_attendee_info = true;
2402
-
2403
-    /**
2404
-     * @var bool|int|string|null $skip_reg_confirmation
2405
-     * @deprecated
2406
-     */
2407
-    public $skip_reg_confirmation;
2408
-
2409
-
2410
-
2411
-
2412
-    /**
2413
-     *    class constructor
2414
-     *
2415
-     * @access    public
2416
-     */
2417
-    public function __construct()
2418
-    {
2419
-        // set default registration settings
2420
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2421
-        $this->email_validation_level = 'wp_default';
2422
-        $this->show_pending_payment_options = true;
2423
-        $this->reg_steps = array();
2424
-        $this->reg_confirmation_last = false;
2425
-        $this->use_bot_trap = true;
2426
-        $this->use_encryption = true;
2427
-        $this->use_captcha = false;
2428
-        $this->recaptcha_theme = 'light';
2429
-        $this->recaptcha_badge = 'bottomleft';
2430
-        $this->recaptcha_type = 'image';
2431
-        $this->recaptcha_language = 'en';
2432
-        $this->recaptcha_publickey = null;
2433
-        $this->recaptcha_privatekey = null;
2434
-        $this->recaptcha_protected_forms = array();
2435
-        $this->recaptcha_width = 500;
2436
-        $this->default_maximum_number_of_tickets = 10;
2437
-        $this->consent_checkbox_enabled = false;
2438
-        $this->consent_checkbox_label_text = '';
2439
-        $this->gateway_log_lifespan = '7 days';
2440
-        $this->copy_attendee_info = true;
2441
-    }
2442
-
2443
-
2444
-    /**
2445
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2446
-     *
2447
-     * @since 4.8.8.rc.019
2448
-     */
2449
-    public function do_hooks()
2450
-    {
2451
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2452
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2453
-        add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2454
-    }
2455
-
2456
-
2457
-    /**
2458
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2459
-     * EVT_default_registration_status field matches the config setting for default_STS_ID.
2460
-     */
2461
-    public function set_default_reg_status_on_EEM_Event()
2462
-    {
2463
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2464
-    }
2465
-
2466
-
2467
-    /**
2468
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2469
-     * for Events matches the config setting for default_maximum_number_of_tickets
2470
-     */
2471
-    public function set_default_max_ticket_on_EEM_Event()
2472
-    {
2473
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2474
-    }
2475
-
2476
-
2477
-    /**
2478
-     * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2479
-     * constructed because that happens before we can get the privacy policy page's permalink.
2480
-     *
2481
-     * @throws InvalidArgumentException
2482
-     * @throws InvalidDataTypeException
2483
-     * @throws InvalidInterfaceException
2484
-     */
2485
-    public function setDefaultCheckboxLabelText()
2486
-    {
2487
-        if (
2488
-            $this->getConsentCheckboxLabelText() === null
2489
-            || $this->getConsentCheckboxLabelText() === ''
2490
-        ) {
2491
-            $opening_a_tag = '';
2492
-            $closing_a_tag = '';
2493
-            if (function_exists('get_privacy_policy_url')) {
2494
-                $privacy_page_url = get_privacy_policy_url();
2495
-                if (! empty($privacy_page_url)) {
2496
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2497
-                    $closing_a_tag = '</a>';
2498
-                }
2499
-            }
2500
-            $loader = LoaderFactory::getLoader();
2501
-            $org_config = $loader->getShared('EE_Organization_Config');
2502
-            /**
2503
-             * @var $org_config EE_Organization_Config
2504
-             */
2505
-
2506
-            $this->setConsentCheckboxLabelText(
2507
-                sprintf(
2508
-                    esc_html__(
2509
-                        'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2510
-                        'event_espresso'
2511
-                    ),
2512
-                    $org_config->name,
2513
-                    $opening_a_tag,
2514
-                    $closing_a_tag
2515
-                )
2516
-            );
2517
-        }
2518
-    }
2519
-
2520
-
2521
-    /**
2522
-     * @return boolean
2523
-     */
2524
-    public function track_invalid_checkout_access()
2525
-    {
2526
-        return $this->track_invalid_checkout_access;
2527
-    }
2528
-
2529
-
2530
-    /**
2531
-     * @param boolean $track_invalid_checkout_access
2532
-     */
2533
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2534
-    {
2535
-        $this->track_invalid_checkout_access = filter_var(
2536
-            $track_invalid_checkout_access,
2537
-            FILTER_VALIDATE_BOOLEAN
2538
-        );
2539
-    }
2540
-
2541
-    /**
2542
-     * @return boolean
2543
-     */
2544
-    public function copyAttendeeInfo()
2545
-    {
2546
-        return $this->copy_attendee_info;
2547
-    }
2548
-
2549
-
2550
-    /**
2551
-     * @param boolean $copy_attendee_info
2552
-     */
2553
-    public function setCopyAttendeeInfo($copy_attendee_info)
2554
-    {
2555
-        $this->copy_attendee_info = filter_var(
2556
-            $copy_attendee_info,
2557
-            FILTER_VALIDATE_BOOLEAN
2558
-        );
2559
-    }
2560
-
2561
-
2562
-    /**
2563
-     * Gets the options to make available for the gateway log lifespan
2564
-     * @return array
2565
-     */
2566
-    public function gatewayLogLifespanOptions()
2567
-    {
2568
-        return (array) apply_filters(
2569
-            'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2570
-            array(
2571
-                '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2572
-                '1 day' => esc_html__('1 Day', 'event_espresso'),
2573
-                '7 days' => esc_html__('7 Days', 'event_espresso'),
2574
-                '14 days' => esc_html__('14 Days', 'event_espresso'),
2575
-                '30 days' => esc_html__('30 Days', 'event_espresso')
2576
-            )
2577
-        );
2578
-    }
2579
-
2580
-
2581
-    /**
2582
-     * @return bool
2583
-     */
2584
-    public function isConsentCheckboxEnabled()
2585
-    {
2586
-        return $this->consent_checkbox_enabled;
2587
-    }
2588
-
2589
-
2590
-    /**
2591
-     * @param bool $consent_checkbox_enabled
2592
-     */
2593
-    public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2594
-    {
2595
-        $this->consent_checkbox_enabled = filter_var(
2596
-            $consent_checkbox_enabled,
2597
-            FILTER_VALIDATE_BOOLEAN
2598
-        );
2599
-    }
2600
-
2601
-
2602
-    /**
2603
-     * @return string
2604
-     */
2605
-    public function getConsentCheckboxLabelText()
2606
-    {
2607
-        return $this->consent_checkbox_label_text;
2608
-    }
2609
-
2610
-
2611
-    /**
2612
-     * @param string $consent_checkbox_label_text
2613
-     */
2614
-    public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2615
-    {
2616
-        $this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2617
-    }
2394
+	public $gateway_log_lifespan = '1 week';
2395
+
2396
+	/**
2397
+	 * Enable copy attendee info at form
2398
+	 *
2399
+	 * @var boolean $enable_copy_attendee
2400
+	 */
2401
+	protected $copy_attendee_info = true;
2402
+
2403
+	/**
2404
+	 * @var bool|int|string|null $skip_reg_confirmation
2405
+	 * @deprecated
2406
+	 */
2407
+	public $skip_reg_confirmation;
2408
+
2409
+
2410
+
2411
+
2412
+	/**
2413
+	 *    class constructor
2414
+	 *
2415
+	 * @access    public
2416
+	 */
2417
+	public function __construct()
2418
+	{
2419
+		// set default registration settings
2420
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2421
+		$this->email_validation_level = 'wp_default';
2422
+		$this->show_pending_payment_options = true;
2423
+		$this->reg_steps = array();
2424
+		$this->reg_confirmation_last = false;
2425
+		$this->use_bot_trap = true;
2426
+		$this->use_encryption = true;
2427
+		$this->use_captcha = false;
2428
+		$this->recaptcha_theme = 'light';
2429
+		$this->recaptcha_badge = 'bottomleft';
2430
+		$this->recaptcha_type = 'image';
2431
+		$this->recaptcha_language = 'en';
2432
+		$this->recaptcha_publickey = null;
2433
+		$this->recaptcha_privatekey = null;
2434
+		$this->recaptcha_protected_forms = array();
2435
+		$this->recaptcha_width = 500;
2436
+		$this->default_maximum_number_of_tickets = 10;
2437
+		$this->consent_checkbox_enabled = false;
2438
+		$this->consent_checkbox_label_text = '';
2439
+		$this->gateway_log_lifespan = '7 days';
2440
+		$this->copy_attendee_info = true;
2441
+	}
2442
+
2443
+
2444
+	/**
2445
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2446
+	 *
2447
+	 * @since 4.8.8.rc.019
2448
+	 */
2449
+	public function do_hooks()
2450
+	{
2451
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2452
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2453
+		add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2454
+	}
2455
+
2456
+
2457
+	/**
2458
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2459
+	 * EVT_default_registration_status field matches the config setting for default_STS_ID.
2460
+	 */
2461
+	public function set_default_reg_status_on_EEM_Event()
2462
+	{
2463
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2464
+	}
2465
+
2466
+
2467
+	/**
2468
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2469
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2470
+	 */
2471
+	public function set_default_max_ticket_on_EEM_Event()
2472
+	{
2473
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2474
+	}
2475
+
2476
+
2477
+	/**
2478
+	 * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2479
+	 * constructed because that happens before we can get the privacy policy page's permalink.
2480
+	 *
2481
+	 * @throws InvalidArgumentException
2482
+	 * @throws InvalidDataTypeException
2483
+	 * @throws InvalidInterfaceException
2484
+	 */
2485
+	public function setDefaultCheckboxLabelText()
2486
+	{
2487
+		if (
2488
+			$this->getConsentCheckboxLabelText() === null
2489
+			|| $this->getConsentCheckboxLabelText() === ''
2490
+		) {
2491
+			$opening_a_tag = '';
2492
+			$closing_a_tag = '';
2493
+			if (function_exists('get_privacy_policy_url')) {
2494
+				$privacy_page_url = get_privacy_policy_url();
2495
+				if (! empty($privacy_page_url)) {
2496
+					$opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2497
+					$closing_a_tag = '</a>';
2498
+				}
2499
+			}
2500
+			$loader = LoaderFactory::getLoader();
2501
+			$org_config = $loader->getShared('EE_Organization_Config');
2502
+			/**
2503
+			 * @var $org_config EE_Organization_Config
2504
+			 */
2505
+
2506
+			$this->setConsentCheckboxLabelText(
2507
+				sprintf(
2508
+					esc_html__(
2509
+						'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2510
+						'event_espresso'
2511
+					),
2512
+					$org_config->name,
2513
+					$opening_a_tag,
2514
+					$closing_a_tag
2515
+				)
2516
+			);
2517
+		}
2518
+	}
2519
+
2520
+
2521
+	/**
2522
+	 * @return boolean
2523
+	 */
2524
+	public function track_invalid_checkout_access()
2525
+	{
2526
+		return $this->track_invalid_checkout_access;
2527
+	}
2528
+
2529
+
2530
+	/**
2531
+	 * @param boolean $track_invalid_checkout_access
2532
+	 */
2533
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2534
+	{
2535
+		$this->track_invalid_checkout_access = filter_var(
2536
+			$track_invalid_checkout_access,
2537
+			FILTER_VALIDATE_BOOLEAN
2538
+		);
2539
+	}
2540
+
2541
+	/**
2542
+	 * @return boolean
2543
+	 */
2544
+	public function copyAttendeeInfo()
2545
+	{
2546
+		return $this->copy_attendee_info;
2547
+	}
2548
+
2549
+
2550
+	/**
2551
+	 * @param boolean $copy_attendee_info
2552
+	 */
2553
+	public function setCopyAttendeeInfo($copy_attendee_info)
2554
+	{
2555
+		$this->copy_attendee_info = filter_var(
2556
+			$copy_attendee_info,
2557
+			FILTER_VALIDATE_BOOLEAN
2558
+		);
2559
+	}
2560
+
2561
+
2562
+	/**
2563
+	 * Gets the options to make available for the gateway log lifespan
2564
+	 * @return array
2565
+	 */
2566
+	public function gatewayLogLifespanOptions()
2567
+	{
2568
+		return (array) apply_filters(
2569
+			'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2570
+			array(
2571
+				'1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2572
+				'1 day' => esc_html__('1 Day', 'event_espresso'),
2573
+				'7 days' => esc_html__('7 Days', 'event_espresso'),
2574
+				'14 days' => esc_html__('14 Days', 'event_espresso'),
2575
+				'30 days' => esc_html__('30 Days', 'event_espresso')
2576
+			)
2577
+		);
2578
+	}
2579
+
2580
+
2581
+	/**
2582
+	 * @return bool
2583
+	 */
2584
+	public function isConsentCheckboxEnabled()
2585
+	{
2586
+		return $this->consent_checkbox_enabled;
2587
+	}
2588
+
2589
+
2590
+	/**
2591
+	 * @param bool $consent_checkbox_enabled
2592
+	 */
2593
+	public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2594
+	{
2595
+		$this->consent_checkbox_enabled = filter_var(
2596
+			$consent_checkbox_enabled,
2597
+			FILTER_VALIDATE_BOOLEAN
2598
+		);
2599
+	}
2600
+
2601
+
2602
+	/**
2603
+	 * @return string
2604
+	 */
2605
+	public function getConsentCheckboxLabelText()
2606
+	{
2607
+		return $this->consent_checkbox_label_text;
2608
+	}
2609
+
2610
+
2611
+	/**
2612
+	 * @param string $consent_checkbox_label_text
2613
+	 */
2614
+	public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2615
+	{
2616
+		$this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2617
+	}
2618 2618
 }
2619 2619
 
2620 2620
 /**
@@ -2622,134 +2622,134 @@  discard block
 block discarded – undo
2622 2622
  */
2623 2623
 class EE_Admin_Config extends EE_Config_Base
2624 2624
 {
2625
-    private $useAdvancedEditor = true;
2626
-
2627
-    public $use_remote_logging = false;
2628
-
2629
-    public $show_reg_footer = false;
2630
-
2631
-    private $is_caffeinated;
2632
-
2633
-    public $use_dashboard_widget = false;
2634
-
2635
-    public $use_personnel_manager = false;
2636
-
2637
-    public $use_event_timezones = false;
2638
-
2639
-    /**
2640
-     * adds extra layer of encoding to session data to prevent serialization errors
2641
-     * but is incompatible with some server configuration errors
2642
-     * if you get "500 internal server errors" during registration, try turning this on
2643
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2644
-     *
2645
-     * @var boolean $encode_session_data
2646
-     */
2647
-    private $encode_session_data = false;
2648
-
2649
-    public ?string $log_file_name = '';
2650
-
2651
-    public ?string $debug_file_name = '';
2652
-
2653
-    public ?string $remote_logging_url = '';
2654
-
2655
-    public ?string $affiliate_id = 'default';
2656
-
2657
-    /**
2658
-     * @var int|null $events_in_dashboard
2659
-     * @deprecated
2660
-     */
2661
-    public ?int $events_in_dashboard = 30;
2662
-
2663
-
2664
-    public function __construct()
2665
-    {
2666
-        /** @var EventEspresso\core\domain\Domain $domain */
2667
-        $domain               = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\Domain');
2668
-        $this->is_caffeinated = $domain->isCaffeinated();
2669
-
2670
-        // set default general admin settings
2671
-        $this->show_reg_footer = apply_filters(
2672
-            'FHEE__EE_Admin_Config__show_reg_footer__default',
2673
-            false
2674
-        );
2675
-    }
2676
-
2677
-
2678
-    /**
2679
-     * @param bool $reset
2680
-     * @return string
2681
-     */
2682
-    public function log_file_name(bool $reset = false): ?string
2683
-    {
2684
-        if (empty($this->log_file_name) || $reset) {
2685
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2686
-            EE_Config::instance()->update_espresso_config(false, false);
2687
-        }
2688
-        return $this->log_file_name;
2689
-    }
2690
-
2691
-
2692
-    /**
2693
-     * @param bool $reset
2694
-     * @return string
2695
-     */
2696
-    public function debug_file_name(bool $reset = false): ?string
2697
-    {
2698
-        if (empty($this->debug_file_name) || $reset) {
2699
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2700
-            EE_Config::instance()->update_espresso_config(false, false);
2701
-        }
2702
-        return $this->debug_file_name;
2703
-    }
2704
-
2705
-
2706
-    /**
2707
-     * @return string
2708
-     */
2709
-    public function affiliate_id(): ?string
2710
-    {
2711
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2712
-    }
2713
-
2714
-
2715
-    /**
2716
-     * @return boolean
2717
-     */
2718
-    public function encode_session_data(): bool
2719
-    {
2720
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2721
-    }
2722
-
2723
-
2724
-    /**
2725
-     * @param bool|int|string $encode_session_data
2726
-     */
2727
-    public function set_encode_session_data($encode_session_data)
2728
-    {
2729
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2730
-    }
2625
+	private $useAdvancedEditor = true;
2731 2626
 
2732
-    /**
2733
-     * @return boolean
2734
-     */
2735
-    public function useAdvancedEditor(): bool
2736
-    {
2737
-        return $this->useAdvancedEditor && $this->is_caffeinated;
2738
-    }
2739
-
2740
-    /**
2741
-     * @param bool|int|string $use_advanced_editor
2742
-     */
2743
-    public function setUseAdvancedEditor($use_advanced_editor = true)
2744
-    {
2745
-        $this->useAdvancedEditor = filter_var(
2746
-            apply_filters(
2747
-                'FHEE__EE_Admin_Config__setUseAdvancedEditor__use_advanced_editor',
2748
-                $use_advanced_editor
2749
-            ),
2750
-            FILTER_VALIDATE_BOOLEAN
2751
-        );
2752
-    }
2627
+	public $use_remote_logging = false;
2628
+
2629
+	public $show_reg_footer = false;
2630
+
2631
+	private $is_caffeinated;
2632
+
2633
+	public $use_dashboard_widget = false;
2634
+
2635
+	public $use_personnel_manager = false;
2636
+
2637
+	public $use_event_timezones = false;
2638
+
2639
+	/**
2640
+	 * adds extra layer of encoding to session data to prevent serialization errors
2641
+	 * but is incompatible with some server configuration errors
2642
+	 * if you get "500 internal server errors" during registration, try turning this on
2643
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2644
+	 *
2645
+	 * @var boolean $encode_session_data
2646
+	 */
2647
+	private $encode_session_data = false;
2648
+
2649
+	public ?string $log_file_name = '';
2650
+
2651
+	public ?string $debug_file_name = '';
2652
+
2653
+	public ?string $remote_logging_url = '';
2654
+
2655
+	public ?string $affiliate_id = 'default';
2656
+
2657
+	/**
2658
+	 * @var int|null $events_in_dashboard
2659
+	 * @deprecated
2660
+	 */
2661
+	public ?int $events_in_dashboard = 30;
2662
+
2663
+
2664
+	public function __construct()
2665
+	{
2666
+		/** @var EventEspresso\core\domain\Domain $domain */
2667
+		$domain               = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\Domain');
2668
+		$this->is_caffeinated = $domain->isCaffeinated();
2669
+
2670
+		// set default general admin settings
2671
+		$this->show_reg_footer = apply_filters(
2672
+			'FHEE__EE_Admin_Config__show_reg_footer__default',
2673
+			false
2674
+		);
2675
+	}
2676
+
2677
+
2678
+	/**
2679
+	 * @param bool $reset
2680
+	 * @return string
2681
+	 */
2682
+	public function log_file_name(bool $reset = false): ?string
2683
+	{
2684
+		if (empty($this->log_file_name) || $reset) {
2685
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2686
+			EE_Config::instance()->update_espresso_config(false, false);
2687
+		}
2688
+		return $this->log_file_name;
2689
+	}
2690
+
2691
+
2692
+	/**
2693
+	 * @param bool $reset
2694
+	 * @return string
2695
+	 */
2696
+	public function debug_file_name(bool $reset = false): ?string
2697
+	{
2698
+		if (empty($this->debug_file_name) || $reset) {
2699
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2700
+			EE_Config::instance()->update_espresso_config(false, false);
2701
+		}
2702
+		return $this->debug_file_name;
2703
+	}
2704
+
2705
+
2706
+	/**
2707
+	 * @return string
2708
+	 */
2709
+	public function affiliate_id(): ?string
2710
+	{
2711
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2712
+	}
2713
+
2714
+
2715
+	/**
2716
+	 * @return boolean
2717
+	 */
2718
+	public function encode_session_data(): bool
2719
+	{
2720
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2721
+	}
2722
+
2723
+
2724
+	/**
2725
+	 * @param bool|int|string $encode_session_data
2726
+	 */
2727
+	public function set_encode_session_data($encode_session_data)
2728
+	{
2729
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2730
+	}
2731
+
2732
+	/**
2733
+	 * @return boolean
2734
+	 */
2735
+	public function useAdvancedEditor(): bool
2736
+	{
2737
+		return $this->useAdvancedEditor && $this->is_caffeinated;
2738
+	}
2739
+
2740
+	/**
2741
+	 * @param bool|int|string $use_advanced_editor
2742
+	 */
2743
+	public function setUseAdvancedEditor($use_advanced_editor = true)
2744
+	{
2745
+		$this->useAdvancedEditor = filter_var(
2746
+			apply_filters(
2747
+				'FHEE__EE_Admin_Config__setUseAdvancedEditor__use_advanced_editor',
2748
+				$use_advanced_editor
2749
+			),
2750
+			FILTER_VALIDATE_BOOLEAN
2751
+		);
2752
+	}
2753 2753
 }
2754 2754
 
2755 2755
 /**
@@ -2757,69 +2757,69 @@  discard block
 block discarded – undo
2757 2757
  */
2758 2758
 class EE_Template_Config extends EE_Config_Base
2759 2759
 {
2760
-    /**
2761
-     * @var EE_Ticket_Selector_Config|stdClass|null
2762
-     */
2763
-    public $EED_Ticket_Selector;
2764
-
2765
-    /**
2766
-     * @var EE_Event_Single_Config|stdClass|null
2767
-     */
2768
-    public $EED_Event_Single;
2769
-
2770
-    /**
2771
-     * @var EE_Events_Archive_Config|stdClass|null
2772
-     */
2773
-    public $EED_Events_Archive;
2774
-
2775
-    /**
2776
-     * @var EE_People_Config|stdClass|null
2777
-     * @since 5.0.12.p
2778
-     */
2779
-    public $EED_People_Single;
2780
-
2781
-    public string $current_espresso_theme = '';
2782
-
2783
-    public $display_address_in_regform = true;
2784
-
2785
-    /**
2786
-     * @var bool|int|string|null $enable_default_style
2787
-     * @deprecated
2788
-     */
2789
-    public $enable_default_style;
2790
-
2791
-    /**
2792
-     * @var bool|int|string|null $display_description_on_multi_reg_page
2793
-     * @deprecated
2794
-     */
2795
-    public $display_description_on_multi_reg_page;
2796
-
2797
-    /**
2798
-     * @var bool|int|string|null $use_custom_templates
2799
-     * @deprecated
2800
-     */
2801
-    public $use_custom_templates;
2802
-
2803
-    /**
2804
-     * @var bool|int|string|null $custom_style_sheet
2805
-     * @deprecated
2806
-     */
2807
-    public $custom_style_sheet;
2808
-
2809
-
2810
-    /**
2811
-     *    class constructor
2812
-     *
2813
-     * @access    public
2814
-     */
2815
-    public function __construct()
2816
-    {
2817
-        // set default template settings
2818
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2819
-        $this->EED_Event_Single = null;
2820
-        $this->EED_Events_Archive = null;
2821
-        $this->EED_Ticket_Selector = null;
2822
-    }
2760
+	/**
2761
+	 * @var EE_Ticket_Selector_Config|stdClass|null
2762
+	 */
2763
+	public $EED_Ticket_Selector;
2764
+
2765
+	/**
2766
+	 * @var EE_Event_Single_Config|stdClass|null
2767
+	 */
2768
+	public $EED_Event_Single;
2769
+
2770
+	/**
2771
+	 * @var EE_Events_Archive_Config|stdClass|null
2772
+	 */
2773
+	public $EED_Events_Archive;
2774
+
2775
+	/**
2776
+	 * @var EE_People_Config|stdClass|null
2777
+	 * @since 5.0.12.p
2778
+	 */
2779
+	public $EED_People_Single;
2780
+
2781
+	public string $current_espresso_theme = '';
2782
+
2783
+	public $display_address_in_regform = true;
2784
+
2785
+	/**
2786
+	 * @var bool|int|string|null $enable_default_style
2787
+	 * @deprecated
2788
+	 */
2789
+	public $enable_default_style;
2790
+
2791
+	/**
2792
+	 * @var bool|int|string|null $display_description_on_multi_reg_page
2793
+	 * @deprecated
2794
+	 */
2795
+	public $display_description_on_multi_reg_page;
2796
+
2797
+	/**
2798
+	 * @var bool|int|string|null $use_custom_templates
2799
+	 * @deprecated
2800
+	 */
2801
+	public $use_custom_templates;
2802
+
2803
+	/**
2804
+	 * @var bool|int|string|null $custom_style_sheet
2805
+	 * @deprecated
2806
+	 */
2807
+	public $custom_style_sheet;
2808
+
2809
+
2810
+	/**
2811
+	 *    class constructor
2812
+	 *
2813
+	 * @access    public
2814
+	 */
2815
+	public function __construct()
2816
+	{
2817
+		// set default template settings
2818
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2819
+		$this->EED_Event_Single = null;
2820
+		$this->EED_Events_Archive = null;
2821
+		$this->EED_Ticket_Selector = null;
2822
+	}
2823 2823
 }
2824 2824
 
2825 2825
 /**
@@ -2827,114 +2827,114 @@  discard block
 block discarded – undo
2827 2827
  */
2828 2828
 class EE_Map_Config extends EE_Config_Base
2829 2829
 {
2830
-    /**
2831
-     * @var boolean $use_google_maps
2832
-     */
2833
-    public $use_google_maps;
2834
-
2835
-    /**
2836
-     * @var string $api_key
2837
-     */
2838
-    public $google_map_api_key;
2839
-
2840
-    /**
2841
-     * @var int $event_details_map_width
2842
-     */
2843
-    public $event_details_map_width;
2844
-
2845
-    /**
2846
-     * @var int $event_details_map_height
2847
-     */
2848
-    public $event_details_map_height;
2849
-
2850
-    /**
2851
-     * @var int $event_details_map_zoom
2852
-     */
2853
-    public $event_details_map_zoom;
2854
-
2855
-    /**
2856
-     * @var boolean $event_details_display_nav
2857
-     */
2858
-    public $event_details_display_nav;
2859
-
2860
-    /**
2861
-     * @var boolean $event_details_nav_size
2862
-     */
2863
-    public $event_details_nav_size;
2864
-
2865
-    /**
2866
-     * @var string $event_details_control_type
2867
-     */
2868
-    public $event_details_control_type;
2869
-
2870
-    /**
2871
-     * @var string $event_details_map_align
2872
-     */
2873
-    public $event_details_map_align;
2874
-
2875
-    /**
2876
-     * @var int $event_list_map_width
2877
-     */
2878
-    public $event_list_map_width;
2879
-
2880
-    /**
2881
-     * @var int $event_list_map_height
2882
-     */
2883
-    public $event_list_map_height;
2884
-
2885
-    /**
2886
-     * @var int $event_list_map_zoom
2887
-     */
2888
-    public $event_list_map_zoom;
2889
-
2890
-    /**
2891
-     * @var boolean $event_list_display_nav
2892
-     */
2893
-    public $event_list_display_nav;
2894
-
2895
-    /**
2896
-     * @var boolean $event_list_nav_size
2897
-     */
2898
-    public $event_list_nav_size;
2899
-
2900
-    /**
2901
-     * @var string $event_list_control_type
2902
-     */
2903
-    public $event_list_control_type;
2904
-
2905
-    /**
2906
-     * @var string $event_list_map_align
2907
-     */
2908
-    public $event_list_map_align;
2909
-
2910
-
2911
-    /**
2912
-     *    class constructor
2913
-     *
2914
-     * @access    public
2915
-     */
2916
-    public function __construct()
2917
-    {
2918
-        // set default map settings
2919
-        $this->use_google_maps = true;
2920
-        $this->google_map_api_key = '';
2921
-        // for event details pages (reg page)
2922
-        $this->event_details_map_width = 585;            // ee_map_width_single
2923
-        $this->event_details_map_height = 362;            // ee_map_height_single
2924
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2925
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2926
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2927
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2928
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2929
-        // for event list pages
2930
-        $this->event_list_map_width = 300;            // ee_map_width
2931
-        $this->event_list_map_height = 185;        // ee_map_height
2932
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2933
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2934
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2935
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2936
-        $this->event_list_map_align = 'center';            // ee_map_align
2937
-    }
2830
+	/**
2831
+	 * @var boolean $use_google_maps
2832
+	 */
2833
+	public $use_google_maps;
2834
+
2835
+	/**
2836
+	 * @var string $api_key
2837
+	 */
2838
+	public $google_map_api_key;
2839
+
2840
+	/**
2841
+	 * @var int $event_details_map_width
2842
+	 */
2843
+	public $event_details_map_width;
2844
+
2845
+	/**
2846
+	 * @var int $event_details_map_height
2847
+	 */
2848
+	public $event_details_map_height;
2849
+
2850
+	/**
2851
+	 * @var int $event_details_map_zoom
2852
+	 */
2853
+	public $event_details_map_zoom;
2854
+
2855
+	/**
2856
+	 * @var boolean $event_details_display_nav
2857
+	 */
2858
+	public $event_details_display_nav;
2859
+
2860
+	/**
2861
+	 * @var boolean $event_details_nav_size
2862
+	 */
2863
+	public $event_details_nav_size;
2864
+
2865
+	/**
2866
+	 * @var string $event_details_control_type
2867
+	 */
2868
+	public $event_details_control_type;
2869
+
2870
+	/**
2871
+	 * @var string $event_details_map_align
2872
+	 */
2873
+	public $event_details_map_align;
2874
+
2875
+	/**
2876
+	 * @var int $event_list_map_width
2877
+	 */
2878
+	public $event_list_map_width;
2879
+
2880
+	/**
2881
+	 * @var int $event_list_map_height
2882
+	 */
2883
+	public $event_list_map_height;
2884
+
2885
+	/**
2886
+	 * @var int $event_list_map_zoom
2887
+	 */
2888
+	public $event_list_map_zoom;
2889
+
2890
+	/**
2891
+	 * @var boolean $event_list_display_nav
2892
+	 */
2893
+	public $event_list_display_nav;
2894
+
2895
+	/**
2896
+	 * @var boolean $event_list_nav_size
2897
+	 */
2898
+	public $event_list_nav_size;
2899
+
2900
+	/**
2901
+	 * @var string $event_list_control_type
2902
+	 */
2903
+	public $event_list_control_type;
2904
+
2905
+	/**
2906
+	 * @var string $event_list_map_align
2907
+	 */
2908
+	public $event_list_map_align;
2909
+
2910
+
2911
+	/**
2912
+	 *    class constructor
2913
+	 *
2914
+	 * @access    public
2915
+	 */
2916
+	public function __construct()
2917
+	{
2918
+		// set default map settings
2919
+		$this->use_google_maps = true;
2920
+		$this->google_map_api_key = '';
2921
+		// for event details pages (reg page)
2922
+		$this->event_details_map_width = 585;            // ee_map_width_single
2923
+		$this->event_details_map_height = 362;            // ee_map_height_single
2924
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2925
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2926
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2927
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2928
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2929
+		// for event list pages
2930
+		$this->event_list_map_width = 300;            // ee_map_width
2931
+		$this->event_list_map_height = 185;        // ee_map_height
2932
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2933
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2934
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2935
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2936
+		$this->event_list_map_align = 'center';            // ee_map_align
2937
+	}
2938 2938
 }
2939 2939
 
2940 2940
 /**
@@ -2942,46 +2942,46 @@  discard block
 block discarded – undo
2942 2942
  */
2943 2943
 class EE_Events_Archive_Config extends EE_Config_Base
2944 2944
 {
2945
-    public $display_status_banner;
2945
+	public $display_status_banner;
2946 2946
 
2947
-    public $display_description;
2947
+	public $display_description;
2948 2948
 
2949
-    public $display_ticket_selector;
2949
+	public $display_ticket_selector;
2950 2950
 
2951
-    public $display_datetimes;
2951
+	public $display_datetimes;
2952 2952
 
2953
-    public $display_venue;
2953
+	public $display_venue;
2954 2954
 
2955
-    public $display_expired_events;
2955
+	public $display_expired_events;
2956 2956
 
2957
-    public $use_sortable_display_order;
2957
+	public $use_sortable_display_order;
2958 2958
 
2959
-    public $display_order_tickets;
2959
+	public $display_order_tickets;
2960 2960
 
2961
-    public $display_order_datetimes;
2961
+	public $display_order_datetimes;
2962 2962
 
2963
-    public $display_order_event;
2963
+	public $display_order_event;
2964 2964
 
2965
-    public $display_order_venue;
2965
+	public $display_order_venue;
2966 2966
 
2967 2967
 
2968
-    /**
2969
-     *    class constructor
2970
-     */
2971
-    public function __construct()
2972
-    {
2973
-        $this->display_status_banner = 0;
2974
-        $this->display_description = 1;
2975
-        $this->display_ticket_selector = 0;
2976
-        $this->display_datetimes = 1;
2977
-        $this->display_venue = 0;
2978
-        $this->display_expired_events = 0;
2979
-        $this->use_sortable_display_order = false;
2980
-        $this->display_order_tickets = 100;
2981
-        $this->display_order_datetimes = 110;
2982
-        $this->display_order_event = 120;
2983
-        $this->display_order_venue = 130;
2984
-    }
2968
+	/**
2969
+	 *    class constructor
2970
+	 */
2971
+	public function __construct()
2972
+	{
2973
+		$this->display_status_banner = 0;
2974
+		$this->display_description = 1;
2975
+		$this->display_ticket_selector = 0;
2976
+		$this->display_datetimes = 1;
2977
+		$this->display_venue = 0;
2978
+		$this->display_expired_events = 0;
2979
+		$this->use_sortable_display_order = false;
2980
+		$this->display_order_tickets = 100;
2981
+		$this->display_order_datetimes = 110;
2982
+		$this->display_order_event = 120;
2983
+		$this->display_order_venue = 130;
2984
+	}
2985 2985
 }
2986 2986
 
2987 2987
 /**
@@ -2989,34 +2989,34 @@  discard block
 block discarded – undo
2989 2989
  */
2990 2990
 class EE_Event_Single_Config extends EE_Config_Base
2991 2991
 {
2992
-    public $display_status_banner_single;
2992
+	public $display_status_banner_single;
2993 2993
 
2994
-    public $display_venue;
2994
+	public $display_venue;
2995 2995
 
2996
-    public $use_sortable_display_order;
2996
+	public $use_sortable_display_order;
2997 2997
 
2998
-    public $display_order_tickets;
2998
+	public $display_order_tickets;
2999 2999
 
3000
-    public $display_order_datetimes;
3000
+	public $display_order_datetimes;
3001 3001
 
3002
-    public $display_order_event;
3002
+	public $display_order_event;
3003 3003
 
3004
-    public $display_order_venue;
3004
+	public $display_order_venue;
3005 3005
 
3006 3006
 
3007
-    /**
3008
-     *    class constructor
3009
-     */
3010
-    public function __construct()
3011
-    {
3012
-        $this->display_status_banner_single = 0;
3013
-        $this->display_venue = 1;
3014
-        $this->use_sortable_display_order = false;
3015
-        $this->display_order_tickets = 100;
3016
-        $this->display_order_datetimes = 110;
3017
-        $this->display_order_event = 120;
3018
-        $this->display_order_venue = 130;
3019
-    }
3007
+	/**
3008
+	 *    class constructor
3009
+	 */
3010
+	public function __construct()
3011
+	{
3012
+		$this->display_status_banner_single = 0;
3013
+		$this->display_venue = 1;
3014
+		$this->use_sortable_display_order = false;
3015
+		$this->display_order_tickets = 100;
3016
+		$this->display_order_datetimes = 110;
3017
+		$this->display_order_event = 120;
3018
+		$this->display_order_venue = 130;
3019
+	}
3020 3020
 }
3021 3021
 
3022 3022
 /**
@@ -3024,172 +3024,172 @@  discard block
 block discarded – undo
3024 3024
  */
3025 3025
 class EE_Ticket_Selector_Config extends EE_Config_Base
3026 3026
 {
3027
-    /**
3028
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
3029
-     */
3030
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
3031
-
3032
-    /**
3033
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
3034
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
3035
-     */
3036
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
3037
-
3038
-    /**
3039
-     * @var boolean $show_ticket_sale_columns
3040
-     */
3041
-    public $show_ticket_sale_columns;
3042
-
3043
-    /**
3044
-     * @var boolean $show_ticket_details
3045
-     */
3046
-    public $show_ticket_details;
3047
-
3048
-    /**
3049
-     * @var boolean $show_expired_tickets
3050
-     */
3051
-    public $show_expired_tickets;
3052
-
3053
-    /**
3054
-     * whether to display a dropdown box populated with event datetimes
3055
-     * that toggles which tickets are displayed for a ticket selector.
3056
-     * uses one of the *_DATETIME_SELECTOR constants defined above
3057
-     *
3058
-     * @var string $show_datetime_selector
3059
-     */
3060
-    private $show_datetime_selector = 'no_datetime_selector';
3061
-
3062
-    /**
3063
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
3064
-     *
3065
-     * @var int $datetime_selector_threshold
3066
-     */
3067
-    private $datetime_selector_threshold = 3;
3068
-
3069
-    /**
3070
-     * determines the maximum number of "checked" dates in the date and time filter
3071
-     *
3072
-     * @var int $datetime_selector_checked
3073
-     */
3074
-    private $datetime_selector_max_checked = 10;
3075
-
3076
-
3077
-    /**
3078
-     *    class constructor
3079
-     */
3080
-    public function __construct()
3081
-    {
3082
-        $this->show_ticket_sale_columns = true;
3083
-        $this->show_ticket_details = true;
3084
-        $this->show_expired_tickets = true;
3085
-        $this->show_datetime_selector = EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3086
-        $this->datetime_selector_threshold = 3;
3087
-        $this->datetime_selector_max_checked = 10;
3088
-    }
3089
-
3090
-
3091
-    /**
3092
-     * returns true if a datetime selector should be displayed
3093
-     *
3094
-     * @param array $datetimes
3095
-     * @return bool
3096
-     */
3097
-    public function showDatetimeSelector(array $datetimes)
3098
-    {
3099
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3100
-        return ! (
3101
-            $this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3102
-            || (
3103
-                $this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3104
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3105
-            )
3106
-        );
3107
-    }
3108
-
3109
-
3110
-    /**
3111
-     * @return string
3112
-     */
3113
-    public function getShowDatetimeSelector()
3114
-    {
3115
-        return $this->show_datetime_selector;
3116
-    }
3117
-
3118
-
3119
-    /**
3120
-     * @param bool $keys_only
3121
-     * @return array
3122
-     */
3123
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3124
-    {
3125
-        return $keys_only
3126
-            ? array(
3127
-                EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3128
-                EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3129
-            )
3130
-            : array(
3131
-                EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3132
-                    'Do not show date & time filter',
3133
-                    'event_espresso'
3134
-                ),
3135
-                EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3136
-                    'Maybe show date & time filter',
3137
-                    'event_espresso'
3138
-                ),
3139
-            );
3140
-    }
3141
-
3142
-
3143
-    /**
3144
-     * @param string $show_datetime_selector
3145
-     */
3146
-    public function setShowDatetimeSelector($show_datetime_selector)
3147
-    {
3148
-        $this->show_datetime_selector = in_array(
3149
-            $show_datetime_selector,
3150
-            $this->getShowDatetimeSelectorOptions(),
3151
-            true
3152
-        )
3153
-            ? $show_datetime_selector
3154
-            : EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3155
-    }
3156
-
3157
-
3158
-    /**
3159
-     * @return int
3160
-     */
3161
-    public function getDatetimeSelectorThreshold()
3162
-    {
3163
-        return $this->datetime_selector_threshold;
3164
-    }
3165
-
3166
-
3167
-    /**
3168
-     * @param int $datetime_selector_threshold
3169
-     */
3170
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3171
-    {
3172
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3173
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3174
-    }
3175
-
3176
-
3177
-    /**
3178
-     * @return int
3179
-     */
3180
-    public function getDatetimeSelectorMaxChecked()
3181
-    {
3182
-        return $this->datetime_selector_max_checked;
3183
-    }
3184
-
3185
-
3186
-    /**
3187
-     * @param int $datetime_selector_max_checked
3188
-     */
3189
-    public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3190
-    {
3191
-        $this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3192
-    }
3027
+	/**
3028
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
3029
+	 */
3030
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
3031
+
3032
+	/**
3033
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
3034
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
3035
+	 */
3036
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
3037
+
3038
+	/**
3039
+	 * @var boolean $show_ticket_sale_columns
3040
+	 */
3041
+	public $show_ticket_sale_columns;
3042
+
3043
+	/**
3044
+	 * @var boolean $show_ticket_details
3045
+	 */
3046
+	public $show_ticket_details;
3047
+
3048
+	/**
3049
+	 * @var boolean $show_expired_tickets
3050
+	 */
3051
+	public $show_expired_tickets;
3052
+
3053
+	/**
3054
+	 * whether to display a dropdown box populated with event datetimes
3055
+	 * that toggles which tickets are displayed for a ticket selector.
3056
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
3057
+	 *
3058
+	 * @var string $show_datetime_selector
3059
+	 */
3060
+	private $show_datetime_selector = 'no_datetime_selector';
3061
+
3062
+	/**
3063
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
3064
+	 *
3065
+	 * @var int $datetime_selector_threshold
3066
+	 */
3067
+	private $datetime_selector_threshold = 3;
3068
+
3069
+	/**
3070
+	 * determines the maximum number of "checked" dates in the date and time filter
3071
+	 *
3072
+	 * @var int $datetime_selector_checked
3073
+	 */
3074
+	private $datetime_selector_max_checked = 10;
3075
+
3076
+
3077
+	/**
3078
+	 *    class constructor
3079
+	 */
3080
+	public function __construct()
3081
+	{
3082
+		$this->show_ticket_sale_columns = true;
3083
+		$this->show_ticket_details = true;
3084
+		$this->show_expired_tickets = true;
3085
+		$this->show_datetime_selector = EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3086
+		$this->datetime_selector_threshold = 3;
3087
+		$this->datetime_selector_max_checked = 10;
3088
+	}
3089
+
3090
+
3091
+	/**
3092
+	 * returns true if a datetime selector should be displayed
3093
+	 *
3094
+	 * @param array $datetimes
3095
+	 * @return bool
3096
+	 */
3097
+	public function showDatetimeSelector(array $datetimes)
3098
+	{
3099
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3100
+		return ! (
3101
+			$this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3102
+			|| (
3103
+				$this->getShowDatetimeSelector() === EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3104
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3105
+			)
3106
+		);
3107
+	}
3108
+
3109
+
3110
+	/**
3111
+	 * @return string
3112
+	 */
3113
+	public function getShowDatetimeSelector()
3114
+	{
3115
+		return $this->show_datetime_selector;
3116
+	}
3117
+
3118
+
3119
+	/**
3120
+	 * @param bool $keys_only
3121
+	 * @return array
3122
+	 */
3123
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3124
+	{
3125
+		return $keys_only
3126
+			? array(
3127
+				EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3128
+				EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3129
+			)
3130
+			: array(
3131
+				EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3132
+					'Do not show date & time filter',
3133
+					'event_espresso'
3134
+				),
3135
+				EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3136
+					'Maybe show date & time filter',
3137
+					'event_espresso'
3138
+				),
3139
+			);
3140
+	}
3141
+
3142
+
3143
+	/**
3144
+	 * @param string $show_datetime_selector
3145
+	 */
3146
+	public function setShowDatetimeSelector($show_datetime_selector)
3147
+	{
3148
+		$this->show_datetime_selector = in_array(
3149
+			$show_datetime_selector,
3150
+			$this->getShowDatetimeSelectorOptions(),
3151
+			true
3152
+		)
3153
+			? $show_datetime_selector
3154
+			: EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3155
+	}
3156
+
3157
+
3158
+	/**
3159
+	 * @return int
3160
+	 */
3161
+	public function getDatetimeSelectorThreshold()
3162
+	{
3163
+		return $this->datetime_selector_threshold;
3164
+	}
3165
+
3166
+
3167
+	/**
3168
+	 * @param int $datetime_selector_threshold
3169
+	 */
3170
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3171
+	{
3172
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3173
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3174
+	}
3175
+
3176
+
3177
+	/**
3178
+	 * @return int
3179
+	 */
3180
+	public function getDatetimeSelectorMaxChecked()
3181
+	{
3182
+		return $this->datetime_selector_max_checked;
3183
+	}
3184
+
3185
+
3186
+	/**
3187
+	 * @param int $datetime_selector_max_checked
3188
+	 */
3189
+	public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3190
+	{
3191
+		$this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3192
+	}
3193 3193
 }
3194 3194
 
3195 3195
 /**
@@ -3201,79 +3201,79 @@  discard block
 block discarded – undo
3201 3201
  */
3202 3202
 class EE_Environment_Config extends EE_Config_Base
3203 3203
 {
3204
-    /**
3205
-     * Hold any php environment variables that we want to track.
3206
-     *
3207
-     * @var stdClass;
3208
-     */
3209
-    public $php;
3210
-
3211
-
3212
-    /**
3213
-     *    constructor
3214
-     */
3215
-    public function __construct()
3216
-    {
3217
-        $this->php = new stdClass();
3218
-        $this->_set_php_values();
3219
-    }
3220
-
3221
-
3222
-    /**
3223
-     * This sets the php environment variables.
3224
-     *
3225
-     * @since 4.4.0
3226
-     * @return void
3227
-     */
3228
-    protected function _set_php_values()
3229
-    {
3230
-        $this->php->max_input_vars = ini_get('max_input_vars');
3231
-        $this->php->version = phpversion();
3232
-    }
3233
-
3234
-
3235
-    /**
3236
-     * helper method for determining whether input_count is
3237
-     * reaching the potential maximum the server can handle
3238
-     * according to max_input_vars
3239
-     *
3240
-     * @param int   $input_count the count of input vars.
3241
-     * @return string error message
3242
-     */
3243
-    public function max_input_vars_limit_check($input_count = 0)
3244
-    {
3245
-        if (
3246
-            ! empty($this->php->max_input_vars)
3247
-            && ($input_count >= $this->php->max_input_vars)
3248
-        ) {
3249
-            // check the server setting because the config value could be stale
3250
-            $max_input_vars = ini_get('max_input_vars');
3251
-            if ($input_count >= $max_input_vars) {
3252
-                return sprintf(
3253
-                    esc_html__(
3254
-                        'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.',
3255
-                        'event_espresso'
3256
-                    ),
3257
-                    '<br>',
3258
-                    $input_count,
3259
-                    $max_input_vars
3260
-                );
3261
-            }
3262
-        }
3263
-        return '';
3264
-    }
3265
-
3266
-
3267
-    /**
3268
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3269
-     *
3270
-     * @since 4.4.1
3271
-     * @return void
3272
-     */
3273
-    public function recheck_values()
3274
-    {
3275
-        $this->_set_php_values();
3276
-    }
3204
+	/**
3205
+	 * Hold any php environment variables that we want to track.
3206
+	 *
3207
+	 * @var stdClass;
3208
+	 */
3209
+	public $php;
3210
+
3211
+
3212
+	/**
3213
+	 *    constructor
3214
+	 */
3215
+	public function __construct()
3216
+	{
3217
+		$this->php = new stdClass();
3218
+		$this->_set_php_values();
3219
+	}
3220
+
3221
+
3222
+	/**
3223
+	 * This sets the php environment variables.
3224
+	 *
3225
+	 * @since 4.4.0
3226
+	 * @return void
3227
+	 */
3228
+	protected function _set_php_values()
3229
+	{
3230
+		$this->php->max_input_vars = ini_get('max_input_vars');
3231
+		$this->php->version = phpversion();
3232
+	}
3233
+
3234
+
3235
+	/**
3236
+	 * helper method for determining whether input_count is
3237
+	 * reaching the potential maximum the server can handle
3238
+	 * according to max_input_vars
3239
+	 *
3240
+	 * @param int   $input_count the count of input vars.
3241
+	 * @return string error message
3242
+	 */
3243
+	public function max_input_vars_limit_check($input_count = 0)
3244
+	{
3245
+		if (
3246
+			! empty($this->php->max_input_vars)
3247
+			&& ($input_count >= $this->php->max_input_vars)
3248
+		) {
3249
+			// check the server setting because the config value could be stale
3250
+			$max_input_vars = ini_get('max_input_vars');
3251
+			if ($input_count >= $max_input_vars) {
3252
+				return sprintf(
3253
+					esc_html__(
3254
+						'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.',
3255
+						'event_espresso'
3256
+					),
3257
+					'<br>',
3258
+					$input_count,
3259
+					$max_input_vars
3260
+				);
3261
+			}
3262
+		}
3263
+		return '';
3264
+	}
3265
+
3266
+
3267
+	/**
3268
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3269
+	 *
3270
+	 * @since 4.4.1
3271
+	 * @return void
3272
+	 */
3273
+	public function recheck_values()
3274
+	{
3275
+		$this->_set_php_values();
3276
+	}
3277 3277
 }
3278 3278
 
3279 3279
 /**
@@ -3285,21 +3285,21 @@  discard block
 block discarded – undo
3285 3285
  */
3286 3286
 class EE_Tax_Config extends EE_Config_Base
3287 3287
 {
3288
-    /*
3288
+	/*
3289 3289
      * flag to indicate whether to display ticket prices with the taxes included
3290 3290
      *
3291 3291
      * @var boolean $prices_displayed_including_taxes
3292 3292
      */
3293
-    public $prices_displayed_including_taxes;
3293
+	public $prices_displayed_including_taxes;
3294 3294
 
3295 3295
 
3296
-    /**
3297
-     *    class constructor
3298
-     */
3299
-    public function __construct()
3300
-    {
3301
-        $this->prices_displayed_including_taxes = true;
3302
-    }
3296
+	/**
3297
+	 *    class constructor
3298
+	 */
3299
+	public function __construct()
3300
+	{
3301
+		$this->prices_displayed_including_taxes = true;
3302
+	}
3303 3303
 }
3304 3304
 
3305 3305
 /**
@@ -3312,19 +3312,19 @@  discard block
 block discarded – undo
3312 3312
  */
3313 3313
 class EE_Messages_Config extends EE_Config_Base
3314 3314
 {
3315
-    /**
3316
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3317
-     * A value of 0 represents never deleting.  Default is 0.
3318
-     *
3319
-     * @var integer
3320
-     */
3321
-    public $delete_threshold;
3322
-
3323
-
3324
-    public function __construct()
3325
-    {
3326
-        $this->delete_threshold = 0;
3327
-    }
3315
+	/**
3316
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3317
+	 * A value of 0 represents never deleting.  Default is 0.
3318
+	 *
3319
+	 * @var integer
3320
+	 */
3321
+	public $delete_threshold;
3322
+
3323
+
3324
+	public function __construct()
3325
+	{
3326
+		$this->delete_threshold = 0;
3327
+	}
3328 3328
 }
3329 3329
 
3330 3330
 /**
@@ -3334,31 +3334,31 @@  discard block
 block discarded – undo
3334 3334
  */
3335 3335
 class EE_Gateway_Config extends EE_Config_Base
3336 3336
 {
3337
-    /**
3338
-     * Array with keys that are payment gateways slugs, and values are arrays
3339
-     * with any config info the gateway wants to store
3340
-     *
3341
-     * @var array
3342
-     */
3343
-    public $payment_settings;
3344
-
3345
-    /**
3346
-     * Where keys are gateway slugs, and values are booleans indicating whether
3347
-     * the gateway is stored in the uploads directory
3348
-     *
3349
-     * @var array
3350
-     */
3351
-    public $active_gateways;
3352
-
3353
-
3354
-    /**
3355
-     *    class constructor
3356
-     *
3357
-     * @deprecated
3358
-     */
3359
-    public function __construct()
3360
-    {
3361
-        $this->payment_settings = array();
3362
-        $this->active_gateways = array('Invoice' => false);
3363
-    }
3337
+	/**
3338
+	 * Array with keys that are payment gateways slugs, and values are arrays
3339
+	 * with any config info the gateway wants to store
3340
+	 *
3341
+	 * @var array
3342
+	 */
3343
+	public $payment_settings;
3344
+
3345
+	/**
3346
+	 * Where keys are gateway slugs, and values are booleans indicating whether
3347
+	 * the gateway is stored in the uploads directory
3348
+	 *
3349
+	 * @var array
3350
+	 */
3351
+	public $active_gateways;
3352
+
3353
+
3354
+	/**
3355
+	 *    class constructor
3356
+	 *
3357
+	 * @deprecated
3358
+	 */
3359
+	public function __construct()
3360
+	{
3361
+		$this->payment_settings = array();
3362
+		$this->active_gateways = array('Invoice' => false);
3363
+	}
3364 3364
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_CPT.core.php 1 patch
Indentation   +1427 added lines, -1427 removed lines patch added patch discarded remove patch
@@ -31,452 +31,452 @@  discard block
 block discarded – undo
31 31
  */
32 32
 abstract class EE_Admin_Page_CPT extends EE_Admin_Page
33 33
 {
34
-    /**
35
-     * @var EE_CPT_Base|null
36
-     */
37
-    protected $_cpt_model_obj;
38
-
39
-    protected ?WP_Post_Type $_cpt_object = null;
40
-
41
-
42
-    /**
43
-     * This property allows cpt classes to define multiple routes as cpt routes.
44
-     * //in this array we define what the custom post type for this route is.
45
-     * array(
46
-     * 'route_name' => 'custom_post_type_slug'
47
-     * )
48
-     *
49
-     * @var array
50
-     */
51
-    protected array $_cpt_routes = [];
52
-
53
-
54
-    /**
55
-     * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
56
-     * in this format:
57
-     * array(
58
-     * 'post_type_slug' => 'edit_route'
59
-     * )
60
-     *
61
-     * @var array
62
-     */
63
-    protected array $_cpt_edit_routes = [];
64
-
65
-
66
-    /**
67
-     * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
68
-     * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
69
-     * _cpt_model_names property should be in the following format: array(
70
-     * 'route_defined_by_action_param' => 'Model_Name')
71
-     *
72
-     * @var array $_cpt_model_names
73
-     */
74
-    protected array $_cpt_model_names = [];
75
-
76
-
77
-    /**
78
-     * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
79
-     * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
80
-     * the _register_autosave_containers() method so that we don't override any other containers already registered.
81
-     * Registration of containers should be done before load_page_dependencies() is run.
82
-     *
83
-     * @var array
84
-     */
85
-    protected array $_autosave_containers = [];
86
-
87
-    protected array $_autosave_fields     = [];
88
-
89
-    /**
90
-     * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
91
-     * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
92
-     *
93
-     * @var array
94
-     */
95
-    protected array $_pagenow_map= [];
96
-
97
-
98
-    /**
99
-     * This is the route that will be used for the edit post route.
100
-     *
101
-     * @var string
102
-     */
103
-    protected string $cpt_editpost_route = 'edit';
104
-
105
-
106
-    /**
107
-     * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
108
-     * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
109
-     * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
110
-     * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
111
-     * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
112
-     *
113
-     * @abstract
114
-     * @param string  $post_id The ID of the cpt that was saved (so you can link relationally)
115
-     * @param WP_Post $post    The post object of the cpt that was saved.
116
-     * @return void
117
-     */
118
-    abstract protected function _insert_update_cpt_item($post_id, $post);
119
-
120
-
121
-    /**
122
-     * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
123
-     *
124
-     * @abstract
125
-     * @param string $post_id The ID of the cpt that was trashed
126
-     * @return void
127
-     */
128
-    abstract public function trash_cpt_item($post_id);
129
-
130
-
131
-    /**
132
-     * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
133
-     *
134
-     * @param string $post_id theID of the cpt that was untrashed
135
-     * @return void
136
-     */
137
-    abstract public function restore_cpt_item($post_id);
138
-
139
-
140
-    /**
141
-     * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
142
-     * from the db
143
-     *
144
-     * @param string $post_id the ID of the cpt that was deleted
145
-     * @return void
146
-     */
147
-    abstract public function delete_cpt_item($post_id);
148
-
149
-
150
-    /**
151
-     * @return LoaderInterface
152
-     * @throws InvalidArgumentException
153
-     * @throws InvalidDataTypeException
154
-     * @throws InvalidInterfaceException
155
-     */
156
-    protected function getLoader(): LoaderInterface
157
-    {
158
-        if (! $this->loader instanceof LoaderInterface) {
159
-            $this->loader = LoaderFactory::getLoader();
160
-        }
161
-        return $this->loader;
162
-    }
163
-
164
-
165
-    /**
166
-     * Just utilizing the method EE_Admin exposes for doing things before page setup.
167
-     *
168
-     * @return void
169
-     */
170
-    protected function _before_page_setup()
171
-    {
172
-        $this->raw_req_action = $this->request->getRequestParam('action');
173
-        $this->raw_req_page   = $this->request->getRequestParam('page');
174
-        $this->_cpt_routes    = array_merge(
175
-            [
176
-                'create_new' => $this->page_slug,
177
-                'edit'       => $this->page_slug,
178
-                'trash'      => $this->page_slug,
179
-            ],
180
-            $this->_cpt_routes
181
-        );
182
-        $cpt_route_action     = $this->_cpt_routes[ $this->raw_req_action ] ?? null;
183
-        // let's see if the current route has a value for cpt_object_slug. if it does, we use that instead of the page
184
-        $page              = $this->raw_req_page ?: $this->page_slug;
185
-        $page              = $cpt_route_action ?: $page;
186
-        $this->_cpt_object = get_post_type_object($page);
187
-        // tweak pagenow for page loading.
188
-        if (empty($this->_pagenow_map)) {
189
-            $this->_pagenow_map = [
190
-                'create_new' => 'post-new.php',
191
-                'edit'       => 'post.php',
192
-                'trash'      => 'post.php',
193
-            ];
194
-        }
195
-        add_action('current_screen', [$this, 'modify_pagenow']);
196
-        // TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
197
-        // get current page from autosave
198
-        $current_page        = $this->request->getRequestParam('ee_autosave_data[ee-cpt-hidden-inputs][current_page]');
199
-        $this->_current_page = $this->request->getRequestParam('current_page', $current_page);
200
-    }
201
-
202
-
203
-    /**
204
-     * Simply ensure that we simulate the correct post route for cpt screens
205
-     *
206
-     * @param WP_Screen|null $current_screen
207
-     * @return void
208
-     */
209
-    public function modify_pagenow(?WP_Screen $current_screen)
210
-    {
211
-        // possibly reset pagenow.
212
-        if (
213
-            $this->page_slug === $this->raw_req_page
214
-            && isset($this->_pagenow_map[ $this->raw_req_action ])
215
-        ) {
216
-            global $pagenow, $hook_suffix;
217
-            $pagenow     = $this->_pagenow_map[ $this->raw_req_action ];
218
-            $hook_suffix = $pagenow;
219
-        }
220
-    }
221
-
222
-
223
-    /**
224
-     * This method is used to register additional autosave containers to the _autosave_containers property.
225
-     *
226
-     * @param array $ids  an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
227
-     *                    you would send along the id of a metabox container.
228
-     * @return void
229
-     * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
230
-     *                    automatically register the id for the post metabox as a container.
231
-     */
232
-    protected function _register_autosave_containers($ids)
233
-    {
234
-        $this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids);
235
-    }
236
-
237
-
238
-    /**
239
-     * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
240
-     * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
241
-     */
242
-    protected function _set_autosave_containers()
243
-    {
244
-        global $wp_meta_boxes;
245
-        $containers = [];
246
-        if (empty($wp_meta_boxes)) {
247
-            return;
248
-        }
249
-        $current_metaboxes = $wp_meta_boxes[ $this->page_slug ] ?? [];
250
-        foreach ($current_metaboxes as $box_context) {
251
-            foreach ($box_context as $box_details) {
252
-                foreach ($box_details as $box) {
253
-                    if (
254
-                        is_array($box) && is_array($box['callback'])
255
-                        && (
256
-                            $box['callback'][0] instanceof EE_Admin_Page
257
-                            || $box['callback'][0] instanceof EE_Admin_Hooks
258
-                        )
259
-                    ) {
260
-                        $containers[] = $box['id'];
261
-                    }
262
-                }
263
-            }
264
-        }
265
-        $this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
266
-        // add hidden inputs container
267
-        $this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
268
-    }
269
-
270
-
271
-    protected function _load_autosave_scripts_styles()
272
-    {
273
-        /*wp_register_script('cpt-autosave', EE_ADMIN_URL . 'assets/ee-cpt-autosave.js', array('ee-serialize-full-array', 'event_editor_js'), EVENT_ESPRESSO_VERSION, TRUE );
34
+	/**
35
+	 * @var EE_CPT_Base|null
36
+	 */
37
+	protected $_cpt_model_obj;
38
+
39
+	protected ?WP_Post_Type $_cpt_object = null;
40
+
41
+
42
+	/**
43
+	 * This property allows cpt classes to define multiple routes as cpt routes.
44
+	 * //in this array we define what the custom post type for this route is.
45
+	 * array(
46
+	 * 'route_name' => 'custom_post_type_slug'
47
+	 * )
48
+	 *
49
+	 * @var array
50
+	 */
51
+	protected array $_cpt_routes = [];
52
+
53
+
54
+	/**
55
+	 * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
56
+	 * in this format:
57
+	 * array(
58
+	 * 'post_type_slug' => 'edit_route'
59
+	 * )
60
+	 *
61
+	 * @var array
62
+	 */
63
+	protected array $_cpt_edit_routes = [];
64
+
65
+
66
+	/**
67
+	 * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
68
+	 * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
69
+	 * _cpt_model_names property should be in the following format: array(
70
+	 * 'route_defined_by_action_param' => 'Model_Name')
71
+	 *
72
+	 * @var array $_cpt_model_names
73
+	 */
74
+	protected array $_cpt_model_names = [];
75
+
76
+
77
+	/**
78
+	 * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
79
+	 * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
80
+	 * the _register_autosave_containers() method so that we don't override any other containers already registered.
81
+	 * Registration of containers should be done before load_page_dependencies() is run.
82
+	 *
83
+	 * @var array
84
+	 */
85
+	protected array $_autosave_containers = [];
86
+
87
+	protected array $_autosave_fields     = [];
88
+
89
+	/**
90
+	 * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
91
+	 * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
92
+	 *
93
+	 * @var array
94
+	 */
95
+	protected array $_pagenow_map= [];
96
+
97
+
98
+	/**
99
+	 * This is the route that will be used for the edit post route.
100
+	 *
101
+	 * @var string
102
+	 */
103
+	protected string $cpt_editpost_route = 'edit';
104
+
105
+
106
+	/**
107
+	 * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
108
+	 * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
109
+	 * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
110
+	 * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
111
+	 * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
112
+	 *
113
+	 * @abstract
114
+	 * @param string  $post_id The ID of the cpt that was saved (so you can link relationally)
115
+	 * @param WP_Post $post    The post object of the cpt that was saved.
116
+	 * @return void
117
+	 */
118
+	abstract protected function _insert_update_cpt_item($post_id, $post);
119
+
120
+
121
+	/**
122
+	 * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
123
+	 *
124
+	 * @abstract
125
+	 * @param string $post_id The ID of the cpt that was trashed
126
+	 * @return void
127
+	 */
128
+	abstract public function trash_cpt_item($post_id);
129
+
130
+
131
+	/**
132
+	 * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
133
+	 *
134
+	 * @param string $post_id theID of the cpt that was untrashed
135
+	 * @return void
136
+	 */
137
+	abstract public function restore_cpt_item($post_id);
138
+
139
+
140
+	/**
141
+	 * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
142
+	 * from the db
143
+	 *
144
+	 * @param string $post_id the ID of the cpt that was deleted
145
+	 * @return void
146
+	 */
147
+	abstract public function delete_cpt_item($post_id);
148
+
149
+
150
+	/**
151
+	 * @return LoaderInterface
152
+	 * @throws InvalidArgumentException
153
+	 * @throws InvalidDataTypeException
154
+	 * @throws InvalidInterfaceException
155
+	 */
156
+	protected function getLoader(): LoaderInterface
157
+	{
158
+		if (! $this->loader instanceof LoaderInterface) {
159
+			$this->loader = LoaderFactory::getLoader();
160
+		}
161
+		return $this->loader;
162
+	}
163
+
164
+
165
+	/**
166
+	 * Just utilizing the method EE_Admin exposes for doing things before page setup.
167
+	 *
168
+	 * @return void
169
+	 */
170
+	protected function _before_page_setup()
171
+	{
172
+		$this->raw_req_action = $this->request->getRequestParam('action');
173
+		$this->raw_req_page   = $this->request->getRequestParam('page');
174
+		$this->_cpt_routes    = array_merge(
175
+			[
176
+				'create_new' => $this->page_slug,
177
+				'edit'       => $this->page_slug,
178
+				'trash'      => $this->page_slug,
179
+			],
180
+			$this->_cpt_routes
181
+		);
182
+		$cpt_route_action     = $this->_cpt_routes[ $this->raw_req_action ] ?? null;
183
+		// let's see if the current route has a value for cpt_object_slug. if it does, we use that instead of the page
184
+		$page              = $this->raw_req_page ?: $this->page_slug;
185
+		$page              = $cpt_route_action ?: $page;
186
+		$this->_cpt_object = get_post_type_object($page);
187
+		// tweak pagenow for page loading.
188
+		if (empty($this->_pagenow_map)) {
189
+			$this->_pagenow_map = [
190
+				'create_new' => 'post-new.php',
191
+				'edit'       => 'post.php',
192
+				'trash'      => 'post.php',
193
+			];
194
+		}
195
+		add_action('current_screen', [$this, 'modify_pagenow']);
196
+		// TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
197
+		// get current page from autosave
198
+		$current_page        = $this->request->getRequestParam('ee_autosave_data[ee-cpt-hidden-inputs][current_page]');
199
+		$this->_current_page = $this->request->getRequestParam('current_page', $current_page);
200
+	}
201
+
202
+
203
+	/**
204
+	 * Simply ensure that we simulate the correct post route for cpt screens
205
+	 *
206
+	 * @param WP_Screen|null $current_screen
207
+	 * @return void
208
+	 */
209
+	public function modify_pagenow(?WP_Screen $current_screen)
210
+	{
211
+		// possibly reset pagenow.
212
+		if (
213
+			$this->page_slug === $this->raw_req_page
214
+			&& isset($this->_pagenow_map[ $this->raw_req_action ])
215
+		) {
216
+			global $pagenow, $hook_suffix;
217
+			$pagenow     = $this->_pagenow_map[ $this->raw_req_action ];
218
+			$hook_suffix = $pagenow;
219
+		}
220
+	}
221
+
222
+
223
+	/**
224
+	 * This method is used to register additional autosave containers to the _autosave_containers property.
225
+	 *
226
+	 * @param array $ids  an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
227
+	 *                    you would send along the id of a metabox container.
228
+	 * @return void
229
+	 * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
230
+	 *                    automatically register the id for the post metabox as a container.
231
+	 */
232
+	protected function _register_autosave_containers($ids)
233
+	{
234
+		$this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids);
235
+	}
236
+
237
+
238
+	/**
239
+	 * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
240
+	 * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
241
+	 */
242
+	protected function _set_autosave_containers()
243
+	{
244
+		global $wp_meta_boxes;
245
+		$containers = [];
246
+		if (empty($wp_meta_boxes)) {
247
+			return;
248
+		}
249
+		$current_metaboxes = $wp_meta_boxes[ $this->page_slug ] ?? [];
250
+		foreach ($current_metaboxes as $box_context) {
251
+			foreach ($box_context as $box_details) {
252
+				foreach ($box_details as $box) {
253
+					if (
254
+						is_array($box) && is_array($box['callback'])
255
+						&& (
256
+							$box['callback'][0] instanceof EE_Admin_Page
257
+							|| $box['callback'][0] instanceof EE_Admin_Hooks
258
+						)
259
+					) {
260
+						$containers[] = $box['id'];
261
+					}
262
+				}
263
+			}
264
+		}
265
+		$this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
266
+		// add hidden inputs container
267
+		$this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
268
+	}
269
+
270
+
271
+	protected function _load_autosave_scripts_styles()
272
+	{
273
+		/*wp_register_script('cpt-autosave', EE_ADMIN_URL . 'assets/ee-cpt-autosave.js', array('ee-serialize-full-array', 'event_editor_js'), EVENT_ESPRESSO_VERSION, TRUE );
274 274
         wp_enqueue_script('cpt-autosave');/**/ // todo re-enable when we start doing autosave again in 4.2
275 275
 
276
-        // filter _autosave_containers
277
-        $containers = apply_filters(
278
-            'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
279
-            $this->_autosave_containers,
280
-            $this
281
-        );
282
-        $containers = apply_filters(
283
-            'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
284
-            $containers,
285
-            $this
286
-        );
287
-
288
-        wp_localize_script(
289
-            'event_editor_js',
290
-            'EE_AUTOSAVE_IDS',
291
-            $containers
292
-        ); // todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
293
-
294
-        $unsaved_data_msg = [
295
-            'eventmsg'     => sprintf(
296
-                wp_strip_all_tags(
297
-                    __(
298
-                        "The changes you made to this %s will be lost if you navigate away from this page.",
299
-                        'event_espresso'
300
-                    )
301
-                ),
302
-                $this->_cpt_object->labels->singular_name
303
-            ),
304
-            'inputChanged' => 0,
305
-        ];
306
-        wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
307
-    }
308
-
309
-
310
-    /**
311
-     * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
312
-     *
313
-     * @return void
314
-     * @throws EE_Error
315
-     * @throws ReflectionException
316
-     * @throws Throwable
317
-     */
318
-    protected function _load_page_dependencies()
319
-    {
320
-        // we only add stuff if this is a cpt_route!
321
-        if (! $this->_cpt_route) {
322
-            parent::_load_page_dependencies();
323
-            return;
324
-        }
325
-        // now let's do some automatic filters into the wp_system
326
-        // and we'll check to make sure the CHILD class
327
-        // automatically has the required methods in place.
328
-        // the following filters are for setting all the redirects
329
-        // on DEFAULT WP custom post type actions
330
-        // let's add a hidden input to the post-edit form
331
-        // so we know when we have to trigger our custom redirects!
332
-        // Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
333
-        add_action('edit_form_after_title', [$this, 'cpt_post_form_hidden_input']);
334
-        // inject our Admin page nav tabs...
335
-        // let's make sure the nav tabs are set if they aren't already
336
-        // if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
337
-        add_action('edit_form_top', [$this, 'inject_nav_tabs']);
338
-        // modify the post_updated messages array
339
-        add_action('post_updated_messages', [$this, 'post_update_messages']);
340
-        // This basically allows us to change the title of the "publish" metabox area
341
-        // on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
342
-        $screen = $this->_cpt_routes[ $this->_req_action ];
343
-        if (! empty($this->_labels['publishbox'])) {
344
-            $this->addMetaBox(
345
-                'submitdiv',
346
-                $this->getPublishBoxTitle(),
347
-                'post_submit_meta_box',
348
-                $screen,
349
-                'side',
350
-                'core'
351
-            );
352
-        }
353
-        // let's add page_templates metabox if this cpt added support for it.
354
-        if ($this->_supports_page_templates($this->_cpt_object->name)) {
355
-            $this->addMetaBox(
356
-                'page_templates',
357
-                esc_html__('Page Template', 'event_espresso'),
358
-                [$this, 'page_template_meta_box'],
359
-                $screen,
360
-                'side'
361
-            );
362
-        }
363
-        // add preview button
364
-        // add_filter('get_sample_permalink_html', [PreviewButton::class, 'addButton'], 5, 2);
365
-        PreviewButton::addEventEditorPermalinkButton(5);
366
-        // add shortlink button to cpt edit screens.
367
-        //  We can do this as a universal thing BECAUSE, cpts use the same format for shortlinks as posts!
368
-        // add_filter('get_sample_permalink_html', [EventShortlinkButton::class, 'addButton'], 10, 2);
369
-        EventShortlinkButton::addEventEditorPermalinkButton();
370
-        // this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
371
-        // add_filter('get_sample_permalink_html', [TicketSelectorShortcodeButton::class, 'addButton'], 12, 2);
372
-        TicketSelectorShortcodeButton::addEventEditorPermalinkButton(12);
373
-        // insert our own post_stati dropdown
374
-        add_action('post_submitbox_misc_actions', [$this, 'custom_post_stati_dropdown']);
375
-        // This allows adding additional information to the publish post submitbox on the wp post edit form
376
-        if (method_exists($this, 'extra_misc_actions_publish_box')) {
377
-            add_action('post_submitbox_misc_actions', [$this, 'extra_misc_actions_publish_box']);
378
-        }
379
-        // This allows for adding additional stuff after the title field on the wp post edit form.
380
-        // This is also before the wp_editor for post description field.
381
-        if (method_exists($this, 'edit_form_after_title')) {
382
-            add_action('edit_form_after_title', [$this, 'edit_form_after_title']);
383
-        }
384
-        /**
385
-         * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
386
-         */
387
-        add_filter('clean_url', [$this, 'switch_core_wp_urls_with_ours']);
388
-        parent::_load_page_dependencies();
389
-        // notice we are ALSO going to load the pagenow hook set for this route
390
-        // (see _before_page_setup for the reset of the pagenow global ).
391
-        // This is for any plugins that are doing things properly
392
-        // and hooking into the load page hook for core wp cpt routes.
393
-        global $pagenow;
394
-        add_action('load-' . $pagenow, [$this, 'modify_current_screen'], 20);
395
-        do_action('load-' . $pagenow);
396
-        add_action('admin_enqueue_scripts', [$this, 'setup_autosave_hooks'], 30);
397
-        // we route REALLY early.
398
-        try {
399
-            $this->_route_admin_request();
400
-        } catch (EE_Error $e) {
401
-            $e->get_error();
402
-        }
403
-    }
404
-
405
-
406
-    /**
407
-     * Since we don't want users going to default core wp routes, this will check any wp urls run through the
408
-     * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
409
-     * route instead.
410
-     *
411
-     * @param string $good_protocol_url The escaped url.
412
-     * @return string possibly a new url for our route.
413
-     */
414
-    public function switch_core_wp_urls_with_ours(string $good_protocol_url): string
415
-    {
416
-        $routes_to_match = [
417
-            0 => [
418
-                'edit.php?post_type=espresso_attendees',
419
-                'admin.php?page=espresso_registrations&action=contact_list',
420
-            ],
421
-            1 => [
422
-                'edit.php?post_type=' . $this->_cpt_object->name,
423
-                'admin.php?page=' . $this->_cpt_object->name,
424
-            ],
425
-        ];
426
-        foreach ($routes_to_match as $route_matches) {
427
-            if (strpos($good_protocol_url, $route_matches[0]) !== false) {
428
-                return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
429
-            }
430
-        }
431
-        return $good_protocol_url;
432
-    }
433
-
434
-
435
-    /**
436
-     * Determine whether the current cpt supports page templates or not.
437
-     *
438
-     * @param string $cpt_name The cpt slug we're checking on.
439
-     * @return bool True supported, false not.
440
-     * @throws InvalidArgumentException
441
-     * @throws InvalidDataTypeException
442
-     * @throws InvalidInterfaceException
443
-     * @since %VER%
444
-     */
445
-    private function _supports_page_templates(string $cpt_name): bool
446
-    {
447
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
448
-        $custom_post_types = $this->loader->getShared(
449
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
450
-        );
451
-        $cpt_args          = $custom_post_types->getDefinitions();
452
-        $cpt_args          = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : [];
453
-        $cpt_has_support   = ! empty($cpt_args['page_templates']);
454
-
455
-        $post_templates = wp_get_theme()->get_post_templates();
456
-        // if there are $post_templates for this cpt, then we return false for this method because
457
-        // that means we aren't going to load our page template manager and leave that up to the native
458
-        // cpt template manager.
459
-        return ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
460
-    }
461
-
462
-
463
-    /**
464
-     * Callback for the page_templates metabox selector.
465
-     *
466
-     * @return void
467
-     * @since %VER%
468
-     */
469
-    public function page_template_meta_box()
470
-    {
471
-        global $post;
472
-        $template = '';
473
-
474
-        $page_template_count = count(get_page_templates());
475
-        if ($page_template_count) {
476
-            $page_template = get_post_meta($post->ID, '_wp_page_template', true);
477
-            $template      = ! empty($page_template) ? $page_template : '';
478
-        }
479
-        ?>
276
+		// filter _autosave_containers
277
+		$containers = apply_filters(
278
+			'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
279
+			$this->_autosave_containers,
280
+			$this
281
+		);
282
+		$containers = apply_filters(
283
+			'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
284
+			$containers,
285
+			$this
286
+		);
287
+
288
+		wp_localize_script(
289
+			'event_editor_js',
290
+			'EE_AUTOSAVE_IDS',
291
+			$containers
292
+		); // todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
293
+
294
+		$unsaved_data_msg = [
295
+			'eventmsg'     => sprintf(
296
+				wp_strip_all_tags(
297
+					__(
298
+						"The changes you made to this %s will be lost if you navigate away from this page.",
299
+						'event_espresso'
300
+					)
301
+				),
302
+				$this->_cpt_object->labels->singular_name
303
+			),
304
+			'inputChanged' => 0,
305
+		];
306
+		wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
307
+	}
308
+
309
+
310
+	/**
311
+	 * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
312
+	 *
313
+	 * @return void
314
+	 * @throws EE_Error
315
+	 * @throws ReflectionException
316
+	 * @throws Throwable
317
+	 */
318
+	protected function _load_page_dependencies()
319
+	{
320
+		// we only add stuff if this is a cpt_route!
321
+		if (! $this->_cpt_route) {
322
+			parent::_load_page_dependencies();
323
+			return;
324
+		}
325
+		// now let's do some automatic filters into the wp_system
326
+		// and we'll check to make sure the CHILD class
327
+		// automatically has the required methods in place.
328
+		// the following filters are for setting all the redirects
329
+		// on DEFAULT WP custom post type actions
330
+		// let's add a hidden input to the post-edit form
331
+		// so we know when we have to trigger our custom redirects!
332
+		// Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
333
+		add_action('edit_form_after_title', [$this, 'cpt_post_form_hidden_input']);
334
+		// inject our Admin page nav tabs...
335
+		// let's make sure the nav tabs are set if they aren't already
336
+		// if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
337
+		add_action('edit_form_top', [$this, 'inject_nav_tabs']);
338
+		// modify the post_updated messages array
339
+		add_action('post_updated_messages', [$this, 'post_update_messages']);
340
+		// This basically allows us to change the title of the "publish" metabox area
341
+		// on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
342
+		$screen = $this->_cpt_routes[ $this->_req_action ];
343
+		if (! empty($this->_labels['publishbox'])) {
344
+			$this->addMetaBox(
345
+				'submitdiv',
346
+				$this->getPublishBoxTitle(),
347
+				'post_submit_meta_box',
348
+				$screen,
349
+				'side',
350
+				'core'
351
+			);
352
+		}
353
+		// let's add page_templates metabox if this cpt added support for it.
354
+		if ($this->_supports_page_templates($this->_cpt_object->name)) {
355
+			$this->addMetaBox(
356
+				'page_templates',
357
+				esc_html__('Page Template', 'event_espresso'),
358
+				[$this, 'page_template_meta_box'],
359
+				$screen,
360
+				'side'
361
+			);
362
+		}
363
+		// add preview button
364
+		// add_filter('get_sample_permalink_html', [PreviewButton::class, 'addButton'], 5, 2);
365
+		PreviewButton::addEventEditorPermalinkButton(5);
366
+		// add shortlink button to cpt edit screens.
367
+		//  We can do this as a universal thing BECAUSE, cpts use the same format for shortlinks as posts!
368
+		// add_filter('get_sample_permalink_html', [EventShortlinkButton::class, 'addButton'], 10, 2);
369
+		EventShortlinkButton::addEventEditorPermalinkButton();
370
+		// this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
371
+		// add_filter('get_sample_permalink_html', [TicketSelectorShortcodeButton::class, 'addButton'], 12, 2);
372
+		TicketSelectorShortcodeButton::addEventEditorPermalinkButton(12);
373
+		// insert our own post_stati dropdown
374
+		add_action('post_submitbox_misc_actions', [$this, 'custom_post_stati_dropdown']);
375
+		// This allows adding additional information to the publish post submitbox on the wp post edit form
376
+		if (method_exists($this, 'extra_misc_actions_publish_box')) {
377
+			add_action('post_submitbox_misc_actions', [$this, 'extra_misc_actions_publish_box']);
378
+		}
379
+		// This allows for adding additional stuff after the title field on the wp post edit form.
380
+		// This is also before the wp_editor for post description field.
381
+		if (method_exists($this, 'edit_form_after_title')) {
382
+			add_action('edit_form_after_title', [$this, 'edit_form_after_title']);
383
+		}
384
+		/**
385
+		 * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
386
+		 */
387
+		add_filter('clean_url', [$this, 'switch_core_wp_urls_with_ours']);
388
+		parent::_load_page_dependencies();
389
+		// notice we are ALSO going to load the pagenow hook set for this route
390
+		// (see _before_page_setup for the reset of the pagenow global ).
391
+		// This is for any plugins that are doing things properly
392
+		// and hooking into the load page hook for core wp cpt routes.
393
+		global $pagenow;
394
+		add_action('load-' . $pagenow, [$this, 'modify_current_screen'], 20);
395
+		do_action('load-' . $pagenow);
396
+		add_action('admin_enqueue_scripts', [$this, 'setup_autosave_hooks'], 30);
397
+		// we route REALLY early.
398
+		try {
399
+			$this->_route_admin_request();
400
+		} catch (EE_Error $e) {
401
+			$e->get_error();
402
+		}
403
+	}
404
+
405
+
406
+	/**
407
+	 * Since we don't want users going to default core wp routes, this will check any wp urls run through the
408
+	 * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
409
+	 * route instead.
410
+	 *
411
+	 * @param string $good_protocol_url The escaped url.
412
+	 * @return string possibly a new url for our route.
413
+	 */
414
+	public function switch_core_wp_urls_with_ours(string $good_protocol_url): string
415
+	{
416
+		$routes_to_match = [
417
+			0 => [
418
+				'edit.php?post_type=espresso_attendees',
419
+				'admin.php?page=espresso_registrations&action=contact_list',
420
+			],
421
+			1 => [
422
+				'edit.php?post_type=' . $this->_cpt_object->name,
423
+				'admin.php?page=' . $this->_cpt_object->name,
424
+			],
425
+		];
426
+		foreach ($routes_to_match as $route_matches) {
427
+			if (strpos($good_protocol_url, $route_matches[0]) !== false) {
428
+				return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
429
+			}
430
+		}
431
+		return $good_protocol_url;
432
+	}
433
+
434
+
435
+	/**
436
+	 * Determine whether the current cpt supports page templates or not.
437
+	 *
438
+	 * @param string $cpt_name The cpt slug we're checking on.
439
+	 * @return bool True supported, false not.
440
+	 * @throws InvalidArgumentException
441
+	 * @throws InvalidDataTypeException
442
+	 * @throws InvalidInterfaceException
443
+	 * @since %VER%
444
+	 */
445
+	private function _supports_page_templates(string $cpt_name): bool
446
+	{
447
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
448
+		$custom_post_types = $this->loader->getShared(
449
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
450
+		);
451
+		$cpt_args          = $custom_post_types->getDefinitions();
452
+		$cpt_args          = isset($cpt_args[ $cpt_name ]) ? $cpt_args[ $cpt_name ]['args'] : [];
453
+		$cpt_has_support   = ! empty($cpt_args['page_templates']);
454
+
455
+		$post_templates = wp_get_theme()->get_post_templates();
456
+		// if there are $post_templates for this cpt, then we return false for this method because
457
+		// that means we aren't going to load our page template manager and leave that up to the native
458
+		// cpt template manager.
459
+		return ! isset($post_templates[ $cpt_name ]) ? $cpt_has_support : false;
460
+	}
461
+
462
+
463
+	/**
464
+	 * Callback for the page_templates metabox selector.
465
+	 *
466
+	 * @return void
467
+	 * @since %VER%
468
+	 */
469
+	public function page_template_meta_box()
470
+	{
471
+		global $post;
472
+		$template = '';
473
+
474
+		$page_template_count = count(get_page_templates());
475
+		if ($page_template_count) {
476
+			$page_template = get_post_meta($post->ID, '_wp_page_template', true);
477
+			$template      = ! empty($page_template) ? $page_template : '';
478
+		}
479
+		?>
480 480
         <p><strong><?php esc_html_e('Template', 'event_espresso') ?></strong></p>
481 481
         <label class="screen-reader-text" for="page_template">
482 482
             <?php esc_html_e('Page Template', 'event_espresso') ?>
@@ -486,457 +486,457 @@  discard block
 block discarded – undo
486 486
             <?php page_template_dropdown($template); ?>
487 487
         </select>
488 488
         <?php
489
-    }
490
-
491
-
492
-    /**
493
-     * if this post is a draft or scheduled post then we provide a preview button for user to click
494
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
495
-     *
496
-     * @param string $return    the current html
497
-     * @param int    $id        the post id for the page
498
-     * @return string            The new html string for the permalink area
499
-     * @deprecated 5.0.0.p
500
-     * @see PreviewButton::addButton()
501
-     */
502
-    public function preview_button_html(string $return, int $id): string
503
-    {
504
-        return PreviewButton::addButton($return, $id);
505
-    }
506
-
507
-
508
-    /**
509
-     * add our custom post status dropdown on the wp post page for this cpt
510
-     *
511
-     * @return void
512
-     */
513
-    public function custom_post_stati_dropdown()
514
-    {
515
-        $statuses         = $this->_cpt_model_obj->get_custom_post_statuses();
516
-        $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
517
-            ? $statuses[ $this->_cpt_model_obj->status() ]
518
-            : '';
519
-        $template_args    = [
520
-            'cur_status'            => $this->_cpt_model_obj->status(),
521
-            'statuses'              => $statuses,
522
-            'cur_status_label'      => $cur_status_label,
523
-            'localized_status_save' => sprintf(esc_html__('Save %s', 'event_espresso'), $cur_status_label),
524
-        ];
525
-        // we'll add a trash post status (WP doesn't add one for some reason)
526
-        if ($this->_cpt_model_obj->status() === 'trash') {
527
-            $template_args['cur_status_label'] = esc_html__('Trashed', 'event_espresso');
528
-            $statuses['trash']                 = esc_html__('Trashed', 'event_espresso');
529
-            $template_args['statuses']         = $statuses;
530
-        }
531
-
532
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
533
-        EEH_Template::display_template($template, $template_args);
534
-    }
535
-
536
-
537
-    public function setup_autosave_hooks()
538
-    {
539
-        $this->_set_autosave_containers();
540
-        $this->_load_autosave_scripts_styles();
541
-    }
542
-
543
-
544
-    /**
545
-     * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a post object (available
546
-     * in request data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
547
-     * for the nonce in here, but then this method looks for two things:
548
-     * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
549
-     * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
550
-     * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
551
-     * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
552
-     * template args.
553
-     *    1. $template_args['error'] = IF there is an error you can add the message in here.
554
-     *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
555
-     *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
556
-     *    $this->_template_args['data']['items'] = array(
557
-     *        'event-datetime-ids' => '1,2,3';
558
-     *    );
559
-     *    Keep in mind the following things:
560
-     *    - "where" index is for the input with the id as that string.
561
-     *    - "what" index is what will be used for the value of that input.
562
-     *
563
-     * @return void
564
-     * @throws EE_Error
565
-     */
566
-    public function do_extra_autosave_stuff()
567
-    {
568
-        // next let's check for the autosave nonce (we'll use _verify_nonce )
569
-        $nonce = $this->request->getRequestParam('autosavenonce');
570
-        $this->_verify_nonce($nonce, 'autosave');
571
-        // make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
572
-        if (! defined('DOING_AUTOSAVE')) {
573
-            define('DOING_AUTOSAVE', true);
574
-        }
575
-        // if we made it here then the nonce checked out.  Let's run our methods and actions
576
-        $autosave = "_ee_autosave_$this->_current_view";
577
-        if (method_exists($this, $autosave)) {
578
-            $this->$autosave();
579
-        } else {
580
-            $this->_template_args['success'] = true;
581
-        }
582
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
583
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
584
-        // now let's return json
585
-        $this->_return_json();
586
-    }
587
-
588
-
589
-    /**
590
-     * This takes care of setting up default routes and pages that utilize the core WP admin pages.
591
-     * Child classes can override the defaults (in cases for adding metaboxes etc.)
592
-     * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
593
-     *
594
-     * @return void
595
-     * @throws EE_Error
596
-     * @throws ReflectionException
597
-     */
598
-    protected function _extend_page_config_for_cpt()
599
-    {
600
-        // before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
601
-        if ($this->raw_req_page !== $this->page_slug) {
602
-            return;
603
-        }
604
-        // set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
605
-        if (! empty($this->_cpt_object)) {
606
-            $this->_page_routes = array_merge(
607
-                [
608
-                    'create_new' => [$this, '_create_new_cpt_item'],
609
-                    'edit'       => [$this, '_edit_cpt_item'],
610
-                ],
611
-                $this->_page_routes
612
-            );
613
-            $this->_page_config = array_merge(
614
-                [
615
-                    'create_new' => [
616
-                        'nav'           => [
617
-                            'label' => $this->_cpt_object->labels->add_new_item,
618
-                            'order' => 5,
619
-                        ],
620
-                        'require_nonce' => false,
621
-                    ],
622
-                    'edit'       => [
623
-                        'nav'           => [
624
-                            'label'      => $this->_cpt_object->labels->edit_item,
625
-                            'order'      => 5,
626
-                            'persistent' => false,
627
-                            'url'        => '',
628
-                        ],
629
-                        'require_nonce' => false,
630
-                    ],
631
-                ],
632
-                $this->_page_config
633
-            );
634
-        }
635
-        // load the next section only if this is a matching cpt route as set in the cpt routes array.
636
-        if (! isset($this->_cpt_routes[ $this->_req_action ])) {
637
-            return;
638
-        }
639
-        $this->_cpt_route = true;
640
-        // $this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]);
641
-        // add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
642
-        if (empty($this->_cpt_object)) {
643
-            $msg = sprintf(
644
-                esc_html__(
645
-                    'This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this:  1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).',
646
-                    'event_espresso'
647
-                ),
648
-                $this->page_slug,
649
-                $this->_req_action,
650
-                get_class($this)
651
-            );
652
-            throw new EE_Error($msg);
653
-        }
654
-        $this->_set_model_object($this->request->getRequestParam('post', 0, DataType::INT));
655
-    }
656
-
657
-
658
-    /**
659
-     * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
660
-     *
661
-     * @param int    $id       The id to retrieve the model object for. If empty we set a default object.
662
-     * @param bool   $ignore_route_check
663
-     * @param string $req_type whether the current route is for inserting, updating, or deleting the CPT
664
-     * @throws EE_Error
665
-     * @throws InvalidArgumentException
666
-     * @throws InvalidDataTypeException
667
-     * @throws InvalidInterfaceException
668
-     * @throws ReflectionException
669
-     */
670
-    protected function _set_model_object(int $id = 0, bool $ignore_route_check = false, string $req_type = '')
671
-    {
672
-        $model = null;
673
-        if (
674
-            empty($this->_cpt_model_names)
675
-            || (
676
-                ! $ignore_route_check
677
-                && ! isset($this->_cpt_routes[ $this->_req_action ])
678
-            )
679
-            || (
680
-                $this->_cpt_model_obj instanceof EE_CPT_Base
681
-                && $this->_cpt_model_obj->ID() === $id
682
-            )
683
-        ) {
684
-            // get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent.
685
-            return;
686
-        }
687
-        // if ignore_route_check is true, then get the model name via CustomPostTypeDefinitions
688
-        if ($ignore_route_check) {
689
-            $post_type = get_post_type($id);
690
-            /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
691
-            $custom_post_types = $this->loader->getShared(
692
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
693
-            );
694
-            $model_names       = $custom_post_types->getCustomPostTypeModelNames($post_type);
695
-            if (isset($model_names[ $post_type ])) {
696
-                $model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
697
-            }
698
-        } else {
699
-            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
700
-        }
701
-        if ($model instanceof EEM_Base) {
702
-            $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
703
-        }
704
-        do_action(
705
-            'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
706
-            $this->_cpt_model_obj,
707
-            $req_type
708
-        );
709
-    }
710
-
711
-
712
-    /**
713
-     * admin_init_global
714
-     * This runs all the code that we want executed within the WP admin_init hook.
715
-     * This method executes for ALL EE Admin pages.
716
-     *
717
-     * @return void
718
-     */
719
-    public function admin_init_global()
720
-    {
721
-        $post_ID = $this->request->getRequestParam('post', 0, DataType::INT);
722
-        // its possible this is a new save so let's catch that instead
723
-        $post_ID        = $this->request->getRequestParam('post_ID', $post_ID, DataType::INT);
724
-        $post           = get_post($post_ID);
725
-        $post_type      = $post instanceof WP_Post ? $post->post_type : false;
726
-        $current_route  = $this->request->getRequestParam('current_route', 'shouldneverwork');
727
-        $route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
728
-            ? $this->_cpt_routes[ $current_route ]
729
-            : '';
730
-        add_filter('get_delete_post_link', [$this, 'modify_delete_post_link'], 10, 2);
731
-        add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 2);
732
-        if ($post_type === $route_to_check) {
733
-            add_filter('redirect_post_location', [$this, 'cpt_post_location_redirect'], 10, 2);
734
-        }
735
-        // now let's filter redirect if we're on a revision page and the revision is for an event CPT.
736
-        $revision = $this->request->getRequestParam('revision');
737
-        if (! empty($revision)) {
738
-            $action = $this->request->getRequestParam('action');
739
-            // doing a restore?
740
-            if (! empty($action) && $action === 'restore') {
741
-                // get post for revision
742
-                $rev_post   = get_post($revision);
743
-                $rev_parent = get_post($rev_post->post_parent);
744
-                // only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
745
-                if ($rev_parent && $rev_parent->post_type === $this->page_slug) {
746
-                    add_filter('wp_redirect', [$this, 'revision_redirect']);
747
-                    // restores of revisions
748
-                    add_action('wp_restore_post_revision', [$this, 'restore_revision'], 10, 2);
749
-                }
750
-            }
751
-        }
752
-        // NOTE we ONLY want to run these hooks if we're on the right class for the given post type.  Otherwise we could see some really freaky things happen!
753
-        if ($post_type && $post_type === $route_to_check) {
754
-            // $post_id, $post
755
-            add_action('save_post', [$this, 'insert_update'], 10, 3);
756
-            // $post_id
757
-            add_action('trashed_post', [$this, 'before_trash_cpt_item']);
758
-            add_action('trashed_post', [$this, 'dont_permanently_delete_ee_cpts']);
759
-            add_action('untrashed_post', [$this, 'before_restore_cpt_item']);
760
-            add_action('after_delete_post', [$this, 'before_delete_cpt_item']);
761
-        }
762
-    }
763
-
764
-
765
-    /**
766
-     * Callback for the WordPress trashed_post hook.
767
-     * Execute some basic checks before calling the trash_cpt_item declared in the child class.
768
-     *
769
-     * @param int $post_id
770
-     * @throws EE_Error
771
-     * @throws ReflectionException
772
-     */
773
-    public function before_trash_cpt_item(int $post_id)
774
-    {
775
-        $this->_set_model_object($post_id, true, 'trash');
776
-        // if our cpt object isn't existent then get out immediately.
777
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
778
-            return;
779
-        }
780
-        $this->trash_cpt_item($post_id);
781
-    }
782
-
783
-
784
-    /**
785
-     * Callback for the WordPress untrashed_post hook.
786
-     * Execute some basic checks before calling the restore_cpt_method in the child class.
787
-     *
788
-     * @param $post_id
789
-     * @throws EE_Error
790
-     * @throws ReflectionException
791
-     */
792
-    public function before_restore_cpt_item($post_id)
793
-    {
794
-        $this->_set_model_object($post_id, true, 'restore');
795
-        // if our cpt object isn't existent then get out immediately.
796
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
797
-            return;
798
-        }
799
-        $this->restore_cpt_item($post_id);
800
-    }
801
-
802
-
803
-    /**
804
-     * Callback for the WordPress after_delete_post hook.
805
-     * Execute some basic checks before calling the delete_cpt_item method in the child class.
806
-     *
807
-     * @param $post_id
808
-     * @throws EE_Error
809
-     * @throws ReflectionException
810
-     */
811
-    public function before_delete_cpt_item($post_id)
812
-    {
813
-        $this->_set_model_object($post_id, true, 'delete');
814
-        // if our cpt object isn't existent then get out immediately.
815
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
816
-            return;
817
-        }
818
-        $this->delete_cpt_item($post_id);
819
-    }
820
-
821
-
822
-    /**
823
-     * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
824
-     * accordingly.
825
-     *
826
-     * @return void
827
-     * @throws EE_Error
828
-     * @throws ReflectionException
829
-     */
830
-    public function verify_cpt_object()
831
-    {
832
-        $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
833
-        // verify event object
834
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
835
-            throw new EE_Error(
836
-                sprintf(
837
-                    esc_html__(
838
-                        'Something has gone wrong with the page load because we are unable to set up the object for the %1$s.  This usually happens when the given id for the page route is NOT for the correct custom post type for this page',
839
-                        'event_espresso'
840
-                    ),
841
-                    $label
842
-                )
843
-            );
844
-        }
845
-        // if auto-draft then throw an error
846
-        if ($this->_cpt_model_obj->get('status') === 'auto-draft') {
847
-            EE_Error::overwrite_errors();
848
-            EE_Error::add_error(
849
-                sprintf(
850
-                    esc_html__(
851
-                        'This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly.  All autodrafts will show up in the "draft" view of your event list table.  You can delete them from there. Please click the "Add %1$s" button to refresh and restart.',
852
-                        'event_espresso'
853
-                    ),
854
-                    $label
855
-                ),
856
-                __FILE__,
857
-                __FUNCTION__,
858
-                __LINE__
859
-            );
860
-        }
861
-    }
862
-
863
-
864
-    /**
865
-     * admin_footer_scripts_global
866
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
867
-     * will apply on ALL EE_Admin pages.
868
-     *
869
-     * @return void
870
-     */
871
-    public function admin_footer_scripts_global()
872
-    {
873
-        $this->_add_admin_page_ajax_loading_img();
874
-        $this->_add_admin_page_overlay();
875
-    }
876
-
877
-
878
-    /**
879
-     * add in any global scripts for cpt routes
880
-     *
881
-     * @return void
882
-     */
883
-    public function load_global_scripts_styles()
884
-    {
885
-        parent::load_global_scripts_styles();
886
-        if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
887
-            // setup custom post status object for localize script but only if we've got a cpt object
888
-            $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
889
-            if (! empty($statuses)) {
890
-                // get ALL statuses!
891
-                $statuses = $this->_cpt_model_obj->get_all_post_statuses();
892
-                // setup object
893
-                $ee_cpt_statuses = [];
894
-                foreach ($statuses as $status => $label) {
895
-                    $ee_cpt_statuses[ $status ] = [
896
-                        'label'      => $label,
897
-                        'save_label' => sprintf(
898
-                            wp_strip_all_tags(__('Save as %s', 'event_espresso')),
899
-                            $label
900
-                        ),
901
-                    ];
902
-                }
903
-                wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
904
-            }
905
-        }
906
-    }
907
-
908
-
909
-    /**
910
-     * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
911
-     * insert/updates
912
-     *
913
-     * @param int     $post_id ID of post being updated
914
-     * @param WP_Post $post    Post object from WP
915
-     * @param bool    $update  Whether this is an update or a new save.
916
-     * @return void
917
-     * @throws EE_Error
918
-     * @throws ReflectionException
919
-     */
920
-    public function insert_update(int $post_id, WP_Post $post, bool $update)
921
-    {
922
-        // make sure that if this is a revision OR trash action that we don't do any updates!
923
-        $action = $this->request->getRequestParam('action');
924
-        if ($action === 'restore' || $action === 'trash') {
925
-            return;
926
-        }
927
-        $this->_set_model_object($post_id, true, 'insert_update');
928
-        // if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
929
-        if (
930
-            $update
931
-            && (
932
-                ! $this->_cpt_model_obj instanceof EE_CPT_Base
933
-                || $this->_cpt_model_obj->ID() !== $post_id
934
-            )
935
-        ) {
936
-            return;
937
-        }
938
-        // check for autosave and update our req_data property accordingly.
939
-        /*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
489
+	}
490
+
491
+
492
+	/**
493
+	 * if this post is a draft or scheduled post then we provide a preview button for user to click
494
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
495
+	 *
496
+	 * @param string $return    the current html
497
+	 * @param int    $id        the post id for the page
498
+	 * @return string            The new html string for the permalink area
499
+	 * @deprecated 5.0.0.p
500
+	 * @see PreviewButton::addButton()
501
+	 */
502
+	public function preview_button_html(string $return, int $id): string
503
+	{
504
+		return PreviewButton::addButton($return, $id);
505
+	}
506
+
507
+
508
+	/**
509
+	 * add our custom post status dropdown on the wp post page for this cpt
510
+	 *
511
+	 * @return void
512
+	 */
513
+	public function custom_post_stati_dropdown()
514
+	{
515
+		$statuses         = $this->_cpt_model_obj->get_custom_post_statuses();
516
+		$cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
517
+			? $statuses[ $this->_cpt_model_obj->status() ]
518
+			: '';
519
+		$template_args    = [
520
+			'cur_status'            => $this->_cpt_model_obj->status(),
521
+			'statuses'              => $statuses,
522
+			'cur_status_label'      => $cur_status_label,
523
+			'localized_status_save' => sprintf(esc_html__('Save %s', 'event_espresso'), $cur_status_label),
524
+		];
525
+		// we'll add a trash post status (WP doesn't add one for some reason)
526
+		if ($this->_cpt_model_obj->status() === 'trash') {
527
+			$template_args['cur_status_label'] = esc_html__('Trashed', 'event_espresso');
528
+			$statuses['trash']                 = esc_html__('Trashed', 'event_espresso');
529
+			$template_args['statuses']         = $statuses;
530
+		}
531
+
532
+		$template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
533
+		EEH_Template::display_template($template, $template_args);
534
+	}
535
+
536
+
537
+	public function setup_autosave_hooks()
538
+	{
539
+		$this->_set_autosave_containers();
540
+		$this->_load_autosave_scripts_styles();
541
+	}
542
+
543
+
544
+	/**
545
+	 * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a post object (available
546
+	 * in request data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
547
+	 * for the nonce in here, but then this method looks for two things:
548
+	 * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
549
+	 * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
550
+	 * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
551
+	 * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
552
+	 * template args.
553
+	 *    1. $template_args['error'] = IF there is an error you can add the message in here.
554
+	 *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
555
+	 *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
556
+	 *    $this->_template_args['data']['items'] = array(
557
+	 *        'event-datetime-ids' => '1,2,3';
558
+	 *    );
559
+	 *    Keep in mind the following things:
560
+	 *    - "where" index is for the input with the id as that string.
561
+	 *    - "what" index is what will be used for the value of that input.
562
+	 *
563
+	 * @return void
564
+	 * @throws EE_Error
565
+	 */
566
+	public function do_extra_autosave_stuff()
567
+	{
568
+		// next let's check for the autosave nonce (we'll use _verify_nonce )
569
+		$nonce = $this->request->getRequestParam('autosavenonce');
570
+		$this->_verify_nonce($nonce, 'autosave');
571
+		// make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
572
+		if (! defined('DOING_AUTOSAVE')) {
573
+			define('DOING_AUTOSAVE', true);
574
+		}
575
+		// if we made it here then the nonce checked out.  Let's run our methods and actions
576
+		$autosave = "_ee_autosave_$this->_current_view";
577
+		if (method_exists($this, $autosave)) {
578
+			$this->$autosave();
579
+		} else {
580
+			$this->_template_args['success'] = true;
581
+		}
582
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
583
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
584
+		// now let's return json
585
+		$this->_return_json();
586
+	}
587
+
588
+
589
+	/**
590
+	 * This takes care of setting up default routes and pages that utilize the core WP admin pages.
591
+	 * Child classes can override the defaults (in cases for adding metaboxes etc.)
592
+	 * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
593
+	 *
594
+	 * @return void
595
+	 * @throws EE_Error
596
+	 * @throws ReflectionException
597
+	 */
598
+	protected function _extend_page_config_for_cpt()
599
+	{
600
+		// before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
601
+		if ($this->raw_req_page !== $this->page_slug) {
602
+			return;
603
+		}
604
+		// set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
605
+		if (! empty($this->_cpt_object)) {
606
+			$this->_page_routes = array_merge(
607
+				[
608
+					'create_new' => [$this, '_create_new_cpt_item'],
609
+					'edit'       => [$this, '_edit_cpt_item'],
610
+				],
611
+				$this->_page_routes
612
+			);
613
+			$this->_page_config = array_merge(
614
+				[
615
+					'create_new' => [
616
+						'nav'           => [
617
+							'label' => $this->_cpt_object->labels->add_new_item,
618
+							'order' => 5,
619
+						],
620
+						'require_nonce' => false,
621
+					],
622
+					'edit'       => [
623
+						'nav'           => [
624
+							'label'      => $this->_cpt_object->labels->edit_item,
625
+							'order'      => 5,
626
+							'persistent' => false,
627
+							'url'        => '',
628
+						],
629
+						'require_nonce' => false,
630
+					],
631
+				],
632
+				$this->_page_config
633
+			);
634
+		}
635
+		// load the next section only if this is a matching cpt route as set in the cpt routes array.
636
+		if (! isset($this->_cpt_routes[ $this->_req_action ])) {
637
+			return;
638
+		}
639
+		$this->_cpt_route = true;
640
+		// $this->_cpt_route = isset($this->_cpt_routes[ $this->_req_action ]);
641
+		// add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
642
+		if (empty($this->_cpt_object)) {
643
+			$msg = sprintf(
644
+				esc_html__(
645
+					'This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this:  1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).',
646
+					'event_espresso'
647
+				),
648
+				$this->page_slug,
649
+				$this->_req_action,
650
+				get_class($this)
651
+			);
652
+			throw new EE_Error($msg);
653
+		}
654
+		$this->_set_model_object($this->request->getRequestParam('post', 0, DataType::INT));
655
+	}
656
+
657
+
658
+	/**
659
+	 * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
660
+	 *
661
+	 * @param int    $id       The id to retrieve the model object for. If empty we set a default object.
662
+	 * @param bool   $ignore_route_check
663
+	 * @param string $req_type whether the current route is for inserting, updating, or deleting the CPT
664
+	 * @throws EE_Error
665
+	 * @throws InvalidArgumentException
666
+	 * @throws InvalidDataTypeException
667
+	 * @throws InvalidInterfaceException
668
+	 * @throws ReflectionException
669
+	 */
670
+	protected function _set_model_object(int $id = 0, bool $ignore_route_check = false, string $req_type = '')
671
+	{
672
+		$model = null;
673
+		if (
674
+			empty($this->_cpt_model_names)
675
+			|| (
676
+				! $ignore_route_check
677
+				&& ! isset($this->_cpt_routes[ $this->_req_action ])
678
+			)
679
+			|| (
680
+				$this->_cpt_model_obj instanceof EE_CPT_Base
681
+				&& $this->_cpt_model_obj->ID() === $id
682
+			)
683
+		) {
684
+			// get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent.
685
+			return;
686
+		}
687
+		// if ignore_route_check is true, then get the model name via CustomPostTypeDefinitions
688
+		if ($ignore_route_check) {
689
+			$post_type = get_post_type($id);
690
+			/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
691
+			$custom_post_types = $this->loader->getShared(
692
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
693
+			);
694
+			$model_names       = $custom_post_types->getCustomPostTypeModelNames($post_type);
695
+			if (isset($model_names[ $post_type ])) {
696
+				$model = EE_Registry::instance()->load_model($model_names[ $post_type ]);
697
+			}
698
+		} else {
699
+			$model = EE_Registry::instance()->load_model($this->_cpt_model_names[ $this->_req_action ]);
700
+		}
701
+		if ($model instanceof EEM_Base) {
702
+			$this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
703
+		}
704
+		do_action(
705
+			'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',
706
+			$this->_cpt_model_obj,
707
+			$req_type
708
+		);
709
+	}
710
+
711
+
712
+	/**
713
+	 * admin_init_global
714
+	 * This runs all the code that we want executed within the WP admin_init hook.
715
+	 * This method executes for ALL EE Admin pages.
716
+	 *
717
+	 * @return void
718
+	 */
719
+	public function admin_init_global()
720
+	{
721
+		$post_ID = $this->request->getRequestParam('post', 0, DataType::INT);
722
+		// its possible this is a new save so let's catch that instead
723
+		$post_ID        = $this->request->getRequestParam('post_ID', $post_ID, DataType::INT);
724
+		$post           = get_post($post_ID);
725
+		$post_type      = $post instanceof WP_Post ? $post->post_type : false;
726
+		$current_route  = $this->request->getRequestParam('current_route', 'shouldneverwork');
727
+		$route_to_check = $post_type && isset($this->_cpt_routes[ $current_route ])
728
+			? $this->_cpt_routes[ $current_route ]
729
+			: '';
730
+		add_filter('get_delete_post_link', [$this, 'modify_delete_post_link'], 10, 2);
731
+		add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 2);
732
+		if ($post_type === $route_to_check) {
733
+			add_filter('redirect_post_location', [$this, 'cpt_post_location_redirect'], 10, 2);
734
+		}
735
+		// now let's filter redirect if we're on a revision page and the revision is for an event CPT.
736
+		$revision = $this->request->getRequestParam('revision');
737
+		if (! empty($revision)) {
738
+			$action = $this->request->getRequestParam('action');
739
+			// doing a restore?
740
+			if (! empty($action) && $action === 'restore') {
741
+				// get post for revision
742
+				$rev_post   = get_post($revision);
743
+				$rev_parent = get_post($rev_post->post_parent);
744
+				// only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
745
+				if ($rev_parent && $rev_parent->post_type === $this->page_slug) {
746
+					add_filter('wp_redirect', [$this, 'revision_redirect']);
747
+					// restores of revisions
748
+					add_action('wp_restore_post_revision', [$this, 'restore_revision'], 10, 2);
749
+				}
750
+			}
751
+		}
752
+		// NOTE we ONLY want to run these hooks if we're on the right class for the given post type.  Otherwise we could see some really freaky things happen!
753
+		if ($post_type && $post_type === $route_to_check) {
754
+			// $post_id, $post
755
+			add_action('save_post', [$this, 'insert_update'], 10, 3);
756
+			// $post_id
757
+			add_action('trashed_post', [$this, 'before_trash_cpt_item']);
758
+			add_action('trashed_post', [$this, 'dont_permanently_delete_ee_cpts']);
759
+			add_action('untrashed_post', [$this, 'before_restore_cpt_item']);
760
+			add_action('after_delete_post', [$this, 'before_delete_cpt_item']);
761
+		}
762
+	}
763
+
764
+
765
+	/**
766
+	 * Callback for the WordPress trashed_post hook.
767
+	 * Execute some basic checks before calling the trash_cpt_item declared in the child class.
768
+	 *
769
+	 * @param int $post_id
770
+	 * @throws EE_Error
771
+	 * @throws ReflectionException
772
+	 */
773
+	public function before_trash_cpt_item(int $post_id)
774
+	{
775
+		$this->_set_model_object($post_id, true, 'trash');
776
+		// if our cpt object isn't existent then get out immediately.
777
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
778
+			return;
779
+		}
780
+		$this->trash_cpt_item($post_id);
781
+	}
782
+
783
+
784
+	/**
785
+	 * Callback for the WordPress untrashed_post hook.
786
+	 * Execute some basic checks before calling the restore_cpt_method in the child class.
787
+	 *
788
+	 * @param $post_id
789
+	 * @throws EE_Error
790
+	 * @throws ReflectionException
791
+	 */
792
+	public function before_restore_cpt_item($post_id)
793
+	{
794
+		$this->_set_model_object($post_id, true, 'restore');
795
+		// if our cpt object isn't existent then get out immediately.
796
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
797
+			return;
798
+		}
799
+		$this->restore_cpt_item($post_id);
800
+	}
801
+
802
+
803
+	/**
804
+	 * Callback for the WordPress after_delete_post hook.
805
+	 * Execute some basic checks before calling the delete_cpt_item method in the child class.
806
+	 *
807
+	 * @param $post_id
808
+	 * @throws EE_Error
809
+	 * @throws ReflectionException
810
+	 */
811
+	public function before_delete_cpt_item($post_id)
812
+	{
813
+		$this->_set_model_object($post_id, true, 'delete');
814
+		// if our cpt object isn't existent then get out immediately.
815
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
816
+			return;
817
+		}
818
+		$this->delete_cpt_item($post_id);
819
+	}
820
+
821
+
822
+	/**
823
+	 * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
824
+	 * accordingly.
825
+	 *
826
+	 * @return void
827
+	 * @throws EE_Error
828
+	 * @throws ReflectionException
829
+	 */
830
+	public function verify_cpt_object()
831
+	{
832
+		$label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
833
+		// verify event object
834
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
835
+			throw new EE_Error(
836
+				sprintf(
837
+					esc_html__(
838
+						'Something has gone wrong with the page load because we are unable to set up the object for the %1$s.  This usually happens when the given id for the page route is NOT for the correct custom post type for this page',
839
+						'event_espresso'
840
+					),
841
+					$label
842
+				)
843
+			);
844
+		}
845
+		// if auto-draft then throw an error
846
+		if ($this->_cpt_model_obj->get('status') === 'auto-draft') {
847
+			EE_Error::overwrite_errors();
848
+			EE_Error::add_error(
849
+				sprintf(
850
+					esc_html__(
851
+						'This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly.  All autodrafts will show up in the "draft" view of your event list table.  You can delete them from there. Please click the "Add %1$s" button to refresh and restart.',
852
+						'event_espresso'
853
+					),
854
+					$label
855
+				),
856
+				__FILE__,
857
+				__FUNCTION__,
858
+				__LINE__
859
+			);
860
+		}
861
+	}
862
+
863
+
864
+	/**
865
+	 * admin_footer_scripts_global
866
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
867
+	 * will apply on ALL EE_Admin pages.
868
+	 *
869
+	 * @return void
870
+	 */
871
+	public function admin_footer_scripts_global()
872
+	{
873
+		$this->_add_admin_page_ajax_loading_img();
874
+		$this->_add_admin_page_overlay();
875
+	}
876
+
877
+
878
+	/**
879
+	 * add in any global scripts for cpt routes
880
+	 *
881
+	 * @return void
882
+	 */
883
+	public function load_global_scripts_styles()
884
+	{
885
+		parent::load_global_scripts_styles();
886
+		if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
887
+			// setup custom post status object for localize script but only if we've got a cpt object
888
+			$statuses = $this->_cpt_model_obj->get_custom_post_statuses();
889
+			if (! empty($statuses)) {
890
+				// get ALL statuses!
891
+				$statuses = $this->_cpt_model_obj->get_all_post_statuses();
892
+				// setup object
893
+				$ee_cpt_statuses = [];
894
+				foreach ($statuses as $status => $label) {
895
+					$ee_cpt_statuses[ $status ] = [
896
+						'label'      => $label,
897
+						'save_label' => sprintf(
898
+							wp_strip_all_tags(__('Save as %s', 'event_espresso')),
899
+							$label
900
+						),
901
+					];
902
+				}
903
+				wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
904
+			}
905
+		}
906
+	}
907
+
908
+
909
+	/**
910
+	 * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
911
+	 * insert/updates
912
+	 *
913
+	 * @param int     $post_id ID of post being updated
914
+	 * @param WP_Post $post    Post object from WP
915
+	 * @param bool    $update  Whether this is an update or a new save.
916
+	 * @return void
917
+	 * @throws EE_Error
918
+	 * @throws ReflectionException
919
+	 */
920
+	public function insert_update(int $post_id, WP_Post $post, bool $update)
921
+	{
922
+		// make sure that if this is a revision OR trash action that we don't do any updates!
923
+		$action = $this->request->getRequestParam('action');
924
+		if ($action === 'restore' || $action === 'trash') {
925
+			return;
926
+		}
927
+		$this->_set_model_object($post_id, true, 'insert_update');
928
+		// if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
929
+		if (
930
+			$update
931
+			&& (
932
+				! $this->_cpt_model_obj instanceof EE_CPT_Base
933
+				|| $this->_cpt_model_obj->ID() !== $post_id
934
+			)
935
+		) {
936
+			return;
937
+		}
938
+		// check for autosave and update our req_data property accordingly.
939
+		/*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
940 940
             foreach( (array) $this->_req_data['ee_autosave_data'] as $id => $values ) {
941 941
 
942 942
                 foreach ( (array) $values as $key => $value ) {
@@ -946,549 +946,549 @@  discard block
 block discarded – undo
946 946
 
947 947
         }/**/ // TODO reactivate after autosave is implemented in 4.2
948 948
 
949
-        // take care of updating any selected page_template IF this cpt supports it.
950
-
951
-        $page_template = $this->request->getRequestParam('page_template');
952
-        if ($this->_supports_page_templates($post->post_type) && ! empty($page_template)) {
953
-            // wp version aware.
954
-            if (RecommendedVersions::compareWordPressVersion('4.7')) {
955
-                $page_templates = wp_get_theme()->get_page_templates();
956
-            } else {
957
-                $post->page_template = $page_template;
958
-                $page_templates      = wp_get_theme()->get_page_templates($post);
959
-            }
960
-            if ($page_template !== 'default' && ! isset($page_templates[ $page_template ])) {
961
-                EE_Error::add_error(
962
-                    esc_html__('Invalid Page Template.', 'event_espresso'),
963
-                    __FILE__,
964
-                    __FUNCTION__,
965
-                    __LINE__
966
-                );
967
-            } else {
968
-                update_post_meta($post_id, '_wp_page_template', $page_template);
969
-            }
970
-        }
971
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
972
-            return;
973
-        } //TODO we'll remove this after reimplementing autosave in 4.2
974
-        $this->_insert_update_cpt_item($post_id, $post);
975
-    }
976
-
977
-
978
-    /**
979
-     * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
980
-     * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
981
-     * so we don't have to check for our CPT.
982
-     *
983
-     * @param int $post_id ID of the post
984
-     * @return void
985
-     */
986
-    public function dont_permanently_delete_ee_cpts(int $post_id)
987
-    {
988
-        // only do this if we're actually processing one of our CPTs
989
-        // if our cpt object isn't existent then get out immediately.
990
-        if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
991
-            return;
992
-        }
993
-        delete_post_meta($post_id, '_wp_trash_meta_status');
994
-        delete_post_meta($post_id, '_wp_trash_meta_time');
995
-        // our cpts may have comments so let's take care of that too
996
-        delete_post_meta($post_id, '_wp_trash_meta_comments_status');
997
-    }
998
-
999
-
1000
-    /**
1001
-     * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
1002
-     * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
1003
-     * in them. We also have our OWN action in here so addons can hook into the restore process easily.
1004
-     *
1005
-     * @param int $post_id     ID of cpt item
1006
-     * @param int $revision_id ID of revision being restored
1007
-     * @return void
1008
-     */
1009
-    public function restore_revision(int $post_id, int $revision_id)
1010
-    {
1011
-        $this->_restore_cpt_item($post_id, $revision_id);
1012
-        // global action
1013
-        do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1014
-        // class specific action so you can limit hooking into a specific page.
1015
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1016
-    }
1017
-
1018
-
1019
-    /**
1020
-     * @param int $post_id     ID of cpt item
1021
-     * @param int $revision_id ID of revision for item
1022
-     * @return void
1023
-     * @see restore_revision() for details
1024
-     */
1025
-    abstract protected function _restore_cpt_item(int $post_id, int $revision_id);
1026
-
1027
-
1028
-    /**
1029
-     * Execution of this method is added to the end of the load_page_dependencies method in the parent
1030
-     * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
1031
-     * To fix we have to reset the current_screen using the page_slug
1032
-     * (which is identical - or should be - to our registered_post_type id.)
1033
-     * Also, since the core WP file loads the admin_header.php for WP
1034
-     * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
1035
-     * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
1036
-     *
1037
-     * @return void
1038
-     * @throws EE_Error
1039
-     * @throws ReflectionException
1040
-     */
1041
-    public function modify_current_screen()
1042
-    {
1043
-        // ONLY do this if the current page_route IS a cpt route
1044
-        if (! $this->_cpt_route) {
1045
-            return;
1046
-        }
1047
-        // routing things REALLY early b/c this is a cpt admin page
1048
-        set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1049
-        $this->_current_screen       = get_current_screen();
1050
-        $this->_current_screen->base = 'event-espresso';
1051
-        $this->_add_help_tabs(); // we make sure we add any help tabs back in!
1052
-        /*try {
949
+		// take care of updating any selected page_template IF this cpt supports it.
950
+
951
+		$page_template = $this->request->getRequestParam('page_template');
952
+		if ($this->_supports_page_templates($post->post_type) && ! empty($page_template)) {
953
+			// wp version aware.
954
+			if (RecommendedVersions::compareWordPressVersion('4.7')) {
955
+				$page_templates = wp_get_theme()->get_page_templates();
956
+			} else {
957
+				$post->page_template = $page_template;
958
+				$page_templates      = wp_get_theme()->get_page_templates($post);
959
+			}
960
+			if ($page_template !== 'default' && ! isset($page_templates[ $page_template ])) {
961
+				EE_Error::add_error(
962
+					esc_html__('Invalid Page Template.', 'event_espresso'),
963
+					__FILE__,
964
+					__FUNCTION__,
965
+					__LINE__
966
+				);
967
+			} else {
968
+				update_post_meta($post_id, '_wp_page_template', $page_template);
969
+			}
970
+		}
971
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
972
+			return;
973
+		} //TODO we'll remove this after reimplementing autosave in 4.2
974
+		$this->_insert_update_cpt_item($post_id, $post);
975
+	}
976
+
977
+
978
+	/**
979
+	 * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
980
+	 * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
981
+	 * so we don't have to check for our CPT.
982
+	 *
983
+	 * @param int $post_id ID of the post
984
+	 * @return void
985
+	 */
986
+	public function dont_permanently_delete_ee_cpts(int $post_id)
987
+	{
988
+		// only do this if we're actually processing one of our CPTs
989
+		// if our cpt object isn't existent then get out immediately.
990
+		if (! $this->_cpt_model_obj instanceof EE_CPT_Base) {
991
+			return;
992
+		}
993
+		delete_post_meta($post_id, '_wp_trash_meta_status');
994
+		delete_post_meta($post_id, '_wp_trash_meta_time');
995
+		// our cpts may have comments so let's take care of that too
996
+		delete_post_meta($post_id, '_wp_trash_meta_comments_status');
997
+	}
998
+
999
+
1000
+	/**
1001
+	 * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
1002
+	 * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
1003
+	 * in them. We also have our OWN action in here so addons can hook into the restore process easily.
1004
+	 *
1005
+	 * @param int $post_id     ID of cpt item
1006
+	 * @param int $revision_id ID of revision being restored
1007
+	 * @return void
1008
+	 */
1009
+	public function restore_revision(int $post_id, int $revision_id)
1010
+	{
1011
+		$this->_restore_cpt_item($post_id, $revision_id);
1012
+		// global action
1013
+		do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
1014
+		// class specific action so you can limit hooking into a specific page.
1015
+		do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
1016
+	}
1017
+
1018
+
1019
+	/**
1020
+	 * @param int $post_id     ID of cpt item
1021
+	 * @param int $revision_id ID of revision for item
1022
+	 * @return void
1023
+	 * @see restore_revision() for details
1024
+	 */
1025
+	abstract protected function _restore_cpt_item(int $post_id, int $revision_id);
1026
+
1027
+
1028
+	/**
1029
+	 * Execution of this method is added to the end of the load_page_dependencies method in the parent
1030
+	 * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
1031
+	 * To fix we have to reset the current_screen using the page_slug
1032
+	 * (which is identical - or should be - to our registered_post_type id.)
1033
+	 * Also, since the core WP file loads the admin_header.php for WP
1034
+	 * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
1035
+	 * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
1036
+	 *
1037
+	 * @return void
1038
+	 * @throws EE_Error
1039
+	 * @throws ReflectionException
1040
+	 */
1041
+	public function modify_current_screen()
1042
+	{
1043
+		// ONLY do this if the current page_route IS a cpt route
1044
+		if (! $this->_cpt_route) {
1045
+			return;
1046
+		}
1047
+		// routing things REALLY early b/c this is a cpt admin page
1048
+		set_current_screen($this->_cpt_routes[ $this->_req_action ]);
1049
+		$this->_current_screen       = get_current_screen();
1050
+		$this->_current_screen->base = 'event-espresso';
1051
+		$this->_add_help_tabs(); // we make sure we add any help tabs back in!
1052
+		/*try {
1053 1053
             $this->_route_admin_request();
1054 1054
         } catch ( EE_Error $e ) {
1055 1055
             $e->get_error();
1056 1056
         }/**/
1057
-    }
1058
-
1059
-
1060
-    /**
1061
-     * This allows child classes to modify the default editor title that appears when people add a new or edit an
1062
-     * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1063
-     * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1064
-     * default to be.
1065
-     *
1066
-     * @param string|null $title The new title (or existing if there is no editor_title defined)
1067
-     * @return string|null
1068
-     */
1069
-    public function add_custom_editor_default_title(?string $title): ?string
1070
-    {
1071
-        return $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ] ?? $title;
1072
-    }
1073
-
1074
-
1075
-    /**
1076
-     * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1077
-     *
1078
-     * @param string $shortlink   The already generated shortlink
1079
-     * @param int    $id          Post ID for this item
1080
-     * @return string
1081
-     * @deprecated 5.0.0.p
1082
-     * @see EventShortlinkButton::addButton()
1083
-     */
1084
-    public function add_shortlink_button_to_editor(string $shortlink, int $id): string
1085
-    {
1086
-        return EventShortlinkButton::addButton($shortlink, $id);
1087
-    }
1088
-
1089
-
1090
-    /**
1091
-     * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1092
-     * already run in modify_current_screen())
1093
-     *
1094
-     * @return void
1095
-     * @throws EE_Error
1096
-     * @throws ReflectionException
1097
-     * @throws Throwable
1098
-     */
1099
-    public function route_admin_request()
1100
-    {
1101
-        if ($this->_cpt_route) {
1102
-            return;
1103
-        }
1104
-        try {
1105
-            $this->_route_admin_request();
1106
-        } catch (EE_Error $e) {
1107
-            $e->get_error();
1108
-        }
1109
-    }
1110
-
1111
-
1112
-    /**
1113
-     * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1114
-     *
1115
-     * @return void
1116
-     */
1117
-    public function cpt_post_form_hidden_input()
1118
-    {
1119
-        // we're also going to add the route value and the current page so we can direct autosave parsing correctly
1120
-        echo '
1057
+	}
1058
+
1059
+
1060
+	/**
1061
+	 * This allows child classes to modify the default editor title that appears when people add a new or edit an
1062
+	 * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1063
+	 * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1064
+	 * default to be.
1065
+	 *
1066
+	 * @param string|null $title The new title (or existing if there is no editor_title defined)
1067
+	 * @return string|null
1068
+	 */
1069
+	public function add_custom_editor_default_title(?string $title): ?string
1070
+	{
1071
+		return $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ] ?? $title;
1072
+	}
1073
+
1074
+
1075
+	/**
1076
+	 * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1077
+	 *
1078
+	 * @param string $shortlink   The already generated shortlink
1079
+	 * @param int    $id          Post ID for this item
1080
+	 * @return string
1081
+	 * @deprecated 5.0.0.p
1082
+	 * @see EventShortlinkButton::addButton()
1083
+	 */
1084
+	public function add_shortlink_button_to_editor(string $shortlink, int $id): string
1085
+	{
1086
+		return EventShortlinkButton::addButton($shortlink, $id);
1087
+	}
1088
+
1089
+
1090
+	/**
1091
+	 * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1092
+	 * already run in modify_current_screen())
1093
+	 *
1094
+	 * @return void
1095
+	 * @throws EE_Error
1096
+	 * @throws ReflectionException
1097
+	 * @throws Throwable
1098
+	 */
1099
+	public function route_admin_request()
1100
+	{
1101
+		if ($this->_cpt_route) {
1102
+			return;
1103
+		}
1104
+		try {
1105
+			$this->_route_admin_request();
1106
+		} catch (EE_Error $e) {
1107
+			$e->get_error();
1108
+		}
1109
+	}
1110
+
1111
+
1112
+	/**
1113
+	 * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1114
+	 *
1115
+	 * @return void
1116
+	 */
1117
+	public function cpt_post_form_hidden_input()
1118
+	{
1119
+		// we're also going to add the route value and the current page so we can direct autosave parsing correctly
1120
+		echo '
1121 1121
         <input type="hidden" name="ee_cpt_item_redirect_url" value="' . esc_url_raw($this->_admin_base_url) . '"/>
1122 1122
         <div id="ee-cpt-hidden-inputs">
1123 1123
             <input type="hidden" id="current_route" name="current_route" value="' . esc_attr($this->_current_view) . '"/>
1124 1124
             <input type="hidden" id="current_page" name="current_page" value="' . esc_attr($this->page_slug) . '"/>
1125 1125
         </div>';
1126
-    }
1127
-
1128
-
1129
-    /**
1130
-     * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1131
-     *
1132
-     * @param string $location Original location url
1133
-     * @return string           new (or original) url to redirect to.
1134
-     * @throws EE_Error
1135
-     */
1136
-    public function revision_redirect(string $location): string
1137
-    {
1138
-        // get revision
1139
-        $revision = $this->request->getRequestParam('revision');
1140
-        // can't do anything without revision so let's get out if not present
1141
-        if (empty($revision)) {
1142
-            return $location;
1143
-        }
1144
-        // get rev_post_data
1145
-        $rev        = get_post($revision);
1146
-        $admin_url  = $this->_admin_base_url;
1147
-        $query_args = [
1148
-            'action'   => 'edit',
1149
-            'post'     => $rev->post_parent,
1150
-            'revision' => $revision,
1151
-            'message'  => 5,
1152
-        ];
1153
-        $this->_process_notices($query_args, true);
1154
-        return EE_Admin_Page_CPT::add_query_args_and_nonce($query_args, $admin_url);
1155
-    }
1156
-
1157
-
1158
-    /**
1159
-     * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1160
-     *
1161
-     * @param null|string $link     the original generated link
1162
-     * @param int    $id            post id
1163
-     * @return string               the link
1164
-     */
1165
-    public function modify_edit_post_link(?string $link, int $id): ?string
1166
-    {
1167
-        $post = get_post($id);
1168
-        $action = $this->request->getRequestParam('action');
1169
-        if (
1170
-            empty($action)
1171
-            || ! isset($this->_cpt_routes[ $action ])
1172
-            || $post->post_type !== $this->_cpt_routes[ $action ]
1173
-        ) {
1174
-            return $link;
1175
-        }
1176
-        $query_args = [
1177
-            'action' => $this->_cpt_edit_routes[ $post->post_type ] ?? 'edit',
1178
-            'post'   => $id,
1179
-        ];
1180
-        return EE_Admin_Page_CPT::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1181
-    }
1182
-
1183
-
1184
-    /**
1185
-     * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1186
-     * our routes.
1187
-     *
1188
-     * @param null|string $delete_link      original delete link
1189
-     * @param int    $post_id               id of cpt object
1190
-     * @return null|string                  new delete link
1191
-     * @throws EE_Error
1192
-     * @throws ReflectionException
1193
-     */
1194
-    public function modify_delete_post_link(?string $delete_link, int $post_id): ?string
1195
-    {
1196
-        $post = get_post($post_id);
1197
-        $action = $this->request->getRequestParam('action');
1198
-        if (
1199
-            ! $post instanceof WP_Post
1200
-            || empty($action)
1201
-            || ! isset($this->_cpt_routes[ $action ])
1202
-            || $post->post_type !== $this->_cpt_routes[ $action ]
1203
-        ) {
1204
-            return $delete_link;
1205
-        }
1206
-        $this->_set_model_object($post->ID, true);
1207
-
1208
-        // returns something like `trash_event` or `trash_attendee` or `trash_venue`
1209
-        $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1210
-
1211
-        return EE_Admin_Page::add_query_args_and_nonce(
1212
-            [
1213
-                'page'   => $this->request->getRequestParam('page'),
1214
-                'action' => $action,
1215
-                $this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name() => $post->ID,
1216
-            ],
1217
-            admin_url()
1218
-        );
1219
-    }
1220
-
1221
-
1222
-    /**
1223
-     * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1224
-     * so that we can hijack the default redirect locations for wp custom post types
1225
-     * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1226
-     *
1227
-     * @param string $location This is the incoming currently set redirect location
1228
-     * @param string $post_id  This is the 'ID' value of the wp_posts table
1229
-     * @return string           the new location to redirect to
1230
-     * @throws EE_Error
1231
-     */
1232
-    public function cpt_post_location_redirect(string $location, string $post_id): string
1233
-    {
1234
-        // we DO have a match so let's setup the url
1235
-        // we have to get the post to determine our route
1236
-        $post       = get_post($post_id);
1237
-        $edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1238
-        // shared query_args
1239
-        $query_args = ['action' => $edit_route, 'post' => $post_id];
1240
-
1241
-        $save = $this->request->getRequestParam('save');
1242
-        $publish = $this->request->getRequestParam('publish');
1243
-        $add_meta = $this->request->getRequestParam('addmeta');
1244
-        $delete_meta = $this->request->getRequestParam('deletemeta');
1245
-        if ($save || $publish) {
1246
-            $status = get_post_status($post_id);
1247
-            if ($publish) {
1248
-                switch ($status) {
1249
-                    case 'pending':
1250
-                        $message = 8;
1251
-                        break;
1252
-                    case 'future':
1253
-                        $message = 9;
1254
-                        break;
1255
-                    default:
1256
-                        $message = 6;
1257
-                }
1258
-            } else {
1259
-                $message = 'draft' === $status ? 10 : 1;
1260
-            }
1261
-        } elseif ($add_meta) {
1262
-            $message = 2;
1263
-        } elseif ($delete_meta) {
1264
-            $message = 3;
1265
-        } elseif ($this->request->getRequestParam('action') === 'post-quickpress-save-cont') {
1266
-            $message = 7;
1267
-        } else {
1268
-            $message = 4;
1269
-        }
1270
-        // change the message if the post type is not viewable on the frontend
1271
-        $this->_cpt_object = get_post_type_object($post->post_type);
1272
-
1273
-        $query_args['message'] = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1274
-        $this->_process_notices($query_args, true);
1275
-        return EE_Admin_Page_CPT::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1276
-    }
1277
-
1278
-
1279
-    /**
1280
-     * This method is called to inject nav tabs on core WP cpt pages
1281
-     *
1282
-     * @return void
1283
-     * @throws EE_Error
1284
-     */
1285
-    public function inject_nav_tabs()
1286
-    {
1287
-        echo wp_kses($this->_get_main_nav_tabs(), AllowedTags::getWithFormTags());
1288
-    }
1289
-
1290
-
1291
-    /**
1292
-     * This just sets up the post update messages when an update form is loaded
1293
-     *
1294
-     * @param array $messages the original messages array
1295
-     * @return array           the new messages array
1296
-     */
1297
-    public function post_update_messages(array $messages): array
1298
-    {
1299
-        global $post;
1300
-        $id       = $this->request->getRequestParam('post');
1301
-        $id       = empty($id) && is_object($post) ? $post->ID : null;
1302
-        $revision = $this->request->getRequestParam('revision', 0, 'int');
1303
-
1304
-        $messages[ $post->post_type ] = [
1305
-            0  => '', // Unused. Messages start at index 1.
1306
-            1  => sprintf(
1307
-                esc_html__('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1308
-                $this->_cpt_object->labels->singular_name,
1309
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1310
-                '</a>'
1311
-            ),
1312
-            2  => esc_html__('Custom field updated', 'event_espresso'),
1313
-            3  => esc_html__('Custom field deleted.', 'event_espresso'),
1314
-            4  => sprintf(esc_html__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1315
-            5  => $revision
1316
-                ? sprintf(
1317
-                    esc_html__('%s restored to revision from %s', 'event_espresso'),
1318
-                    $this->_cpt_object->labels->singular_name,
1319
-                    wp_post_revision_title($revision, false)
1320
-                )
1321
-                : false,
1322
-            6  => sprintf(
1323
-                esc_html__('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1324
-                $this->_cpt_object->labels->singular_name,
1325
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1326
-                '</a>'
1327
-            ),
1328
-            7  => sprintf(esc_html__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1329
-            8  => sprintf(
1330
-                esc_html__('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1331
-                $this->_cpt_object->labels->singular_name,
1332
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1333
-                '</a>'
1334
-            ),
1335
-            9  => sprintf(
1336
-                esc_html__('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1337
-                $this->_cpt_object->labels->singular_name,
1338
-                '<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1339
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1340
-                '</a>'
1341
-            ),
1342
-            10 => sprintf(
1343
-                esc_html__('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1344
-                $this->_cpt_object->labels->singular_name,
1345
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1346
-                '</a>'
1347
-            ),
1348
-        ];
1349
-        return $messages;
1350
-    }
1351
-
1352
-
1353
-    /**
1354
-     * default method for the 'create_new' route for cpt admin pages.
1355
-     * For reference what to include in here, see wp-admin/post-new.php
1356
-     *
1357
-     * @return void
1358
-     */
1359
-    protected function _create_new_cpt_item()
1360
-    {
1361
-        // gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1362
-        global $post, $title, $post_type, $post_type_object;
1363
-        $post_type        = $this->_cpt_routes[ $this->_req_action ];
1364
-        $post_type_object = $this->_cpt_object;
1365
-        $title            = $post_type_object->labels->add_new_item;
1366
-        $post             = $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1367
-        add_action('admin_print_styles', [$this, 'add_new_admin_page_global']);
1368
-        // modify the default editor title field with default title.
1369
-        add_filter('enter_title_here', [$this, 'add_custom_editor_default_title']);
1370
-        $this->loadEditorTemplate();
1371
-    }
1372
-
1373
-
1374
-    /**
1375
-     * Enqueues auto-save and loads the editor template
1376
-     *
1377
-     * @param bool $creating
1378
-     */
1379
-    private function loadEditorTemplate(bool $creating = true)
1380
-    {
1381
-        if ($this->admin_config && ! $this->admin_config->useAdvancedEditor()) {
1382
-            add_filter('admin_body_class', function($classes)
1383
-            {
1384
-                $classes .= ' espresso-legacy-editor';
1385
-                return $classes;
1386
-            });
1387
-        }
1388
-
1389
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1390
-        // these vars are used by the template
1391
-        $editing = true;
1392
-        $post_ID = $post->ID;
1393
-        if (apply_filters('FHEE__EE_Admin_Page_CPT___create_new_cpt_item__replace_editor', false, $post) === false) {
1394
-            // only enqueue autosave when creating event (necessary to get permalink/url generated)
1395
-            // otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1396
-            $action = $this->request->getRequestParam('action');
1397
-            if ($creating) {
1398
-                wp_enqueue_script('autosave');
1399
-            } elseif (
1400
-                isset($this->_cpt_routes[ $action ])
1401
-                && ! isset($this->_labels['hide_add_button_on_cpt_route'][ $action ])
1402
-            ) {
1403
-                $create_new_action = apply_filters(
1404
-                    'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1405
-                    'create_new',
1406
-                    $this
1407
-                );
1408
-                $post_new_file     = EE_Admin_Page::add_query_args_and_nonce(
1409
-                    [
1410
-                        'action' => $create_new_action,
1411
-                        'page'   => $this->page_slug,
1412
-                    ],
1413
-                    'admin.php'
1414
-                );
1415
-            }
1416
-            include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1417
-        }
1418
-    }
1419
-
1420
-
1421
-    public function add_new_admin_page_global()
1422
-    {
1423
-        $admin_page = $this->request->getRequestParam('post', 0, DataType::INT) !== 0
1424
-            ? 'post-php'
1425
-            : 'post-new-php';
1426
-        ?>
1126
+	}
1127
+
1128
+
1129
+	/**
1130
+	 * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1131
+	 *
1132
+	 * @param string $location Original location url
1133
+	 * @return string           new (or original) url to redirect to.
1134
+	 * @throws EE_Error
1135
+	 */
1136
+	public function revision_redirect(string $location): string
1137
+	{
1138
+		// get revision
1139
+		$revision = $this->request->getRequestParam('revision');
1140
+		// can't do anything without revision so let's get out if not present
1141
+		if (empty($revision)) {
1142
+			return $location;
1143
+		}
1144
+		// get rev_post_data
1145
+		$rev        = get_post($revision);
1146
+		$admin_url  = $this->_admin_base_url;
1147
+		$query_args = [
1148
+			'action'   => 'edit',
1149
+			'post'     => $rev->post_parent,
1150
+			'revision' => $revision,
1151
+			'message'  => 5,
1152
+		];
1153
+		$this->_process_notices($query_args, true);
1154
+		return EE_Admin_Page_CPT::add_query_args_and_nonce($query_args, $admin_url);
1155
+	}
1156
+
1157
+
1158
+	/**
1159
+	 * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1160
+	 *
1161
+	 * @param null|string $link     the original generated link
1162
+	 * @param int    $id            post id
1163
+	 * @return string               the link
1164
+	 */
1165
+	public function modify_edit_post_link(?string $link, int $id): ?string
1166
+	{
1167
+		$post = get_post($id);
1168
+		$action = $this->request->getRequestParam('action');
1169
+		if (
1170
+			empty($action)
1171
+			|| ! isset($this->_cpt_routes[ $action ])
1172
+			|| $post->post_type !== $this->_cpt_routes[ $action ]
1173
+		) {
1174
+			return $link;
1175
+		}
1176
+		$query_args = [
1177
+			'action' => $this->_cpt_edit_routes[ $post->post_type ] ?? 'edit',
1178
+			'post'   => $id,
1179
+		];
1180
+		return EE_Admin_Page_CPT::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1181
+	}
1182
+
1183
+
1184
+	/**
1185
+	 * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1186
+	 * our routes.
1187
+	 *
1188
+	 * @param null|string $delete_link      original delete link
1189
+	 * @param int    $post_id               id of cpt object
1190
+	 * @return null|string                  new delete link
1191
+	 * @throws EE_Error
1192
+	 * @throws ReflectionException
1193
+	 */
1194
+	public function modify_delete_post_link(?string $delete_link, int $post_id): ?string
1195
+	{
1196
+		$post = get_post($post_id);
1197
+		$action = $this->request->getRequestParam('action');
1198
+		if (
1199
+			! $post instanceof WP_Post
1200
+			|| empty($action)
1201
+			|| ! isset($this->_cpt_routes[ $action ])
1202
+			|| $post->post_type !== $this->_cpt_routes[ $action ]
1203
+		) {
1204
+			return $delete_link;
1205
+		}
1206
+		$this->_set_model_object($post->ID, true);
1207
+
1208
+		// returns something like `trash_event` or `trash_attendee` or `trash_venue`
1209
+		$action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj)));
1210
+
1211
+		return EE_Admin_Page::add_query_args_and_nonce(
1212
+			[
1213
+				'page'   => $this->request->getRequestParam('page'),
1214
+				'action' => $action,
1215
+				$this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name() => $post->ID,
1216
+			],
1217
+			admin_url()
1218
+		);
1219
+	}
1220
+
1221
+
1222
+	/**
1223
+	 * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1224
+	 * so that we can hijack the default redirect locations for wp custom post types
1225
+	 * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1226
+	 *
1227
+	 * @param string $location This is the incoming currently set redirect location
1228
+	 * @param string $post_id  This is the 'ID' value of the wp_posts table
1229
+	 * @return string           the new location to redirect to
1230
+	 * @throws EE_Error
1231
+	 */
1232
+	public function cpt_post_location_redirect(string $location, string $post_id): string
1233
+	{
1234
+		// we DO have a match so let's setup the url
1235
+		// we have to get the post to determine our route
1236
+		$post       = get_post($post_id);
1237
+		$edit_route = $this->_cpt_edit_routes[ $post->post_type ];
1238
+		// shared query_args
1239
+		$query_args = ['action' => $edit_route, 'post' => $post_id];
1240
+
1241
+		$save = $this->request->getRequestParam('save');
1242
+		$publish = $this->request->getRequestParam('publish');
1243
+		$add_meta = $this->request->getRequestParam('addmeta');
1244
+		$delete_meta = $this->request->getRequestParam('deletemeta');
1245
+		if ($save || $publish) {
1246
+			$status = get_post_status($post_id);
1247
+			if ($publish) {
1248
+				switch ($status) {
1249
+					case 'pending':
1250
+						$message = 8;
1251
+						break;
1252
+					case 'future':
1253
+						$message = 9;
1254
+						break;
1255
+					default:
1256
+						$message = 6;
1257
+				}
1258
+			} else {
1259
+				$message = 'draft' === $status ? 10 : 1;
1260
+			}
1261
+		} elseif ($add_meta) {
1262
+			$message = 2;
1263
+		} elseif ($delete_meta) {
1264
+			$message = 3;
1265
+		} elseif ($this->request->getRequestParam('action') === 'post-quickpress-save-cont') {
1266
+			$message = 7;
1267
+		} else {
1268
+			$message = 4;
1269
+		}
1270
+		// change the message if the post type is not viewable on the frontend
1271
+		$this->_cpt_object = get_post_type_object($post->post_type);
1272
+
1273
+		$query_args['message'] = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1274
+		$this->_process_notices($query_args, true);
1275
+		return EE_Admin_Page_CPT::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1276
+	}
1277
+
1278
+
1279
+	/**
1280
+	 * This method is called to inject nav tabs on core WP cpt pages
1281
+	 *
1282
+	 * @return void
1283
+	 * @throws EE_Error
1284
+	 */
1285
+	public function inject_nav_tabs()
1286
+	{
1287
+		echo wp_kses($this->_get_main_nav_tabs(), AllowedTags::getWithFormTags());
1288
+	}
1289
+
1290
+
1291
+	/**
1292
+	 * This just sets up the post update messages when an update form is loaded
1293
+	 *
1294
+	 * @param array $messages the original messages array
1295
+	 * @return array           the new messages array
1296
+	 */
1297
+	public function post_update_messages(array $messages): array
1298
+	{
1299
+		global $post;
1300
+		$id       = $this->request->getRequestParam('post');
1301
+		$id       = empty($id) && is_object($post) ? $post->ID : null;
1302
+		$revision = $this->request->getRequestParam('revision', 0, 'int');
1303
+
1304
+		$messages[ $post->post_type ] = [
1305
+			0  => '', // Unused. Messages start at index 1.
1306
+			1  => sprintf(
1307
+				esc_html__('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1308
+				$this->_cpt_object->labels->singular_name,
1309
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1310
+				'</a>'
1311
+			),
1312
+			2  => esc_html__('Custom field updated', 'event_espresso'),
1313
+			3  => esc_html__('Custom field deleted.', 'event_espresso'),
1314
+			4  => sprintf(esc_html__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1315
+			5  => $revision
1316
+				? sprintf(
1317
+					esc_html__('%s restored to revision from %s', 'event_espresso'),
1318
+					$this->_cpt_object->labels->singular_name,
1319
+					wp_post_revision_title($revision, false)
1320
+				)
1321
+				: false,
1322
+			6  => sprintf(
1323
+				esc_html__('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1324
+				$this->_cpt_object->labels->singular_name,
1325
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1326
+				'</a>'
1327
+			),
1328
+			7  => sprintf(esc_html__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1329
+			8  => sprintf(
1330
+				esc_html__('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1331
+				$this->_cpt_object->labels->singular_name,
1332
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1333
+				'</a>'
1334
+			),
1335
+			9  => sprintf(
1336
+				esc_html__('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1337
+				$this->_cpt_object->labels->singular_name,
1338
+				'<strong>' . date_i18n('M j, Y @ G:i', strtotime($post->post_date)) . '</strong>',
1339
+				'<a target="_blank" href="' . esc_url(get_permalink($id)),
1340
+				'</a>'
1341
+			),
1342
+			10 => sprintf(
1343
+				esc_html__('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1344
+				$this->_cpt_object->labels->singular_name,
1345
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1346
+				'</a>'
1347
+			),
1348
+		];
1349
+		return $messages;
1350
+	}
1351
+
1352
+
1353
+	/**
1354
+	 * default method for the 'create_new' route for cpt admin pages.
1355
+	 * For reference what to include in here, see wp-admin/post-new.php
1356
+	 *
1357
+	 * @return void
1358
+	 */
1359
+	protected function _create_new_cpt_item()
1360
+	{
1361
+		// gather template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1362
+		global $post, $title, $post_type, $post_type_object;
1363
+		$post_type        = $this->_cpt_routes[ $this->_req_action ];
1364
+		$post_type_object = $this->_cpt_object;
1365
+		$title            = $post_type_object->labels->add_new_item;
1366
+		$post             = $post = get_default_post_to_edit($this->_cpt_routes[ $this->_req_action ], true);
1367
+		add_action('admin_print_styles', [$this, 'add_new_admin_page_global']);
1368
+		// modify the default editor title field with default title.
1369
+		add_filter('enter_title_here', [$this, 'add_custom_editor_default_title']);
1370
+		$this->loadEditorTemplate();
1371
+	}
1372
+
1373
+
1374
+	/**
1375
+	 * Enqueues auto-save and loads the editor template
1376
+	 *
1377
+	 * @param bool $creating
1378
+	 */
1379
+	private function loadEditorTemplate(bool $creating = true)
1380
+	{
1381
+		if ($this->admin_config && ! $this->admin_config->useAdvancedEditor()) {
1382
+			add_filter('admin_body_class', function($classes)
1383
+			{
1384
+				$classes .= ' espresso-legacy-editor';
1385
+				return $classes;
1386
+			});
1387
+		}
1388
+
1389
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1390
+		// these vars are used by the template
1391
+		$editing = true;
1392
+		$post_ID = $post->ID;
1393
+		if (apply_filters('FHEE__EE_Admin_Page_CPT___create_new_cpt_item__replace_editor', false, $post) === false) {
1394
+			// only enqueue autosave when creating event (necessary to get permalink/url generated)
1395
+			// otherwise EE doesn't support autosave fully, so to prevent user confusion we disable it in edit context.
1396
+			$action = $this->request->getRequestParam('action');
1397
+			if ($creating) {
1398
+				wp_enqueue_script('autosave');
1399
+			} elseif (
1400
+				isset($this->_cpt_routes[ $action ])
1401
+				&& ! isset($this->_labels['hide_add_button_on_cpt_route'][ $action ])
1402
+			) {
1403
+				$create_new_action = apply_filters(
1404
+					'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1405
+					'create_new',
1406
+					$this
1407
+				);
1408
+				$post_new_file     = EE_Admin_Page::add_query_args_and_nonce(
1409
+					[
1410
+						'action' => $create_new_action,
1411
+						'page'   => $this->page_slug,
1412
+					],
1413
+					'admin.php'
1414
+				);
1415
+			}
1416
+			include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1417
+		}
1418
+	}
1419
+
1420
+
1421
+	public function add_new_admin_page_global()
1422
+	{
1423
+		$admin_page = $this->request->getRequestParam('post', 0, DataType::INT) !== 0
1424
+			? 'post-php'
1425
+			: 'post-new-php';
1426
+		?>
1427 1427
         <script type="text/javascript">
1428 1428
             adminpage = '<?php echo esc_js($admin_page); ?>';
1429 1429
         </script>
1430 1430
         <?php
1431
-    }
1432
-
1433
-
1434
-    /**
1435
-     * default method for the 'edit' route for cpt admin pages
1436
-     * For reference on what to put in here, refer to wp-admin/post.php
1437
-     *
1438
-     * @return void
1439
-     */
1440
-    protected function _edit_cpt_item()
1441
-    {
1442
-        global $post, $post_type, $post_type_object, $title;
1443
-        $post_id = $this->request->getRequestParam('post', 0, DataType::INT);
1444
-        $post    = $post_id ? get_post($post_id, OBJECT, 'edit') : null;
1445
-        if (empty($post)) {
1446
-            wp_die(
1447
-                esc_html__(
1448
-                    "You attempted to edit an item that doesn't exist. Perhaps it was deleted?",
1449
-                    'event_espresso'
1450
-                )
1451
-            );
1452
-        }
1453
-
1454
-        $post_lock = $this->request->getRequestParam('get-post-lock');
1455
-        if ($post_lock) {
1456
-            wp_set_post_lock($post_id);
1457
-            EEH_URL::safeRedirectAndExit(get_edit_post_link($post_id, 'url'));
1458
-        }
1459
-
1460
-        // template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1461
-        $post_type        = $this->_cpt_routes[ $this->_req_action ];
1462
-        $post_type_object = $this->_cpt_object;
1463
-        $title = $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1464
-                 ?? $post_type_object->labels->edit_item;
1465
-
1466
-        if (! wp_check_post_lock($post->ID)) {
1467
-            wp_set_post_lock($post->ID);
1468
-        }
1469
-        add_action('admin_footer', '_admin_notice_post_locked');
1470
-        if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1471
-            wp_enqueue_script('admin-comments');
1472
-            enqueue_comment_hotkeys_js();
1473
-        }
1474
-        add_action('admin_print_styles', [$this, 'add_new_admin_page_global']);
1475
-        // modify the default editor title field with default title.
1476
-        add_filter('enter_title_here', [$this, 'add_custom_editor_default_title']);
1477
-        $this->loadEditorTemplate(false);
1478
-    }
1479
-
1480
-
1481
-
1482
-    /**
1483
-     * some getters
1484
-     */
1485
-    /**
1486
-     * This returns the protected _cpt_model_obj property
1487
-     *
1488
-     * @return EE_CPT_Base|null
1489
-     */
1490
-    public function get_cpt_model_obj(): ?EE_CPT_Base
1491
-    {
1492
-        return $this->_cpt_model_obj;
1493
-    }
1431
+	}
1432
+
1433
+
1434
+	/**
1435
+	 * default method for the 'edit' route for cpt admin pages
1436
+	 * For reference on what to put in here, refer to wp-admin/post.php
1437
+	 *
1438
+	 * @return void
1439
+	 */
1440
+	protected function _edit_cpt_item()
1441
+	{
1442
+		global $post, $post_type, $post_type_object, $title;
1443
+		$post_id = $this->request->getRequestParam('post', 0, DataType::INT);
1444
+		$post    = $post_id ? get_post($post_id, OBJECT, 'edit') : null;
1445
+		if (empty($post)) {
1446
+			wp_die(
1447
+				esc_html__(
1448
+					"You attempted to edit an item that doesn't exist. Perhaps it was deleted?",
1449
+					'event_espresso'
1450
+				)
1451
+			);
1452
+		}
1453
+
1454
+		$post_lock = $this->request->getRequestParam('get-post-lock');
1455
+		if ($post_lock) {
1456
+			wp_set_post_lock($post_id);
1457
+			EEH_URL::safeRedirectAndExit(get_edit_post_link($post_id, 'url'));
1458
+		}
1459
+
1460
+		// template vars for WP_ADMIN_PATH . 'edit-form-advanced.php'
1461
+		$post_type        = $this->_cpt_routes[ $this->_req_action ];
1462
+		$post_type_object = $this->_cpt_object;
1463
+		$title = $this->_labels['editor_title'][ $this->_cpt_routes[ $this->_req_action ] ]
1464
+				 ?? $post_type_object->labels->edit_item;
1465
+
1466
+		if (! wp_check_post_lock($post->ID)) {
1467
+			wp_set_post_lock($post->ID);
1468
+		}
1469
+		add_action('admin_footer', '_admin_notice_post_locked');
1470
+		if (post_type_supports($this->_cpt_routes[ $this->_req_action ], 'comments')) {
1471
+			wp_enqueue_script('admin-comments');
1472
+			enqueue_comment_hotkeys_js();
1473
+		}
1474
+		add_action('admin_print_styles', [$this, 'add_new_admin_page_global']);
1475
+		// modify the default editor title field with default title.
1476
+		add_filter('enter_title_here', [$this, 'add_custom_editor_default_title']);
1477
+		$this->loadEditorTemplate(false);
1478
+	}
1479
+
1480
+
1481
+
1482
+	/**
1483
+	 * some getters
1484
+	 */
1485
+	/**
1486
+	 * This returns the protected _cpt_model_obj property
1487
+	 *
1488
+	 * @return EE_CPT_Base|null
1489
+	 */
1490
+	public function get_cpt_model_obj(): ?EE_CPT_Base
1491
+	{
1492
+		return $this->_cpt_model_obj;
1493
+	}
1494 1494
 }
Please login to merge, or discard this patch.