Completed
Branch BUG/11294/expired-cart-ticket-... (34806b)
by
unknown
28:42 queued 14:59
created
core/domain/services/admin/PluginUpsells.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -83,12 +83,12 @@
 block discarded – undo
83 83
                     <div class="notice inline notice-alt">
84 84
                         <div class="ee-upsell-container">
85 85
                             <div class="ee-upsell-inner-container">
86
-                                <a href="' . $button_url . '">
87
-                                    ' . $button_text . '
86
+                                <a href="' . $button_url.'">
87
+                                    ' . $button_text.'
88 88
                                 </a>
89 89
                             </div>
90 90
                             <div class="ee-upsell-inner-container">
91
-                                <p>' . $upsell_text . '</p>
91
+                                <p>' . $upsell_text.'</p>
92 92
                             </div>
93 93
                             <div style="clear:both"></div>
94 94
                         </div>
Please login to merge, or discard this patch.
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -16,46 +16,46 @@  discard block
 block discarded – undo
16 16
 class PluginUpsells
17 17
 {
18 18
 
19
-    /**
20
-     * @var DomainInterface
21
-     */
22
-    private $domain;
19
+	/**
20
+	 * @var DomainInterface
21
+	 */
22
+	private $domain;
23 23
 
24 24
 
25
-    /**
26
-     * PluginUpsells constructor.
27
-     *
28
-     * @param DomainInterface $domain
29
-     */
30
-    public function __construct(DomainInterface $domain)
31
-    {
32
-        $this->domain = $domain;
33
-    }
25
+	/**
26
+	 * PluginUpsells constructor.
27
+	 *
28
+	 * @param DomainInterface $domain
29
+	 */
30
+	public function __construct(DomainInterface $domain)
31
+	{
32
+		$this->domain = $domain;
33
+	}
34 34
 
35 35
 
36
-    /**
37
-     * Hook in various upsells for the decaf version of EE.
38
-     */
39
-    public function decafUpsells()
40
-    {
41
-        if ($this->domain instanceof CaffeinatedInterface && ! $this->domain->isCaffeinated()) {
42
-            add_action('after_plugin_row', array($this, 'doPremiumUpsell'), 10, 3);
43
-        }
44
-    }
36
+	/**
37
+	 * Hook in various upsells for the decaf version of EE.
38
+	 */
39
+	public function decafUpsells()
40
+	{
41
+		if ($this->domain instanceof CaffeinatedInterface && ! $this->domain->isCaffeinated()) {
42
+			add_action('after_plugin_row', array($this, 'doPremiumUpsell'), 10, 3);
43
+		}
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * Callback for `after_plugin_row` to add upsell info
49
-     * @param string $plugin_file
50
-     * @param array $plugin_data
51
-     * @param string $status
52
-     * @throws DomainException
53
-     */
54
-    public function doPremiumUpsell($plugin_file, $plugin_data, $status)
55
-    {
56
-        if ($plugin_file === $this->domain->pluginBasename()) {
57
-            list($button_text, $button_url, $upsell_text) = $this->getAfterPluginRowDetails();
58
-            echo '<tr class="plugin-update-tr ee-upsell-plugin-list-table active">
47
+	/**
48
+	 * Callback for `after_plugin_row` to add upsell info
49
+	 * @param string $plugin_file
50
+	 * @param array $plugin_data
51
+	 * @param string $status
52
+	 * @throws DomainException
53
+	 */
54
+	public function doPremiumUpsell($plugin_file, $plugin_data, $status)
55
+	{
56
+		if ($plugin_file === $this->domain->pluginBasename()) {
57
+			list($button_text, $button_url, $upsell_text) = $this->getAfterPluginRowDetails();
58
+			echo '<tr class="plugin-update-tr ee-upsell-plugin-list-table active">
59 59
                 <td colspan="3" class="plugin-update colspanchange">
60 60
                     <div class="notice inline notice-alt">
61 61
                         <div class="ee-upsell-container">
@@ -72,26 +72,26 @@  discard block
 block discarded – undo
72 72
                     </div>
73 73
                 </td>
74 74
               </tr>';
75
-        }
76
-    }
75
+		}
76
+	}
77 77
 
78
-    /**
79
-     * Provide the details used for the upsell container.
80
-     * @return array
81
-     */
82
-    protected function getAfterPluginRowDetails()
83
-    {
84
-        return array(
85
-            esc_html__('Upgrade for Support', 'event_espresso'),
86
-            'https://eventespresso.com/purchase/?slug=ee4-license-personal&utm_source=wp_admin_plugins_screen&utm_medium=link&utm_campaign=plugins_screen_upgrade_link" class="button button-primary',
87
-            sprintf(
88
-                esc_html__(
89
-                    'You\'re missing out on %1$sexpert support%2$s and %1$sone-click updates%2$s! Don\'t have an Event Espresso support license key? Support the project and buy one today!',
90
-                    'event_espresso'
91
-                ),
92
-                '<strong>',
93
-                '</strong>'
94
-            )
95
-        );
96
-    }
78
+	/**
79
+	 * Provide the details used for the upsell container.
80
+	 * @return array
81
+	 */
82
+	protected function getAfterPluginRowDetails()
83
+	{
84
+		return array(
85
+			esc_html__('Upgrade for Support', 'event_espresso'),
86
+			'https://eventespresso.com/purchase/?slug=ee4-license-personal&utm_source=wp_admin_plugins_screen&utm_medium=link&utm_campaign=plugins_screen_upgrade_link" class="button button-primary',
87
+			sprintf(
88
+				esc_html__(
89
+					'You\'re missing out on %1$sexpert support%2$s and %1$sone-click updates%2$s! Don\'t have an Event Espresso support license key? Support the project and buy one today!',
90
+					'event_espresso'
91
+				),
92
+				'<strong>',
93
+				'</strong>'
94
+			)
95
+		);
96
+	}
97 97
 }
Please login to merge, or discard this patch.
caffeinated/modules/recaptcha_invisible/EED_Recaptcha_Invisible.module.php 2 patches
Indentation   +322 added lines, -322 removed lines patch added patch discarded remove patch
@@ -21,326 +21,326 @@
 block discarded – undo
21 21
 class EED_Recaptcha_Invisible extends EED_Module
22 22
 {
23 23
 
24
-    /**
25
-     * @var EE_Registration_Config $config
26
-     */
27
-    private static $config;
28
-
29
-
30
-    /**
31
-     * @return EED_Module|EED_Recaptcha
32
-     */
33
-    public static function instance()
34
-    {
35
-        return parent::get_instance(__CLASS__);
36
-    }
37
-
38
-
39
-    /**
40
-     * @return void
41
-     * @throws InvalidInterfaceException
42
-     * @throws InvalidDataTypeException
43
-     * @throws InvalidArgumentException
44
-     */
45
-    public static function set_hooks()
46
-    {
47
-        EED_Recaptcha_Invisible::setProperties();
48
-        if (EED_Recaptcha_Invisible::useInvisibleRecaptcha()) {
49
-            if(EED_Recaptcha_Invisible::protectForm('ticket_selector')){
50
-                // ticket selection
51
-                add_filter(
52
-                    'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
53
-                    array('EED_Recaptcha_Invisible', 'ticketSelectorForm'),
54
-                    10, 3
55
-                );
56
-                add_action(
57
-                    'EED_Ticket_Selector__process_ticket_selections__before',
58
-                    array('EED_Recaptcha_Invisible', 'processTicketSelectorForm')
59
-                );
60
-            }
61
-            if (EED_Recaptcha_Invisible::protectForm('registration_form')) {
62
-                // checkout
63
-                add_action(
64
-                    'AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form',
65
-                    array('EED_Recaptcha_Invisible', 'spcoRegStepForm')
66
-                );
67
-                add_filter(
68
-                    'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
69
-                    array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'),
70
-                    10, 2
71
-                );
72
-            }
73
-            add_action('loop_end', array('EED_Recaptcha_Invisible', 'localizeScriptVars'));
74
-        }
75
-    }
76
-
77
-
78
-    /**
79
-     * @return void
80
-     * @throws InvalidInterfaceException
81
-     * @throws InvalidDataTypeException
82
-     * @throws InvalidArgumentException
83
-     */
84
-    public static function set_hooks_admin()
85
-    {
86
-        EED_Recaptcha_Invisible::setProperties();
87
-        if (EED_Recaptcha_Invisible::protectForm('ticket_selector')) {
88
-            add_action(
89
-                'EED_Ticket_Selector__process_ticket_selections__before',
90
-                array('EED_Recaptcha_Invisible', 'processTicketSelectorForm')
91
-            );
92
-        }
93
-        if (EED_Recaptcha_Invisible::protectForm('registration_form')) {
94
-            add_filter(
95
-                'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
96
-                array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'),
97
-                10, 2
98
-            );
99
-        }
100
-        // admin settings
101
-        add_action(
102
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
103
-            array('EED_Recaptcha_Invisible', 'adminSettings')
104
-        );
105
-        add_filter(
106
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
107
-            array('EED_Recaptcha_Invisible', 'updateAdminSettings')
108
-        );
109
-    }
110
-
111
-
112
-    /**
113
-     * @return void
114
-     * @throws InvalidInterfaceException
115
-     * @throws InvalidDataTypeException
116
-     * @throws InvalidArgumentException
117
-     */
118
-    public static function setProperties()
119
-    {
120
-
121
-        EED_Recaptcha_Invisible::$config = EE_Registry::instance()->CFG->registration;
122
-    }
123
-
124
-
125
-
126
-    /**
127
-     * @return boolean
128
-     */
129
-    public static function useInvisibleRecaptcha()
130
-    {
131
-        return EED_Recaptcha_Invisible::$config->use_captcha
132
-               && EED_Recaptcha_Invisible::$config->recaptcha_theme === 'invisible';
133
-    }
134
-
135
-
136
-    /**
137
-     * @param string $form
138
-     * @return boolean
139
-     */
140
-    public static function protectForm($form)
141
-    {
142
-        return is_array(EED_Recaptcha_Invisible::$config->recaptcha_protected_forms)
143
-            && in_array($form, EED_Recaptcha_Invisible::$config->recaptcha_protected_forms, true);
144
-    }
145
-
146
-
147
-
148
-
149
-    /**
150
-     * @return void
151
-     * @throws InvalidInterfaceException
152
-     * @throws InvalidDataTypeException
153
-     * @throws InvalidArgumentException
154
-     */
155
-    public static function localizeScriptVars()
156
-    {
157
-        wp_localize_script(
158
-            EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA,
159
-            'eeRecaptcha',
160
-            RecaptchaFactory::create()->getLocalizedVars()
161
-        );
162
-    }
163
-
164
-
165
-    /**
166
-     * @return string
167
-     */
168
-    public static function assetsUrl()
169
-    {
170
-        return plugin_dir_url(__FILE__) . 'assets' . DS;
171
-    }
172
-
173
-
174
-    /**
175
-     * @param \WP $WP
176
-     */
177
-    public function run($WP)
178
-    {
179
-    }
180
-
181
-
182
-
183
-    /**
184
-     * @param EE_Request $request
185
-     * @return bool
186
-     * @throws InvalidArgumentException
187
-     * @throws InvalidDataTypeException
188
-     * @throws InvalidInterfaceException
189
-     * @throws RuntimeException
190
-     */
191
-    public static function verifyToken(EE_Request $request)
192
-    {
193
-        return RecaptchaFactory::create()->verifyToken($request);
194
-    }
195
-
196
-
197
-    /**
198
-     * @param EE_Form_Section_Proper $reg_form
199
-     * @return void
200
-     * @throws EE_Error
201
-     * @throws InvalidArgumentException
202
-     * @throws InvalidDataTypeException
203
-     * @throws InvalidInterfaceException
204
-     * @throws DomainException
205
-     */
206
-    public static function spcoRegStepForm(EE_Form_Section_Proper $reg_form)
207
-    {
208
-        // do nothing if form isn't for a reg step or test has already been passed
209
-        if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
210
-            return;
211
-        }
212
-        $default_hidden_inputs = $reg_form->get_subsection('default_hidden_inputs');
213
-        if ($default_hidden_inputs instanceof EE_Form_Section_Proper) {
214
-            $invisible_recaptcha = RecaptchaFactory::create();
215
-            $invisible_recaptcha->addToFormSection($default_hidden_inputs);
216
-        }
217
-    }
218
-
219
-
220
-    /**
221
-     * @param EE_Form_Section_Proper $reg_form
222
-     * @return bool
223
-     * @throws InvalidDataTypeException
224
-     * @throws InvalidInterfaceException
225
-     * @throws EE_Error
226
-     * @throws InvalidArgumentException
227
-     */
228
-    public static function processSpcoRegStepForm(EE_Form_Section_Proper $reg_form)
229
-    {
230
-        return strpos($reg_form->name(), 'reg-step-form') !== false
231
-               && ! RecaptchaFactory::create()->recaptchaPassed();
232
-    }
233
-
234
-
235
-    /**
236
-     * @param array|null             $req_data
237
-     * @param EE_Form_Section_Proper $reg_form
238
-     * @return array
239
-     * @throws EE_Error
240
-     * @throws InvalidArgumentException
241
-     * @throws InvalidDataTypeException
242
-     * @throws InvalidInterfaceException
243
-     * @throws RuntimeException
244
-     */
245
-    public static function receiveSpcoRegStepForm($req_data = array(), EE_Form_Section_Proper $reg_form)
246
-    {
247
-        // do nothing if form isn't for a reg step or test has already been passed
248
-        if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
249
-            return $req_data;
250
-        }
251
-        /** @var EE_Request $request */
252
-        $request = LoaderFactory::getLoader()->getShared('EE_Request');
253
-        if (! EED_Recaptcha_Invisible::verifyToken($request)) {
254
-            if ($request->isAjax()) {
255
-                $json_response = new EE_SPCO_JSON_Response();
256
-                $json_response->echoAndExit();
257
-            }
258
-            EEH_URL::safeRedirectAndExit(
259
-                EE_Registry::instance()->CFG->core->reg_page_url()
260
-            );
261
-        }
262
-        return $req_data;
263
-    }
264
-
265
-
266
-    /**
267
-     * @param string   $html
268
-     * @param EE_Event $event
269
-     * @param bool     $iframe
270
-     * @return string
271
-     * @throws EE_Error
272
-     * @throws InvalidArgumentException
273
-     * @throws InvalidDataTypeException
274
-     * @throws InvalidInterfaceException
275
-     * @throws ReflectionException
276
-     * @throws DomainException
277
-     */
278
-    public static function ticketSelectorForm($html = '', EE_Event $event, $iframe = false)
279
-    {
280
-        $recaptcha = RecaptchaFactory::create();
281
-        // do nothing if test has  already  been passed
282
-        if ($recaptcha->recaptchaPassed()) {
283
-            return $html;
284
-        }
285
-        $html .= $recaptcha->getInputHtml(
286
-            array(
287
-                'recaptcha_id'   => $event->ID(),
288
-                'iframe'         => $iframe,
289
-                'localized_vars' => $recaptcha->getLocalizedVars(),
290
-            )
291
-        );
292
-        return $html;
293
-    }
294
-
295
-
296
-    /**
297
-     * @return void
298
-     * @throws InvalidArgumentException
299
-     * @throws InvalidInterfaceException
300
-     * @throws InvalidDataTypeException
301
-     * @throws RuntimeException
302
-     */
303
-    public static function processTicketSelectorForm()
304
-    {
305
-        // do nothing if test has  already  been passed
306
-        if (RecaptchaFactory::create()->recaptchaPassed()) {
307
-            return;
308
-        }
309
-        /** @var EE_Request $request */
310
-        $request = LoaderFactory::getLoader()->getShared('EE_Request');
311
-        if (! EED_Recaptcha_Invisible::verifyToken($request)) {
312
-            $event_id   = $request->get('tkt-slctr-event-id');
313
-            $return_url = $request->is_set("tkt-slctr-return-url-{$event_id}")
314
-                ? $request->get("tkt-slctr-return-url-{$event_id}")
315
-                : get_permalink($event_id);
316
-            EEH_URL::safeRedirectAndExit($return_url);
317
-        }
318
-    }
319
-
320
-
321
-    /**
322
-     * @throws EE_Error
323
-     * @throws InvalidArgumentException
324
-     * @throws InvalidDataTypeException
325
-     * @throws InvalidInterfaceException
326
-     */
327
-    public static function adminSettings()
328
-    {
329
-        RecaptchaFactory::getAdminModule()->adminSettings();
330
-    }
331
-
332
-
333
-    /**
334
-     * @param EE_Registration_Config $EE_Registration_Config
335
-     * @return EE_Registration_Config
336
-     * @throws EE_Error
337
-     * @throws InvalidArgumentException
338
-     * @throws InvalidDataTypeException
339
-     * @throws InvalidInterfaceException
340
-     * @throws ReflectionException
341
-     */
342
-    public static function updateAdminSettings(EE_Registration_Config $EE_Registration_Config)
343
-    {
344
-        return RecaptchaFactory::getAdminModule()->updateAdminSettings($EE_Registration_Config);
345
-    }
24
+	/**
25
+	 * @var EE_Registration_Config $config
26
+	 */
27
+	private static $config;
28
+
29
+
30
+	/**
31
+	 * @return EED_Module|EED_Recaptcha
32
+	 */
33
+	public static function instance()
34
+	{
35
+		return parent::get_instance(__CLASS__);
36
+	}
37
+
38
+
39
+	/**
40
+	 * @return void
41
+	 * @throws InvalidInterfaceException
42
+	 * @throws InvalidDataTypeException
43
+	 * @throws InvalidArgumentException
44
+	 */
45
+	public static function set_hooks()
46
+	{
47
+		EED_Recaptcha_Invisible::setProperties();
48
+		if (EED_Recaptcha_Invisible::useInvisibleRecaptcha()) {
49
+			if(EED_Recaptcha_Invisible::protectForm('ticket_selector')){
50
+				// ticket selection
51
+				add_filter(
52
+					'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
53
+					array('EED_Recaptcha_Invisible', 'ticketSelectorForm'),
54
+					10, 3
55
+				);
56
+				add_action(
57
+					'EED_Ticket_Selector__process_ticket_selections__before',
58
+					array('EED_Recaptcha_Invisible', 'processTicketSelectorForm')
59
+				);
60
+			}
61
+			if (EED_Recaptcha_Invisible::protectForm('registration_form')) {
62
+				// checkout
63
+				add_action(
64
+					'AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form',
65
+					array('EED_Recaptcha_Invisible', 'spcoRegStepForm')
66
+				);
67
+				add_filter(
68
+					'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
69
+					array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'),
70
+					10, 2
71
+				);
72
+			}
73
+			add_action('loop_end', array('EED_Recaptcha_Invisible', 'localizeScriptVars'));
74
+		}
75
+	}
76
+
77
+
78
+	/**
79
+	 * @return void
80
+	 * @throws InvalidInterfaceException
81
+	 * @throws InvalidDataTypeException
82
+	 * @throws InvalidArgumentException
83
+	 */
84
+	public static function set_hooks_admin()
85
+	{
86
+		EED_Recaptcha_Invisible::setProperties();
87
+		if (EED_Recaptcha_Invisible::protectForm('ticket_selector')) {
88
+			add_action(
89
+				'EED_Ticket_Selector__process_ticket_selections__before',
90
+				array('EED_Recaptcha_Invisible', 'processTicketSelectorForm')
91
+			);
92
+		}
93
+		if (EED_Recaptcha_Invisible::protectForm('registration_form')) {
94
+			add_filter(
95
+				'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
96
+				array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'),
97
+				10, 2
98
+			);
99
+		}
100
+		// admin settings
101
+		add_action(
102
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
103
+			array('EED_Recaptcha_Invisible', 'adminSettings')
104
+		);
105
+		add_filter(
106
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
107
+			array('EED_Recaptcha_Invisible', 'updateAdminSettings')
108
+		);
109
+	}
110
+
111
+
112
+	/**
113
+	 * @return void
114
+	 * @throws InvalidInterfaceException
115
+	 * @throws InvalidDataTypeException
116
+	 * @throws InvalidArgumentException
117
+	 */
118
+	public static function setProperties()
119
+	{
120
+
121
+		EED_Recaptcha_Invisible::$config = EE_Registry::instance()->CFG->registration;
122
+	}
123
+
124
+
125
+
126
+	/**
127
+	 * @return boolean
128
+	 */
129
+	public static function useInvisibleRecaptcha()
130
+	{
131
+		return EED_Recaptcha_Invisible::$config->use_captcha
132
+			   && EED_Recaptcha_Invisible::$config->recaptcha_theme === 'invisible';
133
+	}
134
+
135
+
136
+	/**
137
+	 * @param string $form
138
+	 * @return boolean
139
+	 */
140
+	public static function protectForm($form)
141
+	{
142
+		return is_array(EED_Recaptcha_Invisible::$config->recaptcha_protected_forms)
143
+			&& in_array($form, EED_Recaptcha_Invisible::$config->recaptcha_protected_forms, true);
144
+	}
145
+
146
+
147
+
148
+
149
+	/**
150
+	 * @return void
151
+	 * @throws InvalidInterfaceException
152
+	 * @throws InvalidDataTypeException
153
+	 * @throws InvalidArgumentException
154
+	 */
155
+	public static function localizeScriptVars()
156
+	{
157
+		wp_localize_script(
158
+			EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA,
159
+			'eeRecaptcha',
160
+			RecaptchaFactory::create()->getLocalizedVars()
161
+		);
162
+	}
163
+
164
+
165
+	/**
166
+	 * @return string
167
+	 */
168
+	public static function assetsUrl()
169
+	{
170
+		return plugin_dir_url(__FILE__) . 'assets' . DS;
171
+	}
172
+
173
+
174
+	/**
175
+	 * @param \WP $WP
176
+	 */
177
+	public function run($WP)
178
+	{
179
+	}
180
+
181
+
182
+
183
+	/**
184
+	 * @param EE_Request $request
185
+	 * @return bool
186
+	 * @throws InvalidArgumentException
187
+	 * @throws InvalidDataTypeException
188
+	 * @throws InvalidInterfaceException
189
+	 * @throws RuntimeException
190
+	 */
191
+	public static function verifyToken(EE_Request $request)
192
+	{
193
+		return RecaptchaFactory::create()->verifyToken($request);
194
+	}
195
+
196
+
197
+	/**
198
+	 * @param EE_Form_Section_Proper $reg_form
199
+	 * @return void
200
+	 * @throws EE_Error
201
+	 * @throws InvalidArgumentException
202
+	 * @throws InvalidDataTypeException
203
+	 * @throws InvalidInterfaceException
204
+	 * @throws DomainException
205
+	 */
206
+	public static function spcoRegStepForm(EE_Form_Section_Proper $reg_form)
207
+	{
208
+		// do nothing if form isn't for a reg step or test has already been passed
209
+		if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
210
+			return;
211
+		}
212
+		$default_hidden_inputs = $reg_form->get_subsection('default_hidden_inputs');
213
+		if ($default_hidden_inputs instanceof EE_Form_Section_Proper) {
214
+			$invisible_recaptcha = RecaptchaFactory::create();
215
+			$invisible_recaptcha->addToFormSection($default_hidden_inputs);
216
+		}
217
+	}
218
+
219
+
220
+	/**
221
+	 * @param EE_Form_Section_Proper $reg_form
222
+	 * @return bool
223
+	 * @throws InvalidDataTypeException
224
+	 * @throws InvalidInterfaceException
225
+	 * @throws EE_Error
226
+	 * @throws InvalidArgumentException
227
+	 */
228
+	public static function processSpcoRegStepForm(EE_Form_Section_Proper $reg_form)
229
+	{
230
+		return strpos($reg_form->name(), 'reg-step-form') !== false
231
+			   && ! RecaptchaFactory::create()->recaptchaPassed();
232
+	}
233
+
234
+
235
+	/**
236
+	 * @param array|null             $req_data
237
+	 * @param EE_Form_Section_Proper $reg_form
238
+	 * @return array
239
+	 * @throws EE_Error
240
+	 * @throws InvalidArgumentException
241
+	 * @throws InvalidDataTypeException
242
+	 * @throws InvalidInterfaceException
243
+	 * @throws RuntimeException
244
+	 */
245
+	public static function receiveSpcoRegStepForm($req_data = array(), EE_Form_Section_Proper $reg_form)
246
+	{
247
+		// do nothing if form isn't for a reg step or test has already been passed
248
+		if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
249
+			return $req_data;
250
+		}
251
+		/** @var EE_Request $request */
252
+		$request = LoaderFactory::getLoader()->getShared('EE_Request');
253
+		if (! EED_Recaptcha_Invisible::verifyToken($request)) {
254
+			if ($request->isAjax()) {
255
+				$json_response = new EE_SPCO_JSON_Response();
256
+				$json_response->echoAndExit();
257
+			}
258
+			EEH_URL::safeRedirectAndExit(
259
+				EE_Registry::instance()->CFG->core->reg_page_url()
260
+			);
261
+		}
262
+		return $req_data;
263
+	}
264
+
265
+
266
+	/**
267
+	 * @param string   $html
268
+	 * @param EE_Event $event
269
+	 * @param bool     $iframe
270
+	 * @return string
271
+	 * @throws EE_Error
272
+	 * @throws InvalidArgumentException
273
+	 * @throws InvalidDataTypeException
274
+	 * @throws InvalidInterfaceException
275
+	 * @throws ReflectionException
276
+	 * @throws DomainException
277
+	 */
278
+	public static function ticketSelectorForm($html = '', EE_Event $event, $iframe = false)
279
+	{
280
+		$recaptcha = RecaptchaFactory::create();
281
+		// do nothing if test has  already  been passed
282
+		if ($recaptcha->recaptchaPassed()) {
283
+			return $html;
284
+		}
285
+		$html .= $recaptcha->getInputHtml(
286
+			array(
287
+				'recaptcha_id'   => $event->ID(),
288
+				'iframe'         => $iframe,
289
+				'localized_vars' => $recaptcha->getLocalizedVars(),
290
+			)
291
+		);
292
+		return $html;
293
+	}
294
+
295
+
296
+	/**
297
+	 * @return void
298
+	 * @throws InvalidArgumentException
299
+	 * @throws InvalidInterfaceException
300
+	 * @throws InvalidDataTypeException
301
+	 * @throws RuntimeException
302
+	 */
303
+	public static function processTicketSelectorForm()
304
+	{
305
+		// do nothing if test has  already  been passed
306
+		if (RecaptchaFactory::create()->recaptchaPassed()) {
307
+			return;
308
+		}
309
+		/** @var EE_Request $request */
310
+		$request = LoaderFactory::getLoader()->getShared('EE_Request');
311
+		if (! EED_Recaptcha_Invisible::verifyToken($request)) {
312
+			$event_id   = $request->get('tkt-slctr-event-id');
313
+			$return_url = $request->is_set("tkt-slctr-return-url-{$event_id}")
314
+				? $request->get("tkt-slctr-return-url-{$event_id}")
315
+				: get_permalink($event_id);
316
+			EEH_URL::safeRedirectAndExit($return_url);
317
+		}
318
+	}
319
+
320
+
321
+	/**
322
+	 * @throws EE_Error
323
+	 * @throws InvalidArgumentException
324
+	 * @throws InvalidDataTypeException
325
+	 * @throws InvalidInterfaceException
326
+	 */
327
+	public static function adminSettings()
328
+	{
329
+		RecaptchaFactory::getAdminModule()->adminSettings();
330
+	}
331
+
332
+
333
+	/**
334
+	 * @param EE_Registration_Config $EE_Registration_Config
335
+	 * @return EE_Registration_Config
336
+	 * @throws EE_Error
337
+	 * @throws InvalidArgumentException
338
+	 * @throws InvalidDataTypeException
339
+	 * @throws InvalidInterfaceException
340
+	 * @throws ReflectionException
341
+	 */
342
+	public static function updateAdminSettings(EE_Registration_Config $EE_Registration_Config)
343
+	{
344
+		return RecaptchaFactory::getAdminModule()->updateAdminSettings($EE_Registration_Config);
345
+	}
346 346
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     {
47 47
         EED_Recaptcha_Invisible::setProperties();
48 48
         if (EED_Recaptcha_Invisible::useInvisibleRecaptcha()) {
49
-            if(EED_Recaptcha_Invisible::protectForm('ticket_selector')){
49
+            if (EED_Recaptcha_Invisible::protectForm('ticket_selector')) {
50 50
                 // ticket selection
51 51
                 add_filter(
52 52
                     'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
      */
168 168
     public static function assetsUrl()
169 169
     {
170
-        return plugin_dir_url(__FILE__) . 'assets' . DS;
170
+        return plugin_dir_url(__FILE__).'assets'.DS;
171 171
     }
172 172
 
173 173
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     public static function spcoRegStepForm(EE_Form_Section_Proper $reg_form)
207 207
     {
208 208
         // do nothing if form isn't for a reg step or test has already been passed
209
-        if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
209
+        if ( ! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
210 210
             return;
211 211
         }
212 212
         $default_hidden_inputs = $reg_form->get_subsection('default_hidden_inputs');
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
     public static function receiveSpcoRegStepForm($req_data = array(), EE_Form_Section_Proper $reg_form)
246 246
     {
247 247
         // do nothing if form isn't for a reg step or test has already been passed
248
-        if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
248
+        if ( ! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
249 249
             return $req_data;
250 250
         }
251 251
         /** @var EE_Request $request */
252 252
         $request = LoaderFactory::getLoader()->getShared('EE_Request');
253
-        if (! EED_Recaptcha_Invisible::verifyToken($request)) {
253
+        if ( ! EED_Recaptcha_Invisible::verifyToken($request)) {
254 254
             if ($request->isAjax()) {
255 255
                 $json_response = new EE_SPCO_JSON_Response();
256 256
                 $json_response->echoAndExit();
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
         }
309 309
         /** @var EE_Request $request */
310 310
         $request = LoaderFactory::getLoader()->getShared('EE_Request');
311
-        if (! EED_Recaptcha_Invisible::verifyToken($request)) {
311
+        if ( ! EED_Recaptcha_Invisible::verifyToken($request)) {
312 312
             $event_id   = $request->get('tkt-slctr-event-id');
313 313
             $return_url = $request->is_set("tkt-slctr-return-url-{$event_id}")
314 314
                 ? $request->get("tkt-slctr-return-url-{$event_id}")
Please login to merge, or discard this patch.
caffeinated/modules/recaptcha_invisible/RecaptchaAdminSettings.php 1 patch
Indentation   +321 added lines, -321 removed lines patch added patch discarded remove patch
@@ -35,337 +35,337 @@
 block discarded – undo
35 35
 class RecaptchaAdminSettings
36 36
 {
37 37
 
38
-    /**
39
-     * @var EE_Registration_Config $config
40
-     */
41
-    private $config;
38
+	/**
39
+	 * @var EE_Registration_Config $config
40
+	 */
41
+	private $config;
42 42
 
43 43
 
44
-    /**
45
-     * RecaptchaAdminSettings constructor.
46
-     *
47
-     * @param EE_Registration_Config $registration_config
48
-     */
49
-    public function __construct(EE_Registration_Config $registration_config)
50
-    {
51
-        $this->config = $registration_config;
52
-    }
44
+	/**
45
+	 * RecaptchaAdminSettings constructor.
46
+	 *
47
+	 * @param EE_Registration_Config $registration_config
48
+	 */
49
+	public function __construct(EE_Registration_Config $registration_config)
50
+	{
51
+		$this->config = $registration_config;
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * @throws InvalidArgumentException
57
-     * @throws InvalidInterfaceException
58
-     * @throws InvalidDataTypeException
59
-     * @throws EE_Error
60
-     */
61
-    public function adminSettings()
62
-    {
63
-        echo $this->settingsForm()->get_html_and_js();
64
-    }
55
+	/**
56
+	 * @throws InvalidArgumentException
57
+	 * @throws InvalidInterfaceException
58
+	 * @throws InvalidDataTypeException
59
+	 * @throws EE_Error
60
+	 */
61
+	public function adminSettings()
62
+	{
63
+		echo $this->settingsForm()->get_html_and_js();
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * @return EE_Form_Section_Proper
69
-     * @throws EE_Error
70
-     */
71
-    protected function settingsForm()
72
-    {
73
-        return new EE_Form_Section_Proper(
74
-            array(
75
-                'name'            => 'recaptcha_settings_form',
76
-                'html_id'         => 'recaptcha_settings_form',
77
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
78
-                'subsections'     => apply_filters(
79
-                    'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections',
80
-                    array(
81
-                        'main_settings_hdr'       => new EE_Form_Section_HTML(
82
-                            EEH_HTML::h2(
83
-                                esc_html__('reCAPTCHA Anti-spam Settings', 'event_espresso')
84
-                                . EEH_Template::get_help_tab_link('recaptcha_info')
85
-                            )
86
-                        ),
87
-                        'main_settings'           => $this->mainSettings(),
88
-                        'appearance_settings_hdr' => new EE_Form_Section_HTML(
89
-                            EEH_HTML::h2(esc_html__('reCAPTCHA Appearance', 'event_espresso'))
90
-                        ),
91
-                        'appearance_settings'     => $this->appearanceSettings(),
92
-                        'required_fields_note'    => new EE_Form_Section_HTML(
93
-                            EEH_HTML::p(
94
-                                esc_html__('All fields marked with a * are required fields', 'event_espresso'),
95
-                                '', 'grey-text'
96
-                            )
97
-                        ),
98
-                    )
99
-                ),
100
-            )
101
-        );
102
-    }
67
+	/**
68
+	 * @return EE_Form_Section_Proper
69
+	 * @throws EE_Error
70
+	 */
71
+	protected function settingsForm()
72
+	{
73
+		return new EE_Form_Section_Proper(
74
+			array(
75
+				'name'            => 'recaptcha_settings_form',
76
+				'html_id'         => 'recaptcha_settings_form',
77
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
78
+				'subsections'     => apply_filters(
79
+					'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections',
80
+					array(
81
+						'main_settings_hdr'       => new EE_Form_Section_HTML(
82
+							EEH_HTML::h2(
83
+								esc_html__('reCAPTCHA Anti-spam Settings', 'event_espresso')
84
+								. EEH_Template::get_help_tab_link('recaptcha_info')
85
+							)
86
+						),
87
+						'main_settings'           => $this->mainSettings(),
88
+						'appearance_settings_hdr' => new EE_Form_Section_HTML(
89
+							EEH_HTML::h2(esc_html__('reCAPTCHA Appearance', 'event_espresso'))
90
+						),
91
+						'appearance_settings'     => $this->appearanceSettings(),
92
+						'required_fields_note'    => new EE_Form_Section_HTML(
93
+							EEH_HTML::p(
94
+								esc_html__('All fields marked with a * are required fields', 'event_espresso'),
95
+								'', 'grey-text'
96
+							)
97
+						),
98
+					)
99
+				),
100
+			)
101
+		);
102
+	}
103 103
 
104 104
 
105
-    /**
106
-     * @return EE_Form_Section_Proper
107
-     * @throws EE_Error
108
-     */
109
-    protected function mainSettings()
110
-    {
111
-        return new EE_Form_Section_Proper(
112
-            array(
113
-                'name'            => 'recaptcha_settings_tbl',
114
-                'html_id'         => 'recaptcha_settings_tbl',
115
-                'html_class'      => 'form-table',
116
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
117
-                'subsections'     => apply_filters(
118
-                    'FHEE__EED_Recaptcha___recaptcha_main_settings__form_subsections',
119
-                    array(
120
-                        'use_captcha'          => new EE_Yes_No_Input(
121
-                            array(
122
-                                'html_label_text'         => esc_html__('Use reCAPTCHA', 'event_espresso'),
123
-                                'html_help_text'          => sprintf(
124
-                                    esc_html__('reCAPTCHA is a free service that  protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.',
125
-                                        'event_espresso'),
126
-                                    '<a href="https://www.google.com/recaptcha/intro/index.html">',
127
-                                    '</a>'
128
-                                ),
129
-                                'default'                 => $this->config->use_captcha !== null
130
-                                    ? $this->config->use_captcha : false,
131
-                                'display_html_label_text' => false,
132
-                            )
133
-                        ),
134
-                        'recaptcha_publickey'  => new EE_Text_Input(
135
-                            array(
136
-                                'html_label_text' => esc_html__('Site Key', 'event_espresso'),
137
-                                'html_help_text'  => esc_html__('The site key is used to display the widget on your site.',
138
-                                    'event_espresso'),
139
-                                'default'         => $this->config->recaptcha_publickey !== null
140
-                                    ? stripslashes($this->config->recaptcha_publickey) : '',
141
-                            )
142
-                        ),
143
-                        'recaptcha_privatekey' => new EE_Text_Input(
144
-                            array(
145
-                                'html_label_text' => esc_html__('Secret Key', 'event_espresso'),
146
-                                'html_help_text'  => esc_html__('The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.',
147
-                                    'event_espresso'),
148
-                                'default'         => $this->config->recaptcha_privatekey !== null
149
-                                    ? stripslashes($this->config->recaptcha_privatekey)
150
-                                    : '',
151
-                            )
152
-                        ),
153
-                        'recaptcha_protected_forms' => new EE_Checkbox_Multi_Input(
154
-                            array(
155
-                                'ticket_selector'   => esc_html__('Ticket Selector', 'event_espresso'),
156
-                                'registration_form' => esc_html__('Registration Form', 'event_espresso'),
157
-                            ),
158
-                            array(
159
-                                'html_label_text'         => esc_html__('Invisible reCAPTCHA Protection', 'event_espresso'),
160
-                                'html_help_text'          => esc_html__('Select which Event Espresso forms you would like to enable Invisible reCAPTCHA on.',
161
-                                    'event_espresso'),
162
-                                'default'                 => is_array($this->config->recaptcha_protected_forms)
163
-                                    ? $this->config->recaptcha_protected_forms
164
-                                    : array(),
165
-                                'display_html_label_text' => false,
166
-                            )
167
-                        ),
168
-                    )
169
-                ),
170
-            )
171
-        );
172
-    }
105
+	/**
106
+	 * @return EE_Form_Section_Proper
107
+	 * @throws EE_Error
108
+	 */
109
+	protected function mainSettings()
110
+	{
111
+		return new EE_Form_Section_Proper(
112
+			array(
113
+				'name'            => 'recaptcha_settings_tbl',
114
+				'html_id'         => 'recaptcha_settings_tbl',
115
+				'html_class'      => 'form-table',
116
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
117
+				'subsections'     => apply_filters(
118
+					'FHEE__EED_Recaptcha___recaptcha_main_settings__form_subsections',
119
+					array(
120
+						'use_captcha'          => new EE_Yes_No_Input(
121
+							array(
122
+								'html_label_text'         => esc_html__('Use reCAPTCHA', 'event_espresso'),
123
+								'html_help_text'          => sprintf(
124
+									esc_html__('reCAPTCHA is a free service that  protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.',
125
+										'event_espresso'),
126
+									'<a href="https://www.google.com/recaptcha/intro/index.html">',
127
+									'</a>'
128
+								),
129
+								'default'                 => $this->config->use_captcha !== null
130
+									? $this->config->use_captcha : false,
131
+								'display_html_label_text' => false,
132
+							)
133
+						),
134
+						'recaptcha_publickey'  => new EE_Text_Input(
135
+							array(
136
+								'html_label_text' => esc_html__('Site Key', 'event_espresso'),
137
+								'html_help_text'  => esc_html__('The site key is used to display the widget on your site.',
138
+									'event_espresso'),
139
+								'default'         => $this->config->recaptcha_publickey !== null
140
+									? stripslashes($this->config->recaptcha_publickey) : '',
141
+							)
142
+						),
143
+						'recaptcha_privatekey' => new EE_Text_Input(
144
+							array(
145
+								'html_label_text' => esc_html__('Secret Key', 'event_espresso'),
146
+								'html_help_text'  => esc_html__('The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.',
147
+									'event_espresso'),
148
+								'default'         => $this->config->recaptcha_privatekey !== null
149
+									? stripslashes($this->config->recaptcha_privatekey)
150
+									: '',
151
+							)
152
+						),
153
+						'recaptcha_protected_forms' => new EE_Checkbox_Multi_Input(
154
+							array(
155
+								'ticket_selector'   => esc_html__('Ticket Selector', 'event_espresso'),
156
+								'registration_form' => esc_html__('Registration Form', 'event_espresso'),
157
+							),
158
+							array(
159
+								'html_label_text'         => esc_html__('Invisible reCAPTCHA Protection', 'event_espresso'),
160
+								'html_help_text'          => esc_html__('Select which Event Espresso forms you would like to enable Invisible reCAPTCHA on.',
161
+									'event_espresso'),
162
+								'default'                 => is_array($this->config->recaptcha_protected_forms)
163
+									? $this->config->recaptcha_protected_forms
164
+									: array(),
165
+								'display_html_label_text' => false,
166
+							)
167
+						),
168
+					)
169
+				),
170
+			)
171
+		);
172
+	}
173 173
 
174 174
 
175
-    /**
176
-     * @return EE_Form_Section_Proper
177
-     * @throws EE_Error
178
-     */
179
-    protected function appearanceSettings()
180
-    {
181
-        return new EE_Form_Section_Proper(
182
-            array(
183
-                'name'            => 'recaptcha_appearance_settings_tbl',
184
-                'html_id'         => 'recaptcha_appearance_settings_tbl',
185
-                'html_class'      => 'form-table',
186
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
187
-                'subsections'     => apply_filters(
188
-                    'FHEE__EED_Recaptcha___recaptcha_appearance_settings__form_subsections',
189
-                    array(
190
-                        'recaptcha_theme'    => new EE_Radio_Button_Input(
191
-                            array(
192
-                                'invisible' => esc_html__('Invisible', 'event_espresso'),
193
-                                'light'     => esc_html__('Light', 'event_espresso'),
194
-                                'dark'      => esc_html__('Dark', 'event_espresso'),
195
-                            ),
196
-                            array(
197
-                                'html_label_text'         => esc_html__('Theme', 'event_espresso'),
198
-                                'html_help_text'          => esc_html__('The color theme of the widget.',
199
-                                    'event_espresso'),
200
-                                'default'                 => $this->config->recaptcha_theme !== null
201
-                                    ? $this->config->recaptcha_theme
202
-                                    : 'invisible',
203
-                                'display_html_label_text' => false,
204
-                            )
205
-                        ),
206
-                        'recaptcha_badge'     => new EE_Radio_Button_Input(
207
-                            array(
208
-                                'bottomleft' => esc_html__('Bottom Left', 'event_espresso'),
209
-                                'bottomright' => esc_html__('Bottom Right', 'event_espresso'),
210
-                                'inline' => esc_html__('Inline', 'event_espresso'),
211
-                            ),
212
-                            array(
213
-                                'html_label_text'         => esc_html__('Invisible reCAPTCHA Badge Position', 'event_espresso'),
214
-                                'html_help_text'          => esc_html__(
215
-                                    'If using Invisible reCAPTCHA, then this determines the position of the reCAPTCHA badge. "Bottom Left" and "Bottom Right" both will float at the bottom of the screen. "Inline" appears beside the submit button but allows you to control the CSS.',
216
-                                    'event_espresso'
217
-                                ),
218
-                                'default'                 => $this->config->recaptcha_badge !== null
219
-                                    ? $this->config->recaptcha_badge
220
-                                    : 'bottomleft',
221
-                                'display_html_label_text' => false,
222
-                            )
223
-                        ),
224
-                        'recaptcha_type'     => new EE_Radio_Button_Input(
225
-                            array(
226
-                                'image' => esc_html__('Image', 'event_espresso'),
227
-                                'audio' => esc_html__('Audio', 'event_espresso'),
228
-                            ),
229
-                            array(
230
-                                'html_label_text'         => esc_html__('Type', 'event_espresso'),
231
-                                'html_help_text'          => esc_html__('The type of CAPTCHA to serve.',
232
-                                    'event_espresso'),
233
-                                'default'                 => $this->config->recaptcha_type !== null
234
-                                    ? $this->config->recaptcha_type
235
-                                    : 'image',
236
-                                'display_html_label_text' => false,
237
-                            )
238
-                        ),
239
-                        'recaptcha_language' => new EE_Select_Input(
240
-                            array(
241
-                                'ar'     => esc_html__('Arabic', 'event_espresso'),
242
-                                'bg'     => esc_html__('Bulgarian', 'event_espresso'),
243
-                                'ca'     => esc_html__('Catalan', 'event_espresso'),
244
-                                'zh-CN'  => esc_html__('Chinese (Simplified)', 'event_espresso'),
245
-                                'zh-TW'  => esc_html__('Chinese (Traditional)	', 'event_espresso'),
246
-                                'hr'     => esc_html__('Croatian', 'event_espresso'),
247
-                                'cs'     => esc_html__('Czech', 'event_espresso'),
248
-                                'da'     => esc_html__('Danish', 'event_espresso'),
249
-                                'nl'     => esc_html__('Dutch', 'event_espresso'),
250
-                                'en-GB'  => esc_html__('English (UK)', 'event_espresso'),
251
-                                'en'     => esc_html__('English (US)', 'event_espresso'),
252
-                                'fil'    => esc_html__('Filipino', 'event_espresso'),
253
-                                'fi'     => esc_html__('Finnish', 'event_espresso'),
254
-                                'fr'     => esc_html__('French', 'event_espresso'),
255
-                                'fr-CA'  => esc_html__('French (Canadian)', 'event_espresso'),
256
-                                'de'     => esc_html__('German', 'event_espresso'),
257
-                                'de-AT'  => esc_html__('German (Austria)', 'event_espresso'),
258
-                                'de-CH'  => esc_html__('German (Switzerland)', 'event_espresso'),
259
-                                'el'     => esc_html__('Greek', 'event_espresso'),
260
-                                'iw'     => esc_html__('Hebrew', 'event_espresso'),
261
-                                'hi'     => esc_html__('Hindi', 'event_espresso'),
262
-                                'hu'     => esc_html__('Hungarian', 'event_espresso'),
263
-                                'id'     => esc_html__('Indonesian', 'event_espresso'),
264
-                                'it'     => esc_html__('Italian', 'event_espresso'),
265
-                                'ja'     => esc_html__('Japanese', 'event_espresso'),
266
-                                'ko'     => esc_html__('Korean', 'event_espresso'),
267
-                                'lv'     => esc_html__('Latvian', 'event_espresso'),
268
-                                'lt'     => esc_html__('Lithuanian', 'event_espresso'),
269
-                                'no'     => esc_html__('Norwegian', 'event_espresso'),
270
-                                'fa'     => esc_html__('Persian', 'event_espresso'),
271
-                                'pl'     => esc_html__('Polish', 'event_espresso'),
272
-                                'pt'     => esc_html__('Portuguese', 'event_espresso'),
273
-                                'pt-BR'  => esc_html__('Portuguese (Brazil)', 'event_espresso'),
274
-                                'pt-PT'  => esc_html__('Portuguese (Portugal)', 'event_espresso'),
275
-                                'ro'     => esc_html__('Romanian', 'event_espresso'),
276
-                                'ru'     => esc_html__('Russian', 'event_espresso'),
277
-                                'sr'     => esc_html__('Serbian', 'event_espresso'),
278
-                                'sk'     => esc_html__('Slovak', 'event_espresso'),
279
-                                'sl'     => esc_html__('Slovenian', 'event_espresso'),
280
-                                'es'     => esc_html__('Spanish', 'event_espresso'),
281
-                                'es-419' => esc_html__('Spanish (Latin America)', 'event_espresso'),
282
-                                'sv'     => esc_html__('Swedish', 'event_espresso'),
283
-                                'th'     => esc_html__('Thai', 'event_espresso'),
284
-                                'tr'     => esc_html__('Turkish', 'event_espresso'),
285
-                                'uk'     => esc_html__('Ukrainian', 'event_espresso'),
286
-                                'vi'     => esc_html__('Vietnamese', 'event_espresso'),
287
-                            ),
288
-                            array(
289
-                                'html_label_text' => esc_html__('Language', 'event_espresso'),
290
-                                'html_help_text'  => esc_html__('Forces the widget to render in a specific language.',
291
-                                    'event_espresso'),
292
-                                'default'         => $this->config->recaptcha_language !== null
293
-                                    ? $this->config->recaptcha_language : 'en',
294
-                            )
295
-                        ),
296
-                    )
297
-                ),
298
-            )
299
-        );
300
-    }
175
+	/**
176
+	 * @return EE_Form_Section_Proper
177
+	 * @throws EE_Error
178
+	 */
179
+	protected function appearanceSettings()
180
+	{
181
+		return new EE_Form_Section_Proper(
182
+			array(
183
+				'name'            => 'recaptcha_appearance_settings_tbl',
184
+				'html_id'         => 'recaptcha_appearance_settings_tbl',
185
+				'html_class'      => 'form-table',
186
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
187
+				'subsections'     => apply_filters(
188
+					'FHEE__EED_Recaptcha___recaptcha_appearance_settings__form_subsections',
189
+					array(
190
+						'recaptcha_theme'    => new EE_Radio_Button_Input(
191
+							array(
192
+								'invisible' => esc_html__('Invisible', 'event_espresso'),
193
+								'light'     => esc_html__('Light', 'event_espresso'),
194
+								'dark'      => esc_html__('Dark', 'event_espresso'),
195
+							),
196
+							array(
197
+								'html_label_text'         => esc_html__('Theme', 'event_espresso'),
198
+								'html_help_text'          => esc_html__('The color theme of the widget.',
199
+									'event_espresso'),
200
+								'default'                 => $this->config->recaptcha_theme !== null
201
+									? $this->config->recaptcha_theme
202
+									: 'invisible',
203
+								'display_html_label_text' => false,
204
+							)
205
+						),
206
+						'recaptcha_badge'     => new EE_Radio_Button_Input(
207
+							array(
208
+								'bottomleft' => esc_html__('Bottom Left', 'event_espresso'),
209
+								'bottomright' => esc_html__('Bottom Right', 'event_espresso'),
210
+								'inline' => esc_html__('Inline', 'event_espresso'),
211
+							),
212
+							array(
213
+								'html_label_text'         => esc_html__('Invisible reCAPTCHA Badge Position', 'event_espresso'),
214
+								'html_help_text'          => esc_html__(
215
+									'If using Invisible reCAPTCHA, then this determines the position of the reCAPTCHA badge. "Bottom Left" and "Bottom Right" both will float at the bottom of the screen. "Inline" appears beside the submit button but allows you to control the CSS.',
216
+									'event_espresso'
217
+								),
218
+								'default'                 => $this->config->recaptcha_badge !== null
219
+									? $this->config->recaptcha_badge
220
+									: 'bottomleft',
221
+								'display_html_label_text' => false,
222
+							)
223
+						),
224
+						'recaptcha_type'     => new EE_Radio_Button_Input(
225
+							array(
226
+								'image' => esc_html__('Image', 'event_espresso'),
227
+								'audio' => esc_html__('Audio', 'event_espresso'),
228
+							),
229
+							array(
230
+								'html_label_text'         => esc_html__('Type', 'event_espresso'),
231
+								'html_help_text'          => esc_html__('The type of CAPTCHA to serve.',
232
+									'event_espresso'),
233
+								'default'                 => $this->config->recaptcha_type !== null
234
+									? $this->config->recaptcha_type
235
+									: 'image',
236
+								'display_html_label_text' => false,
237
+							)
238
+						),
239
+						'recaptcha_language' => new EE_Select_Input(
240
+							array(
241
+								'ar'     => esc_html__('Arabic', 'event_espresso'),
242
+								'bg'     => esc_html__('Bulgarian', 'event_espresso'),
243
+								'ca'     => esc_html__('Catalan', 'event_espresso'),
244
+								'zh-CN'  => esc_html__('Chinese (Simplified)', 'event_espresso'),
245
+								'zh-TW'  => esc_html__('Chinese (Traditional)	', 'event_espresso'),
246
+								'hr'     => esc_html__('Croatian', 'event_espresso'),
247
+								'cs'     => esc_html__('Czech', 'event_espresso'),
248
+								'da'     => esc_html__('Danish', 'event_espresso'),
249
+								'nl'     => esc_html__('Dutch', 'event_espresso'),
250
+								'en-GB'  => esc_html__('English (UK)', 'event_espresso'),
251
+								'en'     => esc_html__('English (US)', 'event_espresso'),
252
+								'fil'    => esc_html__('Filipino', 'event_espresso'),
253
+								'fi'     => esc_html__('Finnish', 'event_espresso'),
254
+								'fr'     => esc_html__('French', 'event_espresso'),
255
+								'fr-CA'  => esc_html__('French (Canadian)', 'event_espresso'),
256
+								'de'     => esc_html__('German', 'event_espresso'),
257
+								'de-AT'  => esc_html__('German (Austria)', 'event_espresso'),
258
+								'de-CH'  => esc_html__('German (Switzerland)', 'event_espresso'),
259
+								'el'     => esc_html__('Greek', 'event_espresso'),
260
+								'iw'     => esc_html__('Hebrew', 'event_espresso'),
261
+								'hi'     => esc_html__('Hindi', 'event_espresso'),
262
+								'hu'     => esc_html__('Hungarian', 'event_espresso'),
263
+								'id'     => esc_html__('Indonesian', 'event_espresso'),
264
+								'it'     => esc_html__('Italian', 'event_espresso'),
265
+								'ja'     => esc_html__('Japanese', 'event_espresso'),
266
+								'ko'     => esc_html__('Korean', 'event_espresso'),
267
+								'lv'     => esc_html__('Latvian', 'event_espresso'),
268
+								'lt'     => esc_html__('Lithuanian', 'event_espresso'),
269
+								'no'     => esc_html__('Norwegian', 'event_espresso'),
270
+								'fa'     => esc_html__('Persian', 'event_espresso'),
271
+								'pl'     => esc_html__('Polish', 'event_espresso'),
272
+								'pt'     => esc_html__('Portuguese', 'event_espresso'),
273
+								'pt-BR'  => esc_html__('Portuguese (Brazil)', 'event_espresso'),
274
+								'pt-PT'  => esc_html__('Portuguese (Portugal)', 'event_espresso'),
275
+								'ro'     => esc_html__('Romanian', 'event_espresso'),
276
+								'ru'     => esc_html__('Russian', 'event_espresso'),
277
+								'sr'     => esc_html__('Serbian', 'event_espresso'),
278
+								'sk'     => esc_html__('Slovak', 'event_espresso'),
279
+								'sl'     => esc_html__('Slovenian', 'event_espresso'),
280
+								'es'     => esc_html__('Spanish', 'event_espresso'),
281
+								'es-419' => esc_html__('Spanish (Latin America)', 'event_espresso'),
282
+								'sv'     => esc_html__('Swedish', 'event_espresso'),
283
+								'th'     => esc_html__('Thai', 'event_espresso'),
284
+								'tr'     => esc_html__('Turkish', 'event_espresso'),
285
+								'uk'     => esc_html__('Ukrainian', 'event_espresso'),
286
+								'vi'     => esc_html__('Vietnamese', 'event_espresso'),
287
+							),
288
+							array(
289
+								'html_label_text' => esc_html__('Language', 'event_espresso'),
290
+								'html_help_text'  => esc_html__('Forces the widget to render in a specific language.',
291
+									'event_espresso'),
292
+								'default'         => $this->config->recaptcha_language !== null
293
+									? $this->config->recaptcha_language : 'en',
294
+							)
295
+						),
296
+					)
297
+				),
298
+			)
299
+		);
300
+	}
301 301
 
302 302
 
303
-    /**
304
-     * @param EE_Registration_Config $EE_Registration_Config
305
-     * @return EE_Registration_Config
306
-     * @throws InvalidArgumentException
307
-     * @throws InvalidInterfaceException
308
-     * @throws InvalidDataTypeException
309
-     * @throws EE_Error
310
-     * @throws ReflectionException
311
-     */
312
-    public function updateAdminSettings(EE_Registration_Config $EE_Registration_Config)
313
-    {
314
-        try {
315
-            $recaptcha_settings_form = $this->settingsForm();
316
-            // if not displaying a form, then check for form submission
317
-            if ($recaptcha_settings_form->was_submitted()) {
318
-                // capture form data
319
-                $recaptcha_settings_form->receive_form_submission();
320
-                // validate form data
321
-                if ($recaptcha_settings_form->is_valid()) {
322
-                    // grab validated data from form
323
-                    $valid_data = $recaptcha_settings_form->valid_data();
324
-                    // user proofing recaptcha:  If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message.
325
-                    if (
326
-                        $valid_data['main_settings']['use_captcha']
327
-                        && (
328
-                            ! $EE_Registration_Config->use_captcha
329
-                            && (
330
-                                empty($valid_data['main_settings']['recaptcha_publickey'])
331
-                                || empty($valid_data['main_settings']['recaptcha_privatekey'])
332
-                            )
333
-                        )
334
-                        && apply_filters(
335
-                            'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys',
336
-                            true,
337
-                            $EE_Registration_Config
338
-                        )
339
-                    ) {
340
-                        $valid_data['main_settings']['use_captcha'] = false;
341
-                        EE_Error::add_error(
342
-                            esc_html__(
343
-                                'The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.',
344
-                                'event_espresso'
345
-                            ),
346
-                            __FILE__, __FUNCTION__, __LINE__
347
-                        );
348
-                    }
349
-                    $EE_Registration_Config->use_captcha          = $valid_data['main_settings']['use_captcha'];
350
-                    $EE_Registration_Config->recaptcha_publickey  = $valid_data['main_settings']['recaptcha_publickey'];
351
-                    $EE_Registration_Config->recaptcha_protected_forms = $valid_data['main_settings']['recaptcha_protected_forms'];
352
-                    $EE_Registration_Config->recaptcha_privatekey = $valid_data['main_settings']['recaptcha_privatekey'];
353
-                    $EE_Registration_Config->recaptcha_type       = $valid_data['appearance_settings']['recaptcha_type'];
354
-                    $EE_Registration_Config->recaptcha_theme      = $valid_data['appearance_settings']['recaptcha_theme'];
355
-                    $EE_Registration_Config->recaptcha_badge      = $valid_data['appearance_settings']['recaptcha_badge'];
356
-                    $EE_Registration_Config->recaptcha_language   = $valid_data['appearance_settings']['recaptcha_language'];
357
-                } else {
358
-                    if ($recaptcha_settings_form->submission_error_message() !== '') {
359
-                        EE_Error::add_error(
360
-                            $recaptcha_settings_form->submission_error_message(),
361
-                            __FILE__, __FUNCTION__, __LINE__
362
-                        );
363
-                    }
364
-                }
365
-            }
366
-        } catch (EE_Error $e) {
367
-            $e->get_error();
368
-        }
369
-        return $EE_Registration_Config;
370
-    }
303
+	/**
304
+	 * @param EE_Registration_Config $EE_Registration_Config
305
+	 * @return EE_Registration_Config
306
+	 * @throws InvalidArgumentException
307
+	 * @throws InvalidInterfaceException
308
+	 * @throws InvalidDataTypeException
309
+	 * @throws EE_Error
310
+	 * @throws ReflectionException
311
+	 */
312
+	public function updateAdminSettings(EE_Registration_Config $EE_Registration_Config)
313
+	{
314
+		try {
315
+			$recaptcha_settings_form = $this->settingsForm();
316
+			// if not displaying a form, then check for form submission
317
+			if ($recaptcha_settings_form->was_submitted()) {
318
+				// capture form data
319
+				$recaptcha_settings_form->receive_form_submission();
320
+				// validate form data
321
+				if ($recaptcha_settings_form->is_valid()) {
322
+					// grab validated data from form
323
+					$valid_data = $recaptcha_settings_form->valid_data();
324
+					// user proofing recaptcha:  If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message.
325
+					if (
326
+						$valid_data['main_settings']['use_captcha']
327
+						&& (
328
+							! $EE_Registration_Config->use_captcha
329
+							&& (
330
+								empty($valid_data['main_settings']['recaptcha_publickey'])
331
+								|| empty($valid_data['main_settings']['recaptcha_privatekey'])
332
+							)
333
+						)
334
+						&& apply_filters(
335
+							'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys',
336
+							true,
337
+							$EE_Registration_Config
338
+						)
339
+					) {
340
+						$valid_data['main_settings']['use_captcha'] = false;
341
+						EE_Error::add_error(
342
+							esc_html__(
343
+								'The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.',
344
+								'event_espresso'
345
+							),
346
+							__FILE__, __FUNCTION__, __LINE__
347
+						);
348
+					}
349
+					$EE_Registration_Config->use_captcha          = $valid_data['main_settings']['use_captcha'];
350
+					$EE_Registration_Config->recaptcha_publickey  = $valid_data['main_settings']['recaptcha_publickey'];
351
+					$EE_Registration_Config->recaptcha_protected_forms = $valid_data['main_settings']['recaptcha_protected_forms'];
352
+					$EE_Registration_Config->recaptcha_privatekey = $valid_data['main_settings']['recaptcha_privatekey'];
353
+					$EE_Registration_Config->recaptcha_type       = $valid_data['appearance_settings']['recaptcha_type'];
354
+					$EE_Registration_Config->recaptcha_theme      = $valid_data['appearance_settings']['recaptcha_theme'];
355
+					$EE_Registration_Config->recaptcha_badge      = $valid_data['appearance_settings']['recaptcha_badge'];
356
+					$EE_Registration_Config->recaptcha_language   = $valid_data['appearance_settings']['recaptcha_language'];
357
+				} else {
358
+					if ($recaptcha_settings_form->submission_error_message() !== '') {
359
+						EE_Error::add_error(
360
+							$recaptcha_settings_form->submission_error_message(),
361
+							__FILE__, __FUNCTION__, __LINE__
362
+						);
363
+					}
364
+				}
365
+			}
366
+		} catch (EE_Error $e) {
367
+			$e->get_error();
368
+		}
369
+		return $EE_Registration_Config;
370
+	}
371 371
 }
Please login to merge, or discard this patch.
core/EE_Config.core.php 1 patch
Indentation   +3078 added lines, -3078 removed lines patch added patch discarded remove patch
@@ -17,2460 +17,2460 @@  discard block
 block discarded – undo
17 17
 final class EE_Config implements ResettableInterface
18 18
 {
19 19
 
20
-    const OPTION_NAME        = 'ee_config';
20
+	const OPTION_NAME        = 'ee_config';
21
+
22
+	const LOG_NAME           = 'ee_config_log';
23
+
24
+	const LOG_LENGTH         = 100;
25
+
26
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
27
+
28
+
29
+	/**
30
+	 *    instance of the EE_Config object
31
+	 *
32
+	 * @var    EE_Config $_instance
33
+	 * @access    private
34
+	 */
35
+	private static $_instance;
36
+
37
+	/**
38
+	 * @var boolean $_logging_enabled
39
+	 */
40
+	private static $_logging_enabled = false;
41
+
42
+	/**
43
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
44
+	 */
45
+	private $legacy_shortcodes_manager;
46
+
47
+	/**
48
+	 * An StdClass whose property names are addon slugs,
49
+	 * and values are their config classes
50
+	 *
51
+	 * @var StdClass
52
+	 */
53
+	public $addons;
54
+
55
+	/**
56
+	 * @var EE_Admin_Config
57
+	 */
58
+	public $admin;
59
+
60
+	/**
61
+	 * @var EE_Core_Config
62
+	 */
63
+	public $core;
64
+
65
+	/**
66
+	 * @var EE_Currency_Config
67
+	 */
68
+	public $currency;
69
+
70
+	/**
71
+	 * @var EE_Organization_Config
72
+	 */
73
+	public $organization;
74
+
75
+	/**
76
+	 * @var EE_Registration_Config
77
+	 */
78
+	public $registration;
79
+
80
+	/**
81
+	 * @var EE_Template_Config
82
+	 */
83
+	public $template_settings;
84
+
85
+	/**
86
+	 * Holds EE environment values.
87
+	 *
88
+	 * @var EE_Environment_Config
89
+	 */
90
+	public $environment;
91
+
92
+	/**
93
+	 * settings pertaining to Google maps
94
+	 *
95
+	 * @var EE_Map_Config
96
+	 */
97
+	public $map_settings;
98
+
99
+	/**
100
+	 * settings pertaining to Taxes
101
+	 *
102
+	 * @var EE_Tax_Config
103
+	 */
104
+	public $tax_settings;
105
+
106
+
107
+	/**
108
+	 * Settings pertaining to global messages settings.
109
+	 *
110
+	 * @var EE_Messages_Config
111
+	 */
112
+	public $messages;
113
+
114
+	/**
115
+	 * @deprecated
116
+	 * @var EE_Gateway_Config
117
+	 */
118
+	public $gateway;
119
+
120
+	/**
121
+	 * @var    array $_addon_option_names
122
+	 * @access    private
123
+	 */
124
+	private $_addon_option_names = array();
125
+
126
+	/**
127
+	 * @var    array $_module_route_map
128
+	 * @access    private
129
+	 */
130
+	private static $_module_route_map = array();
131
+
132
+	/**
133
+	 * @var    array $_module_forward_map
134
+	 * @access    private
135
+	 */
136
+	private static $_module_forward_map = array();
137
+
138
+	/**
139
+	 * @var    array $_module_view_map
140
+	 * @access    private
141
+	 */
142
+	private static $_module_view_map = array();
143
+
144
+
145
+
146
+	/**
147
+	 * @singleton method used to instantiate class object
148
+	 * @access    public
149
+	 * @return EE_Config instance
150
+	 */
151
+	public static function instance()
152
+	{
153
+		// check if class object is instantiated, and instantiated properly
154
+		if (! self::$_instance instanceof EE_Config) {
155
+			self::$_instance = new self();
156
+		}
157
+		return self::$_instance;
158
+	}
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
+		//we don't need to reset the static properties imo because those should
187
+		//only change when a module is added or removed. Currently we don't
188
+		//support removing a module during a request when it previously existed
189
+		if ($reinstantiate) {
190
+			return self::instance();
191
+		} else {
192
+			return null;
193
+		}
194
+	}
195
+
196
+
197
+
198
+	/**
199
+	 *    class constructor
200
+	 *
201
+	 * @access    private
202
+	 */
203
+	private function __construct()
204
+	{
205
+		do_action('AHEE__EE_Config__construct__begin', $this);
206
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
207
+		// setup empty config classes
208
+		$this->_initialize_config();
209
+		// load existing EE site settings
210
+		$this->_load_core_config();
211
+		// confirm everything loaded correctly and set filtered defaults if not
212
+		$this->_verify_config();
213
+		//  register shortcodes and modules
214
+		add_action(
215
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
216
+			array($this, 'register_shortcodes_and_modules'),
217
+			999
218
+		);
219
+		//  initialize shortcodes and modules
220
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
221
+		// register widgets
222
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
223
+		// shutdown
224
+		add_action('shutdown', array($this, 'shutdown'), 10);
225
+		// construct__end hook
226
+		do_action('AHEE__EE_Config__construct__end', $this);
227
+		// hardcoded hack
228
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
229
+	}
230
+
231
+
232
+
233
+	/**
234
+	 * @return boolean
235
+	 */
236
+	public static function logging_enabled()
237
+	{
238
+		return self::$_logging_enabled;
239
+	}
240
+
241
+
242
+
243
+	/**
244
+	 * use to get the current theme if needed from static context
245
+	 *
246
+	 * @return string current theme set.
247
+	 */
248
+	public static function get_current_theme()
249
+	{
250
+		return isset(self::$_instance->template_settings->current_espresso_theme)
251
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
252
+	}
253
+
254
+
255
+
256
+	/**
257
+	 *        _initialize_config
258
+	 *
259
+	 * @access private
260
+	 * @return void
261
+	 */
262
+	private function _initialize_config()
263
+	{
264
+		EE_Config::trim_log();
265
+		//set defaults
266
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
267
+		$this->addons = new stdClass();
268
+		// set _module_route_map
269
+		EE_Config::$_module_route_map = array();
270
+		// set _module_forward_map
271
+		EE_Config::$_module_forward_map = array();
272
+		// set _module_view_map
273
+		EE_Config::$_module_view_map = array();
274
+	}
275
+
276
+
277
+
278
+	/**
279
+	 *        load core plugin configuration
280
+	 *
281
+	 * @access private
282
+	 * @return void
283
+	 */
284
+	private function _load_core_config()
285
+	{
286
+		// load_core_config__start hook
287
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
288
+		$espresso_config = $this->get_espresso_config();
289
+		foreach ($espresso_config as $config => $settings) {
290
+			// load_core_config__start hook
291
+			$settings = apply_filters(
292
+				'FHEE__EE_Config___load_core_config__config_settings',
293
+				$settings,
294
+				$config,
295
+				$this
296
+			);
297
+			if (is_object($settings) && property_exists($this, $config)) {
298
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
299
+				//call configs populate method to ensure any defaults are set for empty values.
300
+				if (method_exists($settings, 'populate')) {
301
+					$this->{$config}->populate();
302
+				}
303
+				if (method_exists($settings, 'do_hooks')) {
304
+					$this->{$config}->do_hooks();
305
+				}
306
+			}
307
+		}
308
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
309
+			$this->update_espresso_config();
310
+		}
311
+		// load_core_config__end hook
312
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
313
+	}
314
+
315
+
316
+
317
+	/**
318
+	 *    _verify_config
319
+	 *
320
+	 * @access    protected
321
+	 * @return    void
322
+	 */
323
+	protected function _verify_config()
324
+	{
325
+		$this->core = $this->core instanceof EE_Core_Config
326
+			? $this->core
327
+			: new EE_Core_Config();
328
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
329
+		$this->organization = $this->organization instanceof EE_Organization_Config
330
+			? $this->organization
331
+			: new EE_Organization_Config();
332
+		$this->organization = apply_filters(
333
+			'FHEE__EE_Config___initialize_config__organization',
334
+			$this->organization
335
+		);
336
+		$this->currency = $this->currency instanceof EE_Currency_Config
337
+			? $this->currency
338
+			: new EE_Currency_Config();
339
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
340
+		$this->registration = $this->registration instanceof EE_Registration_Config
341
+			? $this->registration
342
+			: new EE_Registration_Config();
343
+		$this->registration = apply_filters(
344
+			'FHEE__EE_Config___initialize_config__registration',
345
+			$this->registration
346
+		);
347
+		$this->admin = $this->admin instanceof EE_Admin_Config
348
+			? $this->admin
349
+			: new EE_Admin_Config();
350
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
351
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
352
+			? $this->template_settings
353
+			: new EE_Template_Config();
354
+		$this->template_settings = apply_filters(
355
+			'FHEE__EE_Config___initialize_config__template_settings',
356
+			$this->template_settings
357
+		);
358
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
359
+			? $this->map_settings
360
+			: new EE_Map_Config();
361
+		$this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
362
+			$this->map_settings);
363
+		$this->environment = $this->environment instanceof EE_Environment_Config
364
+			? $this->environment
365
+			: new EE_Environment_Config();
366
+		$this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
367
+			$this->environment);
368
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
369
+			? $this->tax_settings
370
+			: new EE_Tax_Config();
371
+		$this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
372
+			$this->tax_settings);
373
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
374
+		$this->messages = $this->messages instanceof EE_Messages_Config
375
+			? $this->messages
376
+			: new EE_Messages_Config();
377
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
378
+			? $this->gateway
379
+			: new EE_Gateway_Config();
380
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
381
+		$this->legacy_shortcodes_manager = null;
382
+	}
383
+
384
+
385
+	/**
386
+	 *    get_espresso_config
387
+	 *
388
+	 * @access    public
389
+	 * @return    array of espresso config stuff
390
+	 */
391
+	public function get_espresso_config()
392
+	{
393
+		// grab espresso configuration
394
+		return apply_filters(
395
+			'FHEE__EE_Config__get_espresso_config__CFG',
396
+			get_option(EE_Config::OPTION_NAME, array())
397
+		);
398
+	}
399
+
400
+
401
+
402
+	/**
403
+	 *    double_check_config_comparison
404
+	 *
405
+	 * @access    public
406
+	 * @param string $option
407
+	 * @param        $old_value
408
+	 * @param        $value
409
+	 */
410
+	public function double_check_config_comparison($option = '', $old_value, $value)
411
+	{
412
+		// make sure we're checking the ee config
413
+		if ($option === EE_Config::OPTION_NAME) {
414
+			// run a loose comparison of the old value against the new value for type and properties,
415
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
416
+			if ($value != $old_value) {
417
+				// if they are NOT the same, then remove the hook,
418
+				// which means the subsequent update results will be based solely on the update query results
419
+				// the reason we do this is because, as stated above,
420
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
421
+				// this happens PRIOR to serialization and any subsequent update.
422
+				// If values are found to match their previous old value,
423
+				// then WP bails before performing any update.
424
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
425
+				// it just pulled from the db, with the one being passed to it (which will not match).
426
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
427
+				// MySQL MAY ALSO NOT perform the update because
428
+				// the string it sees in the db looks the same as the new one it has been passed!!!
429
+				// This results in the query returning an "affected rows" value of ZERO,
430
+				// which gets returned immediately by WP update_option and looks like an error.
431
+				remove_action('update_option', array($this, 'check_config_updated'));
432
+			}
433
+		}
434
+	}
435
+
436
+
437
+
438
+	/**
439
+	 *    update_espresso_config
440
+	 *
441
+	 * @access   public
442
+	 */
443
+	protected function _reset_espresso_addon_config()
444
+	{
445
+		$this->_addon_option_names = array();
446
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
447
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
448
+			if ($addon_config_obj instanceof EE_Config_Base) {
449
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
450
+			}
451
+			$this->addons->{$addon_name} = null;
452
+		}
453
+	}
454
+
455
+
456
+
457
+	/**
458
+	 *    update_espresso_config
459
+	 *
460
+	 * @access   public
461
+	 * @param   bool $add_success
462
+	 * @param   bool $add_error
463
+	 * @return   bool
464
+	 */
465
+	public function update_espresso_config($add_success = false, $add_error = true)
466
+	{
467
+		// don't allow config updates during WP heartbeats
468
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
469
+			return false;
470
+		}
471
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
472
+		//$clone = clone( self::$_instance );
473
+		//self::$_instance = NULL;
474
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
475
+		$this->_reset_espresso_addon_config();
476
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
477
+		// but BEFORE the actual update occurs
478
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
479
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
480
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
481
+		$this->legacy_shortcodes_manager = null;
482
+		// now update "ee_config"
483
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
484
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
485
+		EE_Config::log(EE_Config::OPTION_NAME);
486
+		// if not saved... check if the hook we just added still exists;
487
+		// if it does, it means one of two things:
488
+		// 		that update_option bailed at the ( $value === $old_value ) conditional,
489
+		//		 or...
490
+		// 		the db update query returned 0 rows affected
491
+		// 		(probably because the data  value was the same from it's perspective)
492
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
493
+		// but just means no update occurred, so don't display an error to the user.
494
+		// BUT... if update_option returns FALSE, AND the hook is missing,
495
+		// then it means that something truly went wrong
496
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
497
+		// remove our action since we don't want it in the system anymore
498
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
499
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
500
+		//self::$_instance = $clone;
501
+		//unset( $clone );
502
+		// if config remains the same or was updated successfully
503
+		if ($saved) {
504
+			if ($add_success) {
505
+				EE_Error::add_success(
506
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
507
+					__FILE__,
508
+					__FUNCTION__,
509
+					__LINE__
510
+				);
511
+			}
512
+			return true;
513
+		} else {
514
+			if ($add_error) {
515
+				EE_Error::add_error(
516
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
517
+					__FILE__,
518
+					__FUNCTION__,
519
+					__LINE__
520
+				);
521
+			}
522
+			return false;
523
+		}
524
+	}
525
+
526
+
527
+
528
+	/**
529
+	 *    _verify_config_params
530
+	 *
531
+	 * @access    private
532
+	 * @param    string         $section
533
+	 * @param    string         $name
534
+	 * @param    string         $config_class
535
+	 * @param    EE_Config_Base $config_obj
536
+	 * @param    array          $tests_to_run
537
+	 * @param    bool           $display_errors
538
+	 * @return    bool    TRUE on success, FALSE on fail
539
+	 */
540
+	private function _verify_config_params(
541
+		$section = '',
542
+		$name = '',
543
+		$config_class = '',
544
+		$config_obj = null,
545
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
+		$display_errors = true
547
+	) {
548
+		try {
549
+			foreach ($tests_to_run as $test) {
550
+				switch ($test) {
551
+					// TEST #1 : check that section was set
552
+					case 1 :
553
+						if (empty($section)) {
554
+							if ($display_errors) {
555
+								throw new EE_Error(
556
+									sprintf(
557
+										__(
558
+											'No configuration section has been provided while attempting to save "%s".',
559
+											'event_espresso'
560
+										),
561
+										$config_class
562
+									)
563
+								);
564
+							}
565
+							return false;
566
+						}
567
+						break;
568
+					// TEST #2 : check that settings section exists
569
+					case 2 :
570
+						if (! isset($this->{$section})) {
571
+							if ($display_errors) {
572
+								throw new EE_Error(
573
+									sprintf(
574
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
575
+										$section
576
+									)
577
+								);
578
+							}
579
+							return false;
580
+						}
581
+						break;
582
+					// TEST #3 : check that section is the proper format
583
+					case 3 :
584
+						if (
585
+						! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
+						) {
587
+							if ($display_errors) {
588
+								throw new EE_Error(
589
+									sprintf(
590
+										__(
591
+											'The "%s" configuration settings have not been formatted correctly.',
592
+											'event_espresso'
593
+										),
594
+										$section
595
+									)
596
+								);
597
+							}
598
+							return false;
599
+						}
600
+						break;
601
+					// TEST #4 : check that config section name has been set
602
+					case 4 :
603
+						if (empty($name)) {
604
+							if ($display_errors) {
605
+								throw new EE_Error(
606
+									__(
607
+										'No name has been provided for the specific configuration section.',
608
+										'event_espresso'
609
+									)
610
+								);
611
+							}
612
+							return false;
613
+						}
614
+						break;
615
+					// TEST #5 : check that a config class name has been set
616
+					case 5 :
617
+						if (empty($config_class)) {
618
+							if ($display_errors) {
619
+								throw new EE_Error(
620
+									__(
621
+										'No class name has been provided for the specific configuration section.',
622
+										'event_espresso'
623
+									)
624
+								);
625
+							}
626
+							return false;
627
+						}
628
+						break;
629
+					// TEST #6 : verify config class is accessible
630
+					case 6 :
631
+						if (! class_exists($config_class)) {
632
+							if ($display_errors) {
633
+								throw new EE_Error(
634
+									sprintf(
635
+										__(
636
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
+											'event_espresso'
638
+										),
639
+										$config_class
640
+									)
641
+								);
642
+							}
643
+							return false;
644
+						}
645
+						break;
646
+					// TEST #7 : check that config has even been set
647
+					case 7 :
648
+						if (! isset($this->{$section}->{$name})) {
649
+							if ($display_errors) {
650
+								throw new EE_Error(
651
+									sprintf(
652
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
+										$section,
654
+										$name
655
+									)
656
+								);
657
+							}
658
+							return false;
659
+						} else {
660
+							// and make sure it's not serialized
661
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
+						}
663
+						break;
664
+					// TEST #8 : check that config is the requested type
665
+					case 8 :
666
+						if (! $this->{$section}->{$name} instanceof $config_class) {
667
+							if ($display_errors) {
668
+								throw new EE_Error(
669
+									sprintf(
670
+										__(
671
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
+											'event_espresso'
673
+										),
674
+										$section,
675
+										$name,
676
+										$config_class
677
+									)
678
+								);
679
+							}
680
+							return false;
681
+						}
682
+						break;
683
+					// TEST #9 : verify config object
684
+					case 9 :
685
+						if (! $config_obj instanceof EE_Config_Base) {
686
+							if ($display_errors) {
687
+								throw new EE_Error(
688
+									sprintf(
689
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
+										print_r($config_obj, true)
691
+									)
692
+								);
693
+							}
694
+							return false;
695
+						}
696
+						break;
697
+				}
698
+			}
699
+		} catch (EE_Error $e) {
700
+			$e->get_error();
701
+		}
702
+		// you have successfully run the gauntlet
703
+		return true;
704
+	}
705
+
706
+
707
+
708
+	/**
709
+	 *    _generate_config_option_name
710
+	 *
711
+	 * @access        protected
712
+	 * @param        string $section
713
+	 * @param        string $name
714
+	 * @return        string
715
+	 */
716
+	private function _generate_config_option_name($section = '', $name = '')
717
+	{
718
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
+	}
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
+	/**
742
+	 *    set_config
743
+	 *
744
+	 * @access    protected
745
+	 * @param    string         $section
746
+	 * @param    string         $name
747
+	 * @param    string         $config_class
748
+	 * @param    EE_Config_Base $config_obj
749
+	 * @return    EE_Config_Base
750
+	 */
751
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
752
+	{
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
+			update_option($config_option_name, $config_obj);
772
+			$this->{$section}->{$name} = $config_obj;
773
+			return $this->{$section}->{$name};
774
+		} else {
775
+			// create a wp-option for this config
776
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
777
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
778
+				return $this->{$section}->{$name};
779
+			} else {
780
+				EE_Error::add_error(
781
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
782
+					__FILE__,
783
+					__FUNCTION__,
784
+					__LINE__
785
+				);
786
+				return null;
787
+			}
788
+		}
789
+	}
790
+
791
+
792
+
793
+	/**
794
+	 *    update_config
795
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
796
+	 *
797
+	 * @access    public
798
+	 * @param    string                $section
799
+	 * @param    string                $name
800
+	 * @param    EE_Config_Base|string $config_obj
801
+	 * @param    bool                  $throw_errors
802
+	 * @return    bool
803
+	 */
804
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
805
+	{
806
+		// don't allow config updates during WP heartbeats
807
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
808
+			return false;
809
+		}
810
+		$config_obj = maybe_unserialize($config_obj);
811
+		// get class name of the incoming object
812
+		$config_class = get_class($config_obj);
813
+		// run tests 1-5 and 9 to verify config
814
+		if (! $this->_verify_config_params(
815
+			$section,
816
+			$name,
817
+			$config_class,
818
+			$config_obj,
819
+			array(1, 2, 3, 4, 7, 9)
820
+		)
821
+		) {
822
+			return false;
823
+		}
824
+		$config_option_name = $this->_generate_config_option_name($section, $name);
825
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
+		if (! isset($this->_addon_option_names[$config_option_name])) {
827
+			// save new config to db
828
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
+				return true;
830
+			}
831
+		} else {
832
+			// first check if the record already exists
833
+			$existing_config = get_option($config_option_name);
834
+			$config_obj = serialize($config_obj);
835
+			// just return if db record is already up to date (NOT type safe comparison)
836
+			if ($existing_config == $config_obj) {
837
+				$this->{$section}->{$name} = $config_obj;
838
+				return true;
839
+			} else if (update_option($config_option_name, $config_obj)) {
840
+				EE_Config::log($config_option_name);
841
+				// update wp-option for this config class
842
+				$this->{$section}->{$name} = $config_obj;
843
+				return true;
844
+			} elseif ($throw_errors) {
845
+				EE_Error::add_error(
846
+					sprintf(
847
+						__(
848
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
+							'event_espresso'
850
+						),
851
+						$config_class,
852
+						'EE_Config->' . $section . '->' . $name
853
+					),
854
+					__FILE__,
855
+					__FUNCTION__,
856
+					__LINE__
857
+				);
858
+			}
859
+		}
860
+		return false;
861
+	}
862
+
863
+
864
+
865
+	/**
866
+	 *    get_config
867
+	 *
868
+	 * @access    public
869
+	 * @param    string $section
870
+	 * @param    string $name
871
+	 * @param    string $config_class
872
+	 * @return    mixed EE_Config_Base | NULL
873
+	 */
874
+	public function get_config($section = '', $name = '', $config_class = '')
875
+	{
876
+		// ensure config class is set to something
877
+		$config_class = $this->_set_config_class($config_class, $name);
878
+		// run tests 1-4, 6 and 7 to verify that all params have been set
879
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
880
+			return null;
881
+		}
882
+		// now test if the requested config object exists, but suppress errors
883
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
884
+			// config already exists, so pass it back
885
+			return $this->{$section}->{$name};
886
+		}
887
+		// load config option from db if it exists
888
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
889
+		// verify the newly retrieved config object, but suppress errors
890
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
891
+			// config is good, so set it and pass it back
892
+			$this->{$section}->{$name} = $config_obj;
893
+			return $this->{$section}->{$name};
894
+		}
895
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
896
+		$config_obj = $this->set_config($section, $name, $config_class);
897
+		// verify the newly created config object
898
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
899
+			return $this->{$section}->{$name};
900
+		} else {
901
+			EE_Error::add_error(
902
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
903
+				__FILE__,
904
+				__FUNCTION__,
905
+				__LINE__
906
+			);
907
+		}
908
+		return null;
909
+	}
910
+
911
+
912
+
913
+	/**
914
+	 *    get_config_option
915
+	 *
916
+	 * @access    public
917
+	 * @param    string $config_option_name
918
+	 * @return    mixed EE_Config_Base | FALSE
919
+	 */
920
+	public function get_config_option($config_option_name = '')
921
+	{
922
+		// retrieve the wp-option for this config class.
923
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
924
+		if (empty($config_option)) {
925
+			EE_Config::log($config_option_name . '-NOT-FOUND');
926
+		}
927
+		return $config_option;
928
+	}
929
+
930
+
931
+
932
+	/**
933
+	 * log
934
+	 *
935
+	 * @param string $config_option_name
936
+	 */
937
+	public static function log($config_option_name = '')
938
+	{
939
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
940
+			$config_log = get_option(EE_Config::LOG_NAME, array());
941
+			//copy incoming $_REQUEST and sanitize it so we can save it
942
+			$_request = $_REQUEST;
943
+			array_walk_recursive($_request, 'sanitize_text_field');
944
+			$config_log[(string)microtime(true)] = array(
945
+				'config_name' => $config_option_name,
946
+				'request'     => $_request,
947
+			);
948
+			update_option(EE_Config::LOG_NAME, $config_log);
949
+		}
950
+	}
951
+
952
+
953
+
954
+	/**
955
+	 * trim_log
956
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
957
+	 */
958
+	public static function trim_log()
959
+	{
960
+		if (! EE_Config::logging_enabled()) {
961
+			return;
962
+		}
963
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
964
+		$log_length = count($config_log);
965
+		if ($log_length > EE_Config::LOG_LENGTH) {
966
+			ksort($config_log);
967
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
968
+			update_option(EE_Config::LOG_NAME, $config_log);
969
+		}
970
+	}
971
+
972
+
973
+
974
+	/**
975
+	 *    get_page_for_posts
976
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
977
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
978
+	 *
979
+	 * @access    public
980
+	 * @return    string
981
+	 */
982
+	public static function get_page_for_posts()
983
+	{
984
+		$page_for_posts = get_option('page_for_posts');
985
+		if (! $page_for_posts) {
986
+			return 'posts';
987
+		}
988
+		/** @type WPDB $wpdb */
989
+		global $wpdb;
990
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
991
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
992
+	}
993
+
994
+
995
+
996
+	/**
997
+	 *    register_shortcodes_and_modules.
998
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
999
+	 *    In fact, this is where we give modules a chance to let core know they exist
1000
+	 *    so they can help trigger maintenance mode if it's needed
1001
+	 *
1002
+	 * @access    public
1003
+	 * @return    void
1004
+	 */
1005
+	public function register_shortcodes_and_modules()
1006
+	{
1007
+		// allow modules to set hooks for the rest of the system
1008
+		EE_Registry::instance()->modules = $this->_register_modules();
1009
+	}
1010
+
1011
+
1012
+
1013
+	/**
1014
+	 *    initialize_shortcodes_and_modules
1015
+	 *    meaning they can start adding their hooks to get stuff done
1016
+	 *
1017
+	 * @access    public
1018
+	 * @return    void
1019
+	 */
1020
+	public function initialize_shortcodes_and_modules()
1021
+	{
1022
+		// allow modules to set hooks for the rest of the system
1023
+		$this->_initialize_modules();
1024
+	}
1025
+
1026
+
1027
+
1028
+	/**
1029
+	 *    widgets_init
1030
+	 *
1031
+	 * @access private
1032
+	 * @return void
1033
+	 */
1034
+	public function widgets_init()
1035
+	{
1036
+		//only init widgets on admin pages when not in complete maintenance, and
1037
+		//on frontend when not in any maintenance mode
1038
+		if (
1039
+			! EE_Maintenance_Mode::instance()->level()
1040
+			|| (
1041
+				is_admin()
1042
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1043
+			)
1044
+		) {
1045
+			// grab list of installed widgets
1046
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1047
+			// filter list of modules to register
1048
+			$widgets_to_register = apply_filters(
1049
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1050
+				$widgets_to_register
1051
+			);
1052
+			if (! empty($widgets_to_register)) {
1053
+				// cycle thru widget folders
1054
+				foreach ($widgets_to_register as $widget_path) {
1055
+					// add to list of installed widget modules
1056
+					EE_Config::register_ee_widget($widget_path);
1057
+				}
1058
+			}
1059
+			// filter list of installed modules
1060
+			EE_Registry::instance()->widgets = apply_filters(
1061
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1062
+				EE_Registry::instance()->widgets
1063
+			);
1064
+		}
1065
+	}
1066
+
1067
+
1068
+
1069
+	/**
1070
+	 *    register_ee_widget - makes core aware of this widget
1071
+	 *
1072
+	 * @access    public
1073
+	 * @param    string $widget_path - full path up to and including widget folder
1074
+	 * @return    void
1075
+	 */
1076
+	public static function register_ee_widget($widget_path = null)
1077
+	{
1078
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1079
+		$widget_ext = '.widget.php';
1080
+		// make all separators match
1081
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1082
+		// does the file path INCLUDE the actual file name as part of the path ?
1083
+		if (strpos($widget_path, $widget_ext) !== false) {
1084
+			// grab and shortcode file name from directory name and break apart at dots
1085
+			$file_name = explode('.', basename($widget_path));
1086
+			// take first segment from file name pieces and remove class prefix if it exists
1087
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1088
+			// sanitize shortcode directory name
1089
+			$widget = sanitize_key($widget);
1090
+			// now we need to rebuild the shortcode path
1091
+			$widget_path = explode(DS, $widget_path);
1092
+			// remove last segment
1093
+			array_pop($widget_path);
1094
+			// glue it back together
1095
+			$widget_path = implode(DS, $widget_path);
1096
+		} else {
1097
+			// grab and sanitize widget directory name
1098
+			$widget = sanitize_key(basename($widget_path));
1099
+		}
1100
+		// create classname from widget directory name
1101
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1102
+		// add class prefix
1103
+		$widget_class = 'EEW_' . $widget;
1104
+		// does the widget exist ?
1105
+		if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1106
+			$msg = sprintf(
1107
+				__(
1108
+					'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',
1109
+					'event_espresso'
1110
+				),
1111
+				$widget_class,
1112
+				$widget_path . DS . $widget_class . $widget_ext
1113
+			);
1114
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1115
+			return;
1116
+		}
1117
+		// load the widget class file
1118
+		require_once($widget_path . DS . $widget_class . $widget_ext);
1119
+		// verify that class exists
1120
+		if (! class_exists($widget_class)) {
1121
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1122
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1123
+			return;
1124
+		}
1125
+		register_widget($widget_class);
1126
+		// add to array of registered widgets
1127
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1128
+	}
1129
+
1130
+
1131
+
1132
+	/**
1133
+	 *        _register_modules
1134
+	 *
1135
+	 * @access private
1136
+	 * @return array
1137
+	 */
1138
+	private function _register_modules()
1139
+	{
1140
+		// grab list of installed modules
1141
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1142
+		// filter list of modules to register
1143
+		$modules_to_register = apply_filters(
1144
+			'FHEE__EE_Config__register_modules__modules_to_register',
1145
+			$modules_to_register
1146
+		);
1147
+		if (! empty($modules_to_register)) {
1148
+			// loop through folders
1149
+			foreach ($modules_to_register as $module_path) {
1150
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1151
+				if (
1152
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1153
+					&& $module_path !== EE_MODULES . 'gateways'
1154
+				) {
1155
+					// add to list of installed modules
1156
+					EE_Config::register_module($module_path);
1157
+				}
1158
+			}
1159
+		}
1160
+		// filter list of installed modules
1161
+		return apply_filters(
1162
+			'FHEE__EE_Config___register_modules__installed_modules',
1163
+			EE_Registry::instance()->modules
1164
+		);
1165
+	}
1166
+
1167
+
1168
+
1169
+	/**
1170
+	 *    register_module - makes core aware of this module
1171
+	 *
1172
+	 * @access    public
1173
+	 * @param    string $module_path - full path up to and including module folder
1174
+	 * @return    bool
1175
+	 */
1176
+	public static function register_module($module_path = null)
1177
+	{
1178
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1179
+		$module_ext = '.module.php';
1180
+		// make all separators match
1181
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1182
+		// does the file path INCLUDE the actual file name as part of the path ?
1183
+		if (strpos($module_path, $module_ext) !== false) {
1184
+			// grab and shortcode file name from directory name and break apart at dots
1185
+			$module_file = explode('.', basename($module_path));
1186
+			// now we need to rebuild the shortcode path
1187
+			$module_path = explode(DS, $module_path);
1188
+			// remove last segment
1189
+			array_pop($module_path);
1190
+			// glue it back together
1191
+			$module_path = implode(DS, $module_path) . DS;
1192
+			// take first segment from file name pieces and sanitize it
1193
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1194
+			// ensure class prefix is added
1195
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1196
+		} else {
1197
+			// we need to generate the filename based off of the folder name
1198
+			// grab and sanitize module name
1199
+			$module = strtolower(basename($module_path));
1200
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1201
+			// like trailingslashit()
1202
+			$module_path = rtrim($module_path, DS) . DS;
1203
+			// create classname from module directory name
1204
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1205
+			// add class prefix
1206
+			$module_class = 'EED_' . $module;
1207
+		}
1208
+		// does the module exist ?
1209
+		if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1210
+			$msg = sprintf(
1211
+				__(
1212
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1213
+					'event_espresso'
1214
+				),
1215
+				$module
1216
+			);
1217
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1218
+			return false;
1219
+		}
1220
+		// load the module class file
1221
+		require_once($module_path . $module_class . $module_ext);
1222
+		// verify that class exists
1223
+		if (! class_exists($module_class)) {
1224
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1225
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1226
+			return false;
1227
+		}
1228
+		// add to array of registered modules
1229
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1230
+		do_action(
1231
+			'AHEE__EE_Config__register_module__complete',
1232
+			$module_class,
1233
+			EE_Registry::instance()->modules->{$module_class}
1234
+		);
1235
+		return true;
1236
+	}
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()) {
1254
+				// fire immediately
1255
+				call_user_func(array($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
+	/**
1269
+	 *    register_route - adds module method routes to route_map
1270
+	 *
1271
+	 * @access    public
1272
+	 * @param    string $route       - "pretty" public alias for module method
1273
+	 * @param    string $module      - module name (classname without EED_ prefix)
1274
+	 * @param    string $method_name - the actual module method to be routed to
1275
+	 * @param    string $key         - url param key indicating a route is being called
1276
+	 * @return    bool
1277
+	 */
1278
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1279
+	{
1280
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1281
+		$module = str_replace('EED_', '', $module);
1282
+		$module_class = 'EED_' . $module;
1283
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1284
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1285
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1286
+			return false;
1287
+		}
1288
+		if (empty($route)) {
1289
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1290
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
+			return false;
1292
+		}
1293
+		if (! method_exists('EED_' . $module, $method_name)) {
1294
+			$msg = sprintf(
1295
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1296
+				$route
1297
+			);
1298
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1299
+			return false;
1300
+		}
1301
+		EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1302
+		return true;
1303
+	}
1304
+
1305
+
1306
+
1307
+	/**
1308
+	 *    get_route - get module method route
1309
+	 *
1310
+	 * @access    public
1311
+	 * @param    string $route - "pretty" public alias for module method
1312
+	 * @param    string $key   - url param key indicating a route is being called
1313
+	 * @return    string
1314
+	 */
1315
+	public static function get_route($route = null, $key = 'ee')
1316
+	{
1317
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1318
+		$route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1319
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1320
+			return EE_Config::$_module_route_map[$key][$route];
1321
+		}
1322
+		return null;
1323
+	}
1324
+
1325
+
1326
+
1327
+	/**
1328
+	 *    get_routes - get ALL module method routes
1329
+	 *
1330
+	 * @access    public
1331
+	 * @return    array
1332
+	 */
1333
+	public static function get_routes()
1334
+	{
1335
+		return EE_Config::$_module_route_map;
1336
+	}
1337
+
1338
+
1339
+
1340
+	/**
1341
+	 *    register_forward - allows modules to forward request to another module for further processing
1342
+	 *
1343
+	 * @access    public
1344
+	 * @param    string       $route   - "pretty" public alias for module method
1345
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1346
+	 *                                 class, allows different forwards to be served based on status
1347
+	 * @param    array|string $forward - function name or array( class, method )
1348
+	 * @param    string       $key     - url param key indicating a route is being called
1349
+	 * @return    bool
1350
+	 */
1351
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1352
+	{
1353
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1354
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1355
+			$msg = sprintf(
1356
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1357
+				$route
1358
+			);
1359
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
+			return false;
1361
+		}
1362
+		if (empty($forward)) {
1363
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1364
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
+			return false;
1366
+		}
1367
+		if (is_array($forward)) {
1368
+			if (! isset($forward[1])) {
1369
+				$msg = sprintf(
1370
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1371
+					$route
1372
+				);
1373
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
+				return false;
1375
+			}
1376
+			if (! method_exists($forward[0], $forward[1])) {
1377
+				$msg = sprintf(
1378
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1379
+					$forward[1],
1380
+					$route
1381
+				);
1382
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1383
+				return false;
1384
+			}
1385
+		} else if (! function_exists($forward)) {
1386
+			$msg = sprintf(
1387
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1388
+				$forward,
1389
+				$route
1390
+			);
1391
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1392
+			return false;
1393
+		}
1394
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1395
+		return true;
1396
+	}
1397
+
1398
+
1399
+
1400
+	/**
1401
+	 *    get_forward - get forwarding route
1402
+	 *
1403
+	 * @access    public
1404
+	 * @param    string  $route  - "pretty" public alias for module method
1405
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1406
+	 *                           allows different forwards to be served based on status
1407
+	 * @param    string  $key    - url param key indicating a route is being called
1408
+	 * @return    string
1409
+	 */
1410
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1411
+	{
1412
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1413
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1414
+			return apply_filters(
1415
+				'FHEE__EE_Config__get_forward',
1416
+				EE_Config::$_module_forward_map[$key][$route][$status],
1417
+				$route,
1418
+				$status
1419
+			);
1420
+		}
1421
+		return null;
1422
+	}
1423
+
1424
+
1425
+
1426
+	/**
1427
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1428
+	 *    results
1429
+	 *
1430
+	 * @access    public
1431
+	 * @param    string  $route  - "pretty" public alias for module method
1432
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1433
+	 *                           allows different views to be served based on status
1434
+	 * @param    string  $view
1435
+	 * @param    string  $key    - url param key indicating a route is being called
1436
+	 * @return    bool
1437
+	 */
1438
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1439
+	{
1440
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1441
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1442
+			$msg = sprintf(
1443
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1444
+				$route
1445
+			);
1446
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1447
+			return false;
1448
+		}
1449
+		if (! is_readable($view)) {
1450
+			$msg = sprintf(
1451
+				__(
1452
+					'The %s view file could not be found or is not readable due to file permissions.',
1453
+					'event_espresso'
1454
+				),
1455
+				$view
1456
+			);
1457
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1458
+			return false;
1459
+		}
1460
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1461
+		return true;
1462
+	}
1463
+
1464
+
1465
+
1466
+	/**
1467
+	 *    get_view - get view for route and status
1468
+	 *
1469
+	 * @access    public
1470
+	 * @param    string  $route  - "pretty" public alias for module method
1471
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1472
+	 *                           allows different views to be served based on status
1473
+	 * @param    string  $key    - url param key indicating a route is being called
1474
+	 * @return    string
1475
+	 */
1476
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1477
+	{
1478
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1479
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1480
+			return apply_filters(
1481
+				'FHEE__EE_Config__get_view',
1482
+				EE_Config::$_module_view_map[$key][$route][$status],
1483
+				$route,
1484
+				$status
1485
+			);
1486
+		}
1487
+		return null;
1488
+	}
1489
+
1490
+
1491
+
1492
+	public function update_addon_option_names()
1493
+	{
1494
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1495
+	}
1496
+
1497
+
1498
+
1499
+	public function shutdown()
1500
+	{
1501
+		$this->update_addon_option_names();
1502
+	}
1503
+
1504
+
1505
+
1506
+	/**
1507
+	 * @return LegacyShortcodesManager
1508
+	 */
1509
+	public static function getLegacyShortcodesManager()
1510
+	{
1511
+
1512
+		if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1513
+			EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1514
+				EE_Registry::instance()
1515
+			);
1516
+		}
1517
+		return EE_Config::instance()->legacy_shortcodes_manager;
1518
+	}
1519
+
1520
+
1521
+
1522
+	/**
1523
+	 * register_shortcode - makes core aware of this shortcode
1524
+	 *
1525
+	 * @deprecated 4.9.26
1526
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1527
+	 * @return    bool
1528
+	 */
1529
+	public static function register_shortcode($shortcode_path = null)
1530
+	{
1531
+		EE_Error::doing_it_wrong(
1532
+			__METHOD__,
1533
+			__(
1534
+				'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.',
1535
+				'event_espresso'
1536
+			),
1537
+			'4.9.26'
1538
+		);
1539
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1540
+	}
21 1541
 
22
-    const LOG_NAME           = 'ee_config_log';
23 1542
 
24
-    const LOG_LENGTH         = 100;
25 1543
 
26
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
27
-
28
-
29
-    /**
30
-     *    instance of the EE_Config object
31
-     *
32
-     * @var    EE_Config $_instance
33
-     * @access    private
34
-     */
35
-    private static $_instance;
36
-
37
-    /**
38
-     * @var boolean $_logging_enabled
39
-     */
40
-    private static $_logging_enabled = false;
41
-
42
-    /**
43
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
44
-     */
45
-    private $legacy_shortcodes_manager;
46
-
47
-    /**
48
-     * An StdClass whose property names are addon slugs,
49
-     * and values are their config classes
50
-     *
51
-     * @var StdClass
52
-     */
53
-    public $addons;
54
-
55
-    /**
56
-     * @var EE_Admin_Config
57
-     */
58
-    public $admin;
59
-
60
-    /**
61
-     * @var EE_Core_Config
62
-     */
63
-    public $core;
64
-
65
-    /**
66
-     * @var EE_Currency_Config
67
-     */
68
-    public $currency;
69
-
70
-    /**
71
-     * @var EE_Organization_Config
72
-     */
73
-    public $organization;
74
-
75
-    /**
76
-     * @var EE_Registration_Config
77
-     */
78
-    public $registration;
79
-
80
-    /**
81
-     * @var EE_Template_Config
82
-     */
83
-    public $template_settings;
84
-
85
-    /**
86
-     * Holds EE environment values.
87
-     *
88
-     * @var EE_Environment_Config
89
-     */
90
-    public $environment;
91
-
92
-    /**
93
-     * settings pertaining to Google maps
94
-     *
95
-     * @var EE_Map_Config
96
-     */
97
-    public $map_settings;
98
-
99
-    /**
100
-     * settings pertaining to Taxes
101
-     *
102
-     * @var EE_Tax_Config
103
-     */
104
-    public $tax_settings;
105
-
106
-
107
-    /**
108
-     * Settings pertaining to global messages settings.
109
-     *
110
-     * @var EE_Messages_Config
111
-     */
112
-    public $messages;
113
-
114
-    /**
115
-     * @deprecated
116
-     * @var EE_Gateway_Config
117
-     */
118
-    public $gateway;
119
-
120
-    /**
121
-     * @var    array $_addon_option_names
122
-     * @access    private
123
-     */
124
-    private $_addon_option_names = array();
125
-
126
-    /**
127
-     * @var    array $_module_route_map
128
-     * @access    private
129
-     */
130
-    private static $_module_route_map = array();
131
-
132
-    /**
133
-     * @var    array $_module_forward_map
134
-     * @access    private
135
-     */
136
-    private static $_module_forward_map = array();
137
-
138
-    /**
139
-     * @var    array $_module_view_map
140
-     * @access    private
141
-     */
142
-    private static $_module_view_map = array();
143
-
144
-
145
-
146
-    /**
147
-     * @singleton method used to instantiate class object
148
-     * @access    public
149
-     * @return EE_Config instance
150
-     */
151
-    public static function instance()
152
-    {
153
-        // check if class object is instantiated, and instantiated properly
154
-        if (! self::$_instance instanceof EE_Config) {
155
-            self::$_instance = new self();
156
-        }
157
-        return self::$_instance;
158
-    }
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
-        //we don't need to reset the static properties imo because those should
187
-        //only change when a module is added or removed. Currently we don't
188
-        //support removing a module during a request when it previously existed
189
-        if ($reinstantiate) {
190
-            return self::instance();
191
-        } else {
192
-            return null;
193
-        }
194
-    }
195
-
196
-
197
-
198
-    /**
199
-     *    class constructor
200
-     *
201
-     * @access    private
202
-     */
203
-    private function __construct()
204
-    {
205
-        do_action('AHEE__EE_Config__construct__begin', $this);
206
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
207
-        // setup empty config classes
208
-        $this->_initialize_config();
209
-        // load existing EE site settings
210
-        $this->_load_core_config();
211
-        // confirm everything loaded correctly and set filtered defaults if not
212
-        $this->_verify_config();
213
-        //  register shortcodes and modules
214
-        add_action(
215
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
216
-            array($this, 'register_shortcodes_and_modules'),
217
-            999
218
-        );
219
-        //  initialize shortcodes and modules
220
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
221
-        // register widgets
222
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
223
-        // shutdown
224
-        add_action('shutdown', array($this, 'shutdown'), 10);
225
-        // construct__end hook
226
-        do_action('AHEE__EE_Config__construct__end', $this);
227
-        // hardcoded hack
228
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
229
-    }
230
-
231
-
232
-
233
-    /**
234
-     * @return boolean
235
-     */
236
-    public static function logging_enabled()
237
-    {
238
-        return self::$_logging_enabled;
239
-    }
240
-
241
-
242
-
243
-    /**
244
-     * use to get the current theme if needed from static context
245
-     *
246
-     * @return string current theme set.
247
-     */
248
-    public static function get_current_theme()
249
-    {
250
-        return isset(self::$_instance->template_settings->current_espresso_theme)
251
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
252
-    }
253
-
254
-
255
-
256
-    /**
257
-     *        _initialize_config
258
-     *
259
-     * @access private
260
-     * @return void
261
-     */
262
-    private function _initialize_config()
263
-    {
264
-        EE_Config::trim_log();
265
-        //set defaults
266
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
267
-        $this->addons = new stdClass();
268
-        // set _module_route_map
269
-        EE_Config::$_module_route_map = array();
270
-        // set _module_forward_map
271
-        EE_Config::$_module_forward_map = array();
272
-        // set _module_view_map
273
-        EE_Config::$_module_view_map = array();
274
-    }
275
-
276
-
277
-
278
-    /**
279
-     *        load core plugin configuration
280
-     *
281
-     * @access private
282
-     * @return void
283
-     */
284
-    private function _load_core_config()
285
-    {
286
-        // load_core_config__start hook
287
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
288
-        $espresso_config = $this->get_espresso_config();
289
-        foreach ($espresso_config as $config => $settings) {
290
-            // load_core_config__start hook
291
-            $settings = apply_filters(
292
-                'FHEE__EE_Config___load_core_config__config_settings',
293
-                $settings,
294
-                $config,
295
-                $this
296
-            );
297
-            if (is_object($settings) && property_exists($this, $config)) {
298
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
299
-                //call configs populate method to ensure any defaults are set for empty values.
300
-                if (method_exists($settings, 'populate')) {
301
-                    $this->{$config}->populate();
302
-                }
303
-                if (method_exists($settings, 'do_hooks')) {
304
-                    $this->{$config}->do_hooks();
305
-                }
306
-            }
307
-        }
308
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
309
-            $this->update_espresso_config();
310
-        }
311
-        // load_core_config__end hook
312
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
313
-    }
314
-
315
-
316
-
317
-    /**
318
-     *    _verify_config
319
-     *
320
-     * @access    protected
321
-     * @return    void
322
-     */
323
-    protected function _verify_config()
324
-    {
325
-        $this->core = $this->core instanceof EE_Core_Config
326
-            ? $this->core
327
-            : new EE_Core_Config();
328
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
329
-        $this->organization = $this->organization instanceof EE_Organization_Config
330
-            ? $this->organization
331
-            : new EE_Organization_Config();
332
-        $this->organization = apply_filters(
333
-            'FHEE__EE_Config___initialize_config__organization',
334
-            $this->organization
335
-        );
336
-        $this->currency = $this->currency instanceof EE_Currency_Config
337
-            ? $this->currency
338
-            : new EE_Currency_Config();
339
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
340
-        $this->registration = $this->registration instanceof EE_Registration_Config
341
-            ? $this->registration
342
-            : new EE_Registration_Config();
343
-        $this->registration = apply_filters(
344
-            'FHEE__EE_Config___initialize_config__registration',
345
-            $this->registration
346
-        );
347
-        $this->admin = $this->admin instanceof EE_Admin_Config
348
-            ? $this->admin
349
-            : new EE_Admin_Config();
350
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
351
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
352
-            ? $this->template_settings
353
-            : new EE_Template_Config();
354
-        $this->template_settings = apply_filters(
355
-            'FHEE__EE_Config___initialize_config__template_settings',
356
-            $this->template_settings
357
-        );
358
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
359
-            ? $this->map_settings
360
-            : new EE_Map_Config();
361
-        $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
362
-            $this->map_settings);
363
-        $this->environment = $this->environment instanceof EE_Environment_Config
364
-            ? $this->environment
365
-            : new EE_Environment_Config();
366
-        $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
367
-            $this->environment);
368
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
369
-            ? $this->tax_settings
370
-            : new EE_Tax_Config();
371
-        $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
372
-            $this->tax_settings);
373
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
374
-        $this->messages = $this->messages instanceof EE_Messages_Config
375
-            ? $this->messages
376
-            : new EE_Messages_Config();
377
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
378
-            ? $this->gateway
379
-            : new EE_Gateway_Config();
380
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
381
-        $this->legacy_shortcodes_manager = null;
382
-    }
383
-
384
-
385
-    /**
386
-     *    get_espresso_config
387
-     *
388
-     * @access    public
389
-     * @return    array of espresso config stuff
390
-     */
391
-    public function get_espresso_config()
392
-    {
393
-        // grab espresso configuration
394
-        return apply_filters(
395
-            'FHEE__EE_Config__get_espresso_config__CFG',
396
-            get_option(EE_Config::OPTION_NAME, array())
397
-        );
398
-    }
399
-
400
-
401
-
402
-    /**
403
-     *    double_check_config_comparison
404
-     *
405
-     * @access    public
406
-     * @param string $option
407
-     * @param        $old_value
408
-     * @param        $value
409
-     */
410
-    public function double_check_config_comparison($option = '', $old_value, $value)
411
-    {
412
-        // make sure we're checking the ee config
413
-        if ($option === EE_Config::OPTION_NAME) {
414
-            // run a loose comparison of the old value against the new value for type and properties,
415
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
416
-            if ($value != $old_value) {
417
-                // if they are NOT the same, then remove the hook,
418
-                // which means the subsequent update results will be based solely on the update query results
419
-                // the reason we do this is because, as stated above,
420
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
421
-                // this happens PRIOR to serialization and any subsequent update.
422
-                // If values are found to match their previous old value,
423
-                // then WP bails before performing any update.
424
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
425
-                // it just pulled from the db, with the one being passed to it (which will not match).
426
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
427
-                // MySQL MAY ALSO NOT perform the update because
428
-                // the string it sees in the db looks the same as the new one it has been passed!!!
429
-                // This results in the query returning an "affected rows" value of ZERO,
430
-                // which gets returned immediately by WP update_option and looks like an error.
431
-                remove_action('update_option', array($this, 'check_config_updated'));
432
-            }
433
-        }
434
-    }
435
-
436
-
437
-
438
-    /**
439
-     *    update_espresso_config
440
-     *
441
-     * @access   public
442
-     */
443
-    protected function _reset_espresso_addon_config()
444
-    {
445
-        $this->_addon_option_names = array();
446
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
447
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
448
-            if ($addon_config_obj instanceof EE_Config_Base) {
449
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
450
-            }
451
-            $this->addons->{$addon_name} = null;
452
-        }
453
-    }
454
-
455
-
456
-
457
-    /**
458
-     *    update_espresso_config
459
-     *
460
-     * @access   public
461
-     * @param   bool $add_success
462
-     * @param   bool $add_error
463
-     * @return   bool
464
-     */
465
-    public function update_espresso_config($add_success = false, $add_error = true)
466
-    {
467
-        // don't allow config updates during WP heartbeats
468
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
469
-            return false;
470
-        }
471
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
472
-        //$clone = clone( self::$_instance );
473
-        //self::$_instance = NULL;
474
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
475
-        $this->_reset_espresso_addon_config();
476
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
477
-        // but BEFORE the actual update occurs
478
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
479
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
480
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
481
-        $this->legacy_shortcodes_manager = null;
482
-        // now update "ee_config"
483
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
484
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
485
-        EE_Config::log(EE_Config::OPTION_NAME);
486
-        // if not saved... check if the hook we just added still exists;
487
-        // if it does, it means one of two things:
488
-        // 		that update_option bailed at the ( $value === $old_value ) conditional,
489
-        //		 or...
490
-        // 		the db update query returned 0 rows affected
491
-        // 		(probably because the data  value was the same from it's perspective)
492
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
493
-        // but just means no update occurred, so don't display an error to the user.
494
-        // BUT... if update_option returns FALSE, AND the hook is missing,
495
-        // then it means that something truly went wrong
496
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
497
-        // remove our action since we don't want it in the system anymore
498
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
499
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
500
-        //self::$_instance = $clone;
501
-        //unset( $clone );
502
-        // if config remains the same or was updated successfully
503
-        if ($saved) {
504
-            if ($add_success) {
505
-                EE_Error::add_success(
506
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
507
-                    __FILE__,
508
-                    __FUNCTION__,
509
-                    __LINE__
510
-                );
511
-            }
512
-            return true;
513
-        } else {
514
-            if ($add_error) {
515
-                EE_Error::add_error(
516
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
517
-                    __FILE__,
518
-                    __FUNCTION__,
519
-                    __LINE__
520
-                );
521
-            }
522
-            return false;
523
-        }
524
-    }
525
-
526
-
527
-
528
-    /**
529
-     *    _verify_config_params
530
-     *
531
-     * @access    private
532
-     * @param    string         $section
533
-     * @param    string         $name
534
-     * @param    string         $config_class
535
-     * @param    EE_Config_Base $config_obj
536
-     * @param    array          $tests_to_run
537
-     * @param    bool           $display_errors
538
-     * @return    bool    TRUE on success, FALSE on fail
539
-     */
540
-    private function _verify_config_params(
541
-        $section = '',
542
-        $name = '',
543
-        $config_class = '',
544
-        $config_obj = null,
545
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
-        $display_errors = true
547
-    ) {
548
-        try {
549
-            foreach ($tests_to_run as $test) {
550
-                switch ($test) {
551
-                    // TEST #1 : check that section was set
552
-                    case 1 :
553
-                        if (empty($section)) {
554
-                            if ($display_errors) {
555
-                                throw new EE_Error(
556
-                                    sprintf(
557
-                                        __(
558
-                                            'No configuration section has been provided while attempting to save "%s".',
559
-                                            'event_espresso'
560
-                                        ),
561
-                                        $config_class
562
-                                    )
563
-                                );
564
-                            }
565
-                            return false;
566
-                        }
567
-                        break;
568
-                    // TEST #2 : check that settings section exists
569
-                    case 2 :
570
-                        if (! isset($this->{$section})) {
571
-                            if ($display_errors) {
572
-                                throw new EE_Error(
573
-                                    sprintf(
574
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
575
-                                        $section
576
-                                    )
577
-                                );
578
-                            }
579
-                            return false;
580
-                        }
581
-                        break;
582
-                    // TEST #3 : check that section is the proper format
583
-                    case 3 :
584
-                        if (
585
-                        ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
-                        ) {
587
-                            if ($display_errors) {
588
-                                throw new EE_Error(
589
-                                    sprintf(
590
-                                        __(
591
-                                            'The "%s" configuration settings have not been formatted correctly.',
592
-                                            'event_espresso'
593
-                                        ),
594
-                                        $section
595
-                                    )
596
-                                );
597
-                            }
598
-                            return false;
599
-                        }
600
-                        break;
601
-                    // TEST #4 : check that config section name has been set
602
-                    case 4 :
603
-                        if (empty($name)) {
604
-                            if ($display_errors) {
605
-                                throw new EE_Error(
606
-                                    __(
607
-                                        'No name has been provided for the specific configuration section.',
608
-                                        'event_espresso'
609
-                                    )
610
-                                );
611
-                            }
612
-                            return false;
613
-                        }
614
-                        break;
615
-                    // TEST #5 : check that a config class name has been set
616
-                    case 5 :
617
-                        if (empty($config_class)) {
618
-                            if ($display_errors) {
619
-                                throw new EE_Error(
620
-                                    __(
621
-                                        'No class name has been provided for the specific configuration section.',
622
-                                        'event_espresso'
623
-                                    )
624
-                                );
625
-                            }
626
-                            return false;
627
-                        }
628
-                        break;
629
-                    // TEST #6 : verify config class is accessible
630
-                    case 6 :
631
-                        if (! class_exists($config_class)) {
632
-                            if ($display_errors) {
633
-                                throw new EE_Error(
634
-                                    sprintf(
635
-                                        __(
636
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
-                                            'event_espresso'
638
-                                        ),
639
-                                        $config_class
640
-                                    )
641
-                                );
642
-                            }
643
-                            return false;
644
-                        }
645
-                        break;
646
-                    // TEST #7 : check that config has even been set
647
-                    case 7 :
648
-                        if (! isset($this->{$section}->{$name})) {
649
-                            if ($display_errors) {
650
-                                throw new EE_Error(
651
-                                    sprintf(
652
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
-                                        $section,
654
-                                        $name
655
-                                    )
656
-                                );
657
-                            }
658
-                            return false;
659
-                        } else {
660
-                            // and make sure it's not serialized
661
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
-                        }
663
-                        break;
664
-                    // TEST #8 : check that config is the requested type
665
-                    case 8 :
666
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
667
-                            if ($display_errors) {
668
-                                throw new EE_Error(
669
-                                    sprintf(
670
-                                        __(
671
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
-                                            'event_espresso'
673
-                                        ),
674
-                                        $section,
675
-                                        $name,
676
-                                        $config_class
677
-                                    )
678
-                                );
679
-                            }
680
-                            return false;
681
-                        }
682
-                        break;
683
-                    // TEST #9 : verify config object
684
-                    case 9 :
685
-                        if (! $config_obj instanceof EE_Config_Base) {
686
-                            if ($display_errors) {
687
-                                throw new EE_Error(
688
-                                    sprintf(
689
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
-                                        print_r($config_obj, true)
691
-                                    )
692
-                                );
693
-                            }
694
-                            return false;
695
-                        }
696
-                        break;
697
-                }
698
-            }
699
-        } catch (EE_Error $e) {
700
-            $e->get_error();
701
-        }
702
-        // you have successfully run the gauntlet
703
-        return true;
704
-    }
705
-
706
-
707
-
708
-    /**
709
-     *    _generate_config_option_name
710
-     *
711
-     * @access        protected
712
-     * @param        string $section
713
-     * @param        string $name
714
-     * @return        string
715
-     */
716
-    private function _generate_config_option_name($section = '', $name = '')
717
-    {
718
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
-    }
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
-    /**
742
-     *    set_config
743
-     *
744
-     * @access    protected
745
-     * @param    string         $section
746
-     * @param    string         $name
747
-     * @param    string         $config_class
748
-     * @param    EE_Config_Base $config_obj
749
-     * @return    EE_Config_Base
750
-     */
751
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
752
-    {
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
-            update_option($config_option_name, $config_obj);
772
-            $this->{$section}->{$name} = $config_obj;
773
-            return $this->{$section}->{$name};
774
-        } else {
775
-            // create a wp-option for this config
776
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
777
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
778
-                return $this->{$section}->{$name};
779
-            } else {
780
-                EE_Error::add_error(
781
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
782
-                    __FILE__,
783
-                    __FUNCTION__,
784
-                    __LINE__
785
-                );
786
-                return null;
787
-            }
788
-        }
789
-    }
790
-
791
-
792
-
793
-    /**
794
-     *    update_config
795
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
796
-     *
797
-     * @access    public
798
-     * @param    string                $section
799
-     * @param    string                $name
800
-     * @param    EE_Config_Base|string $config_obj
801
-     * @param    bool                  $throw_errors
802
-     * @return    bool
803
-     */
804
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
805
-    {
806
-        // don't allow config updates during WP heartbeats
807
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
808
-            return false;
809
-        }
810
-        $config_obj = maybe_unserialize($config_obj);
811
-        // get class name of the incoming object
812
-        $config_class = get_class($config_obj);
813
-        // run tests 1-5 and 9 to verify config
814
-        if (! $this->_verify_config_params(
815
-            $section,
816
-            $name,
817
-            $config_class,
818
-            $config_obj,
819
-            array(1, 2, 3, 4, 7, 9)
820
-        )
821
-        ) {
822
-            return false;
823
-        }
824
-        $config_option_name = $this->_generate_config_option_name($section, $name);
825
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
-        if (! isset($this->_addon_option_names[$config_option_name])) {
827
-            // save new config to db
828
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
-                return true;
830
-            }
831
-        } else {
832
-            // first check if the record already exists
833
-            $existing_config = get_option($config_option_name);
834
-            $config_obj = serialize($config_obj);
835
-            // just return if db record is already up to date (NOT type safe comparison)
836
-            if ($existing_config == $config_obj) {
837
-                $this->{$section}->{$name} = $config_obj;
838
-                return true;
839
-            } else if (update_option($config_option_name, $config_obj)) {
840
-                EE_Config::log($config_option_name);
841
-                // update wp-option for this config class
842
-                $this->{$section}->{$name} = $config_obj;
843
-                return true;
844
-            } elseif ($throw_errors) {
845
-                EE_Error::add_error(
846
-                    sprintf(
847
-                        __(
848
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
-                            'event_espresso'
850
-                        ),
851
-                        $config_class,
852
-                        'EE_Config->' . $section . '->' . $name
853
-                    ),
854
-                    __FILE__,
855
-                    __FUNCTION__,
856
-                    __LINE__
857
-                );
858
-            }
859
-        }
860
-        return false;
861
-    }
862
-
863
-
864
-
865
-    /**
866
-     *    get_config
867
-     *
868
-     * @access    public
869
-     * @param    string $section
870
-     * @param    string $name
871
-     * @param    string $config_class
872
-     * @return    mixed EE_Config_Base | NULL
873
-     */
874
-    public function get_config($section = '', $name = '', $config_class = '')
875
-    {
876
-        // ensure config class is set to something
877
-        $config_class = $this->_set_config_class($config_class, $name);
878
-        // run tests 1-4, 6 and 7 to verify that all params have been set
879
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
880
-            return null;
881
-        }
882
-        // now test if the requested config object exists, but suppress errors
883
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
884
-            // config already exists, so pass it back
885
-            return $this->{$section}->{$name};
886
-        }
887
-        // load config option from db if it exists
888
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
889
-        // verify the newly retrieved config object, but suppress errors
890
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
891
-            // config is good, so set it and pass it back
892
-            $this->{$section}->{$name} = $config_obj;
893
-            return $this->{$section}->{$name};
894
-        }
895
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
896
-        $config_obj = $this->set_config($section, $name, $config_class);
897
-        // verify the newly created config object
898
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
899
-            return $this->{$section}->{$name};
900
-        } else {
901
-            EE_Error::add_error(
902
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
903
-                __FILE__,
904
-                __FUNCTION__,
905
-                __LINE__
906
-            );
907
-        }
908
-        return null;
909
-    }
910
-
911
-
912
-
913
-    /**
914
-     *    get_config_option
915
-     *
916
-     * @access    public
917
-     * @param    string $config_option_name
918
-     * @return    mixed EE_Config_Base | FALSE
919
-     */
920
-    public function get_config_option($config_option_name = '')
921
-    {
922
-        // retrieve the wp-option for this config class.
923
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
924
-        if (empty($config_option)) {
925
-            EE_Config::log($config_option_name . '-NOT-FOUND');
926
-        }
927
-        return $config_option;
928
-    }
929
-
930
-
931
-
932
-    /**
933
-     * log
934
-     *
935
-     * @param string $config_option_name
936
-     */
937
-    public static function log($config_option_name = '')
938
-    {
939
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
940
-            $config_log = get_option(EE_Config::LOG_NAME, array());
941
-            //copy incoming $_REQUEST and sanitize it so we can save it
942
-            $_request = $_REQUEST;
943
-            array_walk_recursive($_request, 'sanitize_text_field');
944
-            $config_log[(string)microtime(true)] = array(
945
-                'config_name' => $config_option_name,
946
-                'request'     => $_request,
947
-            );
948
-            update_option(EE_Config::LOG_NAME, $config_log);
949
-        }
950
-    }
951
-
952
-
953
-
954
-    /**
955
-     * trim_log
956
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
957
-     */
958
-    public static function trim_log()
959
-    {
960
-        if (! EE_Config::logging_enabled()) {
961
-            return;
962
-        }
963
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
964
-        $log_length = count($config_log);
965
-        if ($log_length > EE_Config::LOG_LENGTH) {
966
-            ksort($config_log);
967
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
968
-            update_option(EE_Config::LOG_NAME, $config_log);
969
-        }
970
-    }
971
-
972
-
973
-
974
-    /**
975
-     *    get_page_for_posts
976
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
977
-     *    wp-option "page_for_posts", or "posts" if no page is selected
978
-     *
979
-     * @access    public
980
-     * @return    string
981
-     */
982
-    public static function get_page_for_posts()
983
-    {
984
-        $page_for_posts = get_option('page_for_posts');
985
-        if (! $page_for_posts) {
986
-            return 'posts';
987
-        }
988
-        /** @type WPDB $wpdb */
989
-        global $wpdb;
990
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
991
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
992
-    }
993
-
994
-
995
-
996
-    /**
997
-     *    register_shortcodes_and_modules.
998
-     *    At this point, it's too early to tell if we're maintenance mode or not.
999
-     *    In fact, this is where we give modules a chance to let core know they exist
1000
-     *    so they can help trigger maintenance mode if it's needed
1001
-     *
1002
-     * @access    public
1003
-     * @return    void
1004
-     */
1005
-    public function register_shortcodes_and_modules()
1006
-    {
1007
-        // allow modules to set hooks for the rest of the system
1008
-        EE_Registry::instance()->modules = $this->_register_modules();
1009
-    }
1010
-
1011
-
1012
-
1013
-    /**
1014
-     *    initialize_shortcodes_and_modules
1015
-     *    meaning they can start adding their hooks to get stuff done
1016
-     *
1017
-     * @access    public
1018
-     * @return    void
1019
-     */
1020
-    public function initialize_shortcodes_and_modules()
1021
-    {
1022
-        // allow modules to set hooks for the rest of the system
1023
-        $this->_initialize_modules();
1024
-    }
1025
-
1026
-
1027
-
1028
-    /**
1029
-     *    widgets_init
1030
-     *
1031
-     * @access private
1032
-     * @return void
1033
-     */
1034
-    public function widgets_init()
1035
-    {
1036
-        //only init widgets on admin pages when not in complete maintenance, and
1037
-        //on frontend when not in any maintenance mode
1038
-        if (
1039
-            ! EE_Maintenance_Mode::instance()->level()
1040
-            || (
1041
-                is_admin()
1042
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1043
-            )
1044
-        ) {
1045
-            // grab list of installed widgets
1046
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1047
-            // filter list of modules to register
1048
-            $widgets_to_register = apply_filters(
1049
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1050
-                $widgets_to_register
1051
-            );
1052
-            if (! empty($widgets_to_register)) {
1053
-                // cycle thru widget folders
1054
-                foreach ($widgets_to_register as $widget_path) {
1055
-                    // add to list of installed widget modules
1056
-                    EE_Config::register_ee_widget($widget_path);
1057
-                }
1058
-            }
1059
-            // filter list of installed modules
1060
-            EE_Registry::instance()->widgets = apply_filters(
1061
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1062
-                EE_Registry::instance()->widgets
1063
-            );
1064
-        }
1065
-    }
1066
-
1067
-
1068
-
1069
-    /**
1070
-     *    register_ee_widget - makes core aware of this widget
1071
-     *
1072
-     * @access    public
1073
-     * @param    string $widget_path - full path up to and including widget folder
1074
-     * @return    void
1075
-     */
1076
-    public static function register_ee_widget($widget_path = null)
1077
-    {
1078
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1079
-        $widget_ext = '.widget.php';
1080
-        // make all separators match
1081
-        $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1082
-        // does the file path INCLUDE the actual file name as part of the path ?
1083
-        if (strpos($widget_path, $widget_ext) !== false) {
1084
-            // grab and shortcode file name from directory name and break apart at dots
1085
-            $file_name = explode('.', basename($widget_path));
1086
-            // take first segment from file name pieces and remove class prefix if it exists
1087
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1088
-            // sanitize shortcode directory name
1089
-            $widget = sanitize_key($widget);
1090
-            // now we need to rebuild the shortcode path
1091
-            $widget_path = explode(DS, $widget_path);
1092
-            // remove last segment
1093
-            array_pop($widget_path);
1094
-            // glue it back together
1095
-            $widget_path = implode(DS, $widget_path);
1096
-        } else {
1097
-            // grab and sanitize widget directory name
1098
-            $widget = sanitize_key(basename($widget_path));
1099
-        }
1100
-        // create classname from widget directory name
1101
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1102
-        // add class prefix
1103
-        $widget_class = 'EEW_' . $widget;
1104
-        // does the widget exist ?
1105
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1106
-            $msg = sprintf(
1107
-                __(
1108
-                    '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',
1109
-                    'event_espresso'
1110
-                ),
1111
-                $widget_class,
1112
-                $widget_path . DS . $widget_class . $widget_ext
1113
-            );
1114
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1115
-            return;
1116
-        }
1117
-        // load the widget class file
1118
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1119
-        // verify that class exists
1120
-        if (! class_exists($widget_class)) {
1121
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1122
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1123
-            return;
1124
-        }
1125
-        register_widget($widget_class);
1126
-        // add to array of registered widgets
1127
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1128
-    }
1129
-
1130
-
1131
-
1132
-    /**
1133
-     *        _register_modules
1134
-     *
1135
-     * @access private
1136
-     * @return array
1137
-     */
1138
-    private function _register_modules()
1139
-    {
1140
-        // grab list of installed modules
1141
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1142
-        // filter list of modules to register
1143
-        $modules_to_register = apply_filters(
1144
-            'FHEE__EE_Config__register_modules__modules_to_register',
1145
-            $modules_to_register
1146
-        );
1147
-        if (! empty($modules_to_register)) {
1148
-            // loop through folders
1149
-            foreach ($modules_to_register as $module_path) {
1150
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1151
-                if (
1152
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1153
-                    && $module_path !== EE_MODULES . 'gateways'
1154
-                ) {
1155
-                    // add to list of installed modules
1156
-                    EE_Config::register_module($module_path);
1157
-                }
1158
-            }
1159
-        }
1160
-        // filter list of installed modules
1161
-        return apply_filters(
1162
-            'FHEE__EE_Config___register_modules__installed_modules',
1163
-            EE_Registry::instance()->modules
1164
-        );
1165
-    }
1166
-
1167
-
1168
-
1169
-    /**
1170
-     *    register_module - makes core aware of this module
1171
-     *
1172
-     * @access    public
1173
-     * @param    string $module_path - full path up to and including module folder
1174
-     * @return    bool
1175
-     */
1176
-    public static function register_module($module_path = null)
1177
-    {
1178
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1179
-        $module_ext = '.module.php';
1180
-        // make all separators match
1181
-        $module_path = str_replace(array('\\', '/'), DS, $module_path);
1182
-        // does the file path INCLUDE the actual file name as part of the path ?
1183
-        if (strpos($module_path, $module_ext) !== false) {
1184
-            // grab and shortcode file name from directory name and break apart at dots
1185
-            $module_file = explode('.', basename($module_path));
1186
-            // now we need to rebuild the shortcode path
1187
-            $module_path = explode(DS, $module_path);
1188
-            // remove last segment
1189
-            array_pop($module_path);
1190
-            // glue it back together
1191
-            $module_path = implode(DS, $module_path) . DS;
1192
-            // take first segment from file name pieces and sanitize it
1193
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1194
-            // ensure class prefix is added
1195
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1196
-        } else {
1197
-            // we need to generate the filename based off of the folder name
1198
-            // grab and sanitize module name
1199
-            $module = strtolower(basename($module_path));
1200
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1201
-            // like trailingslashit()
1202
-            $module_path = rtrim($module_path, DS) . DS;
1203
-            // create classname from module directory name
1204
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1205
-            // add class prefix
1206
-            $module_class = 'EED_' . $module;
1207
-        }
1208
-        // does the module exist ?
1209
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1210
-            $msg = sprintf(
1211
-                __(
1212
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1213
-                    'event_espresso'
1214
-                ),
1215
-                $module
1216
-            );
1217
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1218
-            return false;
1219
-        }
1220
-        // load the module class file
1221
-        require_once($module_path . $module_class . $module_ext);
1222
-        // verify that class exists
1223
-        if (! class_exists($module_class)) {
1224
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1225
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1226
-            return false;
1227
-        }
1228
-        // add to array of registered modules
1229
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1230
-        do_action(
1231
-            'AHEE__EE_Config__register_module__complete',
1232
-            $module_class,
1233
-            EE_Registry::instance()->modules->{$module_class}
1234
-        );
1235
-        return true;
1236
-    }
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()) {
1254
-                // fire immediately
1255
-                call_user_func(array($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
-    /**
1269
-     *    register_route - adds module method routes to route_map
1270
-     *
1271
-     * @access    public
1272
-     * @param    string $route       - "pretty" public alias for module method
1273
-     * @param    string $module      - module name (classname without EED_ prefix)
1274
-     * @param    string $method_name - the actual module method to be routed to
1275
-     * @param    string $key         - url param key indicating a route is being called
1276
-     * @return    bool
1277
-     */
1278
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1279
-    {
1280
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1281
-        $module = str_replace('EED_', '', $module);
1282
-        $module_class = 'EED_' . $module;
1283
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1284
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1285
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1286
-            return false;
1287
-        }
1288
-        if (empty($route)) {
1289
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1290
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
-            return false;
1292
-        }
1293
-        if (! method_exists('EED_' . $module, $method_name)) {
1294
-            $msg = sprintf(
1295
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1296
-                $route
1297
-            );
1298
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1299
-            return false;
1300
-        }
1301
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1302
-        return true;
1303
-    }
1304
-
1305
-
1306
-
1307
-    /**
1308
-     *    get_route - get module method route
1309
-     *
1310
-     * @access    public
1311
-     * @param    string $route - "pretty" public alias for module method
1312
-     * @param    string $key   - url param key indicating a route is being called
1313
-     * @return    string
1314
-     */
1315
-    public static function get_route($route = null, $key = 'ee')
1316
-    {
1317
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1318
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1319
-        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1320
-            return EE_Config::$_module_route_map[$key][$route];
1321
-        }
1322
-        return null;
1323
-    }
1324
-
1325
-
1326
-
1327
-    /**
1328
-     *    get_routes - get ALL module method routes
1329
-     *
1330
-     * @access    public
1331
-     * @return    array
1332
-     */
1333
-    public static function get_routes()
1334
-    {
1335
-        return EE_Config::$_module_route_map;
1336
-    }
1337
-
1338
-
1339
-
1340
-    /**
1341
-     *    register_forward - allows modules to forward request to another module for further processing
1342
-     *
1343
-     * @access    public
1344
-     * @param    string       $route   - "pretty" public alias for module method
1345
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1346
-     *                                 class, allows different forwards to be served based on status
1347
-     * @param    array|string $forward - function name or array( class, method )
1348
-     * @param    string       $key     - url param key indicating a route is being called
1349
-     * @return    bool
1350
-     */
1351
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1352
-    {
1353
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1354
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1355
-            $msg = sprintf(
1356
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1357
-                $route
1358
-            );
1359
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
-            return false;
1361
-        }
1362
-        if (empty($forward)) {
1363
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1364
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
-            return false;
1366
-        }
1367
-        if (is_array($forward)) {
1368
-            if (! isset($forward[1])) {
1369
-                $msg = sprintf(
1370
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1371
-                    $route
1372
-                );
1373
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
-                return false;
1375
-            }
1376
-            if (! method_exists($forward[0], $forward[1])) {
1377
-                $msg = sprintf(
1378
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1379
-                    $forward[1],
1380
-                    $route
1381
-                );
1382
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1383
-                return false;
1384
-            }
1385
-        } else if (! function_exists($forward)) {
1386
-            $msg = sprintf(
1387
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1388
-                $forward,
1389
-                $route
1390
-            );
1391
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1392
-            return false;
1393
-        }
1394
-        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1395
-        return true;
1396
-    }
1397
-
1398
-
1399
-
1400
-    /**
1401
-     *    get_forward - get forwarding route
1402
-     *
1403
-     * @access    public
1404
-     * @param    string  $route  - "pretty" public alias for module method
1405
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1406
-     *                           allows different forwards to be served based on status
1407
-     * @param    string  $key    - url param key indicating a route is being called
1408
-     * @return    string
1409
-     */
1410
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1411
-    {
1412
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1413
-        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1414
-            return apply_filters(
1415
-                'FHEE__EE_Config__get_forward',
1416
-                EE_Config::$_module_forward_map[$key][$route][$status],
1417
-                $route,
1418
-                $status
1419
-            );
1420
-        }
1421
-        return null;
1422
-    }
1423
-
1424
-
1425
-
1426
-    /**
1427
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1428
-     *    results
1429
-     *
1430
-     * @access    public
1431
-     * @param    string  $route  - "pretty" public alias for module method
1432
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1433
-     *                           allows different views to be served based on status
1434
-     * @param    string  $view
1435
-     * @param    string  $key    - url param key indicating a route is being called
1436
-     * @return    bool
1437
-     */
1438
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1439
-    {
1440
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1441
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1442
-            $msg = sprintf(
1443
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1444
-                $route
1445
-            );
1446
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1447
-            return false;
1448
-        }
1449
-        if (! is_readable($view)) {
1450
-            $msg = sprintf(
1451
-                __(
1452
-                    'The %s view file could not be found or is not readable due to file permissions.',
1453
-                    'event_espresso'
1454
-                ),
1455
-                $view
1456
-            );
1457
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1458
-            return false;
1459
-        }
1460
-        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1461
-        return true;
1462
-    }
1463
-
1464
-
1465
-
1466
-    /**
1467
-     *    get_view - get view for route and status
1468
-     *
1469
-     * @access    public
1470
-     * @param    string  $route  - "pretty" public alias for module method
1471
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1472
-     *                           allows different views to be served based on status
1473
-     * @param    string  $key    - url param key indicating a route is being called
1474
-     * @return    string
1475
-     */
1476
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1477
-    {
1478
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1479
-        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1480
-            return apply_filters(
1481
-                'FHEE__EE_Config__get_view',
1482
-                EE_Config::$_module_view_map[$key][$route][$status],
1483
-                $route,
1484
-                $status
1485
-            );
1486
-        }
1487
-        return null;
1488
-    }
1489
-
1490
-
1491
-
1492
-    public function update_addon_option_names()
1493
-    {
1494
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1495
-    }
1496
-
1497
-
1498
-
1499
-    public function shutdown()
1500
-    {
1501
-        $this->update_addon_option_names();
1502
-    }
1503
-
1504
-
1505
-
1506
-    /**
1507
-     * @return LegacyShortcodesManager
1508
-     */
1509
-    public static function getLegacyShortcodesManager()
1510
-    {
1511
-
1512
-        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1513
-            EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1514
-                EE_Registry::instance()
1515
-            );
1516
-        }
1517
-        return EE_Config::instance()->legacy_shortcodes_manager;
1518
-    }
1519
-
1520
-
1521
-
1522
-    /**
1523
-     * register_shortcode - makes core aware of this shortcode
1524
-     *
1525
-     * @deprecated 4.9.26
1526
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1527
-     * @return    bool
1528
-     */
1529
-    public static function register_shortcode($shortcode_path = null)
1530
-    {
1531
-        EE_Error::doing_it_wrong(
1532
-            __METHOD__,
1533
-            __(
1534
-                '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.',
1535
-                'event_espresso'
1536
-            ),
1537
-            '4.9.26'
1538
-        );
1539
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1540
-    }
1541
-
1542
-
1543
-
1544
-}
1545
-
1546
-
1547
-
1548
-/**
1549
- * Base class used for config classes. These classes should generally not have
1550
- * magic functions in use, except we'll allow them to magically set and get stuff...
1551
- * basically, they should just be well-defined stdClasses
1552
- */
1553
-class EE_Config_Base
1554
-{
1555
-
1556
-    /**
1557
-     * Utility function for escaping the value of a property and returning.
1558
-     *
1559
-     * @param string $property property name (checks to see if exists).
1560
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561
-     * @throws \EE_Error
1562
-     */
1563
-    public function get_pretty($property)
1564
-    {
1565
-        if (! property_exists($this, $property)) {
1566
-            throw new EE_Error(
1567
-                sprintf(
1568
-                    __(
1569
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1570
-                        'event_espresso'
1571
-                    ),
1572
-                    get_class($this),
1573
-                    $property
1574
-                )
1575
-            );
1576
-        }
1577
-        //just handling escaping of strings for now.
1578
-        if (is_string($this->{$property})) {
1579
-            return stripslashes($this->{$property});
1580
-        }
1581
-        return $this->{$property};
1582
-    }
1583
-
1584
-
1585
-
1586
-    public function populate()
1587
-    {
1588
-        //grab defaults via a new instance of this class.
1589
-        $class_name = get_class($this);
1590
-        $defaults = new $class_name;
1591
-        //loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1592
-        //default from our $defaults object.
1593
-        foreach (get_object_vars($defaults) as $property => $value) {
1594
-            if ($this->{$property} === null) {
1595
-                $this->{$property} = $value;
1596
-            }
1597
-        }
1598
-        //cleanup
1599
-        unset($defaults);
1600
-    }
1601
-
1602
-
1603
-
1604
-    /**
1605
-     *        __isset
1606
-     *
1607
-     * @param $a
1608
-     * @return bool
1609
-     */
1610
-    public function __isset($a)
1611
-    {
1612
-        return false;
1613
-    }
1614
-
1615
-
1616
-
1617
-    /**
1618
-     *        __unset
1619
-     *
1620
-     * @param $a
1621
-     * @return bool
1622
-     */
1623
-    public function __unset($a)
1624
-    {
1625
-        return false;
1626
-    }
1627
-
1628
-
1629
-
1630
-    /**
1631
-     *        __clone
1632
-     */
1633
-    public function __clone()
1634
-    {
1635
-    }
1636
-
1637
-
1638
-
1639
-    /**
1640
-     *        __wakeup
1641
-     */
1642
-    public function __wakeup()
1643
-    {
1644
-    }
1645
-
1646
-
1647
-
1648
-    /**
1649
-     *        __destruct
1650
-     */
1651
-    public function __destruct()
1652
-    {
1653
-    }
1654
-}
1655
-
1656
-
1657
-
1658
-/**
1659
- * Class for defining what's in the EE_Config relating to registration settings
1660
- */
1661
-class EE_Core_Config extends EE_Config_Base
1662
-{
1663
-
1664
-    public $current_blog_id;
1665
-
1666
-    public $ee_ueip_optin;
1667
-
1668
-    public $ee_ueip_has_notified;
1669
-
1670
-    /**
1671
-     * Not to be confused with the 4 critical page variables (See
1672
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1673
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1674
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1675
-     *
1676
-     * @var array
1677
-     */
1678
-    public $post_shortcodes;
1679
-
1680
-    public $module_route_map;
1681
-
1682
-    public $module_forward_map;
1683
-
1684
-    public $module_view_map;
1685
-
1686
-    /**
1687
-     * The next 4 vars are the IDs of critical EE pages.
1688
-     *
1689
-     * @var int
1690
-     */
1691
-    public $reg_page_id;
1692
-
1693
-    public $txn_page_id;
1694
-
1695
-    public $thank_you_page_id;
1696
-
1697
-    public $cancel_page_id;
1698
-
1699
-    /**
1700
-     * The next 4 vars are the URLs of critical EE pages.
1701
-     *
1702
-     * @var int
1703
-     */
1704
-    public $reg_page_url;
1705
-
1706
-    public $txn_page_url;
1707
-
1708
-    public $thank_you_page_url;
1709
-
1710
-    public $cancel_page_url;
1711
-
1712
-    /**
1713
-     * The next vars relate to the custom slugs for EE CPT routes
1714
-     */
1715
-    public $event_cpt_slug;
1716
-
1717
-
1718
-    /**
1719
-     * This caches the _ee_ueip_option in case this config is reset in the same
1720
-     * request across blog switches in a multisite context.
1721
-     * Avoids extra queries to the db for this option.
1722
-     *
1723
-     * @var bool
1724
-     */
1725
-    public static $ee_ueip_option;
1726
-
1727
-
1728
-
1729
-    /**
1730
-     *    class constructor
1731
-     *
1732
-     * @access    public
1733
-     */
1734
-    public function __construct()
1735
-    {
1736
-        // set default organization settings
1737
-        $this->current_blog_id = get_current_blog_id();
1738
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1739
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1740
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1741
-        $this->post_shortcodes = array();
1742
-        $this->module_route_map = array();
1743
-        $this->module_forward_map = array();
1744
-        $this->module_view_map = array();
1745
-        // critical EE page IDs
1746
-        $this->reg_page_id = 0;
1747
-        $this->txn_page_id = 0;
1748
-        $this->thank_you_page_id = 0;
1749
-        $this->cancel_page_id = 0;
1750
-        // critical EE page URLs
1751
-        $this->reg_page_url = '';
1752
-        $this->txn_page_url = '';
1753
-        $this->thank_you_page_url = '';
1754
-        $this->cancel_page_url = '';
1755
-        //cpt slugs
1756
-        $this->event_cpt_slug = __('events', 'event_espresso');
1757
-        //ueip constant check
1758
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1759
-            $this->ee_ueip_optin = false;
1760
-            $this->ee_ueip_has_notified = true;
1761
-        }
1762
-    }
1763
-
1764
-
1765
-
1766
-    /**
1767
-     * @return array
1768
-     */
1769
-    public function get_critical_pages_array()
1770
-    {
1771
-        return array(
1772
-            $this->reg_page_id,
1773
-            $this->txn_page_id,
1774
-            $this->thank_you_page_id,
1775
-            $this->cancel_page_id,
1776
-        );
1777
-    }
1778
-
1779
-
1780
-
1781
-    /**
1782
-     * @return array
1783
-     */
1784
-    public function get_critical_pages_shortcodes_array()
1785
-    {
1786
-        return array(
1787
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1788
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1789
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1790
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1791
-        );
1792
-    }
1793
-
1794
-
1795
-
1796
-    /**
1797
-     *  gets/returns URL for EE reg_page
1798
-     *
1799
-     * @access    public
1800
-     * @return    string
1801
-     */
1802
-    public function reg_page_url()
1803
-    {
1804
-        if (! $this->reg_page_url) {
1805
-            $this->reg_page_url = add_query_arg(
1806
-                                      array('uts' => time()),
1807
-                                      get_permalink($this->reg_page_id)
1808
-                                  ) . '#checkout';
1809
-        }
1810
-        return $this->reg_page_url;
1811
-    }
1812
-
1813
-
1814
-
1815
-    /**
1816
-     *  gets/returns URL for EE txn_page
1817
-     *
1818
-     * @param array $query_args like what gets passed to
1819
-     *                          add_query_arg() as the first argument
1820
-     * @access    public
1821
-     * @return    string
1822
-     */
1823
-    public function txn_page_url($query_args = array())
1824
-    {
1825
-        if (! $this->txn_page_url) {
1826
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1827
-        }
1828
-        if ($query_args) {
1829
-            return add_query_arg($query_args, $this->txn_page_url);
1830
-        } else {
1831
-            return $this->txn_page_url;
1832
-        }
1833
-    }
1834
-
1835
-
1836
-
1837
-    /**
1838
-     *  gets/returns URL for EE thank_you_page
1839
-     *
1840
-     * @param array $query_args like what gets passed to
1841
-     *                          add_query_arg() as the first argument
1842
-     * @access    public
1843
-     * @return    string
1844
-     */
1845
-    public function thank_you_page_url($query_args = array())
1846
-    {
1847
-        if (! $this->thank_you_page_url) {
1848
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1849
-        }
1850
-        if ($query_args) {
1851
-            return add_query_arg($query_args, $this->thank_you_page_url);
1852
-        } else {
1853
-            return $this->thank_you_page_url;
1854
-        }
1855
-    }
1856
-
1857
-
1858
-
1859
-    /**
1860
-     *  gets/returns URL for EE cancel_page
1861
-     *
1862
-     * @access    public
1863
-     * @return    string
1864
-     */
1865
-    public function cancel_page_url()
1866
-    {
1867
-        if (! $this->cancel_page_url) {
1868
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1869
-        }
1870
-        return $this->cancel_page_url;
1871
-    }
1872
-
1873
-
1874
-
1875
-    /**
1876
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1877
-     *
1878
-     * @since 4.7.5
1879
-     */
1880
-    protected function _reset_urls()
1881
-    {
1882
-        $this->reg_page_url = '';
1883
-        $this->txn_page_url = '';
1884
-        $this->cancel_page_url = '';
1885
-        $this->thank_you_page_url = '';
1886
-    }
1887
-
1888
-
1889
-
1890
-    /**
1891
-     * Used to return what the optin value is set for the EE User Experience Program.
1892
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1893
-     * on the main site only.
1894
-     *
1895
-     * @return mixed|void
1896
-     */
1897
-    protected function _get_main_ee_ueip_optin()
1898
-    {
1899
-        //if this is the main site then we can just bypass our direct query.
1900
-        if (is_main_site()) {
1901
-            return get_option('ee_ueip_optin', false);
1902
-        }
1903
-        //is this already cached for this request?  If so use it.
1904
-        if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1905
-            return EE_Core_Config::$ee_ueip_option;
1906
-        }
1907
-        global $wpdb;
1908
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1909
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1910
-        $option = 'ee_ueip_optin';
1911
-        //set correct table for query
1912
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1913
-        //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1914
-        //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1915
-        //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1916
-        //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1917
-        //for the purpose of caching.
1918
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1919
-        if (false !== $pre) {
1920
-            EE_Core_Config::$ee_ueip_option = $pre;
1921
-            return EE_Core_Config::$ee_ueip_option;
1922
-        }
1923
-        $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1924
-            $option));
1925
-        if (is_object($row)) {
1926
-            $value = $row->option_value;
1927
-        } else { //option does not exist so use default.
1928
-            return apply_filters('default_option_' . $option, false, $option);
1929
-        }
1930
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1931
-        return EE_Core_Config::$ee_ueip_option;
1932
-    }
1933
-
1934
-
1935
-
1936
-    /**
1937
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1938
-     * on the object.
1939
-     *
1940
-     * @return array
1941
-     */
1942
-    public function __sleep()
1943
-    {
1944
-        //reset all url properties
1945
-        $this->_reset_urls();
1946
-        //return what to save to db
1947
-        return array_keys(get_object_vars($this));
1948
-    }
1949
-
1950
-}
1951
-
1952
-
1953
-
1954
-/**
1955
- * Config class for storing info on the Organization
1956
- */
1957
-class EE_Organization_Config extends EE_Config_Base
1958
-{
1959
-
1960
-    /**
1961
-     * @var string $name
1962
-     * eg EE4.1
1963
-     */
1964
-    public $name;
1965
-
1966
-    /**
1967
-     * @var string $address_1
1968
-     * eg 123 Onna Road
1969
-     */
1970
-    public $address_1;
1971
-
1972
-    /**
1973
-     * @var string $address_2
1974
-     * eg PO Box 123
1975
-     */
1976
-    public $address_2;
1977
-
1978
-    /**
1979
-     * @var string $city
1980
-     * eg Inna City
1981
-     */
1982
-    public $city;
1983
-
1984
-    /**
1985
-     * @var int $STA_ID
1986
-     * eg 4
1987
-     */
1988
-    public $STA_ID;
1989
-
1990
-    /**
1991
-     * @var string $CNT_ISO
1992
-     * eg US
1993
-     */
1994
-    public $CNT_ISO;
1995
-
1996
-    /**
1997
-     * @var string $zip
1998
-     * eg 12345  or V1A 2B3
1999
-     */
2000
-    public $zip;
2001
-
2002
-    /**
2003
-     * @var string $email
2004
-     * eg [email protected]
2005
-     */
2006
-    public $email;
2007
-
2008
-
2009
-    /**
2010
-     * @var string $phone
2011
-     * eg. 111-111-1111
2012
-     */
2013
-    public $phone;
2014
-
2015
-
2016
-    /**
2017
-     * @var string $vat
2018
-     * VAT/Tax Number
2019
-     */
2020
-    public $vat;
2021
-
2022
-    /**
2023
-     * @var string $logo_url
2024
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2025
-     */
2026
-    public $logo_url;
2027
-
2028
-
2029
-    /**
2030
-     * The below are all various properties for holding links to organization social network profiles
2031
-     *
2032
-     * @var string
2033
-     */
2034
-    /**
2035
-     * facebook (facebook.com/profile.name)
2036
-     *
2037
-     * @var string
2038
-     */
2039
-    public $facebook;
2040
-
2041
-
2042
-    /**
2043
-     * twitter (twitter.com/twitter_handle)
2044
-     *
2045
-     * @var string
2046
-     */
2047
-    public $twitter;
2048
-
2049
-
2050
-    /**
2051
-     * linkedin (linkedin.com/in/profile_name)
2052
-     *
2053
-     * @var string
2054
-     */
2055
-    public $linkedin;
2056
-
2057
-
2058
-    /**
2059
-     * pinterest (www.pinterest.com/profile_name)
2060
-     *
2061
-     * @var string
2062
-     */
2063
-    public $pinterest;
2064
-
2065
-
2066
-    /**
2067
-     * google+ (google.com/+profileName)
2068
-     *
2069
-     * @var string
2070
-     */
2071
-    public $google;
2072
-
2073
-
2074
-    /**
2075
-     * instagram (instagram.com/handle)
2076
-     *
2077
-     * @var string
2078
-     */
2079
-    public $instagram;
2080
-
2081
-
2082
-
2083
-    /**
2084
-     *    class constructor
2085
-     *
2086
-     * @access    public
2087
-     */
2088
-    public function __construct()
2089
-    {
2090
-        // set default organization settings
2091
-        //decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2092
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2093
-        $this->address_1 = '123 Onna Road';
2094
-        $this->address_2 = 'PO Box 123';
2095
-        $this->city = 'Inna City';
2096
-        $this->STA_ID = 4;
2097
-        $this->CNT_ISO = 'US';
2098
-        $this->zip = '12345';
2099
-        $this->email = get_bloginfo('admin_email');
2100
-        $this->phone = '';
2101
-        $this->vat = '123456789';
2102
-        $this->logo_url = '';
2103
-        $this->facebook = '';
2104
-        $this->twitter = '';
2105
-        $this->linkedin = '';
2106
-        $this->pinterest = '';
2107
-        $this->google = '';
2108
-        $this->instagram = '';
2109
-    }
2110
-
2111
-}
2112
-
2113
-
2114
-
2115
-/**
2116
- * Class for defining what's in the EE_Config relating to currency
2117
- */
2118
-class EE_Currency_Config extends EE_Config_Base
2119
-{
2120
-
2121
-    /**
2122
-     * @var string $code
2123
-     * eg 'US'
2124
-     */
2125
-    public $code;
2126
-
2127
-    /**
2128
-     * @var string $name
2129
-     * eg 'Dollar'
2130
-     */
2131
-    public $name;
2132
-
2133
-    /**
2134
-     * plural name
2135
-     *
2136
-     * @var string $plural
2137
-     * eg 'Dollars'
2138
-     */
2139
-    public $plural;
2140
-
2141
-    /**
2142
-     * currency sign
2143
-     *
2144
-     * @var string $sign
2145
-     * eg '$'
2146
-     */
2147
-    public $sign;
2148
-
2149
-    /**
2150
-     * Whether the currency sign should come before the number or not
2151
-     *
2152
-     * @var boolean $sign_b4
2153
-     */
2154
-    public $sign_b4;
2155
-
2156
-    /**
2157
-     * How many digits should come after the decimal place
2158
-     *
2159
-     * @var int $dec_plc
2160
-     */
2161
-    public $dec_plc;
2162
-
2163
-    /**
2164
-     * Symbol to use for decimal mark
2165
-     *
2166
-     * @var string $dec_mrk
2167
-     * eg '.'
2168
-     */
2169
-    public $dec_mrk;
2170
-
2171
-    /**
2172
-     * Symbol to use for thousands
2173
-     *
2174
-     * @var string $thsnds
2175
-     * eg ','
2176
-     */
2177
-    public $thsnds;
2178
-
2179
-
2180
-
2181
-    /**
2182
-     *    class constructor
2183
-     *
2184
-     * @access    public
2185
-     * @param string $CNT_ISO
2186
-     * @throws \EE_Error
2187
-     */
2188
-    public function __construct($CNT_ISO = '')
2189
-    {
2190
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2191
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2192
-        // get country code from organization settings or use default
2193
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2194
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2195
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2196
-            : '';
2197
-        // but override if requested
2198
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2199
-        // 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
2200
-        if (
2201
-            ! empty($CNT_ISO)
2202
-            && EE_Maintenance_Mode::instance()->models_can_query()
2203
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2204
-        ) {
2205
-            // retrieve the country settings from the db, just in case they have been customized
2206
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2207
-            if ($country instanceof EE_Country) {
2208
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2209
-                $this->name = $country->currency_name_single();    // Dollar
2210
-                $this->plural = $country->currency_name_plural();    // Dollars
2211
-                $this->sign = $country->currency_sign();            // currency sign: $
2212
-                $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2213
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2214
-                $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2215
-                $this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2216
-            }
2217
-        }
2218
-        // fallback to hardcoded defaults, in case the above failed
2219
-        if (empty($this->code)) {
2220
-            // set default currency settings
2221
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2222
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2223
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2224
-            $this->sign = '$';    // currency sign: $
2225
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2226
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2227
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2228
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2229
-        }
2230
-    }
2231
-}
2232
-
2233
-
2234
-
2235
-/**
2236
- * Class for defining what's in the EE_Config relating to registration settings
2237
- */
2238
-class EE_Registration_Config extends EE_Config_Base
2239
-{
2240
-
2241
-    /**
2242
-     * Default registration status
2243
-     *
2244
-     * @var string $default_STS_ID
2245
-     * eg 'RPP'
2246
-     */
2247
-    public $default_STS_ID;
2248
-
2249
-
2250
-    /**
2251
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2252
-     * registrations)
2253
-     * @var int
2254
-     */
2255
-    public $default_maximum_number_of_tickets;
2256
-
2257
-
2258
-    /**
2259
-     * level of validation to apply to email addresses
2260
-     *
2261
-     * @var string $email_validation_level
2262
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2263
-     */
2264
-    public $email_validation_level;
2265
-
2266
-    /**
2267
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2268
-     *
2269
-     * @var boolean $show_pending_payment_options
2270
-     */
2271
-    public $show_pending_payment_options;
2272
-
2273
-    /**
2274
-     * Whether to skip the registration confirmation page
2275
-     *
2276
-     * @var boolean $skip_reg_confirmation
2277
-     */
2278
-    public $skip_reg_confirmation;
2279
-
2280
-    /**
2281
-     * an array of SPCO reg steps where:
2282
-     *        the keys denotes the reg step order
2283
-     *        each element consists of an array with the following elements:
2284
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2285
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2286
-     *            "slug" => the URL param used to trigger the reg step
2287
-     *
2288
-     * @var array $reg_steps
2289
-     */
2290
-    public $reg_steps;
2291
-
2292
-    /**
2293
-     * Whether registration confirmation should be the last page of SPCO
2294
-     *
2295
-     * @var boolean $reg_confirmation_last
2296
-     */
2297
-    public $reg_confirmation_last;
2298
-
2299
-    /**
2300
-     * Whether or not to enable the EE Bot Trap
2301
-     *
2302
-     * @var boolean $use_bot_trap
2303
-     */
2304
-    public $use_bot_trap;
2305
-
2306
-    /**
2307
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2308
-     *
2309
-     * @var boolean $use_encryption
2310
-     */
2311
-    public $use_encryption;
2312
-
2313
-    /**
2314
-     * Whether or not to use ReCaptcha
2315
-     *
2316
-     * @var boolean $use_captcha
2317
-     */
2318
-    public $use_captcha;
2319
-
2320
-    /**
2321
-     * ReCaptcha Theme
2322
-     *
2323
-     * @var string $recaptcha_theme
2324
-     *    options: 'dark', 'light', 'invisible'
2325
-     */
2326
-    public $recaptcha_theme;
1544
+}
2327 1545
 
2328
-    /**
2329
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2330
-     *
2331
-     * @var string $recaptcha_badge
2332
-     *    options: 'bottomright', 'bottomleft', 'inline'
2333
-     */
2334
-    public $recaptcha_badge;
2335 1546
 
2336
-    /**
2337
-     * ReCaptcha Type
2338
-     *
2339
-     * @var string $recaptcha_type
2340
-     *    options: 'audio', 'image'
2341
-     */
2342
-    public $recaptcha_type;
2343 1547
 
2344
-    /**
2345
-     * ReCaptcha language
2346
-     *
2347
-     * @var string $recaptcha_language
2348
-     * eg 'en'
2349
-     */
2350
-    public $recaptcha_language;
1548
+/**
1549
+ * Base class used for config classes. These classes should generally not have
1550
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1551
+ * basically, they should just be well-defined stdClasses
1552
+ */
1553
+class EE_Config_Base
1554
+{
2351 1555
 
2352
-    /**
2353
-     * ReCaptcha public key
2354
-     *
2355
-     * @var string $recaptcha_publickey
2356
-     */
2357
-    public $recaptcha_publickey;
1556
+	/**
1557
+	 * Utility function for escaping the value of a property and returning.
1558
+	 *
1559
+	 * @param string $property property name (checks to see if exists).
1560
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561
+	 * @throws \EE_Error
1562
+	 */
1563
+	public function get_pretty($property)
1564
+	{
1565
+		if (! property_exists($this, $property)) {
1566
+			throw new EE_Error(
1567
+				sprintf(
1568
+					__(
1569
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1570
+						'event_espresso'
1571
+					),
1572
+					get_class($this),
1573
+					$property
1574
+				)
1575
+			);
1576
+		}
1577
+		//just handling escaping of strings for now.
1578
+		if (is_string($this->{$property})) {
1579
+			return stripslashes($this->{$property});
1580
+		}
1581
+		return $this->{$property};
1582
+	}
1583
+
1584
+
1585
+
1586
+	public function populate()
1587
+	{
1588
+		//grab defaults via a new instance of this class.
1589
+		$class_name = get_class($this);
1590
+		$defaults = new $class_name;
1591
+		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1592
+		//default from our $defaults object.
1593
+		foreach (get_object_vars($defaults) as $property => $value) {
1594
+			if ($this->{$property} === null) {
1595
+				$this->{$property} = $value;
1596
+			}
1597
+		}
1598
+		//cleanup
1599
+		unset($defaults);
1600
+	}
1601
+
1602
+
1603
+
1604
+	/**
1605
+	 *        __isset
1606
+	 *
1607
+	 * @param $a
1608
+	 * @return bool
1609
+	 */
1610
+	public function __isset($a)
1611
+	{
1612
+		return false;
1613
+	}
1614
+
1615
+
1616
+
1617
+	/**
1618
+	 *        __unset
1619
+	 *
1620
+	 * @param $a
1621
+	 * @return bool
1622
+	 */
1623
+	public function __unset($a)
1624
+	{
1625
+		return false;
1626
+	}
1627
+
1628
+
1629
+
1630
+	/**
1631
+	 *        __clone
1632
+	 */
1633
+	public function __clone()
1634
+	{
1635
+	}
1636
+
1637
+
1638
+
1639
+	/**
1640
+	 *        __wakeup
1641
+	 */
1642
+	public function __wakeup()
1643
+	{
1644
+	}
1645
+
1646
+
1647
+
1648
+	/**
1649
+	 *        __destruct
1650
+	 */
1651
+	public function __destruct()
1652
+	{
1653
+	}
1654
+}
2358 1655
 
2359
-    /**
2360
-     * ReCaptcha private key
2361
-     *
2362
-     * @var string $recaptcha_privatekey
2363
-     */
2364
-    public $recaptcha_privatekey;
2365 1656
 
2366
-    /**
2367
-     * array of form names protected by ReCaptcha
2368
-     *
2369
-     * @var array $recaptcha_protected_forms
2370
-     */
2371
-    public $recaptcha_protected_forms;
2372 1657
 
2373
-    /**
2374
-     * ReCaptcha width
2375
-     *
2376
-     * @var int $recaptcha_width
2377
-     * @deprecated
2378
-     */
2379
-    public $recaptcha_width;
1658
+/**
1659
+ * Class for defining what's in the EE_Config relating to registration settings
1660
+ */
1661
+class EE_Core_Config extends EE_Config_Base
1662
+{
2380 1663
 
2381
-    /**
2382
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2383
-     *
2384
-     * @var boolean $track_invalid_checkout_access
2385
-     */
2386
-    protected $track_invalid_checkout_access = true;
1664
+	public $current_blog_id;
1665
+
1666
+	public $ee_ueip_optin;
1667
+
1668
+	public $ee_ueip_has_notified;
1669
+
1670
+	/**
1671
+	 * Not to be confused with the 4 critical page variables (See
1672
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1673
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1674
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1675
+	 *
1676
+	 * @var array
1677
+	 */
1678
+	public $post_shortcodes;
1679
+
1680
+	public $module_route_map;
1681
+
1682
+	public $module_forward_map;
1683
+
1684
+	public $module_view_map;
1685
+
1686
+	/**
1687
+	 * The next 4 vars are the IDs of critical EE pages.
1688
+	 *
1689
+	 * @var int
1690
+	 */
1691
+	public $reg_page_id;
1692
+
1693
+	public $txn_page_id;
1694
+
1695
+	public $thank_you_page_id;
1696
+
1697
+	public $cancel_page_id;
1698
+
1699
+	/**
1700
+	 * The next 4 vars are the URLs of critical EE pages.
1701
+	 *
1702
+	 * @var int
1703
+	 */
1704
+	public $reg_page_url;
1705
+
1706
+	public $txn_page_url;
1707
+
1708
+	public $thank_you_page_url;
1709
+
1710
+	public $cancel_page_url;
1711
+
1712
+	/**
1713
+	 * The next vars relate to the custom slugs for EE CPT routes
1714
+	 */
1715
+	public $event_cpt_slug;
1716
+
1717
+
1718
+	/**
1719
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1720
+	 * request across blog switches in a multisite context.
1721
+	 * Avoids extra queries to the db for this option.
1722
+	 *
1723
+	 * @var bool
1724
+	 */
1725
+	public static $ee_ueip_option;
1726
+
1727
+
1728
+
1729
+	/**
1730
+	 *    class constructor
1731
+	 *
1732
+	 * @access    public
1733
+	 */
1734
+	public function __construct()
1735
+	{
1736
+		// set default organization settings
1737
+		$this->current_blog_id = get_current_blog_id();
1738
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1739
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1740
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1741
+		$this->post_shortcodes = array();
1742
+		$this->module_route_map = array();
1743
+		$this->module_forward_map = array();
1744
+		$this->module_view_map = array();
1745
+		// critical EE page IDs
1746
+		$this->reg_page_id = 0;
1747
+		$this->txn_page_id = 0;
1748
+		$this->thank_you_page_id = 0;
1749
+		$this->cancel_page_id = 0;
1750
+		// critical EE page URLs
1751
+		$this->reg_page_url = '';
1752
+		$this->txn_page_url = '';
1753
+		$this->thank_you_page_url = '';
1754
+		$this->cancel_page_url = '';
1755
+		//cpt slugs
1756
+		$this->event_cpt_slug = __('events', 'event_espresso');
1757
+		//ueip constant check
1758
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1759
+			$this->ee_ueip_optin = false;
1760
+			$this->ee_ueip_has_notified = true;
1761
+		}
1762
+	}
1763
+
1764
+
1765
+
1766
+	/**
1767
+	 * @return array
1768
+	 */
1769
+	public function get_critical_pages_array()
1770
+	{
1771
+		return array(
1772
+			$this->reg_page_id,
1773
+			$this->txn_page_id,
1774
+			$this->thank_you_page_id,
1775
+			$this->cancel_page_id,
1776
+		);
1777
+	}
1778
+
1779
+
1780
+
1781
+	/**
1782
+	 * @return array
1783
+	 */
1784
+	public function get_critical_pages_shortcodes_array()
1785
+	{
1786
+		return array(
1787
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1788
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1789
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1790
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1791
+		);
1792
+	}
1793
+
1794
+
1795
+
1796
+	/**
1797
+	 *  gets/returns URL for EE reg_page
1798
+	 *
1799
+	 * @access    public
1800
+	 * @return    string
1801
+	 */
1802
+	public function reg_page_url()
1803
+	{
1804
+		if (! $this->reg_page_url) {
1805
+			$this->reg_page_url = add_query_arg(
1806
+									  array('uts' => time()),
1807
+									  get_permalink($this->reg_page_id)
1808
+								  ) . '#checkout';
1809
+		}
1810
+		return $this->reg_page_url;
1811
+	}
1812
+
1813
+
1814
+
1815
+	/**
1816
+	 *  gets/returns URL for EE txn_page
1817
+	 *
1818
+	 * @param array $query_args like what gets passed to
1819
+	 *                          add_query_arg() as the first argument
1820
+	 * @access    public
1821
+	 * @return    string
1822
+	 */
1823
+	public function txn_page_url($query_args = array())
1824
+	{
1825
+		if (! $this->txn_page_url) {
1826
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1827
+		}
1828
+		if ($query_args) {
1829
+			return add_query_arg($query_args, $this->txn_page_url);
1830
+		} else {
1831
+			return $this->txn_page_url;
1832
+		}
1833
+	}
1834
+
1835
+
1836
+
1837
+	/**
1838
+	 *  gets/returns URL for EE thank_you_page
1839
+	 *
1840
+	 * @param array $query_args like what gets passed to
1841
+	 *                          add_query_arg() as the first argument
1842
+	 * @access    public
1843
+	 * @return    string
1844
+	 */
1845
+	public function thank_you_page_url($query_args = array())
1846
+	{
1847
+		if (! $this->thank_you_page_url) {
1848
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1849
+		}
1850
+		if ($query_args) {
1851
+			return add_query_arg($query_args, $this->thank_you_page_url);
1852
+		} else {
1853
+			return $this->thank_you_page_url;
1854
+		}
1855
+	}
1856
+
1857
+
1858
+
1859
+	/**
1860
+	 *  gets/returns URL for EE cancel_page
1861
+	 *
1862
+	 * @access    public
1863
+	 * @return    string
1864
+	 */
1865
+	public function cancel_page_url()
1866
+	{
1867
+		if (! $this->cancel_page_url) {
1868
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1869
+		}
1870
+		return $this->cancel_page_url;
1871
+	}
1872
+
1873
+
1874
+
1875
+	/**
1876
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1877
+	 *
1878
+	 * @since 4.7.5
1879
+	 */
1880
+	protected function _reset_urls()
1881
+	{
1882
+		$this->reg_page_url = '';
1883
+		$this->txn_page_url = '';
1884
+		$this->cancel_page_url = '';
1885
+		$this->thank_you_page_url = '';
1886
+	}
1887
+
1888
+
1889
+
1890
+	/**
1891
+	 * Used to return what the optin value is set for the EE User Experience Program.
1892
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1893
+	 * on the main site only.
1894
+	 *
1895
+	 * @return mixed|void
1896
+	 */
1897
+	protected function _get_main_ee_ueip_optin()
1898
+	{
1899
+		//if this is the main site then we can just bypass our direct query.
1900
+		if (is_main_site()) {
1901
+			return get_option('ee_ueip_optin', false);
1902
+		}
1903
+		//is this already cached for this request?  If so use it.
1904
+		if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1905
+			return EE_Core_Config::$ee_ueip_option;
1906
+		}
1907
+		global $wpdb;
1908
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1909
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1910
+		$option = 'ee_ueip_optin';
1911
+		//set correct table for query
1912
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1913
+		//rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1914
+		//get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1915
+		//re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1916
+		//this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1917
+		//for the purpose of caching.
1918
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1919
+		if (false !== $pre) {
1920
+			EE_Core_Config::$ee_ueip_option = $pre;
1921
+			return EE_Core_Config::$ee_ueip_option;
1922
+		}
1923
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1924
+			$option));
1925
+		if (is_object($row)) {
1926
+			$value = $row->option_value;
1927
+		} else { //option does not exist so use default.
1928
+			return apply_filters('default_option_' . $option, false, $option);
1929
+		}
1930
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1931
+		return EE_Core_Config::$ee_ueip_option;
1932
+	}
1933
+
1934
+
1935
+
1936
+	/**
1937
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1938
+	 * on the object.
1939
+	 *
1940
+	 * @return array
1941
+	 */
1942
+	public function __sleep()
1943
+	{
1944
+		//reset all url properties
1945
+		$this->_reset_urls();
1946
+		//return what to save to db
1947
+		return array_keys(get_object_vars($this));
1948
+	}
2387 1949
 
1950
+}
2388 1951
 
2389 1952
 
2390
-    /**
2391
-     *    class constructor
2392
-     *
2393
-     * @access    public
2394
-     */
2395
-    public function __construct()
2396
-    {
2397
-        // set default registration settings
2398
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2399
-        $this->email_validation_level = 'wp_default';
2400
-        $this->show_pending_payment_options = true;
2401
-        $this->skip_reg_confirmation = false;
2402
-        $this->reg_steps = array();
2403
-        $this->reg_confirmation_last = false;
2404
-        $this->use_bot_trap = true;
2405
-        $this->use_encryption = true;
2406
-        $this->use_captcha = false;
2407
-        $this->recaptcha_theme = 'light';
2408
-        $this->recaptcha_badge = 'bottomleft';
2409
-        $this->recaptcha_type = 'image';
2410
-        $this->recaptcha_language = 'en';
2411
-        $this->recaptcha_publickey = null;
2412
-        $this->recaptcha_privatekey = null;
2413
-        $this->recaptcha_protected_forms = array();
2414
-        $this->recaptcha_width = 500;
2415
-        $this->default_maximum_number_of_tickets = 10;
2416
-    }
2417
-
2418
-
2419
-
2420
-    /**
2421
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2422
-     *
2423
-     * @since 4.8.8.rc.019
2424
-     */
2425
-    public function do_hooks()
2426
-    {
2427
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2428
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2429
-    }
2430 1953
 
1954
+/**
1955
+ * Config class for storing info on the Organization
1956
+ */
1957
+class EE_Organization_Config extends EE_Config_Base
1958
+{
2431 1959
 
1960
+	/**
1961
+	 * @var string $name
1962
+	 * eg EE4.1
1963
+	 */
1964
+	public $name;
1965
+
1966
+	/**
1967
+	 * @var string $address_1
1968
+	 * eg 123 Onna Road
1969
+	 */
1970
+	public $address_1;
1971
+
1972
+	/**
1973
+	 * @var string $address_2
1974
+	 * eg PO Box 123
1975
+	 */
1976
+	public $address_2;
1977
+
1978
+	/**
1979
+	 * @var string $city
1980
+	 * eg Inna City
1981
+	 */
1982
+	public $city;
1983
+
1984
+	/**
1985
+	 * @var int $STA_ID
1986
+	 * eg 4
1987
+	 */
1988
+	public $STA_ID;
1989
+
1990
+	/**
1991
+	 * @var string $CNT_ISO
1992
+	 * eg US
1993
+	 */
1994
+	public $CNT_ISO;
1995
+
1996
+	/**
1997
+	 * @var string $zip
1998
+	 * eg 12345  or V1A 2B3
1999
+	 */
2000
+	public $zip;
2001
+
2002
+	/**
2003
+	 * @var string $email
2004
+	 * eg [email protected]
2005
+	 */
2006
+	public $email;
2007
+
2008
+
2009
+	/**
2010
+	 * @var string $phone
2011
+	 * eg. 111-111-1111
2012
+	 */
2013
+	public $phone;
2014
+
2015
+
2016
+	/**
2017
+	 * @var string $vat
2018
+	 * VAT/Tax Number
2019
+	 */
2020
+	public $vat;
2021
+
2022
+	/**
2023
+	 * @var string $logo_url
2024
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2025
+	 */
2026
+	public $logo_url;
2027
+
2028
+
2029
+	/**
2030
+	 * The below are all various properties for holding links to organization social network profiles
2031
+	 *
2032
+	 * @var string
2033
+	 */
2034
+	/**
2035
+	 * facebook (facebook.com/profile.name)
2036
+	 *
2037
+	 * @var string
2038
+	 */
2039
+	public $facebook;
2040
+
2041
+
2042
+	/**
2043
+	 * twitter (twitter.com/twitter_handle)
2044
+	 *
2045
+	 * @var string
2046
+	 */
2047
+	public $twitter;
2048
+
2049
+
2050
+	/**
2051
+	 * linkedin (linkedin.com/in/profile_name)
2052
+	 *
2053
+	 * @var string
2054
+	 */
2055
+	public $linkedin;
2056
+
2057
+
2058
+	/**
2059
+	 * pinterest (www.pinterest.com/profile_name)
2060
+	 *
2061
+	 * @var string
2062
+	 */
2063
+	public $pinterest;
2064
+
2065
+
2066
+	/**
2067
+	 * google+ (google.com/+profileName)
2068
+	 *
2069
+	 * @var string
2070
+	 */
2071
+	public $google;
2072
+
2073
+
2074
+	/**
2075
+	 * instagram (instagram.com/handle)
2076
+	 *
2077
+	 * @var string
2078
+	 */
2079
+	public $instagram;
2080
+
2081
+
2082
+
2083
+	/**
2084
+	 *    class constructor
2085
+	 *
2086
+	 * @access    public
2087
+	 */
2088
+	public function __construct()
2089
+	{
2090
+		// set default organization settings
2091
+		//decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2092
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2093
+		$this->address_1 = '123 Onna Road';
2094
+		$this->address_2 = 'PO Box 123';
2095
+		$this->city = 'Inna City';
2096
+		$this->STA_ID = 4;
2097
+		$this->CNT_ISO = 'US';
2098
+		$this->zip = '12345';
2099
+		$this->email = get_bloginfo('admin_email');
2100
+		$this->phone = '';
2101
+		$this->vat = '123456789';
2102
+		$this->logo_url = '';
2103
+		$this->facebook = '';
2104
+		$this->twitter = '';
2105
+		$this->linkedin = '';
2106
+		$this->pinterest = '';
2107
+		$this->google = '';
2108
+		$this->instagram = '';
2109
+	}
2432 2110
 
2433
-    /**
2434
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2435
-     * field matches the config setting for default_STS_ID.
2436
-     */
2437
-    public function set_default_reg_status_on_EEM_Event()
2438
-    {
2439
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2440
-    }
2111
+}
2441 2112
 
2442 2113
 
2443
-    /**
2444
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2445
-     * for Events matches the config setting for default_maximum_number_of_tickets
2446
-     */
2447
-    public function set_default_max_ticket_on_EEM_Event()
2448
-    {
2449
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2450
-    }
2451 2114
 
2115
+/**
2116
+ * Class for defining what's in the EE_Config relating to currency
2117
+ */
2118
+class EE_Currency_Config extends EE_Config_Base
2119
+{
2452 2120
 
2121
+	/**
2122
+	 * @var string $code
2123
+	 * eg 'US'
2124
+	 */
2125
+	public $code;
2126
+
2127
+	/**
2128
+	 * @var string $name
2129
+	 * eg 'Dollar'
2130
+	 */
2131
+	public $name;
2132
+
2133
+	/**
2134
+	 * plural name
2135
+	 *
2136
+	 * @var string $plural
2137
+	 * eg 'Dollars'
2138
+	 */
2139
+	public $plural;
2140
+
2141
+	/**
2142
+	 * currency sign
2143
+	 *
2144
+	 * @var string $sign
2145
+	 * eg '$'
2146
+	 */
2147
+	public $sign;
2148
+
2149
+	/**
2150
+	 * Whether the currency sign should come before the number or not
2151
+	 *
2152
+	 * @var boolean $sign_b4
2153
+	 */
2154
+	public $sign_b4;
2155
+
2156
+	/**
2157
+	 * How many digits should come after the decimal place
2158
+	 *
2159
+	 * @var int $dec_plc
2160
+	 */
2161
+	public $dec_plc;
2162
+
2163
+	/**
2164
+	 * Symbol to use for decimal mark
2165
+	 *
2166
+	 * @var string $dec_mrk
2167
+	 * eg '.'
2168
+	 */
2169
+	public $dec_mrk;
2170
+
2171
+	/**
2172
+	 * Symbol to use for thousands
2173
+	 *
2174
+	 * @var string $thsnds
2175
+	 * eg ','
2176
+	 */
2177
+	public $thsnds;
2178
+
2179
+
2180
+
2181
+	/**
2182
+	 *    class constructor
2183
+	 *
2184
+	 * @access    public
2185
+	 * @param string $CNT_ISO
2186
+	 * @throws \EE_Error
2187
+	 */
2188
+	public function __construct($CNT_ISO = '')
2189
+	{
2190
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2191
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2192
+		// get country code from organization settings or use default
2193
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2194
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2195
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2196
+			: '';
2197
+		// but override if requested
2198
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2199
+		// 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
2200
+		if (
2201
+			! empty($CNT_ISO)
2202
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2203
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2204
+		) {
2205
+			// retrieve the country settings from the db, just in case they have been customized
2206
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2207
+			if ($country instanceof EE_Country) {
2208
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2209
+				$this->name = $country->currency_name_single();    // Dollar
2210
+				$this->plural = $country->currency_name_plural();    // Dollars
2211
+				$this->sign = $country->currency_sign();            // currency sign: $
2212
+				$this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2213
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2214
+				$this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2215
+				$this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2216
+			}
2217
+		}
2218
+		// fallback to hardcoded defaults, in case the above failed
2219
+		if (empty($this->code)) {
2220
+			// set default currency settings
2221
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2222
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2223
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2224
+			$this->sign = '$';    // currency sign: $
2225
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2226
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2227
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2228
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2229
+		}
2230
+	}
2231
+}
2453 2232
 
2454
-    /**
2455
-     * @return boolean
2456
-     */
2457
-    public function track_invalid_checkout_access()
2458
-    {
2459
-        return $this->track_invalid_checkout_access;
2460
-    }
2461 2233
 
2462 2234
 
2235
+/**
2236
+ * Class for defining what's in the EE_Config relating to registration settings
2237
+ */
2238
+class EE_Registration_Config extends EE_Config_Base
2239
+{
2463 2240
 
2464
-    /**
2465
-     * @param boolean $track_invalid_checkout_access
2466
-     */
2467
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2468
-    {
2469
-        $this->track_invalid_checkout_access = filter_var(
2470
-            $track_invalid_checkout_access,
2471
-            FILTER_VALIDATE_BOOLEAN
2472
-        );
2473
-    }
2241
+	/**
2242
+	 * Default registration status
2243
+	 *
2244
+	 * @var string $default_STS_ID
2245
+	 * eg 'RPP'
2246
+	 */
2247
+	public $default_STS_ID;
2248
+
2249
+
2250
+	/**
2251
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2252
+	 * registrations)
2253
+	 * @var int
2254
+	 */
2255
+	public $default_maximum_number_of_tickets;
2256
+
2257
+
2258
+	/**
2259
+	 * level of validation to apply to email addresses
2260
+	 *
2261
+	 * @var string $email_validation_level
2262
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2263
+	 */
2264
+	public $email_validation_level;
2265
+
2266
+	/**
2267
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2268
+	 *
2269
+	 * @var boolean $show_pending_payment_options
2270
+	 */
2271
+	public $show_pending_payment_options;
2272
+
2273
+	/**
2274
+	 * Whether to skip the registration confirmation page
2275
+	 *
2276
+	 * @var boolean $skip_reg_confirmation
2277
+	 */
2278
+	public $skip_reg_confirmation;
2279
+
2280
+	/**
2281
+	 * an array of SPCO reg steps where:
2282
+	 *        the keys denotes the reg step order
2283
+	 *        each element consists of an array with the following elements:
2284
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2285
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2286
+	 *            "slug" => the URL param used to trigger the reg step
2287
+	 *
2288
+	 * @var array $reg_steps
2289
+	 */
2290
+	public $reg_steps;
2291
+
2292
+	/**
2293
+	 * Whether registration confirmation should be the last page of SPCO
2294
+	 *
2295
+	 * @var boolean $reg_confirmation_last
2296
+	 */
2297
+	public $reg_confirmation_last;
2298
+
2299
+	/**
2300
+	 * Whether or not to enable the EE Bot Trap
2301
+	 *
2302
+	 * @var boolean $use_bot_trap
2303
+	 */
2304
+	public $use_bot_trap;
2305
+
2306
+	/**
2307
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2308
+	 *
2309
+	 * @var boolean $use_encryption
2310
+	 */
2311
+	public $use_encryption;
2312
+
2313
+	/**
2314
+	 * Whether or not to use ReCaptcha
2315
+	 *
2316
+	 * @var boolean $use_captcha
2317
+	 */
2318
+	public $use_captcha;
2319
+
2320
+	/**
2321
+	 * ReCaptcha Theme
2322
+	 *
2323
+	 * @var string $recaptcha_theme
2324
+	 *    options: 'dark', 'light', 'invisible'
2325
+	 */
2326
+	public $recaptcha_theme;
2327
+
2328
+	/**
2329
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2330
+	 *
2331
+	 * @var string $recaptcha_badge
2332
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2333
+	 */
2334
+	public $recaptcha_badge;
2335
+
2336
+	/**
2337
+	 * ReCaptcha Type
2338
+	 *
2339
+	 * @var string $recaptcha_type
2340
+	 *    options: 'audio', 'image'
2341
+	 */
2342
+	public $recaptcha_type;
2343
+
2344
+	/**
2345
+	 * ReCaptcha language
2346
+	 *
2347
+	 * @var string $recaptcha_language
2348
+	 * eg 'en'
2349
+	 */
2350
+	public $recaptcha_language;
2351
+
2352
+	/**
2353
+	 * ReCaptcha public key
2354
+	 *
2355
+	 * @var string $recaptcha_publickey
2356
+	 */
2357
+	public $recaptcha_publickey;
2358
+
2359
+	/**
2360
+	 * ReCaptcha private key
2361
+	 *
2362
+	 * @var string $recaptcha_privatekey
2363
+	 */
2364
+	public $recaptcha_privatekey;
2365
+
2366
+	/**
2367
+	 * array of form names protected by ReCaptcha
2368
+	 *
2369
+	 * @var array $recaptcha_protected_forms
2370
+	 */
2371
+	public $recaptcha_protected_forms;
2372
+
2373
+	/**
2374
+	 * ReCaptcha width
2375
+	 *
2376
+	 * @var int $recaptcha_width
2377
+	 * @deprecated
2378
+	 */
2379
+	public $recaptcha_width;
2380
+
2381
+	/**
2382
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2383
+	 *
2384
+	 * @var boolean $track_invalid_checkout_access
2385
+	 */
2386
+	protected $track_invalid_checkout_access = true;
2387
+
2388
+
2389
+
2390
+	/**
2391
+	 *    class constructor
2392
+	 *
2393
+	 * @access    public
2394
+	 */
2395
+	public function __construct()
2396
+	{
2397
+		// set default registration settings
2398
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2399
+		$this->email_validation_level = 'wp_default';
2400
+		$this->show_pending_payment_options = true;
2401
+		$this->skip_reg_confirmation = false;
2402
+		$this->reg_steps = array();
2403
+		$this->reg_confirmation_last = false;
2404
+		$this->use_bot_trap = true;
2405
+		$this->use_encryption = true;
2406
+		$this->use_captcha = false;
2407
+		$this->recaptcha_theme = 'light';
2408
+		$this->recaptcha_badge = 'bottomleft';
2409
+		$this->recaptcha_type = 'image';
2410
+		$this->recaptcha_language = 'en';
2411
+		$this->recaptcha_publickey = null;
2412
+		$this->recaptcha_privatekey = null;
2413
+		$this->recaptcha_protected_forms = array();
2414
+		$this->recaptcha_width = 500;
2415
+		$this->default_maximum_number_of_tickets = 10;
2416
+	}
2417
+
2418
+
2419
+
2420
+	/**
2421
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2422
+	 *
2423
+	 * @since 4.8.8.rc.019
2424
+	 */
2425
+	public function do_hooks()
2426
+	{
2427
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2428
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2429
+	}
2430
+
2431
+
2432
+
2433
+	/**
2434
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2435
+	 * field matches the config setting for default_STS_ID.
2436
+	 */
2437
+	public function set_default_reg_status_on_EEM_Event()
2438
+	{
2439
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2440
+	}
2441
+
2442
+
2443
+	/**
2444
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2445
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2446
+	 */
2447
+	public function set_default_max_ticket_on_EEM_Event()
2448
+	{
2449
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2450
+	}
2451
+
2452
+
2453
+
2454
+	/**
2455
+	 * @return boolean
2456
+	 */
2457
+	public function track_invalid_checkout_access()
2458
+	{
2459
+		return $this->track_invalid_checkout_access;
2460
+	}
2461
+
2462
+
2463
+
2464
+	/**
2465
+	 * @param boolean $track_invalid_checkout_access
2466
+	 */
2467
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2468
+	{
2469
+		$this->track_invalid_checkout_access = filter_var(
2470
+			$track_invalid_checkout_access,
2471
+			FILTER_VALIDATE_BOOLEAN
2472
+		);
2473
+	}
2474 2474
 
2475 2475
 
2476 2476
 
@@ -2484,160 +2484,160 @@  discard block
 block discarded – undo
2484 2484
 class EE_Admin_Config extends EE_Config_Base
2485 2485
 {
2486 2486
 
2487
-    /**
2488
-     * @var boolean $use_personnel_manager
2489
-     */
2490
-    public $use_personnel_manager;
2491
-
2492
-    /**
2493
-     * @var boolean $use_dashboard_widget
2494
-     */
2495
-    public $use_dashboard_widget;
2496
-
2497
-    /**
2498
-     * @var int $events_in_dashboard
2499
-     */
2500
-    public $events_in_dashboard;
2501
-
2502
-    /**
2503
-     * @var boolean $use_event_timezones
2504
-     */
2505
-    public $use_event_timezones;
2506
-
2507
-    /**
2508
-     * @var boolean $use_full_logging
2509
-     */
2510
-    public $use_full_logging;
2511
-
2512
-    /**
2513
-     * @var string $log_file_name
2514
-     */
2515
-    public $log_file_name;
2516
-
2517
-    /**
2518
-     * @var string $debug_file_name
2519
-     */
2520
-    public $debug_file_name;
2521
-
2522
-    /**
2523
-     * @var boolean $use_remote_logging
2524
-     */
2525
-    public $use_remote_logging;
2526
-
2527
-    /**
2528
-     * @var string $remote_logging_url
2529
-     */
2530
-    public $remote_logging_url;
2531
-
2532
-    /**
2533
-     * @var boolean $show_reg_footer
2534
-     */
2535
-    public $show_reg_footer;
2536
-
2537
-    /**
2538
-     * @var string $affiliate_id
2539
-     */
2540
-    public $affiliate_id;
2541
-
2542
-    /**
2543
-     * help tours on or off (global setting)
2544
-     *
2545
-     * @var boolean
2546
-     */
2547
-    public $help_tour_activation;
2548
-
2549
-    /**
2550
-     * adds extra layer of encoding to session data to prevent serialization errors
2551
-     * but is incompatible with some server configuration errors
2552
-     * if you get "500 internal server errors" during registration, try turning this on
2553
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2554
-     *
2555
-     * @var boolean $encode_session_data
2556
-     */
2557
-    private $encode_session_data = false;
2558
-
2559
-
2560
-
2561
-    /**
2562
-     *    class constructor
2563
-     *
2564
-     * @access    public
2565
-     */
2566
-    public function __construct()
2567
-    {
2568
-        // set default general admin settings
2569
-        $this->use_personnel_manager = true;
2570
-        $this->use_dashboard_widget = true;
2571
-        $this->events_in_dashboard = 30;
2572
-        $this->use_event_timezones = false;
2573
-        $this->use_full_logging = false;
2574
-        $this->use_remote_logging = false;
2575
-        $this->remote_logging_url = null;
2576
-        $this->show_reg_footer = true;
2577
-        $this->affiliate_id = 'default';
2578
-        $this->help_tour_activation = true;
2579
-        $this->encode_session_data = false;
2580
-    }
2581
-
2582
-
2583
-
2584
-    /**
2585
-     * @param bool $reset
2586
-     * @return string
2587
-     */
2588
-    public function log_file_name($reset = false)
2589
-    {
2590
-        if (empty($this->log_file_name) || $reset) {
2591
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2592
-            EE_Config::instance()->update_espresso_config(false, false);
2593
-        }
2594
-        return $this->log_file_name;
2595
-    }
2596
-
2597
-
2598
-
2599
-    /**
2600
-     * @param bool $reset
2601
-     * @return string
2602
-     */
2603
-    public function debug_file_name($reset = false)
2604
-    {
2605
-        if (empty($this->debug_file_name) || $reset) {
2606
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2607
-            EE_Config::instance()->update_espresso_config(false, false);
2608
-        }
2609
-        return $this->debug_file_name;
2610
-    }
2611
-
2612
-
2613
-
2614
-    /**
2615
-     * @return string
2616
-     */
2617
-    public function affiliate_id()
2618
-    {
2619
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2620
-    }
2621
-
2622
-
2623
-
2624
-    /**
2625
-     * @return boolean
2626
-     */
2627
-    public function encode_session_data()
2628
-    {
2629
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2630
-    }
2631
-
2632
-
2633
-
2634
-    /**
2635
-     * @param boolean $encode_session_data
2636
-     */
2637
-    public function set_encode_session_data($encode_session_data)
2638
-    {
2639
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2640
-    }
2487
+	/**
2488
+	 * @var boolean $use_personnel_manager
2489
+	 */
2490
+	public $use_personnel_manager;
2491
+
2492
+	/**
2493
+	 * @var boolean $use_dashboard_widget
2494
+	 */
2495
+	public $use_dashboard_widget;
2496
+
2497
+	/**
2498
+	 * @var int $events_in_dashboard
2499
+	 */
2500
+	public $events_in_dashboard;
2501
+
2502
+	/**
2503
+	 * @var boolean $use_event_timezones
2504
+	 */
2505
+	public $use_event_timezones;
2506
+
2507
+	/**
2508
+	 * @var boolean $use_full_logging
2509
+	 */
2510
+	public $use_full_logging;
2511
+
2512
+	/**
2513
+	 * @var string $log_file_name
2514
+	 */
2515
+	public $log_file_name;
2516
+
2517
+	/**
2518
+	 * @var string $debug_file_name
2519
+	 */
2520
+	public $debug_file_name;
2521
+
2522
+	/**
2523
+	 * @var boolean $use_remote_logging
2524
+	 */
2525
+	public $use_remote_logging;
2526
+
2527
+	/**
2528
+	 * @var string $remote_logging_url
2529
+	 */
2530
+	public $remote_logging_url;
2531
+
2532
+	/**
2533
+	 * @var boolean $show_reg_footer
2534
+	 */
2535
+	public $show_reg_footer;
2536
+
2537
+	/**
2538
+	 * @var string $affiliate_id
2539
+	 */
2540
+	public $affiliate_id;
2541
+
2542
+	/**
2543
+	 * help tours on or off (global setting)
2544
+	 *
2545
+	 * @var boolean
2546
+	 */
2547
+	public $help_tour_activation;
2548
+
2549
+	/**
2550
+	 * adds extra layer of encoding to session data to prevent serialization errors
2551
+	 * but is incompatible with some server configuration errors
2552
+	 * if you get "500 internal server errors" during registration, try turning this on
2553
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2554
+	 *
2555
+	 * @var boolean $encode_session_data
2556
+	 */
2557
+	private $encode_session_data = false;
2558
+
2559
+
2560
+
2561
+	/**
2562
+	 *    class constructor
2563
+	 *
2564
+	 * @access    public
2565
+	 */
2566
+	public function __construct()
2567
+	{
2568
+		// set default general admin settings
2569
+		$this->use_personnel_manager = true;
2570
+		$this->use_dashboard_widget = true;
2571
+		$this->events_in_dashboard = 30;
2572
+		$this->use_event_timezones = false;
2573
+		$this->use_full_logging = false;
2574
+		$this->use_remote_logging = false;
2575
+		$this->remote_logging_url = null;
2576
+		$this->show_reg_footer = true;
2577
+		$this->affiliate_id = 'default';
2578
+		$this->help_tour_activation = true;
2579
+		$this->encode_session_data = false;
2580
+	}
2581
+
2582
+
2583
+
2584
+	/**
2585
+	 * @param bool $reset
2586
+	 * @return string
2587
+	 */
2588
+	public function log_file_name($reset = false)
2589
+	{
2590
+		if (empty($this->log_file_name) || $reset) {
2591
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2592
+			EE_Config::instance()->update_espresso_config(false, false);
2593
+		}
2594
+		return $this->log_file_name;
2595
+	}
2596
+
2597
+
2598
+
2599
+	/**
2600
+	 * @param bool $reset
2601
+	 * @return string
2602
+	 */
2603
+	public function debug_file_name($reset = false)
2604
+	{
2605
+		if (empty($this->debug_file_name) || $reset) {
2606
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2607
+			EE_Config::instance()->update_espresso_config(false, false);
2608
+		}
2609
+		return $this->debug_file_name;
2610
+	}
2611
+
2612
+
2613
+
2614
+	/**
2615
+	 * @return string
2616
+	 */
2617
+	public function affiliate_id()
2618
+	{
2619
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2620
+	}
2621
+
2622
+
2623
+
2624
+	/**
2625
+	 * @return boolean
2626
+	 */
2627
+	public function encode_session_data()
2628
+	{
2629
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2630
+	}
2631
+
2632
+
2633
+
2634
+	/**
2635
+	 * @param boolean $encode_session_data
2636
+	 */
2637
+	public function set_encode_session_data($encode_session_data)
2638
+	{
2639
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2640
+	}
2641 2641
 
2642 2642
 
2643 2643
 
@@ -2651,71 +2651,71 @@  discard block
 block discarded – undo
2651 2651
 class EE_Template_Config extends EE_Config_Base
2652 2652
 {
2653 2653
 
2654
-    /**
2655
-     * @var boolean $enable_default_style
2656
-     */
2657
-    public $enable_default_style;
2658
-
2659
-    /**
2660
-     * @var string $custom_style_sheet
2661
-     */
2662
-    public $custom_style_sheet;
2663
-
2664
-    /**
2665
-     * @var boolean $display_address_in_regform
2666
-     */
2667
-    public $display_address_in_regform;
2668
-
2669
-    /**
2670
-     * @var int $display_description_on_multi_reg_page
2671
-     */
2672
-    public $display_description_on_multi_reg_page;
2673
-
2674
-    /**
2675
-     * @var boolean $use_custom_templates
2676
-     */
2677
-    public $use_custom_templates;
2678
-
2679
-    /**
2680
-     * @var string $current_espresso_theme
2681
-     */
2682
-    public $current_espresso_theme;
2683
-
2684
-    /**
2685
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2686
-     */
2687
-    public $EED_Ticket_Selector;
2688
-
2689
-    /**
2690
-     * @var EE_Event_Single_Config $EED_Event_Single
2691
-     */
2692
-    public $EED_Event_Single;
2693
-
2694
-    /**
2695
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2696
-     */
2697
-    public $EED_Events_Archive;
2698
-
2699
-
2700
-
2701
-    /**
2702
-     *    class constructor
2703
-     *
2704
-     * @access    public
2705
-     */
2706
-    public function __construct()
2707
-    {
2708
-        // set default template settings
2709
-        $this->enable_default_style = true;
2710
-        $this->custom_style_sheet = null;
2711
-        $this->display_address_in_regform = true;
2712
-        $this->display_description_on_multi_reg_page = false;
2713
-        $this->use_custom_templates = false;
2714
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2715
-        $this->EED_Event_Single = null;
2716
-        $this->EED_Events_Archive = null;
2717
-        $this->EED_Ticket_Selector = null;
2718
-    }
2654
+	/**
2655
+	 * @var boolean $enable_default_style
2656
+	 */
2657
+	public $enable_default_style;
2658
+
2659
+	/**
2660
+	 * @var string $custom_style_sheet
2661
+	 */
2662
+	public $custom_style_sheet;
2663
+
2664
+	/**
2665
+	 * @var boolean $display_address_in_regform
2666
+	 */
2667
+	public $display_address_in_regform;
2668
+
2669
+	/**
2670
+	 * @var int $display_description_on_multi_reg_page
2671
+	 */
2672
+	public $display_description_on_multi_reg_page;
2673
+
2674
+	/**
2675
+	 * @var boolean $use_custom_templates
2676
+	 */
2677
+	public $use_custom_templates;
2678
+
2679
+	/**
2680
+	 * @var string $current_espresso_theme
2681
+	 */
2682
+	public $current_espresso_theme;
2683
+
2684
+	/**
2685
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2686
+	 */
2687
+	public $EED_Ticket_Selector;
2688
+
2689
+	/**
2690
+	 * @var EE_Event_Single_Config $EED_Event_Single
2691
+	 */
2692
+	public $EED_Event_Single;
2693
+
2694
+	/**
2695
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2696
+	 */
2697
+	public $EED_Events_Archive;
2698
+
2699
+
2700
+
2701
+	/**
2702
+	 *    class constructor
2703
+	 *
2704
+	 * @access    public
2705
+	 */
2706
+	public function __construct()
2707
+	{
2708
+		// set default template settings
2709
+		$this->enable_default_style = true;
2710
+		$this->custom_style_sheet = null;
2711
+		$this->display_address_in_regform = true;
2712
+		$this->display_description_on_multi_reg_page = false;
2713
+		$this->use_custom_templates = false;
2714
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2715
+		$this->EED_Event_Single = null;
2716
+		$this->EED_Events_Archive = null;
2717
+		$this->EED_Ticket_Selector = null;
2718
+	}
2719 2719
 
2720 2720
 }
2721 2721
 
@@ -2727,115 +2727,115 @@  discard block
 block discarded – undo
2727 2727
 class EE_Map_Config extends EE_Config_Base
2728 2728
 {
2729 2729
 
2730
-    /**
2731
-     * @var boolean $use_google_maps
2732
-     */
2733
-    public $use_google_maps;
2734
-
2735
-    /**
2736
-     * @var string $api_key
2737
-     */
2738
-    public $google_map_api_key;
2739
-
2740
-    /**
2741
-     * @var int $event_details_map_width
2742
-     */
2743
-    public $event_details_map_width;
2744
-
2745
-    /**
2746
-     * @var int $event_details_map_height
2747
-     */
2748
-    public $event_details_map_height;
2749
-
2750
-    /**
2751
-     * @var int $event_details_map_zoom
2752
-     */
2753
-    public $event_details_map_zoom;
2754
-
2755
-    /**
2756
-     * @var boolean $event_details_display_nav
2757
-     */
2758
-    public $event_details_display_nav;
2759
-
2760
-    /**
2761
-     * @var boolean $event_details_nav_size
2762
-     */
2763
-    public $event_details_nav_size;
2764
-
2765
-    /**
2766
-     * @var string $event_details_control_type
2767
-     */
2768
-    public $event_details_control_type;
2769
-
2770
-    /**
2771
-     * @var string $event_details_map_align
2772
-     */
2773
-    public $event_details_map_align;
2774
-
2775
-    /**
2776
-     * @var int $event_list_map_width
2777
-     */
2778
-    public $event_list_map_width;
2779
-
2780
-    /**
2781
-     * @var int $event_list_map_height
2782
-     */
2783
-    public $event_list_map_height;
2784
-
2785
-    /**
2786
-     * @var int $event_list_map_zoom
2787
-     */
2788
-    public $event_list_map_zoom;
2789
-
2790
-    /**
2791
-     * @var boolean $event_list_display_nav
2792
-     */
2793
-    public $event_list_display_nav;
2794
-
2795
-    /**
2796
-     * @var boolean $event_list_nav_size
2797
-     */
2798
-    public $event_list_nav_size;
2799
-
2800
-    /**
2801
-     * @var string $event_list_control_type
2802
-     */
2803
-    public $event_list_control_type;
2804
-
2805
-    /**
2806
-     * @var string $event_list_map_align
2807
-     */
2808
-    public $event_list_map_align;
2809
-
2810
-
2811
-
2812
-    /**
2813
-     *    class constructor
2814
-     *
2815
-     * @access    public
2816
-     */
2817
-    public function __construct()
2818
-    {
2819
-        // set default map settings
2820
-        $this->use_google_maps = true;
2821
-        $this->google_map_api_key = '';
2822
-        // for event details pages (reg page)
2823
-        $this->event_details_map_width = 585;            // ee_map_width_single
2824
-        $this->event_details_map_height = 362;            // ee_map_height_single
2825
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2826
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2827
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2828
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2829
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2830
-        // for event list pages
2831
-        $this->event_list_map_width = 300;            // ee_map_width
2832
-        $this->event_list_map_height = 185;        // ee_map_height
2833
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2834
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2835
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2836
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2837
-        $this->event_list_map_align = 'center';            // ee_map_align
2838
-    }
2730
+	/**
2731
+	 * @var boolean $use_google_maps
2732
+	 */
2733
+	public $use_google_maps;
2734
+
2735
+	/**
2736
+	 * @var string $api_key
2737
+	 */
2738
+	public $google_map_api_key;
2739
+
2740
+	/**
2741
+	 * @var int $event_details_map_width
2742
+	 */
2743
+	public $event_details_map_width;
2744
+
2745
+	/**
2746
+	 * @var int $event_details_map_height
2747
+	 */
2748
+	public $event_details_map_height;
2749
+
2750
+	/**
2751
+	 * @var int $event_details_map_zoom
2752
+	 */
2753
+	public $event_details_map_zoom;
2754
+
2755
+	/**
2756
+	 * @var boolean $event_details_display_nav
2757
+	 */
2758
+	public $event_details_display_nav;
2759
+
2760
+	/**
2761
+	 * @var boolean $event_details_nav_size
2762
+	 */
2763
+	public $event_details_nav_size;
2764
+
2765
+	/**
2766
+	 * @var string $event_details_control_type
2767
+	 */
2768
+	public $event_details_control_type;
2769
+
2770
+	/**
2771
+	 * @var string $event_details_map_align
2772
+	 */
2773
+	public $event_details_map_align;
2774
+
2775
+	/**
2776
+	 * @var int $event_list_map_width
2777
+	 */
2778
+	public $event_list_map_width;
2779
+
2780
+	/**
2781
+	 * @var int $event_list_map_height
2782
+	 */
2783
+	public $event_list_map_height;
2784
+
2785
+	/**
2786
+	 * @var int $event_list_map_zoom
2787
+	 */
2788
+	public $event_list_map_zoom;
2789
+
2790
+	/**
2791
+	 * @var boolean $event_list_display_nav
2792
+	 */
2793
+	public $event_list_display_nav;
2794
+
2795
+	/**
2796
+	 * @var boolean $event_list_nav_size
2797
+	 */
2798
+	public $event_list_nav_size;
2799
+
2800
+	/**
2801
+	 * @var string $event_list_control_type
2802
+	 */
2803
+	public $event_list_control_type;
2804
+
2805
+	/**
2806
+	 * @var string $event_list_map_align
2807
+	 */
2808
+	public $event_list_map_align;
2809
+
2810
+
2811
+
2812
+	/**
2813
+	 *    class constructor
2814
+	 *
2815
+	 * @access    public
2816
+	 */
2817
+	public function __construct()
2818
+	{
2819
+		// set default map settings
2820
+		$this->use_google_maps = true;
2821
+		$this->google_map_api_key = '';
2822
+		// for event details pages (reg page)
2823
+		$this->event_details_map_width = 585;            // ee_map_width_single
2824
+		$this->event_details_map_height = 362;            // ee_map_height_single
2825
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2826
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2827
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2828
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2829
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2830
+		// for event list pages
2831
+		$this->event_list_map_width = 300;            // ee_map_width
2832
+		$this->event_list_map_height = 185;        // ee_map_height
2833
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2834
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2835
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2836
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2837
+		$this->event_list_map_align = 'center';            // ee_map_align
2838
+	}
2839 2839
 
2840 2840
 }
2841 2841
 
@@ -2847,47 +2847,47 @@  discard block
 block discarded – undo
2847 2847
 class EE_Events_Archive_Config extends EE_Config_Base
2848 2848
 {
2849 2849
 
2850
-    public $display_status_banner;
2850
+	public $display_status_banner;
2851 2851
 
2852
-    public $display_description;
2852
+	public $display_description;
2853 2853
 
2854
-    public $display_ticket_selector;
2854
+	public $display_ticket_selector;
2855 2855
 
2856
-    public $display_datetimes;
2856
+	public $display_datetimes;
2857 2857
 
2858
-    public $display_venue;
2858
+	public $display_venue;
2859 2859
 
2860
-    public $display_expired_events;
2860
+	public $display_expired_events;
2861 2861
 
2862
-    public $use_sortable_display_order;
2862
+	public $use_sortable_display_order;
2863 2863
 
2864
-    public $display_order_tickets;
2864
+	public $display_order_tickets;
2865 2865
 
2866
-    public $display_order_datetimes;
2866
+	public $display_order_datetimes;
2867 2867
 
2868
-    public $display_order_event;
2868
+	public $display_order_event;
2869 2869
 
2870
-    public $display_order_venue;
2870
+	public $display_order_venue;
2871 2871
 
2872 2872
 
2873 2873
 
2874
-    /**
2875
-     *    class constructor
2876
-     */
2877
-    public function __construct()
2878
-    {
2879
-        $this->display_status_banner = 0;
2880
-        $this->display_description = 1;
2881
-        $this->display_ticket_selector = 0;
2882
-        $this->display_datetimes = 1;
2883
-        $this->display_venue = 0;
2884
-        $this->display_expired_events = 0;
2885
-        $this->use_sortable_display_order = false;
2886
-        $this->display_order_tickets = 100;
2887
-        $this->display_order_datetimes = 110;
2888
-        $this->display_order_event = 120;
2889
-        $this->display_order_venue = 130;
2890
-    }
2874
+	/**
2875
+	 *    class constructor
2876
+	 */
2877
+	public function __construct()
2878
+	{
2879
+		$this->display_status_banner = 0;
2880
+		$this->display_description = 1;
2881
+		$this->display_ticket_selector = 0;
2882
+		$this->display_datetimes = 1;
2883
+		$this->display_venue = 0;
2884
+		$this->display_expired_events = 0;
2885
+		$this->use_sortable_display_order = false;
2886
+		$this->display_order_tickets = 100;
2887
+		$this->display_order_datetimes = 110;
2888
+		$this->display_order_event = 120;
2889
+		$this->display_order_venue = 130;
2890
+	}
2891 2891
 }
2892 2892
 
2893 2893
 
@@ -2898,35 +2898,35 @@  discard block
 block discarded – undo
2898 2898
 class EE_Event_Single_Config extends EE_Config_Base
2899 2899
 {
2900 2900
 
2901
-    public $display_status_banner_single;
2901
+	public $display_status_banner_single;
2902 2902
 
2903
-    public $display_venue;
2903
+	public $display_venue;
2904 2904
 
2905
-    public $use_sortable_display_order;
2905
+	public $use_sortable_display_order;
2906 2906
 
2907
-    public $display_order_tickets;
2907
+	public $display_order_tickets;
2908 2908
 
2909
-    public $display_order_datetimes;
2909
+	public $display_order_datetimes;
2910 2910
 
2911
-    public $display_order_event;
2911
+	public $display_order_event;
2912 2912
 
2913
-    public $display_order_venue;
2913
+	public $display_order_venue;
2914 2914
 
2915 2915
 
2916 2916
 
2917
-    /**
2918
-     *    class constructor
2919
-     */
2920
-    public function __construct()
2921
-    {
2922
-        $this->display_status_banner_single = 0;
2923
-        $this->display_venue = 1;
2924
-        $this->use_sortable_display_order = false;
2925
-        $this->display_order_tickets = 100;
2926
-        $this->display_order_datetimes = 110;
2927
-        $this->display_order_event = 120;
2928
-        $this->display_order_venue = 130;
2929
-    }
2917
+	/**
2918
+	 *    class constructor
2919
+	 */
2920
+	public function __construct()
2921
+	{
2922
+		$this->display_status_banner_single = 0;
2923
+		$this->display_venue = 1;
2924
+		$this->use_sortable_display_order = false;
2925
+		$this->display_order_tickets = 100;
2926
+		$this->display_order_datetimes = 110;
2927
+		$this->display_order_event = 120;
2928
+		$this->display_order_venue = 130;
2929
+	}
2930 2930
 }
2931 2931
 
2932 2932
 
@@ -2937,152 +2937,152 @@  discard block
 block discarded – undo
2937 2937
 class EE_Ticket_Selector_Config extends EE_Config_Base
2938 2938
 {
2939 2939
 
2940
-    /**
2941
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2942
-     */
2943
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2944
-
2945
-    /**
2946
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2947
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2948
-     */
2949
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2950
-
2951
-    /**
2952
-     * @var boolean $show_ticket_sale_columns
2953
-     */
2954
-    public $show_ticket_sale_columns;
2955
-
2956
-    /**
2957
-     * @var boolean $show_ticket_details
2958
-     */
2959
-    public $show_ticket_details;
2960
-
2961
-    /**
2962
-     * @var boolean $show_expired_tickets
2963
-     */
2964
-    public $show_expired_tickets;
2965
-
2966
-    /**
2967
-     * whether or not to display a dropdown box populated with event datetimes
2968
-     * that toggles which tickets are displayed for a ticket selector.
2969
-     * uses one of the *_DATETIME_SELECTOR constants defined above
2970
-     *
2971
-     * @var string $show_datetime_selector
2972
-     */
2973
-    private $show_datetime_selector = 'no_datetime_selector';
2974
-
2975
-    /**
2976
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
2977
-     *
2978
-     * @var int $datetime_selector_threshold
2979
-     */
2980
-    private $datetime_selector_threshold = 3;
2981
-
2982
-
2983
-
2984
-    /**
2985
-     *    class constructor
2986
-     */
2987
-    public function __construct()
2988
-    {
2989
-        $this->show_ticket_sale_columns = true;
2990
-        $this->show_ticket_details = true;
2991
-        $this->show_expired_tickets = true;
2992
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2993
-        $this->datetime_selector_threshold = 3;
2994
-    }
2995
-
2996
-
2997
-
2998
-    /**
2999
-     * returns true if a datetime selector should be displayed
3000
-     *
3001
-     * @param array $datetimes
3002
-     * @return bool
3003
-     */
3004
-    public function showDatetimeSelector(array $datetimes)
3005
-    {
3006
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3007
-        return ! (
3008
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3009
-            || (
3010
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3011
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3012
-            )
3013
-        );
3014
-    }
3015
-
3016
-
3017
-
3018
-    /**
3019
-     * @return string
3020
-     */
3021
-    public function getShowDatetimeSelector()
3022
-    {
3023
-        return $this->show_datetime_selector;
3024
-    }
3025
-
3026
-
3027
-
3028
-    /**
3029
-     * @param bool $keys_only
3030
-     * @return array
3031
-     */
3032
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3033
-    {
3034
-        return $keys_only
3035
-            ? array(
3036
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3037
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3038
-            )
3039
-            : array(
3040
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3041
-                    'Do not show date & time filter', 'event_espresso'
3042
-                ),
3043
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3044
-                    'Maybe show date & time filter', 'event_espresso'
3045
-                ),
3046
-            );
3047
-    }
3048
-
3049
-
3050
-
3051
-    /**
3052
-     * @param string $show_datetime_selector
3053
-     */
3054
-    public function setShowDatetimeSelector($show_datetime_selector)
3055
-    {
3056
-        $this->show_datetime_selector = in_array(
3057
-            $show_datetime_selector,
3058
-            $this->getShowDatetimeSelectorOptions(),
3059
-            true
3060
-        )
3061
-            ? $show_datetime_selector
3062
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3063
-    }
3064
-
3065
-
3066
-
3067
-    /**
3068
-     * @return int
3069
-     */
3070
-    public function getDatetimeSelectorThreshold()
3071
-    {
3072
-        return $this->datetime_selector_threshold;
3073
-    }
3074
-
3075
-
3076
-
3077
-
3078
-    /**
3079
-     * @param int $datetime_selector_threshold
3080
-     */
3081
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3082
-    {
3083
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3084
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3085
-    }
2940
+	/**
2941
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2942
+	 */
2943
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2944
+
2945
+	/**
2946
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2947
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2948
+	 */
2949
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2950
+
2951
+	/**
2952
+	 * @var boolean $show_ticket_sale_columns
2953
+	 */
2954
+	public $show_ticket_sale_columns;
2955
+
2956
+	/**
2957
+	 * @var boolean $show_ticket_details
2958
+	 */
2959
+	public $show_ticket_details;
2960
+
2961
+	/**
2962
+	 * @var boolean $show_expired_tickets
2963
+	 */
2964
+	public $show_expired_tickets;
2965
+
2966
+	/**
2967
+	 * whether or not to display a dropdown box populated with event datetimes
2968
+	 * that toggles which tickets are displayed for a ticket selector.
2969
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
2970
+	 *
2971
+	 * @var string $show_datetime_selector
2972
+	 */
2973
+	private $show_datetime_selector = 'no_datetime_selector';
2974
+
2975
+	/**
2976
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
2977
+	 *
2978
+	 * @var int $datetime_selector_threshold
2979
+	 */
2980
+	private $datetime_selector_threshold = 3;
2981
+
2982
+
2983
+
2984
+	/**
2985
+	 *    class constructor
2986
+	 */
2987
+	public function __construct()
2988
+	{
2989
+		$this->show_ticket_sale_columns = true;
2990
+		$this->show_ticket_details = true;
2991
+		$this->show_expired_tickets = true;
2992
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2993
+		$this->datetime_selector_threshold = 3;
2994
+	}
2995
+
2996
+
2997
+
2998
+	/**
2999
+	 * returns true if a datetime selector should be displayed
3000
+	 *
3001
+	 * @param array $datetimes
3002
+	 * @return bool
3003
+	 */
3004
+	public function showDatetimeSelector(array $datetimes)
3005
+	{
3006
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3007
+		return ! (
3008
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3009
+			|| (
3010
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3011
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3012
+			)
3013
+		);
3014
+	}
3015
+
3016
+
3017
+
3018
+	/**
3019
+	 * @return string
3020
+	 */
3021
+	public function getShowDatetimeSelector()
3022
+	{
3023
+		return $this->show_datetime_selector;
3024
+	}
3025
+
3026
+
3027
+
3028
+	/**
3029
+	 * @param bool $keys_only
3030
+	 * @return array
3031
+	 */
3032
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3033
+	{
3034
+		return $keys_only
3035
+			? array(
3036
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3037
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3038
+			)
3039
+			: array(
3040
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3041
+					'Do not show date & time filter', 'event_espresso'
3042
+				),
3043
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3044
+					'Maybe show date & time filter', 'event_espresso'
3045
+				),
3046
+			);
3047
+	}
3048
+
3049
+
3050
+
3051
+	/**
3052
+	 * @param string $show_datetime_selector
3053
+	 */
3054
+	public function setShowDatetimeSelector($show_datetime_selector)
3055
+	{
3056
+		$this->show_datetime_selector = in_array(
3057
+			$show_datetime_selector,
3058
+			$this->getShowDatetimeSelectorOptions(),
3059
+			true
3060
+		)
3061
+			? $show_datetime_selector
3062
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3063
+	}
3064
+
3065
+
3066
+
3067
+	/**
3068
+	 * @return int
3069
+	 */
3070
+	public function getDatetimeSelectorThreshold()
3071
+	{
3072
+		return $this->datetime_selector_threshold;
3073
+	}
3074
+
3075
+
3076
+
3077
+
3078
+	/**
3079
+	 * @param int $datetime_selector_threshold
3080
+	 */
3081
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3082
+	{
3083
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3084
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3085
+	}
3086 3086
 
3087 3087
 
3088 3088
 
@@ -3100,85 +3100,85 @@  discard block
 block discarded – undo
3100 3100
 class EE_Environment_Config extends EE_Config_Base
3101 3101
 {
3102 3102
 
3103
-    /**
3104
-     * Hold any php environment variables that we want to track.
3105
-     *
3106
-     * @var stdClass;
3107
-     */
3108
-    public $php;
3109
-
3110
-
3111
-
3112
-    /**
3113
-     *    constructor
3114
-     */
3115
-    public function __construct()
3116
-    {
3117
-        $this->php = new stdClass();
3118
-        $this->_set_php_values();
3119
-    }
3120
-
3121
-
3122
-
3123
-    /**
3124
-     * This sets the php environment variables.
3125
-     *
3126
-     * @since 4.4.0
3127
-     * @return void
3128
-     */
3129
-    protected function _set_php_values()
3130
-    {
3131
-        $this->php->max_input_vars = ini_get('max_input_vars');
3132
-        $this->php->version = phpversion();
3133
-    }
3134
-
3135
-
3136
-
3137
-    /**
3138
-     * helper method for determining whether input_count is
3139
-     * reaching the potential maximum the server can handle
3140
-     * according to max_input_vars
3141
-     *
3142
-     * @param int   $input_count the count of input vars.
3143
-     * @return array {
3144
-     *                           An array that represents whether available space and if no available space the error
3145
-     *                           message.
3146
-     * @type bool   $has_space   whether more inputs can be added.
3147
-     * @type string $msg         Any message to be displayed.
3148
-     *                           }
3149
-     */
3150
-    public function max_input_vars_limit_check($input_count = 0)
3151
-    {
3152
-        if (! empty($this->php->max_input_vars)
3153
-            && ($input_count >= $this->php->max_input_vars)
3154
-            && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3155
-        ) {
3156
-            return sprintf(
3157
-                __(
3158
-                    'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3159
-                    'event_espresso'
3160
-                ),
3161
-                '<br>',
3162
-                $input_count,
3163
-                $this->php->max_input_vars
3164
-            );
3165
-        } else {
3166
-            return '';
3167
-        }
3168
-    }
3169
-
3170
-
3171
-
3172
-    /**
3173
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3174
-     *
3175
-     * @since 4.4.1
3176
-     * @return void
3177
-     */
3178
-    public function recheck_values()
3179
-    {
3180
-        $this->_set_php_values();
3181
-    }
3103
+	/**
3104
+	 * Hold any php environment variables that we want to track.
3105
+	 *
3106
+	 * @var stdClass;
3107
+	 */
3108
+	public $php;
3109
+
3110
+
3111
+
3112
+	/**
3113
+	 *    constructor
3114
+	 */
3115
+	public function __construct()
3116
+	{
3117
+		$this->php = new stdClass();
3118
+		$this->_set_php_values();
3119
+	}
3120
+
3121
+
3122
+
3123
+	/**
3124
+	 * This sets the php environment variables.
3125
+	 *
3126
+	 * @since 4.4.0
3127
+	 * @return void
3128
+	 */
3129
+	protected function _set_php_values()
3130
+	{
3131
+		$this->php->max_input_vars = ini_get('max_input_vars');
3132
+		$this->php->version = phpversion();
3133
+	}
3134
+
3135
+
3136
+
3137
+	/**
3138
+	 * helper method for determining whether input_count is
3139
+	 * reaching the potential maximum the server can handle
3140
+	 * according to max_input_vars
3141
+	 *
3142
+	 * @param int   $input_count the count of input vars.
3143
+	 * @return array {
3144
+	 *                           An array that represents whether available space and if no available space the error
3145
+	 *                           message.
3146
+	 * @type bool   $has_space   whether more inputs can be added.
3147
+	 * @type string $msg         Any message to be displayed.
3148
+	 *                           }
3149
+	 */
3150
+	public function max_input_vars_limit_check($input_count = 0)
3151
+	{
3152
+		if (! empty($this->php->max_input_vars)
3153
+			&& ($input_count >= $this->php->max_input_vars)
3154
+			&& (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3155
+		) {
3156
+			return sprintf(
3157
+				__(
3158
+					'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3159
+					'event_espresso'
3160
+				),
3161
+				'<br>',
3162
+				$input_count,
3163
+				$this->php->max_input_vars
3164
+			);
3165
+		} else {
3166
+			return '';
3167
+		}
3168
+	}
3169
+
3170
+
3171
+
3172
+	/**
3173
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3174
+	 *
3175
+	 * @since 4.4.1
3176
+	 * @return void
3177
+	 */
3178
+	public function recheck_values()
3179
+	{
3180
+		$this->_set_php_values();
3181
+	}
3182 3182
 
3183 3183
 
3184 3184
 
@@ -3196,22 +3196,22 @@  discard block
 block discarded – undo
3196 3196
 class EE_Tax_Config extends EE_Config_Base
3197 3197
 {
3198 3198
 
3199
-    /*
3199
+	/*
3200 3200
      * flag to indicate whether or not to display ticket prices with the taxes included
3201 3201
      *
3202 3202
      * @var boolean $prices_displayed_including_taxes
3203 3203
      */
3204
-    public $prices_displayed_including_taxes;
3204
+	public $prices_displayed_including_taxes;
3205 3205
 
3206 3206
 
3207 3207
 
3208
-    /**
3209
-     *    class constructor
3210
-     */
3211
-    public function __construct()
3212
-    {
3213
-        $this->prices_displayed_including_taxes = true;
3214
-    }
3208
+	/**
3209
+	 *    class constructor
3210
+	 */
3211
+	public function __construct()
3212
+	{
3213
+		$this->prices_displayed_including_taxes = true;
3214
+	}
3215 3215
 }
3216 3216
 
3217 3217
 
@@ -3226,17 +3226,17 @@  discard block
 block discarded – undo
3226 3226
 class EE_Messages_Config extends EE_Config_Base
3227 3227
 {
3228 3228
 
3229
-    /**
3230
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3231
-     * A value of 0 represents never deleting.  Default is 0.
3232
-     *
3233
-     * @var integer
3234
-     */
3235
-    public $delete_threshold;
3236
-
3237
-    public function __construct() {
3238
-        $this->delete_threshold = 0;
3239
-    }
3229
+	/**
3230
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3231
+	 * A value of 0 represents never deleting.  Default is 0.
3232
+	 *
3233
+	 * @var integer
3234
+	 */
3235
+	public $delete_threshold;
3236
+
3237
+	public function __construct() {
3238
+		$this->delete_threshold = 0;
3239
+	}
3240 3240
 }
3241 3241
 
3242 3242
 
@@ -3248,34 +3248,34 @@  discard block
 block discarded – undo
3248 3248
 class EE_Gateway_Config extends EE_Config_Base
3249 3249
 {
3250 3250
 
3251
-    /**
3252
-     * Array with keys that are payment gateways slugs, and values are arrays
3253
-     * with any config info the gateway wants to store
3254
-     *
3255
-     * @var array
3256
-     */
3257
-    public $payment_settings;
3258
-
3259
-    /**
3260
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3261
-     * the gateway is stored in the uploads directory
3262
-     *
3263
-     * @var array
3264
-     */
3265
-    public $active_gateways;
3266
-
3267
-
3268
-
3269
-    /**
3270
-     *    class constructor
3271
-     *
3272
-     * @deprecated
3273
-     */
3274
-    public function __construct()
3275
-    {
3276
-        $this->payment_settings = array();
3277
-        $this->active_gateways = array('Invoice' => false);
3278
-    }
3251
+	/**
3252
+	 * Array with keys that are payment gateways slugs, and values are arrays
3253
+	 * with any config info the gateway wants to store
3254
+	 *
3255
+	 * @var array
3256
+	 */
3257
+	public $payment_settings;
3258
+
3259
+	/**
3260
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3261
+	 * the gateway is stored in the uploads directory
3262
+	 *
3263
+	 * @var array
3264
+	 */
3265
+	public $active_gateways;
3266
+
3267
+
3268
+
3269
+	/**
3270
+	 *    class constructor
3271
+	 *
3272
+	 * @deprecated
3273
+	 */
3274
+	public function __construct()
3275
+	{
3276
+		$this->payment_settings = array();
3277
+		$this->active_gateways = array('Invoice' => false);
3278
+	}
3279 3279
 }
3280 3280
 
3281 3281
 // End of file EE_Config.core.php
Please login to merge, or discard this patch.
core/domain/CaffeinatedInterface.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@
 block discarded – undo
12 12
  */
13 13
 interface CaffeinatedInterface
14 14
 {
15
-    /**
16
-     * Used to indicate when functionality is caffeinated or not.
17
-     * @return bool
18
-     */
19
-    public function isCaffeinated();
15
+	/**
16
+	 * Used to indicate when functionality is caffeinated or not.
17
+	 * @return bool
18
+	 */
19
+	public function isCaffeinated();
20 20
 }
21 21
\ No newline at end of file
Please login to merge, or discard this patch.
core/domain/Domain.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -19,54 +19,54 @@
 block discarded – undo
19 19
 class Domain extends DomainBase implements CaffeinatedInterface
20 20
 {
21 21
 
22
-    /**
23
-     * URL path component used to denote an API request
24
-     */
25
-    const API_NAMESPACE = 'ee/v';
22
+	/**
23
+	 * URL path component used to denote an API request
24
+	 */
25
+	const API_NAMESPACE = 'ee/v';
26 26
 
27
-    /**
28
-     * Slug used for the context where a registration status is changed from a manual trigger in the Registration Admin
29
-     * Page ui.
30
-     */
31
-    const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN
32
-        = 'manual_registration_status_change_from_registration_admin';
27
+	/**
28
+	 * Slug used for the context where a registration status is changed from a manual trigger in the Registration Admin
29
+	 * Page ui.
30
+	 */
31
+	const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN
32
+		= 'manual_registration_status_change_from_registration_admin';
33 33
 
34
-    const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
35
-        = 'manual_registration_status_change_from_registration_admin_and_notify';
34
+	const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
35
+		= 'manual_registration_status_change_from_registration_admin_and_notify';
36 36
 
37 37
 
38
-    /**
39
-     * Whether or not EE core is the full premium version.
40
-     * @since $VID:$
41
-     * @var bool
42
-     */
43
-    private $caffeinated;
38
+	/**
39
+	 * Whether or not EE core is the full premium version.
40
+	 * @since $VID:$
41
+	 * @var bool
42
+	 */
43
+	private $caffeinated;
44 44
 
45 45
 
46
-    public function __construct(FilePath $plugin_file, Version $version)
47
-    {
48
-        parent::__construct($plugin_file, $version);
49
-        $this->setCaffeinated();
50
-    }
46
+	public function __construct(FilePath $plugin_file, Version $version)
47
+	{
48
+		parent::__construct($plugin_file, $version);
49
+		$this->setCaffeinated();
50
+	}
51 51
 
52
-    /**
53
-     * Whether or not EE core is the full premium version.
54
-     * @since $VID:$
55
-     * @return bool
56
-     */
57
-    public function isCaffeinated()
58
-    {
59
-        return $this->caffeinated;
60
-    }
52
+	/**
53
+	 * Whether or not EE core is the full premium version.
54
+	 * @since $VID:$
55
+	 * @return bool
56
+	 */
57
+	public function isCaffeinated()
58
+	{
59
+		return $this->caffeinated;
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * Setter for $is_caffeinated property.
65
-     * @since $VID:$
66
-     */
67
-    private function setCaffeinated()
68
-    {
69
-        $this->caffeinated = (! defined('EE_DECAF') || EE_DECAF !== true)
70
-            && is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php');
71
-    }
63
+	/**
64
+	 * Setter for $is_caffeinated property.
65
+	 * @since $VID:$
66
+	 */
67
+	private function setCaffeinated()
68
+	{
69
+		$this->caffeinated = (! defined('EE_DECAF') || EE_DECAF !== true)
70
+			&& is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php');
71
+	}
72 72
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
      */
67 67
     private function setCaffeinated()
68 68
     {
69
-        $this->caffeinated = (! defined('EE_DECAF') || EE_DECAF !== true)
70
-            && is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php');
69
+        $this->caffeinated = ( ! defined('EE_DECAF') || EE_DECAF !== true)
70
+            && is_readable($this->pluginPath().'caffeinated/brewing_regular.php');
71 71
     }
72 72
 }
Please login to merge, or discard this patch.
core/EE_System.core.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         EE_Maintenance_Mode $maintenance_mode = null
149 149
     ) {
150 150
         // check if class object is instantiated
151
-        if (! self::$_instance instanceof EE_System) {
151
+        if ( ! self::$_instance instanceof EE_System) {
152 152
             self::$_instance = new self($registry, $loader, $request, $maintenance_mode);
153 153
         }
154 154
         return self::$_instance;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
         $this->capabilities = $this->loader->getShared('EE_Capabilities');
268 268
         add_action(
269 269
             'AHEE__EE_Capabilities__init_caps__before_initialization',
270
-            function ()
270
+            function()
271 271
             {
272 272
                 LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
273 273
             }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
     {
312 312
         // set autoloaders for all of the classes implementing EEI_Plugin_API
313 313
         // which provide helpers for EE plugin authors to more easily register certain components with EE.
314
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
314
+        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api');
315 315
         $this->loader->getShared('EE_Request_Handler');
316 316
     }
317 317
 
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
         $load_callback,
332 332
         $plugin_file_constant
333 333
     ) {
334
-        if (! defined($version_constant)) {
334
+        if ( ! defined($version_constant)) {
335 335
             return;
336 336
         }
337 337
         $addon_version = constant($version_constant);
338 338
         if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
339 339
             remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
340
-            if (! function_exists('deactivate_plugins')) {
341
-                require_once ABSPATH . 'wp-admin/includes/plugin.php';
340
+            if ( ! function_exists('deactivate_plugins')) {
341
+                require_once ABSPATH.'wp-admin/includes/plugin.php';
342 342
             }
343 343
             deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
344 344
             unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
                     $addon_name,
352 352
                     $min_version_required
353 353
                 ),
354
-                __FILE__, __FUNCTION__ . "({$addon_name})", __LINE__
354
+                __FILE__, __FUNCTION__."({$addon_name})", __LINE__
355 355
             );
356 356
             EE_Error::get_notices(false, true);
357 357
         }
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
                 true
402 402
             )
403 403
         ) {
404
-            include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
404
+            include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php';
405 405
         }
406 406
         do_action('AHEE__EE_System__load_espresso_addons__complete');
407 407
     }
@@ -508,11 +508,11 @@  discard block
 block discarded – undo
508 508
     private function fix_espresso_db_upgrade_option($espresso_db_update = null)
509 509
     {
510 510
         do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
511
-        if (! $espresso_db_update) {
511
+        if ( ! $espresso_db_update) {
512 512
             $espresso_db_update = get_option('espresso_db_update');
513 513
         }
514 514
         // check that option is an array
515
-        if (! is_array($espresso_db_update)) {
515
+        if ( ! is_array($espresso_db_update)) {
516 516
             // if option is FALSE, then it never existed
517 517
             if ($espresso_db_update === false) {
518 518
                 // make $espresso_db_update an array and save option with autoload OFF
@@ -532,10 +532,10 @@  discard block
 block discarded – undo
532 532
                     //so it must be numerically-indexed, where values are versions installed...
533 533
                     //fix it!
534 534
                     $version_string                         = $should_be_array;
535
-                    $corrected_db_update[ $version_string ] = array('unknown-date');
535
+                    $corrected_db_update[$version_string] = array('unknown-date');
536 536
                 } else {
537 537
                     //ok it checks out
538
-                    $corrected_db_update[ $should_be_version_string ] = $should_be_array;
538
+                    $corrected_db_update[$should_be_version_string] = $should_be_array;
539 539
                 }
540 540
             }
541 541
             $espresso_db_update = $corrected_db_update;
@@ -617,13 +617,13 @@  discard block
 block discarded – undo
617 617
      */
618 618
     public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
619 619
     {
620
-        if (! $version_history) {
620
+        if ( ! $version_history) {
621 621
             $version_history = $this->fix_espresso_db_upgrade_option($version_history);
622 622
         }
623 623
         if ($current_version_to_add === null) {
624 624
             $current_version_to_add = espresso_version();
625 625
         }
626
-        $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
626
+        $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time());
627 627
         // re-save
628 628
         return update_option('espresso_db_update', $version_history);
629 629
     }
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
         if ($activation_history_for_addon) {
717 717
             //it exists, so this isn't a completely new install
718 718
             //check if this version already in that list of previously installed versions
719
-            if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) {
719
+            if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) {
720 720
                 //it a version we haven't seen before
721 721
                 if ($version_is_higher === 1) {
722 722
                     $req_type = EE_System::req_type_upgrade;
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
             foreach ($activation_history as $version => $times_activated) {
797 797
                 //check there is a record of when this version was activated. Otherwise,
798 798
                 //mark it as unknown
799
-                if (! $times_activated) {
799
+                if ( ! $times_activated) {
800 800
                     $times_activated = array('unknown-date');
801 801
                 }
802 802
                 if (is_string($times_activated)) {
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
     private function _parse_model_names()
898 898
     {
899 899
         //get all the files in the EE_MODELS folder that end in .model.php
900
-        $models                 = glob(EE_MODELS . '*.model.php');
900
+        $models                 = glob(EE_MODELS.'*.model.php');
901 901
         $model_names            = array();
902 902
         $non_abstract_db_models = array();
903 903
         foreach ($models as $model) {
@@ -906,9 +906,9 @@  discard block
 block discarded – undo
906 906
             $short_name      = str_replace('EEM_', '', $classname);
907 907
             $reflectionClass = new ReflectionClass($classname);
908 908
             if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
909
-                $non_abstract_db_models[ $short_name ] = $classname;
909
+                $non_abstract_db_models[$short_name] = $classname;
910 910
             }
911
-            $model_names[ $short_name ] = $classname;
911
+            $model_names[$short_name] = $classname;
912 912
         }
913 913
         $this->registry->models                 = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
914 914
         $this->registry->non_abstract_db_models = apply_filters(
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
             )
944 944
         );
945 945
         if ($domain->isCaffeinated()) {
946
-            require_once EE_CAFF_PATH . 'brewing_regular.php';
946
+            require_once EE_CAFF_PATH.'brewing_regular.php';
947 947
         }
948 948
     }
949 949
 
@@ -996,17 +996,17 @@  discard block
 block discarded – undo
996 996
         $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
997 997
             'AHEE__EE_System__register_shortcodes_modules_and_addons'
998 998
         );
999
-        if (! empty($class_names)) {
999
+        if ( ! empty($class_names)) {
1000 1000
             $msg = __(
1001 1001
                 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
1002 1002
                 'event_espresso'
1003 1003
             );
1004 1004
             $msg .= '<ul>';
1005 1005
             foreach ($class_names as $class_name) {
1006
-                $msg .= '<li><b>Event Espresso - ' . str_replace(
1006
+                $msg .= '<li><b>Event Espresso - '.str_replace(
1007 1007
                         array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '',
1008 1008
                         $class_name
1009
-                    ) . '</b></li>';
1009
+                    ).'</b></li>';
1010 1010
             }
1011 1011
             $msg .= '</ul>';
1012 1012
             $msg .= __(
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
     private function _deactivate_incompatible_addons()
1078 1078
     {
1079 1079
         $incompatible_addons = get_option('ee_incompatible_addons', array());
1080
-        if (! empty($incompatible_addons)) {
1080
+        if ( ! empty($incompatible_addons)) {
1081 1081
             $active_plugins = get_option('active_plugins', array());
1082 1082
             foreach ($active_plugins as $active_plugin) {
1083 1083
                 foreach ($incompatible_addons as $incompatible_addon) {
@@ -1172,10 +1172,10 @@  discard block
 block discarded – undo
1172 1172
         do_action('AHEE__EE_System__core_loaded_and_ready');
1173 1173
         // load_espresso_template_tags
1174 1174
         if (
1175
-            is_readable(EE_PUBLIC . 'template_tags.php')
1175
+            is_readable(EE_PUBLIC.'template_tags.php')
1176 1176
             && ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isFeed())
1177 1177
         ) {
1178
-            require_once EE_PUBLIC . 'template_tags.php';
1178
+            require_once EE_PUBLIC.'template_tags.php';
1179 1179
         }
1180 1180
         do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1181 1181
         if ($this->request->isAdmin() || $this->request->isFrontend() || $this->request->isIframe()) {
@@ -1239,13 +1239,13 @@  discard block
 block discarded – undo
1239 1239
     public static function do_not_cache()
1240 1240
     {
1241 1241
         // set no cache constants
1242
-        if (! defined('DONOTCACHEPAGE')) {
1242
+        if ( ! defined('DONOTCACHEPAGE')) {
1243 1243
             define('DONOTCACHEPAGE', true);
1244 1244
         }
1245
-        if (! defined('DONOTCACHCEOBJECT')) {
1245
+        if ( ! defined('DONOTCACHCEOBJECT')) {
1246 1246
             define('DONOTCACHCEOBJECT', true);
1247 1247
         }
1248
-        if (! defined('DONOTCACHEDB')) {
1248
+        if ( ! defined('DONOTCACHEDB')) {
1249 1249
             define('DONOTCACHEDB', true);
1250 1250
         }
1251 1251
         // add no cache headers
Please login to merge, or discard this patch.
Indentation   +1265 added lines, -1265 removed lines patch added patch discarded remove patch
@@ -32,1271 +32,1271 @@
 block discarded – undo
32 32
 {
33 33
 
34 34
 
35
-    /**
36
-     * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
37
-     * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
38
-     */
39
-    const req_type_normal = 0;
40
-
41
-    /**
42
-     * Indicates this is a brand new installation of EE so we should install
43
-     * tables and default data etc
44
-     */
45
-    const req_type_new_activation = 1;
46
-
47
-    /**
48
-     * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
49
-     * and we just exited maintenance mode). We MUST check the database is setup properly
50
-     * and that default data is setup too
51
-     */
52
-    const req_type_reactivation = 2;
53
-
54
-    /**
55
-     * indicates that EE has been upgraded since its previous request.
56
-     * We may have data migration scripts to call and will want to trigger maintenance mode
57
-     */
58
-    const req_type_upgrade = 3;
59
-
60
-    /**
61
-     * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
62
-     */
63
-    const req_type_downgrade = 4;
64
-
65
-    /**
66
-     * @deprecated since version 4.6.0.dev.006
67
-     * Now whenever a new_activation is detected the request type is still just
68
-     * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
69
-     * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
70
-     * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
71
-     * (Specifically, when the migration manager indicates migrations are finished
72
-     * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
73
-     */
74
-    const req_type_activation_but_not_installed = 5;
75
-
76
-    /**
77
-     * option prefix for recording the activation history (like core's "espresso_db_update") of addons
78
-     */
79
-    const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
80
-
81
-
82
-    /**
83
-     * @var EE_System $_instance
84
-     */
85
-    private static $_instance;
86
-
87
-    /**
88
-     * @var EE_Registry $registry
89
-     */
90
-    private $registry;
91
-
92
-    /**
93
-     * @var LoaderInterface $loader
94
-     */
95
-    private $loader;
96
-
97
-    /**
98
-     * @var EE_Capabilities $capabilities
99
-     */
100
-    private $capabilities;
101
-
102
-    /**
103
-     * @var RequestInterface $request
104
-     */
105
-    private $request;
106
-
107
-    /**
108
-     * @var EE_Maintenance_Mode $maintenance_mode
109
-     */
110
-    private $maintenance_mode;
111
-
112
-    /**
113
-     * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
114
-     * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
115
-     *
116
-     * @var int $_req_type
117
-     */
118
-    private $_req_type;
119
-
120
-    /**
121
-     * Whether or not there was a non-micro version change in EE core version during this request
122
-     *
123
-     * @var boolean $_major_version_change
124
-     */
125
-    private $_major_version_change = false;
126
-
127
-    /**
128
-     * A Context DTO dedicated solely to identifying the current request type.
129
-     *
130
-     * @var RequestTypeContextCheckerInterface $request_type
131
-     */
132
-    private $request_type;
133
-
134
-
135
-
136
-    /**
137
-     * @singleton method used to instantiate class object
138
-     * @param EE_Registry|null         $registry
139
-     * @param LoaderInterface|null     $loader
140
-     * @param RequestInterface|null          $request
141
-     * @param EE_Maintenance_Mode|null $maintenance_mode
142
-     * @return EE_System
143
-     */
144
-    public static function instance(
145
-        EE_Registry $registry = null,
146
-        LoaderInterface $loader = null,
147
-        RequestInterface $request = null,
148
-        EE_Maintenance_Mode $maintenance_mode = null
149
-    ) {
150
-        // check if class object is instantiated
151
-        if (! self::$_instance instanceof EE_System) {
152
-            self::$_instance = new self($registry, $loader, $request, $maintenance_mode);
153
-        }
154
-        return self::$_instance;
155
-    }
156
-
157
-
158
-
159
-    /**
160
-     * resets the instance and returns it
161
-     *
162
-     * @return EE_System
163
-     */
164
-    public static function reset()
165
-    {
166
-        self::$_instance->_req_type = null;
167
-        //make sure none of the old hooks are left hanging around
168
-        remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
169
-        //we need to reset the migration manager in order for it to detect DMSs properly
170
-        EE_Data_Migration_Manager::reset();
171
-        self::instance()->detect_activations_or_upgrades();
172
-        self::instance()->perform_activations_upgrades_and_migrations();
173
-        return self::instance();
174
-    }
175
-
176
-
177
-
178
-    /**
179
-     * sets hooks for running rest of system
180
-     * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
181
-     * starting EE Addons from any other point may lead to problems
182
-     *
183
-     * @param EE_Registry         $registry
184
-     * @param LoaderInterface     $loader
185
-     * @param RequestInterface          $request
186
-     * @param EE_Maintenance_Mode $maintenance_mode
187
-     */
188
-    private function __construct(
189
-        EE_Registry $registry,
190
-        LoaderInterface $loader,
191
-        RequestInterface $request,
192
-        EE_Maintenance_Mode $maintenance_mode
193
-    ) {
194
-        $this->registry         = $registry;
195
-        $this->loader           = $loader;
196
-        $this->request          = $request;
197
-        $this->maintenance_mode = $maintenance_mode;
198
-        do_action('AHEE__EE_System__construct__begin', $this);
199
-        add_action(
200
-            'AHEE__EE_Bootstrap__load_espresso_addons',
201
-            array($this, 'loadCapabilities'),
202
-            5
203
-        );
204
-        add_action(
205
-            'AHEE__EE_Bootstrap__load_espresso_addons',
206
-            array($this, 'loadCommandBus'),
207
-            7
208
-        );
209
-        add_action(
210
-            'AHEE__EE_Bootstrap__load_espresso_addons',
211
-            array($this, 'loadPluginApi'),
212
-            9
213
-        );
214
-        // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
215
-        add_action(
216
-            'AHEE__EE_Bootstrap__load_espresso_addons',
217
-            array($this, 'load_espresso_addons')
218
-        );
219
-        // when an ee addon is activated, we want to call the core hook(s) again
220
-        // because the newly-activated addon didn't get a chance to run at all
221
-        add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
222
-        // detect whether install or upgrade
223
-        add_action(
224
-            'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
225
-            array($this, 'detect_activations_or_upgrades'),
226
-            3
227
-        );
228
-        // load EE_Config, EE_Textdomain, etc
229
-        add_action(
230
-            'AHEE__EE_Bootstrap__load_core_configuration',
231
-            array($this, 'load_core_configuration'),
232
-            5
233
-        );
234
-        // load EE_Config, EE_Textdomain, etc
235
-        add_action(
236
-            'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
237
-            array($this, 'register_shortcodes_modules_and_widgets'),
238
-            7
239
-        );
240
-        // you wanna get going? I wanna get going... let's get going!
241
-        add_action(
242
-            'AHEE__EE_Bootstrap__brew_espresso',
243
-            array($this, 'brew_espresso'),
244
-            9
245
-        );
246
-        //other housekeeping
247
-        //exclude EE critical pages from wp_list_pages
248
-        add_filter(
249
-            'wp_list_pages_excludes',
250
-            array($this, 'remove_pages_from_wp_list_pages'),
251
-            10
252
-        );
253
-        // ALL EE Addons should use the following hook point to attach their initial setup too
254
-        // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
255
-        do_action('AHEE__EE_System__construct__complete', $this);
256
-    }
257
-
258
-
259
-    /**
260
-     * load and setup EE_Capabilities
261
-     *
262
-     * @return void
263
-     * @throws EE_Error
264
-     */
265
-    public function loadCapabilities()
266
-    {
267
-        $this->capabilities = $this->loader->getShared('EE_Capabilities');
268
-        add_action(
269
-            'AHEE__EE_Capabilities__init_caps__before_initialization',
270
-            function ()
271
-            {
272
-                LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
273
-            }
274
-        );
275
-    }
276
-
277
-
278
-
279
-    /**
280
-     * create and cache the CommandBus, and also add middleware
281
-     * The CapChecker middleware requires the use of EE_Capabilities
282
-     * which is why we need to load the CommandBus after Caps are set up
283
-     *
284
-     * @return void
285
-     * @throws EE_Error
286
-     */
287
-    public function loadCommandBus()
288
-    {
289
-        $this->loader->getShared(
290
-            'CommandBusInterface',
291
-            array(
292
-                null,
293
-                apply_filters(
294
-                    'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
295
-                    array(
296
-                        $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'),
297
-                        $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'),
298
-                    )
299
-                ),
300
-            )
301
-        );
302
-    }
303
-
304
-
305
-
306
-    /**
307
-     * @return void
308
-     * @throws EE_Error
309
-     */
310
-    public function loadPluginApi()
311
-    {
312
-        // set autoloaders for all of the classes implementing EEI_Plugin_API
313
-        // which provide helpers for EE plugin authors to more easily register certain components with EE.
314
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
315
-        $this->loader->getShared('EE_Request_Handler');
316
-    }
317
-
318
-
319
-    /**
320
-     * @param string $addon_name
321
-     * @param string $version_constant
322
-     * @param string $min_version_required
323
-     * @param string $load_callback
324
-     * @param string $plugin_file_constant
325
-     * @return void
326
-     */
327
-    private function deactivateIncompatibleAddon(
328
-        $addon_name,
329
-        $version_constant,
330
-        $min_version_required,
331
-        $load_callback,
332
-        $plugin_file_constant
333
-    ) {
334
-        if (! defined($version_constant)) {
335
-            return;
336
-        }
337
-        $addon_version = constant($version_constant);
338
-        if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
339
-            remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
340
-            if (! function_exists('deactivate_plugins')) {
341
-                require_once ABSPATH . 'wp-admin/includes/plugin.php';
342
-            }
343
-            deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
344
-            unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
345
-            EE_Error::add_error(
346
-                sprintf(
347
-                    esc_html__(
348
-                        'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.',
349
-                        'event_espresso'
350
-                    ),
351
-                    $addon_name,
352
-                    $min_version_required
353
-                ),
354
-                __FILE__, __FUNCTION__ . "({$addon_name})", __LINE__
355
-            );
356
-            EE_Error::get_notices(false, true);
357
-        }
358
-    }
359
-
360
-
361
-    /**
362
-     * load_espresso_addons
363
-     * allow addons to load first so that they can set hooks for running DMS's, etc
364
-     * this is hooked into both:
365
-     *    'AHEE__EE_Bootstrap__load_core_configuration'
366
-     *        which runs during the WP 'plugins_loaded' action at priority 5
367
-     *    and the WP 'activate_plugin' hook point
368
-     *
369
-     * @access public
370
-     * @return void
371
-     */
372
-    public function load_espresso_addons()
373
-    {
374
-        $this->deactivateIncompatibleAddon(
375
-            'Wait Lists',
376
-            'EE_WAIT_LISTS_VERSION',
377
-            '1.0.0.beta.074',
378
-            'load_espresso_wait_lists',
379
-            'EE_WAIT_LISTS_PLUGIN_FILE'
380
-        );
381
-        $this->deactivateIncompatibleAddon(
382
-            'Automated Upcoming Event Notifications',
383
-            'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION',
384
-            '1.0.0.beta.091',
385
-            'load_espresso_automated_upcoming_event_notification',
386
-            'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE'
387
-        );
388
-        do_action('AHEE__EE_System__load_espresso_addons');
389
-        //if the WP API basic auth plugin isn't already loaded, load it now.
390
-        //We want it for mobile apps. Just include the entire plugin
391
-        //also, don't load the basic auth when a plugin is getting activated, because
392
-        //it could be the basic auth plugin, and it doesn't check if its methods are already defined
393
-        //and causes a fatal error
394
-        if (
395
-            $this->request->getRequestParam('activate') !== 'true'
396
-            && ! function_exists('json_basic_auth_handler')
397
-            && ! function_exists('json_basic_auth_error')
398
-            && ! in_array(
399
-                $this->request->getRequestParam('action'),
400
-                array('activate', 'activate-selected'),
401
-                true
402
-            )
403
-        ) {
404
-            include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
405
-        }
406
-        do_action('AHEE__EE_System__load_espresso_addons__complete');
407
-    }
408
-
409
-
410
-
411
-    /**
412
-     * detect_activations_or_upgrades
413
-     * Checks for activation or upgrade of core first;
414
-     * then also checks if any registered addons have been activated or upgraded
415
-     * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
416
-     * which runs during the WP 'plugins_loaded' action at priority 3
417
-     *
418
-     * @access public
419
-     * @return void
420
-     */
421
-    public function detect_activations_or_upgrades()
422
-    {
423
-        //first off: let's make sure to handle core
424
-        $this->detect_if_activation_or_upgrade();
425
-        foreach ($this->registry->addons as $addon) {
426
-            if ($addon instanceof EE_Addon) {
427
-                //detect teh request type for that addon
428
-                $addon->detect_activation_or_upgrade();
429
-            }
430
-        }
431
-    }
432
-
433
-
434
-
435
-    /**
436
-     * detect_if_activation_or_upgrade
437
-     * Takes care of detecting whether this is a brand new install or code upgrade,
438
-     * and either setting up the DB or setting up maintenance mode etc.
439
-     *
440
-     * @access public
441
-     * @return void
442
-     */
443
-    public function detect_if_activation_or_upgrade()
444
-    {
445
-        do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
446
-        // check if db has been updated, or if its a brand-new installation
447
-        $espresso_db_update = $this->fix_espresso_db_upgrade_option();
448
-        $request_type       = $this->detect_req_type($espresso_db_update);
449
-        //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
450
-        switch ($request_type) {
451
-            case EE_System::req_type_new_activation:
452
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
453
-                $this->_handle_core_version_change($espresso_db_update);
454
-                break;
455
-            case EE_System::req_type_reactivation:
456
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
457
-                $this->_handle_core_version_change($espresso_db_update);
458
-                break;
459
-            case EE_System::req_type_upgrade:
460
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
461
-                //migrations may be required now that we've upgraded
462
-                $this->maintenance_mode->set_maintenance_mode_if_db_old();
463
-                $this->_handle_core_version_change($espresso_db_update);
464
-                //				echo "done upgrade";die;
465
-                break;
466
-            case EE_System::req_type_downgrade:
467
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
468
-                //its possible migrations are no longer required
469
-                $this->maintenance_mode->set_maintenance_mode_if_db_old();
470
-                $this->_handle_core_version_change($espresso_db_update);
471
-                break;
472
-            case EE_System::req_type_normal:
473
-            default:
474
-                break;
475
-        }
476
-        do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
477
-    }
478
-
479
-
480
-
481
-    /**
482
-     * Updates the list of installed versions and sets hooks for
483
-     * initializing the database later during the request
484
-     *
485
-     * @param array $espresso_db_update
486
-     */
487
-    private function _handle_core_version_change($espresso_db_update)
488
-    {
489
-        $this->update_list_of_installed_versions($espresso_db_update);
490
-        //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
491
-        add_action(
492
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
493
-            array($this, 'initialize_db_if_no_migrations_required')
494
-        );
495
-    }
496
-
497
-
498
-
499
-    /**
500
-     * standardizes the wp option 'espresso_db_upgrade' which actually stores
501
-     * information about what versions of EE have been installed and activated,
502
-     * NOT necessarily the state of the database
503
-     *
504
-     * @param mixed $espresso_db_update           the value of the WordPress option.
505
-     *                                            If not supplied, fetches it from the options table
506
-     * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
507
-     */
508
-    private function fix_espresso_db_upgrade_option($espresso_db_update = null)
509
-    {
510
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
511
-        if (! $espresso_db_update) {
512
-            $espresso_db_update = get_option('espresso_db_update');
513
-        }
514
-        // check that option is an array
515
-        if (! is_array($espresso_db_update)) {
516
-            // if option is FALSE, then it never existed
517
-            if ($espresso_db_update === false) {
518
-                // make $espresso_db_update an array and save option with autoload OFF
519
-                $espresso_db_update = array();
520
-                add_option('espresso_db_update', $espresso_db_update, '', 'no');
521
-            } else {
522
-                // option is NOT FALSE but also is NOT an array, so make it an array and save it
523
-                $espresso_db_update = array($espresso_db_update => array());
524
-                update_option('espresso_db_update', $espresso_db_update);
525
-            }
526
-        } else {
527
-            $corrected_db_update = array();
528
-            //if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
529
-            foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
530
-                if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
531
-                    //the key is an int, and the value IS NOT an array
532
-                    //so it must be numerically-indexed, where values are versions installed...
533
-                    //fix it!
534
-                    $version_string                         = $should_be_array;
535
-                    $corrected_db_update[ $version_string ] = array('unknown-date');
536
-                } else {
537
-                    //ok it checks out
538
-                    $corrected_db_update[ $should_be_version_string ] = $should_be_array;
539
-                }
540
-            }
541
-            $espresso_db_update = $corrected_db_update;
542
-            update_option('espresso_db_update', $espresso_db_update);
543
-        }
544
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
545
-        return $espresso_db_update;
546
-    }
547
-
548
-
549
-
550
-    /**
551
-     * Does the traditional work of setting up the plugin's database and adding default data.
552
-     * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
553
-     * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
554
-     * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
555
-     * so that it will be done when migrations are finished
556
-     *
557
-     * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
558
-     * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
559
-     *                                       This is a resource-intensive job
560
-     *                                       so we prefer to only do it when necessary
561
-     * @return void
562
-     * @throws EE_Error
563
-     */
564
-    public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
565
-    {
566
-        $request_type = $this->detect_req_type();
567
-        //only initialize system if we're not in maintenance mode.
568
-        if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
569
-            update_option('ee_flush_rewrite_rules', true);
570
-            if ($verify_schema) {
571
-                EEH_Activation::initialize_db_and_folders();
572
-            }
573
-            EEH_Activation::initialize_db_content();
574
-            EEH_Activation::system_initialization();
575
-            if ($initialize_addons_too) {
576
-                $this->initialize_addons();
577
-            }
578
-        } else {
579
-            EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
580
-        }
581
-        if ($request_type === EE_System::req_type_new_activation
582
-            || $request_type === EE_System::req_type_reactivation
583
-            || (
584
-                $request_type === EE_System::req_type_upgrade
585
-                && $this->is_major_version_change()
586
-            )
587
-        ) {
588
-            add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
589
-        }
590
-    }
591
-
592
-
593
-
594
-    /**
595
-     * Initializes the db for all registered addons
596
-     *
597
-     * @throws EE_Error
598
-     */
599
-    public function initialize_addons()
600
-    {
601
-        //foreach registered addon, make sure its db is up-to-date too
602
-        foreach ($this->registry->addons as $addon) {
603
-            if ($addon instanceof EE_Addon) {
604
-                $addon->initialize_db_if_no_migrations_required();
605
-            }
606
-        }
607
-    }
608
-
609
-
610
-
611
-    /**
612
-     * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
613
-     *
614
-     * @param    array  $version_history
615
-     * @param    string $current_version_to_add version to be added to the version history
616
-     * @return    boolean success as to whether or not this option was changed
617
-     */
618
-    public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
619
-    {
620
-        if (! $version_history) {
621
-            $version_history = $this->fix_espresso_db_upgrade_option($version_history);
622
-        }
623
-        if ($current_version_to_add === null) {
624
-            $current_version_to_add = espresso_version();
625
-        }
626
-        $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
627
-        // re-save
628
-        return update_option('espresso_db_update', $version_history);
629
-    }
630
-
631
-
632
-
633
-    /**
634
-     * Detects if the current version indicated in the has existed in the list of
635
-     * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
636
-     *
637
-     * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
638
-     *                                  If not supplied, fetches it from the options table.
639
-     *                                  Also, caches its result so later parts of the code can also know whether
640
-     *                                  there's been an update or not. This way we can add the current version to
641
-     *                                  espresso_db_update, but still know if this is a new install or not
642
-     * @return int one of the constants on EE_System::req_type_
643
-     */
644
-    public function detect_req_type($espresso_db_update = null)
645
-    {
646
-        if ($this->_req_type === null) {
647
-            $espresso_db_update          = ! empty($espresso_db_update)
648
-                ? $espresso_db_update
649
-                : $this->fix_espresso_db_upgrade_option();
650
-            $this->_req_type             = EE_System::detect_req_type_given_activation_history(
651
-                $espresso_db_update,
652
-                'ee_espresso_activation', espresso_version()
653
-            );
654
-            $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
655
-            $this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal);
656
-        }
657
-        return $this->_req_type;
658
-    }
659
-
660
-
661
-
662
-    /**
663
-     * Returns whether or not there was a non-micro version change (ie, change in either
664
-     * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
665
-     * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
666
-     *
667
-     * @param $activation_history
668
-     * @return bool
669
-     */
670
-    private function _detect_major_version_change($activation_history)
671
-    {
672
-        $previous_version       = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
673
-        $previous_version_parts = explode('.', $previous_version);
674
-        $current_version_parts  = explode('.', espresso_version());
675
-        return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
676
-               && ($previous_version_parts[0] !== $current_version_parts[0]
677
-                   || $previous_version_parts[1] !== $current_version_parts[1]
678
-               );
679
-    }
680
-
681
-
682
-
683
-    /**
684
-     * Returns true if either the major or minor version of EE changed during this request.
685
-     * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001
686
-     *
687
-     * @return bool
688
-     */
689
-    public function is_major_version_change()
690
-    {
691
-        return $this->_major_version_change;
692
-    }
693
-
694
-
695
-
696
-    /**
697
-     * Determines the request type for any ee addon, given three piece of info: the current array of activation
698
-     * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
699
-     * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
700
-     * just activated to (for core that will always be espresso_version())
701
-     *
702
-     * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
703
-     *                                                 ee plugin. for core that's 'espresso_db_update'
704
-     * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
705
-     *                                                 indicate that this plugin was just activated
706
-     * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
707
-     *                                                 espresso_version())
708
-     * @return int one of the constants on EE_System::req_type_*
709
-     */
710
-    public static function detect_req_type_given_activation_history(
711
-        $activation_history_for_addon,
712
-        $activation_indicator_option_name,
713
-        $version_to_upgrade_to
714
-    ) {
715
-        $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
716
-        if ($activation_history_for_addon) {
717
-            //it exists, so this isn't a completely new install
718
-            //check if this version already in that list of previously installed versions
719
-            if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) {
720
-                //it a version we haven't seen before
721
-                if ($version_is_higher === 1) {
722
-                    $req_type = EE_System::req_type_upgrade;
723
-                } else {
724
-                    $req_type = EE_System::req_type_downgrade;
725
-                }
726
-                delete_option($activation_indicator_option_name);
727
-            } else {
728
-                // its not an update. maybe a reactivation?
729
-                if (get_option($activation_indicator_option_name, false)) {
730
-                    if ($version_is_higher === -1) {
731
-                        $req_type = EE_System::req_type_downgrade;
732
-                    } elseif ($version_is_higher === 0) {
733
-                        //we've seen this version before, but it's an activation. must be a reactivation
734
-                        $req_type = EE_System::req_type_reactivation;
735
-                    } else {//$version_is_higher === 1
736
-                        $req_type = EE_System::req_type_upgrade;
737
-                    }
738
-                    delete_option($activation_indicator_option_name);
739
-                } else {
740
-                    //we've seen this version before and the activation indicate doesn't show it was just activated
741
-                    if ($version_is_higher === -1) {
742
-                        $req_type = EE_System::req_type_downgrade;
743
-                    } elseif ($version_is_higher === 0) {
744
-                        //we've seen this version before and it's not an activation. its normal request
745
-                        $req_type = EE_System::req_type_normal;
746
-                    } else {//$version_is_higher === 1
747
-                        $req_type = EE_System::req_type_upgrade;
748
-                    }
749
-                }
750
-            }
751
-        } else {
752
-            //brand new install
753
-            $req_type = EE_System::req_type_new_activation;
754
-            delete_option($activation_indicator_option_name);
755
-        }
756
-        return $req_type;
757
-    }
758
-
759
-
760
-
761
-    /**
762
-     * Detects if the $version_to_upgrade_to is higher than the most recent version in
763
-     * the $activation_history_for_addon
764
-     *
765
-     * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
766
-     *                                             sometimes containing 'unknown-date'
767
-     * @param string $version_to_upgrade_to        (current version)
768
-     * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
769
-     *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
770
-     *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
771
-     *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
772
-     */
773
-    private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
774
-    {
775
-        //find the most recently-activated version
776
-        $most_recently_active_version =
777
-            EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
778
-        return version_compare($version_to_upgrade_to, $most_recently_active_version);
779
-    }
780
-
781
-
782
-
783
-    /**
784
-     * Gets the most recently active version listed in the activation history,
785
-     * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
786
-     *
787
-     * @param array $activation_history  (keys are versions, values are arrays of times activated,
788
-     *                                   sometimes containing 'unknown-date'
789
-     * @return string
790
-     */
791
-    private static function _get_most_recently_active_version_from_activation_history($activation_history)
792
-    {
793
-        $most_recently_active_version_activation = '1970-01-01 00:00:00';
794
-        $most_recently_active_version            = '0.0.0.dev.000';
795
-        if (is_array($activation_history)) {
796
-            foreach ($activation_history as $version => $times_activated) {
797
-                //check there is a record of when this version was activated. Otherwise,
798
-                //mark it as unknown
799
-                if (! $times_activated) {
800
-                    $times_activated = array('unknown-date');
801
-                }
802
-                if (is_string($times_activated)) {
803
-                    $times_activated = array($times_activated);
804
-                }
805
-                foreach ($times_activated as $an_activation) {
806
-                    if ($an_activation !== 'unknown-date'
807
-                        && $an_activation
808
-                           > $most_recently_active_version_activation) {
809
-                        $most_recently_active_version            = $version;
810
-                        $most_recently_active_version_activation = $an_activation === 'unknown-date'
811
-                            ? '1970-01-01 00:00:00'
812
-                            : $an_activation;
813
-                    }
814
-                }
815
-            }
816
-        }
817
-        return $most_recently_active_version;
818
-    }
819
-
820
-
821
-
822
-    /**
823
-     * This redirects to the about EE page after activation
824
-     *
825
-     * @return void
826
-     */
827
-    public function redirect_to_about_ee()
828
-    {
829
-        $notices = EE_Error::get_notices(false);
830
-        //if current user is an admin and it's not an ajax or rest request
831
-        if (
832
-            ! isset($notices['errors'])
833
-            && $this->request->isAdmin()
834
-            && apply_filters(
835
-                'FHEE__EE_System__redirect_to_about_ee__do_redirect',
836
-                $this->capabilities->current_user_can('manage_options', 'espresso_about_default')
837
-            )
838
-        ) {
839
-            $query_params = array('page' => 'espresso_about');
840
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
841
-                $query_params['new_activation'] = true;
842
-            }
843
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
844
-                $query_params['reactivation'] = true;
845
-            }
846
-            $url = add_query_arg($query_params, admin_url('admin.php'));
847
-            wp_safe_redirect($url);
848
-            exit();
849
-        }
850
-    }
851
-
852
-
853
-
854
-    /**
855
-     * load_core_configuration
856
-     * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
857
-     * which runs during the WP 'plugins_loaded' action at priority 5
858
-     *
859
-     * @return void
860
-     * @throws ReflectionException
861
-     */
862
-    public function load_core_configuration()
863
-    {
864
-        do_action('AHEE__EE_System__load_core_configuration__begin', $this);
865
-        $this->loader->getShared('EE_Load_Textdomain');
866
-        //load textdomain
867
-        EE_Load_Textdomain::load_textdomain();
868
-        // load and setup EE_Config and EE_Network_Config
869
-        $config = $this->loader->getShared('EE_Config');
870
-        $this->loader->getShared('EE_Network_Config');
871
-        // setup autoloaders
872
-        // enable logging?
873
-        if ($config->admin->use_full_logging) {
874
-            $this->loader->getShared('EE_Log');
875
-        }
876
-        // check for activation errors
877
-        $activation_errors = get_option('ee_plugin_activation_errors', false);
878
-        if ($activation_errors) {
879
-            EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
880
-            update_option('ee_plugin_activation_errors', false);
881
-        }
882
-        // get model names
883
-        $this->_parse_model_names();
884
-        //load caf stuff a chance to play during the activation process too.
885
-        $this->_maybe_brew_regular();
886
-        do_action('AHEE__EE_System__load_core_configuration__complete', $this);
887
-    }
888
-
889
-
890
-
891
-    /**
892
-     * cycles through all of the models/*.model.php files, and assembles an array of model names
893
-     *
894
-     * @return void
895
-     * @throws ReflectionException
896
-     */
897
-    private function _parse_model_names()
898
-    {
899
-        //get all the files in the EE_MODELS folder that end in .model.php
900
-        $models                 = glob(EE_MODELS . '*.model.php');
901
-        $model_names            = array();
902
-        $non_abstract_db_models = array();
903
-        foreach ($models as $model) {
904
-            // get model classname
905
-            $classname       = EEH_File::get_classname_from_filepath_with_standard_filename($model);
906
-            $short_name      = str_replace('EEM_', '', $classname);
907
-            $reflectionClass = new ReflectionClass($classname);
908
-            if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
909
-                $non_abstract_db_models[ $short_name ] = $classname;
910
-            }
911
-            $model_names[ $short_name ] = $classname;
912
-        }
913
-        $this->registry->models                 = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
914
-        $this->registry->non_abstract_db_models = apply_filters(
915
-            'FHEE__EE_System__parse_implemented_model_names',
916
-            $non_abstract_db_models
917
-        );
918
-    }
919
-
920
-
921
-    /**
922
-     * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
923
-     * that need to be setup before our EE_System launches.
924
-     *
925
-     * @return void
926
-     * @throws DomainException
927
-     * @throws InvalidArgumentException
928
-     * @throws InvalidDataTypeException
929
-     * @throws InvalidInterfaceException
930
-     * @throws InvalidClassException
931
-     * @throws InvalidFilePathException
932
-     */
933
-    private function _maybe_brew_regular()
934
-    {
935
-        /** @var Domain $domain */
936
-        $domain = DomainFactory::getShared(
937
-            new FullyQualifiedName(
938
-                'EventEspresso\core\domain\Domain'
939
-            ),
940
-            array(
941
-                new FilePath(EVENT_ESPRESSO_MAIN_FILE),
942
-                Version::fromString(espresso_version())
943
-            )
944
-        );
945
-        if ($domain->isCaffeinated()) {
946
-            require_once EE_CAFF_PATH . 'brewing_regular.php';
947
-        }
948
-    }
949
-
950
-
951
-
952
-    /**
953
-     * register_shortcodes_modules_and_widgets
954
-     * generate lists of shortcodes and modules, then verify paths and classes
955
-     * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
956
-     * which runs during the WP 'plugins_loaded' action at priority 7
957
-     *
958
-     * @access public
959
-     * @return void
960
-     * @throws Exception
961
-     */
962
-    public function register_shortcodes_modules_and_widgets()
963
-    {
964
-        if ($this->request->isFrontend() || $this->request->isIframe()) {
965
-            try {
966
-                // load, register, and add shortcodes the new way
967
-                $this->loader->getShared(
968
-                    'EventEspresso\core\services\shortcodes\ShortcodesManager',
969
-                    array(
970
-                        // and the old way, but we'll put it under control of the new system
971
-                        EE_Config::getLegacyShortcodesManager(),
972
-                    )
973
-                );
974
-            } catch (Exception $exception) {
975
-                new ExceptionStackTraceDisplay($exception);
976
-            }
977
-        }
978
-        do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
979
-        // check for addons using old hook point
980
-        if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
981
-            $this->_incompatible_addon_error();
982
-        }
983
-    }
984
-
985
-
986
-
987
-    /**
988
-     * _incompatible_addon_error
989
-     *
990
-     * @access public
991
-     * @return void
992
-     */
993
-    private function _incompatible_addon_error()
994
-    {
995
-        // get array of classes hooking into here
996
-        $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
997
-            'AHEE__EE_System__register_shortcodes_modules_and_addons'
998
-        );
999
-        if (! empty($class_names)) {
1000
-            $msg = __(
1001
-                'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
1002
-                'event_espresso'
1003
-            );
1004
-            $msg .= '<ul>';
1005
-            foreach ($class_names as $class_name) {
1006
-                $msg .= '<li><b>Event Espresso - ' . str_replace(
1007
-                        array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '',
1008
-                        $class_name
1009
-                    ) . '</b></li>';
1010
-            }
1011
-            $msg .= '</ul>';
1012
-            $msg .= __(
1013
-                'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
1014
-                'event_espresso'
1015
-            );
1016
-            // save list of incompatible addons to wp-options for later use
1017
-            add_option('ee_incompatible_addons', $class_names, '', 'no');
1018
-            if (is_admin()) {
1019
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1020
-            }
1021
-        }
1022
-    }
1023
-
1024
-
1025
-
1026
-    /**
1027
-     * brew_espresso
1028
-     * begins the process of setting hooks for initializing EE in the correct order
1029
-     * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
1030
-     * which runs during the WP 'plugins_loaded' action at priority 9
1031
-     *
1032
-     * @return void
1033
-     */
1034
-    public function brew_espresso()
1035
-    {
1036
-        do_action('AHEE__EE_System__brew_espresso__begin', $this);
1037
-        // load some final core systems
1038
-        add_action('init', array($this, 'set_hooks_for_core'), 1);
1039
-        add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
1040
-        add_action('init', array($this, 'load_CPTs_and_session'), 5);
1041
-        add_action('init', array($this, 'load_controllers'), 7);
1042
-        add_action('init', array($this, 'core_loaded_and_ready'), 9);
1043
-        add_action('init', array($this, 'initialize'), 10);
1044
-        add_action('init', array($this, 'initialize_last'), 100);
1045
-        if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
1046
-            // pew pew pew
1047
-            $this->loader->getShared('EE_PUE');
1048
-            do_action('AHEE__EE_System__brew_espresso__after_pue_init');
1049
-        }
1050
-        do_action('AHEE__EE_System__brew_espresso__complete', $this);
1051
-    }
1052
-
1053
-
1054
-
1055
-    /**
1056
-     *    set_hooks_for_core
1057
-     *
1058
-     * @access public
1059
-     * @return    void
1060
-     * @throws EE_Error
1061
-     */
1062
-    public function set_hooks_for_core()
1063
-    {
1064
-        $this->_deactivate_incompatible_addons();
1065
-        do_action('AHEE__EE_System__set_hooks_for_core');
1066
-        $this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan');
1067
-        //caps need to be initialized on every request so that capability maps are set.
1068
-        //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674
1069
-        $this->registry->CAP->init_caps();
1070
-    }
1071
-
1072
-
1073
-
1074
-    /**
1075
-     * Using the information gathered in EE_System::_incompatible_addon_error,
1076
-     * deactivates any addons considered incompatible with the current version of EE
1077
-     */
1078
-    private function _deactivate_incompatible_addons()
1079
-    {
1080
-        $incompatible_addons = get_option('ee_incompatible_addons', array());
1081
-        if (! empty($incompatible_addons)) {
1082
-            $active_plugins = get_option('active_plugins', array());
1083
-            foreach ($active_plugins as $active_plugin) {
1084
-                foreach ($incompatible_addons as $incompatible_addon) {
1085
-                    if (strpos($active_plugin, $incompatible_addon) !== false) {
1086
-                        unset($_GET['activate']);
1087
-                        espresso_deactivate_plugin($active_plugin);
1088
-                    }
1089
-                }
1090
-            }
1091
-        }
1092
-    }
1093
-
1094
-
1095
-
1096
-    /**
1097
-     *    perform_activations_upgrades_and_migrations
1098
-     *
1099
-     * @access public
1100
-     * @return    void
1101
-     */
1102
-    public function perform_activations_upgrades_and_migrations()
1103
-    {
1104
-        do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
1105
-    }
1106
-
1107
-
1108
-
1109
-    /**
1110
-     *    load_CPTs_and_session
1111
-     *
1112
-     * @access public
1113
-     * @return    void
1114
-     */
1115
-    public function load_CPTs_and_session()
1116
-    {
1117
-        do_action('AHEE__EE_System__load_CPTs_and_session__start');
1118
-        // register Custom Post Types
1119
-        $this->loader->getShared('EE_Register_CPTs');
1120
-        do_action('AHEE__EE_System__load_CPTs_and_session__complete');
1121
-    }
1122
-
1123
-
1124
-
1125
-    /**
1126
-     * load_controllers
1127
-     * this is the best place to load any additional controllers that needs access to EE core.
1128
-     * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
1129
-     * time
1130
-     *
1131
-     * @access public
1132
-     * @return void
1133
-     */
1134
-    public function load_controllers()
1135
-    {
1136
-        do_action('AHEE__EE_System__load_controllers__start');
1137
-        // let's get it started
1138
-        if (
1139
-            ! $this->maintenance_mode->level()
1140
-            && ($this->request->isFrontend() || $this->request->isFrontAjax())
1141
-        ) {
1142
-            do_action('AHEE__EE_System__load_controllers__load_front_controllers');
1143
-            $this->loader->getShared('EE_Front_Controller');
1144
-        } elseif ($this->request->isAdmin() || $this->request->isAdminAjax()) {
1145
-            do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1146
-            $this->loader->getShared('EE_Admin');
1147
-        }
1148
-        do_action('AHEE__EE_System__load_controllers__complete');
1149
-    }
1150
-
1151
-
1152
-
1153
-    /**
1154
-     * core_loaded_and_ready
1155
-     * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1156
-     *
1157
-     * @access public
1158
-     * @return void
1159
-     */
1160
-    public function core_loaded_and_ready()
1161
-    {
1162
-        if (
1163
-            $this->request->isAdmin()
1164
-            || $this->request->isEeAjax()
1165
-            || $this->request->isFrontend()
1166
-        ) {
1167
-            $this->loader->getShared('EE_Session');
1168
-        }
1169
-        do_action('AHEE__EE_System__core_loaded_and_ready');
1170
-        // load_espresso_template_tags
1171
-        if (
1172
-            is_readable(EE_PUBLIC . 'template_tags.php')
1173
-            && ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isFeed())
1174
-        ) {
1175
-            require_once EE_PUBLIC . 'template_tags.php';
1176
-        }
1177
-        do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1178
-        if ($this->request->isAdmin() || $this->request->isFrontend() || $this->request->isIframe()) {
1179
-            $this->loader->getShared('EventEspresso\core\services\assets\Registry');
1180
-        }
1181
-    }
1182
-
1183
-
1184
-
1185
-    /**
1186
-     * initialize
1187
-     * this is the best place to begin initializing client code
1188
-     *
1189
-     * @access public
1190
-     * @return void
1191
-     */
1192
-    public function initialize()
1193
-    {
1194
-        do_action('AHEE__EE_System__initialize');
1195
-    }
1196
-
1197
-
1198
-
1199
-    /**
1200
-     * initialize_last
1201
-     * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1202
-     * initialize has done so
1203
-     *
1204
-     * @access public
1205
-     * @return void
1206
-     */
1207
-    public function initialize_last()
1208
-    {
1209
-        do_action('AHEE__EE_System__initialize_last');
1210
-        add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1211
-    }
1212
-
1213
-
1214
-
1215
-    /**
1216
-     * @return void
1217
-     * @throws EE_Error
1218
-     */
1219
-    public function addEspressoToolbar()
1220
-    {
1221
-        $this->loader->getShared(
1222
-            'EventEspresso\core\domain\services\admin\AdminToolBar',
1223
-            array($this->registry->CAP)
1224
-        );
1225
-    }
1226
-
1227
-
1228
-
1229
-    /**
1230
-     * do_not_cache
1231
-     * sets no cache headers and defines no cache constants for WP plugins
1232
-     *
1233
-     * @access public
1234
-     * @return void
1235
-     */
1236
-    public static function do_not_cache()
1237
-    {
1238
-        // set no cache constants
1239
-        if (! defined('DONOTCACHEPAGE')) {
1240
-            define('DONOTCACHEPAGE', true);
1241
-        }
1242
-        if (! defined('DONOTCACHCEOBJECT')) {
1243
-            define('DONOTCACHCEOBJECT', true);
1244
-        }
1245
-        if (! defined('DONOTCACHEDB')) {
1246
-            define('DONOTCACHEDB', true);
1247
-        }
1248
-        // add no cache headers
1249
-        add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1250
-        // plus a little extra for nginx and Google Chrome
1251
-        add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1252
-        // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1253
-        remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1254
-    }
1255
-
1256
-
1257
-
1258
-    /**
1259
-     *    extra_nocache_headers
1260
-     *
1261
-     * @access    public
1262
-     * @param $headers
1263
-     * @return    array
1264
-     */
1265
-    public static function extra_nocache_headers($headers)
1266
-    {
1267
-        // for NGINX
1268
-        $headers['X-Accel-Expires'] = 0;
1269
-        // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1270
-        $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1271
-        return $headers;
1272
-    }
1273
-
1274
-
1275
-
1276
-    /**
1277
-     *    nocache_headers
1278
-     *
1279
-     * @access    public
1280
-     * @return    void
1281
-     */
1282
-    public static function nocache_headers()
1283
-    {
1284
-        nocache_headers();
1285
-    }
1286
-
1287
-
1288
-
1289
-    /**
1290
-     * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1291
-     * never returned with the function.
1292
-     *
1293
-     * @param  array $exclude_array any existing pages being excluded are in this array.
1294
-     * @return array
1295
-     */
1296
-    public function remove_pages_from_wp_list_pages($exclude_array)
1297
-    {
1298
-        return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1299
-    }
35
+	/**
36
+	 * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
37
+	 * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
38
+	 */
39
+	const req_type_normal = 0;
40
+
41
+	/**
42
+	 * Indicates this is a brand new installation of EE so we should install
43
+	 * tables and default data etc
44
+	 */
45
+	const req_type_new_activation = 1;
46
+
47
+	/**
48
+	 * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
49
+	 * and we just exited maintenance mode). We MUST check the database is setup properly
50
+	 * and that default data is setup too
51
+	 */
52
+	const req_type_reactivation = 2;
53
+
54
+	/**
55
+	 * indicates that EE has been upgraded since its previous request.
56
+	 * We may have data migration scripts to call and will want to trigger maintenance mode
57
+	 */
58
+	const req_type_upgrade = 3;
59
+
60
+	/**
61
+	 * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
62
+	 */
63
+	const req_type_downgrade = 4;
64
+
65
+	/**
66
+	 * @deprecated since version 4.6.0.dev.006
67
+	 * Now whenever a new_activation is detected the request type is still just
68
+	 * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
69
+	 * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
70
+	 * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
71
+	 * (Specifically, when the migration manager indicates migrations are finished
72
+	 * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
73
+	 */
74
+	const req_type_activation_but_not_installed = 5;
75
+
76
+	/**
77
+	 * option prefix for recording the activation history (like core's "espresso_db_update") of addons
78
+	 */
79
+	const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
80
+
81
+
82
+	/**
83
+	 * @var EE_System $_instance
84
+	 */
85
+	private static $_instance;
86
+
87
+	/**
88
+	 * @var EE_Registry $registry
89
+	 */
90
+	private $registry;
91
+
92
+	/**
93
+	 * @var LoaderInterface $loader
94
+	 */
95
+	private $loader;
96
+
97
+	/**
98
+	 * @var EE_Capabilities $capabilities
99
+	 */
100
+	private $capabilities;
101
+
102
+	/**
103
+	 * @var RequestInterface $request
104
+	 */
105
+	private $request;
106
+
107
+	/**
108
+	 * @var EE_Maintenance_Mode $maintenance_mode
109
+	 */
110
+	private $maintenance_mode;
111
+
112
+	/**
113
+	 * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
114
+	 * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
115
+	 *
116
+	 * @var int $_req_type
117
+	 */
118
+	private $_req_type;
119
+
120
+	/**
121
+	 * Whether or not there was a non-micro version change in EE core version during this request
122
+	 *
123
+	 * @var boolean $_major_version_change
124
+	 */
125
+	private $_major_version_change = false;
126
+
127
+	/**
128
+	 * A Context DTO dedicated solely to identifying the current request type.
129
+	 *
130
+	 * @var RequestTypeContextCheckerInterface $request_type
131
+	 */
132
+	private $request_type;
133
+
134
+
135
+
136
+	/**
137
+	 * @singleton method used to instantiate class object
138
+	 * @param EE_Registry|null         $registry
139
+	 * @param LoaderInterface|null     $loader
140
+	 * @param RequestInterface|null          $request
141
+	 * @param EE_Maintenance_Mode|null $maintenance_mode
142
+	 * @return EE_System
143
+	 */
144
+	public static function instance(
145
+		EE_Registry $registry = null,
146
+		LoaderInterface $loader = null,
147
+		RequestInterface $request = null,
148
+		EE_Maintenance_Mode $maintenance_mode = null
149
+	) {
150
+		// check if class object is instantiated
151
+		if (! self::$_instance instanceof EE_System) {
152
+			self::$_instance = new self($registry, $loader, $request, $maintenance_mode);
153
+		}
154
+		return self::$_instance;
155
+	}
156
+
157
+
158
+
159
+	/**
160
+	 * resets the instance and returns it
161
+	 *
162
+	 * @return EE_System
163
+	 */
164
+	public static function reset()
165
+	{
166
+		self::$_instance->_req_type = null;
167
+		//make sure none of the old hooks are left hanging around
168
+		remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
169
+		//we need to reset the migration manager in order for it to detect DMSs properly
170
+		EE_Data_Migration_Manager::reset();
171
+		self::instance()->detect_activations_or_upgrades();
172
+		self::instance()->perform_activations_upgrades_and_migrations();
173
+		return self::instance();
174
+	}
175
+
176
+
177
+
178
+	/**
179
+	 * sets hooks for running rest of system
180
+	 * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
181
+	 * starting EE Addons from any other point may lead to problems
182
+	 *
183
+	 * @param EE_Registry         $registry
184
+	 * @param LoaderInterface     $loader
185
+	 * @param RequestInterface          $request
186
+	 * @param EE_Maintenance_Mode $maintenance_mode
187
+	 */
188
+	private function __construct(
189
+		EE_Registry $registry,
190
+		LoaderInterface $loader,
191
+		RequestInterface $request,
192
+		EE_Maintenance_Mode $maintenance_mode
193
+	) {
194
+		$this->registry         = $registry;
195
+		$this->loader           = $loader;
196
+		$this->request          = $request;
197
+		$this->maintenance_mode = $maintenance_mode;
198
+		do_action('AHEE__EE_System__construct__begin', $this);
199
+		add_action(
200
+			'AHEE__EE_Bootstrap__load_espresso_addons',
201
+			array($this, 'loadCapabilities'),
202
+			5
203
+		);
204
+		add_action(
205
+			'AHEE__EE_Bootstrap__load_espresso_addons',
206
+			array($this, 'loadCommandBus'),
207
+			7
208
+		);
209
+		add_action(
210
+			'AHEE__EE_Bootstrap__load_espresso_addons',
211
+			array($this, 'loadPluginApi'),
212
+			9
213
+		);
214
+		// allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
215
+		add_action(
216
+			'AHEE__EE_Bootstrap__load_espresso_addons',
217
+			array($this, 'load_espresso_addons')
218
+		);
219
+		// when an ee addon is activated, we want to call the core hook(s) again
220
+		// because the newly-activated addon didn't get a chance to run at all
221
+		add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
222
+		// detect whether install or upgrade
223
+		add_action(
224
+			'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
225
+			array($this, 'detect_activations_or_upgrades'),
226
+			3
227
+		);
228
+		// load EE_Config, EE_Textdomain, etc
229
+		add_action(
230
+			'AHEE__EE_Bootstrap__load_core_configuration',
231
+			array($this, 'load_core_configuration'),
232
+			5
233
+		);
234
+		// load EE_Config, EE_Textdomain, etc
235
+		add_action(
236
+			'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
237
+			array($this, 'register_shortcodes_modules_and_widgets'),
238
+			7
239
+		);
240
+		// you wanna get going? I wanna get going... let's get going!
241
+		add_action(
242
+			'AHEE__EE_Bootstrap__brew_espresso',
243
+			array($this, 'brew_espresso'),
244
+			9
245
+		);
246
+		//other housekeeping
247
+		//exclude EE critical pages from wp_list_pages
248
+		add_filter(
249
+			'wp_list_pages_excludes',
250
+			array($this, 'remove_pages_from_wp_list_pages'),
251
+			10
252
+		);
253
+		// ALL EE Addons should use the following hook point to attach their initial setup too
254
+		// it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
255
+		do_action('AHEE__EE_System__construct__complete', $this);
256
+	}
257
+
258
+
259
+	/**
260
+	 * load and setup EE_Capabilities
261
+	 *
262
+	 * @return void
263
+	 * @throws EE_Error
264
+	 */
265
+	public function loadCapabilities()
266
+	{
267
+		$this->capabilities = $this->loader->getShared('EE_Capabilities');
268
+		add_action(
269
+			'AHEE__EE_Capabilities__init_caps__before_initialization',
270
+			function ()
271
+			{
272
+				LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
273
+			}
274
+		);
275
+	}
276
+
277
+
278
+
279
+	/**
280
+	 * create and cache the CommandBus, and also add middleware
281
+	 * The CapChecker middleware requires the use of EE_Capabilities
282
+	 * which is why we need to load the CommandBus after Caps are set up
283
+	 *
284
+	 * @return void
285
+	 * @throws EE_Error
286
+	 */
287
+	public function loadCommandBus()
288
+	{
289
+		$this->loader->getShared(
290
+			'CommandBusInterface',
291
+			array(
292
+				null,
293
+				apply_filters(
294
+					'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
295
+					array(
296
+						$this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'),
297
+						$this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'),
298
+					)
299
+				),
300
+			)
301
+		);
302
+	}
303
+
304
+
305
+
306
+	/**
307
+	 * @return void
308
+	 * @throws EE_Error
309
+	 */
310
+	public function loadPluginApi()
311
+	{
312
+		// set autoloaders for all of the classes implementing EEI_Plugin_API
313
+		// which provide helpers for EE plugin authors to more easily register certain components with EE.
314
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
315
+		$this->loader->getShared('EE_Request_Handler');
316
+	}
317
+
318
+
319
+	/**
320
+	 * @param string $addon_name
321
+	 * @param string $version_constant
322
+	 * @param string $min_version_required
323
+	 * @param string $load_callback
324
+	 * @param string $plugin_file_constant
325
+	 * @return void
326
+	 */
327
+	private function deactivateIncompatibleAddon(
328
+		$addon_name,
329
+		$version_constant,
330
+		$min_version_required,
331
+		$load_callback,
332
+		$plugin_file_constant
333
+	) {
334
+		if (! defined($version_constant)) {
335
+			return;
336
+		}
337
+		$addon_version = constant($version_constant);
338
+		if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
339
+			remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
340
+			if (! function_exists('deactivate_plugins')) {
341
+				require_once ABSPATH . 'wp-admin/includes/plugin.php';
342
+			}
343
+			deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
344
+			unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
345
+			EE_Error::add_error(
346
+				sprintf(
347
+					esc_html__(
348
+						'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.',
349
+						'event_espresso'
350
+					),
351
+					$addon_name,
352
+					$min_version_required
353
+				),
354
+				__FILE__, __FUNCTION__ . "({$addon_name})", __LINE__
355
+			);
356
+			EE_Error::get_notices(false, true);
357
+		}
358
+	}
359
+
360
+
361
+	/**
362
+	 * load_espresso_addons
363
+	 * allow addons to load first so that they can set hooks for running DMS's, etc
364
+	 * this is hooked into both:
365
+	 *    'AHEE__EE_Bootstrap__load_core_configuration'
366
+	 *        which runs during the WP 'plugins_loaded' action at priority 5
367
+	 *    and the WP 'activate_plugin' hook point
368
+	 *
369
+	 * @access public
370
+	 * @return void
371
+	 */
372
+	public function load_espresso_addons()
373
+	{
374
+		$this->deactivateIncompatibleAddon(
375
+			'Wait Lists',
376
+			'EE_WAIT_LISTS_VERSION',
377
+			'1.0.0.beta.074',
378
+			'load_espresso_wait_lists',
379
+			'EE_WAIT_LISTS_PLUGIN_FILE'
380
+		);
381
+		$this->deactivateIncompatibleAddon(
382
+			'Automated Upcoming Event Notifications',
383
+			'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION',
384
+			'1.0.0.beta.091',
385
+			'load_espresso_automated_upcoming_event_notification',
386
+			'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE'
387
+		);
388
+		do_action('AHEE__EE_System__load_espresso_addons');
389
+		//if the WP API basic auth plugin isn't already loaded, load it now.
390
+		//We want it for mobile apps. Just include the entire plugin
391
+		//also, don't load the basic auth when a plugin is getting activated, because
392
+		//it could be the basic auth plugin, and it doesn't check if its methods are already defined
393
+		//and causes a fatal error
394
+		if (
395
+			$this->request->getRequestParam('activate') !== 'true'
396
+			&& ! function_exists('json_basic_auth_handler')
397
+			&& ! function_exists('json_basic_auth_error')
398
+			&& ! in_array(
399
+				$this->request->getRequestParam('action'),
400
+				array('activate', 'activate-selected'),
401
+				true
402
+			)
403
+		) {
404
+			include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
405
+		}
406
+		do_action('AHEE__EE_System__load_espresso_addons__complete');
407
+	}
408
+
409
+
410
+
411
+	/**
412
+	 * detect_activations_or_upgrades
413
+	 * Checks for activation or upgrade of core first;
414
+	 * then also checks if any registered addons have been activated or upgraded
415
+	 * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
416
+	 * which runs during the WP 'plugins_loaded' action at priority 3
417
+	 *
418
+	 * @access public
419
+	 * @return void
420
+	 */
421
+	public function detect_activations_or_upgrades()
422
+	{
423
+		//first off: let's make sure to handle core
424
+		$this->detect_if_activation_or_upgrade();
425
+		foreach ($this->registry->addons as $addon) {
426
+			if ($addon instanceof EE_Addon) {
427
+				//detect teh request type for that addon
428
+				$addon->detect_activation_or_upgrade();
429
+			}
430
+		}
431
+	}
432
+
433
+
434
+
435
+	/**
436
+	 * detect_if_activation_or_upgrade
437
+	 * Takes care of detecting whether this is a brand new install or code upgrade,
438
+	 * and either setting up the DB or setting up maintenance mode etc.
439
+	 *
440
+	 * @access public
441
+	 * @return void
442
+	 */
443
+	public function detect_if_activation_or_upgrade()
444
+	{
445
+		do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
446
+		// check if db has been updated, or if its a brand-new installation
447
+		$espresso_db_update = $this->fix_espresso_db_upgrade_option();
448
+		$request_type       = $this->detect_req_type($espresso_db_update);
449
+		//EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
450
+		switch ($request_type) {
451
+			case EE_System::req_type_new_activation:
452
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
453
+				$this->_handle_core_version_change($espresso_db_update);
454
+				break;
455
+			case EE_System::req_type_reactivation:
456
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
457
+				$this->_handle_core_version_change($espresso_db_update);
458
+				break;
459
+			case EE_System::req_type_upgrade:
460
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
461
+				//migrations may be required now that we've upgraded
462
+				$this->maintenance_mode->set_maintenance_mode_if_db_old();
463
+				$this->_handle_core_version_change($espresso_db_update);
464
+				//				echo "done upgrade";die;
465
+				break;
466
+			case EE_System::req_type_downgrade:
467
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
468
+				//its possible migrations are no longer required
469
+				$this->maintenance_mode->set_maintenance_mode_if_db_old();
470
+				$this->_handle_core_version_change($espresso_db_update);
471
+				break;
472
+			case EE_System::req_type_normal:
473
+			default:
474
+				break;
475
+		}
476
+		do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
477
+	}
478
+
479
+
480
+
481
+	/**
482
+	 * Updates the list of installed versions and sets hooks for
483
+	 * initializing the database later during the request
484
+	 *
485
+	 * @param array $espresso_db_update
486
+	 */
487
+	private function _handle_core_version_change($espresso_db_update)
488
+	{
489
+		$this->update_list_of_installed_versions($espresso_db_update);
490
+		//get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
491
+		add_action(
492
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
493
+			array($this, 'initialize_db_if_no_migrations_required')
494
+		);
495
+	}
496
+
497
+
498
+
499
+	/**
500
+	 * standardizes the wp option 'espresso_db_upgrade' which actually stores
501
+	 * information about what versions of EE have been installed and activated,
502
+	 * NOT necessarily the state of the database
503
+	 *
504
+	 * @param mixed $espresso_db_update           the value of the WordPress option.
505
+	 *                                            If not supplied, fetches it from the options table
506
+	 * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
507
+	 */
508
+	private function fix_espresso_db_upgrade_option($espresso_db_update = null)
509
+	{
510
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
511
+		if (! $espresso_db_update) {
512
+			$espresso_db_update = get_option('espresso_db_update');
513
+		}
514
+		// check that option is an array
515
+		if (! is_array($espresso_db_update)) {
516
+			// if option is FALSE, then it never existed
517
+			if ($espresso_db_update === false) {
518
+				// make $espresso_db_update an array and save option with autoload OFF
519
+				$espresso_db_update = array();
520
+				add_option('espresso_db_update', $espresso_db_update, '', 'no');
521
+			} else {
522
+				// option is NOT FALSE but also is NOT an array, so make it an array and save it
523
+				$espresso_db_update = array($espresso_db_update => array());
524
+				update_option('espresso_db_update', $espresso_db_update);
525
+			}
526
+		} else {
527
+			$corrected_db_update = array();
528
+			//if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
529
+			foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
530
+				if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
531
+					//the key is an int, and the value IS NOT an array
532
+					//so it must be numerically-indexed, where values are versions installed...
533
+					//fix it!
534
+					$version_string                         = $should_be_array;
535
+					$corrected_db_update[ $version_string ] = array('unknown-date');
536
+				} else {
537
+					//ok it checks out
538
+					$corrected_db_update[ $should_be_version_string ] = $should_be_array;
539
+				}
540
+			}
541
+			$espresso_db_update = $corrected_db_update;
542
+			update_option('espresso_db_update', $espresso_db_update);
543
+		}
544
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
545
+		return $espresso_db_update;
546
+	}
547
+
548
+
549
+
550
+	/**
551
+	 * Does the traditional work of setting up the plugin's database and adding default data.
552
+	 * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
553
+	 * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
554
+	 * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
555
+	 * so that it will be done when migrations are finished
556
+	 *
557
+	 * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
558
+	 * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
559
+	 *                                       This is a resource-intensive job
560
+	 *                                       so we prefer to only do it when necessary
561
+	 * @return void
562
+	 * @throws EE_Error
563
+	 */
564
+	public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
565
+	{
566
+		$request_type = $this->detect_req_type();
567
+		//only initialize system if we're not in maintenance mode.
568
+		if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
569
+			update_option('ee_flush_rewrite_rules', true);
570
+			if ($verify_schema) {
571
+				EEH_Activation::initialize_db_and_folders();
572
+			}
573
+			EEH_Activation::initialize_db_content();
574
+			EEH_Activation::system_initialization();
575
+			if ($initialize_addons_too) {
576
+				$this->initialize_addons();
577
+			}
578
+		} else {
579
+			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
580
+		}
581
+		if ($request_type === EE_System::req_type_new_activation
582
+			|| $request_type === EE_System::req_type_reactivation
583
+			|| (
584
+				$request_type === EE_System::req_type_upgrade
585
+				&& $this->is_major_version_change()
586
+			)
587
+		) {
588
+			add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
589
+		}
590
+	}
591
+
592
+
593
+
594
+	/**
595
+	 * Initializes the db for all registered addons
596
+	 *
597
+	 * @throws EE_Error
598
+	 */
599
+	public function initialize_addons()
600
+	{
601
+		//foreach registered addon, make sure its db is up-to-date too
602
+		foreach ($this->registry->addons as $addon) {
603
+			if ($addon instanceof EE_Addon) {
604
+				$addon->initialize_db_if_no_migrations_required();
605
+			}
606
+		}
607
+	}
608
+
609
+
610
+
611
+	/**
612
+	 * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
613
+	 *
614
+	 * @param    array  $version_history
615
+	 * @param    string $current_version_to_add version to be added to the version history
616
+	 * @return    boolean success as to whether or not this option was changed
617
+	 */
618
+	public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
619
+	{
620
+		if (! $version_history) {
621
+			$version_history = $this->fix_espresso_db_upgrade_option($version_history);
622
+		}
623
+		if ($current_version_to_add === null) {
624
+			$current_version_to_add = espresso_version();
625
+		}
626
+		$version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
627
+		// re-save
628
+		return update_option('espresso_db_update', $version_history);
629
+	}
630
+
631
+
632
+
633
+	/**
634
+	 * Detects if the current version indicated in the has existed in the list of
635
+	 * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
636
+	 *
637
+	 * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
638
+	 *                                  If not supplied, fetches it from the options table.
639
+	 *                                  Also, caches its result so later parts of the code can also know whether
640
+	 *                                  there's been an update or not. This way we can add the current version to
641
+	 *                                  espresso_db_update, but still know if this is a new install or not
642
+	 * @return int one of the constants on EE_System::req_type_
643
+	 */
644
+	public function detect_req_type($espresso_db_update = null)
645
+	{
646
+		if ($this->_req_type === null) {
647
+			$espresso_db_update          = ! empty($espresso_db_update)
648
+				? $espresso_db_update
649
+				: $this->fix_espresso_db_upgrade_option();
650
+			$this->_req_type             = EE_System::detect_req_type_given_activation_history(
651
+				$espresso_db_update,
652
+				'ee_espresso_activation', espresso_version()
653
+			);
654
+			$this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
655
+			$this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal);
656
+		}
657
+		return $this->_req_type;
658
+	}
659
+
660
+
661
+
662
+	/**
663
+	 * Returns whether or not there was a non-micro version change (ie, change in either
664
+	 * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
665
+	 * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
666
+	 *
667
+	 * @param $activation_history
668
+	 * @return bool
669
+	 */
670
+	private function _detect_major_version_change($activation_history)
671
+	{
672
+		$previous_version       = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
673
+		$previous_version_parts = explode('.', $previous_version);
674
+		$current_version_parts  = explode('.', espresso_version());
675
+		return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
676
+			   && ($previous_version_parts[0] !== $current_version_parts[0]
677
+				   || $previous_version_parts[1] !== $current_version_parts[1]
678
+			   );
679
+	}
680
+
681
+
682
+
683
+	/**
684
+	 * Returns true if either the major or minor version of EE changed during this request.
685
+	 * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001
686
+	 *
687
+	 * @return bool
688
+	 */
689
+	public function is_major_version_change()
690
+	{
691
+		return $this->_major_version_change;
692
+	}
693
+
694
+
695
+
696
+	/**
697
+	 * Determines the request type for any ee addon, given three piece of info: the current array of activation
698
+	 * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
699
+	 * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
700
+	 * just activated to (for core that will always be espresso_version())
701
+	 *
702
+	 * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
703
+	 *                                                 ee plugin. for core that's 'espresso_db_update'
704
+	 * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
705
+	 *                                                 indicate that this plugin was just activated
706
+	 * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
707
+	 *                                                 espresso_version())
708
+	 * @return int one of the constants on EE_System::req_type_*
709
+	 */
710
+	public static function detect_req_type_given_activation_history(
711
+		$activation_history_for_addon,
712
+		$activation_indicator_option_name,
713
+		$version_to_upgrade_to
714
+	) {
715
+		$version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
716
+		if ($activation_history_for_addon) {
717
+			//it exists, so this isn't a completely new install
718
+			//check if this version already in that list of previously installed versions
719
+			if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) {
720
+				//it a version we haven't seen before
721
+				if ($version_is_higher === 1) {
722
+					$req_type = EE_System::req_type_upgrade;
723
+				} else {
724
+					$req_type = EE_System::req_type_downgrade;
725
+				}
726
+				delete_option($activation_indicator_option_name);
727
+			} else {
728
+				// its not an update. maybe a reactivation?
729
+				if (get_option($activation_indicator_option_name, false)) {
730
+					if ($version_is_higher === -1) {
731
+						$req_type = EE_System::req_type_downgrade;
732
+					} elseif ($version_is_higher === 0) {
733
+						//we've seen this version before, but it's an activation. must be a reactivation
734
+						$req_type = EE_System::req_type_reactivation;
735
+					} else {//$version_is_higher === 1
736
+						$req_type = EE_System::req_type_upgrade;
737
+					}
738
+					delete_option($activation_indicator_option_name);
739
+				} else {
740
+					//we've seen this version before and the activation indicate doesn't show it was just activated
741
+					if ($version_is_higher === -1) {
742
+						$req_type = EE_System::req_type_downgrade;
743
+					} elseif ($version_is_higher === 0) {
744
+						//we've seen this version before and it's not an activation. its normal request
745
+						$req_type = EE_System::req_type_normal;
746
+					} else {//$version_is_higher === 1
747
+						$req_type = EE_System::req_type_upgrade;
748
+					}
749
+				}
750
+			}
751
+		} else {
752
+			//brand new install
753
+			$req_type = EE_System::req_type_new_activation;
754
+			delete_option($activation_indicator_option_name);
755
+		}
756
+		return $req_type;
757
+	}
758
+
759
+
760
+
761
+	/**
762
+	 * Detects if the $version_to_upgrade_to is higher than the most recent version in
763
+	 * the $activation_history_for_addon
764
+	 *
765
+	 * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
766
+	 *                                             sometimes containing 'unknown-date'
767
+	 * @param string $version_to_upgrade_to        (current version)
768
+	 * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
769
+	 *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
770
+	 *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
771
+	 *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
772
+	 */
773
+	private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
774
+	{
775
+		//find the most recently-activated version
776
+		$most_recently_active_version =
777
+			EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
778
+		return version_compare($version_to_upgrade_to, $most_recently_active_version);
779
+	}
780
+
781
+
782
+
783
+	/**
784
+	 * Gets the most recently active version listed in the activation history,
785
+	 * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
786
+	 *
787
+	 * @param array $activation_history  (keys are versions, values are arrays of times activated,
788
+	 *                                   sometimes containing 'unknown-date'
789
+	 * @return string
790
+	 */
791
+	private static function _get_most_recently_active_version_from_activation_history($activation_history)
792
+	{
793
+		$most_recently_active_version_activation = '1970-01-01 00:00:00';
794
+		$most_recently_active_version            = '0.0.0.dev.000';
795
+		if (is_array($activation_history)) {
796
+			foreach ($activation_history as $version => $times_activated) {
797
+				//check there is a record of when this version was activated. Otherwise,
798
+				//mark it as unknown
799
+				if (! $times_activated) {
800
+					$times_activated = array('unknown-date');
801
+				}
802
+				if (is_string($times_activated)) {
803
+					$times_activated = array($times_activated);
804
+				}
805
+				foreach ($times_activated as $an_activation) {
806
+					if ($an_activation !== 'unknown-date'
807
+						&& $an_activation
808
+						   > $most_recently_active_version_activation) {
809
+						$most_recently_active_version            = $version;
810
+						$most_recently_active_version_activation = $an_activation === 'unknown-date'
811
+							? '1970-01-01 00:00:00'
812
+							: $an_activation;
813
+					}
814
+				}
815
+			}
816
+		}
817
+		return $most_recently_active_version;
818
+	}
819
+
820
+
821
+
822
+	/**
823
+	 * This redirects to the about EE page after activation
824
+	 *
825
+	 * @return void
826
+	 */
827
+	public function redirect_to_about_ee()
828
+	{
829
+		$notices = EE_Error::get_notices(false);
830
+		//if current user is an admin and it's not an ajax or rest request
831
+		if (
832
+			! isset($notices['errors'])
833
+			&& $this->request->isAdmin()
834
+			&& apply_filters(
835
+				'FHEE__EE_System__redirect_to_about_ee__do_redirect',
836
+				$this->capabilities->current_user_can('manage_options', 'espresso_about_default')
837
+			)
838
+		) {
839
+			$query_params = array('page' => 'espresso_about');
840
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
841
+				$query_params['new_activation'] = true;
842
+			}
843
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
844
+				$query_params['reactivation'] = true;
845
+			}
846
+			$url = add_query_arg($query_params, admin_url('admin.php'));
847
+			wp_safe_redirect($url);
848
+			exit();
849
+		}
850
+	}
851
+
852
+
853
+
854
+	/**
855
+	 * load_core_configuration
856
+	 * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
857
+	 * which runs during the WP 'plugins_loaded' action at priority 5
858
+	 *
859
+	 * @return void
860
+	 * @throws ReflectionException
861
+	 */
862
+	public function load_core_configuration()
863
+	{
864
+		do_action('AHEE__EE_System__load_core_configuration__begin', $this);
865
+		$this->loader->getShared('EE_Load_Textdomain');
866
+		//load textdomain
867
+		EE_Load_Textdomain::load_textdomain();
868
+		// load and setup EE_Config and EE_Network_Config
869
+		$config = $this->loader->getShared('EE_Config');
870
+		$this->loader->getShared('EE_Network_Config');
871
+		// setup autoloaders
872
+		// enable logging?
873
+		if ($config->admin->use_full_logging) {
874
+			$this->loader->getShared('EE_Log');
875
+		}
876
+		// check for activation errors
877
+		$activation_errors = get_option('ee_plugin_activation_errors', false);
878
+		if ($activation_errors) {
879
+			EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
880
+			update_option('ee_plugin_activation_errors', false);
881
+		}
882
+		// get model names
883
+		$this->_parse_model_names();
884
+		//load caf stuff a chance to play during the activation process too.
885
+		$this->_maybe_brew_regular();
886
+		do_action('AHEE__EE_System__load_core_configuration__complete', $this);
887
+	}
888
+
889
+
890
+
891
+	/**
892
+	 * cycles through all of the models/*.model.php files, and assembles an array of model names
893
+	 *
894
+	 * @return void
895
+	 * @throws ReflectionException
896
+	 */
897
+	private function _parse_model_names()
898
+	{
899
+		//get all the files in the EE_MODELS folder that end in .model.php
900
+		$models                 = glob(EE_MODELS . '*.model.php');
901
+		$model_names            = array();
902
+		$non_abstract_db_models = array();
903
+		foreach ($models as $model) {
904
+			// get model classname
905
+			$classname       = EEH_File::get_classname_from_filepath_with_standard_filename($model);
906
+			$short_name      = str_replace('EEM_', '', $classname);
907
+			$reflectionClass = new ReflectionClass($classname);
908
+			if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
909
+				$non_abstract_db_models[ $short_name ] = $classname;
910
+			}
911
+			$model_names[ $short_name ] = $classname;
912
+		}
913
+		$this->registry->models                 = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
914
+		$this->registry->non_abstract_db_models = apply_filters(
915
+			'FHEE__EE_System__parse_implemented_model_names',
916
+			$non_abstract_db_models
917
+		);
918
+	}
919
+
920
+
921
+	/**
922
+	 * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
923
+	 * that need to be setup before our EE_System launches.
924
+	 *
925
+	 * @return void
926
+	 * @throws DomainException
927
+	 * @throws InvalidArgumentException
928
+	 * @throws InvalidDataTypeException
929
+	 * @throws InvalidInterfaceException
930
+	 * @throws InvalidClassException
931
+	 * @throws InvalidFilePathException
932
+	 */
933
+	private function _maybe_brew_regular()
934
+	{
935
+		/** @var Domain $domain */
936
+		$domain = DomainFactory::getShared(
937
+			new FullyQualifiedName(
938
+				'EventEspresso\core\domain\Domain'
939
+			),
940
+			array(
941
+				new FilePath(EVENT_ESPRESSO_MAIN_FILE),
942
+				Version::fromString(espresso_version())
943
+			)
944
+		);
945
+		if ($domain->isCaffeinated()) {
946
+			require_once EE_CAFF_PATH . 'brewing_regular.php';
947
+		}
948
+	}
949
+
950
+
951
+
952
+	/**
953
+	 * register_shortcodes_modules_and_widgets
954
+	 * generate lists of shortcodes and modules, then verify paths and classes
955
+	 * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
956
+	 * which runs during the WP 'plugins_loaded' action at priority 7
957
+	 *
958
+	 * @access public
959
+	 * @return void
960
+	 * @throws Exception
961
+	 */
962
+	public function register_shortcodes_modules_and_widgets()
963
+	{
964
+		if ($this->request->isFrontend() || $this->request->isIframe()) {
965
+			try {
966
+				// load, register, and add shortcodes the new way
967
+				$this->loader->getShared(
968
+					'EventEspresso\core\services\shortcodes\ShortcodesManager',
969
+					array(
970
+						// and the old way, but we'll put it under control of the new system
971
+						EE_Config::getLegacyShortcodesManager(),
972
+					)
973
+				);
974
+			} catch (Exception $exception) {
975
+				new ExceptionStackTraceDisplay($exception);
976
+			}
977
+		}
978
+		do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
979
+		// check for addons using old hook point
980
+		if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
981
+			$this->_incompatible_addon_error();
982
+		}
983
+	}
984
+
985
+
986
+
987
+	/**
988
+	 * _incompatible_addon_error
989
+	 *
990
+	 * @access public
991
+	 * @return void
992
+	 */
993
+	private function _incompatible_addon_error()
994
+	{
995
+		// get array of classes hooking into here
996
+		$class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
997
+			'AHEE__EE_System__register_shortcodes_modules_and_addons'
998
+		);
999
+		if (! empty($class_names)) {
1000
+			$msg = __(
1001
+				'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
1002
+				'event_espresso'
1003
+			);
1004
+			$msg .= '<ul>';
1005
+			foreach ($class_names as $class_name) {
1006
+				$msg .= '<li><b>Event Espresso - ' . str_replace(
1007
+						array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '',
1008
+						$class_name
1009
+					) . '</b></li>';
1010
+			}
1011
+			$msg .= '</ul>';
1012
+			$msg .= __(
1013
+				'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
1014
+				'event_espresso'
1015
+			);
1016
+			// save list of incompatible addons to wp-options for later use
1017
+			add_option('ee_incompatible_addons', $class_names, '', 'no');
1018
+			if (is_admin()) {
1019
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1020
+			}
1021
+		}
1022
+	}
1023
+
1024
+
1025
+
1026
+	/**
1027
+	 * brew_espresso
1028
+	 * begins the process of setting hooks for initializing EE in the correct order
1029
+	 * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
1030
+	 * which runs during the WP 'plugins_loaded' action at priority 9
1031
+	 *
1032
+	 * @return void
1033
+	 */
1034
+	public function brew_espresso()
1035
+	{
1036
+		do_action('AHEE__EE_System__brew_espresso__begin', $this);
1037
+		// load some final core systems
1038
+		add_action('init', array($this, 'set_hooks_for_core'), 1);
1039
+		add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
1040
+		add_action('init', array($this, 'load_CPTs_and_session'), 5);
1041
+		add_action('init', array($this, 'load_controllers'), 7);
1042
+		add_action('init', array($this, 'core_loaded_and_ready'), 9);
1043
+		add_action('init', array($this, 'initialize'), 10);
1044
+		add_action('init', array($this, 'initialize_last'), 100);
1045
+		if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
1046
+			// pew pew pew
1047
+			$this->loader->getShared('EE_PUE');
1048
+			do_action('AHEE__EE_System__brew_espresso__after_pue_init');
1049
+		}
1050
+		do_action('AHEE__EE_System__brew_espresso__complete', $this);
1051
+	}
1052
+
1053
+
1054
+
1055
+	/**
1056
+	 *    set_hooks_for_core
1057
+	 *
1058
+	 * @access public
1059
+	 * @return    void
1060
+	 * @throws EE_Error
1061
+	 */
1062
+	public function set_hooks_for_core()
1063
+	{
1064
+		$this->_deactivate_incompatible_addons();
1065
+		do_action('AHEE__EE_System__set_hooks_for_core');
1066
+		$this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan');
1067
+		//caps need to be initialized on every request so that capability maps are set.
1068
+		//@see https://events.codebasehq.com/projects/event-espresso/tickets/8674
1069
+		$this->registry->CAP->init_caps();
1070
+	}
1071
+
1072
+
1073
+
1074
+	/**
1075
+	 * Using the information gathered in EE_System::_incompatible_addon_error,
1076
+	 * deactivates any addons considered incompatible with the current version of EE
1077
+	 */
1078
+	private function _deactivate_incompatible_addons()
1079
+	{
1080
+		$incompatible_addons = get_option('ee_incompatible_addons', array());
1081
+		if (! empty($incompatible_addons)) {
1082
+			$active_plugins = get_option('active_plugins', array());
1083
+			foreach ($active_plugins as $active_plugin) {
1084
+				foreach ($incompatible_addons as $incompatible_addon) {
1085
+					if (strpos($active_plugin, $incompatible_addon) !== false) {
1086
+						unset($_GET['activate']);
1087
+						espresso_deactivate_plugin($active_plugin);
1088
+					}
1089
+				}
1090
+			}
1091
+		}
1092
+	}
1093
+
1094
+
1095
+
1096
+	/**
1097
+	 *    perform_activations_upgrades_and_migrations
1098
+	 *
1099
+	 * @access public
1100
+	 * @return    void
1101
+	 */
1102
+	public function perform_activations_upgrades_and_migrations()
1103
+	{
1104
+		do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
1105
+	}
1106
+
1107
+
1108
+
1109
+	/**
1110
+	 *    load_CPTs_and_session
1111
+	 *
1112
+	 * @access public
1113
+	 * @return    void
1114
+	 */
1115
+	public function load_CPTs_and_session()
1116
+	{
1117
+		do_action('AHEE__EE_System__load_CPTs_and_session__start');
1118
+		// register Custom Post Types
1119
+		$this->loader->getShared('EE_Register_CPTs');
1120
+		do_action('AHEE__EE_System__load_CPTs_and_session__complete');
1121
+	}
1122
+
1123
+
1124
+
1125
+	/**
1126
+	 * load_controllers
1127
+	 * this is the best place to load any additional controllers that needs access to EE core.
1128
+	 * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
1129
+	 * time
1130
+	 *
1131
+	 * @access public
1132
+	 * @return void
1133
+	 */
1134
+	public function load_controllers()
1135
+	{
1136
+		do_action('AHEE__EE_System__load_controllers__start');
1137
+		// let's get it started
1138
+		if (
1139
+			! $this->maintenance_mode->level()
1140
+			&& ($this->request->isFrontend() || $this->request->isFrontAjax())
1141
+		) {
1142
+			do_action('AHEE__EE_System__load_controllers__load_front_controllers');
1143
+			$this->loader->getShared('EE_Front_Controller');
1144
+		} elseif ($this->request->isAdmin() || $this->request->isAdminAjax()) {
1145
+			do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1146
+			$this->loader->getShared('EE_Admin');
1147
+		}
1148
+		do_action('AHEE__EE_System__load_controllers__complete');
1149
+	}
1150
+
1151
+
1152
+
1153
+	/**
1154
+	 * core_loaded_and_ready
1155
+	 * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1156
+	 *
1157
+	 * @access public
1158
+	 * @return void
1159
+	 */
1160
+	public function core_loaded_and_ready()
1161
+	{
1162
+		if (
1163
+			$this->request->isAdmin()
1164
+			|| $this->request->isEeAjax()
1165
+			|| $this->request->isFrontend()
1166
+		) {
1167
+			$this->loader->getShared('EE_Session');
1168
+		}
1169
+		do_action('AHEE__EE_System__core_loaded_and_ready');
1170
+		// load_espresso_template_tags
1171
+		if (
1172
+			is_readable(EE_PUBLIC . 'template_tags.php')
1173
+			&& ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isFeed())
1174
+		) {
1175
+			require_once EE_PUBLIC . 'template_tags.php';
1176
+		}
1177
+		do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1178
+		if ($this->request->isAdmin() || $this->request->isFrontend() || $this->request->isIframe()) {
1179
+			$this->loader->getShared('EventEspresso\core\services\assets\Registry');
1180
+		}
1181
+	}
1182
+
1183
+
1184
+
1185
+	/**
1186
+	 * initialize
1187
+	 * this is the best place to begin initializing client code
1188
+	 *
1189
+	 * @access public
1190
+	 * @return void
1191
+	 */
1192
+	public function initialize()
1193
+	{
1194
+		do_action('AHEE__EE_System__initialize');
1195
+	}
1196
+
1197
+
1198
+
1199
+	/**
1200
+	 * initialize_last
1201
+	 * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1202
+	 * initialize has done so
1203
+	 *
1204
+	 * @access public
1205
+	 * @return void
1206
+	 */
1207
+	public function initialize_last()
1208
+	{
1209
+		do_action('AHEE__EE_System__initialize_last');
1210
+		add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1211
+	}
1212
+
1213
+
1214
+
1215
+	/**
1216
+	 * @return void
1217
+	 * @throws EE_Error
1218
+	 */
1219
+	public function addEspressoToolbar()
1220
+	{
1221
+		$this->loader->getShared(
1222
+			'EventEspresso\core\domain\services\admin\AdminToolBar',
1223
+			array($this->registry->CAP)
1224
+		);
1225
+	}
1226
+
1227
+
1228
+
1229
+	/**
1230
+	 * do_not_cache
1231
+	 * sets no cache headers and defines no cache constants for WP plugins
1232
+	 *
1233
+	 * @access public
1234
+	 * @return void
1235
+	 */
1236
+	public static function do_not_cache()
1237
+	{
1238
+		// set no cache constants
1239
+		if (! defined('DONOTCACHEPAGE')) {
1240
+			define('DONOTCACHEPAGE', true);
1241
+		}
1242
+		if (! defined('DONOTCACHCEOBJECT')) {
1243
+			define('DONOTCACHCEOBJECT', true);
1244
+		}
1245
+		if (! defined('DONOTCACHEDB')) {
1246
+			define('DONOTCACHEDB', true);
1247
+		}
1248
+		// add no cache headers
1249
+		add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1250
+		// plus a little extra for nginx and Google Chrome
1251
+		add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1252
+		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1253
+		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1254
+	}
1255
+
1256
+
1257
+
1258
+	/**
1259
+	 *    extra_nocache_headers
1260
+	 *
1261
+	 * @access    public
1262
+	 * @param $headers
1263
+	 * @return    array
1264
+	 */
1265
+	public static function extra_nocache_headers($headers)
1266
+	{
1267
+		// for NGINX
1268
+		$headers['X-Accel-Expires'] = 0;
1269
+		// plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1270
+		$headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1271
+		return $headers;
1272
+	}
1273
+
1274
+
1275
+
1276
+	/**
1277
+	 *    nocache_headers
1278
+	 *
1279
+	 * @access    public
1280
+	 * @return    void
1281
+	 */
1282
+	public static function nocache_headers()
1283
+	{
1284
+		nocache_headers();
1285
+	}
1286
+
1287
+
1288
+
1289
+	/**
1290
+	 * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1291
+	 * never returned with the function.
1292
+	 *
1293
+	 * @param  array $exclude_array any existing pages being excluded are in this array.
1294
+	 * @return array
1295
+	 */
1296
+	public function remove_pages_from_wp_list_pages($exclude_array)
1297
+	{
1298
+		return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1299
+	}
1300 1300
 
1301 1301
 
1302 1302
 
Please login to merge, or discard this patch.
core/admin/EE_Admin.core.php 1 patch
Indentation   +915 added lines, -915 removed lines patch added patch discarded remove patch
@@ -23,458 +23,458 @@  discard block
 block discarded – undo
23 23
 final class EE_Admin implements InterminableInterface
24 24
 {
25 25
 
26
-    /**
27
-     * @var EE_Admin $_instance
28
-     */
29
-    private static $_instance;
30
-
31
-    /**
32
-     * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
33
-     */
34
-    private $persistent_admin_notice_manager;
35
-
36
-    /**
37
-     * @singleton method used to instantiate class object
38
-     * @return EE_Admin
39
-     * @throws EE_Error
40
-     */
41
-    public static function instance()
42
-    {
43
-        // check if class object is instantiated
44
-        if (! self::$_instance instanceof EE_Admin) {
45
-            self::$_instance = new self();
46
-        }
47
-        return self::$_instance;
48
-    }
49
-
50
-
51
-    /**
52
-     * @return EE_Admin
53
-     * @throws EE_Error
54
-     */
55
-    public static function reset()
56
-    {
57
-        self::$_instance = null;
58
-        return self::instance();
59
-    }
60
-
61
-
62
-    /**
63
-     * class constructor
64
-     *
65
-     * @throws EE_Error
66
-     * @throws InvalidDataTypeException
67
-     * @throws InvalidInterfaceException
68
-     * @throws InvalidArgumentException
69
-     */
70
-    protected function __construct()
71
-    {
72
-        // define global EE_Admin constants
73
-        $this->_define_all_constants();
74
-        // set autoloaders for our admin page classes based on included path information
75
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
76
-        // admin hooks
77
-        add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
78
-        // load EE_Request_Handler early
79
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
80
-        add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
81
-        add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
82
-        add_action('wp_loaded', array($this, 'wp_loaded'), 100);
83
-        add_action('admin_init', array($this, 'admin_init'), 100);
84
-        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
85
-        add_action('admin_notices', array($this, 'display_admin_notices'), 10);
86
-        add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
87
-        add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
88
-        add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
89
-        add_action('load-plugins.php', array($this, 'hookIntoWpPluginsPage'));
90
-        //reset Environment config (we only do this on admin page loads);
91
-        EE_Registry::instance()->CFG->environment->recheck_values();
92
-        do_action('AHEE__EE_Admin__loaded');
93
-    }
94
-
95
-
96
-
97
-    /**
98
-     * _define_all_constants
99
-     * define constants that are set globally for all admin pages
100
-     *
101
-     * @return void
102
-     */
103
-    private function _define_all_constants()
104
-    {
105
-        if (! defined('EE_ADMIN_URL')) {
106
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
107
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
108
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
109
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
110
-            define('WP_AJAX_URL', admin_url('admin-ajax.php'));
111
-        }
112
-    }
113
-
114
-
115
-    /**
116
-     * filter_plugin_actions - adds links to the Plugins page listing
117
-     *
118
-     * @param    array  $links
119
-     * @param    string $plugin
120
-     * @return    array
121
-     */
122
-    public function filter_plugin_actions($links, $plugin)
123
-    {
124
-        // set $main_file in stone
125
-        static $main_file;
126
-        // if $main_file is not set yet
127
-        if (! $main_file) {
128
-            $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
129
-        }
130
-        if ($plugin === $main_file) {
131
-            // compare current plugin to this one
132
-            if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
133
-                $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
134
-                                    . ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
135
-                                    . esc_html__('Maintenance Mode Active', 'event_espresso')
136
-                                    . '</a>';
137
-                array_unshift($links, $maintenance_link);
138
-            } else {
139
-                $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
140
-                                     . esc_html__('Settings', 'event_espresso')
141
-                                     . '</a>';
142
-                $events_link       = '<a href="admin.php?page=espresso_events">'
143
-                                     . esc_html__('Events', 'event_espresso')
144
-                                     . '</a>';
145
-                // add before other links
146
-                array_unshift($links, $org_settings_link, $events_link);
147
-            }
148
-        }
149
-        return $links;
150
-    }
151
-
152
-
153
-    /**
154
-     * _get_request
155
-     *
156
-     * @return void
157
-     * @throws EE_Error
158
-     * @throws InvalidArgumentException
159
-     * @throws InvalidDataTypeException
160
-     * @throws InvalidInterfaceException
161
-     * @throws ReflectionException
162
-     */
163
-    public function get_request()
164
-    {
165
-        EE_Registry::instance()->load_core('Request_Handler');
166
-        EE_Registry::instance()->load_core('CPT_Strategy');
167
-    }
168
-
169
-
170
-
171
-    /**
172
-     * hide_admin_pages_except_maintenance_mode
173
-     *
174
-     * @param array $admin_page_folder_names
175
-     * @return array
176
-     */
177
-    public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
178
-    {
179
-        return array(
180
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
181
-            'about'       => EE_ADMIN_PAGES . 'about' . DS,
182
-            'support'     => EE_ADMIN_PAGES . 'support' . DS,
183
-        );
184
-    }
185
-
186
-
187
-
188
-    /**
189
-     * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
190
-     * EE_Front_Controller's init phases have run
191
-     *
192
-     * @return void
193
-     * @throws EE_Error
194
-     * @throws InvalidArgumentException
195
-     * @throws InvalidDataTypeException
196
-     * @throws InvalidInterfaceException
197
-     * @throws ReflectionException
198
-     * @throws ServiceNotFoundException
199
-     */
200
-    public function init()
201
-    {
202
-        //only enable most of the EE_Admin IF we're not in full maintenance mode
203
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
204
-            //ok so we want to enable the entire admin
205
-            $this->persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
206
-                'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
207
-            );
208
-            $this->persistent_admin_notice_manager->setReturnUrl(
209
-                EE_Admin_Page::add_query_args_and_nonce(
210
-                    array(
211
-                        'page'   => EE_Registry::instance()->REQ->get('page', ''),
212
-                        'action' => EE_Registry::instance()->REQ->get('action', ''),
213
-                    ),
214
-                    EE_ADMIN_URL
215
-                )
216
-            );
217
-            $this->maybeSetDatetimeWarningNotice();
218
-            //at a glance dashboard widget
219
-            add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
220
-            //filter for get_edit_post_link used on comments for custom post types
221
-            add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
222
-        }
223
-        // run the admin page factory but ONLY if we are doing an ee admin ajax request
224
-        if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
225
-            try {
226
-                //this loads the controller for the admin pages which will setup routing etc
227
-                EE_Registry::instance()->load_core('Admin_Page_Loader');
228
-            } catch (EE_Error $e) {
229
-                $e->get_error();
230
-            }
231
-        }
232
-        add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
233
-        //make sure our CPTs and custom taxonomy metaboxes get shown for first time users
234
-        add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
235
-        add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
236
-        //exclude EE critical pages from all nav menus and wp_list_pages
237
-        add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
238
-    }
239
-
240
-
241
-    /**
242
-     *    get_persistent_admin_notices
243
-     *
244
-     * @access    public
245
-     * @return void
246
-     * @throws EE_Error
247
-     * @throws InvalidArgumentException
248
-     * @throws InvalidDataTypeException
249
-     * @throws InvalidInterfaceException
250
-     */
251
-    public function maybeSetDatetimeWarningNotice()
252
-    {
253
-        //add dismissable notice for datetime changes.  Only valid if site does not have a timezone_string set.
254
-        //@todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
255
-        //with this.  But after enough time (indeterminate at this point) we can just remove this notice.
256
-        //this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
257
-        if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
258
-            && ! get_option('timezone_string')
259
-            && EEM_Event::instance()->count() > 0
260
-        ) {
261
-            new PersistentAdminNotice(
262
-                'datetime_fix_notice',
263
-                sprintf(
264
-                    esc_html__(
265
-                        '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times.  Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',
266
-                        'event_espresso'
267
-                    ),
268
-                    '<strong>',
269
-                    '</strong>',
270
-                    '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
271
-                    '</a>',
272
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
273
-                        array(
274
-                            'page' => 'espresso_maintenance_settings',
275
-                            'action' => 'datetime_tools'
276
-                        ),
277
-                        admin_url('admin.php')
278
-                    ) . '">'
279
-                ),
280
-                false,
281
-                'manage_options',
282
-                'datetime_fix_persistent_notice'
283
-            );
284
-        }
285
-    }
286
-
287
-
288
-
289
-    /**
290
-     * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
291
-     * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
292
-     * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
293
-     * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
294
-     * normal property on the post_type object.  It's found ONLY in this particular context.
295
-     *
296
-     * @param WP_Post $post_type WP post type object
297
-     * @return WP_Post
298
-     * @throws InvalidArgumentException
299
-     * @throws InvalidDataTypeException
300
-     * @throws InvalidInterfaceException
301
-     */
302
-    public function remove_pages_from_nav_menu($post_type)
303
-    {
304
-        //if this isn't the "pages" post type let's get out
305
-        if ($post_type->name !== 'page') {
306
-            return $post_type;
307
-        }
308
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
309
-        $post_type->_default_query = array(
310
-            'post__not_in' => $critical_pages,
311
-        );
312
-        return $post_type;
313
-    }
314
-
315
-
316
-
317
-    /**
318
-     * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
319
-     * metaboxes get shown as well
320
-     *
321
-     * @return void
322
-     */
323
-    public function enable_hidden_ee_nav_menu_metaboxes()
324
-    {
325
-        global $wp_meta_boxes, $pagenow;
326
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
327
-            return;
328
-        }
329
-        $user = wp_get_current_user();
330
-        //has this been done yet?
331
-        if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
332
-            return;
333
-        }
334
-
335
-        $hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
336
-        $initial_meta_boxes = apply_filters(
337
-            'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
338
-            array(
339
-                'nav-menu-theme-locations',
340
-                'add-page',
341
-                'add-custom-links',
342
-                'add-category',
343
-                'add-espresso_events',
344
-                'add-espresso_venues',
345
-                'add-espresso_event_categories',
346
-                'add-espresso_venue_categories',
347
-                'add-post-type-post',
348
-                'add-post-type-page',
349
-            )
350
-        );
351
-
352
-        if (is_array($hidden_meta_boxes)) {
353
-            foreach ($hidden_meta_boxes as $key => $meta_box_id) {
354
-                if (in_array($meta_box_id, $initial_meta_boxes, true)) {
355
-                    unset($hidden_meta_boxes[$key]);
356
-                }
357
-            }
358
-        }
359
-        update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
360
-        update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
361
-    }
362
-
363
-
364
-
365
-    /**
366
-     * This method simply registers custom nav menu boxes for "nav_menus.php route"
367
-     * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
368
-     *
369
-     * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
370
-     *         addons etc.
371
-     * @return void
372
-     */
373
-    public function register_custom_nav_menu_boxes()
374
-    {
375
-        add_meta_box(
376
-            'add-extra-nav-menu-pages',
377
-            esc_html__('Event Espresso Pages', 'event_espresso'),
378
-            array($this, 'ee_cpt_archive_pages'),
379
-            'nav-menus',
380
-            'side',
381
-            'core'
382
-        );
383
-    }
384
-
385
-
386
-
387
-    /**
388
-     * Use this to edit the post link for our cpts so that the edit link points to the correct page.
389
-     *
390
-     * @since   4.3.0
391
-     * @param string $link the original link generated by wp
392
-     * @param int    $id   post id
393
-     * @return string  the (maybe) modified link
394
-     */
395
-    public function modify_edit_post_link($link, $id)
396
-    {
397
-        if (! $post = get_post($id)) {
398
-            return $link;
399
-        }
400
-        if ($post->post_type === 'espresso_attendees') {
401
-            $query_args = array(
402
-                'action' => 'edit_attendee',
403
-                'post'   => $id,
404
-            );
405
-            return EEH_URL::add_query_args_and_nonce(
406
-                $query_args,
407
-                admin_url('admin.php?page=espresso_registrations')
408
-            );
409
-        }
410
-        return $link;
411
-    }
412
-
413
-
414
-
415
-    public function ee_cpt_archive_pages()
416
-    {
417
-        global $nav_menu_selected_id;
418
-        $db_fields   = false;
419
-        $walker      = new Walker_Nav_Menu_Checklist($db_fields);
420
-        $current_tab = 'event-archives';
421
-        $removed_args = array(
422
-            'action',
423
-            'customlink-tab',
424
-            'edit-menu-item',
425
-            'menu-item',
426
-            'page-tab',
427
-            '_wpnonce',
428
-        );
429
-        ?>
26
+	/**
27
+	 * @var EE_Admin $_instance
28
+	 */
29
+	private static $_instance;
30
+
31
+	/**
32
+	 * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
33
+	 */
34
+	private $persistent_admin_notice_manager;
35
+
36
+	/**
37
+	 * @singleton method used to instantiate class object
38
+	 * @return EE_Admin
39
+	 * @throws EE_Error
40
+	 */
41
+	public static function instance()
42
+	{
43
+		// check if class object is instantiated
44
+		if (! self::$_instance instanceof EE_Admin) {
45
+			self::$_instance = new self();
46
+		}
47
+		return self::$_instance;
48
+	}
49
+
50
+
51
+	/**
52
+	 * @return EE_Admin
53
+	 * @throws EE_Error
54
+	 */
55
+	public static function reset()
56
+	{
57
+		self::$_instance = null;
58
+		return self::instance();
59
+	}
60
+
61
+
62
+	/**
63
+	 * class constructor
64
+	 *
65
+	 * @throws EE_Error
66
+	 * @throws InvalidDataTypeException
67
+	 * @throws InvalidInterfaceException
68
+	 * @throws InvalidArgumentException
69
+	 */
70
+	protected function __construct()
71
+	{
72
+		// define global EE_Admin constants
73
+		$this->_define_all_constants();
74
+		// set autoloaders for our admin page classes based on included path information
75
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
76
+		// admin hooks
77
+		add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
78
+		// load EE_Request_Handler early
79
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
80
+		add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
81
+		add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
82
+		add_action('wp_loaded', array($this, 'wp_loaded'), 100);
83
+		add_action('admin_init', array($this, 'admin_init'), 100);
84
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
85
+		add_action('admin_notices', array($this, 'display_admin_notices'), 10);
86
+		add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
87
+		add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
88
+		add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
89
+		add_action('load-plugins.php', array($this, 'hookIntoWpPluginsPage'));
90
+		//reset Environment config (we only do this on admin page loads);
91
+		EE_Registry::instance()->CFG->environment->recheck_values();
92
+		do_action('AHEE__EE_Admin__loaded');
93
+	}
94
+
95
+
96
+
97
+	/**
98
+	 * _define_all_constants
99
+	 * define constants that are set globally for all admin pages
100
+	 *
101
+	 * @return void
102
+	 */
103
+	private function _define_all_constants()
104
+	{
105
+		if (! defined('EE_ADMIN_URL')) {
106
+			define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
107
+			define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
108
+			define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS);
109
+			define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
110
+			define('WP_AJAX_URL', admin_url('admin-ajax.php'));
111
+		}
112
+	}
113
+
114
+
115
+	/**
116
+	 * filter_plugin_actions - adds links to the Plugins page listing
117
+	 *
118
+	 * @param    array  $links
119
+	 * @param    string $plugin
120
+	 * @return    array
121
+	 */
122
+	public function filter_plugin_actions($links, $plugin)
123
+	{
124
+		// set $main_file in stone
125
+		static $main_file;
126
+		// if $main_file is not set yet
127
+		if (! $main_file) {
128
+			$main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
129
+		}
130
+		if ($plugin === $main_file) {
131
+			// compare current plugin to this one
132
+			if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
133
+				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
134
+									. ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
135
+									. esc_html__('Maintenance Mode Active', 'event_espresso')
136
+									. '</a>';
137
+				array_unshift($links, $maintenance_link);
138
+			} else {
139
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
140
+									 . esc_html__('Settings', 'event_espresso')
141
+									 . '</a>';
142
+				$events_link       = '<a href="admin.php?page=espresso_events">'
143
+									 . esc_html__('Events', 'event_espresso')
144
+									 . '</a>';
145
+				// add before other links
146
+				array_unshift($links, $org_settings_link, $events_link);
147
+			}
148
+		}
149
+		return $links;
150
+	}
151
+
152
+
153
+	/**
154
+	 * _get_request
155
+	 *
156
+	 * @return void
157
+	 * @throws EE_Error
158
+	 * @throws InvalidArgumentException
159
+	 * @throws InvalidDataTypeException
160
+	 * @throws InvalidInterfaceException
161
+	 * @throws ReflectionException
162
+	 */
163
+	public function get_request()
164
+	{
165
+		EE_Registry::instance()->load_core('Request_Handler');
166
+		EE_Registry::instance()->load_core('CPT_Strategy');
167
+	}
168
+
169
+
170
+
171
+	/**
172
+	 * hide_admin_pages_except_maintenance_mode
173
+	 *
174
+	 * @param array $admin_page_folder_names
175
+	 * @return array
176
+	 */
177
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())
178
+	{
179
+		return array(
180
+			'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
181
+			'about'       => EE_ADMIN_PAGES . 'about' . DS,
182
+			'support'     => EE_ADMIN_PAGES . 'support' . DS,
183
+		);
184
+	}
185
+
186
+
187
+
188
+	/**
189
+	 * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
190
+	 * EE_Front_Controller's init phases have run
191
+	 *
192
+	 * @return void
193
+	 * @throws EE_Error
194
+	 * @throws InvalidArgumentException
195
+	 * @throws InvalidDataTypeException
196
+	 * @throws InvalidInterfaceException
197
+	 * @throws ReflectionException
198
+	 * @throws ServiceNotFoundException
199
+	 */
200
+	public function init()
201
+	{
202
+		//only enable most of the EE_Admin IF we're not in full maintenance mode
203
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
204
+			//ok so we want to enable the entire admin
205
+			$this->persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
206
+				'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
207
+			);
208
+			$this->persistent_admin_notice_manager->setReturnUrl(
209
+				EE_Admin_Page::add_query_args_and_nonce(
210
+					array(
211
+						'page'   => EE_Registry::instance()->REQ->get('page', ''),
212
+						'action' => EE_Registry::instance()->REQ->get('action', ''),
213
+					),
214
+					EE_ADMIN_URL
215
+				)
216
+			);
217
+			$this->maybeSetDatetimeWarningNotice();
218
+			//at a glance dashboard widget
219
+			add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
220
+			//filter for get_edit_post_link used on comments for custom post types
221
+			add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
222
+		}
223
+		// run the admin page factory but ONLY if we are doing an ee admin ajax request
224
+		if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
225
+			try {
226
+				//this loads the controller for the admin pages which will setup routing etc
227
+				EE_Registry::instance()->load_core('Admin_Page_Loader');
228
+			} catch (EE_Error $e) {
229
+				$e->get_error();
230
+			}
231
+		}
232
+		add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
233
+		//make sure our CPTs and custom taxonomy metaboxes get shown for first time users
234
+		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
235
+		add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
236
+		//exclude EE critical pages from all nav menus and wp_list_pages
237
+		add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
238
+	}
239
+
240
+
241
+	/**
242
+	 *    get_persistent_admin_notices
243
+	 *
244
+	 * @access    public
245
+	 * @return void
246
+	 * @throws EE_Error
247
+	 * @throws InvalidArgumentException
248
+	 * @throws InvalidDataTypeException
249
+	 * @throws InvalidInterfaceException
250
+	 */
251
+	public function maybeSetDatetimeWarningNotice()
252
+	{
253
+		//add dismissable notice for datetime changes.  Only valid if site does not have a timezone_string set.
254
+		//@todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
255
+		//with this.  But after enough time (indeterminate at this point) we can just remove this notice.
256
+		//this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
257
+		if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
258
+			&& ! get_option('timezone_string')
259
+			&& EEM_Event::instance()->count() > 0
260
+		) {
261
+			new PersistentAdminNotice(
262
+				'datetime_fix_notice',
263
+				sprintf(
264
+					esc_html__(
265
+						'%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times.  Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',
266
+						'event_espresso'
267
+					),
268
+					'<strong>',
269
+					'</strong>',
270
+					'<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
271
+					'</a>',
272
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
273
+						array(
274
+							'page' => 'espresso_maintenance_settings',
275
+							'action' => 'datetime_tools'
276
+						),
277
+						admin_url('admin.php')
278
+					) . '">'
279
+				),
280
+				false,
281
+				'manage_options',
282
+				'datetime_fix_persistent_notice'
283
+			);
284
+		}
285
+	}
286
+
287
+
288
+
289
+	/**
290
+	 * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
291
+	 * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
292
+	 * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
293
+	 * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
294
+	 * normal property on the post_type object.  It's found ONLY in this particular context.
295
+	 *
296
+	 * @param WP_Post $post_type WP post type object
297
+	 * @return WP_Post
298
+	 * @throws InvalidArgumentException
299
+	 * @throws InvalidDataTypeException
300
+	 * @throws InvalidInterfaceException
301
+	 */
302
+	public function remove_pages_from_nav_menu($post_type)
303
+	{
304
+		//if this isn't the "pages" post type let's get out
305
+		if ($post_type->name !== 'page') {
306
+			return $post_type;
307
+		}
308
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
309
+		$post_type->_default_query = array(
310
+			'post__not_in' => $critical_pages,
311
+		);
312
+		return $post_type;
313
+	}
314
+
315
+
316
+
317
+	/**
318
+	 * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
319
+	 * metaboxes get shown as well
320
+	 *
321
+	 * @return void
322
+	 */
323
+	public function enable_hidden_ee_nav_menu_metaboxes()
324
+	{
325
+		global $wp_meta_boxes, $pagenow;
326
+		if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
327
+			return;
328
+		}
329
+		$user = wp_get_current_user();
330
+		//has this been done yet?
331
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
332
+			return;
333
+		}
334
+
335
+		$hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
336
+		$initial_meta_boxes = apply_filters(
337
+			'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
338
+			array(
339
+				'nav-menu-theme-locations',
340
+				'add-page',
341
+				'add-custom-links',
342
+				'add-category',
343
+				'add-espresso_events',
344
+				'add-espresso_venues',
345
+				'add-espresso_event_categories',
346
+				'add-espresso_venue_categories',
347
+				'add-post-type-post',
348
+				'add-post-type-page',
349
+			)
350
+		);
351
+
352
+		if (is_array($hidden_meta_boxes)) {
353
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
354
+				if (in_array($meta_box_id, $initial_meta_boxes, true)) {
355
+					unset($hidden_meta_boxes[$key]);
356
+				}
357
+			}
358
+		}
359
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
360
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
361
+	}
362
+
363
+
364
+
365
+	/**
366
+	 * This method simply registers custom nav menu boxes for "nav_menus.php route"
367
+	 * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
368
+	 *
369
+	 * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
370
+	 *         addons etc.
371
+	 * @return void
372
+	 */
373
+	public function register_custom_nav_menu_boxes()
374
+	{
375
+		add_meta_box(
376
+			'add-extra-nav-menu-pages',
377
+			esc_html__('Event Espresso Pages', 'event_espresso'),
378
+			array($this, 'ee_cpt_archive_pages'),
379
+			'nav-menus',
380
+			'side',
381
+			'core'
382
+		);
383
+	}
384
+
385
+
386
+
387
+	/**
388
+	 * Use this to edit the post link for our cpts so that the edit link points to the correct page.
389
+	 *
390
+	 * @since   4.3.0
391
+	 * @param string $link the original link generated by wp
392
+	 * @param int    $id   post id
393
+	 * @return string  the (maybe) modified link
394
+	 */
395
+	public function modify_edit_post_link($link, $id)
396
+	{
397
+		if (! $post = get_post($id)) {
398
+			return $link;
399
+		}
400
+		if ($post->post_type === 'espresso_attendees') {
401
+			$query_args = array(
402
+				'action' => 'edit_attendee',
403
+				'post'   => $id,
404
+			);
405
+			return EEH_URL::add_query_args_and_nonce(
406
+				$query_args,
407
+				admin_url('admin.php?page=espresso_registrations')
408
+			);
409
+		}
410
+		return $link;
411
+	}
412
+
413
+
414
+
415
+	public function ee_cpt_archive_pages()
416
+	{
417
+		global $nav_menu_selected_id;
418
+		$db_fields   = false;
419
+		$walker      = new Walker_Nav_Menu_Checklist($db_fields);
420
+		$current_tab = 'event-archives';
421
+		$removed_args = array(
422
+			'action',
423
+			'customlink-tab',
424
+			'edit-menu-item',
425
+			'menu-item',
426
+			'page-tab',
427
+			'_wpnonce',
428
+		);
429
+		?>
430 430
         <div id="posttype-extra-nav-menu-pages" class="posttypediv">
431 431
             <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">
432 432
                 <li <?php echo('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>>
433 433
                     <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives"
434 434
                        href="<?php if ($nav_menu_selected_id) {
435
-                            echo esc_url(
436
-                                add_query_arg(
437
-                                    'extra-nav-menu-pages-tab',
438
-                                    'event-archives',
439
-                                    remove_query_arg($removed_args)
440
-                                )
441
-                            );
442
-                       } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
435
+							echo esc_url(
436
+								add_query_arg(
437
+									'extra-nav-menu-pages-tab',
438
+									'event-archives',
439
+									remove_query_arg($removed_args)
440
+								)
441
+							);
442
+					   } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
443 443
                         <?php _e('Event Archive Pages', 'event_espresso'); ?>
444 444
                     </a>
445 445
                 </li>
446 446
             </ul><!-- .posttype-tabs -->
447 447
 
448 448
             <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php
449
-                echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
450
-                ?>">
449
+				echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
450
+				?>">
451 451
                     <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear">
452 452
                         <?php
453
-                        $pages          = $this->_get_extra_nav_menu_pages_items();
454
-                        $args['walker'] = $walker;
455
-                        echo walk_nav_menu_tree(
456
-                            array_map(
457
-                                array($this, '_setup_extra_nav_menu_pages_items'),
458
-                                $pages
459
-                            ),
460
-                            0,
461
-                            (object) $args
462
-                        );
463
-                        ?>
453
+						$pages          = $this->_get_extra_nav_menu_pages_items();
454
+						$args['walker'] = $walker;
455
+						echo walk_nav_menu_tree(
456
+							array_map(
457
+								array($this, '_setup_extra_nav_menu_pages_items'),
458
+								$pages
459
+							),
460
+							0,
461
+							(object) $args
462
+						);
463
+						?>
464 464
                     </ul>
465 465
                 </div><!-- /.tabs-panel -->
466 466
 
467 467
                 <p class="button-controls">
468 468
                 <span class="list-controls">
469 469
                     <a href="<?php
470
-                    echo esc_url(add_query_arg(
471
-                        array(
472
-                            'extra-nav-menu-pages-tab' => 'event-archives',
473
-                            'selectall'                => 1,
474
-                        ),
475
-                        remove_query_arg($removed_args)
476
-                    ));
477
-                    ?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a>
470
+					echo esc_url(add_query_arg(
471
+						array(
472
+							'extra-nav-menu-pages-tab' => 'event-archives',
473
+							'selectall'                => 1,
474
+						),
475
+						remove_query_arg($removed_args)
476
+					));
477
+					?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a>
478 478
                 </span>
479 479
                 <span class="add-to-menu">
480 480
                     <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?>
@@ -487,486 +487,486 @@  discard block
 block discarded – undo
487 487
 
488 488
         </div><!-- /.posttypediv -->
489 489
         <?php
490
-    }
491
-
492
-
493
-    /**
494
-     * Returns an array of event archive nav items.
495
-     *
496
-     * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
497
-     *        method we use for getting the extra nav menu items
498
-     * @return array
499
-     */
500
-    private function _get_extra_nav_menu_pages_items()
501
-    {
502
-        $menuitems[] = array(
503
-            'title'       => esc_html__('Event List', 'event_espresso'),
504
-            'url'         => get_post_type_archive_link('espresso_events'),
505
-            'description' => esc_html__('Archive page for all events.', 'event_espresso'),
506
-        );
507
-        return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
508
-    }
509
-
510
-
511
-    /**
512
-     * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
513
-     * the properties and converts it to the menu item object.
514
-     *
515
-     * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
516
-     * @param $menu_item_values
517
-     * @return stdClass
518
-     */
519
-    private function _setup_extra_nav_menu_pages_items($menu_item_values)
520
-    {
521
-        $menu_item = new stdClass();
522
-        $keys      = array(
523
-            'ID'               => 0,
524
-            'db_id'            => 0,
525
-            'menu_item_parent' => 0,
526
-            'object_id'        => -1,
527
-            'post_parent'      => 0,
528
-            'type'             => 'custom',
529
-            'object'           => '',
530
-            'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
531
-            'title'            => '',
532
-            'url'              => '',
533
-            'target'           => '',
534
-            'attr_title'       => '',
535
-            'description'      => '',
536
-            'classes'          => array(),
537
-            'xfn'              => '',
538
-        );
539
-
540
-        foreach ($keys as $key => $value) {
541
-            $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
542
-        }
543
-        return $menu_item;
544
-    }
545
-
546
-
547
-    /**
548
-     * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
549
-     * EE_Admin_Page route is called.
550
-     *
551
-     * @return void
552
-     */
553
-    public function route_admin_request()
554
-    {
555
-    }
556
-
557
-
558
-    /**
559
-     * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
560
-     *
561
-     * @return void
562
-     */
563
-    public function wp_loaded()
564
-    {
565
-    }
566
-
567
-
568
-    /**
569
-     * admin_init
570
-     *
571
-     * @return void
572
-     * @throws EE_Error
573
-     * @throws InvalidArgumentException
574
-     * @throws InvalidDataTypeException
575
-     * @throws InvalidInterfaceException
576
-     * @throws ReflectionException
577
-     */
578
-    public function admin_init()
579
-    {
580
-
581
-        /**
582
-         * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
583
-         * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
584
-         * - check if doing post processing.
585
-         * - check if doing post processing of one of EE CPTs
586
-         * - instantiate the corresponding EE CPT model for the post_type being processed.
587
-         */
588
-        if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
589
-            EE_Registry::instance()->load_core('Register_CPTs');
590
-            EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']);
591
-        }
592
-
593
-
594
-        /**
595
-         * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
596
-         * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
597
-         * Pages" tab in the EE General Settings Admin page.
598
-         * This is for user-proofing.
599
-         */
600
-        add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
601
-    }
602
-
603
-
604
-    /**
605
-     * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
606
-     *
607
-     * @param string $output Current output.
608
-     * @return string
609
-     * @throws InvalidArgumentException
610
-     * @throws InvalidDataTypeException
611
-     * @throws InvalidInterfaceException
612
-     */
613
-    public function modify_dropdown_pages($output)
614
-    {
615
-        //get critical pages
616
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
617
-
618
-        //split current output by line break for easier parsing.
619
-        $split_output = explode("\n", $output);
620
-
621
-        //loop through to remove any critical pages from the array.
622
-        foreach ($critical_pages as $page_id) {
623
-            $needle = 'value="' . $page_id . '"';
624
-            foreach ($split_output as $key => $haystack) {
625
-                if (strpos($haystack, $needle) !== false) {
626
-                    unset($split_output[$key]);
627
-                }
628
-            }
629
-        }
630
-        //replace output with the new contents
631
-        return implode("\n", $split_output);
632
-    }
633
-
634
-
635
-    /**
636
-     * enqueue all admin scripts that need loaded for admin pages
637
-     *
638
-     * @return void
639
-     */
640
-    public function enqueue_admin_scripts()
641
-    {
642
-        // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
643
-        // Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
644
-        // calls.
645
-        wp_enqueue_script(
646
-            'ee-inject-wp',
647
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
648
-            array('jquery'),
649
-            EVENT_ESPRESSO_VERSION,
650
-            true
651
-        );
652
-        // register cookie script for future dependencies
653
-        wp_register_script(
654
-            'jquery-cookie',
655
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
656
-            array('jquery'),
657
-            '2.1',
658
-            true
659
-        );
660
-        //joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again
661
-        // via: add_filter('FHEE_load_joyride', '__return_true' );
662
-        if (apply_filters('FHEE_load_joyride', false)) {
663
-            //joyride style
664
-            wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
665
-            wp_register_style(
666
-                'ee-joyride-css',
667
-                EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
668
-                array('joyride-css'),
669
-                EVENT_ESPRESSO_VERSION
670
-            );
671
-            wp_register_script(
672
-                'joyride-modernizr',
673
-                EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
674
-                array(),
675
-                '2.1',
676
-                true
677
-            );
678
-            //joyride JS
679
-            wp_register_script(
680
-                'jquery-joyride',
681
-                EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
682
-                array('jquery-cookie', 'joyride-modernizr'),
683
-                '2.1',
684
-                true
685
-            );
686
-            // wanna go for a joyride?
687
-            wp_enqueue_style('ee-joyride-css');
688
-            wp_enqueue_script('jquery-joyride');
689
-        }
690
-    }
691
-
692
-
693
-    /**
694
-     * display_admin_notices
695
-     *
696
-     * @return void
697
-     */
698
-    public function display_admin_notices()
699
-    {
700
-        echo EE_Error::get_notices();
701
-    }
702
-
703
-
704
-
705
-    /**
706
-     * @param array $elements
707
-     * @return array
708
-     * @throws EE_Error
709
-     * @throws InvalidArgumentException
710
-     * @throws InvalidDataTypeException
711
-     * @throws InvalidInterfaceException
712
-     */
713
-    public function dashboard_glance_items($elements)
714
-    {
715
-        $elements                        = is_array($elements) ? $elements : array($elements);
716
-        $events                          = EEM_Event::instance()->count();
717
-        $items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(
718
-            array('page' => 'espresso_events'),
719
-            admin_url('admin.php')
720
-        );
721
-        $items['events']['text']         = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events));
722
-        $items['events']['title']        = esc_html__('Click to view all Events', 'event_espresso');
723
-        $registrations                   = EEM_Registration::instance()->count(
724
-            array(
725
-                array(
726
-                    'STS_ID' => array('!=', EEM_Registration::status_id_incomplete),
727
-                ),
728
-            )
729
-        );
730
-        $items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
731
-            array('page' => 'espresso_registrations'),
732
-            admin_url('admin.php')
733
-        );
734
-        $items['registrations']['text']  = sprintf(
735
-            _n('%s Registration', '%s Registrations', $registrations),
736
-            number_format_i18n($registrations)
737
-        );
738
-        $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
739
-
740
-        $items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
741
-
742
-        foreach ($items as $type => $item_properties) {
743
-            $elements[] = sprintf(
744
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
745
-                $item_properties['url'],
746
-                $item_properties['title'],
747
-                $item_properties['text']
748
-            );
749
-        }
750
-        return $elements;
751
-    }
752
-
753
-
754
-    /**
755
-     * check_for_invalid_datetime_formats
756
-     * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
757
-     * their selected format can be parsed by PHP
758
-     *
759
-     * @param    $value
760
-     * @param    $option
761
-     * @throws EE_Error
762
-     * @return    string
763
-     */
764
-    public function check_for_invalid_datetime_formats($value, $option)
765
-    {
766
-        // check for date_format or time_format
767
-        switch ($option) {
768
-            case 'date_format':
769
-                $date_time_format = $value . ' ' . get_option('time_format');
770
-                break;
771
-            case 'time_format':
772
-                $date_time_format = get_option('date_format') . ' ' . $value;
773
-                break;
774
-            default:
775
-                $date_time_format = false;
776
-        }
777
-        // do we have a date_time format to check ?
778
-        if ($date_time_format) {
779
-            $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
780
-
781
-            if (is_array($error_msg)) {
782
-                $msg = '<p>'
783
-                       . sprintf(
784
-                           esc_html__(
785
-                               'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
786
-                               'event_espresso'
787
-                           ),
788
-                           date($date_time_format),
789
-                           $date_time_format
790
-                       )
791
-                       . '</p><p><ul>';
792
-
793
-
794
-                foreach ($error_msg as $error) {
795
-                    $msg .= '<li>' . $error . '</li>';
796
-                }
797
-
798
-                $msg .= '</ul></p><p>'
799
-                        . sprintf(
800
-                            esc_html__(
801
-                                '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
802
-                                'event_espresso'
803
-                            ),
804
-                            '<span style="color:#D54E21;">',
805
-                            '</span>'
806
-                        )
807
-                        . '</p>';
808
-
809
-                // trigger WP settings error
810
-                add_settings_error(
811
-                    'date_format',
812
-                    'date_format',
813
-                    $msg
814
-                );
815
-
816
-                // set format to something valid
817
-                switch ($option) {
818
-                    case 'date_format':
819
-                        $value = 'F j, Y';
820
-                        break;
821
-                    case 'time_format':
822
-                        $value = 'g:i a';
823
-                        break;
824
-                }
825
-            }
826
-        }
827
-        return $value;
828
-    }
829
-
830
-
831
-    /**
832
-     * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
833
-     *
834
-     * @param $content
835
-     * @return    string
836
-     */
837
-    public function its_eSpresso($content)
838
-    {
839
-        return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
840
-    }
841
-
842
-
843
-    /**
844
-     * espresso_admin_footer
845
-     *
846
-     * @return    string
847
-     */
848
-    public function espresso_admin_footer()
849
-    {
850
-        return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer'));
851
-    }
852
-
853
-
854
-    /**
855
-     * static method for registering ee admin page.
856
-     * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
857
-     *
858
-     * @since      4.3.0
859
-     * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
860
-     * @see        EE_Register_Admin_Page::register()
861
-     * @param       $page_basename
862
-     * @param       $page_path
863
-     * @param array $config
864
-     * @return void
865
-     * @throws EE_Error
866
-     */
867
-    public static function register_ee_admin_page($page_basename, $page_path, $config = array())
868
-    {
869
-        EE_Error::doing_it_wrong(
870
-            __METHOD__,
871
-            sprintf(
872
-                esc_html__(
873
-                    'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
874
-                    'event_espresso'
875
-                ),
876
-                $page_basename
877
-            ),
878
-            '4.3'
879
-        );
880
-        if (class_exists('EE_Register_Admin_Page')) {
881
-            $config['page_path'] = $page_path;
882
-        }
883
-        EE_Register_Admin_Page::register($page_basename, $config);
884
-    }
885
-
886
-
887
-    /**
888
-     * @deprecated 4.8.41
889
-     * @param  int      $post_ID
890
-     * @param  \WP_Post $post
891
-     * @return void
892
-     */
893
-    public static function parse_post_content_on_save($post_ID, $post)
894
-    {
895
-        EE_Error::doing_it_wrong(
896
-            __METHOD__,
897
-            esc_html__('Usage is deprecated', 'event_espresso'),
898
-            '4.8.41'
899
-        );
900
-    }
901
-
902
-
903
-    /**
904
-     * @deprecated 4.8.41
905
-     * @param  $option
906
-     * @param  $old_value
907
-     * @param  $value
908
-     * @return void
909
-     */
910
-    public function reset_page_for_posts_on_change($option, $old_value, $value)
911
-    {
912
-        EE_Error::doing_it_wrong(
913
-            __METHOD__,
914
-            esc_html__('Usage is deprecated', 'event_espresso'),
915
-            '4.8.41'
916
-        );
917
-    }
918
-
919
-
920
-
921
-    /**
922
-     * @deprecated 4.9.27
923
-     * @return void
924
-     */
925
-    public function get_persistent_admin_notices()
926
-    {
927
-        EE_Error::doing_it_wrong(
928
-            __METHOD__,
929
-            sprintf(
930
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
931
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
932
-            ),
933
-            '4.9.27'
934
-        );
935
-    }
936
-
937
-
938
-
939
-    /**
940
-     * @deprecated 4.9.27
941
-     * @throws InvalidInterfaceException
942
-     * @throws InvalidDataTypeException
943
-     * @throws DomainException
944
-     */
945
-    public function dismiss_ee_nag_notice_callback()
946
-    {
947
-        EE_Error::doing_it_wrong(
948
-            __METHOD__,
949
-            sprintf(
950
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
951
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
952
-            ),
953
-            '4.9.27'
954
-        );
955
-        $this->persistent_admin_notice_manager->dismissNotice();
956
-    }
957
-
958
-
959
-    /**
960
-     * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.
961
-     * @throws InvalidArgumentException
962
-     * @throws InvalidDataTypeException
963
-     * @throws InvalidInterfaceException
964
-     */
965
-    public function hookIntoWpPluginsPage()
966
-    {
967
-        LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\ExitModal');
968
-        LoaderFactory::getLoader()
969
-                     ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells')
970
-                     ->decafUpsells();
971
-    }
490
+	}
491
+
492
+
493
+	/**
494
+	 * Returns an array of event archive nav items.
495
+	 *
496
+	 * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
497
+	 *        method we use for getting the extra nav menu items
498
+	 * @return array
499
+	 */
500
+	private function _get_extra_nav_menu_pages_items()
501
+	{
502
+		$menuitems[] = array(
503
+			'title'       => esc_html__('Event List', 'event_espresso'),
504
+			'url'         => get_post_type_archive_link('espresso_events'),
505
+			'description' => esc_html__('Archive page for all events.', 'event_espresso'),
506
+		);
507
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
508
+	}
509
+
510
+
511
+	/**
512
+	 * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
513
+	 * the properties and converts it to the menu item object.
514
+	 *
515
+	 * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
516
+	 * @param $menu_item_values
517
+	 * @return stdClass
518
+	 */
519
+	private function _setup_extra_nav_menu_pages_items($menu_item_values)
520
+	{
521
+		$menu_item = new stdClass();
522
+		$keys      = array(
523
+			'ID'               => 0,
524
+			'db_id'            => 0,
525
+			'menu_item_parent' => 0,
526
+			'object_id'        => -1,
527
+			'post_parent'      => 0,
528
+			'type'             => 'custom',
529
+			'object'           => '',
530
+			'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
531
+			'title'            => '',
532
+			'url'              => '',
533
+			'target'           => '',
534
+			'attr_title'       => '',
535
+			'description'      => '',
536
+			'classes'          => array(),
537
+			'xfn'              => '',
538
+		);
539
+
540
+		foreach ($keys as $key => $value) {
541
+			$menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
542
+		}
543
+		return $menu_item;
544
+	}
545
+
546
+
547
+	/**
548
+	 * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
549
+	 * EE_Admin_Page route is called.
550
+	 *
551
+	 * @return void
552
+	 */
553
+	public function route_admin_request()
554
+	{
555
+	}
556
+
557
+
558
+	/**
559
+	 * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
560
+	 *
561
+	 * @return void
562
+	 */
563
+	public function wp_loaded()
564
+	{
565
+	}
566
+
567
+
568
+	/**
569
+	 * admin_init
570
+	 *
571
+	 * @return void
572
+	 * @throws EE_Error
573
+	 * @throws InvalidArgumentException
574
+	 * @throws InvalidDataTypeException
575
+	 * @throws InvalidInterfaceException
576
+	 * @throws ReflectionException
577
+	 */
578
+	public function admin_init()
579
+	{
580
+
581
+		/**
582
+		 * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
583
+		 * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
584
+		 * - check if doing post processing.
585
+		 * - check if doing post processing of one of EE CPTs
586
+		 * - instantiate the corresponding EE CPT model for the post_type being processed.
587
+		 */
588
+		if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
589
+			EE_Registry::instance()->load_core('Register_CPTs');
590
+			EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']);
591
+		}
592
+
593
+
594
+		/**
595
+		 * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
596
+		 * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
597
+		 * Pages" tab in the EE General Settings Admin page.
598
+		 * This is for user-proofing.
599
+		 */
600
+		add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
601
+	}
602
+
603
+
604
+	/**
605
+	 * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
606
+	 *
607
+	 * @param string $output Current output.
608
+	 * @return string
609
+	 * @throws InvalidArgumentException
610
+	 * @throws InvalidDataTypeException
611
+	 * @throws InvalidInterfaceException
612
+	 */
613
+	public function modify_dropdown_pages($output)
614
+	{
615
+		//get critical pages
616
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
617
+
618
+		//split current output by line break for easier parsing.
619
+		$split_output = explode("\n", $output);
620
+
621
+		//loop through to remove any critical pages from the array.
622
+		foreach ($critical_pages as $page_id) {
623
+			$needle = 'value="' . $page_id . '"';
624
+			foreach ($split_output as $key => $haystack) {
625
+				if (strpos($haystack, $needle) !== false) {
626
+					unset($split_output[$key]);
627
+				}
628
+			}
629
+		}
630
+		//replace output with the new contents
631
+		return implode("\n", $split_output);
632
+	}
633
+
634
+
635
+	/**
636
+	 * enqueue all admin scripts that need loaded for admin pages
637
+	 *
638
+	 * @return void
639
+	 */
640
+	public function enqueue_admin_scripts()
641
+	{
642
+		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
643
+		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
644
+		// calls.
645
+		wp_enqueue_script(
646
+			'ee-inject-wp',
647
+			EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
648
+			array('jquery'),
649
+			EVENT_ESPRESSO_VERSION,
650
+			true
651
+		);
652
+		// register cookie script for future dependencies
653
+		wp_register_script(
654
+			'jquery-cookie',
655
+			EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
656
+			array('jquery'),
657
+			'2.1',
658
+			true
659
+		);
660
+		//joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again
661
+		// via: add_filter('FHEE_load_joyride', '__return_true' );
662
+		if (apply_filters('FHEE_load_joyride', false)) {
663
+			//joyride style
664
+			wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
665
+			wp_register_style(
666
+				'ee-joyride-css',
667
+				EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
668
+				array('joyride-css'),
669
+				EVENT_ESPRESSO_VERSION
670
+			);
671
+			wp_register_script(
672
+				'joyride-modernizr',
673
+				EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
674
+				array(),
675
+				'2.1',
676
+				true
677
+			);
678
+			//joyride JS
679
+			wp_register_script(
680
+				'jquery-joyride',
681
+				EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
682
+				array('jquery-cookie', 'joyride-modernizr'),
683
+				'2.1',
684
+				true
685
+			);
686
+			// wanna go for a joyride?
687
+			wp_enqueue_style('ee-joyride-css');
688
+			wp_enqueue_script('jquery-joyride');
689
+		}
690
+	}
691
+
692
+
693
+	/**
694
+	 * display_admin_notices
695
+	 *
696
+	 * @return void
697
+	 */
698
+	public function display_admin_notices()
699
+	{
700
+		echo EE_Error::get_notices();
701
+	}
702
+
703
+
704
+
705
+	/**
706
+	 * @param array $elements
707
+	 * @return array
708
+	 * @throws EE_Error
709
+	 * @throws InvalidArgumentException
710
+	 * @throws InvalidDataTypeException
711
+	 * @throws InvalidInterfaceException
712
+	 */
713
+	public function dashboard_glance_items($elements)
714
+	{
715
+		$elements                        = is_array($elements) ? $elements : array($elements);
716
+		$events                          = EEM_Event::instance()->count();
717
+		$items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(
718
+			array('page' => 'espresso_events'),
719
+			admin_url('admin.php')
720
+		);
721
+		$items['events']['text']         = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events));
722
+		$items['events']['title']        = esc_html__('Click to view all Events', 'event_espresso');
723
+		$registrations                   = EEM_Registration::instance()->count(
724
+			array(
725
+				array(
726
+					'STS_ID' => array('!=', EEM_Registration::status_id_incomplete),
727
+				),
728
+			)
729
+		);
730
+		$items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
731
+			array('page' => 'espresso_registrations'),
732
+			admin_url('admin.php')
733
+		);
734
+		$items['registrations']['text']  = sprintf(
735
+			_n('%s Registration', '%s Registrations', $registrations),
736
+			number_format_i18n($registrations)
737
+		);
738
+		$items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
739
+
740
+		$items = (array)apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
741
+
742
+		foreach ($items as $type => $item_properties) {
743
+			$elements[] = sprintf(
744
+				'<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
745
+				$item_properties['url'],
746
+				$item_properties['title'],
747
+				$item_properties['text']
748
+			);
749
+		}
750
+		return $elements;
751
+	}
752
+
753
+
754
+	/**
755
+	 * check_for_invalid_datetime_formats
756
+	 * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
757
+	 * their selected format can be parsed by PHP
758
+	 *
759
+	 * @param    $value
760
+	 * @param    $option
761
+	 * @throws EE_Error
762
+	 * @return    string
763
+	 */
764
+	public function check_for_invalid_datetime_formats($value, $option)
765
+	{
766
+		// check for date_format or time_format
767
+		switch ($option) {
768
+			case 'date_format':
769
+				$date_time_format = $value . ' ' . get_option('time_format');
770
+				break;
771
+			case 'time_format':
772
+				$date_time_format = get_option('date_format') . ' ' . $value;
773
+				break;
774
+			default:
775
+				$date_time_format = false;
776
+		}
777
+		// do we have a date_time format to check ?
778
+		if ($date_time_format) {
779
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
780
+
781
+			if (is_array($error_msg)) {
782
+				$msg = '<p>'
783
+					   . sprintf(
784
+						   esc_html__(
785
+							   'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
786
+							   'event_espresso'
787
+						   ),
788
+						   date($date_time_format),
789
+						   $date_time_format
790
+					   )
791
+					   . '</p><p><ul>';
792
+
793
+
794
+				foreach ($error_msg as $error) {
795
+					$msg .= '<li>' . $error . '</li>';
796
+				}
797
+
798
+				$msg .= '</ul></p><p>'
799
+						. sprintf(
800
+							esc_html__(
801
+								'%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
802
+								'event_espresso'
803
+							),
804
+							'<span style="color:#D54E21;">',
805
+							'</span>'
806
+						)
807
+						. '</p>';
808
+
809
+				// trigger WP settings error
810
+				add_settings_error(
811
+					'date_format',
812
+					'date_format',
813
+					$msg
814
+				);
815
+
816
+				// set format to something valid
817
+				switch ($option) {
818
+					case 'date_format':
819
+						$value = 'F j, Y';
820
+						break;
821
+					case 'time_format':
822
+						$value = 'g:i a';
823
+						break;
824
+				}
825
+			}
826
+		}
827
+		return $value;
828
+	}
829
+
830
+
831
+	/**
832
+	 * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
833
+	 *
834
+	 * @param $content
835
+	 * @return    string
836
+	 */
837
+	public function its_eSpresso($content)
838
+	{
839
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
840
+	}
841
+
842
+
843
+	/**
844
+	 * espresso_admin_footer
845
+	 *
846
+	 * @return    string
847
+	 */
848
+	public function espresso_admin_footer()
849
+	{
850
+		return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer'));
851
+	}
852
+
853
+
854
+	/**
855
+	 * static method for registering ee admin page.
856
+	 * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
857
+	 *
858
+	 * @since      4.3.0
859
+	 * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
860
+	 * @see        EE_Register_Admin_Page::register()
861
+	 * @param       $page_basename
862
+	 * @param       $page_path
863
+	 * @param array $config
864
+	 * @return void
865
+	 * @throws EE_Error
866
+	 */
867
+	public static function register_ee_admin_page($page_basename, $page_path, $config = array())
868
+	{
869
+		EE_Error::doing_it_wrong(
870
+			__METHOD__,
871
+			sprintf(
872
+				esc_html__(
873
+					'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
874
+					'event_espresso'
875
+				),
876
+				$page_basename
877
+			),
878
+			'4.3'
879
+		);
880
+		if (class_exists('EE_Register_Admin_Page')) {
881
+			$config['page_path'] = $page_path;
882
+		}
883
+		EE_Register_Admin_Page::register($page_basename, $config);
884
+	}
885
+
886
+
887
+	/**
888
+	 * @deprecated 4.8.41
889
+	 * @param  int      $post_ID
890
+	 * @param  \WP_Post $post
891
+	 * @return void
892
+	 */
893
+	public static function parse_post_content_on_save($post_ID, $post)
894
+	{
895
+		EE_Error::doing_it_wrong(
896
+			__METHOD__,
897
+			esc_html__('Usage is deprecated', 'event_espresso'),
898
+			'4.8.41'
899
+		);
900
+	}
901
+
902
+
903
+	/**
904
+	 * @deprecated 4.8.41
905
+	 * @param  $option
906
+	 * @param  $old_value
907
+	 * @param  $value
908
+	 * @return void
909
+	 */
910
+	public function reset_page_for_posts_on_change($option, $old_value, $value)
911
+	{
912
+		EE_Error::doing_it_wrong(
913
+			__METHOD__,
914
+			esc_html__('Usage is deprecated', 'event_espresso'),
915
+			'4.8.41'
916
+		);
917
+	}
918
+
919
+
920
+
921
+	/**
922
+	 * @deprecated 4.9.27
923
+	 * @return void
924
+	 */
925
+	public function get_persistent_admin_notices()
926
+	{
927
+		EE_Error::doing_it_wrong(
928
+			__METHOD__,
929
+			sprintf(
930
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
931
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
932
+			),
933
+			'4.9.27'
934
+		);
935
+	}
936
+
937
+
938
+
939
+	/**
940
+	 * @deprecated 4.9.27
941
+	 * @throws InvalidInterfaceException
942
+	 * @throws InvalidDataTypeException
943
+	 * @throws DomainException
944
+	 */
945
+	public function dismiss_ee_nag_notice_callback()
946
+	{
947
+		EE_Error::doing_it_wrong(
948
+			__METHOD__,
949
+			sprintf(
950
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
951
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
952
+			),
953
+			'4.9.27'
954
+		);
955
+		$this->persistent_admin_notice_manager->dismissNotice();
956
+	}
957
+
958
+
959
+	/**
960
+	 * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.
961
+	 * @throws InvalidArgumentException
962
+	 * @throws InvalidDataTypeException
963
+	 * @throws InvalidInterfaceException
964
+	 */
965
+	public function hookIntoWpPluginsPage()
966
+	{
967
+		LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\ExitModal');
968
+		LoaderFactory::getLoader()
969
+					 ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells')
970
+					 ->decafUpsells();
971
+	}
972 972
 }
Please login to merge, or discard this patch.
core/request_stack/EE_Request.core.php 1 patch
Indentation   +363 added lines, -363 removed lines patch added patch discarded remove patch
@@ -22,369 +22,369 @@
 block discarded – undo
22 22
 class EE_Request implements LegacyRequestInterface, InterminableInterface
23 23
 {
24 24
 
25
-    /**
26
-     * @var RequestInterface $request
27
-     */
28
-    private $request;
29
-
30
-    /**
31
-     * whether current request is for the admin but NOT via AJAX
32
-     *
33
-     * @var boolean $admin
34
-     */
35
-    public $admin = false;
36
-
37
-    /**
38
-     * whether current request is via AJAX
39
-     *
40
-     * @var boolean $ajax
41
-     */
42
-    public $ajax = false;
43
-
44
-    /**
45
-     * whether current request is via AJAX from the frontend of the site
46
-     *
47
-     * @var boolean $front_ajax
48
-     */
49
-    public $front_ajax = false;
50
-
51
-
52
-    /**
53
-     * @deprecated 4.9.53
54
-     * @param array $get
55
-     * @param array $post
56
-     * @param array $cookie
57
-     * @param array $server
58
-     */
59
-    public function __construct(
60
-        array $get = array(),
61
-        array $post = array(),
62
-        array $cookie = array(),
63
-        array $server = array()
64
-    ) {
65
-    }
66
-
67
-
68
-    /**
69
-     * @return RequestInterface
70
-     * @throws InvalidArgumentException
71
-     * @throws InvalidInterfaceException
72
-     * @throws InvalidDataTypeException
73
-     */
74
-    private function request()
75
-    {
76
-        if($this->request instanceof RequestInterface){
77
-            return $this->request;
78
-        }
79
-        $loader = LoaderFactory::getLoader();
80
-        $this->request = $loader->getShared('EventEspresso\core\services\request\RequestInterface');
81
-        return $this->request;
82
-    }
83
-
84
-
85
-    /**
86
-     * @param RequestInterface $request
87
-     */
88
-    public function setRequest(RequestInterface $request)
89
-    {
90
-        $this->request = $request;
91
-    }
92
-
93
-
94
-
95
-    /**
96
-     * @deprecated 4.9.53
97
-     * @return array
98
-     * @throws InvalidArgumentException
99
-     * @throws InvalidDataTypeException
100
-     * @throws InvalidInterfaceException
101
-     */
102
-    public function get_params()
103
-    {
104
-        return $this->request()->getParams();
105
-    }
106
-
107
-
108
-
109
-    /**
110
-     * @deprecated 4.9.53
111
-     * @return array
112
-     * @throws InvalidArgumentException
113
-     * @throws InvalidDataTypeException
114
-     * @throws InvalidInterfaceException
115
-     */
116
-    public function post_params()
117
-    {
118
-        return $this->request()->postParams();
119
-    }
120
-
121
-
122
-
123
-    /**
124
-     * @deprecated 4.9.53
125
-     * @return array
126
-     * @throws InvalidArgumentException
127
-     * @throws InvalidDataTypeException
128
-     * @throws InvalidInterfaceException
129
-     */
130
-    public function cookie_params()
131
-    {
132
-        return $this->request()->cookieParams();
133
-    }
134
-
135
-
136
-    /**
137
-     * @deprecated 4.9.53
138
-     * @return array
139
-     * @throws InvalidArgumentException
140
-     * @throws InvalidDataTypeException
141
-     * @throws InvalidInterfaceException
142
-     */
143
-    public function server_params()
144
-    {
145
-        return $this->request()->serverParams();
146
-    }
147
-
148
-
149
-
150
-    /**
151
-     * returns contents of $_REQUEST
152
-     *
153
-     * @deprecated 4.9.53
154
-     * @return array
155
-     * @throws InvalidArgumentException
156
-     * @throws InvalidDataTypeException
157
-     * @throws InvalidInterfaceException
158
-     */
159
-    public function params()
160
-    {
161
-        return $this->request()->requestParams();
162
-    }
163
-
164
-
165
-
166
-    /**
167
-     * @deprecated 4.9.53
168
-     * @param      $key
169
-     * @param      $value
170
-     * @param bool $override_ee
171
-     * @return void
172
-     * @throws InvalidArgumentException
173
-     * @throws InvalidDataTypeException
174
-     * @throws InvalidInterfaceException
175
-     */
176
-    public function set($key, $value, $override_ee = false)
177
-    {
178
-        $this->request()->setRequestParam($key, $value, $override_ee);
179
-    }
180
-
181
-
182
-
183
-    /**
184
-     * returns   the value for a request param if the given key exists
185
-     *
186
-     * @deprecated 4.9.53
187
-     * @param      $key
188
-     * @param null $default
189
-     * @return mixed
190
-     * @throws InvalidArgumentException
191
-     * @throws InvalidDataTypeException
192
-     * @throws InvalidInterfaceException
193
-     */
194
-    public function get($key, $default = null)
195
-    {
196
-        return $this->request()->getRequestParam($key, $default);
197
-    }
198
-
199
-
200
-
201
-    /**
202
-     * check if param exists
203
-     *
204
-     * @deprecated 4.9.53
205
-     * @param $key
206
-     * @return bool
207
-     * @throws InvalidArgumentException
208
-     * @throws InvalidDataTypeException
209
-     * @throws InvalidInterfaceException
210
-     */
211
-    public function is_set($key)
212
-    {
213
-        return $this->request()->requestParamIsSet($key);
214
-    }
215
-
216
-
217
-    /**
218
-     * remove param
219
-     *
220
-     * @deprecated 4.9.53
221
-     * @param      $key
222
-     * @param bool $unset_from_global_too
223
-     * @throws InvalidArgumentException
224
-     * @throws InvalidDataTypeException
225
-     * @throws InvalidInterfaceException
226
-     */
227
-    public function un_set($key, $unset_from_global_too = false)
228
-    {
229
-        $this->request()->unSetRequestParam($key, $unset_from_global_too);
230
-    }
231
-
232
-
233
-
234
-    /**
235
-     * @deprecated 4.9.53
236
-     * @return string
237
-     * @throws InvalidArgumentException
238
-     * @throws InvalidDataTypeException
239
-     * @throws InvalidInterfaceException
240
-     */
241
-    public function ip_address()
242
-    {
243
-        return $this->request()->ipAddress();
244
-    }
245
-
246
-
247
-    /**
248
-     * @deprecated 4.9.53
249
-     * @return bool
250
-     * @throws InvalidArgumentException
251
-     * @throws InvalidDataTypeException
252
-     * @throws InvalidInterfaceException
253
-     */
254
-    public function isAdmin()
255
-    {
256
-        return $this->request()->isAdmin();
257
-    }
258
-
259
-
260
-    /**
261
-     * @deprecated 4.9.53
262
-     * @return mixed
263
-     * @throws InvalidArgumentException
264
-     * @throws InvalidDataTypeException
265
-     * @throws InvalidInterfaceException
266
-     */
267
-    public function isAjax()
268
-    {
269
-        return $this->request()->isAjax();
270
-    }
271
-
272
-
273
-    /**
274
-     * @deprecated 4.9.53
275
-     * @return mixed
276
-     * @throws InvalidArgumentException
277
-     * @throws InvalidDataTypeException
278
-     * @throws InvalidInterfaceException
279
-     */
280
-    public function isFrontAjax()
281
-    {
282
-        return $this->request()->isFrontAjax();
283
-    }
284
-
285
-
286
-    /**
287
-     * @deprecated 4.9.53
288
-     * @return mixed|string
289
-     * @throws InvalidArgumentException
290
-     * @throws InvalidDataTypeException
291
-     * @throws InvalidInterfaceException
292
-     */
293
-    public function requestUri()
294
-    {
295
-        return $this->request()->requestUri();
296
-    }
297
-
298
-
299
-    /**
300
-     * @deprecated 4.9.53
301
-     * @return string
302
-     * @throws InvalidArgumentException
303
-     * @throws InvalidDataTypeException
304
-     * @throws InvalidInterfaceException
305
-     */
306
-    public function userAgent()
307
-    {
308
-        return $this->request()->userAgent();
309
-    }
310
-
311
-
312
-    /**
313
-     * @deprecated 4.9.53
314
-     * @param string $user_agent
315
-     * @throws InvalidArgumentException
316
-     * @throws InvalidDataTypeException
317
-     * @throws InvalidInterfaceException
318
-     */
319
-    public function setUserAgent($user_agent = '')
320
-    {
321
-        $this->request()->setUserAgent($user_agent);
322
-    }
323
-
324
-
325
-    /**
326
-     * @deprecated 4.9.53
327
-     * @return bool
328
-     * @throws InvalidArgumentException
329
-     * @throws InvalidDataTypeException
330
-     * @throws InvalidInterfaceException
331
-     */
332
-    public function isBot()
333
-    {
334
-        return $this->request()->isBot();
335
-    }
336
-
337
-
338
-    /**
339
-     * @deprecated 4.9.53
340
-     * @param bool $is_bot
341
-     * @throws InvalidArgumentException
342
-     * @throws InvalidDataTypeException
343
-     * @throws InvalidInterfaceException
344
-     */
345
-    public function setIsBot($is_bot)
346
-    {
347
-        $this->request()->setIsBot($is_bot);
348
-    }
349
-
350
-
351
-    /**
352
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
353
-     * and return the value for the first match found
354
-     * wildcards can be either of the following:
355
-     *      ? to represent a single character of any type
356
-     *      * to represent one or more characters of any type
357
-     *
358
-     * @param string     $pattern
359
-     * @param null|mixed $default
360
-     * @return false|int
361
-     * @throws InvalidArgumentException
362
-     * @throws InvalidInterfaceException
363
-     * @throws InvalidDataTypeException
364
-     */
365
-    public function getMatch($pattern, $default = null)
366
-    {
367
-        return $this->request()->getMatch($pattern, $default);
368
-    }
369
-
370
-
371
-    /**
372
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
373
-     * wildcards can be either of the following:
374
-     *      ? to represent a single character of any type
375
-     *      * to represent one or more characters of any type
376
-     * returns true if a match is found or false if not
377
-     *
378
-     * @param string $pattern
379
-     * @return false|int
380
-     * @throws InvalidArgumentException
381
-     * @throws InvalidInterfaceException
382
-     * @throws InvalidDataTypeException
383
-     */
384
-    public function matches($pattern)
385
-    {
386
-        return $this->request()->matches($pattern);
387
-    }
25
+	/**
26
+	 * @var RequestInterface $request
27
+	 */
28
+	private $request;
29
+
30
+	/**
31
+	 * whether current request is for the admin but NOT via AJAX
32
+	 *
33
+	 * @var boolean $admin
34
+	 */
35
+	public $admin = false;
36
+
37
+	/**
38
+	 * whether current request is via AJAX
39
+	 *
40
+	 * @var boolean $ajax
41
+	 */
42
+	public $ajax = false;
43
+
44
+	/**
45
+	 * whether current request is via AJAX from the frontend of the site
46
+	 *
47
+	 * @var boolean $front_ajax
48
+	 */
49
+	public $front_ajax = false;
50
+
51
+
52
+	/**
53
+	 * @deprecated 4.9.53
54
+	 * @param array $get
55
+	 * @param array $post
56
+	 * @param array $cookie
57
+	 * @param array $server
58
+	 */
59
+	public function __construct(
60
+		array $get = array(),
61
+		array $post = array(),
62
+		array $cookie = array(),
63
+		array $server = array()
64
+	) {
65
+	}
66
+
67
+
68
+	/**
69
+	 * @return RequestInterface
70
+	 * @throws InvalidArgumentException
71
+	 * @throws InvalidInterfaceException
72
+	 * @throws InvalidDataTypeException
73
+	 */
74
+	private function request()
75
+	{
76
+		if($this->request instanceof RequestInterface){
77
+			return $this->request;
78
+		}
79
+		$loader = LoaderFactory::getLoader();
80
+		$this->request = $loader->getShared('EventEspresso\core\services\request\RequestInterface');
81
+		return $this->request;
82
+	}
83
+
84
+
85
+	/**
86
+	 * @param RequestInterface $request
87
+	 */
88
+	public function setRequest(RequestInterface $request)
89
+	{
90
+		$this->request = $request;
91
+	}
92
+
93
+
94
+
95
+	/**
96
+	 * @deprecated 4.9.53
97
+	 * @return array
98
+	 * @throws InvalidArgumentException
99
+	 * @throws InvalidDataTypeException
100
+	 * @throws InvalidInterfaceException
101
+	 */
102
+	public function get_params()
103
+	{
104
+		return $this->request()->getParams();
105
+	}
106
+
107
+
108
+
109
+	/**
110
+	 * @deprecated 4.9.53
111
+	 * @return array
112
+	 * @throws InvalidArgumentException
113
+	 * @throws InvalidDataTypeException
114
+	 * @throws InvalidInterfaceException
115
+	 */
116
+	public function post_params()
117
+	{
118
+		return $this->request()->postParams();
119
+	}
120
+
121
+
122
+
123
+	/**
124
+	 * @deprecated 4.9.53
125
+	 * @return array
126
+	 * @throws InvalidArgumentException
127
+	 * @throws InvalidDataTypeException
128
+	 * @throws InvalidInterfaceException
129
+	 */
130
+	public function cookie_params()
131
+	{
132
+		return $this->request()->cookieParams();
133
+	}
134
+
135
+
136
+	/**
137
+	 * @deprecated 4.9.53
138
+	 * @return array
139
+	 * @throws InvalidArgumentException
140
+	 * @throws InvalidDataTypeException
141
+	 * @throws InvalidInterfaceException
142
+	 */
143
+	public function server_params()
144
+	{
145
+		return $this->request()->serverParams();
146
+	}
147
+
148
+
149
+
150
+	/**
151
+	 * returns contents of $_REQUEST
152
+	 *
153
+	 * @deprecated 4.9.53
154
+	 * @return array
155
+	 * @throws InvalidArgumentException
156
+	 * @throws InvalidDataTypeException
157
+	 * @throws InvalidInterfaceException
158
+	 */
159
+	public function params()
160
+	{
161
+		return $this->request()->requestParams();
162
+	}
163
+
164
+
165
+
166
+	/**
167
+	 * @deprecated 4.9.53
168
+	 * @param      $key
169
+	 * @param      $value
170
+	 * @param bool $override_ee
171
+	 * @return void
172
+	 * @throws InvalidArgumentException
173
+	 * @throws InvalidDataTypeException
174
+	 * @throws InvalidInterfaceException
175
+	 */
176
+	public function set($key, $value, $override_ee = false)
177
+	{
178
+		$this->request()->setRequestParam($key, $value, $override_ee);
179
+	}
180
+
181
+
182
+
183
+	/**
184
+	 * returns   the value for a request param if the given key exists
185
+	 *
186
+	 * @deprecated 4.9.53
187
+	 * @param      $key
188
+	 * @param null $default
189
+	 * @return mixed
190
+	 * @throws InvalidArgumentException
191
+	 * @throws InvalidDataTypeException
192
+	 * @throws InvalidInterfaceException
193
+	 */
194
+	public function get($key, $default = null)
195
+	{
196
+		return $this->request()->getRequestParam($key, $default);
197
+	}
198
+
199
+
200
+
201
+	/**
202
+	 * check if param exists
203
+	 *
204
+	 * @deprecated 4.9.53
205
+	 * @param $key
206
+	 * @return bool
207
+	 * @throws InvalidArgumentException
208
+	 * @throws InvalidDataTypeException
209
+	 * @throws InvalidInterfaceException
210
+	 */
211
+	public function is_set($key)
212
+	{
213
+		return $this->request()->requestParamIsSet($key);
214
+	}
215
+
216
+
217
+	/**
218
+	 * remove param
219
+	 *
220
+	 * @deprecated 4.9.53
221
+	 * @param      $key
222
+	 * @param bool $unset_from_global_too
223
+	 * @throws InvalidArgumentException
224
+	 * @throws InvalidDataTypeException
225
+	 * @throws InvalidInterfaceException
226
+	 */
227
+	public function un_set($key, $unset_from_global_too = false)
228
+	{
229
+		$this->request()->unSetRequestParam($key, $unset_from_global_too);
230
+	}
231
+
232
+
233
+
234
+	/**
235
+	 * @deprecated 4.9.53
236
+	 * @return string
237
+	 * @throws InvalidArgumentException
238
+	 * @throws InvalidDataTypeException
239
+	 * @throws InvalidInterfaceException
240
+	 */
241
+	public function ip_address()
242
+	{
243
+		return $this->request()->ipAddress();
244
+	}
245
+
246
+
247
+	/**
248
+	 * @deprecated 4.9.53
249
+	 * @return bool
250
+	 * @throws InvalidArgumentException
251
+	 * @throws InvalidDataTypeException
252
+	 * @throws InvalidInterfaceException
253
+	 */
254
+	public function isAdmin()
255
+	{
256
+		return $this->request()->isAdmin();
257
+	}
258
+
259
+
260
+	/**
261
+	 * @deprecated 4.9.53
262
+	 * @return mixed
263
+	 * @throws InvalidArgumentException
264
+	 * @throws InvalidDataTypeException
265
+	 * @throws InvalidInterfaceException
266
+	 */
267
+	public function isAjax()
268
+	{
269
+		return $this->request()->isAjax();
270
+	}
271
+
272
+
273
+	/**
274
+	 * @deprecated 4.9.53
275
+	 * @return mixed
276
+	 * @throws InvalidArgumentException
277
+	 * @throws InvalidDataTypeException
278
+	 * @throws InvalidInterfaceException
279
+	 */
280
+	public function isFrontAjax()
281
+	{
282
+		return $this->request()->isFrontAjax();
283
+	}
284
+
285
+
286
+	/**
287
+	 * @deprecated 4.9.53
288
+	 * @return mixed|string
289
+	 * @throws InvalidArgumentException
290
+	 * @throws InvalidDataTypeException
291
+	 * @throws InvalidInterfaceException
292
+	 */
293
+	public function requestUri()
294
+	{
295
+		return $this->request()->requestUri();
296
+	}
297
+
298
+
299
+	/**
300
+	 * @deprecated 4.9.53
301
+	 * @return string
302
+	 * @throws InvalidArgumentException
303
+	 * @throws InvalidDataTypeException
304
+	 * @throws InvalidInterfaceException
305
+	 */
306
+	public function userAgent()
307
+	{
308
+		return $this->request()->userAgent();
309
+	}
310
+
311
+
312
+	/**
313
+	 * @deprecated 4.9.53
314
+	 * @param string $user_agent
315
+	 * @throws InvalidArgumentException
316
+	 * @throws InvalidDataTypeException
317
+	 * @throws InvalidInterfaceException
318
+	 */
319
+	public function setUserAgent($user_agent = '')
320
+	{
321
+		$this->request()->setUserAgent($user_agent);
322
+	}
323
+
324
+
325
+	/**
326
+	 * @deprecated 4.9.53
327
+	 * @return bool
328
+	 * @throws InvalidArgumentException
329
+	 * @throws InvalidDataTypeException
330
+	 * @throws InvalidInterfaceException
331
+	 */
332
+	public function isBot()
333
+	{
334
+		return $this->request()->isBot();
335
+	}
336
+
337
+
338
+	/**
339
+	 * @deprecated 4.9.53
340
+	 * @param bool $is_bot
341
+	 * @throws InvalidArgumentException
342
+	 * @throws InvalidDataTypeException
343
+	 * @throws InvalidInterfaceException
344
+	 */
345
+	public function setIsBot($is_bot)
346
+	{
347
+		$this->request()->setIsBot($is_bot);
348
+	}
349
+
350
+
351
+	/**
352
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
353
+	 * and return the value for the first match found
354
+	 * wildcards can be either of the following:
355
+	 *      ? to represent a single character of any type
356
+	 *      * to represent one or more characters of any type
357
+	 *
358
+	 * @param string     $pattern
359
+	 * @param null|mixed $default
360
+	 * @return false|int
361
+	 * @throws InvalidArgumentException
362
+	 * @throws InvalidInterfaceException
363
+	 * @throws InvalidDataTypeException
364
+	 */
365
+	public function getMatch($pattern, $default = null)
366
+	{
367
+		return $this->request()->getMatch($pattern, $default);
368
+	}
369
+
370
+
371
+	/**
372
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
373
+	 * wildcards can be either of the following:
374
+	 *      ? to represent a single character of any type
375
+	 *      * to represent one or more characters of any type
376
+	 * returns true if a match is found or false if not
377
+	 *
378
+	 * @param string $pattern
379
+	 * @return false|int
380
+	 * @throws InvalidArgumentException
381
+	 * @throws InvalidInterfaceException
382
+	 * @throws InvalidDataTypeException
383
+	 */
384
+	public function matches($pattern)
385
+	{
386
+		return $this->request()->matches($pattern);
387
+	}
388 388
 
389 389
 
390 390
 }
Please login to merge, or discard this patch.