Completed
Branch Gutenberg/form-system (1dc3a2)
by
unknown
50:13 queued 41:39
created
admin_pages/general_settings/OrganizationSettings.php 1 patch
Indentation   +515 added lines, -515 removed lines patch added patch discarded remove patch
@@ -44,540 +44,540 @@
 block discarded – undo
44 44
 class OrganizationSettings extends FormHandler
45 45
 {
46 46
 
47
-    /**
48
-     * @var EE_Organization_Config
49
-     */
50
-    protected $organization_config;
47
+	/**
48
+	 * @var EE_Organization_Config
49
+	 */
50
+	protected $organization_config;
51 51
 
52
-    /**
53
-     * @var EE_Core_Config
54
-     */
55
-    protected $core_config;
52
+	/**
53
+	 * @var EE_Core_Config
54
+	 */
55
+	protected $core_config;
56 56
 
57 57
 
58
-    /**
59
-     * @var EE_Network_Core_Config
60
-     */
61
-    protected $network_core_config;
58
+	/**
59
+	 * @var EE_Network_Core_Config
60
+	 */
61
+	protected $network_core_config;
62 62
 
63
-    /**
64
-     * @var CountrySubRegionDao $countrySubRegionDao
65
-     */
66
-    protected $countrySubRegionDao;
63
+	/**
64
+	 * @var CountrySubRegionDao $countrySubRegionDao
65
+	 */
66
+	protected $countrySubRegionDao;
67 67
 
68
-    /**
69
-     * Form constructor.
70
-     *
71
-     * @param EE_Registry             $registry
72
-     * @param EE_Organization_Config  $organization_config
73
-     * @param EE_Core_Config          $core_config
74
-     * @param EE_Network_Core_Config $network_core_config
75
-     * @param CountrySubRegionDao $countrySubRegionDao
76
-     * @throws InvalidArgumentException
77
-     * @throws InvalidDataTypeException
78
-     * @throws DomainException
79
-     */
80
-    public function __construct(
81
-        EE_Registry $registry,
82
-        EE_Organization_Config $organization_config,
83
-        EE_Core_Config $core_config,
84
-        EE_Network_Core_Config $network_core_config,
85
-        CountrySubRegionDao $countrySubRegionDao
86
-    ) {
87
-        $this->organization_config = $organization_config;
88
-        $this->core_config = $core_config;
89
-        $this->network_core_config = $network_core_config;
90
-        $this->countrySubRegionDao = $countrySubRegionDao;
91
-        parent::__construct(
92
-            esc_html__('Your Organization Settings', 'event_espresso'),
93
-            esc_html__('Your Organization Settings', 'event_espresso'),
94
-            'organization_settings',
95
-            '',
96
-            FormHandler::DO_NOT_SETUP_FORM,
97
-            $registry
98
-        );
99
-    }
68
+	/**
69
+	 * Form constructor.
70
+	 *
71
+	 * @param EE_Registry             $registry
72
+	 * @param EE_Organization_Config  $organization_config
73
+	 * @param EE_Core_Config          $core_config
74
+	 * @param EE_Network_Core_Config $network_core_config
75
+	 * @param CountrySubRegionDao $countrySubRegionDao
76
+	 * @throws InvalidArgumentException
77
+	 * @throws InvalidDataTypeException
78
+	 * @throws DomainException
79
+	 */
80
+	public function __construct(
81
+		EE_Registry $registry,
82
+		EE_Organization_Config $organization_config,
83
+		EE_Core_Config $core_config,
84
+		EE_Network_Core_Config $network_core_config,
85
+		CountrySubRegionDao $countrySubRegionDao
86
+	) {
87
+		$this->organization_config = $organization_config;
88
+		$this->core_config = $core_config;
89
+		$this->network_core_config = $network_core_config;
90
+		$this->countrySubRegionDao = $countrySubRegionDao;
91
+		parent::__construct(
92
+			esc_html__('Your Organization Settings', 'event_espresso'),
93
+			esc_html__('Your Organization Settings', 'event_espresso'),
94
+			'organization_settings',
95
+			'',
96
+			FormHandler::DO_NOT_SETUP_FORM,
97
+			$registry
98
+		);
99
+	}
100 100
 
101 101
 
102
-    /**
103
-     * creates and returns the actual form
104
-     *
105
-     * @return EE_Form_Section_Proper
106
-     * @throws EE_Error
107
-     * @throws InvalidArgumentException
108
-     * @throws InvalidDataTypeException
109
-     * @throws InvalidInterfaceException
110
-     * @throws ReflectionException
111
-     */
112
-    public function generate()
113
-    {
114
-        $has_sub_regions = EEM_State::instance()->count(
115
-            array(array('Country.CNT_ISO' => $this->organization_config->CNT_ISO))
116
-        );
117
-        $form = new EE_Form_Section_Proper(
118
-            array(
119
-                'name'            => 'organization_settings',
120
-                'html_id'         => 'organization_settings',
121
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
122
-                'subsections'     => array(
123
-                    'contact_information_hdr'        => new EE_Form_Section_HTML(
124
-                        EEH_HTML::h2(
125
-                            esc_html__('Contact Information', 'event_espresso')
126
-                            . ' '
127
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
128
-                            '',
129
-                            'contact-information-hdr'
130
-                        )
131
-                    ),
132
-                    'organization_name'      => new EE_Text_Input(
133
-                        array(
134
-                            'html_name' => 'organization_name',
135
-                            'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
136
-                            'html_help_text'  => esc_html__(
137
-                                'Displayed on all emails and invoices.',
138
-                                'event_espresso'
139
-                            ),
140
-                            'default'         => $this->organization_config->get_pretty('name'),
141
-                            'required'        => false,
142
-                        )
143
-                    ),
144
-                    'organization_address_1'      => new EE_Text_Input(
145
-                        array(
146
-                            'html_name' => 'organization_address_1',
147
-                            'html_label_text' => esc_html__('Street Address', 'event_espresso'),
148
-                            'default'         => $this->organization_config->get_pretty('address_1'),
149
-                            'required'        => false,
150
-                        )
151
-                    ),
152
-                    'organization_address_2'      => new EE_Text_Input(
153
-                        array(
154
-                            'html_name' => 'organization_address_2',
155
-                            'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
156
-                            'default'         => $this->organization_config->get_pretty('address_2'),
157
-                            'required'        => false,
158
-                        )
159
-                    ),
160
-                    'organization_city'      => new EE_Text_Input(
161
-                        array(
162
-                            'html_name' => 'organization_city',
163
-                            'html_label_text' => esc_html__('City', 'event_espresso'),
164
-                            'default'         => $this->organization_config->get_pretty('city'),
165
-                            'required'        => false,
166
-                        )
167
-                    ),
168
-                    'organization_country'      => new EE_Country_Select_Input(
169
-                        null,
170
-                        array(
171
-                            EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL,
172
-                            'html_name'       => 'organization_country',
173
-                            'html_label_text' => esc_html__('Country', 'event_espresso'),
174
-                            'default'         => $this->organization_config->CNT_ISO,
175
-                            'required'        => false,
176
-                            'html_help_text'  => sprintf(
177
-                                esc_html__(
178
-                                    '%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s',
179
-                                    'event_espresso'
180
-                                ),
181
-                                '<span class="reminder-spn">',
182
-                                '</span>'
183
-                            ),
184
-                        )
185
-                    ),
186
-                    'organization_state' => new EE_State_Select_Input(
187
-                        null,
188
-                        array(
189
-                            'html_name'       => 'organization_state',
190
-                            'html_label_text' => esc_html__('State/Province', 'event_espresso'),
191
-                            'default'         => $this->organization_config->STA_ID,
192
-                            'required'        => false,
193
-                            'html_help_text' => empty($this->organization_config->STA_ID) || ! $has_sub_regions
194
-                                ? sprintf(
195
-                                    esc_html__(
196
-                                        'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s',
197
-                                        'event_espresso'
198
-                                    ),
199
-                                    '<span class="reminder-spn">',
200
-                                    '</span>',
201
-                                    '<br />'
202
-                                )
203
-                                : '',
204
-                        )
205
-                    ),
206
-                    'organization_zip'      => new EE_Text_Input(
207
-                        array(
208
-                            'html_name' => 'organization_zip',
209
-                            'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
210
-                            'default'         => $this->organization_config->get_pretty('zip'),
211
-                            'required'        => false,
212
-                        )
213
-                    ),
214
-                    'organization_email'      => new EE_Text_Input(
215
-                        array(
216
-                            'html_name' => 'organization_email',
217
-                            'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
218
-                            'html_help_text'  => sprintf(
219
-                                esc_html__(
220
-                                    'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
221
-                                    'event_espresso'
222
-                                ),
223
-                                '<code>[CO_FORMATTED_EMAIL]</code>',
224
-                                '<code>[CO_EMAIL]</code>'
225
-                            ),
226
-                            'default'         => $this->organization_config->get_pretty('email'),
227
-                            'required'        => false,
228
-                        )
229
-                    ),
230
-                    'organization_phone'      => new EE_Text_Input(
231
-                        array(
232
-                            'html_name' => 'organization_phone',
233
-                            'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
234
-                            'html_help_text'  => esc_html__(
235
-                                'The phone number for your organization.',
236
-                                'event_espresso'
237
-                            ),
238
-                            'default'         => $this->organization_config->get_pretty('phone'),
239
-                            'required'        => false,
240
-                        )
241
-                    ),
242
-                    'organization_vat'      => new EE_Text_Input(
243
-                        array(
244
-                            'html_name' => 'organization_vat',
245
-                            'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
246
-                            'html_help_text'  => esc_html__(
247
-                                'The VAT/Tax Number may be displayed on invoices and receipts.',
248
-                                'event_espresso'
249
-                            ),
250
-                            'default'         => $this->organization_config->get_pretty('vat'),
251
-                            'required'        => false,
252
-                        )
253
-                    ),
254
-                    'company_logo_hdr'        => new EE_Form_Section_HTML(
255
-                        EEH_HTML::h2(
256
-                            esc_html__('Company Logo', 'event_espresso')
257
-                            . ' '
258
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
259
-                            '',
260
-                            'company-logo-hdr'
261
-                        )
262
-                    ),
263
-                    'organization_logo_url'      => new EE_Admin_File_Uploader_Input(
264
-                        array(
265
-                            'html_name' => 'organization_logo_url',
266
-                            'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
267
-                            'html_help_text'  => esc_html__(
268
-                                'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
269
-                                'event_espresso'
270
-                            ),
271
-                            'default'         => $this->organization_config->get_pretty('logo_url'),
272
-                            'required'        => false,
273
-                        )
274
-                    ),
275
-                    'social_links_hdr'        => new EE_Form_Section_HTML(
276
-                        EEH_HTML::h2(
277
-                            esc_html__('Social Links', 'event_espresso')
278
-                            . ' '
279
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
280
-                            . EEH_HTML::br()
281
-                            . EEH_HTML::p(
282
-                                esc_html__(
283
-                                    'Enter any links to social accounts for your organization here',
284
-                                    'event_espresso'
285
-                                ),
286
-                                '',
287
-                                'description'
288
-                            ),
289
-                            '',
290
-                            'social-links-hdr'
291
-                        )
292
-                    ),
293
-                    'organization_facebook'      => new EE_Text_Input(
294
-                        array(
295
-                            'html_name' => 'organization_facebook',
296
-                            'html_label_text' => esc_html__('Facebook', 'event_espresso'),
297
-                            'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
298
-                            'default'         => $this->organization_config->get_pretty('facebook'),
299
-                            'required'        => false,
300
-                        )
301
-                    ),
302
-                    'organization_twitter'      => new EE_Text_Input(
303
-                        array(
304
-                            'html_name' => 'organization_twitter',
305
-                            'html_label_text' => esc_html__('Twitter', 'event_espresso'),
306
-                            'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
307
-                            'default'         => $this->organization_config->get_pretty('twitter'),
308
-                            'required'        => false,
309
-                        )
310
-                    ),
311
-                    'organization_linkedin'      => new EE_Text_Input(
312
-                        array(
313
-                            'html_name' => 'organization_linkedin',
314
-                            'html_label_text' => esc_html__('LinkedIn', 'event_espresso'),
315
-                            'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
316
-                            'default'         => $this->organization_config->get_pretty('linkedin'),
317
-                            'required'        => false,
318
-                        )
319
-                    ),
320
-                    'organization_pinterest'      => new EE_Text_Input(
321
-                        array(
322
-                            'html_name' => 'organization_pinterest',
323
-                            'html_label_text' => esc_html__('Pinterest', 'event_espresso'),
324
-                            'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
325
-                            'default'         => $this->organization_config->get_pretty('pinterest'),
326
-                            'required'        => false,
327
-                        )
328
-                    ),
329
-                    'organization_google'      => new EE_Text_Input(
330
-                        array(
331
-                            'html_name' => 'organization_google',
332
-                            'html_label_text' => esc_html__('Google+', 'event_espresso'),
333
-                            'other_html_attributes' => ' placeholder="google.com/+profilename"',
334
-                            'default'         => $this->organization_config->get_pretty('google'),
335
-                            'required'        => false,
336
-                        )
337
-                    ),
338
-                    'organization_instagram'      => new EE_Text_Input(
339
-                        array(
340
-                            'html_name' => 'organization_instagram',
341
-                            'html_label_text' => esc_html__('Instagram', 'event_espresso'),
342
-                            'other_html_attributes' => ' placeholder="instagram.com/handle"',
343
-                            'default'         => $this->organization_config->get_pretty('instagram'),
344
-                            'required'        => false,
345
-                        )
346
-                    ),
347
-                ),
348
-            )
349
-        );
350
-        if (is_main_site()) {
351
-            $form->add_subsections(
352
-                array(
353
-                    'site_license_key_hdr' => new EE_Form_Section_HTML(
354
-                        EEH_HTML::h2(
355
-                            esc_html__('Your Event Espresso License Key', 'event_espresso')
356
-                            . ' '
357
-                            . EEH_HTML::span(
358
-                                EEH_Template::get_help_tab_link('site_license_key_info'),
359
-                                'help_tour_activation'
360
-                            ),
361
-                            '',
362
-                            'site-license-key-hdr'
363
-                        )
364
-                    ),
365
-                    'site_license_key' => $this->getSiteLicenseKeyField()
366
-                )
367
-            );
368
-            $form->add_subsections(
369
-                array(
370
-                    'uxip_optin_hdr' => new EE_Form_Section_HTML(
371
-                        $this->uxipOptinText()
372
-                    ),
373
-                    'ueip_optin' => new EE_Checkbox_Multi_Input(
374
-                        array(
375
-                            true => __('Yes! I want to help improve Event Espresso!', 'event_espresso')
376
-                        ),
377
-                        array(
378
-                            'html_name' => EE_Core_Config::OPTION_NAME_UXIP,
379
-                            'html_label_text' => esc_html__(
380
-                                'UXIP Opt In?',
381
-                                'event_espresso'
382
-                            ),
383
-                            'default'         => isset($this->core_config->ee_ueip_optin)
384
-                                ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
385
-                                : false,
386
-                            'required'        => false,
387
-                        )
388
-                    ),
389
-                ),
390
-                'organization_instagram',
391
-                false
392
-            );
393
-        }
394
-        return $form;
395
-    }
102
+	/**
103
+	 * creates and returns the actual form
104
+	 *
105
+	 * @return EE_Form_Section_Proper
106
+	 * @throws EE_Error
107
+	 * @throws InvalidArgumentException
108
+	 * @throws InvalidDataTypeException
109
+	 * @throws InvalidInterfaceException
110
+	 * @throws ReflectionException
111
+	 */
112
+	public function generate()
113
+	{
114
+		$has_sub_regions = EEM_State::instance()->count(
115
+			array(array('Country.CNT_ISO' => $this->organization_config->CNT_ISO))
116
+		);
117
+		$form = new EE_Form_Section_Proper(
118
+			array(
119
+				'name'            => 'organization_settings',
120
+				'html_id'         => 'organization_settings',
121
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
122
+				'subsections'     => array(
123
+					'contact_information_hdr'        => new EE_Form_Section_HTML(
124
+						EEH_HTML::h2(
125
+							esc_html__('Contact Information', 'event_espresso')
126
+							. ' '
127
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
128
+							'',
129
+							'contact-information-hdr'
130
+						)
131
+					),
132
+					'organization_name'      => new EE_Text_Input(
133
+						array(
134
+							'html_name' => 'organization_name',
135
+							'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
136
+							'html_help_text'  => esc_html__(
137
+								'Displayed on all emails and invoices.',
138
+								'event_espresso'
139
+							),
140
+							'default'         => $this->organization_config->get_pretty('name'),
141
+							'required'        => false,
142
+						)
143
+					),
144
+					'organization_address_1'      => new EE_Text_Input(
145
+						array(
146
+							'html_name' => 'organization_address_1',
147
+							'html_label_text' => esc_html__('Street Address', 'event_espresso'),
148
+							'default'         => $this->organization_config->get_pretty('address_1'),
149
+							'required'        => false,
150
+						)
151
+					),
152
+					'organization_address_2'      => new EE_Text_Input(
153
+						array(
154
+							'html_name' => 'organization_address_2',
155
+							'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
156
+							'default'         => $this->organization_config->get_pretty('address_2'),
157
+							'required'        => false,
158
+						)
159
+					),
160
+					'organization_city'      => new EE_Text_Input(
161
+						array(
162
+							'html_name' => 'organization_city',
163
+							'html_label_text' => esc_html__('City', 'event_espresso'),
164
+							'default'         => $this->organization_config->get_pretty('city'),
165
+							'required'        => false,
166
+						)
167
+					),
168
+					'organization_country'      => new EE_Country_Select_Input(
169
+						null,
170
+						array(
171
+							EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL,
172
+							'html_name'       => 'organization_country',
173
+							'html_label_text' => esc_html__('Country', 'event_espresso'),
174
+							'default'         => $this->organization_config->CNT_ISO,
175
+							'required'        => false,
176
+							'html_help_text'  => sprintf(
177
+								esc_html__(
178
+									'%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s',
179
+									'event_espresso'
180
+								),
181
+								'<span class="reminder-spn">',
182
+								'</span>'
183
+							),
184
+						)
185
+					),
186
+					'organization_state' => new EE_State_Select_Input(
187
+						null,
188
+						array(
189
+							'html_name'       => 'organization_state',
190
+							'html_label_text' => esc_html__('State/Province', 'event_espresso'),
191
+							'default'         => $this->organization_config->STA_ID,
192
+							'required'        => false,
193
+							'html_help_text' => empty($this->organization_config->STA_ID) || ! $has_sub_regions
194
+								? sprintf(
195
+									esc_html__(
196
+										'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s',
197
+										'event_espresso'
198
+									),
199
+									'<span class="reminder-spn">',
200
+									'</span>',
201
+									'<br />'
202
+								)
203
+								: '',
204
+						)
205
+					),
206
+					'organization_zip'      => new EE_Text_Input(
207
+						array(
208
+							'html_name' => 'organization_zip',
209
+							'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
210
+							'default'         => $this->organization_config->get_pretty('zip'),
211
+							'required'        => false,
212
+						)
213
+					),
214
+					'organization_email'      => new EE_Text_Input(
215
+						array(
216
+							'html_name' => 'organization_email',
217
+							'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
218
+							'html_help_text'  => sprintf(
219
+								esc_html__(
220
+									'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
221
+									'event_espresso'
222
+								),
223
+								'<code>[CO_FORMATTED_EMAIL]</code>',
224
+								'<code>[CO_EMAIL]</code>'
225
+							),
226
+							'default'         => $this->organization_config->get_pretty('email'),
227
+							'required'        => false,
228
+						)
229
+					),
230
+					'organization_phone'      => new EE_Text_Input(
231
+						array(
232
+							'html_name' => 'organization_phone',
233
+							'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
234
+							'html_help_text'  => esc_html__(
235
+								'The phone number for your organization.',
236
+								'event_espresso'
237
+							),
238
+							'default'         => $this->organization_config->get_pretty('phone'),
239
+							'required'        => false,
240
+						)
241
+					),
242
+					'organization_vat'      => new EE_Text_Input(
243
+						array(
244
+							'html_name' => 'organization_vat',
245
+							'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
246
+							'html_help_text'  => esc_html__(
247
+								'The VAT/Tax Number may be displayed on invoices and receipts.',
248
+								'event_espresso'
249
+							),
250
+							'default'         => $this->organization_config->get_pretty('vat'),
251
+							'required'        => false,
252
+						)
253
+					),
254
+					'company_logo_hdr'        => new EE_Form_Section_HTML(
255
+						EEH_HTML::h2(
256
+							esc_html__('Company Logo', 'event_espresso')
257
+							. ' '
258
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
259
+							'',
260
+							'company-logo-hdr'
261
+						)
262
+					),
263
+					'organization_logo_url'      => new EE_Admin_File_Uploader_Input(
264
+						array(
265
+							'html_name' => 'organization_logo_url',
266
+							'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
267
+							'html_help_text'  => esc_html__(
268
+								'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
269
+								'event_espresso'
270
+							),
271
+							'default'         => $this->organization_config->get_pretty('logo_url'),
272
+							'required'        => false,
273
+						)
274
+					),
275
+					'social_links_hdr'        => new EE_Form_Section_HTML(
276
+						EEH_HTML::h2(
277
+							esc_html__('Social Links', 'event_espresso')
278
+							. ' '
279
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
280
+							. EEH_HTML::br()
281
+							. EEH_HTML::p(
282
+								esc_html__(
283
+									'Enter any links to social accounts for your organization here',
284
+									'event_espresso'
285
+								),
286
+								'',
287
+								'description'
288
+							),
289
+							'',
290
+							'social-links-hdr'
291
+						)
292
+					),
293
+					'organization_facebook'      => new EE_Text_Input(
294
+						array(
295
+							'html_name' => 'organization_facebook',
296
+							'html_label_text' => esc_html__('Facebook', 'event_espresso'),
297
+							'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
298
+							'default'         => $this->organization_config->get_pretty('facebook'),
299
+							'required'        => false,
300
+						)
301
+					),
302
+					'organization_twitter'      => new EE_Text_Input(
303
+						array(
304
+							'html_name' => 'organization_twitter',
305
+							'html_label_text' => esc_html__('Twitter', 'event_espresso'),
306
+							'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
307
+							'default'         => $this->organization_config->get_pretty('twitter'),
308
+							'required'        => false,
309
+						)
310
+					),
311
+					'organization_linkedin'      => new EE_Text_Input(
312
+						array(
313
+							'html_name' => 'organization_linkedin',
314
+							'html_label_text' => esc_html__('LinkedIn', 'event_espresso'),
315
+							'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
316
+							'default'         => $this->organization_config->get_pretty('linkedin'),
317
+							'required'        => false,
318
+						)
319
+					),
320
+					'organization_pinterest'      => new EE_Text_Input(
321
+						array(
322
+							'html_name' => 'organization_pinterest',
323
+							'html_label_text' => esc_html__('Pinterest', 'event_espresso'),
324
+							'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
325
+							'default'         => $this->organization_config->get_pretty('pinterest'),
326
+							'required'        => false,
327
+						)
328
+					),
329
+					'organization_google'      => new EE_Text_Input(
330
+						array(
331
+							'html_name' => 'organization_google',
332
+							'html_label_text' => esc_html__('Google+', 'event_espresso'),
333
+							'other_html_attributes' => ' placeholder="google.com/+profilename"',
334
+							'default'         => $this->organization_config->get_pretty('google'),
335
+							'required'        => false,
336
+						)
337
+					),
338
+					'organization_instagram'      => new EE_Text_Input(
339
+						array(
340
+							'html_name' => 'organization_instagram',
341
+							'html_label_text' => esc_html__('Instagram', 'event_espresso'),
342
+							'other_html_attributes' => ' placeholder="instagram.com/handle"',
343
+							'default'         => $this->organization_config->get_pretty('instagram'),
344
+							'required'        => false,
345
+						)
346
+					),
347
+				),
348
+			)
349
+		);
350
+		if (is_main_site()) {
351
+			$form->add_subsections(
352
+				array(
353
+					'site_license_key_hdr' => new EE_Form_Section_HTML(
354
+						EEH_HTML::h2(
355
+							esc_html__('Your Event Espresso License Key', 'event_espresso')
356
+							. ' '
357
+							. EEH_HTML::span(
358
+								EEH_Template::get_help_tab_link('site_license_key_info'),
359
+								'help_tour_activation'
360
+							),
361
+							'',
362
+							'site-license-key-hdr'
363
+						)
364
+					),
365
+					'site_license_key' => $this->getSiteLicenseKeyField()
366
+				)
367
+			);
368
+			$form->add_subsections(
369
+				array(
370
+					'uxip_optin_hdr' => new EE_Form_Section_HTML(
371
+						$this->uxipOptinText()
372
+					),
373
+					'ueip_optin' => new EE_Checkbox_Multi_Input(
374
+						array(
375
+							true => __('Yes! I want to help improve Event Espresso!', 'event_espresso')
376
+						),
377
+						array(
378
+							'html_name' => EE_Core_Config::OPTION_NAME_UXIP,
379
+							'html_label_text' => esc_html__(
380
+								'UXIP Opt In?',
381
+								'event_espresso'
382
+							),
383
+							'default'         => isset($this->core_config->ee_ueip_optin)
384
+								? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
385
+								: false,
386
+							'required'        => false,
387
+						)
388
+					),
389
+				),
390
+				'organization_instagram',
391
+				false
392
+			);
393
+		}
394
+		return $form;
395
+	}
396 396
 
397 397
 
398
-    /**
399
-     * takes the generated form and displays it along with ony other non-form HTML that may be required
400
-     * returns a string of HTML that can be directly echoed in a template
401
-     *
402
-     * @return string
403
-     * @throws EE_Error
404
-     * @throws InvalidArgumentException
405
-     * @throws InvalidDataTypeException
406
-     * @throws InvalidInterfaceException
407
-     * @throws LogicException
408
-     */
409
-    public function display()
410
-    {
411
-        $this->form()->enqueue_js();
412
-        return parent::display();
413
-    }
398
+	/**
399
+	 * takes the generated form and displays it along with ony other non-form HTML that may be required
400
+	 * returns a string of HTML that can be directly echoed in a template
401
+	 *
402
+	 * @return string
403
+	 * @throws EE_Error
404
+	 * @throws InvalidArgumentException
405
+	 * @throws InvalidDataTypeException
406
+	 * @throws InvalidInterfaceException
407
+	 * @throws LogicException
408
+	 */
409
+	public function display()
410
+	{
411
+		$this->form()->enqueue_js();
412
+		return parent::display();
413
+	}
414 414
 
415 415
 
416
-    /**
417
-     * handles processing the form submission
418
-     * returns true or false depending on whether the form was processed successfully or not
419
-     *
420
-     * @param array $form_data
421
-     * @return bool
422
-     * @throws InvalidFormSubmissionException
423
-     * @throws EE_Error
424
-     * @throws LogicException
425
-     * @throws InvalidArgumentException
426
-     * @throws InvalidDataTypeException
427
-     * @throws ReflectionException
428
-     */
429
-    public function process($form_data = array())
430
-    {
431
-        // process form
432
-        $valid_data = (array) parent::process($form_data);
433
-        if (empty($valid_data)) {
434
-            return false;
435
-        }
416
+	/**
417
+	 * handles processing the form submission
418
+	 * returns true or false depending on whether the form was processed successfully or not
419
+	 *
420
+	 * @param array $form_data
421
+	 * @return bool
422
+	 * @throws InvalidFormSubmissionException
423
+	 * @throws EE_Error
424
+	 * @throws LogicException
425
+	 * @throws InvalidArgumentException
426
+	 * @throws InvalidDataTypeException
427
+	 * @throws ReflectionException
428
+	 */
429
+	public function process($form_data = array())
430
+	{
431
+		// process form
432
+		$valid_data = (array) parent::process($form_data);
433
+		if (empty($valid_data)) {
434
+			return false;
435
+		}
436 436
 
437
-        if (is_main_site()) {
438
-            $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])
439
-                ? sanitize_text_field($form_data['ee_site_license_key'])
440
-                : $this->network_core_config->site_license_key;
441
-        }
442
-        $this->organization_config->name = isset($form_data['organization_name'])
443
-            ? sanitize_text_field($form_data['organization_name'])
444
-            : $this->organization_config->name;
445
-        $this->organization_config->address_1 = isset($form_data['organization_address_1'])
446
-            ? sanitize_text_field($form_data['organization_address_1'])
447
-            : $this->organization_config->address_1;
448
-        $this->organization_config->address_2 = isset($form_data['organization_address_2'])
449
-            ? sanitize_text_field($form_data['organization_address_2'])
450
-            : $this->organization_config->address_2;
451
-        $this->organization_config->city = isset($form_data['organization_city'])
452
-            ? sanitize_text_field($form_data['organization_city'])
453
-            : $this->organization_config->city;
454
-        $this->organization_config->STA_ID = isset($form_data['organization_state'])
455
-            ? absint($form_data['organization_state'])
456
-            : $this->organization_config->STA_ID;
457
-        $this->organization_config->CNT_ISO = isset($form_data['organization_country'])
458
-            ? sanitize_text_field($form_data['organization_country'])
459
-            : $this->organization_config->CNT_ISO;
460
-        $this->organization_config->zip = isset($form_data['organization_zip'])
461
-            ? sanitize_text_field($form_data['organization_zip'])
462
-            : $this->organization_config->zip;
463
-        $this->organization_config->email = isset($form_data['organization_email'])
464
-            ? sanitize_email($form_data['organization_email'])
465
-            : $this->organization_config->email;
466
-        $this->organization_config->vat = isset($form_data['organization_vat'])
467
-            ? sanitize_text_field($form_data['organization_vat'])
468
-            : $this->organization_config->vat;
469
-        $this->organization_config->phone = isset($form_data['organization_phone'])
470
-            ? sanitize_text_field($form_data['organization_phone'])
471
-            : $this->organization_config->phone;
472
-        $this->organization_config->logo_url = isset($form_data['organization_logo_url'])
473
-            ? esc_url_raw($form_data['organization_logo_url'])
474
-            : $this->organization_config->logo_url;
475
-        $this->organization_config->facebook = isset($form_data['organization_facebook'])
476
-            ? esc_url_raw($form_data['organization_facebook'])
477
-            : $this->organization_config->facebook;
478
-        $this->organization_config->twitter = isset($form_data['organization_twitter'])
479
-            ? esc_url_raw($form_data['organization_twitter'])
480
-            : $this->organization_config->twitter;
481
-        $this->organization_config->linkedin = isset($form_data['organization_linkedin'])
482
-            ? esc_url_raw($form_data['organization_linkedin'])
483
-            : $this->organization_config->linkedin;
484
-        $this->organization_config->pinterest = isset($form_data['organization_pinterest'])
485
-            ? esc_url_raw($form_data['organization_pinterest'])
486
-            : $this->organization_config->pinterest;
487
-        $this->organization_config->google = isset($form_data['organization_google'])
488
-            ? esc_url_raw($form_data['organization_google'])
489
-            : $this->organization_config->google;
490
-        $this->organization_config->instagram = isset($form_data['organization_instagram'])
491
-            ? esc_url_raw($form_data['organization_instagram'])
492
-            : $this->organization_config->instagram;
493
-        $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
494
-            ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
495
-            : false;
496
-        $this->core_config->ee_ueip_has_notified = true;
437
+		if (is_main_site()) {
438
+			$this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])
439
+				? sanitize_text_field($form_data['ee_site_license_key'])
440
+				: $this->network_core_config->site_license_key;
441
+		}
442
+		$this->organization_config->name = isset($form_data['organization_name'])
443
+			? sanitize_text_field($form_data['organization_name'])
444
+			: $this->organization_config->name;
445
+		$this->organization_config->address_1 = isset($form_data['organization_address_1'])
446
+			? sanitize_text_field($form_data['organization_address_1'])
447
+			: $this->organization_config->address_1;
448
+		$this->organization_config->address_2 = isset($form_data['organization_address_2'])
449
+			? sanitize_text_field($form_data['organization_address_2'])
450
+			: $this->organization_config->address_2;
451
+		$this->organization_config->city = isset($form_data['organization_city'])
452
+			? sanitize_text_field($form_data['organization_city'])
453
+			: $this->organization_config->city;
454
+		$this->organization_config->STA_ID = isset($form_data['organization_state'])
455
+			? absint($form_data['organization_state'])
456
+			: $this->organization_config->STA_ID;
457
+		$this->organization_config->CNT_ISO = isset($form_data['organization_country'])
458
+			? sanitize_text_field($form_data['organization_country'])
459
+			: $this->organization_config->CNT_ISO;
460
+		$this->organization_config->zip = isset($form_data['organization_zip'])
461
+			? sanitize_text_field($form_data['organization_zip'])
462
+			: $this->organization_config->zip;
463
+		$this->organization_config->email = isset($form_data['organization_email'])
464
+			? sanitize_email($form_data['organization_email'])
465
+			: $this->organization_config->email;
466
+		$this->organization_config->vat = isset($form_data['organization_vat'])
467
+			? sanitize_text_field($form_data['organization_vat'])
468
+			: $this->organization_config->vat;
469
+		$this->organization_config->phone = isset($form_data['organization_phone'])
470
+			? sanitize_text_field($form_data['organization_phone'])
471
+			: $this->organization_config->phone;
472
+		$this->organization_config->logo_url = isset($form_data['organization_logo_url'])
473
+			? esc_url_raw($form_data['organization_logo_url'])
474
+			: $this->organization_config->logo_url;
475
+		$this->organization_config->facebook = isset($form_data['organization_facebook'])
476
+			? esc_url_raw($form_data['organization_facebook'])
477
+			: $this->organization_config->facebook;
478
+		$this->organization_config->twitter = isset($form_data['organization_twitter'])
479
+			? esc_url_raw($form_data['organization_twitter'])
480
+			: $this->organization_config->twitter;
481
+		$this->organization_config->linkedin = isset($form_data['organization_linkedin'])
482
+			? esc_url_raw($form_data['organization_linkedin'])
483
+			: $this->organization_config->linkedin;
484
+		$this->organization_config->pinterest = isset($form_data['organization_pinterest'])
485
+			? esc_url_raw($form_data['organization_pinterest'])
486
+			: $this->organization_config->pinterest;
487
+		$this->organization_config->google = isset($form_data['organization_google'])
488
+			? esc_url_raw($form_data['organization_google'])
489
+			: $this->organization_config->google;
490
+		$this->organization_config->instagram = isset($form_data['organization_instagram'])
491
+			? esc_url_raw($form_data['organization_instagram'])
492
+			: $this->organization_config->instagram;
493
+		$this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
494
+			? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
495
+			: false;
496
+		$this->core_config->ee_ueip_has_notified = true;
497 497
 
498
-        $this->registry->CFG->currency = new EE_Currency_Config(
499
-            $this->organization_config->CNT_ISO
500
-        );
501
-        /** @var EE_Country $country */
502
-        $country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO);
503
-        if ($country instanceof EE_Country) {
504
-            $country->set('CNT_active', 1);
505
-            $country->save();
506
-            $this->countrySubRegionDao->saveCountrySubRegions($country);
507
-        }
508
-        return true;
509
-    }
498
+		$this->registry->CFG->currency = new EE_Currency_Config(
499
+			$this->organization_config->CNT_ISO
500
+		);
501
+		/** @var EE_Country $country */
502
+		$country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO);
503
+		if ($country instanceof EE_Country) {
504
+			$country->set('CNT_active', 1);
505
+			$country->save();
506
+			$this->countrySubRegionDao->saveCountrySubRegions($country);
507
+		}
508
+		return true;
509
+	}
510 510
 
511 511
 
512
-    /**
513
-     * @return string
514
-     */
515
-    private function uxipOptinText()
516
-    {
517
-        ob_start();
518
-        Stats::optinText(false);
519
-        return ob_get_clean();
520
-    }
512
+	/**
513
+	 * @return string
514
+	 */
515
+	private function uxipOptinText()
516
+	{
517
+		ob_start();
518
+		Stats::optinText(false);
519
+		return ob_get_clean();
520
+	}
521 521
 
522 522
 
523
-    /**
524
-     * Return whether the site license key has been verified or not.
525
-     * @return bool
526
-     */
527
-    private function licenseKeyVerified()
528
-    {
529
-        if (empty($this->network_core_config->site_license_key)) {
530
-            return false;
531
-        }
532
-        $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
533
-        $verify_fail = get_option($ver_option_key, false);
534
-        return $verify_fail === false
535
-                  || (! empty($this->network_core_config->site_license_key)
536
-                        && $verify_fail === false
537
-                  );
538
-    }
523
+	/**
524
+	 * Return whether the site license key has been verified or not.
525
+	 * @return bool
526
+	 */
527
+	private function licenseKeyVerified()
528
+	{
529
+		if (empty($this->network_core_config->site_license_key)) {
530
+			return false;
531
+		}
532
+		$ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
533
+		$verify_fail = get_option($ver_option_key, false);
534
+		return $verify_fail === false
535
+				  || (! empty($this->network_core_config->site_license_key)
536
+						&& $verify_fail === false
537
+				  );
538
+	}
539 539
 
540 540
 
541
-    /**
542
-     * @return EE_Text_Input
543
-     */
544
-    private function getSiteLicenseKeyField()
545
-    {
546
-        $text_input = new EE_Text_Input(
547
-            array(
548
-                'html_name' => 'ee_site_license_key',
549
-                'html_id' => 'site_license_key',
550
-                'html_label_text' => esc_html__('Support License Key', 'event_espresso'),
551
-                /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
552
-                'html_help_text'  => sprintf(
553
-                    esc_html__(
554
-                        'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
555
-                        'event_espresso'
556
-                    ),
557
-                    '<strong>',
558
-                    '</strong>'
559
-                ),
560
-                /** phpcs:enable */
561
-                'default'         => isset($this->network_core_config->site_license_key)
562
-                    ? $this->network_core_config->site_license_key
563
-                    : '',
564
-                'required'        => false,
565
-                'form_html_filter' => new VsprintfFilter(
566
-                    '%2$s %1$s',
567
-                    array($this->getValidationIndicator())
568
-                )
569
-            )
570
-        );
571
-        return $text_input;
572
-    }
541
+	/**
542
+	 * @return EE_Text_Input
543
+	 */
544
+	private function getSiteLicenseKeyField()
545
+	{
546
+		$text_input = new EE_Text_Input(
547
+			array(
548
+				'html_name' => 'ee_site_license_key',
549
+				'html_id' => 'site_license_key',
550
+				'html_label_text' => esc_html__('Support License Key', 'event_espresso'),
551
+				/** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
552
+				'html_help_text'  => sprintf(
553
+					esc_html__(
554
+						'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
555
+						'event_espresso'
556
+					),
557
+					'<strong>',
558
+					'</strong>'
559
+				),
560
+				/** phpcs:enable */
561
+				'default'         => isset($this->network_core_config->site_license_key)
562
+					? $this->network_core_config->site_license_key
563
+					: '',
564
+				'required'        => false,
565
+				'form_html_filter' => new VsprintfFilter(
566
+					'%2$s %1$s',
567
+					array($this->getValidationIndicator())
568
+				)
569
+			)
570
+		);
571
+		return $text_input;
572
+	}
573 573
 
574 574
 
575
-    /**
576
-     * @return string
577
-     */
578
-    private function getValidationIndicator()
579
-    {
580
-        $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
581
-        return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
582
-    }
575
+	/**
576
+	 * @return string
577
+	 */
578
+	private function getValidationIndicator()
579
+	{
580
+		$verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
581
+		return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
582
+	}
583 583
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 1 patch
Indentation   +4019 added lines, -4019 removed lines patch added patch discarded remove patch
@@ -17,4086 +17,4086 @@
 block discarded – undo
17 17
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var LoaderInterface $loader
22
-     */
23
-    protected $loader;
20
+	/**
21
+	 * @var LoaderInterface $loader
22
+	 */
23
+	protected $loader;
24 24
 
25
-    // set in _init_page_props()
26
-    public $page_slug;
25
+	// set in _init_page_props()
26
+	public $page_slug;
27 27
 
28
-    public $page_label;
28
+	public $page_label;
29 29
 
30
-    public $page_folder;
30
+	public $page_folder;
31 31
 
32
-    // set in define_page_props()
33
-    protected $_admin_base_url;
32
+	// set in define_page_props()
33
+	protected $_admin_base_url;
34 34
 
35
-    protected $_admin_base_path;
35
+	protected $_admin_base_path;
36 36
 
37
-    protected $_admin_page_title;
37
+	protected $_admin_page_title;
38 38
 
39
-    protected $_labels;
39
+	protected $_labels;
40 40
 
41 41
 
42
-    // set early within EE_Admin_Init
43
-    protected $_wp_page_slug;
42
+	// set early within EE_Admin_Init
43
+	protected $_wp_page_slug;
44 44
 
45
-    // navtabs
46
-    protected $_nav_tabs;
45
+	// navtabs
46
+	protected $_nav_tabs;
47 47
 
48
-    protected $_default_nav_tab_name;
48
+	protected $_default_nav_tab_name;
49 49
 
50
-    /**
51
-     * @var array $_help_tour
52
-     */
53
-    protected $_help_tour = array();
50
+	/**
51
+	 * @var array $_help_tour
52
+	 */
53
+	protected $_help_tour = array();
54 54
 
55 55
 
56
-    // template variables (used by templates)
57
-    protected $_template_path;
56
+	// template variables (used by templates)
57
+	protected $_template_path;
58 58
 
59
-    protected $_column_template_path;
59
+	protected $_column_template_path;
60 60
 
61
-    /**
62
-     * @var array $_template_args
63
-     */
64
-    protected $_template_args = array();
61
+	/**
62
+	 * @var array $_template_args
63
+	 */
64
+	protected $_template_args = array();
65 65
 
66
-    /**
67
-     * this will hold the list table object for a given view.
68
-     *
69
-     * @var EE_Admin_List_Table $_list_table_object
70
-     */
71
-    protected $_list_table_object;
66
+	/**
67
+	 * this will hold the list table object for a given view.
68
+	 *
69
+	 * @var EE_Admin_List_Table $_list_table_object
70
+	 */
71
+	protected $_list_table_object;
72 72
 
73
-    // bools
74
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
73
+	// bools
74
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
75 75
 
76
-    protected $_routing;
76
+	protected $_routing;
77 77
 
78
-    // list table args
79
-    protected $_view;
78
+	// list table args
79
+	protected $_view;
80 80
 
81
-    protected $_views;
81
+	protected $_views;
82 82
 
83 83
 
84
-    // action => method pairs used for routing incoming requests
85
-    protected $_page_routes;
84
+	// action => method pairs used for routing incoming requests
85
+	protected $_page_routes;
86 86
 
87
-    /**
88
-     * @var array $_page_config
89
-     */
90
-    protected $_page_config;
87
+	/**
88
+	 * @var array $_page_config
89
+	 */
90
+	protected $_page_config;
91 91
 
92
-    /**
93
-     * the current page route and route config
94
-     *
95
-     * @var string $_route
96
-     */
97
-    protected $_route;
92
+	/**
93
+	 * the current page route and route config
94
+	 *
95
+	 * @var string $_route
96
+	 */
97
+	protected $_route;
98 98
 
99
-    /**
100
-     * @var string $_cpt_route
101
-     */
102
-    protected $_cpt_route;
99
+	/**
100
+	 * @var string $_cpt_route
101
+	 */
102
+	protected $_cpt_route;
103 103
 
104
-    /**
105
-     * @var array $_route_config
106
-     */
107
-    protected $_route_config;
108
-
109
-    /**
110
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
111
-     * actions.
112
-     *
113
-     * @since 4.6.x
114
-     * @var array.
115
-     */
116
-    protected $_default_route_query_args;
117
-
118
-    // set via request page and action args.
119
-    protected $_current_page;
120
-
121
-    protected $_current_view;
122
-
123
-    protected $_current_page_view_url;
124
-
125
-    // sanitized request action (and nonce)
126
-
127
-    /**
128
-     * @var string $_req_action
129
-     */
130
-    protected $_req_action;
131
-
132
-    /**
133
-     * @var string $_req_nonce
134
-     */
135
-    protected $_req_nonce;
136
-
137
-    // search related
138
-    protected $_search_btn_label;
139
-
140
-    protected $_search_box_callback;
141
-
142
-    /**
143
-     * WP Current Screen object
144
-     *
145
-     * @var WP_Screen
146
-     */
147
-    protected $_current_screen;
148
-
149
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
150
-    protected $_hook_obj;
151
-
152
-    // for holding incoming request data
153
-    protected $_req_data;
154
-
155
-    // yes / no array for admin form fields
156
-    protected $_yes_no_values = array();
157
-
158
-    // some default things shared by all child classes
159
-    protected $_default_espresso_metaboxes;
160
-
161
-    /**
162
-     *    EE_Registry Object
163
-     *
164
-     * @var    EE_Registry
165
-     */
166
-    protected $EE = null;
167
-
168
-
169
-    /**
170
-     * This is just a property that flags whether the given route is a caffeinated route or not.
171
-     *
172
-     * @var boolean
173
-     */
174
-    protected $_is_caf = false;
175
-
176
-
177
-    /**
178
-     * @Constructor
179
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
180
-     * @throws EE_Error
181
-     * @throws InvalidArgumentException
182
-     * @throws ReflectionException
183
-     * @throws InvalidDataTypeException
184
-     * @throws InvalidInterfaceException
185
-     */
186
-    public function __construct($routing = true)
187
-    {
188
-        $this->loader = LoaderFactory::getLoader();
189
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
190
-            $this->_is_caf = true;
191
-        }
192
-        $this->_yes_no_values = array(
193
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
194
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
195
-        );
196
-        // set the _req_data property.
197
-        $this->_req_data = array_merge($_GET, $_POST);
198
-        // routing enabled?
199
-        $this->_routing = $routing;
200
-        // set initial page props (child method)
201
-        $this->_init_page_props();
202
-        // set global defaults
203
-        $this->_set_defaults();
204
-        // set early because incoming requests could be ajax related and we need to register those hooks.
205
-        $this->_global_ajax_hooks();
206
-        $this->_ajax_hooks();
207
-        // other_page_hooks have to be early too.
208
-        $this->_do_other_page_hooks();
209
-        // This just allows us to have extending classes do something specific
210
-        // before the parent constructor runs _page_setup().
211
-        if (method_exists($this, '_before_page_setup')) {
212
-            $this->_before_page_setup();
213
-        }
214
-        // set up page dependencies
215
-        $this->_page_setup();
216
-    }
217
-
218
-
219
-    /**
220
-     * _init_page_props
221
-     * Child classes use to set at least the following properties:
222
-     * $page_slug.
223
-     * $page_label.
224
-     *
225
-     * @abstract
226
-     * @return void
227
-     */
228
-    abstract protected function _init_page_props();
229
-
230
-
231
-    /**
232
-     * _ajax_hooks
233
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
234
-     * Note: within the ajax callback methods.
235
-     *
236
-     * @abstract
237
-     * @return void
238
-     */
239
-    abstract protected function _ajax_hooks();
240
-
241
-
242
-    /**
243
-     * _define_page_props
244
-     * child classes define page properties in here.  Must include at least:
245
-     * $_admin_base_url = base_url for all admin pages
246
-     * $_admin_page_title = default admin_page_title for admin pages
247
-     * $_labels = array of default labels for various automatically generated elements:
248
-     *    array(
249
-     *        'buttons' => array(
250
-     *            'add' => esc_html__('label for add new button'),
251
-     *            'edit' => esc_html__('label for edit button'),
252
-     *            'delete' => esc_html__('label for delete button')
253
-     *            )
254
-     *        )
255
-     *
256
-     * @abstract
257
-     * @return void
258
-     */
259
-    abstract protected function _define_page_props();
260
-
261
-
262
-    /**
263
-     * _set_page_routes
264
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
265
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
266
-     * have a 'default' route. Here's the format
267
-     * $this->_page_routes = array(
268
-     *        'default' => array(
269
-     *            'func' => '_default_method_handling_route',
270
-     *            'args' => array('array','of','args'),
271
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
272
-     *            ajax request, backend processing)
273
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
274
-     *            headers route after.  The string you enter here should match the defined route reference for a
275
-     *            headers sent route.
276
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
277
-     *            this route.
278
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
279
-     *            checks).
280
-     *        ),
281
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
282
-     *        handling method.
283
-     *        )
284
-     * )
285
-     *
286
-     * @abstract
287
-     * @return void
288
-     */
289
-    abstract protected function _set_page_routes();
290
-
291
-
292
-    /**
293
-     * _set_page_config
294
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
295
-     * array corresponds to the page_route for the loaded page. Format:
296
-     * $this->_page_config = array(
297
-     *        'default' => array(
298
-     *            'labels' => array(
299
-     *                'buttons' => array(
300
-     *                    'add' => esc_html__('label for adding item'),
301
-     *                    'edit' => esc_html__('label for editing item'),
302
-     *                    'delete' => esc_html__('label for deleting item')
303
-     *                ),
304
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
305
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
306
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
307
-     *            _define_page_props() method
308
-     *            'nav' => array(
309
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
310
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
311
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
312
-     *                'order' => 10, //required to indicate tab position.
313
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
314
-     *                displayed then add this parameter.
315
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
316
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
317
-     *            metaboxes set for eventespresso admin pages.
318
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
319
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
320
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
321
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
322
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
323
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
324
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
325
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
326
-     *            want to display.
327
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
328
-     *                'tab_id' => array(
329
-     *                    'title' => 'tab_title',
330
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
331
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
332
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
333
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
334
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
335
-     *                    attempt to use the callback which should match the name of a method in the class
336
-     *                    ),
337
-     *                'tab2_id' => array(
338
-     *                    'title' => 'tab2 title',
339
-     *                    'filename' => 'file_name_2'
340
-     *                    'callback' => 'callback_method_for_content',
341
-     *                 ),
342
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
343
-     *            help tab area on an admin page. @link
344
-     *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
345
-     *            'help_tour' => array(
346
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
347
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
348
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
349
-     *            ),
350
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
351
-     *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
352
-     *            just set
353
-     *            'require_nonce' to FALSE
354
-     *            )
355
-     * )
356
-     *
357
-     * @abstract
358
-     * @return void
359
-     */
360
-    abstract protected function _set_page_config();
361
-
362
-
363
-
364
-
365
-
366
-    /** end sample help_tour methods **/
367
-    /**
368
-     * _add_screen_options
369
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
370
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
371
-     * to a particular view.
372
-     *
373
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
374
-     *         see also WP_Screen object documents...
375
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
376
-     * @abstract
377
-     * @return void
378
-     */
379
-    abstract protected function _add_screen_options();
380
-
381
-
382
-    /**
383
-     * _add_feature_pointers
384
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
385
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
386
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
387
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
388
-     * extended) also see:
389
-     *
390
-     * @link   http://eamann.com/tech/wordpress-portland/
391
-     * @abstract
392
-     * @return void
393
-     */
394
-    abstract protected function _add_feature_pointers();
395
-
396
-
397
-    /**
398
-     * load_scripts_styles
399
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
400
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
401
-     * scripts/styles per view by putting them in a dynamic function in this format
402
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
403
-     *
404
-     * @abstract
405
-     * @return void
406
-     */
407
-    abstract public function load_scripts_styles();
408
-
409
-
410
-    /**
411
-     * admin_init
412
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
413
-     * all pages/views loaded by child class.
414
-     *
415
-     * @abstract
416
-     * @return void
417
-     */
418
-    abstract public function admin_init();
419
-
420
-
421
-    /**
422
-     * admin_notices
423
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
424
-     * all pages/views loaded by child class.
425
-     *
426
-     * @abstract
427
-     * @return void
428
-     */
429
-    abstract public function admin_notices();
430
-
431
-
432
-    /**
433
-     * admin_footer_scripts
434
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
435
-     * will apply to all pages/views loaded by child class.
436
-     *
437
-     * @return void
438
-     */
439
-    abstract public function admin_footer_scripts();
440
-
441
-
442
-    /**
443
-     * admin_footer
444
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
445
-     * apply to all pages/views loaded by child class.
446
-     *
447
-     * @return void
448
-     */
449
-    public function admin_footer()
450
-    {
451
-    }
452
-
453
-
454
-    /**
455
-     * _global_ajax_hooks
456
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
457
-     * Note: within the ajax callback methods.
458
-     *
459
-     * @abstract
460
-     * @return void
461
-     */
462
-    protected function _global_ajax_hooks()
463
-    {
464
-        // for lazy loading of metabox content
465
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
466
-    }
467
-
468
-
469
-    public function ajax_metabox_content()
470
-    {
471
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
472
-        $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
473
-        self::cached_rss_display($contentid, $url);
474
-        wp_die();
475
-    }
476
-
477
-
478
-    /**
479
-     * _page_setup
480
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
481
-     * doesn't match the object.
482
-     *
483
-     * @final
484
-     * @return void
485
-     * @throws EE_Error
486
-     * @throws InvalidArgumentException
487
-     * @throws ReflectionException
488
-     * @throws InvalidDataTypeException
489
-     * @throws InvalidInterfaceException
490
-     */
491
-    final protected function _page_setup()
492
-    {
493
-        // requires?
494
-        // admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
495
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
496
-        // next verify if we need to load anything...
497
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
498
-        $this->page_folder = strtolower(
499
-            str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
500
-        );
501
-        global $ee_menu_slugs;
502
-        $ee_menu_slugs = (array) $ee_menu_slugs;
503
-        if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
504
-            return;
505
-        }
506
-        // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
507
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
508
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
509
-                ? $this->_req_data['action2']
510
-                : $this->_req_data['action'];
511
-        }
512
-        // then set blank or -1 action values to 'default'
513
-        $this->_req_action = isset($this->_req_data['action'])
514
-                             && ! empty($this->_req_data['action'])
515
-                             && $this->_req_data['action'] !== '-1'
516
-            ? sanitize_key($this->_req_data['action'])
517
-            : 'default';
518
-        // if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
519
-        //  This covers cases where we're coming in from a list table that isn't on the default route.
520
-        $this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
521
-            ? $this->_req_data['route'] : $this->_req_action;
522
-        // however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
523
-        $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route'])
524
-            ? $this->_req_data['route']
525
-            : $this->_req_action;
526
-        $this->_current_view = $this->_req_action;
527
-        $this->_req_nonce = $this->_req_action . '_nonce';
528
-        $this->_define_page_props();
529
-        $this->_current_page_view_url = add_query_arg(
530
-            array('page' => $this->_current_page, 'action' => $this->_current_view),
531
-            $this->_admin_base_url
532
-        );
533
-        // default things
534
-        $this->_default_espresso_metaboxes = array(
535
-            '_espresso_news_post_box',
536
-            '_espresso_links_post_box',
537
-            '_espresso_ratings_request',
538
-            '_espresso_sponsors_post_box',
539
-        );
540
-        // set page configs
541
-        $this->_set_page_routes();
542
-        $this->_set_page_config();
543
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
544
-        if (isset($this->_req_data['wp_referer'])) {
545
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
546
-        }
547
-        // for caffeinated and other extended functionality.
548
-        //  If there is a _extend_page_config method
549
-        // then let's run that to modify the all the various page configuration arrays
550
-        if (method_exists($this, '_extend_page_config')) {
551
-            $this->_extend_page_config();
552
-        }
553
-        // for CPT and other extended functionality.
554
-        // If there is an _extend_page_config_for_cpt
555
-        // then let's run that to modify all the various page configuration arrays.
556
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
557
-            $this->_extend_page_config_for_cpt();
558
-        }
559
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
560
-        $this->_page_routes = apply_filters(
561
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
562
-            $this->_page_routes,
563
-            $this
564
-        );
565
-        $this->_page_config = apply_filters(
566
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
567
-            $this->_page_config,
568
-            $this
569
-        );
570
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
571
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
572
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
573
-            add_action(
574
-                'AHEE__EE_Admin_Page__route_admin_request',
575
-                array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
576
-                10,
577
-                2
578
-            );
579
-        }
580
-        // next route only if routing enabled
581
-        if ($this->_routing && ! defined('DOING_AJAX')) {
582
-            $this->_verify_routes();
583
-            // next let's just check user_access and kill if no access
584
-            $this->check_user_access();
585
-            if ($this->_is_UI_request) {
586
-                // admin_init stuff - global, all views for this page class, specific view
587
-                add_action('admin_init', array($this, 'admin_init'), 10);
588
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
589
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
590
-                }
591
-            } else {
592
-                // hijack regular WP loading and route admin request immediately
593
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
594
-                $this->route_admin_request();
595
-            }
596
-        }
597
-    }
598
-
599
-
600
-    /**
601
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
602
-     *
603
-     * @return void
604
-     * @throws ReflectionException
605
-     * @throws EE_Error
606
-     */
607
-    private function _do_other_page_hooks()
608
-    {
609
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
610
-        foreach ($registered_pages as $page) {
611
-            // now let's setup the file name and class that should be present
612
-            $classname = str_replace('.class.php', '', $page);
613
-            // autoloaders should take care of loading file
614
-            if (! class_exists($classname)) {
615
-                $error_msg[] = sprintf(
616
-                    esc_html__(
617
-                        'Something went wrong with loading the %s admin hooks page.',
618
-                        'event_espresso'
619
-                    ),
620
-                    $page
621
-                );
622
-                $error_msg[] = $error_msg[0]
623
-                               . "\r\n"
624
-                               . sprintf(
625
-                                   esc_html__(
626
-                                       'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
627
-                                       'event_espresso'
628
-                                   ),
629
-                                   $page,
630
-                                   '<br />',
631
-                                   '<strong>' . $classname . '</strong>'
632
-                               );
633
-                throw new EE_Error(implode('||', $error_msg));
634
-            }
635
-            $a = new ReflectionClass($classname);
636
-            // notice we are passing the instance of this class to the hook object.
637
-            $hookobj[] = $a->newInstance($this);
638
-        }
639
-    }
640
-
641
-
642
-    public function load_page_dependencies()
643
-    {
644
-        try {
645
-            $this->_load_page_dependencies();
646
-        } catch (EE_Error $e) {
647
-            $e->get_error();
648
-        }
649
-    }
650
-
651
-
652
-    /**
653
-     * load_page_dependencies
654
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
655
-     *
656
-     * @return void
657
-     * @throws DomainException
658
-     * @throws EE_Error
659
-     * @throws InvalidArgumentException
660
-     * @throws InvalidDataTypeException
661
-     * @throws InvalidInterfaceException
662
-     * @throws ReflectionException
663
-     */
664
-    protected function _load_page_dependencies()
665
-    {
666
-        // let's set the current_screen and screen options to override what WP set
667
-        $this->_current_screen = get_current_screen();
668
-        // load admin_notices - global, page class, and view specific
669
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
670
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
671
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
672
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
673
-        }
674
-        // load network admin_notices - global, page class, and view specific
675
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
676
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
677
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
678
-        }
679
-        // this will save any per_page screen options if they are present
680
-        $this->_set_per_page_screen_options();
681
-        // setup list table properties
682
-        $this->_set_list_table();
683
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
684
-        // However in some cases the metaboxes will need to be added within a route handling callback.
685
-        $this->_add_registered_meta_boxes();
686
-        $this->_add_screen_columns();
687
-        // add screen options - global, page child class, and view specific
688
-        $this->_add_global_screen_options();
689
-        $this->_add_screen_options();
690
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
691
-        if (method_exists($this, $add_screen_options)) {
692
-            $this->{$add_screen_options}();
693
-        }
694
-        // add help tab(s) and tours- set via page_config and qtips.
695
-        $this->_add_help_tour();
696
-        $this->_add_help_tabs();
697
-        $this->_add_qtips();
698
-        // add feature_pointers - global, page child class, and view specific
699
-        $this->_add_feature_pointers();
700
-        $this->_add_global_feature_pointers();
701
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
702
-        if (method_exists($this, $add_feature_pointer)) {
703
-            $this->{$add_feature_pointer}();
704
-        }
705
-        // enqueue scripts/styles - global, page class, and view specific
706
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
707
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
708
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
709
-            add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
710
-        }
711
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
712
-        // admin_print_footer_scripts - global, page child class, and view specific.
713
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
714
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
715
-        // is a good use case. Notice the late priority we're giving these
716
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
717
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
718
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
719
-            add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
720
-        }
721
-        // admin footer scripts
722
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
723
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
724
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
725
-            add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
726
-        }
727
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
728
-        // targeted hook
729
-        do_action(
730
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
731
-        );
732
-    }
733
-
734
-
735
-    /**
736
-     * _set_defaults
737
-     * This sets some global defaults for class properties.
738
-     */
739
-    private function _set_defaults()
740
-    {
741
-        $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
742
-        $this->_event = $this->_template_path = $this->_column_template_path = null;
743
-        $this->_nav_tabs = $this->_views = $this->_page_routes = array();
744
-        $this->_page_config = $this->_default_route_query_args = array();
745
-        $this->_default_nav_tab_name = 'overview';
746
-        // init template args
747
-        $this->_template_args = array(
748
-            'admin_page_header'  => '',
749
-            'admin_page_content' => '',
750
-            'post_body_content'  => '',
751
-            'before_list_table'  => '',
752
-            'after_list_table'   => '',
753
-        );
754
-    }
755
-
756
-
757
-    /**
758
-     * route_admin_request
759
-     *
760
-     * @see    _route_admin_request()
761
-     * @return exception|void error
762
-     * @throws InvalidArgumentException
763
-     * @throws InvalidInterfaceException
764
-     * @throws InvalidDataTypeException
765
-     * @throws EE_Error
766
-     * @throws ReflectionException
767
-     */
768
-    public function route_admin_request()
769
-    {
770
-        try {
771
-            $this->_route_admin_request();
772
-        } catch (EE_Error $e) {
773
-            $e->get_error();
774
-        }
775
-    }
776
-
777
-
778
-    public function set_wp_page_slug($wp_page_slug)
779
-    {
780
-        $this->_wp_page_slug = $wp_page_slug;
781
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
782
-        if (is_network_admin()) {
783
-            $this->_wp_page_slug .= '-network';
784
-        }
785
-    }
786
-
787
-
788
-    /**
789
-     * _verify_routes
790
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
791
-     * we know if we need to drop out.
792
-     *
793
-     * @return bool
794
-     * @throws EE_Error
795
-     */
796
-    protected function _verify_routes()
797
-    {
798
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
799
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
800
-            return false;
801
-        }
802
-        $this->_route = false;
803
-        // check that the page_routes array is not empty
804
-        if (empty($this->_page_routes)) {
805
-            // user error msg
806
-            $error_msg = sprintf(
807
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
808
-                $this->_admin_page_title
809
-            );
810
-            // developer error msg
811
-            $error_msg .= '||' . $error_msg
812
-                          . esc_html__(
813
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
814
-                              'event_espresso'
815
-                          );
816
-            throw new EE_Error($error_msg);
817
-        }
818
-        // and that the requested page route exists
819
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
820
-            $this->_route = $this->_page_routes[ $this->_req_action ];
821
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
822
-                ? $this->_page_config[ $this->_req_action ] : array();
823
-        } else {
824
-            // user error msg
825
-            $error_msg = sprintf(
826
-                esc_html__(
827
-                    'The requested page route does not exist for the %s admin page.',
828
-                    'event_espresso'
829
-                ),
830
-                $this->_admin_page_title
831
-            );
832
-            // developer error msg
833
-            $error_msg .= '||' . $error_msg
834
-                          . sprintf(
835
-                              esc_html__(
836
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
837
-                                  'event_espresso'
838
-                              ),
839
-                              $this->_req_action
840
-                          );
841
-            throw new EE_Error($error_msg);
842
-        }
843
-        // and that a default route exists
844
-        if (! array_key_exists('default', $this->_page_routes)) {
845
-            // user error msg
846
-            $error_msg = sprintf(
847
-                esc_html__(
848
-                    'A default page route has not been set for the % admin page.',
849
-                    'event_espresso'
850
-                ),
851
-                $this->_admin_page_title
852
-            );
853
-            // developer error msg
854
-            $error_msg .= '||' . $error_msg
855
-                          . esc_html__(
856
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
857
-                              'event_espresso'
858
-                          );
859
-            throw new EE_Error($error_msg);
860
-        }
861
-        // first lets' catch if the UI request has EVER been set.
862
-        if ($this->_is_UI_request === null) {
863
-            // lets set if this is a UI request or not.
864
-            $this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
865
-            // wait a minute... we might have a noheader in the route array
866
-            $this->_is_UI_request = is_array($this->_route)
867
-                                    && isset($this->_route['noheader'])
868
-                                    && $this->_route['noheader'] ? false : $this->_is_UI_request;
869
-        }
870
-        $this->_set_current_labels();
871
-        return true;
872
-    }
873
-
874
-
875
-    /**
876
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
877
-     *
878
-     * @param  string $route the route name we're verifying
879
-     * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
880
-     * @throws EE_Error
881
-     */
882
-    protected function _verify_route($route)
883
-    {
884
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
885
-            return true;
886
-        }
887
-        // user error msg
888
-        $error_msg = sprintf(
889
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
890
-            $this->_admin_page_title
891
-        );
892
-        // developer error msg
893
-        $error_msg .= '||' . $error_msg
894
-                      . sprintf(
895
-                          esc_html__(
896
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
897
-                              'event_espresso'
898
-                          ),
899
-                          $route
900
-                      );
901
-        throw new EE_Error($error_msg);
902
-    }
903
-
904
-
905
-    /**
906
-     * perform nonce verification
907
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
908
-     * using this method (and save retyping!)
909
-     *
910
-     * @param  string $nonce     The nonce sent
911
-     * @param  string $nonce_ref The nonce reference string (name0)
912
-     * @return void
913
-     * @throws EE_Error
914
-     */
915
-    protected function _verify_nonce($nonce, $nonce_ref)
916
-    {
917
-        // verify nonce against expected value
918
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
919
-            // these are not the droids you are looking for !!!
920
-            $msg = sprintf(
921
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
922
-                '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
923
-                '</a>'
924
-            );
925
-            if (WP_DEBUG) {
926
-                $msg .= "\n  "
927
-                        . sprintf(
928
-                            esc_html__(
929
-                                'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
930
-                                'event_espresso'
931
-                            ),
932
-                            __CLASS__
933
-                        );
934
-            }
935
-            if (! defined('DOING_AJAX')) {
936
-                wp_die($msg);
937
-            } else {
938
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
939
-                $this->_return_json();
940
-            }
941
-        }
942
-    }
943
-
944
-
945
-    /**
946
-     * _route_admin_request()
947
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
948
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
949
-     * in the page routes and then will try to load the corresponding method.
950
-     *
951
-     * @return void
952
-     * @throws EE_Error
953
-     * @throws InvalidArgumentException
954
-     * @throws InvalidDataTypeException
955
-     * @throws InvalidInterfaceException
956
-     * @throws ReflectionException
957
-     */
958
-    protected function _route_admin_request()
959
-    {
960
-        if (! $this->_is_UI_request) {
961
-            $this->_verify_routes();
962
-        }
963
-        $nonce_check = isset($this->_route_config['require_nonce'])
964
-            ? $this->_route_config['require_nonce']
965
-            : true;
966
-        if ($this->_req_action !== 'default' && $nonce_check) {
967
-            // set nonce from post data
968
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
969
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
970
-                : '';
971
-            $this->_verify_nonce($nonce, $this->_req_nonce);
972
-        }
973
-        // set the nav_tabs array but ONLY if this is  UI_request
974
-        if ($this->_is_UI_request) {
975
-            $this->_set_nav_tabs();
976
-        }
977
-        // grab callback function
978
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
979
-        // check if callback has args
980
-        $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
981
-        $error_msg = '';
982
-        // action right before calling route
983
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
984
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
985
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
986
-        }
987
-        // right before calling the route, let's remove _wp_http_referer from the
988
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
989
-        $_SERVER['REQUEST_URI'] = remove_query_arg(
990
-            '_wp_http_referer',
991
-            wp_unslash($_SERVER['REQUEST_URI'])
992
-        );
993
-        if (! empty($func)) {
994
-            if (is_array($func)) {
995
-                list($class, $method) = $func;
996
-            } elseif (strpos($func, '::') !== false) {
997
-                list($class, $method) = explode('::', $func);
998
-            } else {
999
-                $class = $this;
1000
-                $method = $func;
1001
-            }
1002
-            if (! (is_object($class) && $class === $this)) {
1003
-                // send along this admin page object for access by addons.
1004
-                $args['admin_page_object'] = $this;
1005
-            }
1006
-            if (// is it a method on a class that doesn't work?
1007
-                (
1008
-                    (
1009
-                        method_exists($class, $method)
1010
-                        && call_user_func_array(array($class, $method), $args) === false
1011
-                    )
1012
-                    && (
1013
-                        // is it a standalone function that doesn't work?
1014
-                        function_exists($method)
1015
-                        && call_user_func_array(
1016
-                            $func,
1017
-                            array_merge(array('admin_page_object' => $this), $args)
1018
-                        ) === false
1019
-                    )
1020
-                )
1021
-                || (
1022
-                    // is it neither a class method NOR a standalone function?
1023
-                    ! method_exists($class, $method)
1024
-                    && ! function_exists($method)
1025
-                )
1026
-            ) {
1027
-                // user error msg
1028
-                $error_msg = esc_html__(
1029
-                    'An error occurred. The  requested page route could not be found.',
1030
-                    'event_espresso'
1031
-                );
1032
-                // developer error msg
1033
-                $error_msg .= '||';
1034
-                $error_msg .= sprintf(
1035
-                    esc_html__(
1036
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1037
-                        'event_espresso'
1038
-                    ),
1039
-                    $method
1040
-                );
1041
-            }
1042
-            if (! empty($error_msg)) {
1043
-                throw new EE_Error($error_msg);
1044
-            }
1045
-        }
1046
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1047
-        // then we need to reset the routing properties to the new route.
1048
-        // now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1049
-        if ($this->_is_UI_request === false
1050
-            && is_array($this->_route)
1051
-            && ! empty($this->_route['headers_sent_route'])
1052
-        ) {
1053
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1054
-        }
1055
-    }
1056
-
1057
-
1058
-    /**
1059
-     * This method just allows the resetting of page properties in the case where a no headers
1060
-     * route redirects to a headers route in its route config.
1061
-     *
1062
-     * @since   4.3.0
1063
-     * @param  string $new_route New (non header) route to redirect to.
1064
-     * @return   void
1065
-     * @throws ReflectionException
1066
-     * @throws InvalidArgumentException
1067
-     * @throws InvalidInterfaceException
1068
-     * @throws InvalidDataTypeException
1069
-     * @throws EE_Error
1070
-     */
1071
-    protected function _reset_routing_properties($new_route)
1072
-    {
1073
-        $this->_is_UI_request = true;
1074
-        // now we set the current route to whatever the headers_sent_route is set at
1075
-        $this->_req_data['action'] = $new_route;
1076
-        // rerun page setup
1077
-        $this->_page_setup();
1078
-    }
1079
-
1080
-
1081
-    /**
1082
-     * _add_query_arg
1083
-     * adds nonce to array of arguments then calls WP add_query_arg function
1084
-     *(internally just uses EEH_URL's function with the same name)
1085
-     *
1086
-     * @param array  $args
1087
-     * @param string $url
1088
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1089
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1090
-     *                                        Example usage: If the current page is:
1091
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1092
-     *                                        &action=default&event_id=20&month_range=March%202015
1093
-     *                                        &_wpnonce=5467821
1094
-     *                                        and you call:
1095
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1096
-     *                                        array(
1097
-     *                                        'action' => 'resend_something',
1098
-     *                                        'page=>espresso_registrations'
1099
-     *                                        ),
1100
-     *                                        $some_url,
1101
-     *                                        true
1102
-     *                                        );
1103
-     *                                        It will produce a url in this structure:
1104
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1105
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1106
-     *                                        month_range]=March%202015
1107
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1108
-     * @return string
1109
-     */
1110
-    public static function add_query_args_and_nonce(
1111
-        $args = array(),
1112
-        $url = false,
1113
-        $sticky = false,
1114
-        $exclude_nonce = false
1115
-    ) {
1116
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1117
-        if ($sticky) {
1118
-            $request = $_REQUEST;
1119
-            unset($request['_wp_http_referer']);
1120
-            unset($request['wp_referer']);
1121
-            foreach ($request as $key => $value) {
1122
-                // do not add nonces
1123
-                if (strpos($key, 'nonce') !== false) {
1124
-                    continue;
1125
-                }
1126
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1127
-            }
1128
-        }
1129
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1130
-    }
1131
-
1132
-
1133
-    /**
1134
-     * This returns a generated link that will load the related help tab.
1135
-     *
1136
-     * @param  string $help_tab_id the id for the connected help tab
1137
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1138
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1139
-     * @uses EEH_Template::get_help_tab_link()
1140
-     * @return string              generated link
1141
-     */
1142
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1143
-    {
1144
-        return EEH_Template::get_help_tab_link(
1145
-            $help_tab_id,
1146
-            $this->page_slug,
1147
-            $this->_req_action,
1148
-            $icon_style,
1149
-            $help_text
1150
-        );
1151
-    }
1152
-
1153
-
1154
-    /**
1155
-     * _add_help_tabs
1156
-     * Note child classes define their help tabs within the page_config array.
1157
-     *
1158
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1159
-     * @return void
1160
-     * @throws DomainException
1161
-     * @throws EE_Error
1162
-     */
1163
-    protected function _add_help_tabs()
1164
-    {
1165
-        $tour_buttons = '';
1166
-        if (isset($this->_page_config[ $this->_req_action ])) {
1167
-            $config = $this->_page_config[ $this->_req_action ];
1168
-            // is there a help tour for the current route?  if there is let's setup the tour buttons
1169
-            if (isset($this->_help_tour[ $this->_req_action ])) {
1170
-                $tb = array();
1171
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1172
-                foreach ($this->_help_tour['tours'] as $tour) {
1173
-                    // if this is the end tour then we don't need to setup a button
1174
-                    if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1175
-                        continue;
1176
-                    }
1177
-                    $tb[] = '<button id="trigger-tour-'
1178
-                            . $tour->get_slug()
1179
-                            . '" class="button-primary trigger-ee-help-tour">'
1180
-                            . $tour->get_label()
1181
-                            . '</button>';
1182
-                }
1183
-                $tour_buttons .= implode('<br />', $tb);
1184
-                $tour_buttons .= '</div></div>';
1185
-            }
1186
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1187
-            if (is_array($config) && isset($config['help_sidebar'])) {
1188
-                // check that the callback given is valid
1189
-                if (! method_exists($this, $config['help_sidebar'])) {
1190
-                    throw new EE_Error(
1191
-                        sprintf(
1192
-                            esc_html__(
1193
-                                'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1194
-                                'event_espresso'
1195
-                            ),
1196
-                            $config['help_sidebar'],
1197
-                            get_class($this)
1198
-                        )
1199
-                    );
1200
-                }
1201
-                $content = apply_filters(
1202
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1203
-                    $this->{$config['help_sidebar']}()
1204
-                );
1205
-                $content .= $tour_buttons; // add help tour buttons.
1206
-                // do we have any help tours setup?  Cause if we do we want to add the buttons
1207
-                $this->_current_screen->set_help_sidebar($content);
1208
-            }
1209
-            // if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1210
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1211
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1212
-            }
1213
-            // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1214
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1215
-                $_ht['id'] = $this->page_slug;
1216
-                $_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1217
-                $_ht['content'] = '<p>'
1218
-                                  . esc_html__(
1219
-                                      'The buttons to the right allow you to start/restart any help tours available for this page',
1220
-                                      'event_espresso'
1221
-                                  ) . '</p>';
1222
-                $this->_current_screen->add_help_tab($_ht);
1223
-            }
1224
-            if (! isset($config['help_tabs'])) {
1225
-                return;
1226
-            } //no help tabs for this route
1227
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1228
-                // we're here so there ARE help tabs!
1229
-                // make sure we've got what we need
1230
-                if (! isset($cfg['title'])) {
1231
-                    throw new EE_Error(
1232
-                        esc_html__(
1233
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1234
-                            'event_espresso'
1235
-                        )
1236
-                    );
1237
-                }
1238
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1239
-                    throw new EE_Error(
1240
-                        esc_html__(
1241
-                            'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1242
-                            'event_espresso'
1243
-                        )
1244
-                    );
1245
-                }
1246
-                // first priority goes to content.
1247
-                if (! empty($cfg['content'])) {
1248
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1249
-                    // second priority goes to filename
1250
-                } elseif (! empty($cfg['filename'])) {
1251
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1252
-                    // it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1253
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1254
-                                                             . basename($this->_get_dir())
1255
-                                                             . '/help_tabs/'
1256
-                                                             . $cfg['filename']
1257
-                                                             . '.help_tab.php' : $file_path;
1258
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1259
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1260
-                        EE_Error::add_error(
1261
-                            sprintf(
1262
-                                esc_html__(
1263
-                                    'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1264
-                                    'event_espresso'
1265
-                                ),
1266
-                                $tab_id,
1267
-                                key($config),
1268
-                                $file_path
1269
-                            ),
1270
-                            __FILE__,
1271
-                            __FUNCTION__,
1272
-                            __LINE__
1273
-                        );
1274
-                        return;
1275
-                    }
1276
-                    $template_args['admin_page_obj'] = $this;
1277
-                    $content = EEH_Template::display_template(
1278
-                        $file_path,
1279
-                        $template_args,
1280
-                        true
1281
-                    );
1282
-                } else {
1283
-                    $content = '';
1284
-                }
1285
-                // check if callback is valid
1286
-                if (empty($content) && (
1287
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1288
-                    )
1289
-                ) {
1290
-                    EE_Error::add_error(
1291
-                        sprintf(
1292
-                            esc_html__(
1293
-                                'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1294
-                                'event_espresso'
1295
-                            ),
1296
-                            $cfg['title']
1297
-                        ),
1298
-                        __FILE__,
1299
-                        __FUNCTION__,
1300
-                        __LINE__
1301
-                    );
1302
-                    return;
1303
-                }
1304
-                // setup config array for help tab method
1305
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1306
-                $_ht = array(
1307
-                    'id'       => $id,
1308
-                    'title'    => $cfg['title'],
1309
-                    'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1310
-                    'content'  => $content,
1311
-                );
1312
-                $this->_current_screen->add_help_tab($_ht);
1313
-            }
1314
-        }
1315
-    }
1316
-
1317
-
1318
-    /**
1319
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1320
-     * an array with properties for setting up usage of the joyride plugin
1321
-     *
1322
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1323
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1324
-     *         _set_page_config() comments
1325
-     * @return void
1326
-     * @throws EE_Error
1327
-     * @throws InvalidArgumentException
1328
-     * @throws InvalidDataTypeException
1329
-     * @throws InvalidInterfaceException
1330
-     */
1331
-    protected function _add_help_tour()
1332
-    {
1333
-        $tours = array();
1334
-        $this->_help_tour = array();
1335
-        // exit early if help tours are turned off globally
1336
-        if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1337
-            || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1338
-        ) {
1339
-            return;
1340
-        }
1341
-        // loop through _page_config to find any help_tour defined
1342
-        foreach ($this->_page_config as $route => $config) {
1343
-            // we're only going to set things up for this route
1344
-            if ($route !== $this->_req_action) {
1345
-                continue;
1346
-            }
1347
-            if (isset($config['help_tour'])) {
1348
-                foreach ($config['help_tour'] as $tour) {
1349
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1350
-                    // let's see if we can get that file...
1351
-                    // if not its possible this is a decaf route not set in caffeinated
1352
-                    // so lets try and get the caffeinated equivalent
1353
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1354
-                                                             . basename($this->_get_dir())
1355
-                                                             . '/help_tours/'
1356
-                                                             . $tour
1357
-                                                             . '.class.php' : $file_path;
1358
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1359
-                    if (! is_readable($file_path)) {
1360
-                        EE_Error::add_error(
1361
-                            sprintf(
1362
-                                esc_html__(
1363
-                                    'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1364
-                                    'event_espresso'
1365
-                                ),
1366
-                                $file_path,
1367
-                                $tour
1368
-                            ),
1369
-                            __FILE__,
1370
-                            __FUNCTION__,
1371
-                            __LINE__
1372
-                        );
1373
-                        return;
1374
-                    }
1375
-                    require_once $file_path;
1376
-                    if (! class_exists($tour)) {
1377
-                        $error_msg[] = sprintf(
1378
-                            esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1379
-                            $tour
1380
-                        );
1381
-                        $error_msg[] = $error_msg[0] . "\r\n"
1382
-                                       . sprintf(
1383
-                                           esc_html__(
1384
-                                               'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1385
-                                               'event_espresso'
1386
-                                           ),
1387
-                                           $tour,
1388
-                                           '<br />',
1389
-                                           $tour,
1390
-                                           $this->_req_action,
1391
-                                           get_class($this)
1392
-                                       );
1393
-                        throw new EE_Error(implode('||', $error_msg));
1394
-                    }
1395
-                    $tour_obj = new $tour($this->_is_caf);
1396
-                    $tours[] = $tour_obj;
1397
-                    $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1398
-                }
1399
-                // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1400
-                $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1401
-                $tours[] = $end_stop_tour;
1402
-                $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1403
-            }
1404
-        }
1405
-        if (! empty($tours)) {
1406
-            $this->_help_tour['tours'] = $tours;
1407
-        }
1408
-        // that's it!  Now that the $_help_tours property is set (or not)
1409
-        // the scripts and html should be taken care of automatically.
1410
-    }
1411
-
1412
-
1413
-    /**
1414
-     * This simply sets up any qtips that have been defined in the page config
1415
-     *
1416
-     * @return void
1417
-     */
1418
-    protected function _add_qtips()
1419
-    {
1420
-        if (isset($this->_route_config['qtips'])) {
1421
-            $qtips = (array) $this->_route_config['qtips'];
1422
-            // load qtip loader
1423
-            $path = array(
1424
-                $this->_get_dir() . '/qtips/',
1425
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1426
-            );
1427
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1428
-        }
1429
-    }
1430
-
1431
-
1432
-    /**
1433
-     * _set_nav_tabs
1434
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1435
-     * wish to add additional tabs or modify accordingly.
1436
-     *
1437
-     * @return void
1438
-     * @throws InvalidArgumentException
1439
-     * @throws InvalidInterfaceException
1440
-     * @throws InvalidDataTypeException
1441
-     */
1442
-    protected function _set_nav_tabs()
1443
-    {
1444
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1445
-        $i = 0;
1446
-        foreach ($this->_page_config as $slug => $config) {
1447
-            if (! is_array($config)
1448
-                || (
1449
-                    is_array($config)
1450
-                    && (
1451
-                        (isset($config['nav']) && ! $config['nav'])
1452
-                        || ! isset($config['nav'])
1453
-                    )
1454
-                )
1455
-            ) {
1456
-                continue;
1457
-            }
1458
-            // no nav tab for this config
1459
-            // check for persistent flag
1460
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1461
-                // nav tab is only to appear when route requested.
1462
-                continue;
1463
-            }
1464
-            if (! $this->check_user_access($slug, true)) {
1465
-                // no nav tab because current user does not have access.
1466
-                continue;
1467
-            }
1468
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1469
-            $this->_nav_tabs[ $slug ] = array(
1470
-                'url'       => isset($config['nav']['url'])
1471
-                    ? $config['nav']['url']
1472
-                    : self::add_query_args_and_nonce(
1473
-                        array('action' => $slug),
1474
-                        $this->_admin_base_url
1475
-                    ),
1476
-                'link_text' => isset($config['nav']['label'])
1477
-                    ? $config['nav']['label']
1478
-                    : ucwords(
1479
-                        str_replace('_', ' ', $slug)
1480
-                    ),
1481
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1482
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1483
-            );
1484
-            $i++;
1485
-        }
1486
-        // if $this->_nav_tabs is empty then lets set the default
1487
-        if (empty($this->_nav_tabs)) {
1488
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1489
-                'url'       => $this->_admin_base_url,
1490
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1491
-                'css_class' => 'nav-tab-active',
1492
-                'order'     => 10,
1493
-            );
1494
-        }
1495
-        // now let's sort the tabs according to order
1496
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1497
-    }
1498
-
1499
-
1500
-    /**
1501
-     * _set_current_labels
1502
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1503
-     * property array
1504
-     *
1505
-     * @return void
1506
-     */
1507
-    private function _set_current_labels()
1508
-    {
1509
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1510
-            foreach ($this->_route_config['labels'] as $label => $text) {
1511
-                if (is_array($text)) {
1512
-                    foreach ($text as $sublabel => $subtext) {
1513
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1514
-                    }
1515
-                } else {
1516
-                    $this->_labels[ $label ] = $text;
1517
-                }
1518
-            }
1519
-        }
1520
-    }
1521
-
1522
-
1523
-    /**
1524
-     *        verifies user access for this admin page
1525
-     *
1526
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1527
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1528
-     *                               return false if verify fail.
1529
-     * @return bool
1530
-     * @throws InvalidArgumentException
1531
-     * @throws InvalidDataTypeException
1532
-     * @throws InvalidInterfaceException
1533
-     */
1534
-    public function check_user_access($route_to_check = '', $verify_only = false)
1535
-    {
1536
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1537
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1538
-        $capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1539
-                      && is_array(
1540
-                          $this->_page_routes[ $route_to_check ]
1541
-                      )
1542
-                      && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1543
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1544
-        if (empty($capability) && empty($route_to_check)) {
1545
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1546
-                : $this->_route['capability'];
1547
-        } else {
1548
-            $capability = empty($capability) ? 'manage_options' : $capability;
1549
-        }
1550
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1551
-        if (! defined('DOING_AJAX')
1552
-            && (
1553
-                ! function_exists('is_admin')
1554
-                || ! EE_Registry::instance()->CAP->current_user_can(
1555
-                    $capability,
1556
-                    $this->page_slug
1557
-                    . '_'
1558
-                    . $route_to_check,
1559
-                    $id
1560
-                )
1561
-            )
1562
-        ) {
1563
-            if ($verify_only) {
1564
-                return false;
1565
-            }
1566
-            if (is_user_logged_in()) {
1567
-                wp_die(__('You do not have access to this route.', 'event_espresso'));
1568
-            } else {
1569
-                return false;
1570
-            }
1571
-        }
1572
-        return true;
1573
-    }
1574
-
1575
-
1576
-    /**
1577
-     * admin_init_global
1578
-     * This runs all the code that we want executed within the WP admin_init hook.
1579
-     * This method executes for ALL EE Admin pages.
1580
-     *
1581
-     * @return void
1582
-     */
1583
-    public function admin_init_global()
1584
-    {
1585
-    }
1586
-
1587
-
1588
-    /**
1589
-     * wp_loaded_global
1590
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1591
-     * EE_Admin page and will execute on every EE Admin Page load
1592
-     *
1593
-     * @return void
1594
-     */
1595
-    public function wp_loaded()
1596
-    {
1597
-    }
1598
-
1599
-
1600
-    /**
1601
-     * admin_notices
1602
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1603
-     * ALL EE_Admin pages.
1604
-     *
1605
-     * @return void
1606
-     */
1607
-    public function admin_notices_global()
1608
-    {
1609
-        $this->_display_no_javascript_warning();
1610
-        $this->_display_espresso_notices();
1611
-    }
1612
-
1613
-
1614
-    public function network_admin_notices_global()
1615
-    {
1616
-        $this->_display_no_javascript_warning();
1617
-        $this->_display_espresso_notices();
1618
-    }
1619
-
1620
-
1621
-    /**
1622
-     * admin_footer_scripts_global
1623
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1624
-     * will apply on ALL EE_Admin pages.
1625
-     *
1626
-     * @return void
1627
-     */
1628
-    public function admin_footer_scripts_global()
1629
-    {
1630
-        $this->_add_admin_page_ajax_loading_img();
1631
-        $this->_add_admin_page_overlay();
1632
-        // if metaboxes are present we need to add the nonce field
1633
-        if (isset($this->_route_config['metaboxes'])
1634
-            || isset($this->_route_config['list_table'])
1635
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1636
-        ) {
1637
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1638
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1639
-        }
1640
-    }
1641
-
1642
-
1643
-    /**
1644
-     * admin_footer_global
1645
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1646
-     * ALL EE_Admin Pages.
1647
-     *
1648
-     * @return void
1649
-     * @throws EE_Error
1650
-     */
1651
-    public function admin_footer_global()
1652
-    {
1653
-        // dialog container for dialog helper
1654
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1655
-        $d_cont .= '<div class="ee-notices"></div>';
1656
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1657
-        $d_cont .= '</div>';
1658
-        echo $d_cont;
1659
-        // help tour stuff?
1660
-        if (isset($this->_help_tour[ $this->_req_action ])) {
1661
-            echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1662
-        }
1663
-        // current set timezone for timezone js
1664
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1665
-    }
1666
-
1667
-
1668
-    /**
1669
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1670
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1671
-     * help popups then in your templates or your content you set "triggers" for the content using the
1672
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1673
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1674
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1675
-     * for the
1676
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1677
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1678
-     *    'help_trigger_id' => array(
1679
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1680
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1681
-     *    )
1682
-     * );
1683
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1684
-     *
1685
-     * @param array $help_array
1686
-     * @param bool  $display
1687
-     * @return string content
1688
-     * @throws DomainException
1689
-     * @throws EE_Error
1690
-     */
1691
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1692
-    {
1693
-        $content = '';
1694
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1695
-        // loop through the array and setup content
1696
-        foreach ($help_array as $trigger => $help) {
1697
-            // make sure the array is setup properly
1698
-            if (! isset($help['title']) || ! isset($help['content'])) {
1699
-                throw new EE_Error(
1700
-                    esc_html__(
1701
-                        'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1702
-                        'event_espresso'
1703
-                    )
1704
-                );
1705
-            }
1706
-            // we're good so let'd setup the template vars and then assign parsed template content to our content.
1707
-            $template_args = array(
1708
-                'help_popup_id'      => $trigger,
1709
-                'help_popup_title'   => $help['title'],
1710
-                'help_popup_content' => $help['content'],
1711
-            );
1712
-            $content .= EEH_Template::display_template(
1713
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1714
-                $template_args,
1715
-                true
1716
-            );
1717
-        }
1718
-        if ($display) {
1719
-            echo $content;
1720
-            return '';
1721
-        }
1722
-        return $content;
1723
-    }
1724
-
1725
-
1726
-    /**
1727
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1728
-     *
1729
-     * @return array properly formatted array for help popup content
1730
-     * @throws EE_Error
1731
-     */
1732
-    private function _get_help_content()
1733
-    {
1734
-        // what is the method we're looking for?
1735
-        $method_name = '_help_popup_content_' . $this->_req_action;
1736
-        // if method doesn't exist let's get out.
1737
-        if (! method_exists($this, $method_name)) {
1738
-            return array();
1739
-        }
1740
-        // k we're good to go let's retrieve the help array
1741
-        $help_array = call_user_func(array($this, $method_name));
1742
-        // make sure we've got an array!
1743
-        if (! is_array($help_array)) {
1744
-            throw new EE_Error(
1745
-                esc_html__(
1746
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1747
-                    'event_espresso'
1748
-                )
1749
-            );
1750
-        }
1751
-        return $help_array;
1752
-    }
1753
-
1754
-
1755
-    /**
1756
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1757
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1758
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1759
-     *
1760
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1761
-     * @param boolean $display    if false then we return the trigger string
1762
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1763
-     * @return string
1764
-     * @throws DomainException
1765
-     * @throws EE_Error
1766
-     */
1767
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1768
-    {
1769
-        if (defined('DOING_AJAX')) {
1770
-            return '';
1771
-        }
1772
-        // let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1773
-        $help_array = $this->_get_help_content();
1774
-        $help_content = '';
1775
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1776
-            $help_array[ $trigger_id ] = array(
1777
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1778
-                'content' => esc_html__(
1779
-                    'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1780
-                    'event_espresso'
1781
-                ),
1782
-            );
1783
-            $help_content = $this->_set_help_popup_content($help_array, false);
1784
-        }
1785
-        // let's setup the trigger
1786
-        $content = '<a class="ee-dialog" href="?height='
1787
-                   . $dimensions[0]
1788
-                   . '&width='
1789
-                   . $dimensions[1]
1790
-                   . '&inlineId='
1791
-                   . $trigger_id
1792
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1793
-        $content .= $help_content;
1794
-        if ($display) {
1795
-            echo $content;
1796
-            return '';
1797
-        }
1798
-        return $content;
1799
-    }
1800
-
1801
-
1802
-    /**
1803
-     * _add_global_screen_options
1804
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1805
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1806
-     *
1807
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1808
-     *         see also WP_Screen object documents...
1809
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1810
-     * @abstract
1811
-     * @return void
1812
-     */
1813
-    private function _add_global_screen_options()
1814
-    {
1815
-    }
1816
-
1817
-
1818
-    /**
1819
-     * _add_global_feature_pointers
1820
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1821
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1822
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1823
-     *
1824
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1825
-     *         extended) also see:
1826
-     * @link   http://eamann.com/tech/wordpress-portland/
1827
-     * @abstract
1828
-     * @return void
1829
-     */
1830
-    private function _add_global_feature_pointers()
1831
-    {
1832
-    }
1833
-
1834
-
1835
-    /**
1836
-     * load_global_scripts_styles
1837
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1838
-     *
1839
-     * @return void
1840
-     * @throws EE_Error
1841
-     */
1842
-    public function load_global_scripts_styles()
1843
-    {
1844
-        /** STYLES **/
1845
-        // add debugging styles
1846
-        if (WP_DEBUG) {
1847
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1848
-        }
1849
-        // register all styles
1850
-        wp_register_style(
1851
-            'espresso-ui-theme',
1852
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1853
-            array(),
1854
-            EVENT_ESPRESSO_VERSION
1855
-        );
1856
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1857
-        // helpers styles
1858
-        wp_register_style(
1859
-            'ee-text-links',
1860
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1861
-            array(),
1862
-            EVENT_ESPRESSO_VERSION
1863
-        );
1864
-        /** SCRIPTS **/
1865
-        // register all scripts
1866
-        wp_register_script(
1867
-            'ee-dialog',
1868
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1869
-            array('jquery', 'jquery-ui-draggable'),
1870
-            EVENT_ESPRESSO_VERSION,
1871
-            true
1872
-        );
1873
-        wp_register_script(
1874
-            'ee_admin_js',
1875
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1876
-            array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1877
-            EVENT_ESPRESSO_VERSION,
1878
-            true
1879
-        );
1880
-        wp_register_script(
1881
-            'jquery-ui-timepicker-addon',
1882
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1883
-            array('jquery-ui-datepicker', 'jquery-ui-slider'),
1884
-            EVENT_ESPRESSO_VERSION,
1885
-            true
1886
-        );
1887
-        add_filter('FHEE_load_joyride', '__return_true');
1888
-        // script for sorting tables
1889
-        wp_register_script(
1890
-            'espresso_ajax_table_sorting',
1891
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1892
-            array('ee_admin_js', 'jquery-ui-sortable'),
1893
-            EVENT_ESPRESSO_VERSION,
1894
-            true
1895
-        );
1896
-        // script for parsing uri's
1897
-        wp_register_script(
1898
-            'ee-parse-uri',
1899
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1900
-            array(),
1901
-            EVENT_ESPRESSO_VERSION,
1902
-            true
1903
-        );
1904
-        // and parsing associative serialized form elements
1905
-        wp_register_script(
1906
-            'ee-serialize-full-array',
1907
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1908
-            array('jquery'),
1909
-            EVENT_ESPRESSO_VERSION,
1910
-            true
1911
-        );
1912
-        // helpers scripts
1913
-        wp_register_script(
1914
-            'ee-text-links',
1915
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1916
-            array('jquery'),
1917
-            EVENT_ESPRESSO_VERSION,
1918
-            true
1919
-        );
1920
-        wp_register_script(
1921
-            'ee-moment-core',
1922
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1923
-            array(),
1924
-            EVENT_ESPRESSO_VERSION,
1925
-            true
1926
-        );
1927
-        wp_register_script(
1928
-            'ee-moment',
1929
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1930
-            array('ee-moment-core'),
1931
-            EVENT_ESPRESSO_VERSION,
1932
-            true
1933
-        );
1934
-        wp_register_script(
1935
-            'ee-datepicker',
1936
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1937
-            array('jquery-ui-timepicker-addon', 'ee-moment'),
1938
-            EVENT_ESPRESSO_VERSION,
1939
-            true
1940
-        );
1941
-        // google charts
1942
-        wp_register_script(
1943
-            'google-charts',
1944
-            'https://www.gstatic.com/charts/loader.js',
1945
-            array(),
1946
-            EVENT_ESPRESSO_VERSION,
1947
-            false
1948
-        );
1949
-        // ENQUEUE ALL BASICS BY DEFAULT
1950
-        wp_enqueue_style('ee-admin-css');
1951
-        wp_enqueue_script('ee_admin_js');
1952
-        wp_enqueue_script('ee-accounting');
1953
-        wp_enqueue_script('jquery-validate');
1954
-        // taking care of metaboxes
1955
-        if (empty($this->_cpt_route)
1956
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1957
-        ) {
1958
-            wp_enqueue_script('dashboard');
1959
-        }
1960
-        // LOCALIZED DATA
1961
-        // localize script for ajax lazy loading
1962
-        $lazy_loader_container_ids = apply_filters(
1963
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1964
-            array('espresso_news_post_box_content')
1965
-        );
1966
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1967
-        /**
1968
-         * help tour stuff
1969
-         */
1970
-        if (! empty($this->_help_tour)) {
1971
-            // register the js for kicking things off
1972
-            wp_enqueue_script(
1973
-                'ee-help-tour',
1974
-                EE_ADMIN_URL . 'assets/ee-help-tour.js',
1975
-                array('jquery-joyride'),
1976
-                EVENT_ESPRESSO_VERSION,
1977
-                true
1978
-            );
1979
-            $tours = array();
1980
-            // setup tours for the js tour object
1981
-            foreach ($this->_help_tour['tours'] as $tour) {
1982
-                if ($tour instanceof EE_Help_Tour) {
1983
-                    $tours[] = array(
1984
-                        'id'      => $tour->get_slug(),
1985
-                        'options' => $tour->get_options(),
1986
-                    );
1987
-                }
1988
-            }
1989
-            wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1990
-            // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1991
-        }
1992
-    }
1993
-
1994
-
1995
-    /**
1996
-     *        admin_footer_scripts_eei18n_js_strings
1997
-     *
1998
-     * @return        void
1999
-     */
2000
-    public function admin_footer_scripts_eei18n_js_strings()
2001
-    {
2002
-        EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
2003
-        EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2004
-            'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2005
-            'event_espresso'
2006
-        );
2007
-        EE_Registry::$i18n_js_strings['January'] = esc_html__('January', 'event_espresso');
2008
-        EE_Registry::$i18n_js_strings['February'] = esc_html__('February', 'event_espresso');
2009
-        EE_Registry::$i18n_js_strings['March'] = esc_html__('March', 'event_espresso');
2010
-        EE_Registry::$i18n_js_strings['April'] = esc_html__('April', 'event_espresso');
2011
-        EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2012
-        EE_Registry::$i18n_js_strings['June'] = esc_html__('June', 'event_espresso');
2013
-        EE_Registry::$i18n_js_strings['July'] = esc_html__('July', 'event_espresso');
2014
-        EE_Registry::$i18n_js_strings['August'] = esc_html__('August', 'event_espresso');
2015
-        EE_Registry::$i18n_js_strings['September'] = esc_html__('September', 'event_espresso');
2016
-        EE_Registry::$i18n_js_strings['October'] = esc_html__('October', 'event_espresso');
2017
-        EE_Registry::$i18n_js_strings['November'] = esc_html__('November', 'event_espresso');
2018
-        EE_Registry::$i18n_js_strings['December'] = esc_html__('December', 'event_espresso');
2019
-        EE_Registry::$i18n_js_strings['Jan'] = esc_html__('Jan', 'event_espresso');
2020
-        EE_Registry::$i18n_js_strings['Feb'] = esc_html__('Feb', 'event_espresso');
2021
-        EE_Registry::$i18n_js_strings['Mar'] = esc_html__('Mar', 'event_espresso');
2022
-        EE_Registry::$i18n_js_strings['Apr'] = esc_html__('Apr', 'event_espresso');
2023
-        EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2024
-        EE_Registry::$i18n_js_strings['Jun'] = esc_html__('Jun', 'event_espresso');
2025
-        EE_Registry::$i18n_js_strings['Jul'] = esc_html__('Jul', 'event_espresso');
2026
-        EE_Registry::$i18n_js_strings['Aug'] = esc_html__('Aug', 'event_espresso');
2027
-        EE_Registry::$i18n_js_strings['Sep'] = esc_html__('Sep', 'event_espresso');
2028
-        EE_Registry::$i18n_js_strings['Oct'] = esc_html__('Oct', 'event_espresso');
2029
-        EE_Registry::$i18n_js_strings['Nov'] = esc_html__('Nov', 'event_espresso');
2030
-        EE_Registry::$i18n_js_strings['Dec'] = esc_html__('Dec', 'event_espresso');
2031
-        EE_Registry::$i18n_js_strings['Sunday'] = esc_html__('Sunday', 'event_espresso');
2032
-        EE_Registry::$i18n_js_strings['Monday'] = esc_html__('Monday', 'event_espresso');
2033
-        EE_Registry::$i18n_js_strings['Tuesday'] = esc_html__('Tuesday', 'event_espresso');
2034
-        EE_Registry::$i18n_js_strings['Wednesday'] = esc_html__('Wednesday', 'event_espresso');
2035
-        EE_Registry::$i18n_js_strings['Thursday'] = esc_html__('Thursday', 'event_espresso');
2036
-        EE_Registry::$i18n_js_strings['Friday'] = esc_html__('Friday', 'event_espresso');
2037
-        EE_Registry::$i18n_js_strings['Saturday'] = esc_html__('Saturday', 'event_espresso');
2038
-        EE_Registry::$i18n_js_strings['Sun'] = esc_html__('Sun', 'event_espresso');
2039
-        EE_Registry::$i18n_js_strings['Mon'] = esc_html__('Mon', 'event_espresso');
2040
-        EE_Registry::$i18n_js_strings['Tue'] = esc_html__('Tue', 'event_espresso');
2041
-        EE_Registry::$i18n_js_strings['Wed'] = esc_html__('Wed', 'event_espresso');
2042
-        EE_Registry::$i18n_js_strings['Thu'] = esc_html__('Thu', 'event_espresso');
2043
-        EE_Registry::$i18n_js_strings['Fri'] = esc_html__('Fri', 'event_espresso');
2044
-        EE_Registry::$i18n_js_strings['Sat'] = esc_html__('Sat', 'event_espresso');
2045
-    }
2046
-
2047
-
2048
-    /**
2049
-     *        load enhanced xdebug styles for ppl with failing eyesight
2050
-     *
2051
-     * @return        void
2052
-     */
2053
-    public function add_xdebug_style()
2054
-    {
2055
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2056
-    }
2057
-
2058
-
2059
-    /************************/
2060
-    /** LIST TABLE METHODS **/
2061
-    /************************/
2062
-    /**
2063
-     * this sets up the list table if the current view requires it.
2064
-     *
2065
-     * @return void
2066
-     * @throws EE_Error
2067
-     */
2068
-    protected function _set_list_table()
2069
-    {
2070
-        // first is this a list_table view?
2071
-        if (! isset($this->_route_config['list_table'])) {
2072
-            return;
2073
-        } //not a list_table view so get out.
2074
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2075
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2076
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2077
-            // user error msg
2078
-            $error_msg = esc_html__(
2079
-                'An error occurred. The requested list table views could not be found.',
2080
-                'event_espresso'
2081
-            );
2082
-            // developer error msg
2083
-            $error_msg .= '||'
2084
-                          . sprintf(
2085
-                              esc_html__(
2086
-                                  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2087
-                                  'event_espresso'
2088
-                              ),
2089
-                              $this->_req_action,
2090
-                              $list_table_view
2091
-                          );
2092
-            throw new EE_Error($error_msg);
2093
-        }
2094
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2095
-        $this->_views = apply_filters(
2096
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2097
-            $this->_views
2098
-        );
2099
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2100
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2101
-        $this->_set_list_table_view();
2102
-        $this->_set_list_table_object();
2103
-    }
2104
-
2105
-
2106
-    /**
2107
-     * set current view for List Table
2108
-     *
2109
-     * @return void
2110
-     */
2111
-    protected function _set_list_table_view()
2112
-    {
2113
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2114
-        // looking at active items or dumpster diving ?
2115
-        if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2116
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2117
-        } else {
2118
-            $this->_view = sanitize_key($this->_req_data['status']);
2119
-        }
2120
-    }
2121
-
2122
-
2123
-    /**
2124
-     * _set_list_table_object
2125
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2126
-     *
2127
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2128
-     * @throws \InvalidArgumentException
2129
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2130
-     * @throws EE_Error
2131
-     * @throws InvalidInterfaceException
2132
-     */
2133
-    protected function _set_list_table_object()
2134
-    {
2135
-        if (isset($this->_route_config['list_table'])) {
2136
-            if (! class_exists($this->_route_config['list_table'])) {
2137
-                throw new EE_Error(
2138
-                    sprintf(
2139
-                        esc_html__(
2140
-                            'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2141
-                            'event_espresso'
2142
-                        ),
2143
-                        $this->_route_config['list_table'],
2144
-                        get_class($this)
2145
-                    )
2146
-                );
2147
-            }
2148
-            $this->_list_table_object = $this->loader->getShared(
2149
-                $this->_route_config['list_table'],
2150
-                array($this)
2151
-            );
2152
-        }
2153
-    }
2154
-
2155
-
2156
-    /**
2157
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2158
-     *
2159
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2160
-     *                                                    urls.  The array should be indexed by the view it is being
2161
-     *                                                    added to.
2162
-     * @return array
2163
-     */
2164
-    public function get_list_table_view_RLs($extra_query_args = array())
2165
-    {
2166
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2167
-        if (empty($this->_views)) {
2168
-            $this->_views = array();
2169
-        }
2170
-        // cycle thru views
2171
-        foreach ($this->_views as $key => $view) {
2172
-            $query_args = array();
2173
-            // check for current view
2174
-            $this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2175
-            $query_args['action'] = $this->_req_action;
2176
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2177
-            $query_args['status'] = $view['slug'];
2178
-            // merge any other arguments sent in.
2179
-            if (isset($extra_query_args[ $view['slug'] ])) {
2180
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2181
-            }
2182
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2183
-        }
2184
-        return $this->_views;
2185
-    }
2186
-
2187
-
2188
-    /**
2189
-     * _entries_per_page_dropdown
2190
-     * generates a drop down box for selecting the number of visible rows in an admin page list table
2191
-     *
2192
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2193
-     *         WP does it.
2194
-     * @param int $max_entries total number of rows in the table
2195
-     * @return string
2196
-     */
2197
-    protected function _entries_per_page_dropdown($max_entries = 0)
2198
-    {
2199
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2200
-        $values = array(10, 25, 50, 100);
2201
-        $per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2202
-        if ($max_entries) {
2203
-            $values[] = $max_entries;
2204
-            sort($values);
2205
-        }
2206
-        $entries_per_page_dropdown = '
104
+	/**
105
+	 * @var array $_route_config
106
+	 */
107
+	protected $_route_config;
108
+
109
+	/**
110
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
111
+	 * actions.
112
+	 *
113
+	 * @since 4.6.x
114
+	 * @var array.
115
+	 */
116
+	protected $_default_route_query_args;
117
+
118
+	// set via request page and action args.
119
+	protected $_current_page;
120
+
121
+	protected $_current_view;
122
+
123
+	protected $_current_page_view_url;
124
+
125
+	// sanitized request action (and nonce)
126
+
127
+	/**
128
+	 * @var string $_req_action
129
+	 */
130
+	protected $_req_action;
131
+
132
+	/**
133
+	 * @var string $_req_nonce
134
+	 */
135
+	protected $_req_nonce;
136
+
137
+	// search related
138
+	protected $_search_btn_label;
139
+
140
+	protected $_search_box_callback;
141
+
142
+	/**
143
+	 * WP Current Screen object
144
+	 *
145
+	 * @var WP_Screen
146
+	 */
147
+	protected $_current_screen;
148
+
149
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
150
+	protected $_hook_obj;
151
+
152
+	// for holding incoming request data
153
+	protected $_req_data;
154
+
155
+	// yes / no array for admin form fields
156
+	protected $_yes_no_values = array();
157
+
158
+	// some default things shared by all child classes
159
+	protected $_default_espresso_metaboxes;
160
+
161
+	/**
162
+	 *    EE_Registry Object
163
+	 *
164
+	 * @var    EE_Registry
165
+	 */
166
+	protected $EE = null;
167
+
168
+
169
+	/**
170
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
171
+	 *
172
+	 * @var boolean
173
+	 */
174
+	protected $_is_caf = false;
175
+
176
+
177
+	/**
178
+	 * @Constructor
179
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
180
+	 * @throws EE_Error
181
+	 * @throws InvalidArgumentException
182
+	 * @throws ReflectionException
183
+	 * @throws InvalidDataTypeException
184
+	 * @throws InvalidInterfaceException
185
+	 */
186
+	public function __construct($routing = true)
187
+	{
188
+		$this->loader = LoaderFactory::getLoader();
189
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
190
+			$this->_is_caf = true;
191
+		}
192
+		$this->_yes_no_values = array(
193
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
194
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
195
+		);
196
+		// set the _req_data property.
197
+		$this->_req_data = array_merge($_GET, $_POST);
198
+		// routing enabled?
199
+		$this->_routing = $routing;
200
+		// set initial page props (child method)
201
+		$this->_init_page_props();
202
+		// set global defaults
203
+		$this->_set_defaults();
204
+		// set early because incoming requests could be ajax related and we need to register those hooks.
205
+		$this->_global_ajax_hooks();
206
+		$this->_ajax_hooks();
207
+		// other_page_hooks have to be early too.
208
+		$this->_do_other_page_hooks();
209
+		// This just allows us to have extending classes do something specific
210
+		// before the parent constructor runs _page_setup().
211
+		if (method_exists($this, '_before_page_setup')) {
212
+			$this->_before_page_setup();
213
+		}
214
+		// set up page dependencies
215
+		$this->_page_setup();
216
+	}
217
+
218
+
219
+	/**
220
+	 * _init_page_props
221
+	 * Child classes use to set at least the following properties:
222
+	 * $page_slug.
223
+	 * $page_label.
224
+	 *
225
+	 * @abstract
226
+	 * @return void
227
+	 */
228
+	abstract protected function _init_page_props();
229
+
230
+
231
+	/**
232
+	 * _ajax_hooks
233
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
234
+	 * Note: within the ajax callback methods.
235
+	 *
236
+	 * @abstract
237
+	 * @return void
238
+	 */
239
+	abstract protected function _ajax_hooks();
240
+
241
+
242
+	/**
243
+	 * _define_page_props
244
+	 * child classes define page properties in here.  Must include at least:
245
+	 * $_admin_base_url = base_url for all admin pages
246
+	 * $_admin_page_title = default admin_page_title for admin pages
247
+	 * $_labels = array of default labels for various automatically generated elements:
248
+	 *    array(
249
+	 *        'buttons' => array(
250
+	 *            'add' => esc_html__('label for add new button'),
251
+	 *            'edit' => esc_html__('label for edit button'),
252
+	 *            'delete' => esc_html__('label for delete button')
253
+	 *            )
254
+	 *        )
255
+	 *
256
+	 * @abstract
257
+	 * @return void
258
+	 */
259
+	abstract protected function _define_page_props();
260
+
261
+
262
+	/**
263
+	 * _set_page_routes
264
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
265
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
266
+	 * have a 'default' route. Here's the format
267
+	 * $this->_page_routes = array(
268
+	 *        'default' => array(
269
+	 *            'func' => '_default_method_handling_route',
270
+	 *            'args' => array('array','of','args'),
271
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
272
+	 *            ajax request, backend processing)
273
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
274
+	 *            headers route after.  The string you enter here should match the defined route reference for a
275
+	 *            headers sent route.
276
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
277
+	 *            this route.
278
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
279
+	 *            checks).
280
+	 *        ),
281
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
282
+	 *        handling method.
283
+	 *        )
284
+	 * )
285
+	 *
286
+	 * @abstract
287
+	 * @return void
288
+	 */
289
+	abstract protected function _set_page_routes();
290
+
291
+
292
+	/**
293
+	 * _set_page_config
294
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
295
+	 * array corresponds to the page_route for the loaded page. Format:
296
+	 * $this->_page_config = array(
297
+	 *        'default' => array(
298
+	 *            'labels' => array(
299
+	 *                'buttons' => array(
300
+	 *                    'add' => esc_html__('label for adding item'),
301
+	 *                    'edit' => esc_html__('label for editing item'),
302
+	 *                    'delete' => esc_html__('label for deleting item')
303
+	 *                ),
304
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
305
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
306
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
307
+	 *            _define_page_props() method
308
+	 *            'nav' => array(
309
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
310
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
311
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
312
+	 *                'order' => 10, //required to indicate tab position.
313
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
314
+	 *                displayed then add this parameter.
315
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
316
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
317
+	 *            metaboxes set for eventespresso admin pages.
318
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
319
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
320
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
321
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
322
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
323
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
324
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
325
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
326
+	 *            want to display.
327
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
328
+	 *                'tab_id' => array(
329
+	 *                    'title' => 'tab_title',
330
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
331
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
332
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
333
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
334
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
335
+	 *                    attempt to use the callback which should match the name of a method in the class
336
+	 *                    ),
337
+	 *                'tab2_id' => array(
338
+	 *                    'title' => 'tab2 title',
339
+	 *                    'filename' => 'file_name_2'
340
+	 *                    'callback' => 'callback_method_for_content',
341
+	 *                 ),
342
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
343
+	 *            help tab area on an admin page. @link
344
+	 *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
345
+	 *            'help_tour' => array(
346
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
347
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
348
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
349
+	 *            ),
350
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
351
+	 *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
352
+	 *            just set
353
+	 *            'require_nonce' to FALSE
354
+	 *            )
355
+	 * )
356
+	 *
357
+	 * @abstract
358
+	 * @return void
359
+	 */
360
+	abstract protected function _set_page_config();
361
+
362
+
363
+
364
+
365
+
366
+	/** end sample help_tour methods **/
367
+	/**
368
+	 * _add_screen_options
369
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
370
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
371
+	 * to a particular view.
372
+	 *
373
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
374
+	 *         see also WP_Screen object documents...
375
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
376
+	 * @abstract
377
+	 * @return void
378
+	 */
379
+	abstract protected function _add_screen_options();
380
+
381
+
382
+	/**
383
+	 * _add_feature_pointers
384
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
385
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
386
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
387
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
388
+	 * extended) also see:
389
+	 *
390
+	 * @link   http://eamann.com/tech/wordpress-portland/
391
+	 * @abstract
392
+	 * @return void
393
+	 */
394
+	abstract protected function _add_feature_pointers();
395
+
396
+
397
+	/**
398
+	 * load_scripts_styles
399
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
400
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
401
+	 * scripts/styles per view by putting them in a dynamic function in this format
402
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
403
+	 *
404
+	 * @abstract
405
+	 * @return void
406
+	 */
407
+	abstract public function load_scripts_styles();
408
+
409
+
410
+	/**
411
+	 * admin_init
412
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
413
+	 * all pages/views loaded by child class.
414
+	 *
415
+	 * @abstract
416
+	 * @return void
417
+	 */
418
+	abstract public function admin_init();
419
+
420
+
421
+	/**
422
+	 * admin_notices
423
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
424
+	 * all pages/views loaded by child class.
425
+	 *
426
+	 * @abstract
427
+	 * @return void
428
+	 */
429
+	abstract public function admin_notices();
430
+
431
+
432
+	/**
433
+	 * admin_footer_scripts
434
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
435
+	 * will apply to all pages/views loaded by child class.
436
+	 *
437
+	 * @return void
438
+	 */
439
+	abstract public function admin_footer_scripts();
440
+
441
+
442
+	/**
443
+	 * admin_footer
444
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
445
+	 * apply to all pages/views loaded by child class.
446
+	 *
447
+	 * @return void
448
+	 */
449
+	public function admin_footer()
450
+	{
451
+	}
452
+
453
+
454
+	/**
455
+	 * _global_ajax_hooks
456
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
457
+	 * Note: within the ajax callback methods.
458
+	 *
459
+	 * @abstract
460
+	 * @return void
461
+	 */
462
+	protected function _global_ajax_hooks()
463
+	{
464
+		// for lazy loading of metabox content
465
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
466
+	}
467
+
468
+
469
+	public function ajax_metabox_content()
470
+	{
471
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
472
+		$url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
473
+		self::cached_rss_display($contentid, $url);
474
+		wp_die();
475
+	}
476
+
477
+
478
+	/**
479
+	 * _page_setup
480
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
481
+	 * doesn't match the object.
482
+	 *
483
+	 * @final
484
+	 * @return void
485
+	 * @throws EE_Error
486
+	 * @throws InvalidArgumentException
487
+	 * @throws ReflectionException
488
+	 * @throws InvalidDataTypeException
489
+	 * @throws InvalidInterfaceException
490
+	 */
491
+	final protected function _page_setup()
492
+	{
493
+		// requires?
494
+		// admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
495
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
496
+		// next verify if we need to load anything...
497
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
498
+		$this->page_folder = strtolower(
499
+			str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
500
+		);
501
+		global $ee_menu_slugs;
502
+		$ee_menu_slugs = (array) $ee_menu_slugs;
503
+		if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
504
+			return;
505
+		}
506
+		// becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
507
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
508
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
509
+				? $this->_req_data['action2']
510
+				: $this->_req_data['action'];
511
+		}
512
+		// then set blank or -1 action values to 'default'
513
+		$this->_req_action = isset($this->_req_data['action'])
514
+							 && ! empty($this->_req_data['action'])
515
+							 && $this->_req_data['action'] !== '-1'
516
+			? sanitize_key($this->_req_data['action'])
517
+			: 'default';
518
+		// if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
519
+		//  This covers cases where we're coming in from a list table that isn't on the default route.
520
+		$this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
521
+			? $this->_req_data['route'] : $this->_req_action;
522
+		// however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
523
+		$this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route'])
524
+			? $this->_req_data['route']
525
+			: $this->_req_action;
526
+		$this->_current_view = $this->_req_action;
527
+		$this->_req_nonce = $this->_req_action . '_nonce';
528
+		$this->_define_page_props();
529
+		$this->_current_page_view_url = add_query_arg(
530
+			array('page' => $this->_current_page, 'action' => $this->_current_view),
531
+			$this->_admin_base_url
532
+		);
533
+		// default things
534
+		$this->_default_espresso_metaboxes = array(
535
+			'_espresso_news_post_box',
536
+			'_espresso_links_post_box',
537
+			'_espresso_ratings_request',
538
+			'_espresso_sponsors_post_box',
539
+		);
540
+		// set page configs
541
+		$this->_set_page_routes();
542
+		$this->_set_page_config();
543
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
544
+		if (isset($this->_req_data['wp_referer'])) {
545
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
546
+		}
547
+		// for caffeinated and other extended functionality.
548
+		//  If there is a _extend_page_config method
549
+		// then let's run that to modify the all the various page configuration arrays
550
+		if (method_exists($this, '_extend_page_config')) {
551
+			$this->_extend_page_config();
552
+		}
553
+		// for CPT and other extended functionality.
554
+		// If there is an _extend_page_config_for_cpt
555
+		// then let's run that to modify all the various page configuration arrays.
556
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
557
+			$this->_extend_page_config_for_cpt();
558
+		}
559
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
560
+		$this->_page_routes = apply_filters(
561
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
562
+			$this->_page_routes,
563
+			$this
564
+		);
565
+		$this->_page_config = apply_filters(
566
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
567
+			$this->_page_config,
568
+			$this
569
+		);
570
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
571
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
572
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
573
+			add_action(
574
+				'AHEE__EE_Admin_Page__route_admin_request',
575
+				array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
576
+				10,
577
+				2
578
+			);
579
+		}
580
+		// next route only if routing enabled
581
+		if ($this->_routing && ! defined('DOING_AJAX')) {
582
+			$this->_verify_routes();
583
+			// next let's just check user_access and kill if no access
584
+			$this->check_user_access();
585
+			if ($this->_is_UI_request) {
586
+				// admin_init stuff - global, all views for this page class, specific view
587
+				add_action('admin_init', array($this, 'admin_init'), 10);
588
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
589
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
590
+				}
591
+			} else {
592
+				// hijack regular WP loading and route admin request immediately
593
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
594
+				$this->route_admin_request();
595
+			}
596
+		}
597
+	}
598
+
599
+
600
+	/**
601
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
602
+	 *
603
+	 * @return void
604
+	 * @throws ReflectionException
605
+	 * @throws EE_Error
606
+	 */
607
+	private function _do_other_page_hooks()
608
+	{
609
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
610
+		foreach ($registered_pages as $page) {
611
+			// now let's setup the file name and class that should be present
612
+			$classname = str_replace('.class.php', '', $page);
613
+			// autoloaders should take care of loading file
614
+			if (! class_exists($classname)) {
615
+				$error_msg[] = sprintf(
616
+					esc_html__(
617
+						'Something went wrong with loading the %s admin hooks page.',
618
+						'event_espresso'
619
+					),
620
+					$page
621
+				);
622
+				$error_msg[] = $error_msg[0]
623
+							   . "\r\n"
624
+							   . sprintf(
625
+								   esc_html__(
626
+									   'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
627
+									   'event_espresso'
628
+								   ),
629
+								   $page,
630
+								   '<br />',
631
+								   '<strong>' . $classname . '</strong>'
632
+							   );
633
+				throw new EE_Error(implode('||', $error_msg));
634
+			}
635
+			$a = new ReflectionClass($classname);
636
+			// notice we are passing the instance of this class to the hook object.
637
+			$hookobj[] = $a->newInstance($this);
638
+		}
639
+	}
640
+
641
+
642
+	public function load_page_dependencies()
643
+	{
644
+		try {
645
+			$this->_load_page_dependencies();
646
+		} catch (EE_Error $e) {
647
+			$e->get_error();
648
+		}
649
+	}
650
+
651
+
652
+	/**
653
+	 * load_page_dependencies
654
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
655
+	 *
656
+	 * @return void
657
+	 * @throws DomainException
658
+	 * @throws EE_Error
659
+	 * @throws InvalidArgumentException
660
+	 * @throws InvalidDataTypeException
661
+	 * @throws InvalidInterfaceException
662
+	 * @throws ReflectionException
663
+	 */
664
+	protected function _load_page_dependencies()
665
+	{
666
+		// let's set the current_screen and screen options to override what WP set
667
+		$this->_current_screen = get_current_screen();
668
+		// load admin_notices - global, page class, and view specific
669
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
670
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
671
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
672
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
673
+		}
674
+		// load network admin_notices - global, page class, and view specific
675
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
676
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
677
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
678
+		}
679
+		// this will save any per_page screen options if they are present
680
+		$this->_set_per_page_screen_options();
681
+		// setup list table properties
682
+		$this->_set_list_table();
683
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
684
+		// However in some cases the metaboxes will need to be added within a route handling callback.
685
+		$this->_add_registered_meta_boxes();
686
+		$this->_add_screen_columns();
687
+		// add screen options - global, page child class, and view specific
688
+		$this->_add_global_screen_options();
689
+		$this->_add_screen_options();
690
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
691
+		if (method_exists($this, $add_screen_options)) {
692
+			$this->{$add_screen_options}();
693
+		}
694
+		// add help tab(s) and tours- set via page_config and qtips.
695
+		$this->_add_help_tour();
696
+		$this->_add_help_tabs();
697
+		$this->_add_qtips();
698
+		// add feature_pointers - global, page child class, and view specific
699
+		$this->_add_feature_pointers();
700
+		$this->_add_global_feature_pointers();
701
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
702
+		if (method_exists($this, $add_feature_pointer)) {
703
+			$this->{$add_feature_pointer}();
704
+		}
705
+		// enqueue scripts/styles - global, page class, and view specific
706
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
707
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
708
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
709
+			add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
710
+		}
711
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
712
+		// admin_print_footer_scripts - global, page child class, and view specific.
713
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
714
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
715
+		// is a good use case. Notice the late priority we're giving these
716
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
717
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
718
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
719
+			add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
720
+		}
721
+		// admin footer scripts
722
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
723
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
724
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
725
+			add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
726
+		}
727
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
728
+		// targeted hook
729
+		do_action(
730
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
731
+		);
732
+	}
733
+
734
+
735
+	/**
736
+	 * _set_defaults
737
+	 * This sets some global defaults for class properties.
738
+	 */
739
+	private function _set_defaults()
740
+	{
741
+		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
742
+		$this->_event = $this->_template_path = $this->_column_template_path = null;
743
+		$this->_nav_tabs = $this->_views = $this->_page_routes = array();
744
+		$this->_page_config = $this->_default_route_query_args = array();
745
+		$this->_default_nav_tab_name = 'overview';
746
+		// init template args
747
+		$this->_template_args = array(
748
+			'admin_page_header'  => '',
749
+			'admin_page_content' => '',
750
+			'post_body_content'  => '',
751
+			'before_list_table'  => '',
752
+			'after_list_table'   => '',
753
+		);
754
+	}
755
+
756
+
757
+	/**
758
+	 * route_admin_request
759
+	 *
760
+	 * @see    _route_admin_request()
761
+	 * @return exception|void error
762
+	 * @throws InvalidArgumentException
763
+	 * @throws InvalidInterfaceException
764
+	 * @throws InvalidDataTypeException
765
+	 * @throws EE_Error
766
+	 * @throws ReflectionException
767
+	 */
768
+	public function route_admin_request()
769
+	{
770
+		try {
771
+			$this->_route_admin_request();
772
+		} catch (EE_Error $e) {
773
+			$e->get_error();
774
+		}
775
+	}
776
+
777
+
778
+	public function set_wp_page_slug($wp_page_slug)
779
+	{
780
+		$this->_wp_page_slug = $wp_page_slug;
781
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
782
+		if (is_network_admin()) {
783
+			$this->_wp_page_slug .= '-network';
784
+		}
785
+	}
786
+
787
+
788
+	/**
789
+	 * _verify_routes
790
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
791
+	 * we know if we need to drop out.
792
+	 *
793
+	 * @return bool
794
+	 * @throws EE_Error
795
+	 */
796
+	protected function _verify_routes()
797
+	{
798
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
799
+		if (! $this->_current_page && ! defined('DOING_AJAX')) {
800
+			return false;
801
+		}
802
+		$this->_route = false;
803
+		// check that the page_routes array is not empty
804
+		if (empty($this->_page_routes)) {
805
+			// user error msg
806
+			$error_msg = sprintf(
807
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
808
+				$this->_admin_page_title
809
+			);
810
+			// developer error msg
811
+			$error_msg .= '||' . $error_msg
812
+						  . esc_html__(
813
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
814
+							  'event_espresso'
815
+						  );
816
+			throw new EE_Error($error_msg);
817
+		}
818
+		// and that the requested page route exists
819
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
820
+			$this->_route = $this->_page_routes[ $this->_req_action ];
821
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
822
+				? $this->_page_config[ $this->_req_action ] : array();
823
+		} else {
824
+			// user error msg
825
+			$error_msg = sprintf(
826
+				esc_html__(
827
+					'The requested page route does not exist for the %s admin page.',
828
+					'event_espresso'
829
+				),
830
+				$this->_admin_page_title
831
+			);
832
+			// developer error msg
833
+			$error_msg .= '||' . $error_msg
834
+						  . sprintf(
835
+							  esc_html__(
836
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
837
+								  'event_espresso'
838
+							  ),
839
+							  $this->_req_action
840
+						  );
841
+			throw new EE_Error($error_msg);
842
+		}
843
+		// and that a default route exists
844
+		if (! array_key_exists('default', $this->_page_routes)) {
845
+			// user error msg
846
+			$error_msg = sprintf(
847
+				esc_html__(
848
+					'A default page route has not been set for the % admin page.',
849
+					'event_espresso'
850
+				),
851
+				$this->_admin_page_title
852
+			);
853
+			// developer error msg
854
+			$error_msg .= '||' . $error_msg
855
+						  . esc_html__(
856
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
857
+							  'event_espresso'
858
+						  );
859
+			throw new EE_Error($error_msg);
860
+		}
861
+		// first lets' catch if the UI request has EVER been set.
862
+		if ($this->_is_UI_request === null) {
863
+			// lets set if this is a UI request or not.
864
+			$this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
865
+			// wait a minute... we might have a noheader in the route array
866
+			$this->_is_UI_request = is_array($this->_route)
867
+									&& isset($this->_route['noheader'])
868
+									&& $this->_route['noheader'] ? false : $this->_is_UI_request;
869
+		}
870
+		$this->_set_current_labels();
871
+		return true;
872
+	}
873
+
874
+
875
+	/**
876
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
877
+	 *
878
+	 * @param  string $route the route name we're verifying
879
+	 * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
880
+	 * @throws EE_Error
881
+	 */
882
+	protected function _verify_route($route)
883
+	{
884
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
885
+			return true;
886
+		}
887
+		// user error msg
888
+		$error_msg = sprintf(
889
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
890
+			$this->_admin_page_title
891
+		);
892
+		// developer error msg
893
+		$error_msg .= '||' . $error_msg
894
+					  . sprintf(
895
+						  esc_html__(
896
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
897
+							  'event_espresso'
898
+						  ),
899
+						  $route
900
+					  );
901
+		throw new EE_Error($error_msg);
902
+	}
903
+
904
+
905
+	/**
906
+	 * perform nonce verification
907
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
908
+	 * using this method (and save retyping!)
909
+	 *
910
+	 * @param  string $nonce     The nonce sent
911
+	 * @param  string $nonce_ref The nonce reference string (name0)
912
+	 * @return void
913
+	 * @throws EE_Error
914
+	 */
915
+	protected function _verify_nonce($nonce, $nonce_ref)
916
+	{
917
+		// verify nonce against expected value
918
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
919
+			// these are not the droids you are looking for !!!
920
+			$msg = sprintf(
921
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
922
+				'<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
923
+				'</a>'
924
+			);
925
+			if (WP_DEBUG) {
926
+				$msg .= "\n  "
927
+						. sprintf(
928
+							esc_html__(
929
+								'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
930
+								'event_espresso'
931
+							),
932
+							__CLASS__
933
+						);
934
+			}
935
+			if (! defined('DOING_AJAX')) {
936
+				wp_die($msg);
937
+			} else {
938
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
939
+				$this->_return_json();
940
+			}
941
+		}
942
+	}
943
+
944
+
945
+	/**
946
+	 * _route_admin_request()
947
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
948
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
949
+	 * in the page routes and then will try to load the corresponding method.
950
+	 *
951
+	 * @return void
952
+	 * @throws EE_Error
953
+	 * @throws InvalidArgumentException
954
+	 * @throws InvalidDataTypeException
955
+	 * @throws InvalidInterfaceException
956
+	 * @throws ReflectionException
957
+	 */
958
+	protected function _route_admin_request()
959
+	{
960
+		if (! $this->_is_UI_request) {
961
+			$this->_verify_routes();
962
+		}
963
+		$nonce_check = isset($this->_route_config['require_nonce'])
964
+			? $this->_route_config['require_nonce']
965
+			: true;
966
+		if ($this->_req_action !== 'default' && $nonce_check) {
967
+			// set nonce from post data
968
+			$nonce = isset($this->_req_data[ $this->_req_nonce ])
969
+				? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
970
+				: '';
971
+			$this->_verify_nonce($nonce, $this->_req_nonce);
972
+		}
973
+		// set the nav_tabs array but ONLY if this is  UI_request
974
+		if ($this->_is_UI_request) {
975
+			$this->_set_nav_tabs();
976
+		}
977
+		// grab callback function
978
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
979
+		// check if callback has args
980
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
981
+		$error_msg = '';
982
+		// action right before calling route
983
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
984
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
985
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
986
+		}
987
+		// right before calling the route, let's remove _wp_http_referer from the
988
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
989
+		$_SERVER['REQUEST_URI'] = remove_query_arg(
990
+			'_wp_http_referer',
991
+			wp_unslash($_SERVER['REQUEST_URI'])
992
+		);
993
+		if (! empty($func)) {
994
+			if (is_array($func)) {
995
+				list($class, $method) = $func;
996
+			} elseif (strpos($func, '::') !== false) {
997
+				list($class, $method) = explode('::', $func);
998
+			} else {
999
+				$class = $this;
1000
+				$method = $func;
1001
+			}
1002
+			if (! (is_object($class) && $class === $this)) {
1003
+				// send along this admin page object for access by addons.
1004
+				$args['admin_page_object'] = $this;
1005
+			}
1006
+			if (// is it a method on a class that doesn't work?
1007
+				(
1008
+					(
1009
+						method_exists($class, $method)
1010
+						&& call_user_func_array(array($class, $method), $args) === false
1011
+					)
1012
+					&& (
1013
+						// is it a standalone function that doesn't work?
1014
+						function_exists($method)
1015
+						&& call_user_func_array(
1016
+							$func,
1017
+							array_merge(array('admin_page_object' => $this), $args)
1018
+						) === false
1019
+					)
1020
+				)
1021
+				|| (
1022
+					// is it neither a class method NOR a standalone function?
1023
+					! method_exists($class, $method)
1024
+					&& ! function_exists($method)
1025
+				)
1026
+			) {
1027
+				// user error msg
1028
+				$error_msg = esc_html__(
1029
+					'An error occurred. The  requested page route could not be found.',
1030
+					'event_espresso'
1031
+				);
1032
+				// developer error msg
1033
+				$error_msg .= '||';
1034
+				$error_msg .= sprintf(
1035
+					esc_html__(
1036
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1037
+						'event_espresso'
1038
+					),
1039
+					$method
1040
+				);
1041
+			}
1042
+			if (! empty($error_msg)) {
1043
+				throw new EE_Error($error_msg);
1044
+			}
1045
+		}
1046
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1047
+		// then we need to reset the routing properties to the new route.
1048
+		// now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1049
+		if ($this->_is_UI_request === false
1050
+			&& is_array($this->_route)
1051
+			&& ! empty($this->_route['headers_sent_route'])
1052
+		) {
1053
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1054
+		}
1055
+	}
1056
+
1057
+
1058
+	/**
1059
+	 * This method just allows the resetting of page properties in the case where a no headers
1060
+	 * route redirects to a headers route in its route config.
1061
+	 *
1062
+	 * @since   4.3.0
1063
+	 * @param  string $new_route New (non header) route to redirect to.
1064
+	 * @return   void
1065
+	 * @throws ReflectionException
1066
+	 * @throws InvalidArgumentException
1067
+	 * @throws InvalidInterfaceException
1068
+	 * @throws InvalidDataTypeException
1069
+	 * @throws EE_Error
1070
+	 */
1071
+	protected function _reset_routing_properties($new_route)
1072
+	{
1073
+		$this->_is_UI_request = true;
1074
+		// now we set the current route to whatever the headers_sent_route is set at
1075
+		$this->_req_data['action'] = $new_route;
1076
+		// rerun page setup
1077
+		$this->_page_setup();
1078
+	}
1079
+
1080
+
1081
+	/**
1082
+	 * _add_query_arg
1083
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1084
+	 *(internally just uses EEH_URL's function with the same name)
1085
+	 *
1086
+	 * @param array  $args
1087
+	 * @param string $url
1088
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1089
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1090
+	 *                                        Example usage: If the current page is:
1091
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1092
+	 *                                        &action=default&event_id=20&month_range=March%202015
1093
+	 *                                        &_wpnonce=5467821
1094
+	 *                                        and you call:
1095
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1096
+	 *                                        array(
1097
+	 *                                        'action' => 'resend_something',
1098
+	 *                                        'page=>espresso_registrations'
1099
+	 *                                        ),
1100
+	 *                                        $some_url,
1101
+	 *                                        true
1102
+	 *                                        );
1103
+	 *                                        It will produce a url in this structure:
1104
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1105
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1106
+	 *                                        month_range]=March%202015
1107
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1108
+	 * @return string
1109
+	 */
1110
+	public static function add_query_args_and_nonce(
1111
+		$args = array(),
1112
+		$url = false,
1113
+		$sticky = false,
1114
+		$exclude_nonce = false
1115
+	) {
1116
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1117
+		if ($sticky) {
1118
+			$request = $_REQUEST;
1119
+			unset($request['_wp_http_referer']);
1120
+			unset($request['wp_referer']);
1121
+			foreach ($request as $key => $value) {
1122
+				// do not add nonces
1123
+				if (strpos($key, 'nonce') !== false) {
1124
+					continue;
1125
+				}
1126
+				$args[ 'wp_referer[' . $key . ']' ] = $value;
1127
+			}
1128
+		}
1129
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1130
+	}
1131
+
1132
+
1133
+	/**
1134
+	 * This returns a generated link that will load the related help tab.
1135
+	 *
1136
+	 * @param  string $help_tab_id the id for the connected help tab
1137
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1138
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1139
+	 * @uses EEH_Template::get_help_tab_link()
1140
+	 * @return string              generated link
1141
+	 */
1142
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1143
+	{
1144
+		return EEH_Template::get_help_tab_link(
1145
+			$help_tab_id,
1146
+			$this->page_slug,
1147
+			$this->_req_action,
1148
+			$icon_style,
1149
+			$help_text
1150
+		);
1151
+	}
1152
+
1153
+
1154
+	/**
1155
+	 * _add_help_tabs
1156
+	 * Note child classes define their help tabs within the page_config array.
1157
+	 *
1158
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1159
+	 * @return void
1160
+	 * @throws DomainException
1161
+	 * @throws EE_Error
1162
+	 */
1163
+	protected function _add_help_tabs()
1164
+	{
1165
+		$tour_buttons = '';
1166
+		if (isset($this->_page_config[ $this->_req_action ])) {
1167
+			$config = $this->_page_config[ $this->_req_action ];
1168
+			// is there a help tour for the current route?  if there is let's setup the tour buttons
1169
+			if (isset($this->_help_tour[ $this->_req_action ])) {
1170
+				$tb = array();
1171
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1172
+				foreach ($this->_help_tour['tours'] as $tour) {
1173
+					// if this is the end tour then we don't need to setup a button
1174
+					if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1175
+						continue;
1176
+					}
1177
+					$tb[] = '<button id="trigger-tour-'
1178
+							. $tour->get_slug()
1179
+							. '" class="button-primary trigger-ee-help-tour">'
1180
+							. $tour->get_label()
1181
+							. '</button>';
1182
+				}
1183
+				$tour_buttons .= implode('<br />', $tb);
1184
+				$tour_buttons .= '</div></div>';
1185
+			}
1186
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1187
+			if (is_array($config) && isset($config['help_sidebar'])) {
1188
+				// check that the callback given is valid
1189
+				if (! method_exists($this, $config['help_sidebar'])) {
1190
+					throw new EE_Error(
1191
+						sprintf(
1192
+							esc_html__(
1193
+								'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1194
+								'event_espresso'
1195
+							),
1196
+							$config['help_sidebar'],
1197
+							get_class($this)
1198
+						)
1199
+					);
1200
+				}
1201
+				$content = apply_filters(
1202
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1203
+					$this->{$config['help_sidebar']}()
1204
+				);
1205
+				$content .= $tour_buttons; // add help tour buttons.
1206
+				// do we have any help tours setup?  Cause if we do we want to add the buttons
1207
+				$this->_current_screen->set_help_sidebar($content);
1208
+			}
1209
+			// if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1210
+			if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1211
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1212
+			}
1213
+			// handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1214
+			if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1215
+				$_ht['id'] = $this->page_slug;
1216
+				$_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1217
+				$_ht['content'] = '<p>'
1218
+								  . esc_html__(
1219
+									  'The buttons to the right allow you to start/restart any help tours available for this page',
1220
+									  'event_espresso'
1221
+								  ) . '</p>';
1222
+				$this->_current_screen->add_help_tab($_ht);
1223
+			}
1224
+			if (! isset($config['help_tabs'])) {
1225
+				return;
1226
+			} //no help tabs for this route
1227
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1228
+				// we're here so there ARE help tabs!
1229
+				// make sure we've got what we need
1230
+				if (! isset($cfg['title'])) {
1231
+					throw new EE_Error(
1232
+						esc_html__(
1233
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1234
+							'event_espresso'
1235
+						)
1236
+					);
1237
+				}
1238
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1239
+					throw new EE_Error(
1240
+						esc_html__(
1241
+							'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1242
+							'event_espresso'
1243
+						)
1244
+					);
1245
+				}
1246
+				// first priority goes to content.
1247
+				if (! empty($cfg['content'])) {
1248
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1249
+					// second priority goes to filename
1250
+				} elseif (! empty($cfg['filename'])) {
1251
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1252
+					// it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1253
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1254
+															 . basename($this->_get_dir())
1255
+															 . '/help_tabs/'
1256
+															 . $cfg['filename']
1257
+															 . '.help_tab.php' : $file_path;
1258
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1259
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1260
+						EE_Error::add_error(
1261
+							sprintf(
1262
+								esc_html__(
1263
+									'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1264
+									'event_espresso'
1265
+								),
1266
+								$tab_id,
1267
+								key($config),
1268
+								$file_path
1269
+							),
1270
+							__FILE__,
1271
+							__FUNCTION__,
1272
+							__LINE__
1273
+						);
1274
+						return;
1275
+					}
1276
+					$template_args['admin_page_obj'] = $this;
1277
+					$content = EEH_Template::display_template(
1278
+						$file_path,
1279
+						$template_args,
1280
+						true
1281
+					);
1282
+				} else {
1283
+					$content = '';
1284
+				}
1285
+				// check if callback is valid
1286
+				if (empty($content) && (
1287
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1288
+					)
1289
+				) {
1290
+					EE_Error::add_error(
1291
+						sprintf(
1292
+							esc_html__(
1293
+								'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1294
+								'event_espresso'
1295
+							),
1296
+							$cfg['title']
1297
+						),
1298
+						__FILE__,
1299
+						__FUNCTION__,
1300
+						__LINE__
1301
+					);
1302
+					return;
1303
+				}
1304
+				// setup config array for help tab method
1305
+				$id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1306
+				$_ht = array(
1307
+					'id'       => $id,
1308
+					'title'    => $cfg['title'],
1309
+					'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1310
+					'content'  => $content,
1311
+				);
1312
+				$this->_current_screen->add_help_tab($_ht);
1313
+			}
1314
+		}
1315
+	}
1316
+
1317
+
1318
+	/**
1319
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1320
+	 * an array with properties for setting up usage of the joyride plugin
1321
+	 *
1322
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1323
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1324
+	 *         _set_page_config() comments
1325
+	 * @return void
1326
+	 * @throws EE_Error
1327
+	 * @throws InvalidArgumentException
1328
+	 * @throws InvalidDataTypeException
1329
+	 * @throws InvalidInterfaceException
1330
+	 */
1331
+	protected function _add_help_tour()
1332
+	{
1333
+		$tours = array();
1334
+		$this->_help_tour = array();
1335
+		// exit early if help tours are turned off globally
1336
+		if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1337
+			|| ! EE_Registry::instance()->CFG->admin->help_tour_activation
1338
+		) {
1339
+			return;
1340
+		}
1341
+		// loop through _page_config to find any help_tour defined
1342
+		foreach ($this->_page_config as $route => $config) {
1343
+			// we're only going to set things up for this route
1344
+			if ($route !== $this->_req_action) {
1345
+				continue;
1346
+			}
1347
+			if (isset($config['help_tour'])) {
1348
+				foreach ($config['help_tour'] as $tour) {
1349
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1350
+					// let's see if we can get that file...
1351
+					// if not its possible this is a decaf route not set in caffeinated
1352
+					// so lets try and get the caffeinated equivalent
1353
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1354
+															 . basename($this->_get_dir())
1355
+															 . '/help_tours/'
1356
+															 . $tour
1357
+															 . '.class.php' : $file_path;
1358
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1359
+					if (! is_readable($file_path)) {
1360
+						EE_Error::add_error(
1361
+							sprintf(
1362
+								esc_html__(
1363
+									'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1364
+									'event_espresso'
1365
+								),
1366
+								$file_path,
1367
+								$tour
1368
+							),
1369
+							__FILE__,
1370
+							__FUNCTION__,
1371
+							__LINE__
1372
+						);
1373
+						return;
1374
+					}
1375
+					require_once $file_path;
1376
+					if (! class_exists($tour)) {
1377
+						$error_msg[] = sprintf(
1378
+							esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1379
+							$tour
1380
+						);
1381
+						$error_msg[] = $error_msg[0] . "\r\n"
1382
+									   . sprintf(
1383
+										   esc_html__(
1384
+											   'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1385
+											   'event_espresso'
1386
+										   ),
1387
+										   $tour,
1388
+										   '<br />',
1389
+										   $tour,
1390
+										   $this->_req_action,
1391
+										   get_class($this)
1392
+									   );
1393
+						throw new EE_Error(implode('||', $error_msg));
1394
+					}
1395
+					$tour_obj = new $tour($this->_is_caf);
1396
+					$tours[] = $tour_obj;
1397
+					$this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1398
+				}
1399
+				// let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1400
+				$end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1401
+				$tours[] = $end_stop_tour;
1402
+				$this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1403
+			}
1404
+		}
1405
+		if (! empty($tours)) {
1406
+			$this->_help_tour['tours'] = $tours;
1407
+		}
1408
+		// that's it!  Now that the $_help_tours property is set (or not)
1409
+		// the scripts and html should be taken care of automatically.
1410
+	}
1411
+
1412
+
1413
+	/**
1414
+	 * This simply sets up any qtips that have been defined in the page config
1415
+	 *
1416
+	 * @return void
1417
+	 */
1418
+	protected function _add_qtips()
1419
+	{
1420
+		if (isset($this->_route_config['qtips'])) {
1421
+			$qtips = (array) $this->_route_config['qtips'];
1422
+			// load qtip loader
1423
+			$path = array(
1424
+				$this->_get_dir() . '/qtips/',
1425
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1426
+			);
1427
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1428
+		}
1429
+	}
1430
+
1431
+
1432
+	/**
1433
+	 * _set_nav_tabs
1434
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1435
+	 * wish to add additional tabs or modify accordingly.
1436
+	 *
1437
+	 * @return void
1438
+	 * @throws InvalidArgumentException
1439
+	 * @throws InvalidInterfaceException
1440
+	 * @throws InvalidDataTypeException
1441
+	 */
1442
+	protected function _set_nav_tabs()
1443
+	{
1444
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1445
+		$i = 0;
1446
+		foreach ($this->_page_config as $slug => $config) {
1447
+			if (! is_array($config)
1448
+				|| (
1449
+					is_array($config)
1450
+					&& (
1451
+						(isset($config['nav']) && ! $config['nav'])
1452
+						|| ! isset($config['nav'])
1453
+					)
1454
+				)
1455
+			) {
1456
+				continue;
1457
+			}
1458
+			// no nav tab for this config
1459
+			// check for persistent flag
1460
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1461
+				// nav tab is only to appear when route requested.
1462
+				continue;
1463
+			}
1464
+			if (! $this->check_user_access($slug, true)) {
1465
+				// no nav tab because current user does not have access.
1466
+				continue;
1467
+			}
1468
+			$css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1469
+			$this->_nav_tabs[ $slug ] = array(
1470
+				'url'       => isset($config['nav']['url'])
1471
+					? $config['nav']['url']
1472
+					: self::add_query_args_and_nonce(
1473
+						array('action' => $slug),
1474
+						$this->_admin_base_url
1475
+					),
1476
+				'link_text' => isset($config['nav']['label'])
1477
+					? $config['nav']['label']
1478
+					: ucwords(
1479
+						str_replace('_', ' ', $slug)
1480
+					),
1481
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1482
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1483
+			);
1484
+			$i++;
1485
+		}
1486
+		// if $this->_nav_tabs is empty then lets set the default
1487
+		if (empty($this->_nav_tabs)) {
1488
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1489
+				'url'       => $this->_admin_base_url,
1490
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1491
+				'css_class' => 'nav-tab-active',
1492
+				'order'     => 10,
1493
+			);
1494
+		}
1495
+		// now let's sort the tabs according to order
1496
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1497
+	}
1498
+
1499
+
1500
+	/**
1501
+	 * _set_current_labels
1502
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1503
+	 * property array
1504
+	 *
1505
+	 * @return void
1506
+	 */
1507
+	private function _set_current_labels()
1508
+	{
1509
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1510
+			foreach ($this->_route_config['labels'] as $label => $text) {
1511
+				if (is_array($text)) {
1512
+					foreach ($text as $sublabel => $subtext) {
1513
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1514
+					}
1515
+				} else {
1516
+					$this->_labels[ $label ] = $text;
1517
+				}
1518
+			}
1519
+		}
1520
+	}
1521
+
1522
+
1523
+	/**
1524
+	 *        verifies user access for this admin page
1525
+	 *
1526
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1527
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1528
+	 *                               return false if verify fail.
1529
+	 * @return bool
1530
+	 * @throws InvalidArgumentException
1531
+	 * @throws InvalidDataTypeException
1532
+	 * @throws InvalidInterfaceException
1533
+	 */
1534
+	public function check_user_access($route_to_check = '', $verify_only = false)
1535
+	{
1536
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1537
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1538
+		$capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1539
+					  && is_array(
1540
+						  $this->_page_routes[ $route_to_check ]
1541
+					  )
1542
+					  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1543
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1544
+		if (empty($capability) && empty($route_to_check)) {
1545
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1546
+				: $this->_route['capability'];
1547
+		} else {
1548
+			$capability = empty($capability) ? 'manage_options' : $capability;
1549
+		}
1550
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1551
+		if (! defined('DOING_AJAX')
1552
+			&& (
1553
+				! function_exists('is_admin')
1554
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1555
+					$capability,
1556
+					$this->page_slug
1557
+					. '_'
1558
+					. $route_to_check,
1559
+					$id
1560
+				)
1561
+			)
1562
+		) {
1563
+			if ($verify_only) {
1564
+				return false;
1565
+			}
1566
+			if (is_user_logged_in()) {
1567
+				wp_die(__('You do not have access to this route.', 'event_espresso'));
1568
+			} else {
1569
+				return false;
1570
+			}
1571
+		}
1572
+		return true;
1573
+	}
1574
+
1575
+
1576
+	/**
1577
+	 * admin_init_global
1578
+	 * This runs all the code that we want executed within the WP admin_init hook.
1579
+	 * This method executes for ALL EE Admin pages.
1580
+	 *
1581
+	 * @return void
1582
+	 */
1583
+	public function admin_init_global()
1584
+	{
1585
+	}
1586
+
1587
+
1588
+	/**
1589
+	 * wp_loaded_global
1590
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1591
+	 * EE_Admin page and will execute on every EE Admin Page load
1592
+	 *
1593
+	 * @return void
1594
+	 */
1595
+	public function wp_loaded()
1596
+	{
1597
+	}
1598
+
1599
+
1600
+	/**
1601
+	 * admin_notices
1602
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1603
+	 * ALL EE_Admin pages.
1604
+	 *
1605
+	 * @return void
1606
+	 */
1607
+	public function admin_notices_global()
1608
+	{
1609
+		$this->_display_no_javascript_warning();
1610
+		$this->_display_espresso_notices();
1611
+	}
1612
+
1613
+
1614
+	public function network_admin_notices_global()
1615
+	{
1616
+		$this->_display_no_javascript_warning();
1617
+		$this->_display_espresso_notices();
1618
+	}
1619
+
1620
+
1621
+	/**
1622
+	 * admin_footer_scripts_global
1623
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1624
+	 * will apply on ALL EE_Admin pages.
1625
+	 *
1626
+	 * @return void
1627
+	 */
1628
+	public function admin_footer_scripts_global()
1629
+	{
1630
+		$this->_add_admin_page_ajax_loading_img();
1631
+		$this->_add_admin_page_overlay();
1632
+		// if metaboxes are present we need to add the nonce field
1633
+		if (isset($this->_route_config['metaboxes'])
1634
+			|| isset($this->_route_config['list_table'])
1635
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1636
+		) {
1637
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1638
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1639
+		}
1640
+	}
1641
+
1642
+
1643
+	/**
1644
+	 * admin_footer_global
1645
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1646
+	 * ALL EE_Admin Pages.
1647
+	 *
1648
+	 * @return void
1649
+	 * @throws EE_Error
1650
+	 */
1651
+	public function admin_footer_global()
1652
+	{
1653
+		// dialog container for dialog helper
1654
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1655
+		$d_cont .= '<div class="ee-notices"></div>';
1656
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1657
+		$d_cont .= '</div>';
1658
+		echo $d_cont;
1659
+		// help tour stuff?
1660
+		if (isset($this->_help_tour[ $this->_req_action ])) {
1661
+			echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1662
+		}
1663
+		// current set timezone for timezone js
1664
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1665
+	}
1666
+
1667
+
1668
+	/**
1669
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1670
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1671
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1672
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1673
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1674
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1675
+	 * for the
1676
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1677
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1678
+	 *    'help_trigger_id' => array(
1679
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1680
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1681
+	 *    )
1682
+	 * );
1683
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1684
+	 *
1685
+	 * @param array $help_array
1686
+	 * @param bool  $display
1687
+	 * @return string content
1688
+	 * @throws DomainException
1689
+	 * @throws EE_Error
1690
+	 */
1691
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1692
+	{
1693
+		$content = '';
1694
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1695
+		// loop through the array and setup content
1696
+		foreach ($help_array as $trigger => $help) {
1697
+			// make sure the array is setup properly
1698
+			if (! isset($help['title']) || ! isset($help['content'])) {
1699
+				throw new EE_Error(
1700
+					esc_html__(
1701
+						'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1702
+						'event_espresso'
1703
+					)
1704
+				);
1705
+			}
1706
+			// we're good so let'd setup the template vars and then assign parsed template content to our content.
1707
+			$template_args = array(
1708
+				'help_popup_id'      => $trigger,
1709
+				'help_popup_title'   => $help['title'],
1710
+				'help_popup_content' => $help['content'],
1711
+			);
1712
+			$content .= EEH_Template::display_template(
1713
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1714
+				$template_args,
1715
+				true
1716
+			);
1717
+		}
1718
+		if ($display) {
1719
+			echo $content;
1720
+			return '';
1721
+		}
1722
+		return $content;
1723
+	}
1724
+
1725
+
1726
+	/**
1727
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1728
+	 *
1729
+	 * @return array properly formatted array for help popup content
1730
+	 * @throws EE_Error
1731
+	 */
1732
+	private function _get_help_content()
1733
+	{
1734
+		// what is the method we're looking for?
1735
+		$method_name = '_help_popup_content_' . $this->_req_action;
1736
+		// if method doesn't exist let's get out.
1737
+		if (! method_exists($this, $method_name)) {
1738
+			return array();
1739
+		}
1740
+		// k we're good to go let's retrieve the help array
1741
+		$help_array = call_user_func(array($this, $method_name));
1742
+		// make sure we've got an array!
1743
+		if (! is_array($help_array)) {
1744
+			throw new EE_Error(
1745
+				esc_html__(
1746
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1747
+					'event_espresso'
1748
+				)
1749
+			);
1750
+		}
1751
+		return $help_array;
1752
+	}
1753
+
1754
+
1755
+	/**
1756
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1757
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1758
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1759
+	 *
1760
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1761
+	 * @param boolean $display    if false then we return the trigger string
1762
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1763
+	 * @return string
1764
+	 * @throws DomainException
1765
+	 * @throws EE_Error
1766
+	 */
1767
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1768
+	{
1769
+		if (defined('DOING_AJAX')) {
1770
+			return '';
1771
+		}
1772
+		// let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1773
+		$help_array = $this->_get_help_content();
1774
+		$help_content = '';
1775
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1776
+			$help_array[ $trigger_id ] = array(
1777
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1778
+				'content' => esc_html__(
1779
+					'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1780
+					'event_espresso'
1781
+				),
1782
+			);
1783
+			$help_content = $this->_set_help_popup_content($help_array, false);
1784
+		}
1785
+		// let's setup the trigger
1786
+		$content = '<a class="ee-dialog" href="?height='
1787
+				   . $dimensions[0]
1788
+				   . '&width='
1789
+				   . $dimensions[1]
1790
+				   . '&inlineId='
1791
+				   . $trigger_id
1792
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1793
+		$content .= $help_content;
1794
+		if ($display) {
1795
+			echo $content;
1796
+			return '';
1797
+		}
1798
+		return $content;
1799
+	}
1800
+
1801
+
1802
+	/**
1803
+	 * _add_global_screen_options
1804
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1805
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1806
+	 *
1807
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1808
+	 *         see also WP_Screen object documents...
1809
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1810
+	 * @abstract
1811
+	 * @return void
1812
+	 */
1813
+	private function _add_global_screen_options()
1814
+	{
1815
+	}
1816
+
1817
+
1818
+	/**
1819
+	 * _add_global_feature_pointers
1820
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1821
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1822
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1823
+	 *
1824
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1825
+	 *         extended) also see:
1826
+	 * @link   http://eamann.com/tech/wordpress-portland/
1827
+	 * @abstract
1828
+	 * @return void
1829
+	 */
1830
+	private function _add_global_feature_pointers()
1831
+	{
1832
+	}
1833
+
1834
+
1835
+	/**
1836
+	 * load_global_scripts_styles
1837
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1838
+	 *
1839
+	 * @return void
1840
+	 * @throws EE_Error
1841
+	 */
1842
+	public function load_global_scripts_styles()
1843
+	{
1844
+		/** STYLES **/
1845
+		// add debugging styles
1846
+		if (WP_DEBUG) {
1847
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1848
+		}
1849
+		// register all styles
1850
+		wp_register_style(
1851
+			'espresso-ui-theme',
1852
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1853
+			array(),
1854
+			EVENT_ESPRESSO_VERSION
1855
+		);
1856
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1857
+		// helpers styles
1858
+		wp_register_style(
1859
+			'ee-text-links',
1860
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1861
+			array(),
1862
+			EVENT_ESPRESSO_VERSION
1863
+		);
1864
+		/** SCRIPTS **/
1865
+		// register all scripts
1866
+		wp_register_script(
1867
+			'ee-dialog',
1868
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1869
+			array('jquery', 'jquery-ui-draggable'),
1870
+			EVENT_ESPRESSO_VERSION,
1871
+			true
1872
+		);
1873
+		wp_register_script(
1874
+			'ee_admin_js',
1875
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1876
+			array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1877
+			EVENT_ESPRESSO_VERSION,
1878
+			true
1879
+		);
1880
+		wp_register_script(
1881
+			'jquery-ui-timepicker-addon',
1882
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1883
+			array('jquery-ui-datepicker', 'jquery-ui-slider'),
1884
+			EVENT_ESPRESSO_VERSION,
1885
+			true
1886
+		);
1887
+		add_filter('FHEE_load_joyride', '__return_true');
1888
+		// script for sorting tables
1889
+		wp_register_script(
1890
+			'espresso_ajax_table_sorting',
1891
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1892
+			array('ee_admin_js', 'jquery-ui-sortable'),
1893
+			EVENT_ESPRESSO_VERSION,
1894
+			true
1895
+		);
1896
+		// script for parsing uri's
1897
+		wp_register_script(
1898
+			'ee-parse-uri',
1899
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1900
+			array(),
1901
+			EVENT_ESPRESSO_VERSION,
1902
+			true
1903
+		);
1904
+		// and parsing associative serialized form elements
1905
+		wp_register_script(
1906
+			'ee-serialize-full-array',
1907
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1908
+			array('jquery'),
1909
+			EVENT_ESPRESSO_VERSION,
1910
+			true
1911
+		);
1912
+		// helpers scripts
1913
+		wp_register_script(
1914
+			'ee-text-links',
1915
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1916
+			array('jquery'),
1917
+			EVENT_ESPRESSO_VERSION,
1918
+			true
1919
+		);
1920
+		wp_register_script(
1921
+			'ee-moment-core',
1922
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1923
+			array(),
1924
+			EVENT_ESPRESSO_VERSION,
1925
+			true
1926
+		);
1927
+		wp_register_script(
1928
+			'ee-moment',
1929
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1930
+			array('ee-moment-core'),
1931
+			EVENT_ESPRESSO_VERSION,
1932
+			true
1933
+		);
1934
+		wp_register_script(
1935
+			'ee-datepicker',
1936
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1937
+			array('jquery-ui-timepicker-addon', 'ee-moment'),
1938
+			EVENT_ESPRESSO_VERSION,
1939
+			true
1940
+		);
1941
+		// google charts
1942
+		wp_register_script(
1943
+			'google-charts',
1944
+			'https://www.gstatic.com/charts/loader.js',
1945
+			array(),
1946
+			EVENT_ESPRESSO_VERSION,
1947
+			false
1948
+		);
1949
+		// ENQUEUE ALL BASICS BY DEFAULT
1950
+		wp_enqueue_style('ee-admin-css');
1951
+		wp_enqueue_script('ee_admin_js');
1952
+		wp_enqueue_script('ee-accounting');
1953
+		wp_enqueue_script('jquery-validate');
1954
+		// taking care of metaboxes
1955
+		if (empty($this->_cpt_route)
1956
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1957
+		) {
1958
+			wp_enqueue_script('dashboard');
1959
+		}
1960
+		// LOCALIZED DATA
1961
+		// localize script for ajax lazy loading
1962
+		$lazy_loader_container_ids = apply_filters(
1963
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1964
+			array('espresso_news_post_box_content')
1965
+		);
1966
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1967
+		/**
1968
+		 * help tour stuff
1969
+		 */
1970
+		if (! empty($this->_help_tour)) {
1971
+			// register the js for kicking things off
1972
+			wp_enqueue_script(
1973
+				'ee-help-tour',
1974
+				EE_ADMIN_URL . 'assets/ee-help-tour.js',
1975
+				array('jquery-joyride'),
1976
+				EVENT_ESPRESSO_VERSION,
1977
+				true
1978
+			);
1979
+			$tours = array();
1980
+			// setup tours for the js tour object
1981
+			foreach ($this->_help_tour['tours'] as $tour) {
1982
+				if ($tour instanceof EE_Help_Tour) {
1983
+					$tours[] = array(
1984
+						'id'      => $tour->get_slug(),
1985
+						'options' => $tour->get_options(),
1986
+					);
1987
+				}
1988
+			}
1989
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1990
+			// admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1991
+		}
1992
+	}
1993
+
1994
+
1995
+	/**
1996
+	 *        admin_footer_scripts_eei18n_js_strings
1997
+	 *
1998
+	 * @return        void
1999
+	 */
2000
+	public function admin_footer_scripts_eei18n_js_strings()
2001
+	{
2002
+		EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
2003
+		EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2004
+			'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2005
+			'event_espresso'
2006
+		);
2007
+		EE_Registry::$i18n_js_strings['January'] = esc_html__('January', 'event_espresso');
2008
+		EE_Registry::$i18n_js_strings['February'] = esc_html__('February', 'event_espresso');
2009
+		EE_Registry::$i18n_js_strings['March'] = esc_html__('March', 'event_espresso');
2010
+		EE_Registry::$i18n_js_strings['April'] = esc_html__('April', 'event_espresso');
2011
+		EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2012
+		EE_Registry::$i18n_js_strings['June'] = esc_html__('June', 'event_espresso');
2013
+		EE_Registry::$i18n_js_strings['July'] = esc_html__('July', 'event_espresso');
2014
+		EE_Registry::$i18n_js_strings['August'] = esc_html__('August', 'event_espresso');
2015
+		EE_Registry::$i18n_js_strings['September'] = esc_html__('September', 'event_espresso');
2016
+		EE_Registry::$i18n_js_strings['October'] = esc_html__('October', 'event_espresso');
2017
+		EE_Registry::$i18n_js_strings['November'] = esc_html__('November', 'event_espresso');
2018
+		EE_Registry::$i18n_js_strings['December'] = esc_html__('December', 'event_espresso');
2019
+		EE_Registry::$i18n_js_strings['Jan'] = esc_html__('Jan', 'event_espresso');
2020
+		EE_Registry::$i18n_js_strings['Feb'] = esc_html__('Feb', 'event_espresso');
2021
+		EE_Registry::$i18n_js_strings['Mar'] = esc_html__('Mar', 'event_espresso');
2022
+		EE_Registry::$i18n_js_strings['Apr'] = esc_html__('Apr', 'event_espresso');
2023
+		EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2024
+		EE_Registry::$i18n_js_strings['Jun'] = esc_html__('Jun', 'event_espresso');
2025
+		EE_Registry::$i18n_js_strings['Jul'] = esc_html__('Jul', 'event_espresso');
2026
+		EE_Registry::$i18n_js_strings['Aug'] = esc_html__('Aug', 'event_espresso');
2027
+		EE_Registry::$i18n_js_strings['Sep'] = esc_html__('Sep', 'event_espresso');
2028
+		EE_Registry::$i18n_js_strings['Oct'] = esc_html__('Oct', 'event_espresso');
2029
+		EE_Registry::$i18n_js_strings['Nov'] = esc_html__('Nov', 'event_espresso');
2030
+		EE_Registry::$i18n_js_strings['Dec'] = esc_html__('Dec', 'event_espresso');
2031
+		EE_Registry::$i18n_js_strings['Sunday'] = esc_html__('Sunday', 'event_espresso');
2032
+		EE_Registry::$i18n_js_strings['Monday'] = esc_html__('Monday', 'event_espresso');
2033
+		EE_Registry::$i18n_js_strings['Tuesday'] = esc_html__('Tuesday', 'event_espresso');
2034
+		EE_Registry::$i18n_js_strings['Wednesday'] = esc_html__('Wednesday', 'event_espresso');
2035
+		EE_Registry::$i18n_js_strings['Thursday'] = esc_html__('Thursday', 'event_espresso');
2036
+		EE_Registry::$i18n_js_strings['Friday'] = esc_html__('Friday', 'event_espresso');
2037
+		EE_Registry::$i18n_js_strings['Saturday'] = esc_html__('Saturday', 'event_espresso');
2038
+		EE_Registry::$i18n_js_strings['Sun'] = esc_html__('Sun', 'event_espresso');
2039
+		EE_Registry::$i18n_js_strings['Mon'] = esc_html__('Mon', 'event_espresso');
2040
+		EE_Registry::$i18n_js_strings['Tue'] = esc_html__('Tue', 'event_espresso');
2041
+		EE_Registry::$i18n_js_strings['Wed'] = esc_html__('Wed', 'event_espresso');
2042
+		EE_Registry::$i18n_js_strings['Thu'] = esc_html__('Thu', 'event_espresso');
2043
+		EE_Registry::$i18n_js_strings['Fri'] = esc_html__('Fri', 'event_espresso');
2044
+		EE_Registry::$i18n_js_strings['Sat'] = esc_html__('Sat', 'event_espresso');
2045
+	}
2046
+
2047
+
2048
+	/**
2049
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2050
+	 *
2051
+	 * @return        void
2052
+	 */
2053
+	public function add_xdebug_style()
2054
+	{
2055
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2056
+	}
2057
+
2058
+
2059
+	/************************/
2060
+	/** LIST TABLE METHODS **/
2061
+	/************************/
2062
+	/**
2063
+	 * this sets up the list table if the current view requires it.
2064
+	 *
2065
+	 * @return void
2066
+	 * @throws EE_Error
2067
+	 */
2068
+	protected function _set_list_table()
2069
+	{
2070
+		// first is this a list_table view?
2071
+		if (! isset($this->_route_config['list_table'])) {
2072
+			return;
2073
+		} //not a list_table view so get out.
2074
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2075
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2076
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2077
+			// user error msg
2078
+			$error_msg = esc_html__(
2079
+				'An error occurred. The requested list table views could not be found.',
2080
+				'event_espresso'
2081
+			);
2082
+			// developer error msg
2083
+			$error_msg .= '||'
2084
+						  . sprintf(
2085
+							  esc_html__(
2086
+								  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2087
+								  'event_espresso'
2088
+							  ),
2089
+							  $this->_req_action,
2090
+							  $list_table_view
2091
+						  );
2092
+			throw new EE_Error($error_msg);
2093
+		}
2094
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2095
+		$this->_views = apply_filters(
2096
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2097
+			$this->_views
2098
+		);
2099
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2100
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2101
+		$this->_set_list_table_view();
2102
+		$this->_set_list_table_object();
2103
+	}
2104
+
2105
+
2106
+	/**
2107
+	 * set current view for List Table
2108
+	 *
2109
+	 * @return void
2110
+	 */
2111
+	protected function _set_list_table_view()
2112
+	{
2113
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2114
+		// looking at active items or dumpster diving ?
2115
+		if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2116
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2117
+		} else {
2118
+			$this->_view = sanitize_key($this->_req_data['status']);
2119
+		}
2120
+	}
2121
+
2122
+
2123
+	/**
2124
+	 * _set_list_table_object
2125
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2126
+	 *
2127
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2128
+	 * @throws \InvalidArgumentException
2129
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2130
+	 * @throws EE_Error
2131
+	 * @throws InvalidInterfaceException
2132
+	 */
2133
+	protected function _set_list_table_object()
2134
+	{
2135
+		if (isset($this->_route_config['list_table'])) {
2136
+			if (! class_exists($this->_route_config['list_table'])) {
2137
+				throw new EE_Error(
2138
+					sprintf(
2139
+						esc_html__(
2140
+							'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2141
+							'event_espresso'
2142
+						),
2143
+						$this->_route_config['list_table'],
2144
+						get_class($this)
2145
+					)
2146
+				);
2147
+			}
2148
+			$this->_list_table_object = $this->loader->getShared(
2149
+				$this->_route_config['list_table'],
2150
+				array($this)
2151
+			);
2152
+		}
2153
+	}
2154
+
2155
+
2156
+	/**
2157
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2158
+	 *
2159
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2160
+	 *                                                    urls.  The array should be indexed by the view it is being
2161
+	 *                                                    added to.
2162
+	 * @return array
2163
+	 */
2164
+	public function get_list_table_view_RLs($extra_query_args = array())
2165
+	{
2166
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2167
+		if (empty($this->_views)) {
2168
+			$this->_views = array();
2169
+		}
2170
+		// cycle thru views
2171
+		foreach ($this->_views as $key => $view) {
2172
+			$query_args = array();
2173
+			// check for current view
2174
+			$this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2175
+			$query_args['action'] = $this->_req_action;
2176
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2177
+			$query_args['status'] = $view['slug'];
2178
+			// merge any other arguments sent in.
2179
+			if (isset($extra_query_args[ $view['slug'] ])) {
2180
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2181
+			}
2182
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2183
+		}
2184
+		return $this->_views;
2185
+	}
2186
+
2187
+
2188
+	/**
2189
+	 * _entries_per_page_dropdown
2190
+	 * generates a drop down box for selecting the number of visible rows in an admin page list table
2191
+	 *
2192
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2193
+	 *         WP does it.
2194
+	 * @param int $max_entries total number of rows in the table
2195
+	 * @return string
2196
+	 */
2197
+	protected function _entries_per_page_dropdown($max_entries = 0)
2198
+	{
2199
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2200
+		$values = array(10, 25, 50, 100);
2201
+		$per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2202
+		if ($max_entries) {
2203
+			$values[] = $max_entries;
2204
+			sort($values);
2205
+		}
2206
+		$entries_per_page_dropdown = '
2207 2207
 			<div id="entries-per-page-dv" class="alignleft actions">
2208 2208
 				<label class="hide-if-no-js">
2209 2209
 					Show
2210 2210
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2211
-        foreach ($values as $value) {
2212
-            if ($value < $max_entries) {
2213
-                $selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2214
-                $entries_per_page_dropdown .= '
2211
+		foreach ($values as $value) {
2212
+			if ($value < $max_entries) {
2213
+				$selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2214
+				$entries_per_page_dropdown .= '
2215 2215
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2216
-            }
2217
-        }
2218
-        $selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2219
-        $entries_per_page_dropdown .= '
2216
+			}
2217
+		}
2218
+		$selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2219
+		$entries_per_page_dropdown .= '
2220 2220
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2221
-        $entries_per_page_dropdown .= '
2221
+		$entries_per_page_dropdown .= '
2222 2222
 					</select>
2223 2223
 					entries
2224 2224
 				</label>
2225 2225
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2226 2226
 			</div>
2227 2227
 		';
2228
-        return $entries_per_page_dropdown;
2229
-    }
2230
-
2231
-
2232
-    /**
2233
-     *        _set_search_attributes
2234
-     *
2235
-     * @return        void
2236
-     */
2237
-    public function _set_search_attributes()
2238
-    {
2239
-        $this->_template_args['search']['btn_label'] = sprintf(
2240
-            esc_html__('Search %s', 'event_espresso'),
2241
-            empty($this->_search_btn_label) ? $this->page_label
2242
-                : $this->_search_btn_label
2243
-        );
2244
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2245
-    }
2246
-
2247
-
2248
-
2249
-    /*** END LIST TABLE METHODS **/
2250
-
2251
-
2252
-    /**
2253
-     * _add_registered_metaboxes
2254
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2255
-     *
2256
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2257
-     * @return void
2258
-     * @throws EE_Error
2259
-     */
2260
-    private function _add_registered_meta_boxes()
2261
-    {
2262
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2263
-        // we only add meta boxes if the page_route calls for it
2264
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2265
-            && is_array(
2266
-                $this->_route_config['metaboxes']
2267
-            )
2268
-        ) {
2269
-            // this simply loops through the callbacks provided
2270
-            // and checks if there is a corresponding callback registered by the child
2271
-            // if there is then we go ahead and process the metabox loader.
2272
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2273
-                // first check for Closures
2274
-                if ($metabox_callback instanceof Closure) {
2275
-                    $result = $metabox_callback();
2276
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2277
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2278
-                } else {
2279
-                    $result = call_user_func(array($this, &$metabox_callback));
2280
-                }
2281
-                if ($result === false) {
2282
-                    // user error msg
2283
-                    $error_msg = esc_html__(
2284
-                        'An error occurred. The  requested metabox could not be found.',
2285
-                        'event_espresso'
2286
-                    );
2287
-                    // developer error msg
2288
-                    $error_msg .= '||'
2289
-                                  . sprintf(
2290
-                                      esc_html__(
2291
-                                          'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2292
-                                          'event_espresso'
2293
-                                      ),
2294
-                                      $metabox_callback
2295
-                                  );
2296
-                    throw new EE_Error($error_msg);
2297
-                }
2298
-            }
2299
-        }
2300
-    }
2301
-
2302
-
2303
-    /**
2304
-     * _add_screen_columns
2305
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2306
-     * the dynamic column template and we'll setup the column options for the page.
2307
-     *
2308
-     * @return void
2309
-     */
2310
-    private function _add_screen_columns()
2311
-    {
2312
-        if (is_array($this->_route_config)
2313
-            && isset($this->_route_config['columns'])
2314
-            && is_array($this->_route_config['columns'])
2315
-            && count($this->_route_config['columns']) === 2
2316
-        ) {
2317
-            add_screen_option(
2318
-                'layout_columns',
2319
-                array(
2320
-                    'max'     => (int) $this->_route_config['columns'][0],
2321
-                    'default' => (int) $this->_route_config['columns'][1],
2322
-                )
2323
-            );
2324
-            $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
2325
-            $screen_id = $this->_current_screen->id;
2326
-            $screen_columns = (int) get_user_option("screen_layout_{$screen_id}");
2327
-            $total_columns = ! empty($screen_columns)
2328
-                ? $screen_columns
2329
-                : $this->_route_config['columns'][1];
2330
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2331
-            $this->_template_args['current_page'] = $this->_wp_page_slug;
2332
-            $this->_template_args['screen'] = $this->_current_screen;
2333
-            $this->_column_template_path = EE_ADMIN_TEMPLATE
2334
-                                           . 'admin_details_metabox_column_wrapper.template.php';
2335
-            // finally if we don't have has_metaboxes set in the route config
2336
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2337
-            $this->_route_config['has_metaboxes'] = true;
2338
-        }
2339
-    }
2340
-
2341
-
2342
-
2343
-    /** GLOBALLY AVAILABLE METABOXES **/
2344
-
2345
-
2346
-    /**
2347
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2348
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2349
-     * these get loaded on.
2350
-     */
2351
-    private function _espresso_news_post_box()
2352
-    {
2353
-        $news_box_title = apply_filters(
2354
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2355
-            esc_html__('New @ Event Espresso', 'event_espresso')
2356
-        );
2357
-        add_meta_box(
2358
-            'espresso_news_post_box',
2359
-            $news_box_title,
2360
-            array(
2361
-                $this,
2362
-                'espresso_news_post_box',
2363
-            ),
2364
-            $this->_wp_page_slug,
2365
-            'side'
2366
-        );
2367
-    }
2368
-
2369
-
2370
-    /**
2371
-     * Code for setting up espresso ratings request metabox.
2372
-     */
2373
-    protected function _espresso_ratings_request()
2374
-    {
2375
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2376
-            return;
2377
-        }
2378
-        $ratings_box_title = apply_filters(
2379
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2380
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2381
-        );
2382
-        add_meta_box(
2383
-            'espresso_ratings_request',
2384
-            $ratings_box_title,
2385
-            array(
2386
-                $this,
2387
-                'espresso_ratings_request',
2388
-            ),
2389
-            $this->_wp_page_slug,
2390
-            'side'
2391
-        );
2392
-    }
2393
-
2394
-
2395
-    /**
2396
-     * Code for setting up espresso ratings request metabox content.
2397
-     *
2398
-     * @throws DomainException
2399
-     */
2400
-    public function espresso_ratings_request()
2401
-    {
2402
-        EEH_Template::display_template(
2403
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2404
-            array()
2405
-        );
2406
-    }
2407
-
2408
-
2409
-    public static function cached_rss_display($rss_id, $url)
2410
-    {
2411
-        $loading = '<p class="widget-loading hide-if-no-js">'
2412
-                   . __('Loading&#8230;', 'event_espresso')
2413
-                   . '</p><p class="hide-if-js">'
2414
-                   . esc_html__('This widget requires JavaScript.', 'event_espresso')
2415
-                   . '</p>';
2416
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
2417
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2418
-        $post = '</div>' . "\n";
2419
-        $cache_key = 'ee_rss_' . md5($rss_id);
2420
-        $output = get_transient($cache_key);
2421
-        if ($output !== false) {
2422
-            echo $pre . $output . $post;
2423
-            return true;
2424
-        }
2425
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2426
-            echo $pre . $loading . $post;
2427
-            return false;
2428
-        }
2429
-        ob_start();
2430
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2431
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2432
-        return true;
2433
-    }
2434
-
2435
-
2436
-    public function espresso_news_post_box()
2437
-    {
2438
-        ?>
2228
+		return $entries_per_page_dropdown;
2229
+	}
2230
+
2231
+
2232
+	/**
2233
+	 *        _set_search_attributes
2234
+	 *
2235
+	 * @return        void
2236
+	 */
2237
+	public function _set_search_attributes()
2238
+	{
2239
+		$this->_template_args['search']['btn_label'] = sprintf(
2240
+			esc_html__('Search %s', 'event_espresso'),
2241
+			empty($this->_search_btn_label) ? $this->page_label
2242
+				: $this->_search_btn_label
2243
+		);
2244
+		$this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2245
+	}
2246
+
2247
+
2248
+
2249
+	/*** END LIST TABLE METHODS **/
2250
+
2251
+
2252
+	/**
2253
+	 * _add_registered_metaboxes
2254
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2255
+	 *
2256
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2257
+	 * @return void
2258
+	 * @throws EE_Error
2259
+	 */
2260
+	private function _add_registered_meta_boxes()
2261
+	{
2262
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2263
+		// we only add meta boxes if the page_route calls for it
2264
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2265
+			&& is_array(
2266
+				$this->_route_config['metaboxes']
2267
+			)
2268
+		) {
2269
+			// this simply loops through the callbacks provided
2270
+			// and checks if there is a corresponding callback registered by the child
2271
+			// if there is then we go ahead and process the metabox loader.
2272
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2273
+				// first check for Closures
2274
+				if ($metabox_callback instanceof Closure) {
2275
+					$result = $metabox_callback();
2276
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2277
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2278
+				} else {
2279
+					$result = call_user_func(array($this, &$metabox_callback));
2280
+				}
2281
+				if ($result === false) {
2282
+					// user error msg
2283
+					$error_msg = esc_html__(
2284
+						'An error occurred. The  requested metabox could not be found.',
2285
+						'event_espresso'
2286
+					);
2287
+					// developer error msg
2288
+					$error_msg .= '||'
2289
+								  . sprintf(
2290
+									  esc_html__(
2291
+										  'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2292
+										  'event_espresso'
2293
+									  ),
2294
+									  $metabox_callback
2295
+								  );
2296
+					throw new EE_Error($error_msg);
2297
+				}
2298
+			}
2299
+		}
2300
+	}
2301
+
2302
+
2303
+	/**
2304
+	 * _add_screen_columns
2305
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2306
+	 * the dynamic column template and we'll setup the column options for the page.
2307
+	 *
2308
+	 * @return void
2309
+	 */
2310
+	private function _add_screen_columns()
2311
+	{
2312
+		if (is_array($this->_route_config)
2313
+			&& isset($this->_route_config['columns'])
2314
+			&& is_array($this->_route_config['columns'])
2315
+			&& count($this->_route_config['columns']) === 2
2316
+		) {
2317
+			add_screen_option(
2318
+				'layout_columns',
2319
+				array(
2320
+					'max'     => (int) $this->_route_config['columns'][0],
2321
+					'default' => (int) $this->_route_config['columns'][1],
2322
+				)
2323
+			);
2324
+			$this->_template_args['num_columns'] = $this->_route_config['columns'][0];
2325
+			$screen_id = $this->_current_screen->id;
2326
+			$screen_columns = (int) get_user_option("screen_layout_{$screen_id}");
2327
+			$total_columns = ! empty($screen_columns)
2328
+				? $screen_columns
2329
+				: $this->_route_config['columns'][1];
2330
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2331
+			$this->_template_args['current_page'] = $this->_wp_page_slug;
2332
+			$this->_template_args['screen'] = $this->_current_screen;
2333
+			$this->_column_template_path = EE_ADMIN_TEMPLATE
2334
+										   . 'admin_details_metabox_column_wrapper.template.php';
2335
+			// finally if we don't have has_metaboxes set in the route config
2336
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2337
+			$this->_route_config['has_metaboxes'] = true;
2338
+		}
2339
+	}
2340
+
2341
+
2342
+
2343
+	/** GLOBALLY AVAILABLE METABOXES **/
2344
+
2345
+
2346
+	/**
2347
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2348
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2349
+	 * these get loaded on.
2350
+	 */
2351
+	private function _espresso_news_post_box()
2352
+	{
2353
+		$news_box_title = apply_filters(
2354
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2355
+			esc_html__('New @ Event Espresso', 'event_espresso')
2356
+		);
2357
+		add_meta_box(
2358
+			'espresso_news_post_box',
2359
+			$news_box_title,
2360
+			array(
2361
+				$this,
2362
+				'espresso_news_post_box',
2363
+			),
2364
+			$this->_wp_page_slug,
2365
+			'side'
2366
+		);
2367
+	}
2368
+
2369
+
2370
+	/**
2371
+	 * Code for setting up espresso ratings request metabox.
2372
+	 */
2373
+	protected function _espresso_ratings_request()
2374
+	{
2375
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2376
+			return;
2377
+		}
2378
+		$ratings_box_title = apply_filters(
2379
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2380
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2381
+		);
2382
+		add_meta_box(
2383
+			'espresso_ratings_request',
2384
+			$ratings_box_title,
2385
+			array(
2386
+				$this,
2387
+				'espresso_ratings_request',
2388
+			),
2389
+			$this->_wp_page_slug,
2390
+			'side'
2391
+		);
2392
+	}
2393
+
2394
+
2395
+	/**
2396
+	 * Code for setting up espresso ratings request metabox content.
2397
+	 *
2398
+	 * @throws DomainException
2399
+	 */
2400
+	public function espresso_ratings_request()
2401
+	{
2402
+		EEH_Template::display_template(
2403
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2404
+			array()
2405
+		);
2406
+	}
2407
+
2408
+
2409
+	public static function cached_rss_display($rss_id, $url)
2410
+	{
2411
+		$loading = '<p class="widget-loading hide-if-no-js">'
2412
+				   . __('Loading&#8230;', 'event_espresso')
2413
+				   . '</p><p class="hide-if-js">'
2414
+				   . esc_html__('This widget requires JavaScript.', 'event_espresso')
2415
+				   . '</p>';
2416
+		$pre = '<div class="espresso-rss-display">' . "\n\t";
2417
+		$pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2418
+		$post = '</div>' . "\n";
2419
+		$cache_key = 'ee_rss_' . md5($rss_id);
2420
+		$output = get_transient($cache_key);
2421
+		if ($output !== false) {
2422
+			echo $pre . $output . $post;
2423
+			return true;
2424
+		}
2425
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2426
+			echo $pre . $loading . $post;
2427
+			return false;
2428
+		}
2429
+		ob_start();
2430
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2431
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2432
+		return true;
2433
+	}
2434
+
2435
+
2436
+	public function espresso_news_post_box()
2437
+	{
2438
+		?>
2439 2439
         <div class="padding">
2440 2440
             <div id="espresso_news_post_box_content" class="infolinks">
2441 2441
                 <?php
2442
-                // Get RSS Feed(s)
2443
-                self::cached_rss_display(
2444
-                    'espresso_news_post_box_content',
2445
-                    urlencode(
2446
-                        apply_filters(
2447
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2448
-                            'http://eventespresso.com/feed/'
2449
-                        )
2450
-                    )
2451
-                );
2452
-                ?>
2442
+				// Get RSS Feed(s)
2443
+				self::cached_rss_display(
2444
+					'espresso_news_post_box_content',
2445
+					urlencode(
2446
+						apply_filters(
2447
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2448
+							'http://eventespresso.com/feed/'
2449
+						)
2450
+					)
2451
+				);
2452
+				?>
2453 2453
             </div>
2454 2454
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2455 2455
         </div>
2456 2456
         <?php
2457
-    }
2458
-
2459
-
2460
-    private function _espresso_links_post_box()
2461
-    {
2462
-        // Hiding until we actually have content to put in here...
2463
-        // add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2464
-    }
2465
-
2466
-
2467
-    public function espresso_links_post_box()
2468
-    {
2469
-        // Hiding until we actually have content to put in here...
2470
-        // EEH_Template::display_template(
2471
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2472
-        // );
2473
-    }
2474
-
2475
-
2476
-    protected function _espresso_sponsors_post_box()
2477
-    {
2478
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2479
-            add_meta_box(
2480
-                'espresso_sponsors_post_box',
2481
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2482
-                array($this, 'espresso_sponsors_post_box'),
2483
-                $this->_wp_page_slug,
2484
-                'side'
2485
-            );
2486
-        }
2487
-    }
2488
-
2489
-
2490
-    public function espresso_sponsors_post_box()
2491
-    {
2492
-        EEH_Template::display_template(
2493
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2494
-        );
2495
-    }
2496
-
2497
-
2498
-    private function _publish_post_box()
2499
-    {
2500
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2501
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2502
-        // then we'll use that for the metabox label.
2503
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2504
-        if (! empty($this->_labels['publishbox'])) {
2505
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2506
-                : $this->_labels['publishbox'];
2507
-        } else {
2508
-            $box_label = esc_html__('Publish', 'event_espresso');
2509
-        }
2510
-        $box_label = apply_filters(
2511
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2512
-            $box_label,
2513
-            $this->_req_action,
2514
-            $this
2515
-        );
2516
-        add_meta_box(
2517
-            $meta_box_ref,
2518
-            $box_label,
2519
-            array($this, 'editor_overview'),
2520
-            $this->_current_screen->id,
2521
-            'side',
2522
-            'high'
2523
-        );
2524
-    }
2525
-
2526
-
2527
-    public function editor_overview()
2528
-    {
2529
-        // if we have extra content set let's add it in if not make sure its empty
2530
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2531
-            ? $this->_template_args['publish_box_extra_content']
2532
-            : '';
2533
-        echo EEH_Template::display_template(
2534
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2535
-            $this->_template_args,
2536
-            true
2537
-        );
2538
-    }
2539
-
2540
-
2541
-    /** end of globally available metaboxes section **/
2542
-
2543
-
2544
-    /**
2545
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2546
-     * protected method.
2547
-     *
2548
-     * @see   $this->_set_publish_post_box_vars for param details
2549
-     * @since 4.6.0
2550
-     * @param string $name
2551
-     * @param int    $id
2552
-     * @param bool   $delete
2553
-     * @param string $save_close_redirect_URL
2554
-     * @param bool   $both_btns
2555
-     * @throws EE_Error
2556
-     * @throws InvalidArgumentException
2557
-     * @throws InvalidDataTypeException
2558
-     * @throws InvalidInterfaceException
2559
-     */
2560
-    public function set_publish_post_box_vars(
2561
-        $name = '',
2562
-        $id = 0,
2563
-        $delete = false,
2564
-        $save_close_redirect_URL = '',
2565
-        $both_btns = true
2566
-    ) {
2567
-        $this->_set_publish_post_box_vars(
2568
-            $name,
2569
-            $id,
2570
-            $delete,
2571
-            $save_close_redirect_URL,
2572
-            $both_btns
2573
-        );
2574
-    }
2575
-
2576
-
2577
-    /**
2578
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2579
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2580
-     * save, and save and close buttons to work properly, then you will want to include a
2581
-     * values for the name and id arguments.
2582
-     *
2583
-     * @todo  Add in validation for name/id arguments.
2584
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2585
-     * @param    int     $id                      id attached to the item published
2586
-     * @param    string  $delete                  page route callback for the delete action
2587
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2588
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2589
-     *                                            the Save button
2590
-     * @throws EE_Error
2591
-     * @throws InvalidArgumentException
2592
-     * @throws InvalidDataTypeException
2593
-     * @throws InvalidInterfaceException
2594
-     */
2595
-    protected function _set_publish_post_box_vars(
2596
-        $name = '',
2597
-        $id = 0,
2598
-        $delete = '',
2599
-        $save_close_redirect_URL = '',
2600
-        $both_btns = true
2601
-    ) {
2602
-        // if Save & Close, use a custom redirect URL or default to the main page?
2603
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2604
-            ? $save_close_redirect_URL
2605
-            : $this->_admin_base_url;
2606
-        // create the Save & Close and Save buttons
2607
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2608
-        // if we have extra content set let's add it in if not make sure its empty
2609
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2610
-            ? $this->_template_args['publish_box_extra_content']
2611
-            : '';
2612
-        if ($delete && ! empty($id)) {
2613
-            // make sure we have a default if just true is sent.
2614
-            $delete = ! empty($delete) ? $delete : 'delete';
2615
-            $delete_link_args = array($name => $id);
2616
-            $delete = $this->get_action_link_or_button(
2617
-                $delete,
2618
-                $delete,
2619
-                $delete_link_args,
2620
-                'submitdelete deletion',
2621
-                '',
2622
-                false
2623
-            );
2624
-        }
2625
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2626
-        if (! empty($name) && ! empty($id)) {
2627
-            $hidden_field_arr[ $name ] = array(
2628
-                'type'  => 'hidden',
2629
-                'value' => $id,
2630
-            );
2631
-            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2632
-        } else {
2633
-            $hf = '';
2634
-        }
2635
-        // add hidden field
2636
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2637
-            ? $hf[ $name ]['field']
2638
-            : $hf;
2639
-    }
2640
-
2641
-
2642
-    /**
2643
-     * displays an error message to ppl who have javascript disabled
2644
-     *
2645
-     * @return void
2646
-     */
2647
-    private function _display_no_javascript_warning()
2648
-    {
2649
-        ?>
2457
+	}
2458
+
2459
+
2460
+	private function _espresso_links_post_box()
2461
+	{
2462
+		// Hiding until we actually have content to put in here...
2463
+		// add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2464
+	}
2465
+
2466
+
2467
+	public function espresso_links_post_box()
2468
+	{
2469
+		// Hiding until we actually have content to put in here...
2470
+		// EEH_Template::display_template(
2471
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2472
+		// );
2473
+	}
2474
+
2475
+
2476
+	protected function _espresso_sponsors_post_box()
2477
+	{
2478
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2479
+			add_meta_box(
2480
+				'espresso_sponsors_post_box',
2481
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2482
+				array($this, 'espresso_sponsors_post_box'),
2483
+				$this->_wp_page_slug,
2484
+				'side'
2485
+			);
2486
+		}
2487
+	}
2488
+
2489
+
2490
+	public function espresso_sponsors_post_box()
2491
+	{
2492
+		EEH_Template::display_template(
2493
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2494
+		);
2495
+	}
2496
+
2497
+
2498
+	private function _publish_post_box()
2499
+	{
2500
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2501
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2502
+		// then we'll use that for the metabox label.
2503
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2504
+		if (! empty($this->_labels['publishbox'])) {
2505
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2506
+				: $this->_labels['publishbox'];
2507
+		} else {
2508
+			$box_label = esc_html__('Publish', 'event_espresso');
2509
+		}
2510
+		$box_label = apply_filters(
2511
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2512
+			$box_label,
2513
+			$this->_req_action,
2514
+			$this
2515
+		);
2516
+		add_meta_box(
2517
+			$meta_box_ref,
2518
+			$box_label,
2519
+			array($this, 'editor_overview'),
2520
+			$this->_current_screen->id,
2521
+			'side',
2522
+			'high'
2523
+		);
2524
+	}
2525
+
2526
+
2527
+	public function editor_overview()
2528
+	{
2529
+		// if we have extra content set let's add it in if not make sure its empty
2530
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2531
+			? $this->_template_args['publish_box_extra_content']
2532
+			: '';
2533
+		echo EEH_Template::display_template(
2534
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2535
+			$this->_template_args,
2536
+			true
2537
+		);
2538
+	}
2539
+
2540
+
2541
+	/** end of globally available metaboxes section **/
2542
+
2543
+
2544
+	/**
2545
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2546
+	 * protected method.
2547
+	 *
2548
+	 * @see   $this->_set_publish_post_box_vars for param details
2549
+	 * @since 4.6.0
2550
+	 * @param string $name
2551
+	 * @param int    $id
2552
+	 * @param bool   $delete
2553
+	 * @param string $save_close_redirect_URL
2554
+	 * @param bool   $both_btns
2555
+	 * @throws EE_Error
2556
+	 * @throws InvalidArgumentException
2557
+	 * @throws InvalidDataTypeException
2558
+	 * @throws InvalidInterfaceException
2559
+	 */
2560
+	public function set_publish_post_box_vars(
2561
+		$name = '',
2562
+		$id = 0,
2563
+		$delete = false,
2564
+		$save_close_redirect_URL = '',
2565
+		$both_btns = true
2566
+	) {
2567
+		$this->_set_publish_post_box_vars(
2568
+			$name,
2569
+			$id,
2570
+			$delete,
2571
+			$save_close_redirect_URL,
2572
+			$both_btns
2573
+		);
2574
+	}
2575
+
2576
+
2577
+	/**
2578
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2579
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2580
+	 * save, and save and close buttons to work properly, then you will want to include a
2581
+	 * values for the name and id arguments.
2582
+	 *
2583
+	 * @todo  Add in validation for name/id arguments.
2584
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2585
+	 * @param    int     $id                      id attached to the item published
2586
+	 * @param    string  $delete                  page route callback for the delete action
2587
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2588
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2589
+	 *                                            the Save button
2590
+	 * @throws EE_Error
2591
+	 * @throws InvalidArgumentException
2592
+	 * @throws InvalidDataTypeException
2593
+	 * @throws InvalidInterfaceException
2594
+	 */
2595
+	protected function _set_publish_post_box_vars(
2596
+		$name = '',
2597
+		$id = 0,
2598
+		$delete = '',
2599
+		$save_close_redirect_URL = '',
2600
+		$both_btns = true
2601
+	) {
2602
+		// if Save & Close, use a custom redirect URL or default to the main page?
2603
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2604
+			? $save_close_redirect_URL
2605
+			: $this->_admin_base_url;
2606
+		// create the Save & Close and Save buttons
2607
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2608
+		// if we have extra content set let's add it in if not make sure its empty
2609
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2610
+			? $this->_template_args['publish_box_extra_content']
2611
+			: '';
2612
+		if ($delete && ! empty($id)) {
2613
+			// make sure we have a default if just true is sent.
2614
+			$delete = ! empty($delete) ? $delete : 'delete';
2615
+			$delete_link_args = array($name => $id);
2616
+			$delete = $this->get_action_link_or_button(
2617
+				$delete,
2618
+				$delete,
2619
+				$delete_link_args,
2620
+				'submitdelete deletion',
2621
+				'',
2622
+				false
2623
+			);
2624
+		}
2625
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2626
+		if (! empty($name) && ! empty($id)) {
2627
+			$hidden_field_arr[ $name ] = array(
2628
+				'type'  => 'hidden',
2629
+				'value' => $id,
2630
+			);
2631
+			$hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2632
+		} else {
2633
+			$hf = '';
2634
+		}
2635
+		// add hidden field
2636
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2637
+			? $hf[ $name ]['field']
2638
+			: $hf;
2639
+	}
2640
+
2641
+
2642
+	/**
2643
+	 * displays an error message to ppl who have javascript disabled
2644
+	 *
2645
+	 * @return void
2646
+	 */
2647
+	private function _display_no_javascript_warning()
2648
+	{
2649
+		?>
2650 2650
         <noscript>
2651 2651
             <div id="no-js-message" class="error">
2652 2652
                 <p style="font-size:1.3em;">
2653 2653
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2654 2654
                     <?php esc_html_e(
2655
-                        'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2656
-                        'event_espresso'
2657
-                    ); ?>
2655
+						'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2656
+						'event_espresso'
2657
+					); ?>
2658 2658
                 </p>
2659 2659
             </div>
2660 2660
         </noscript>
2661 2661
         <?php
2662
-    }
2663
-
2664
-
2665
-    /**
2666
-     * displays espresso success and/or error notices
2667
-     *
2668
-     * @return void
2669
-     */
2670
-    private function _display_espresso_notices()
2671
-    {
2672
-        $notices = $this->_get_transient(true);
2673
-        echo stripslashes($notices);
2674
-    }
2675
-
2676
-
2677
-    /**
2678
-     * spinny things pacify the masses
2679
-     *
2680
-     * @return void
2681
-     */
2682
-    protected function _add_admin_page_ajax_loading_img()
2683
-    {
2684
-        ?>
2662
+	}
2663
+
2664
+
2665
+	/**
2666
+	 * displays espresso success and/or error notices
2667
+	 *
2668
+	 * @return void
2669
+	 */
2670
+	private function _display_espresso_notices()
2671
+	{
2672
+		$notices = $this->_get_transient(true);
2673
+		echo stripslashes($notices);
2674
+	}
2675
+
2676
+
2677
+	/**
2678
+	 * spinny things pacify the masses
2679
+	 *
2680
+	 * @return void
2681
+	 */
2682
+	protected function _add_admin_page_ajax_loading_img()
2683
+	{
2684
+		?>
2685 2685
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2686 2686
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2687
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2687
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2688 2688
         </div>
2689 2689
         <?php
2690
-    }
2690
+	}
2691 2691
 
2692 2692
 
2693
-    /**
2694
-     * add admin page overlay for modal boxes
2695
-     *
2696
-     * @return void
2697
-     */
2698
-    protected function _add_admin_page_overlay()
2699
-    {
2700
-        ?>
2693
+	/**
2694
+	 * add admin page overlay for modal boxes
2695
+	 *
2696
+	 * @return void
2697
+	 */
2698
+	protected function _add_admin_page_overlay()
2699
+	{
2700
+		?>
2701 2701
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2702 2702
         <?php
2703
-    }
2704
-
2705
-
2706
-    /**
2707
-     * facade for add_meta_box
2708
-     *
2709
-     * @param string  $action        where the metabox get's displayed
2710
-     * @param string  $title         Title of Metabox (output in metabox header)
2711
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2712
-     *                               instead of the one created in here.
2713
-     * @param array   $callback_args an array of args supplied for the metabox
2714
-     * @param string  $column        what metabox column
2715
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2716
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2717
-     *                               created but just set our own callback for wp's add_meta_box.
2718
-     * @throws \DomainException
2719
-     */
2720
-    public function _add_admin_page_meta_box(
2721
-        $action,
2722
-        $title,
2723
-        $callback,
2724
-        $callback_args,
2725
-        $column = 'normal',
2726
-        $priority = 'high',
2727
-        $create_func = true
2728
-    ) {
2729
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2730
-        // if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2731
-        if (empty($callback_args) && $create_func) {
2732
-            $callback_args = array(
2733
-                'template_path' => $this->_template_path,
2734
-                'template_args' => $this->_template_args,
2735
-            );
2736
-        }
2737
-        // if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2738
-        $call_back_func = $create_func
2739
-            ? function ($post, $metabox) {
2740
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2741
-                echo EEH_Template::display_template(
2742
-                    $metabox['args']['template_path'],
2743
-                    $metabox['args']['template_args'],
2744
-                    true
2745
-                );
2746
-            }
2747
-            : $callback;
2748
-        add_meta_box(
2749
-            str_replace('_', '-', $action) . '-mbox',
2750
-            $title,
2751
-            $call_back_func,
2752
-            $this->_wp_page_slug,
2753
-            $column,
2754
-            $priority,
2755
-            $callback_args
2756
-        );
2757
-    }
2758
-
2759
-
2760
-    /**
2761
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2762
-     *
2763
-     * @throws DomainException
2764
-     * @throws EE_Error
2765
-     */
2766
-    public function display_admin_page_with_metabox_columns()
2767
-    {
2768
-        $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2769
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2770
-            $this->_column_template_path,
2771
-            $this->_template_args,
2772
-            true
2773
-        );
2774
-        // the final wrapper
2775
-        $this->admin_page_wrapper();
2776
-    }
2777
-
2778
-
2779
-    /**
2780
-     * generates  HTML wrapper for an admin details page
2781
-     *
2782
-     * @return void
2783
-     * @throws EE_Error
2784
-     * @throws DomainException
2785
-     */
2786
-    public function display_admin_page_with_sidebar()
2787
-    {
2788
-        $this->_display_admin_page(true);
2789
-    }
2790
-
2791
-
2792
-    /**
2793
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2794
-     *
2795
-     * @return void
2796
-     * @throws EE_Error
2797
-     * @throws DomainException
2798
-     */
2799
-    public function display_admin_page_with_no_sidebar()
2800
-    {
2801
-        $this->_display_admin_page();
2802
-    }
2803
-
2804
-
2805
-    /**
2806
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2807
-     *
2808
-     * @return void
2809
-     * @throws EE_Error
2810
-     * @throws DomainException
2811
-     */
2812
-    public function display_about_admin_page()
2813
-    {
2814
-        $this->_display_admin_page(false, true);
2815
-    }
2816
-
2817
-
2818
-    /**
2819
-     * display_admin_page
2820
-     * contains the code for actually displaying an admin page
2821
-     *
2822
-     * @param  boolean $sidebar true with sidebar, false without
2823
-     * @param  boolean $about   use the about admin wrapper instead of the default.
2824
-     * @return void
2825
-     * @throws DomainException
2826
-     * @throws EE_Error
2827
-     */
2828
-    private function _display_admin_page($sidebar = false, $about = false)
2829
-    {
2830
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2831
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2832
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2833
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2834
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2835
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2836
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2837
-            ? 'poststuff'
2838
-            : 'espresso-default-admin';
2839
-        $template_path = $sidebar
2840
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2841
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2842
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2843
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2844
-        }
2845
-        $template_path = ! empty($this->_column_template_path)
2846
-            ? $this->_column_template_path : $template_path;
2847
-        $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content'])
2848
-            ? $this->_template_args['admin_page_content']
2849
-            : '';
2850
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2851
-            ? $this->_template_args['before_admin_page_content']
2852
-            : '';
2853
-        $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content'])
2854
-            ? $this->_template_args['after_admin_page_content']
2855
-            : '';
2856
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2857
-            $template_path,
2858
-            $this->_template_args,
2859
-            true
2860
-        );
2861
-        // the final template wrapper
2862
-        $this->admin_page_wrapper($about);
2863
-    }
2864
-
2865
-
2866
-    /**
2867
-     * This is used to display caf preview pages.
2868
-     *
2869
-     * @since 4.3.2
2870
-     * @param string $utm_campaign_source what is the key used for google analytics link
2871
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2872
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2873
-     * @return void
2874
-     * @throws DomainException
2875
-     * @throws EE_Error
2876
-     * @throws InvalidArgumentException
2877
-     * @throws InvalidDataTypeException
2878
-     * @throws InvalidInterfaceException
2879
-     */
2880
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2881
-    {
2882
-        // let's generate a default preview action button if there isn't one already present.
2883
-        $this->_labels['buttons']['buy_now'] = esc_html__(
2884
-            'Upgrade to Event Espresso 4 Right Now',
2885
-            'event_espresso'
2886
-        );
2887
-        $buy_now_url = add_query_arg(
2888
-            array(
2889
-                'ee_ver'       => 'ee4',
2890
-                'utm_source'   => 'ee4_plugin_admin',
2891
-                'utm_medium'   => 'link',
2892
-                'utm_campaign' => $utm_campaign_source,
2893
-                'utm_content'  => 'buy_now_button',
2894
-            ),
2895
-            'http://eventespresso.com/pricing/'
2896
-        );
2897
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2898
-            ? $this->get_action_link_or_button(
2899
-                '',
2900
-                'buy_now',
2901
-                array(),
2902
-                'button-primary button-large',
2903
-                $buy_now_url,
2904
-                true
2905
-            )
2906
-            : $this->_template_args['preview_action_button'];
2907
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2908
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2909
-            $this->_template_args,
2910
-            true
2911
-        );
2912
-        $this->_display_admin_page($display_sidebar);
2913
-    }
2914
-
2915
-
2916
-    /**
2917
-     * display_admin_list_table_page_with_sidebar
2918
-     * generates HTML wrapper for an admin_page with list_table
2919
-     *
2920
-     * @return void
2921
-     * @throws EE_Error
2922
-     * @throws DomainException
2923
-     */
2924
-    public function display_admin_list_table_page_with_sidebar()
2925
-    {
2926
-        $this->_display_admin_list_table_page(true);
2927
-    }
2928
-
2929
-
2930
-    /**
2931
-     * display_admin_list_table_page_with_no_sidebar
2932
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2933
-     *
2934
-     * @return void
2935
-     * @throws EE_Error
2936
-     * @throws DomainException
2937
-     */
2938
-    public function display_admin_list_table_page_with_no_sidebar()
2939
-    {
2940
-        $this->_display_admin_list_table_page();
2941
-    }
2942
-
2943
-
2944
-    /**
2945
-     * generates html wrapper for an admin_list_table page
2946
-     *
2947
-     * @param boolean $sidebar whether to display with sidebar or not.
2948
-     * @return void
2949
-     * @throws DomainException
2950
-     * @throws EE_Error
2951
-     */
2952
-    private function _display_admin_list_table_page($sidebar = false)
2953
-    {
2954
-        // setup search attributes
2955
-        $this->_set_search_attributes();
2956
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2957
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2958
-        $this->_template_args['table_url'] = defined('DOING_AJAX')
2959
-            ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2960
-            : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2961
-        $this->_template_args['list_table'] = $this->_list_table_object;
2962
-        $this->_template_args['current_route'] = $this->_req_action;
2963
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2964
-        $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2965
-        if (! empty($ajax_sorting_callback)) {
2966
-            $sortable_list_table_form_fields = wp_nonce_field(
2967
-                $ajax_sorting_callback . '_nonce',
2968
-                $ajax_sorting_callback . '_nonce',
2969
-                false,
2970
-                false
2971
-            );
2972
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2973
-                                                . $this->page_slug
2974
-                                                . '" />';
2975
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2976
-                                                . $ajax_sorting_callback
2977
-                                                . '" />';
2978
-        } else {
2979
-            $sortable_list_table_form_fields = '';
2980
-        }
2981
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2982
-        $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
2983
-            ? $this->_template_args['list_table_hidden_fields']
2984
-            : '';
2985
-        $nonce_ref = $this->_req_action . '_nonce';
2986
-        $hidden_form_fields .= '<input type="hidden" name="'
2987
-                               . $nonce_ref
2988
-                               . '" value="'
2989
-                               . wp_create_nonce($nonce_ref)
2990
-                               . '">';
2991
-        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2992
-        // display message about search results?
2993
-        $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2994
-            ? '<p class="ee-search-results">' . sprintf(
2995
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2996
-                trim($this->_req_data['s'], '%')
2997
-            ) . '</p>'
2998
-            : '';
2999
-        // filter before_list_table template arg
3000
-        $this->_template_args['before_list_table'] = apply_filters(
3001
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3002
-            $this->_template_args['before_list_table'],
3003
-            $this->page_slug,
3004
-            $this->_req_data,
3005
-            $this->_req_action
3006
-        );
3007
-        // convert to array and filter again
3008
-        // arrays are easier to inject new items in a specific location,
3009
-        // but would not be backwards compatible, so we have to add a new filter
3010
-        $this->_template_args['before_list_table'] = implode(
3011
-            " \n",
3012
-            (array) apply_filters(
3013
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3014
-                (array) $this->_template_args['before_list_table'],
3015
-                $this->page_slug,
3016
-                $this->_req_data,
3017
-                $this->_req_action
3018
-            )
3019
-        );
3020
-        // filter after_list_table template arg
3021
-        $this->_template_args['after_list_table'] = apply_filters(
3022
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3023
-            $this->_template_args['after_list_table'],
3024
-            $this->page_slug,
3025
-            $this->_req_data,
3026
-            $this->_req_action
3027
-        );
3028
-        // convert to array and filter again
3029
-        // arrays are easier to inject new items in a specific location,
3030
-        // but would not be backwards compatible, so we have to add a new filter
3031
-        $this->_template_args['after_list_table'] = implode(
3032
-            " \n",
3033
-            (array) apply_filters(
3034
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3035
-                (array) $this->_template_args['after_list_table'],
3036
-                $this->page_slug,
3037
-                $this->_req_data,
3038
-                $this->_req_action
3039
-            )
3040
-        );
3041
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3042
-            $template_path,
3043
-            $this->_template_args,
3044
-            true
3045
-        );
3046
-        // the final template wrapper
3047
-        if ($sidebar) {
3048
-            $this->display_admin_page_with_sidebar();
3049
-        } else {
3050
-            $this->display_admin_page_with_no_sidebar();
3051
-        }
3052
-    }
3053
-
3054
-
3055
-    /**
3056
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3057
-     * html string for the legend.
3058
-     * $items are expected in an array in the following format:
3059
-     * $legend_items = array(
3060
-     *        'item_id' => array(
3061
-     *            'icon' => 'http://url_to_icon_being_described.png',
3062
-     *            'desc' => esc_html__('localized description of item');
3063
-     *        )
3064
-     * );
3065
-     *
3066
-     * @param  array $items see above for format of array
3067
-     * @return string html string of legend
3068
-     * @throws DomainException
3069
-     */
3070
-    protected function _display_legend($items)
3071
-    {
3072
-        $this->_template_args['items'] = apply_filters(
3073
-            'FHEE__EE_Admin_Page___display_legend__items',
3074
-            (array) $items,
3075
-            $this
3076
-        );
3077
-        return EEH_Template::display_template(
3078
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3079
-            $this->_template_args,
3080
-            true
3081
-        );
3082
-    }
3083
-
3084
-
3085
-    /**
3086
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3087
-     * The returned json object is created from an array in the following format:
3088
-     * array(
3089
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3090
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3091
-     *  'notices' => '', // - contains any EE_Error formatted notices
3092
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3093
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3094
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3095
-     *  that might be included in here)
3096
-     * )
3097
-     * The json object is populated by whatever is set in the $_template_args property.
3098
-     *
3099
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3100
-     *                                 instead of displayed.
3101
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3102
-     * @return void
3103
-     * @throws EE_Error
3104
-     */
3105
-    protected function _return_json($sticky_notices = false, $notices_arguments = array())
3106
-    {
3107
-        // make sure any EE_Error notices have been handled.
3108
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3109
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3110
-        unset($this->_template_args['data']);
3111
-        $json = array(
3112
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3113
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3114
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3115
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3116
-            'notices'   => EE_Error::get_notices(),
3117
-            'content'   => isset($this->_template_args['admin_page_content'])
3118
-                ? $this->_template_args['admin_page_content'] : '',
3119
-            'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3120
-            'isEEajax'  => true
3121
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3122
-        );
3123
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3124
-        if (null === error_get_last() || ! headers_sent()) {
3125
-            header('Content-Type: application/json; charset=UTF-8');
3126
-        }
3127
-        echo wp_json_encode($json);
3128
-        exit();
3129
-    }
3130
-
3131
-
3132
-    /**
3133
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3134
-     *
3135
-     * @return void
3136
-     * @throws EE_Error
3137
-     */
3138
-    public function return_json()
3139
-    {
3140
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3141
-            $this->_return_json();
3142
-        } else {
3143
-            throw new EE_Error(
3144
-                sprintf(
3145
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3146
-                    __FUNCTION__
3147
-                )
3148
-            );
3149
-        }
3150
-    }
3151
-
3152
-
3153
-    /**
3154
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3155
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3156
-     *
3157
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3158
-     */
3159
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3160
-    {
3161
-        $this->_hook_obj = $hook_obj;
3162
-    }
3163
-
3164
-
3165
-    /**
3166
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3167
-     *
3168
-     * @param  boolean $about whether to use the special about page wrapper or default.
3169
-     * @return void
3170
-     * @throws DomainException
3171
-     * @throws EE_Error
3172
-     */
3173
-    public function admin_page_wrapper($about = false)
3174
-    {
3175
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3176
-        $this->_nav_tabs = $this->_get_main_nav_tabs();
3177
-        $this->_template_args['nav_tabs'] = $this->_nav_tabs;
3178
-        $this->_template_args['admin_page_title'] = $this->_admin_page_title;
3179
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3180
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3181
-            isset($this->_template_args['before_admin_page_content'])
3182
-                ? $this->_template_args['before_admin_page_content']
3183
-                : ''
3184
-        );
3185
-        $this->_template_args['after_admin_page_content'] = apply_filters(
3186
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3187
-            isset($this->_template_args['after_admin_page_content'])
3188
-                ? $this->_template_args['after_admin_page_content']
3189
-                : ''
3190
-        );
3191
-        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3192
-        // load settings page wrapper template
3193
-        $template_path = ! defined('DOING_AJAX')
3194
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3195
-            : EE_ADMIN_TEMPLATE
3196
-              . 'admin_wrapper_ajax.template.php';
3197
-        // about page?
3198
-        $template_path = $about
3199
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3200
-            : $template_path;
3201
-        if (defined('DOING_AJAX')) {
3202
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3203
-                $template_path,
3204
-                $this->_template_args,
3205
-                true
3206
-            );
3207
-            $this->_return_json();
3208
-        } else {
3209
-            EEH_Template::display_template($template_path, $this->_template_args);
3210
-        }
3211
-    }
3212
-
3213
-
3214
-    /**
3215
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3216
-     *
3217
-     * @return string html
3218
-     * @throws EE_Error
3219
-     */
3220
-    protected function _get_main_nav_tabs()
3221
-    {
3222
-        // let's generate the html using the EEH_Tabbed_Content helper.
3223
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3224
-        // (rather than setting in the page_routes array)
3225
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3226
-    }
3227
-
3228
-
3229
-    /**
3230
-     *        sort nav tabs
3231
-     *
3232
-     * @param $a
3233
-     * @param $b
3234
-     * @return int
3235
-     */
3236
-    private function _sort_nav_tabs($a, $b)
3237
-    {
3238
-        if ($a['order'] === $b['order']) {
3239
-            return 0;
3240
-        }
3241
-        return ($a['order'] < $b['order']) ? -1 : 1;
3242
-    }
3243
-
3244
-
3245
-    /**
3246
-     *    generates HTML for the forms used on admin pages
3247
-     *
3248
-     * @param    array $input_vars - array of input field details
3249
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3250
-     *                             use)
3251
-     * @param bool     $id
3252
-     * @return string
3253
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3254
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3255
-     */
3256
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3257
-    {
3258
-        $content = $generator === 'string'
3259
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3260
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3261
-        return $content;
3262
-    }
3263
-
3264
-
3265
-    /**
3266
-     * generates the "Save" and "Save & Close" buttons for edit forms
3267
-     *
3268
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3269
-     *                                   Close" button.
3270
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3271
-     *                                   'Save', [1] => 'save & close')
3272
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3273
-     *                                   via the "name" value in the button).  We can also use this to just dump
3274
-     *                                   default actions by submitting some other value.
3275
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3276
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3277
-     *                                   close (normal form handling).
3278
-     */
3279
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3280
-    {
3281
-        // make sure $text and $actions are in an array
3282
-        $text = (array) $text;
3283
-        $actions = (array) $actions;
3284
-        $referrer_url = empty($referrer)
3285
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3286
-              . $_SERVER['REQUEST_URI']
3287
-              . '" />'
3288
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3289
-              . $referrer
3290
-              . '" />';
3291
-        $button_text = ! empty($text)
3292
-            ? $text
3293
-            : array(
3294
-                esc_html__('Save', 'event_espresso'),
3295
-                esc_html__('Save and Close', 'event_espresso'),
3296
-            );
3297
-        $default_names = array('save', 'save_and_close');
3298
-        // add in a hidden index for the current page (so save and close redirects properly)
3299
-        $this->_template_args['save_buttons'] = $referrer_url;
3300
-        foreach ($button_text as $key => $button) {
3301
-            $ref = $default_names[ $key ];
3302
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3303
-                                                     . $ref
3304
-                                                     . '" value="'
3305
-                                                     . $button
3306
-                                                     . '" name="'
3307
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3308
-                                                     . '" id="'
3309
-                                                     . $this->_current_view . '_' . $ref
3310
-                                                     . '" />';
3311
-            if (! $both) {
3312
-                break;
3313
-            }
3314
-        }
3315
-    }
3316
-
3317
-
3318
-    /**
3319
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3320
-     *
3321
-     * @see   $this->_set_add_edit_form_tags() for details on params
3322
-     * @since 4.6.0
3323
-     * @param string $route
3324
-     * @param array  $additional_hidden_fields
3325
-     */
3326
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3327
-    {
3328
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3329
-    }
3330
-
3331
-
3332
-    /**
3333
-     * set form open and close tags on add/edit pages.
3334
-     *
3335
-     * @param string $route                    the route you want the form to direct to
3336
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3337
-     * @return void
3338
-     */
3339
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3340
-    {
3341
-        if (empty($route)) {
3342
-            $user_msg = esc_html__(
3343
-                'An error occurred. No action was set for this page\'s form.',
3344
-                'event_espresso'
3345
-            );
3346
-            $dev_msg = $user_msg . "\n"
3347
-                       . sprintf(
3348
-                           esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3349
-                           __FUNCTION__,
3350
-                           __CLASS__
3351
-                       );
3352
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3353
-        }
3354
-        // open form
3355
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3356
-                                                             . $this->_admin_base_url
3357
-                                                             . '" id="'
3358
-                                                             . $route
3359
-                                                             . '_event_form" >';
3360
-        // add nonce
3361
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3362
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3363
-        // add REQUIRED form action
3364
-        $hidden_fields = array(
3365
-            'action' => array('type' => 'hidden', 'value' => $route),
3366
-        );
3367
-        // merge arrays
3368
-        $hidden_fields = is_array($additional_hidden_fields)
3369
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3370
-            : $hidden_fields;
3371
-        // generate form fields
3372
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3373
-        // add fields to form
3374
-        foreach ((array) $form_fields as $field_name => $form_field) {
3375
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3376
-        }
3377
-        // close form
3378
-        $this->_template_args['after_admin_page_content'] = '</form>';
3379
-    }
3380
-
3381
-
3382
-    /**
3383
-     * Public Wrapper for _redirect_after_action() method since its
3384
-     * discovered it would be useful for external code to have access.
3385
-     *
3386
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3387
-     * @since 4.5.0
3388
-     * @param bool   $success
3389
-     * @param string $what
3390
-     * @param string $action_desc
3391
-     * @param array  $query_args
3392
-     * @param bool   $override_overwrite
3393
-     * @throws EE_Error
3394
-     */
3395
-    public function redirect_after_action(
3396
-        $success = false,
3397
-        $what = 'item',
3398
-        $action_desc = 'processed',
3399
-        $query_args = array(),
3400
-        $override_overwrite = false
3401
-    ) {
3402
-        $this->_redirect_after_action(
3403
-            $success,
3404
-            $what,
3405
-            $action_desc,
3406
-            $query_args,
3407
-            $override_overwrite
3408
-        );
3409
-    }
3410
-
3411
-
3412
-    /**
3413
-     *    _redirect_after_action
3414
-     *
3415
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3416
-     * @param string $what               - what the action was performed on
3417
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3418
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3419
-     *                                   action is completed
3420
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3421
-     *                                   override this so that they show.
3422
-     * @return void
3423
-     * @throws EE_Error
3424
-     */
3425
-    protected function _redirect_after_action(
3426
-        $success = 0,
3427
-        $what = 'item',
3428
-        $action_desc = 'processed',
3429
-        $query_args = array(),
3430
-        $override_overwrite = false
3431
-    ) {
3432
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3433
-        // class name for actions/filters.
3434
-        $classname = get_class($this);
3435
-        // set redirect url.
3436
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3437
-        // otherwise we go with whatever is set as the _admin_base_url
3438
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3439
-        $notices = EE_Error::get_notices(false);
3440
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3441
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3442
-            EE_Error::overwrite_success();
3443
-        }
3444
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3445
-            // how many records affected ? more than one record ? or just one ?
3446
-            if ($success > 1) {
3447
-                // set plural msg
3448
-                EE_Error::add_success(
3449
-                    sprintf(
3450
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3451
-                        $what,
3452
-                        $action_desc
3453
-                    ),
3454
-                    __FILE__,
3455
-                    __FUNCTION__,
3456
-                    __LINE__
3457
-                );
3458
-            } elseif ($success === 1) {
3459
-                // set singular msg
3460
-                EE_Error::add_success(
3461
-                    sprintf(
3462
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3463
-                        $what,
3464
-                        $action_desc
3465
-                    ),
3466
-                    __FILE__,
3467
-                    __FUNCTION__,
3468
-                    __LINE__
3469
-                );
3470
-            }
3471
-        }
3472
-        // check that $query_args isn't something crazy
3473
-        if (! is_array($query_args)) {
3474
-            $query_args = array();
3475
-        }
3476
-        /**
3477
-         * Allow injecting actions before the query_args are modified for possible different
3478
-         * redirections on save and close actions
3479
-         *
3480
-         * @since 4.2.0
3481
-         * @param array $query_args       The original query_args array coming into the
3482
-         *                                method.
3483
-         */
3484
-        do_action(
3485
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3486
-            $query_args
3487
-        );
3488
-        // calculate where we're going (if we have a "save and close" button pushed)
3489
-        if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3490
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3491
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3492
-            // regenerate query args array from referrer URL
3493
-            parse_str($parsed_url['query'], $query_args);
3494
-            // correct page and action will be in the query args now
3495
-            $redirect_url = admin_url('admin.php');
3496
-        }
3497
-        // merge any default query_args set in _default_route_query_args property
3498
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3499
-            $args_to_merge = array();
3500
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3501
-                // is there a wp_referer array in our _default_route_query_args property?
3502
-                if ($query_param === 'wp_referer') {
3503
-                    $query_value = (array) $query_value;
3504
-                    foreach ($query_value as $reference => $value) {
3505
-                        if (strpos($reference, 'nonce') !== false) {
3506
-                            continue;
3507
-                        }
3508
-                        // finally we will override any arguments in the referer with
3509
-                        // what might be set on the _default_route_query_args array.
3510
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3511
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3512
-                        } else {
3513
-                            $args_to_merge[ $reference ] = urlencode($value);
3514
-                        }
3515
-                    }
3516
-                    continue;
3517
-                }
3518
-                $args_to_merge[ $query_param ] = $query_value;
3519
-            }
3520
-            // now let's merge these arguments but override with what was specifically sent in to the
3521
-            // redirect.
3522
-            $query_args = array_merge($args_to_merge, $query_args);
3523
-        }
3524
-        $this->_process_notices($query_args);
3525
-        // generate redirect url
3526
-        // if redirecting to anything other than the main page, add a nonce
3527
-        if (isset($query_args['action'])) {
3528
-            // manually generate wp_nonce and merge that with the query vars
3529
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3530
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3531
-        }
3532
-        // we're adding some hooks and filters in here for processing any things just before redirects
3533
-        // (example: an admin page has done an insert or update and we want to run something after that).
3534
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3535
-        $redirect_url = apply_filters(
3536
-            'FHEE_redirect_' . $classname . $this->_req_action,
3537
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3538
-            $query_args
3539
-        );
3540
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3541
-        if (defined('DOING_AJAX')) {
3542
-            $default_data = array(
3543
-                'close'        => true,
3544
-                'redirect_url' => $redirect_url,
3545
-                'where'        => 'main',
3546
-                'what'         => 'append',
3547
-            );
3548
-            $this->_template_args['success'] = $success;
3549
-            $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge(
3550
-                $default_data,
3551
-                $this->_template_args['data']
3552
-            ) : $default_data;
3553
-            $this->_return_json();
3554
-        }
3555
-        wp_safe_redirect($redirect_url);
3556
-        exit();
3557
-    }
3558
-
3559
-
3560
-    /**
3561
-     * process any notices before redirecting (or returning ajax request)
3562
-     * This method sets the $this->_template_args['notices'] attribute;
3563
-     *
3564
-     * @param  array $query_args        any query args that need to be used for notice transient ('action')
3565
-     * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and
3566
-     *                                  page_routes haven't been defined yet.
3567
-     * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we
3568
-     *                                  still save a transient for the notice.
3569
-     * @return void
3570
-     * @throws EE_Error
3571
-     */
3572
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3573
-    {
3574
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3575
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3576
-            $notices = EE_Error::get_notices(false);
3577
-            if (empty($this->_template_args['success'])) {
3578
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3579
-            }
3580
-            if (empty($this->_template_args['errors'])) {
3581
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3582
-            }
3583
-            if (empty($this->_template_args['attention'])) {
3584
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3585
-            }
3586
-        }
3587
-        $this->_template_args['notices'] = EE_Error::get_notices();
3588
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3589
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3590
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3591
-            $this->_add_transient(
3592
-                $route,
3593
-                $this->_template_args['notices'],
3594
-                true,
3595
-                $skip_route_verify
3596
-            );
3597
-        }
3598
-    }
3599
-
3600
-
3601
-    /**
3602
-     * get_action_link_or_button
3603
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3604
-     *
3605
-     * @param string $action        use this to indicate which action the url is generated with.
3606
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3607
-     *                              property.
3608
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3609
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3610
-     * @param string $base_url      If this is not provided
3611
-     *                              the _admin_base_url will be used as the default for the button base_url.
3612
-     *                              Otherwise this value will be used.
3613
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3614
-     * @return string
3615
-     * @throws InvalidArgumentException
3616
-     * @throws InvalidInterfaceException
3617
-     * @throws InvalidDataTypeException
3618
-     * @throws EE_Error
3619
-     */
3620
-    public function get_action_link_or_button(
3621
-        $action,
3622
-        $type = 'add',
3623
-        $extra_request = array(),
3624
-        $class = 'button-primary',
3625
-        $base_url = '',
3626
-        $exclude_nonce = false
3627
-    ) {
3628
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3629
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3630
-            throw new EE_Error(
3631
-                sprintf(
3632
-                    esc_html__(
3633
-                        'There is no page route for given action for the button.  This action was given: %s',
3634
-                        'event_espresso'
3635
-                    ),
3636
-                    $action
3637
-                )
3638
-            );
3639
-        }
3640
-        if (! isset($this->_labels['buttons'][ $type ])) {
3641
-            throw new EE_Error(
3642
-                sprintf(
3643
-                    __(
3644
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3645
-                        'event_espresso'
3646
-                    ),
3647
-                    $type
3648
-                )
3649
-            );
3650
-        }
3651
-        // finally check user access for this button.
3652
-        $has_access = $this->check_user_access($action, true);
3653
-        if (! $has_access) {
3654
-            return '';
3655
-        }
3656
-        $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3657
-        $query_args = array(
3658
-            'action' => $action,
3659
-        );
3660
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3661
-        if (! empty($extra_request)) {
3662
-            $query_args = array_merge($extra_request, $query_args);
3663
-        }
3664
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3665
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3666
-    }
3667
-
3668
-
3669
-    /**
3670
-     * _per_page_screen_option
3671
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3672
-     *
3673
-     * @return void
3674
-     * @throws InvalidArgumentException
3675
-     * @throws InvalidInterfaceException
3676
-     * @throws InvalidDataTypeException
3677
-     */
3678
-    protected function _per_page_screen_option()
3679
-    {
3680
-        $option = 'per_page';
3681
-        $args = array(
3682
-            'label'   => apply_filters(
3683
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3684
-                $this->_admin_page_title,
3685
-                $this
3686
-            ),
3687
-            'default' => (int) apply_filters(
3688
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3689
-                10
3690
-            ),
3691
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3692
-        );
3693
-        // ONLY add the screen option if the user has access to it.
3694
-        if ($this->check_user_access($this->_current_view, true)) {
3695
-            add_screen_option($option, $args);
3696
-        }
3697
-    }
3698
-
3699
-
3700
-    /**
3701
-     * set_per_page_screen_option
3702
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3703
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3704
-     * admin_menu.
3705
-     *
3706
-     * @return void
3707
-     */
3708
-    private function _set_per_page_screen_options()
3709
-    {
3710
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3711
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3712
-            if (! $user = wp_get_current_user()) {
3713
-                return;
3714
-            }
3715
-            $option = $_POST['wp_screen_options']['option'];
3716
-            $value = $_POST['wp_screen_options']['value'];
3717
-            if ($option != sanitize_key($option)) {
3718
-                return;
3719
-            }
3720
-            $map_option = $option;
3721
-            $option = str_replace('-', '_', $option);
3722
-            switch ($map_option) {
3723
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3724
-                    $value = (int) $value;
3725
-                    $max_value = apply_filters(
3726
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3727
-                        999,
3728
-                        $this->_current_page,
3729
-                        $this->_current_view
3730
-                    );
3731
-                    if ($value < 1) {
3732
-                        return;
3733
-                    }
3734
-                    $value = min($value, $max_value);
3735
-                    break;
3736
-                default:
3737
-                    $value = apply_filters(
3738
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3739
-                        false,
3740
-                        $option,
3741
-                        $value
3742
-                    );
3743
-                    if (false === $value) {
3744
-                        return;
3745
-                    }
3746
-                    break;
3747
-            }
3748
-            update_user_meta($user->ID, $option, $value);
3749
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3750
-            exit;
3751
-        }
3752
-    }
3753
-
3754
-
3755
-    /**
3756
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3757
-     *
3758
-     * @param array $data array that will be assigned to template args.
3759
-     */
3760
-    public function set_template_args($data)
3761
-    {
3762
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3763
-    }
3764
-
3765
-
3766
-    /**
3767
-     * This makes available the WP transient system for temporarily moving data between routes
3768
-     *
3769
-     * @param string $route             the route that should receive the transient
3770
-     * @param array  $data              the data that gets sent
3771
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3772
-     *                                  normal route transient.
3773
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3774
-     *                                  when we are adding a transient before page_routes have been defined.
3775
-     * @return void
3776
-     * @throws EE_Error
3777
-     */
3778
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3779
-    {
3780
-        $user_id = get_current_user_id();
3781
-        if (! $skip_route_verify) {
3782
-            $this->_verify_route($route);
3783
-        }
3784
-        // now let's set the string for what kind of transient we're setting
3785
-        $transient = $notices
3786
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3787
-            : 'rte_tx_' . $route . '_' . $user_id;
3788
-        $data = $notices ? array('notices' => $data) : $data;
3789
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3790
-        $existing = is_multisite() && is_network_admin()
3791
-            ? get_site_transient($transient)
3792
-            : get_transient($transient);
3793
-        if ($existing) {
3794
-            $data = array_merge((array) $data, (array) $existing);
3795
-        }
3796
-        if (is_multisite() && is_network_admin()) {
3797
-            set_site_transient($transient, $data, 8);
3798
-        } else {
3799
-            set_transient($transient, $data, 8);
3800
-        }
3801
-    }
3802
-
3803
-
3804
-    /**
3805
-     * this retrieves the temporary transient that has been set for moving data between routes.
3806
-     *
3807
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3808
-     * @param string $route
3809
-     * @return mixed data
3810
-     */
3811
-    protected function _get_transient($notices = false, $route = '')
3812
-    {
3813
-        $user_id = get_current_user_id();
3814
-        $route = ! $route ? $this->_req_action : $route;
3815
-        $transient = $notices
3816
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3817
-            : 'rte_tx_' . $route . '_' . $user_id;
3818
-        $data = is_multisite() && is_network_admin()
3819
-            ? get_site_transient($transient)
3820
-            : get_transient($transient);
3821
-        // delete transient after retrieval (just in case it hasn't expired);
3822
-        if (is_multisite() && is_network_admin()) {
3823
-            delete_site_transient($transient);
3824
-        } else {
3825
-            delete_transient($transient);
3826
-        }
3827
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3828
-    }
3829
-
3830
-
3831
-    /**
3832
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3833
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3834
-     * default route callback on the EE_Admin page you want it run.)
3835
-     *
3836
-     * @return void
3837
-     */
3838
-    protected function _transient_garbage_collection()
3839
-    {
3840
-        global $wpdb;
3841
-        // retrieve all existing transients
3842
-        $query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3843
-        if ($results = $wpdb->get_results($query)) {
3844
-            foreach ($results as $result) {
3845
-                $transient = str_replace('_transient_', '', $result->option_name);
3846
-                get_transient($transient);
3847
-                if (is_multisite() && is_network_admin()) {
3848
-                    get_site_transient($transient);
3849
-                }
3850
-            }
3851
-        }
3852
-    }
3853
-
3854
-
3855
-    /**
3856
-     * get_view
3857
-     *
3858
-     * @return string content of _view property
3859
-     */
3860
-    public function get_view()
3861
-    {
3862
-        return $this->_view;
3863
-    }
3864
-
3865
-
3866
-    /**
3867
-     * getter for the protected $_views property
3868
-     *
3869
-     * @return array
3870
-     */
3871
-    public function get_views()
3872
-    {
3873
-        return $this->_views;
3874
-    }
3875
-
3876
-
3877
-    /**
3878
-     * get_current_page
3879
-     *
3880
-     * @return string _current_page property value
3881
-     */
3882
-    public function get_current_page()
3883
-    {
3884
-        return $this->_current_page;
3885
-    }
3886
-
3887
-
3888
-    /**
3889
-     * get_current_view
3890
-     *
3891
-     * @return string _current_view property value
3892
-     */
3893
-    public function get_current_view()
3894
-    {
3895
-        return $this->_current_view;
3896
-    }
3897
-
3898
-
3899
-    /**
3900
-     * get_current_screen
3901
-     *
3902
-     * @return object The current WP_Screen object
3903
-     */
3904
-    public function get_current_screen()
3905
-    {
3906
-        return $this->_current_screen;
3907
-    }
3908
-
3909
-
3910
-    /**
3911
-     * get_current_page_view_url
3912
-     *
3913
-     * @return string This returns the url for the current_page_view.
3914
-     */
3915
-    public function get_current_page_view_url()
3916
-    {
3917
-        return $this->_current_page_view_url;
3918
-    }
3919
-
3920
-
3921
-    /**
3922
-     * just returns the _req_data property
3923
-     *
3924
-     * @return array
3925
-     */
3926
-    public function get_request_data()
3927
-    {
3928
-        return $this->_req_data;
3929
-    }
3930
-
3931
-
3932
-    /**
3933
-     * returns the _req_data protected property
3934
-     *
3935
-     * @return string
3936
-     */
3937
-    public function get_req_action()
3938
-    {
3939
-        return $this->_req_action;
3940
-    }
3941
-
3942
-
3943
-    /**
3944
-     * @return bool  value of $_is_caf property
3945
-     */
3946
-    public function is_caf()
3947
-    {
3948
-        return $this->_is_caf;
3949
-    }
3950
-
3951
-
3952
-    /**
3953
-     * @return mixed
3954
-     */
3955
-    public function default_espresso_metaboxes()
3956
-    {
3957
-        return $this->_default_espresso_metaboxes;
3958
-    }
3959
-
3960
-
3961
-    /**
3962
-     * @return mixed
3963
-     */
3964
-    public function admin_base_url()
3965
-    {
3966
-        return $this->_admin_base_url;
3967
-    }
3968
-
3969
-
3970
-    /**
3971
-     * @return mixed
3972
-     */
3973
-    public function wp_page_slug()
3974
-    {
3975
-        return $this->_wp_page_slug;
3976
-    }
3977
-
3978
-
3979
-    /**
3980
-     * updates  espresso configuration settings
3981
-     *
3982
-     * @param string                   $tab
3983
-     * @param EE_Config_Base|EE_Config $config
3984
-     * @param string                   $file file where error occurred
3985
-     * @param string                   $func function  where error occurred
3986
-     * @param string                   $line line no where error occurred
3987
-     * @return boolean
3988
-     */
3989
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3990
-    {
3991
-        // remove any options that are NOT going to be saved with the config settings.
3992
-        if (isset($config->core->ee_ueip_optin)) {
3993
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3994
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3995
-            update_option('ee_ueip_has_notified', true);
3996
-        }
3997
-        // and save it (note we're also doing the network save here)
3998
-        $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3999
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4000
-        if ($config_saved && $net_saved) {
4001
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4002
-            return true;
4003
-        }
4004
-        EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4005
-        return false;
4006
-    }
4007
-
4008
-
4009
-    /**
4010
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4011
-     *
4012
-     * @return array
4013
-     */
4014
-    public function get_yes_no_values()
4015
-    {
4016
-        return $this->_yes_no_values;
4017
-    }
4018
-
4019
-
4020
-    protected function _get_dir()
4021
-    {
4022
-        $reflector = new ReflectionClass(get_class($this));
4023
-        return dirname($reflector->getFileName());
4024
-    }
4025
-
4026
-
4027
-    /**
4028
-     * A helper for getting a "next link".
4029
-     *
4030
-     * @param string $url   The url to link to
4031
-     * @param string $class The class to use.
4032
-     * @return string
4033
-     */
4034
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4035
-    {
4036
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4037
-    }
4038
-
4039
-
4040
-    /**
4041
-     * A helper for getting a "previous link".
4042
-     *
4043
-     * @param string $url   The url to link to
4044
-     * @param string $class The class to use.
4045
-     * @return string
4046
-     */
4047
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4048
-    {
4049
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4050
-    }
4051
-
4052
-
4053
-
4054
-
4055
-
4056
-
4057
-
4058
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4059
-
4060
-
4061
-    /**
4062
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4063
-     * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4064
-     * _req_data array.
4065
-     *
4066
-     * @return bool success/fail
4067
-     * @throws EE_Error
4068
-     * @throws InvalidArgumentException
4069
-     * @throws ReflectionException
4070
-     * @throws InvalidDataTypeException
4071
-     * @throws InvalidInterfaceException
4072
-     */
4073
-    protected function _process_resend_registration()
4074
-    {
4075
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4076
-        do_action(
4077
-            'AHEE__EE_Admin_Page___process_resend_registration',
4078
-            $this->_template_args['success'],
4079
-            $this->_req_data
4080
-        );
4081
-        return $this->_template_args['success'];
4082
-    }
4083
-
4084
-
4085
-    /**
4086
-     * This automatically processes any payment message notifications when manual payment has been applied.
4087
-     *
4088
-     * @param \EE_Payment $payment
4089
-     * @return bool success/fail
4090
-     */
4091
-    protected function _process_payment_notification(EE_Payment $payment)
4092
-    {
4093
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4094
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4095
-        $this->_template_args['success'] = apply_filters(
4096
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4097
-            false,
4098
-            $payment
4099
-        );
4100
-        return $this->_template_args['success'];
4101
-    }
2703
+	}
2704
+
2705
+
2706
+	/**
2707
+	 * facade for add_meta_box
2708
+	 *
2709
+	 * @param string  $action        where the metabox get's displayed
2710
+	 * @param string  $title         Title of Metabox (output in metabox header)
2711
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2712
+	 *                               instead of the one created in here.
2713
+	 * @param array   $callback_args an array of args supplied for the metabox
2714
+	 * @param string  $column        what metabox column
2715
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2716
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2717
+	 *                               created but just set our own callback for wp's add_meta_box.
2718
+	 * @throws \DomainException
2719
+	 */
2720
+	public function _add_admin_page_meta_box(
2721
+		$action,
2722
+		$title,
2723
+		$callback,
2724
+		$callback_args,
2725
+		$column = 'normal',
2726
+		$priority = 'high',
2727
+		$create_func = true
2728
+	) {
2729
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2730
+		// if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2731
+		if (empty($callback_args) && $create_func) {
2732
+			$callback_args = array(
2733
+				'template_path' => $this->_template_path,
2734
+				'template_args' => $this->_template_args,
2735
+			);
2736
+		}
2737
+		// if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2738
+		$call_back_func = $create_func
2739
+			? function ($post, $metabox) {
2740
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2741
+				echo EEH_Template::display_template(
2742
+					$metabox['args']['template_path'],
2743
+					$metabox['args']['template_args'],
2744
+					true
2745
+				);
2746
+			}
2747
+			: $callback;
2748
+		add_meta_box(
2749
+			str_replace('_', '-', $action) . '-mbox',
2750
+			$title,
2751
+			$call_back_func,
2752
+			$this->_wp_page_slug,
2753
+			$column,
2754
+			$priority,
2755
+			$callback_args
2756
+		);
2757
+	}
2758
+
2759
+
2760
+	/**
2761
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2762
+	 *
2763
+	 * @throws DomainException
2764
+	 * @throws EE_Error
2765
+	 */
2766
+	public function display_admin_page_with_metabox_columns()
2767
+	{
2768
+		$this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2769
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2770
+			$this->_column_template_path,
2771
+			$this->_template_args,
2772
+			true
2773
+		);
2774
+		// the final wrapper
2775
+		$this->admin_page_wrapper();
2776
+	}
2777
+
2778
+
2779
+	/**
2780
+	 * generates  HTML wrapper for an admin details page
2781
+	 *
2782
+	 * @return void
2783
+	 * @throws EE_Error
2784
+	 * @throws DomainException
2785
+	 */
2786
+	public function display_admin_page_with_sidebar()
2787
+	{
2788
+		$this->_display_admin_page(true);
2789
+	}
2790
+
2791
+
2792
+	/**
2793
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2794
+	 *
2795
+	 * @return void
2796
+	 * @throws EE_Error
2797
+	 * @throws DomainException
2798
+	 */
2799
+	public function display_admin_page_with_no_sidebar()
2800
+	{
2801
+		$this->_display_admin_page();
2802
+	}
2803
+
2804
+
2805
+	/**
2806
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2807
+	 *
2808
+	 * @return void
2809
+	 * @throws EE_Error
2810
+	 * @throws DomainException
2811
+	 */
2812
+	public function display_about_admin_page()
2813
+	{
2814
+		$this->_display_admin_page(false, true);
2815
+	}
2816
+
2817
+
2818
+	/**
2819
+	 * display_admin_page
2820
+	 * contains the code for actually displaying an admin page
2821
+	 *
2822
+	 * @param  boolean $sidebar true with sidebar, false without
2823
+	 * @param  boolean $about   use the about admin wrapper instead of the default.
2824
+	 * @return void
2825
+	 * @throws DomainException
2826
+	 * @throws EE_Error
2827
+	 */
2828
+	private function _display_admin_page($sidebar = false, $about = false)
2829
+	{
2830
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2831
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2832
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2833
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2834
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2835
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2836
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2837
+			? 'poststuff'
2838
+			: 'espresso-default-admin';
2839
+		$template_path = $sidebar
2840
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2841
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2842
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2843
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2844
+		}
2845
+		$template_path = ! empty($this->_column_template_path)
2846
+			? $this->_column_template_path : $template_path;
2847
+		$this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content'])
2848
+			? $this->_template_args['admin_page_content']
2849
+			: '';
2850
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2851
+			? $this->_template_args['before_admin_page_content']
2852
+			: '';
2853
+		$this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content'])
2854
+			? $this->_template_args['after_admin_page_content']
2855
+			: '';
2856
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2857
+			$template_path,
2858
+			$this->_template_args,
2859
+			true
2860
+		);
2861
+		// the final template wrapper
2862
+		$this->admin_page_wrapper($about);
2863
+	}
2864
+
2865
+
2866
+	/**
2867
+	 * This is used to display caf preview pages.
2868
+	 *
2869
+	 * @since 4.3.2
2870
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2871
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2872
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2873
+	 * @return void
2874
+	 * @throws DomainException
2875
+	 * @throws EE_Error
2876
+	 * @throws InvalidArgumentException
2877
+	 * @throws InvalidDataTypeException
2878
+	 * @throws InvalidInterfaceException
2879
+	 */
2880
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2881
+	{
2882
+		// let's generate a default preview action button if there isn't one already present.
2883
+		$this->_labels['buttons']['buy_now'] = esc_html__(
2884
+			'Upgrade to Event Espresso 4 Right Now',
2885
+			'event_espresso'
2886
+		);
2887
+		$buy_now_url = add_query_arg(
2888
+			array(
2889
+				'ee_ver'       => 'ee4',
2890
+				'utm_source'   => 'ee4_plugin_admin',
2891
+				'utm_medium'   => 'link',
2892
+				'utm_campaign' => $utm_campaign_source,
2893
+				'utm_content'  => 'buy_now_button',
2894
+			),
2895
+			'http://eventespresso.com/pricing/'
2896
+		);
2897
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2898
+			? $this->get_action_link_or_button(
2899
+				'',
2900
+				'buy_now',
2901
+				array(),
2902
+				'button-primary button-large',
2903
+				$buy_now_url,
2904
+				true
2905
+			)
2906
+			: $this->_template_args['preview_action_button'];
2907
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2908
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2909
+			$this->_template_args,
2910
+			true
2911
+		);
2912
+		$this->_display_admin_page($display_sidebar);
2913
+	}
2914
+
2915
+
2916
+	/**
2917
+	 * display_admin_list_table_page_with_sidebar
2918
+	 * generates HTML wrapper for an admin_page with list_table
2919
+	 *
2920
+	 * @return void
2921
+	 * @throws EE_Error
2922
+	 * @throws DomainException
2923
+	 */
2924
+	public function display_admin_list_table_page_with_sidebar()
2925
+	{
2926
+		$this->_display_admin_list_table_page(true);
2927
+	}
2928
+
2929
+
2930
+	/**
2931
+	 * display_admin_list_table_page_with_no_sidebar
2932
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2933
+	 *
2934
+	 * @return void
2935
+	 * @throws EE_Error
2936
+	 * @throws DomainException
2937
+	 */
2938
+	public function display_admin_list_table_page_with_no_sidebar()
2939
+	{
2940
+		$this->_display_admin_list_table_page();
2941
+	}
2942
+
2943
+
2944
+	/**
2945
+	 * generates html wrapper for an admin_list_table page
2946
+	 *
2947
+	 * @param boolean $sidebar whether to display with sidebar or not.
2948
+	 * @return void
2949
+	 * @throws DomainException
2950
+	 * @throws EE_Error
2951
+	 */
2952
+	private function _display_admin_list_table_page($sidebar = false)
2953
+	{
2954
+		// setup search attributes
2955
+		$this->_set_search_attributes();
2956
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2957
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2958
+		$this->_template_args['table_url'] = defined('DOING_AJAX')
2959
+			? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2960
+			: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2961
+		$this->_template_args['list_table'] = $this->_list_table_object;
2962
+		$this->_template_args['current_route'] = $this->_req_action;
2963
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2964
+		$ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2965
+		if (! empty($ajax_sorting_callback)) {
2966
+			$sortable_list_table_form_fields = wp_nonce_field(
2967
+				$ajax_sorting_callback . '_nonce',
2968
+				$ajax_sorting_callback . '_nonce',
2969
+				false,
2970
+				false
2971
+			);
2972
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2973
+												. $this->page_slug
2974
+												. '" />';
2975
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2976
+												. $ajax_sorting_callback
2977
+												. '" />';
2978
+		} else {
2979
+			$sortable_list_table_form_fields = '';
2980
+		}
2981
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2982
+		$hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
2983
+			? $this->_template_args['list_table_hidden_fields']
2984
+			: '';
2985
+		$nonce_ref = $this->_req_action . '_nonce';
2986
+		$hidden_form_fields .= '<input type="hidden" name="'
2987
+							   . $nonce_ref
2988
+							   . '" value="'
2989
+							   . wp_create_nonce($nonce_ref)
2990
+							   . '">';
2991
+		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2992
+		// display message about search results?
2993
+		$this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2994
+			? '<p class="ee-search-results">' . sprintf(
2995
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2996
+				trim($this->_req_data['s'], '%')
2997
+			) . '</p>'
2998
+			: '';
2999
+		// filter before_list_table template arg
3000
+		$this->_template_args['before_list_table'] = apply_filters(
3001
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3002
+			$this->_template_args['before_list_table'],
3003
+			$this->page_slug,
3004
+			$this->_req_data,
3005
+			$this->_req_action
3006
+		);
3007
+		// convert to array and filter again
3008
+		// arrays are easier to inject new items in a specific location,
3009
+		// but would not be backwards compatible, so we have to add a new filter
3010
+		$this->_template_args['before_list_table'] = implode(
3011
+			" \n",
3012
+			(array) apply_filters(
3013
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3014
+				(array) $this->_template_args['before_list_table'],
3015
+				$this->page_slug,
3016
+				$this->_req_data,
3017
+				$this->_req_action
3018
+			)
3019
+		);
3020
+		// filter after_list_table template arg
3021
+		$this->_template_args['after_list_table'] = apply_filters(
3022
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3023
+			$this->_template_args['after_list_table'],
3024
+			$this->page_slug,
3025
+			$this->_req_data,
3026
+			$this->_req_action
3027
+		);
3028
+		// convert to array and filter again
3029
+		// arrays are easier to inject new items in a specific location,
3030
+		// but would not be backwards compatible, so we have to add a new filter
3031
+		$this->_template_args['after_list_table'] = implode(
3032
+			" \n",
3033
+			(array) apply_filters(
3034
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3035
+				(array) $this->_template_args['after_list_table'],
3036
+				$this->page_slug,
3037
+				$this->_req_data,
3038
+				$this->_req_action
3039
+			)
3040
+		);
3041
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3042
+			$template_path,
3043
+			$this->_template_args,
3044
+			true
3045
+		);
3046
+		// the final template wrapper
3047
+		if ($sidebar) {
3048
+			$this->display_admin_page_with_sidebar();
3049
+		} else {
3050
+			$this->display_admin_page_with_no_sidebar();
3051
+		}
3052
+	}
3053
+
3054
+
3055
+	/**
3056
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3057
+	 * html string for the legend.
3058
+	 * $items are expected in an array in the following format:
3059
+	 * $legend_items = array(
3060
+	 *        'item_id' => array(
3061
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3062
+	 *            'desc' => esc_html__('localized description of item');
3063
+	 *        )
3064
+	 * );
3065
+	 *
3066
+	 * @param  array $items see above for format of array
3067
+	 * @return string html string of legend
3068
+	 * @throws DomainException
3069
+	 */
3070
+	protected function _display_legend($items)
3071
+	{
3072
+		$this->_template_args['items'] = apply_filters(
3073
+			'FHEE__EE_Admin_Page___display_legend__items',
3074
+			(array) $items,
3075
+			$this
3076
+		);
3077
+		return EEH_Template::display_template(
3078
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3079
+			$this->_template_args,
3080
+			true
3081
+		);
3082
+	}
3083
+
3084
+
3085
+	/**
3086
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3087
+	 * The returned json object is created from an array in the following format:
3088
+	 * array(
3089
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3090
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3091
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3092
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3093
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3094
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3095
+	 *  that might be included in here)
3096
+	 * )
3097
+	 * The json object is populated by whatever is set in the $_template_args property.
3098
+	 *
3099
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3100
+	 *                                 instead of displayed.
3101
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3102
+	 * @return void
3103
+	 * @throws EE_Error
3104
+	 */
3105
+	protected function _return_json($sticky_notices = false, $notices_arguments = array())
3106
+	{
3107
+		// make sure any EE_Error notices have been handled.
3108
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3109
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3110
+		unset($this->_template_args['data']);
3111
+		$json = array(
3112
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3113
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3114
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3115
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3116
+			'notices'   => EE_Error::get_notices(),
3117
+			'content'   => isset($this->_template_args['admin_page_content'])
3118
+				? $this->_template_args['admin_page_content'] : '',
3119
+			'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3120
+			'isEEajax'  => true
3121
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3122
+		);
3123
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3124
+		if (null === error_get_last() || ! headers_sent()) {
3125
+			header('Content-Type: application/json; charset=UTF-8');
3126
+		}
3127
+		echo wp_json_encode($json);
3128
+		exit();
3129
+	}
3130
+
3131
+
3132
+	/**
3133
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3134
+	 *
3135
+	 * @return void
3136
+	 * @throws EE_Error
3137
+	 */
3138
+	public function return_json()
3139
+	{
3140
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3141
+			$this->_return_json();
3142
+		} else {
3143
+			throw new EE_Error(
3144
+				sprintf(
3145
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3146
+					__FUNCTION__
3147
+				)
3148
+			);
3149
+		}
3150
+	}
3151
+
3152
+
3153
+	/**
3154
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3155
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3156
+	 *
3157
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3158
+	 */
3159
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3160
+	{
3161
+		$this->_hook_obj = $hook_obj;
3162
+	}
3163
+
3164
+
3165
+	/**
3166
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3167
+	 *
3168
+	 * @param  boolean $about whether to use the special about page wrapper or default.
3169
+	 * @return void
3170
+	 * @throws DomainException
3171
+	 * @throws EE_Error
3172
+	 */
3173
+	public function admin_page_wrapper($about = false)
3174
+	{
3175
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3176
+		$this->_nav_tabs = $this->_get_main_nav_tabs();
3177
+		$this->_template_args['nav_tabs'] = $this->_nav_tabs;
3178
+		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
3179
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3180
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3181
+			isset($this->_template_args['before_admin_page_content'])
3182
+				? $this->_template_args['before_admin_page_content']
3183
+				: ''
3184
+		);
3185
+		$this->_template_args['after_admin_page_content'] = apply_filters(
3186
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3187
+			isset($this->_template_args['after_admin_page_content'])
3188
+				? $this->_template_args['after_admin_page_content']
3189
+				: ''
3190
+		);
3191
+		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3192
+		// load settings page wrapper template
3193
+		$template_path = ! defined('DOING_AJAX')
3194
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3195
+			: EE_ADMIN_TEMPLATE
3196
+			  . 'admin_wrapper_ajax.template.php';
3197
+		// about page?
3198
+		$template_path = $about
3199
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3200
+			: $template_path;
3201
+		if (defined('DOING_AJAX')) {
3202
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3203
+				$template_path,
3204
+				$this->_template_args,
3205
+				true
3206
+			);
3207
+			$this->_return_json();
3208
+		} else {
3209
+			EEH_Template::display_template($template_path, $this->_template_args);
3210
+		}
3211
+	}
3212
+
3213
+
3214
+	/**
3215
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3216
+	 *
3217
+	 * @return string html
3218
+	 * @throws EE_Error
3219
+	 */
3220
+	protected function _get_main_nav_tabs()
3221
+	{
3222
+		// let's generate the html using the EEH_Tabbed_Content helper.
3223
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3224
+		// (rather than setting in the page_routes array)
3225
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3226
+	}
3227
+
3228
+
3229
+	/**
3230
+	 *        sort nav tabs
3231
+	 *
3232
+	 * @param $a
3233
+	 * @param $b
3234
+	 * @return int
3235
+	 */
3236
+	private function _sort_nav_tabs($a, $b)
3237
+	{
3238
+		if ($a['order'] === $b['order']) {
3239
+			return 0;
3240
+		}
3241
+		return ($a['order'] < $b['order']) ? -1 : 1;
3242
+	}
3243
+
3244
+
3245
+	/**
3246
+	 *    generates HTML for the forms used on admin pages
3247
+	 *
3248
+	 * @param    array $input_vars - array of input field details
3249
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3250
+	 *                             use)
3251
+	 * @param bool     $id
3252
+	 * @return string
3253
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3254
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3255
+	 */
3256
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3257
+	{
3258
+		$content = $generator === 'string'
3259
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3260
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3261
+		return $content;
3262
+	}
3263
+
3264
+
3265
+	/**
3266
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3267
+	 *
3268
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3269
+	 *                                   Close" button.
3270
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3271
+	 *                                   'Save', [1] => 'save & close')
3272
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3273
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3274
+	 *                                   default actions by submitting some other value.
3275
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3276
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3277
+	 *                                   close (normal form handling).
3278
+	 */
3279
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3280
+	{
3281
+		// make sure $text and $actions are in an array
3282
+		$text = (array) $text;
3283
+		$actions = (array) $actions;
3284
+		$referrer_url = empty($referrer)
3285
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3286
+			  . $_SERVER['REQUEST_URI']
3287
+			  . '" />'
3288
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3289
+			  . $referrer
3290
+			  . '" />';
3291
+		$button_text = ! empty($text)
3292
+			? $text
3293
+			: array(
3294
+				esc_html__('Save', 'event_espresso'),
3295
+				esc_html__('Save and Close', 'event_espresso'),
3296
+			);
3297
+		$default_names = array('save', 'save_and_close');
3298
+		// add in a hidden index for the current page (so save and close redirects properly)
3299
+		$this->_template_args['save_buttons'] = $referrer_url;
3300
+		foreach ($button_text as $key => $button) {
3301
+			$ref = $default_names[ $key ];
3302
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3303
+													 . $ref
3304
+													 . '" value="'
3305
+													 . $button
3306
+													 . '" name="'
3307
+													 . (! empty($actions) ? $actions[ $key ] : $ref)
3308
+													 . '" id="'
3309
+													 . $this->_current_view . '_' . $ref
3310
+													 . '" />';
3311
+			if (! $both) {
3312
+				break;
3313
+			}
3314
+		}
3315
+	}
3316
+
3317
+
3318
+	/**
3319
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3320
+	 *
3321
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3322
+	 * @since 4.6.0
3323
+	 * @param string $route
3324
+	 * @param array  $additional_hidden_fields
3325
+	 */
3326
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3327
+	{
3328
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3329
+	}
3330
+
3331
+
3332
+	/**
3333
+	 * set form open and close tags on add/edit pages.
3334
+	 *
3335
+	 * @param string $route                    the route you want the form to direct to
3336
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3337
+	 * @return void
3338
+	 */
3339
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3340
+	{
3341
+		if (empty($route)) {
3342
+			$user_msg = esc_html__(
3343
+				'An error occurred. No action was set for this page\'s form.',
3344
+				'event_espresso'
3345
+			);
3346
+			$dev_msg = $user_msg . "\n"
3347
+					   . sprintf(
3348
+						   esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3349
+						   __FUNCTION__,
3350
+						   __CLASS__
3351
+					   );
3352
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3353
+		}
3354
+		// open form
3355
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3356
+															 . $this->_admin_base_url
3357
+															 . '" id="'
3358
+															 . $route
3359
+															 . '_event_form" >';
3360
+		// add nonce
3361
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3362
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3363
+		// add REQUIRED form action
3364
+		$hidden_fields = array(
3365
+			'action' => array('type' => 'hidden', 'value' => $route),
3366
+		);
3367
+		// merge arrays
3368
+		$hidden_fields = is_array($additional_hidden_fields)
3369
+			? array_merge($hidden_fields, $additional_hidden_fields)
3370
+			: $hidden_fields;
3371
+		// generate form fields
3372
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3373
+		// add fields to form
3374
+		foreach ((array) $form_fields as $field_name => $form_field) {
3375
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3376
+		}
3377
+		// close form
3378
+		$this->_template_args['after_admin_page_content'] = '</form>';
3379
+	}
3380
+
3381
+
3382
+	/**
3383
+	 * Public Wrapper for _redirect_after_action() method since its
3384
+	 * discovered it would be useful for external code to have access.
3385
+	 *
3386
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3387
+	 * @since 4.5.0
3388
+	 * @param bool   $success
3389
+	 * @param string $what
3390
+	 * @param string $action_desc
3391
+	 * @param array  $query_args
3392
+	 * @param bool   $override_overwrite
3393
+	 * @throws EE_Error
3394
+	 */
3395
+	public function redirect_after_action(
3396
+		$success = false,
3397
+		$what = 'item',
3398
+		$action_desc = 'processed',
3399
+		$query_args = array(),
3400
+		$override_overwrite = false
3401
+	) {
3402
+		$this->_redirect_after_action(
3403
+			$success,
3404
+			$what,
3405
+			$action_desc,
3406
+			$query_args,
3407
+			$override_overwrite
3408
+		);
3409
+	}
3410
+
3411
+
3412
+	/**
3413
+	 *    _redirect_after_action
3414
+	 *
3415
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3416
+	 * @param string $what               - what the action was performed on
3417
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3418
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3419
+	 *                                   action is completed
3420
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3421
+	 *                                   override this so that they show.
3422
+	 * @return void
3423
+	 * @throws EE_Error
3424
+	 */
3425
+	protected function _redirect_after_action(
3426
+		$success = 0,
3427
+		$what = 'item',
3428
+		$action_desc = 'processed',
3429
+		$query_args = array(),
3430
+		$override_overwrite = false
3431
+	) {
3432
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3433
+		// class name for actions/filters.
3434
+		$classname = get_class($this);
3435
+		// set redirect url.
3436
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3437
+		// otherwise we go with whatever is set as the _admin_base_url
3438
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3439
+		$notices = EE_Error::get_notices(false);
3440
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3441
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3442
+			EE_Error::overwrite_success();
3443
+		}
3444
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3445
+			// how many records affected ? more than one record ? or just one ?
3446
+			if ($success > 1) {
3447
+				// set plural msg
3448
+				EE_Error::add_success(
3449
+					sprintf(
3450
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3451
+						$what,
3452
+						$action_desc
3453
+					),
3454
+					__FILE__,
3455
+					__FUNCTION__,
3456
+					__LINE__
3457
+				);
3458
+			} elseif ($success === 1) {
3459
+				// set singular msg
3460
+				EE_Error::add_success(
3461
+					sprintf(
3462
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3463
+						$what,
3464
+						$action_desc
3465
+					),
3466
+					__FILE__,
3467
+					__FUNCTION__,
3468
+					__LINE__
3469
+				);
3470
+			}
3471
+		}
3472
+		// check that $query_args isn't something crazy
3473
+		if (! is_array($query_args)) {
3474
+			$query_args = array();
3475
+		}
3476
+		/**
3477
+		 * Allow injecting actions before the query_args are modified for possible different
3478
+		 * redirections on save and close actions
3479
+		 *
3480
+		 * @since 4.2.0
3481
+		 * @param array $query_args       The original query_args array coming into the
3482
+		 *                                method.
3483
+		 */
3484
+		do_action(
3485
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3486
+			$query_args
3487
+		);
3488
+		// calculate where we're going (if we have a "save and close" button pushed)
3489
+		if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3490
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3491
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3492
+			// regenerate query args array from referrer URL
3493
+			parse_str($parsed_url['query'], $query_args);
3494
+			// correct page and action will be in the query args now
3495
+			$redirect_url = admin_url('admin.php');
3496
+		}
3497
+		// merge any default query_args set in _default_route_query_args property
3498
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3499
+			$args_to_merge = array();
3500
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3501
+				// is there a wp_referer array in our _default_route_query_args property?
3502
+				if ($query_param === 'wp_referer') {
3503
+					$query_value = (array) $query_value;
3504
+					foreach ($query_value as $reference => $value) {
3505
+						if (strpos($reference, 'nonce') !== false) {
3506
+							continue;
3507
+						}
3508
+						// finally we will override any arguments in the referer with
3509
+						// what might be set on the _default_route_query_args array.
3510
+						if (isset($this->_default_route_query_args[ $reference ])) {
3511
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3512
+						} else {
3513
+							$args_to_merge[ $reference ] = urlencode($value);
3514
+						}
3515
+					}
3516
+					continue;
3517
+				}
3518
+				$args_to_merge[ $query_param ] = $query_value;
3519
+			}
3520
+			// now let's merge these arguments but override with what was specifically sent in to the
3521
+			// redirect.
3522
+			$query_args = array_merge($args_to_merge, $query_args);
3523
+		}
3524
+		$this->_process_notices($query_args);
3525
+		// generate redirect url
3526
+		// if redirecting to anything other than the main page, add a nonce
3527
+		if (isset($query_args['action'])) {
3528
+			// manually generate wp_nonce and merge that with the query vars
3529
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3530
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3531
+		}
3532
+		// we're adding some hooks and filters in here for processing any things just before redirects
3533
+		// (example: an admin page has done an insert or update and we want to run something after that).
3534
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3535
+		$redirect_url = apply_filters(
3536
+			'FHEE_redirect_' . $classname . $this->_req_action,
3537
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3538
+			$query_args
3539
+		);
3540
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3541
+		if (defined('DOING_AJAX')) {
3542
+			$default_data = array(
3543
+				'close'        => true,
3544
+				'redirect_url' => $redirect_url,
3545
+				'where'        => 'main',
3546
+				'what'         => 'append',
3547
+			);
3548
+			$this->_template_args['success'] = $success;
3549
+			$this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge(
3550
+				$default_data,
3551
+				$this->_template_args['data']
3552
+			) : $default_data;
3553
+			$this->_return_json();
3554
+		}
3555
+		wp_safe_redirect($redirect_url);
3556
+		exit();
3557
+	}
3558
+
3559
+
3560
+	/**
3561
+	 * process any notices before redirecting (or returning ajax request)
3562
+	 * This method sets the $this->_template_args['notices'] attribute;
3563
+	 *
3564
+	 * @param  array $query_args        any query args that need to be used for notice transient ('action')
3565
+	 * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and
3566
+	 *                                  page_routes haven't been defined yet.
3567
+	 * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we
3568
+	 *                                  still save a transient for the notice.
3569
+	 * @return void
3570
+	 * @throws EE_Error
3571
+	 */
3572
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3573
+	{
3574
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3575
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3576
+			$notices = EE_Error::get_notices(false);
3577
+			if (empty($this->_template_args['success'])) {
3578
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3579
+			}
3580
+			if (empty($this->_template_args['errors'])) {
3581
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3582
+			}
3583
+			if (empty($this->_template_args['attention'])) {
3584
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3585
+			}
3586
+		}
3587
+		$this->_template_args['notices'] = EE_Error::get_notices();
3588
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3589
+		if (! defined('DOING_AJAX') || $sticky_notices) {
3590
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3591
+			$this->_add_transient(
3592
+				$route,
3593
+				$this->_template_args['notices'],
3594
+				true,
3595
+				$skip_route_verify
3596
+			);
3597
+		}
3598
+	}
3599
+
3600
+
3601
+	/**
3602
+	 * get_action_link_or_button
3603
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3604
+	 *
3605
+	 * @param string $action        use this to indicate which action the url is generated with.
3606
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3607
+	 *                              property.
3608
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3609
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3610
+	 * @param string $base_url      If this is not provided
3611
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3612
+	 *                              Otherwise this value will be used.
3613
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3614
+	 * @return string
3615
+	 * @throws InvalidArgumentException
3616
+	 * @throws InvalidInterfaceException
3617
+	 * @throws InvalidDataTypeException
3618
+	 * @throws EE_Error
3619
+	 */
3620
+	public function get_action_link_or_button(
3621
+		$action,
3622
+		$type = 'add',
3623
+		$extra_request = array(),
3624
+		$class = 'button-primary',
3625
+		$base_url = '',
3626
+		$exclude_nonce = false
3627
+	) {
3628
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3629
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3630
+			throw new EE_Error(
3631
+				sprintf(
3632
+					esc_html__(
3633
+						'There is no page route for given action for the button.  This action was given: %s',
3634
+						'event_espresso'
3635
+					),
3636
+					$action
3637
+				)
3638
+			);
3639
+		}
3640
+		if (! isset($this->_labels['buttons'][ $type ])) {
3641
+			throw new EE_Error(
3642
+				sprintf(
3643
+					__(
3644
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3645
+						'event_espresso'
3646
+					),
3647
+					$type
3648
+				)
3649
+			);
3650
+		}
3651
+		// finally check user access for this button.
3652
+		$has_access = $this->check_user_access($action, true);
3653
+		if (! $has_access) {
3654
+			return '';
3655
+		}
3656
+		$_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3657
+		$query_args = array(
3658
+			'action' => $action,
3659
+		);
3660
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3661
+		if (! empty($extra_request)) {
3662
+			$query_args = array_merge($extra_request, $query_args);
3663
+		}
3664
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3665
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3666
+	}
3667
+
3668
+
3669
+	/**
3670
+	 * _per_page_screen_option
3671
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3672
+	 *
3673
+	 * @return void
3674
+	 * @throws InvalidArgumentException
3675
+	 * @throws InvalidInterfaceException
3676
+	 * @throws InvalidDataTypeException
3677
+	 */
3678
+	protected function _per_page_screen_option()
3679
+	{
3680
+		$option = 'per_page';
3681
+		$args = array(
3682
+			'label'   => apply_filters(
3683
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3684
+				$this->_admin_page_title,
3685
+				$this
3686
+			),
3687
+			'default' => (int) apply_filters(
3688
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3689
+				10
3690
+			),
3691
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3692
+		);
3693
+		// ONLY add the screen option if the user has access to it.
3694
+		if ($this->check_user_access($this->_current_view, true)) {
3695
+			add_screen_option($option, $args);
3696
+		}
3697
+	}
3698
+
3699
+
3700
+	/**
3701
+	 * set_per_page_screen_option
3702
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3703
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3704
+	 * admin_menu.
3705
+	 *
3706
+	 * @return void
3707
+	 */
3708
+	private function _set_per_page_screen_options()
3709
+	{
3710
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3711
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3712
+			if (! $user = wp_get_current_user()) {
3713
+				return;
3714
+			}
3715
+			$option = $_POST['wp_screen_options']['option'];
3716
+			$value = $_POST['wp_screen_options']['value'];
3717
+			if ($option != sanitize_key($option)) {
3718
+				return;
3719
+			}
3720
+			$map_option = $option;
3721
+			$option = str_replace('-', '_', $option);
3722
+			switch ($map_option) {
3723
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3724
+					$value = (int) $value;
3725
+					$max_value = apply_filters(
3726
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3727
+						999,
3728
+						$this->_current_page,
3729
+						$this->_current_view
3730
+					);
3731
+					if ($value < 1) {
3732
+						return;
3733
+					}
3734
+					$value = min($value, $max_value);
3735
+					break;
3736
+				default:
3737
+					$value = apply_filters(
3738
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3739
+						false,
3740
+						$option,
3741
+						$value
3742
+					);
3743
+					if (false === $value) {
3744
+						return;
3745
+					}
3746
+					break;
3747
+			}
3748
+			update_user_meta($user->ID, $option, $value);
3749
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3750
+			exit;
3751
+		}
3752
+	}
3753
+
3754
+
3755
+	/**
3756
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3757
+	 *
3758
+	 * @param array $data array that will be assigned to template args.
3759
+	 */
3760
+	public function set_template_args($data)
3761
+	{
3762
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3763
+	}
3764
+
3765
+
3766
+	/**
3767
+	 * This makes available the WP transient system for temporarily moving data between routes
3768
+	 *
3769
+	 * @param string $route             the route that should receive the transient
3770
+	 * @param array  $data              the data that gets sent
3771
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3772
+	 *                                  normal route transient.
3773
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3774
+	 *                                  when we are adding a transient before page_routes have been defined.
3775
+	 * @return void
3776
+	 * @throws EE_Error
3777
+	 */
3778
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3779
+	{
3780
+		$user_id = get_current_user_id();
3781
+		if (! $skip_route_verify) {
3782
+			$this->_verify_route($route);
3783
+		}
3784
+		// now let's set the string for what kind of transient we're setting
3785
+		$transient = $notices
3786
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3787
+			: 'rte_tx_' . $route . '_' . $user_id;
3788
+		$data = $notices ? array('notices' => $data) : $data;
3789
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3790
+		$existing = is_multisite() && is_network_admin()
3791
+			? get_site_transient($transient)
3792
+			: get_transient($transient);
3793
+		if ($existing) {
3794
+			$data = array_merge((array) $data, (array) $existing);
3795
+		}
3796
+		if (is_multisite() && is_network_admin()) {
3797
+			set_site_transient($transient, $data, 8);
3798
+		} else {
3799
+			set_transient($transient, $data, 8);
3800
+		}
3801
+	}
3802
+
3803
+
3804
+	/**
3805
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3806
+	 *
3807
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3808
+	 * @param string $route
3809
+	 * @return mixed data
3810
+	 */
3811
+	protected function _get_transient($notices = false, $route = '')
3812
+	{
3813
+		$user_id = get_current_user_id();
3814
+		$route = ! $route ? $this->_req_action : $route;
3815
+		$transient = $notices
3816
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3817
+			: 'rte_tx_' . $route . '_' . $user_id;
3818
+		$data = is_multisite() && is_network_admin()
3819
+			? get_site_transient($transient)
3820
+			: get_transient($transient);
3821
+		// delete transient after retrieval (just in case it hasn't expired);
3822
+		if (is_multisite() && is_network_admin()) {
3823
+			delete_site_transient($transient);
3824
+		} else {
3825
+			delete_transient($transient);
3826
+		}
3827
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3828
+	}
3829
+
3830
+
3831
+	/**
3832
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3833
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3834
+	 * default route callback on the EE_Admin page you want it run.)
3835
+	 *
3836
+	 * @return void
3837
+	 */
3838
+	protected function _transient_garbage_collection()
3839
+	{
3840
+		global $wpdb;
3841
+		// retrieve all existing transients
3842
+		$query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3843
+		if ($results = $wpdb->get_results($query)) {
3844
+			foreach ($results as $result) {
3845
+				$transient = str_replace('_transient_', '', $result->option_name);
3846
+				get_transient($transient);
3847
+				if (is_multisite() && is_network_admin()) {
3848
+					get_site_transient($transient);
3849
+				}
3850
+			}
3851
+		}
3852
+	}
3853
+
3854
+
3855
+	/**
3856
+	 * get_view
3857
+	 *
3858
+	 * @return string content of _view property
3859
+	 */
3860
+	public function get_view()
3861
+	{
3862
+		return $this->_view;
3863
+	}
3864
+
3865
+
3866
+	/**
3867
+	 * getter for the protected $_views property
3868
+	 *
3869
+	 * @return array
3870
+	 */
3871
+	public function get_views()
3872
+	{
3873
+		return $this->_views;
3874
+	}
3875
+
3876
+
3877
+	/**
3878
+	 * get_current_page
3879
+	 *
3880
+	 * @return string _current_page property value
3881
+	 */
3882
+	public function get_current_page()
3883
+	{
3884
+		return $this->_current_page;
3885
+	}
3886
+
3887
+
3888
+	/**
3889
+	 * get_current_view
3890
+	 *
3891
+	 * @return string _current_view property value
3892
+	 */
3893
+	public function get_current_view()
3894
+	{
3895
+		return $this->_current_view;
3896
+	}
3897
+
3898
+
3899
+	/**
3900
+	 * get_current_screen
3901
+	 *
3902
+	 * @return object The current WP_Screen object
3903
+	 */
3904
+	public function get_current_screen()
3905
+	{
3906
+		return $this->_current_screen;
3907
+	}
3908
+
3909
+
3910
+	/**
3911
+	 * get_current_page_view_url
3912
+	 *
3913
+	 * @return string This returns the url for the current_page_view.
3914
+	 */
3915
+	public function get_current_page_view_url()
3916
+	{
3917
+		return $this->_current_page_view_url;
3918
+	}
3919
+
3920
+
3921
+	/**
3922
+	 * just returns the _req_data property
3923
+	 *
3924
+	 * @return array
3925
+	 */
3926
+	public function get_request_data()
3927
+	{
3928
+		return $this->_req_data;
3929
+	}
3930
+
3931
+
3932
+	/**
3933
+	 * returns the _req_data protected property
3934
+	 *
3935
+	 * @return string
3936
+	 */
3937
+	public function get_req_action()
3938
+	{
3939
+		return $this->_req_action;
3940
+	}
3941
+
3942
+
3943
+	/**
3944
+	 * @return bool  value of $_is_caf property
3945
+	 */
3946
+	public function is_caf()
3947
+	{
3948
+		return $this->_is_caf;
3949
+	}
3950
+
3951
+
3952
+	/**
3953
+	 * @return mixed
3954
+	 */
3955
+	public function default_espresso_metaboxes()
3956
+	{
3957
+		return $this->_default_espresso_metaboxes;
3958
+	}
3959
+
3960
+
3961
+	/**
3962
+	 * @return mixed
3963
+	 */
3964
+	public function admin_base_url()
3965
+	{
3966
+		return $this->_admin_base_url;
3967
+	}
3968
+
3969
+
3970
+	/**
3971
+	 * @return mixed
3972
+	 */
3973
+	public function wp_page_slug()
3974
+	{
3975
+		return $this->_wp_page_slug;
3976
+	}
3977
+
3978
+
3979
+	/**
3980
+	 * updates  espresso configuration settings
3981
+	 *
3982
+	 * @param string                   $tab
3983
+	 * @param EE_Config_Base|EE_Config $config
3984
+	 * @param string                   $file file where error occurred
3985
+	 * @param string                   $func function  where error occurred
3986
+	 * @param string                   $line line no where error occurred
3987
+	 * @return boolean
3988
+	 */
3989
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3990
+	{
3991
+		// remove any options that are NOT going to be saved with the config settings.
3992
+		if (isset($config->core->ee_ueip_optin)) {
3993
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3994
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3995
+			update_option('ee_ueip_has_notified', true);
3996
+		}
3997
+		// and save it (note we're also doing the network save here)
3998
+		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3999
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4000
+		if ($config_saved && $net_saved) {
4001
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4002
+			return true;
4003
+		}
4004
+		EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4005
+		return false;
4006
+	}
4007
+
4008
+
4009
+	/**
4010
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4011
+	 *
4012
+	 * @return array
4013
+	 */
4014
+	public function get_yes_no_values()
4015
+	{
4016
+		return $this->_yes_no_values;
4017
+	}
4018
+
4019
+
4020
+	protected function _get_dir()
4021
+	{
4022
+		$reflector = new ReflectionClass(get_class($this));
4023
+		return dirname($reflector->getFileName());
4024
+	}
4025
+
4026
+
4027
+	/**
4028
+	 * A helper for getting a "next link".
4029
+	 *
4030
+	 * @param string $url   The url to link to
4031
+	 * @param string $class The class to use.
4032
+	 * @return string
4033
+	 */
4034
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4035
+	{
4036
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4037
+	}
4038
+
4039
+
4040
+	/**
4041
+	 * A helper for getting a "previous link".
4042
+	 *
4043
+	 * @param string $url   The url to link to
4044
+	 * @param string $class The class to use.
4045
+	 * @return string
4046
+	 */
4047
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4048
+	{
4049
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4050
+	}
4051
+
4052
+
4053
+
4054
+
4055
+
4056
+
4057
+
4058
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4059
+
4060
+
4061
+	/**
4062
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4063
+	 * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4064
+	 * _req_data array.
4065
+	 *
4066
+	 * @return bool success/fail
4067
+	 * @throws EE_Error
4068
+	 * @throws InvalidArgumentException
4069
+	 * @throws ReflectionException
4070
+	 * @throws InvalidDataTypeException
4071
+	 * @throws InvalidInterfaceException
4072
+	 */
4073
+	protected function _process_resend_registration()
4074
+	{
4075
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4076
+		do_action(
4077
+			'AHEE__EE_Admin_Page___process_resend_registration',
4078
+			$this->_template_args['success'],
4079
+			$this->_req_data
4080
+		);
4081
+		return $this->_template_args['success'];
4082
+	}
4083
+
4084
+
4085
+	/**
4086
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4087
+	 *
4088
+	 * @param \EE_Payment $payment
4089
+	 * @return bool success/fail
4090
+	 */
4091
+	protected function _process_payment_notification(EE_Payment $payment)
4092
+	{
4093
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4094
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4095
+		$this->_template_args['success'] = apply_filters(
4096
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4097
+			false,
4098
+			$payment
4099
+		);
4100
+		return $this->_template_args['success'];
4101
+	}
4102 4102
 }
Please login to merge, or discard this patch.
core/services/validators/JsonValidator.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public function isValid($file, $func, $line)
34 34
     {
35
-        if (! defined('JSON_ERROR_RECURSION')) {
35
+        if ( ! defined('JSON_ERROR_RECURSION')) {
36 36
             define('JSON_ERROR_RECURSION', 6);
37 37
         }
38
-        if (! defined('JSON_ERROR_INF_OR_NAN')) {
38
+        if ( ! defined('JSON_ERROR_INF_OR_NAN')) {
39 39
             define('JSON_ERROR_INF_OR_NAN', 7);
40 40
         }
41
-        if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
41
+        if ( ! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
42 42
             define('JSON_ERROR_UNSUPPORTED_TYPE', 8);
43 43
         }
44
-        if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
44
+        if ( ! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
45 45
             define('JSON_ERROR_INVALID_PROPERTY_NAME', 9);
46 46
         }
47
-        if (! defined('JSON_ERROR_UTF16')) {
47
+        if ( ! defined('JSON_ERROR_UTF16')) {
48 48
             define('JSON_ERROR_UTF16', 10);
49 49
         }
50 50
         switch (json_last_error()) {
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                 $error = ': Unknown error';
85 85
                 break;
86 86
         }
87
-        EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line);
87
+        EE_Error::add_error('JSON decoding failed'.$error, $file, $func, $line);
88 88
         return false;
89 89
     }
90 90
 }
Please login to merge, or discard this patch.
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -18,76 +18,76 @@
 block discarded – undo
18 18
 class JsonValidator
19 19
 {
20 20
 
21
-    /**
22
-     * Call this method IMMEDIATELY after json_decode() and
23
-     * it will will return true if the decoded JSON was valid,
24
-     * or return false after adding an error if not valid.
25
-     * The actual JSON file does not need to be supplied,
26
-     * but details re: code execution location are required.
27
-     * ex:
28
-     * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__)
29
-     *
30
-     * @param string $file
31
-     * @param string $func
32
-     * @param string $line
33
-     * @return boolean
34
-     * @since 4.9.70.p
35
-     */
36
-    public function isValid($file, $func, $line)
37
-    {
38
-        if (! defined('JSON_ERROR_RECURSION')) {
39
-            define('JSON_ERROR_RECURSION', 6);
40
-        }
41
-        if (! defined('JSON_ERROR_INF_OR_NAN')) {
42
-            define('JSON_ERROR_INF_OR_NAN', 7);
43
-        }
44
-        if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
45
-            define('JSON_ERROR_UNSUPPORTED_TYPE', 8);
46
-        }
47
-        if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
48
-            define('JSON_ERROR_INVALID_PROPERTY_NAME', 9);
49
-        }
50
-        if (! defined('JSON_ERROR_UTF16')) {
51
-            define('JSON_ERROR_UTF16', 10);
52
-        }
53
-        switch (json_last_error()) {
54
-            case JSON_ERROR_NONE:
55
-                return true;
56
-            case JSON_ERROR_DEPTH:
57
-                $error = ': Maximum stack depth exceeded';
58
-                break;
59
-            case JSON_ERROR_STATE_MISMATCH:
60
-                $error = ': Invalid or malformed JSON';
61
-                break;
62
-            case JSON_ERROR_CTRL_CHAR:
63
-                $error = ': Control character error, possible malformed JSON';
64
-                break;
65
-            case JSON_ERROR_SYNTAX:
66
-                $error = ': Syntax error, malformed JSON';
67
-                break;
68
-            case JSON_ERROR_UTF8:
69
-                $error = ': Malformed UTF-8 characters, possible malformed JSON';
70
-                break;
71
-            case JSON_ERROR_RECURSION:
72
-                $error = ': One or more recursive references in the value to be encoded';
73
-                break;
74
-            case JSON_ERROR_INF_OR_NAN:
75
-                $error = ': One or more NAN or INF values in the value to be encoded';
76
-                break;
77
-            case JSON_ERROR_UNSUPPORTED_TYPE:
78
-                $error = ': A value of a type that cannot be encoded was given';
79
-                break;
80
-            case JSON_ERROR_INVALID_PROPERTY_NAME:
81
-                $error = ': A property name that cannot be encoded was given';
82
-                break;
83
-            case JSON_ERROR_UTF16:
84
-                $error = ': Malformed UTF-16 characters, possibly incorrectly encoded';
85
-                break;
86
-            default:
87
-                $error = ': Unknown error';
88
-                break;
89
-        }
90
-        EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line);
91
-        return false;
92
-    }
21
+	/**
22
+	 * Call this method IMMEDIATELY after json_decode() and
23
+	 * it will will return true if the decoded JSON was valid,
24
+	 * or return false after adding an error if not valid.
25
+	 * The actual JSON file does not need to be supplied,
26
+	 * but details re: code execution location are required.
27
+	 * ex:
28
+	 * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__)
29
+	 *
30
+	 * @param string $file
31
+	 * @param string $func
32
+	 * @param string $line
33
+	 * @return boolean
34
+	 * @since 4.9.70.p
35
+	 */
36
+	public function isValid($file, $func, $line)
37
+	{
38
+		if (! defined('JSON_ERROR_RECURSION')) {
39
+			define('JSON_ERROR_RECURSION', 6);
40
+		}
41
+		if (! defined('JSON_ERROR_INF_OR_NAN')) {
42
+			define('JSON_ERROR_INF_OR_NAN', 7);
43
+		}
44
+		if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
45
+			define('JSON_ERROR_UNSUPPORTED_TYPE', 8);
46
+		}
47
+		if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
48
+			define('JSON_ERROR_INVALID_PROPERTY_NAME', 9);
49
+		}
50
+		if (! defined('JSON_ERROR_UTF16')) {
51
+			define('JSON_ERROR_UTF16', 10);
52
+		}
53
+		switch (json_last_error()) {
54
+			case JSON_ERROR_NONE:
55
+				return true;
56
+			case JSON_ERROR_DEPTH:
57
+				$error = ': Maximum stack depth exceeded';
58
+				break;
59
+			case JSON_ERROR_STATE_MISMATCH:
60
+				$error = ': Invalid or malformed JSON';
61
+				break;
62
+			case JSON_ERROR_CTRL_CHAR:
63
+				$error = ': Control character error, possible malformed JSON';
64
+				break;
65
+			case JSON_ERROR_SYNTAX:
66
+				$error = ': Syntax error, malformed JSON';
67
+				break;
68
+			case JSON_ERROR_UTF8:
69
+				$error = ': Malformed UTF-8 characters, possible malformed JSON';
70
+				break;
71
+			case JSON_ERROR_RECURSION:
72
+				$error = ': One or more recursive references in the value to be encoded';
73
+				break;
74
+			case JSON_ERROR_INF_OR_NAN:
75
+				$error = ': One or more NAN or INF values in the value to be encoded';
76
+				break;
77
+			case JSON_ERROR_UNSUPPORTED_TYPE:
78
+				$error = ': A value of a type that cannot be encoded was given';
79
+				break;
80
+			case JSON_ERROR_INVALID_PROPERTY_NAME:
81
+				$error = ': A property name that cannot be encoded was given';
82
+				break;
83
+			case JSON_ERROR_UTF16:
84
+				$error = ': Malformed UTF-16 characters, possibly incorrectly encoded';
85
+				break;
86
+			default:
87
+				$error = ': Unknown error';
88
+				break;
89
+		}
90
+		EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line);
91
+		return false;
92
+	}
93 93
 }
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 2 patches
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     public static function instance(ClassInterfaceCache $class_cache = null)
123 123
     {
124 124
         // check if class object is instantiated, and instantiated properly
125
-        if (! self::$_instance instanceof EE_Dependency_Map
125
+        if ( ! self::$_instance instanceof EE_Dependency_Map
126 126
             && $class_cache instanceof ClassInterfaceCache
127 127
         ) {
128 128
             self::$_instance = new EE_Dependency_Map($class_cache);
@@ -203,18 +203,18 @@  discard block
 block discarded – undo
203 203
     ) {
204 204
         $class = trim($class, '\\');
205 205
         $registered = false;
206
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
207
-            self::$_instance->_dependency_map[ $class ] = array();
206
+        if (empty(self::$_instance->_dependency_map[$class])) {
207
+            self::$_instance->_dependency_map[$class] = array();
208 208
         }
209 209
         // we need to make sure that any aliases used when registering a dependency
210 210
         // get resolved to the correct class name
211 211
         foreach ($dependencies as $dependency => $load_source) {
212 212
             $alias = self::$_instance->getFqnForAlias($dependency);
213 213
             if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
214
+                || ! isset(self::$_instance->_dependency_map[$class][$alias])
215 215
             ) {
216
-                unset($dependencies[ $dependency ]);
217
-                $dependencies[ $alias ] = $load_source;
216
+                unset($dependencies[$dependency]);
217
+                $dependencies[$alias] = $load_source;
218 218
                 $registered = true;
219 219
             }
220 220
         }
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
         // ie: with A = B + C, entries in B take precedence over duplicate entries in C
225 225
         // Union is way faster than array_merge() but should be used with caution...
226 226
         // especially with numerically indexed arrays
227
-        $dependencies += self::$_instance->_dependency_map[ $class ];
227
+        $dependencies += self::$_instance->_dependency_map[$class];
228 228
         // now we need to ensure that the resulting dependencies
229 229
         // array only has the entries that are required for the class
230 230
         // so first count how many dependencies were originally registered for the class
231
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
231
+        $dependency_count = count(self::$_instance->_dependency_map[$class]);
232 232
         // if that count is non-zero (meaning dependencies were already registered)
233
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
233
+        self::$_instance->_dependency_map[$class] = $dependency_count
234 234
             // then truncate the  final array to match that count
235 235
             ? array_slice($dependencies, 0, $dependency_count)
236 236
             // otherwise just take the incoming array because nothing previously existed
@@ -247,13 +247,13 @@  discard block
 block discarded – undo
247 247
      */
248 248
     public static function register_class_loader($class_name, $loader = 'load_core')
249 249
     {
250
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
250
+        if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251 251
             throw new DomainException(
252 252
                 esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253 253
             );
254 254
         }
255 255
         // check that loader is callable or method starts with "load_" and exists in EE_Registry
256
-        if (! is_callable($loader)
256
+        if ( ! is_callable($loader)
257 257
             && (
258 258
                 strpos($loader, 'load_') !== 0
259 259
                 || ! method_exists('EE_Registry', $loader)
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
             );
271 271
         }
272 272
         $class_name = self::$_instance->getFqnForAlias($class_name);
273
-        if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
-            self::$_instance->_class_loaders[ $class_name ] = $loader;
273
+        if ( ! isset(self::$_instance->_class_loaders[$class_name])) {
274
+            self::$_instance->_class_loaders[$class_name] = $loader;
275 275
             return true;
276 276
         }
277 277
         return false;
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         if (strpos($class_name, 'EEM_') === 0) {
300 300
             $class_name = 'LEGACY_MODELS';
301 301
         }
302
-        return isset($this->_dependency_map[ $class_name ]) ? true : false;
302
+        return isset($this->_dependency_map[$class_name]) ? true : false;
303 303
     }
304 304
 
305 305
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
             $class_name = 'LEGACY_MODELS';
318 318
         }
319 319
         $dependency = $this->getFqnForAlias($dependency, $class_name);
320
-        return isset($this->_dependency_map[ $class_name ][ $dependency ])
320
+        return isset($this->_dependency_map[$class_name][$dependency])
321 321
             ? true
322 322
             : false;
323 323
     }
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
         }
339 339
         $dependency = $this->getFqnForAlias($dependency);
340 340
         return $this->has_dependency_for_class($class_name, $dependency)
341
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
341
+            ? $this->_dependency_map[$class_name][$dependency]
342 342
             : EE_Dependency_Map::not_registered;
343 343
     }
344 344
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
             return 'load_core';
362 362
         }
363 363
         $class_name = $this->getFqnForAlias($class_name);
364
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
364
+        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
365 365
     }
366 366
 
367 367
 
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
     {
866 866
         $this->_class_loaders = array(
867 867
             // load_core
868
-            'EE_Dependency_Map'                            => function () {
868
+            'EE_Dependency_Map'                            => function() {
869 869
                 return $this;
870 870
             },
871 871
             'EE_Capabilities'                              => 'load_core',
@@ -873,13 +873,13 @@  discard block
 block discarded – undo
873 873
             'EE_Front_Controller'                          => 'load_core',
874 874
             'EE_Module_Request_Router'                     => 'load_core',
875 875
             'EE_Registry'                                  => 'load_core',
876
-            'EE_Request'                                   => function () {
876
+            'EE_Request'                                   => function() {
877 877
                 return $this->legacy_request;
878 878
             },
879
-            'EventEspresso\core\services\request\Request'  => function () {
879
+            'EventEspresso\core\services\request\Request'  => function() {
880 880
                 return $this->request;
881 881
             },
882
-            'EventEspresso\core\services\request\Response' => function () {
882
+            'EventEspresso\core\services\request\Response' => function() {
883 883
                 return $this->response;
884 884
             },
885 885
             'EE_Base'                                      => 'load_core',
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
             'EE_Messages_Data_Handler_Collection'          => 'load_lib',
904 904
             'EE_Message_Template_Group_Collection'         => 'load_lib',
905 905
             'EE_Payment_Method_Manager'                    => 'load_lib',
906
-            'EE_Messages_Generator'                        => function () {
906
+            'EE_Messages_Generator'                        => function() {
907 907
                 return EE_Registry::instance()->load_lib(
908 908
                     'Messages_Generator',
909 909
                     array(),
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
                     false
912 912
                 );
913 913
             },
914
-            'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
914
+            'EE_Messages_Template_Defaults'                => function($arguments = array()) {
915 915
                 return EE_Registry::instance()->load_lib(
916 916
                     'Messages_Template_Defaults',
917 917
                     $arguments,
@@ -920,43 +920,43 @@  discard block
 block discarded – undo
920 920
                 );
921 921
             },
922 922
             // load_helper
923
-            'EEH_Parse_Shortcodes'                         => function () {
923
+            'EEH_Parse_Shortcodes'                         => function() {
924 924
                 if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
925 925
                     return new EEH_Parse_Shortcodes();
926 926
                 }
927 927
                 return null;
928 928
             },
929
-            'EE_Template_Config'                           => function () {
929
+            'EE_Template_Config'                           => function() {
930 930
                 return EE_Config::instance()->template_settings;
931 931
             },
932
-            'EE_Currency_Config'                           => function () {
932
+            'EE_Currency_Config'                           => function() {
933 933
                 return EE_Config::instance()->currency;
934 934
             },
935
-            'EE_Registration_Config'                       => function () {
935
+            'EE_Registration_Config'                       => function() {
936 936
                 return EE_Config::instance()->registration;
937 937
             },
938
-            'EE_Core_Config'                               => function () {
938
+            'EE_Core_Config'                               => function() {
939 939
                 return EE_Config::instance()->core;
940 940
             },
941
-            'EventEspresso\core\services\loaders\Loader'   => function () {
941
+            'EventEspresso\core\services\loaders\Loader'   => function() {
942 942
                 return LoaderFactory::getLoader();
943 943
             },
944
-            'EE_Network_Config'                            => function () {
944
+            'EE_Network_Config'                            => function() {
945 945
                 return EE_Network_Config::instance();
946 946
             },
947
-            'EE_Config'                                    => function () {
947
+            'EE_Config'                                    => function() {
948 948
                 return EE_Config::instance();
949 949
             },
950
-            'EventEspresso\core\domain\Domain'             => function () {
950
+            'EventEspresso\core\domain\Domain'             => function() {
951 951
                 return DomainFactory::getEventEspressoCoreDomain();
952 952
             },
953
-            'EE_Admin_Config'                              => function () {
953
+            'EE_Admin_Config'                              => function() {
954 954
                 return EE_Config::instance()->admin;
955 955
             },
956
-            'EE_Organization_Config'                       => function () {
956
+            'EE_Organization_Config'                       => function() {
957 957
                 return EE_Config::instance()->organization;
958 958
             },
959
-            'EE_Network_Core_Config'                            => function () {
959
+            'EE_Network_Core_Config'                            => function() {
960 960
                 return EE_Network_Config::instance()->core;
961 961
             },
962 962
         );
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
             }
1018 1018
             $this->class_cache->addAlias($fqn, $alias);
1019 1019
         }
1020
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1020
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1021 1021
             $this->class_cache->addAlias(
1022 1022
                 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1023 1023
                 'EventEspresso\core\services\notices\NoticeConverterInterface'
Please login to merge, or discard this patch.
Indentation   +1069 added lines, -1069 removed lines patch added patch discarded remove patch
@@ -20,1073 +20,1073 @@
 block discarded – undo
20 20
 class EE_Dependency_Map
21 21
 {
22 22
 
23
-    /**
24
-     * This means that the requested class dependency is not present in the dependency map
25
-     */
26
-    const not_registered = 0;
27
-
28
-    /**
29
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
-     */
31
-    const load_new_object = 1;
32
-
33
-    /**
34
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
-     */
37
-    const load_from_cache = 2;
38
-
39
-    /**
40
-     * When registering a dependency,
41
-     * this indicates to keep any existing dependencies that already exist,
42
-     * and simply discard any new dependencies declared in the incoming data
43
-     */
44
-    const KEEP_EXISTING_DEPENDENCIES = 0;
45
-
46
-    /**
47
-     * When registering a dependency,
48
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
-     */
50
-    const OVERWRITE_DEPENDENCIES = 1;
51
-
52
-
53
-    /**
54
-     * @type EE_Dependency_Map $_instance
55
-     */
56
-    protected static $_instance;
57
-
58
-    /**
59
-     * @var ClassInterfaceCache $class_cache
60
-     */
61
-    private $class_cache;
62
-
63
-    /**
64
-     * @type RequestInterface $request
65
-     */
66
-    protected $request;
67
-
68
-    /**
69
-     * @type LegacyRequestInterface $legacy_request
70
-     */
71
-    protected $legacy_request;
72
-
73
-    /**
74
-     * @type ResponseInterface $response
75
-     */
76
-    protected $response;
77
-
78
-    /**
79
-     * @type LoaderInterface $loader
80
-     */
81
-    protected $loader;
82
-
83
-    /**
84
-     * @type array $_dependency_map
85
-     */
86
-    protected $_dependency_map = array();
87
-
88
-    /**
89
-     * @type array $_class_loaders
90
-     */
91
-    protected $_class_loaders = array();
92
-
93
-
94
-    /**
95
-     * EE_Dependency_Map constructor.
96
-     *
97
-     * @param ClassInterfaceCache $class_cache
98
-     */
99
-    protected function __construct(ClassInterfaceCache $class_cache)
100
-    {
101
-        $this->class_cache = $class_cache;
102
-        do_action('EE_Dependency_Map____construct', $this);
103
-    }
104
-
105
-
106
-    /**
107
-     * @return void
108
-     */
109
-    public function initialize()
110
-    {
111
-        $this->_register_core_dependencies();
112
-        $this->_register_core_class_loaders();
113
-        $this->_register_core_aliases();
114
-    }
115
-
116
-
117
-    /**
118
-     * @singleton method used to instantiate class object
119
-     * @param ClassInterfaceCache|null $class_cache
120
-     * @return EE_Dependency_Map
121
-     */
122
-    public static function instance(ClassInterfaceCache $class_cache = null)
123
-    {
124
-        // check if class object is instantiated, and instantiated properly
125
-        if (! self::$_instance instanceof EE_Dependency_Map
126
-            && $class_cache instanceof ClassInterfaceCache
127
-        ) {
128
-            self::$_instance = new EE_Dependency_Map($class_cache);
129
-        }
130
-        return self::$_instance;
131
-    }
132
-
133
-
134
-    /**
135
-     * @param RequestInterface $request
136
-     */
137
-    public function setRequest(RequestInterface $request)
138
-    {
139
-        $this->request = $request;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param LegacyRequestInterface $legacy_request
145
-     */
146
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
-    {
148
-        $this->legacy_request = $legacy_request;
149
-    }
150
-
151
-
152
-    /**
153
-     * @param ResponseInterface $response
154
-     */
155
-    public function setResponse(ResponseInterface $response)
156
-    {
157
-        $this->response = $response;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param LoaderInterface $loader
163
-     */
164
-    public function setLoader(LoaderInterface $loader)
165
-    {
166
-        $this->loader = $loader;
167
-    }
168
-
169
-
170
-    /**
171
-     * @param string $class
172
-     * @param array  $dependencies
173
-     * @param int    $overwrite
174
-     * @return bool
175
-     */
176
-    public static function register_dependencies(
177
-        $class,
178
-        array $dependencies,
179
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
-    ) {
181
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
-    }
183
-
184
-
185
-    /**
186
-     * Assigns an array of class names and corresponding load sources (new or cached)
187
-     * to the class specified by the first parameter.
188
-     * IMPORTANT !!!
189
-     * The order of elements in the incoming $dependencies array MUST match
190
-     * the order of the constructor parameters for the class in question.
191
-     * This is especially important when overriding any existing dependencies that are registered.
192
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
-     *
194
-     * @param string $class
195
-     * @param array  $dependencies
196
-     * @param int    $overwrite
197
-     * @return bool
198
-     */
199
-    public function registerDependencies(
200
-        $class,
201
-        array $dependencies,
202
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
-    ) {
204
-        $class = trim($class, '\\');
205
-        $registered = false;
206
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
207
-            self::$_instance->_dependency_map[ $class ] = array();
208
-        }
209
-        // we need to make sure that any aliases used when registering a dependency
210
-        // get resolved to the correct class name
211
-        foreach ($dependencies as $dependency => $load_source) {
212
-            $alias = self::$_instance->getFqnForAlias($dependency);
213
-            if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
-            ) {
216
-                unset($dependencies[ $dependency ]);
217
-                $dependencies[ $alias ] = $load_source;
218
-                $registered = true;
219
-            }
220
-        }
221
-        // now add our two lists of dependencies together.
222
-        // using Union (+=) favours the arrays in precedence from left to right,
223
-        // so $dependencies is NOT overwritten because it is listed first
224
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
-        // Union is way faster than array_merge() but should be used with caution...
226
-        // especially with numerically indexed arrays
227
-        $dependencies += self::$_instance->_dependency_map[ $class ];
228
-        // now we need to ensure that the resulting dependencies
229
-        // array only has the entries that are required for the class
230
-        // so first count how many dependencies were originally registered for the class
231
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
-        // if that count is non-zero (meaning dependencies were already registered)
233
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
234
-            // then truncate the  final array to match that count
235
-            ? array_slice($dependencies, 0, $dependency_count)
236
-            // otherwise just take the incoming array because nothing previously existed
237
-            : $dependencies;
238
-        return $registered;
239
-    }
240
-
241
-
242
-    /**
243
-     * @param string $class_name
244
-     * @param string $loader
245
-     * @return bool
246
-     * @throws DomainException
247
-     */
248
-    public static function register_class_loader($class_name, $loader = 'load_core')
249
-    {
250
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
-            throw new DomainException(
252
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
-            );
254
-        }
255
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
256
-        if (! is_callable($loader)
257
-            && (
258
-                strpos($loader, 'load_') !== 0
259
-                || ! method_exists('EE_Registry', $loader)
260
-            )
261
-        ) {
262
-            throw new DomainException(
263
-                sprintf(
264
-                    esc_html__(
265
-                        '"%1$s" is not a valid loader method on EE_Registry.',
266
-                        'event_espresso'
267
-                    ),
268
-                    $loader
269
-                )
270
-            );
271
-        }
272
-        $class_name = self::$_instance->getFqnForAlias($class_name);
273
-        if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
-            self::$_instance->_class_loaders[ $class_name ] = $loader;
275
-            return true;
276
-        }
277
-        return false;
278
-    }
279
-
280
-
281
-    /**
282
-     * @return array
283
-     */
284
-    public function dependency_map()
285
-    {
286
-        return $this->_dependency_map;
287
-    }
288
-
289
-
290
-    /**
291
-     * returns TRUE if dependency map contains a listing for the provided class name
292
-     *
293
-     * @param string $class_name
294
-     * @return boolean
295
-     */
296
-    public function has($class_name = '')
297
-    {
298
-        // all legacy models have the same dependencies
299
-        if (strpos($class_name, 'EEM_') === 0) {
300
-            $class_name = 'LEGACY_MODELS';
301
-        }
302
-        return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
-    }
304
-
305
-
306
-    /**
307
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
-     *
309
-     * @param string $class_name
310
-     * @param string $dependency
311
-     * @return bool
312
-     */
313
-    public function has_dependency_for_class($class_name = '', $dependency = '')
314
-    {
315
-        // all legacy models have the same dependencies
316
-        if (strpos($class_name, 'EEM_') === 0) {
317
-            $class_name = 'LEGACY_MODELS';
318
-        }
319
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
320
-        return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
-            ? true
322
-            : false;
323
-    }
324
-
325
-
326
-    /**
327
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
-     *
329
-     * @param string $class_name
330
-     * @param string $dependency
331
-     * @return int
332
-     */
333
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
-    {
335
-        // all legacy models have the same dependencies
336
-        if (strpos($class_name, 'EEM_') === 0) {
337
-            $class_name = 'LEGACY_MODELS';
338
-        }
339
-        $dependency = $this->getFqnForAlias($dependency);
340
-        return $this->has_dependency_for_class($class_name, $dependency)
341
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
342
-            : EE_Dependency_Map::not_registered;
343
-    }
344
-
345
-
346
-    /**
347
-     * @param string $class_name
348
-     * @return string | Closure
349
-     */
350
-    public function class_loader($class_name)
351
-    {
352
-        // all legacy models use load_model()
353
-        if (strpos($class_name, 'EEM_') === 0) {
354
-            return 'load_model';
355
-        }
356
-        // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
-        // perform strpos() first to avoid loading regex every time we load a class
358
-        if (strpos($class_name, 'EE_CPT_') === 0
359
-            && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
-        ) {
361
-            return 'load_core';
362
-        }
363
-        $class_name = $this->getFqnForAlias($class_name);
364
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
-    }
366
-
367
-
368
-    /**
369
-     * @return array
370
-     */
371
-    public function class_loaders()
372
-    {
373
-        return $this->_class_loaders;
374
-    }
375
-
376
-
377
-    /**
378
-     * adds an alias for a classname
379
-     *
380
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
-     */
384
-    public function add_alias($fqcn, $alias, $for_class = '')
385
-    {
386
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
387
-    }
388
-
389
-
390
-    /**
391
-     * Returns TRUE if the provided fully qualified name IS an alias
392
-     * WHY?
393
-     * Because if a class is type hinting for a concretion,
394
-     * then why would we need to find another class to supply it?
395
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
-     * Don't go looking for some substitute.
398
-     * Whereas if a class is type hinting for an interface...
399
-     * then we need to find an actual class to use.
400
-     * So the interface IS the alias for some other FQN,
401
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
-     * represents some other class.
403
-     *
404
-     * @param string $fqn
405
-     * @param string $for_class
406
-     * @return bool
407
-     */
408
-    public function isAlias($fqn = '', $for_class = '')
409
-    {
410
-        return $this->class_cache->isAlias($fqn, $for_class);
411
-    }
412
-
413
-
414
-    /**
415
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
-     *  for example:
418
-     *      if the following two entries were added to the _aliases array:
419
-     *          array(
420
-     *              'interface_alias'           => 'some\namespace\interface'
421
-     *              'some\namespace\interface'  => 'some\namespace\classname'
422
-     *          )
423
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
-     *      to load an instance of 'some\namespace\classname'
425
-     *
426
-     * @param string $alias
427
-     * @param string $for_class
428
-     * @return string
429
-     */
430
-    public function getFqnForAlias($alias = '', $for_class = '')
431
-    {
432
-        return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
-    }
434
-
435
-
436
-    /**
437
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
-     * This is done by using the following class constants:
440
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
442
-     */
443
-    protected function _register_core_dependencies()
444
-    {
445
-        $this->_dependency_map = array(
446
-            'EE_Request_Handler'                                                                                          => array(
447
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
448
-            ),
449
-            'EE_System'                                                                                                   => array(
450
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
-            ),
455
-            'EE_Session'                                                                                                  => array(
456
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
-                'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
460
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
461
-            ),
462
-            'EE_Cart'                                                                                                     => array(
463
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
464
-            ),
465
-            'EE_Front_Controller'                                                                                         => array(
466
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
467
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
468
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
469
-            ),
470
-            'EE_Messenger_Collection_Loader'                                                                              => array(
471
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
472
-            ),
473
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
474
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
475
-            ),
476
-            'EE_Message_Resource_Manager'                                                                                 => array(
477
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
478
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
479
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
480
-            ),
481
-            'EE_Message_Factory'                                                                                          => array(
482
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
483
-            ),
484
-            'EE_messages'                                                                                                 => array(
485
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
-            ),
487
-            'EE_Messages_Generator'                                                                                       => array(
488
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
489
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
490
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
491
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
492
-            ),
493
-            'EE_Messages_Processor'                                                                                       => array(
494
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
495
-            ),
496
-            'EE_Messages_Queue'                                                                                           => array(
497
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
498
-            ),
499
-            'EE_Messages_Template_Defaults'                                                                               => array(
500
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
501
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
502
-            ),
503
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
504
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
506
-            ),
507
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
508
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
509
-            ),
510
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
511
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
512
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
513
-            ),
514
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
515
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
516
-            ),
517
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
518
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
519
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
520
-            ),
521
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
522
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
523
-            ),
524
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
525
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
526
-            ),
527
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
528
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
529
-            ),
530
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
531
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
532
-            ),
533
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
534
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
535
-            ),
536
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
537
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
538
-            ),
539
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
540
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
541
-            ),
542
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
543
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
546
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
547
-            ),
548
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
549
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
550
-            ),
551
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
552
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
553
-            ),
554
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
555
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
556
-            ),
557
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
558
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
559
-            ),
560
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
561
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
562
-            ),
563
-            'EE_Data_Migration_Class_Base'                                                                                => array(
564
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
-            ),
567
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
568
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
-            ),
571
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
572
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
-            ),
575
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
576
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
-            ),
579
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
580
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
-            ),
583
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
584
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
-            ),
587
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
588
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
-            ),
591
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
592
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
-            ),
595
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
596
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
597
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
598
-            ),
599
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
600
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
601
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
602
-            ),
603
-            'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
604
-                array(),
605
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
606
-            ),
607
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
608
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
609
-                'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
610
-            ),
611
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
612
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
613
-            ),
614
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
615
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
616
-            ),
617
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
618
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
619
-            ),
620
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
621
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
622
-            ),
623
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
624
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
625
-            ),
626
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
627
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
628
-            ),
629
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
630
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
631
-            ),
632
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
633
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
634
-            ),
635
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
636
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
637
-            ),
638
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
639
-                'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
640
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
641
-            ),
642
-            'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
643
-                null,
644
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
645
-            ),
646
-            'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
647
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
648
-            ),
649
-            'LEGACY_MODELS'                                                                                               => array(
650
-                null,
651
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
652
-            ),
653
-            'EE_Module_Request_Router'                                                                                    => array(
654
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
655
-            ),
656
-            'EE_Registration_Processor'                                                                                   => array(
657
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
658
-            ),
659
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
660
-                null,
661
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
662
-                'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
663
-            ),
664
-            'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
665
-                'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
666
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
667
-            ),
668
-            'EE_Admin_Transactions_List_Table'                                                                            => array(
669
-                null,
670
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
671
-            ),
672
-            'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
673
-                'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
674
-                'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
675
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
676
-            ),
677
-            'EventEspresso\core\domain\services\pue\Config'                                                               => array(
678
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
679
-                'EE_Config'         => EE_Dependency_Map::load_from_cache,
680
-            ),
681
-            'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
682
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
683
-                'EEM_Event'          => EE_Dependency_Map::load_from_cache,
684
-                'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
685
-                'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
686
-                'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
687
-                'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
688
-                'EE_Config'          => EE_Dependency_Map::load_from_cache,
689
-            ),
690
-            'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
691
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
692
-            ),
693
-            'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
694
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
695
-            ),
696
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
697
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
698
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
699
-            ),
700
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
701
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
702
-            ),
703
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
704
-                'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
705
-                'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
706
-                'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
707
-                'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
708
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
709
-            ),
710
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
711
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
712
-            ),
713
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
714
-                'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
715
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
716
-            ),
717
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
718
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
719
-            ),
720
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
721
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
722
-            ),
723
-            'EE_CPT_Strategy'                                                                                             => array(
724
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
725
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
726
-            ),
727
-            'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
728
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
729
-            ),
730
-            'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
731
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
732
-                'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
733
-                'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
734
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
735
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
736
-            ),
737
-            'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
738
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
739
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
740
-            ),
741
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
742
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
743
-            ),
744
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
745
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
746
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
747
-            ),
748
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
749
-                'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
750
-            ),
751
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
752
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
753
-            ),
754
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
755
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
756
-            ),
757
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
758
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
759
-            ),
760
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
761
-                'EEM_Answer' => EE_Dependency_Map::load_from_cache,
762
-                'EEM_Question' => EE_Dependency_Map::load_from_cache,
763
-            ),
764
-            'EventEspresso\core\CPTs\CptQueryModifier' => array(
765
-                null,
766
-                null,
767
-                null,
768
-                'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
769
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
770
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
771
-            ),
772
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
773
-                'EE_Registry' => EE_Dependency_Map::load_from_cache,
774
-                'EE_Config' => EE_Dependency_Map::load_from_cache
775
-            ),
776
-            'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
777
-                'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
778
-                'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
779
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
780
-                'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
781
-            ),
782
-            'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array(
783
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
784
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
785
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
786
-            ),
787
-            'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array(
788
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
789
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
790
-            ),
791
-            'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array(
792
-                'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache,
793
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
794
-                'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
795
-            ),
796
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array(
797
-                'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache,
798
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
799
-                'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
800
-            ),
801
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array(
802
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
803
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
804
-            ),
805
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array(
806
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
807
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache,
808
-            ),
809
-            'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array(
810
-                'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache
811
-            ),
812
-            'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array(
813
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
814
-            ),
815
-            'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array(
816
-                'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache
817
-            ),
818
-            'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array(
819
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
820
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
821
-            ),
822
-            'EventEspresso\core\libraries\rest_api\calculations\Event' => array(
823
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
824
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
825
-            ),
826
-            'EventEspresso\core\libraries\rest_api\calculations\Registration' => array(
827
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache
828
-            ),
829
-            'EventEspresso\core\services\session\SessionStartHandler' => array(
830
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
831
-            ),
832
-            'EE_URL_Validation_Strategy' => array(
833
-                null,
834
-                null,
835
-                'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
836
-            ),
837
-            'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array(
838
-                'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
839
-                'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
840
-                'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
841
-                'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
842
-                'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
843
-            ),
844
-            'EventEspresso\core\services\address\CountrySubRegionDao' => array(
845
-                'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
846
-                'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
847
-            ),
848
-        );
849
-    }
850
-
851
-
852
-    /**
853
-     * Registers how core classes are loaded.
854
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
855
-     *        'EE_Request_Handler' => 'load_core'
856
-     *        'EE_Messages_Queue'  => 'load_lib'
857
-     *        'EEH_Debug_Tools'    => 'load_helper'
858
-     * or, if greater control is required, by providing a custom closure. For example:
859
-     *        'Some_Class' => function () {
860
-     *            return new Some_Class();
861
-     *        },
862
-     * This is required for instantiating dependencies
863
-     * where an interface has been type hinted in a class constructor. For example:
864
-     *        'Required_Interface' => function () {
865
-     *            return new A_Class_That_Implements_Required_Interface();
866
-     *        },
867
-     */
868
-    protected function _register_core_class_loaders()
869
-    {
870
-        $this->_class_loaders = array(
871
-            // load_core
872
-            'EE_Dependency_Map'                            => function () {
873
-                return $this;
874
-            },
875
-            'EE_Capabilities'                              => 'load_core',
876
-            'EE_Encryption'                                => 'load_core',
877
-            'EE_Front_Controller'                          => 'load_core',
878
-            'EE_Module_Request_Router'                     => 'load_core',
879
-            'EE_Registry'                                  => 'load_core',
880
-            'EE_Request'                                   => function () {
881
-                return $this->legacy_request;
882
-            },
883
-            'EventEspresso\core\services\request\Request'  => function () {
884
-                return $this->request;
885
-            },
886
-            'EventEspresso\core\services\request\Response' => function () {
887
-                return $this->response;
888
-            },
889
-            'EE_Base'                                      => 'load_core',
890
-            'EE_Request_Handler'                           => 'load_core',
891
-            'EE_Session'                                   => 'load_core',
892
-            'EE_Cron_Tasks'                                => 'load_core',
893
-            'EE_System'                                    => 'load_core',
894
-            'EE_Maintenance_Mode'                          => 'load_core',
895
-            'EE_Register_CPTs'                             => 'load_core',
896
-            'EE_Admin'                                     => 'load_core',
897
-            'EE_CPT_Strategy'                              => 'load_core',
898
-            // load_lib
899
-            'EE_Message_Resource_Manager'                  => 'load_lib',
900
-            'EE_Message_Type_Collection'                   => 'load_lib',
901
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
902
-            'EE_Messenger_Collection'                      => 'load_lib',
903
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
904
-            'EE_Messages_Processor'                        => 'load_lib',
905
-            'EE_Message_Repository'                        => 'load_lib',
906
-            'EE_Messages_Queue'                            => 'load_lib',
907
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
908
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
909
-            'EE_Payment_Method_Manager'                    => 'load_lib',
910
-            'EE_Messages_Generator'                        => function () {
911
-                return EE_Registry::instance()->load_lib(
912
-                    'Messages_Generator',
913
-                    array(),
914
-                    false,
915
-                    false
916
-                );
917
-            },
918
-            'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
919
-                return EE_Registry::instance()->load_lib(
920
-                    'Messages_Template_Defaults',
921
-                    $arguments,
922
-                    false,
923
-                    false
924
-                );
925
-            },
926
-            // load_helper
927
-            'EEH_Parse_Shortcodes'                         => function () {
928
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
929
-                    return new EEH_Parse_Shortcodes();
930
-                }
931
-                return null;
932
-            },
933
-            'EE_Template_Config'                           => function () {
934
-                return EE_Config::instance()->template_settings;
935
-            },
936
-            'EE_Currency_Config'                           => function () {
937
-                return EE_Config::instance()->currency;
938
-            },
939
-            'EE_Registration_Config'                       => function () {
940
-                return EE_Config::instance()->registration;
941
-            },
942
-            'EE_Core_Config'                               => function () {
943
-                return EE_Config::instance()->core;
944
-            },
945
-            'EventEspresso\core\services\loaders\Loader'   => function () {
946
-                return LoaderFactory::getLoader();
947
-            },
948
-            'EE_Network_Config'                            => function () {
949
-                return EE_Network_Config::instance();
950
-            },
951
-            'EE_Config'                                    => function () {
952
-                return EE_Config::instance();
953
-            },
954
-            'EventEspresso\core\domain\Domain'             => function () {
955
-                return DomainFactory::getEventEspressoCoreDomain();
956
-            },
957
-            'EE_Admin_Config'                              => function () {
958
-                return EE_Config::instance()->admin;
959
-            },
960
-            'EE_Organization_Config'                       => function () {
961
-                return EE_Config::instance()->organization;
962
-            },
963
-            'EE_Network_Core_Config'                            => function () {
964
-                return EE_Network_Config::instance()->core;
965
-            },
966
-        );
967
-    }
968
-
969
-
970
-    /**
971
-     * can be used for supplying alternate names for classes,
972
-     * or for connecting interface names to instantiable classes
973
-     */
974
-    protected function _register_core_aliases()
975
-    {
976
-        $aliases = array(
977
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
978
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
979
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
980
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
981
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
982
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
983
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
984
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
985
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
986
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
987
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
988
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
989
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
990
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
991
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
992
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
993
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
994
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
995
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
996
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
997
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
998
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
999
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1000
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1001
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1002
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1003
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1004
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1005
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1006
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1007
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1008
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1009
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1010
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1011
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1012
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1013
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1014
-        );
1015
-        foreach ($aliases as $alias => $fqn) {
1016
-            if (is_array($fqn)) {
1017
-                foreach ($fqn as $class => $for_class) {
1018
-                    $this->class_cache->addAlias($class, $alias, $for_class);
1019
-                }
1020
-                continue;
1021
-            }
1022
-            $this->class_cache->addAlias($fqn, $alias);
1023
-        }
1024
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1025
-            $this->class_cache->addAlias(
1026
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1027
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
1028
-            );
1029
-        }
1030
-    }
1031
-
1032
-
1033
-    /**
1034
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1035
-     * request Primarily used by unit tests.
1036
-     */
1037
-    public function reset()
1038
-    {
1039
-        $this->_register_core_class_loaders();
1040
-        $this->_register_core_dependencies();
1041
-    }
1042
-
1043
-
1044
-    /**
1045
-     * PLZ NOTE: a better name for this method would be is_alias()
1046
-     * because it returns TRUE if the provided fully qualified name IS an alias
1047
-     * WHY?
1048
-     * Because if a class is type hinting for a concretion,
1049
-     * then why would we need to find another class to supply it?
1050
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1051
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1052
-     * Don't go looking for some substitute.
1053
-     * Whereas if a class is type hinting for an interface...
1054
-     * then we need to find an actual class to use.
1055
-     * So the interface IS the alias for some other FQN,
1056
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1057
-     * represents some other class.
1058
-     *
1059
-     * @deprecated 4.9.62.p
1060
-     * @param string $fqn
1061
-     * @param string $for_class
1062
-     * @return bool
1063
-     */
1064
-    public function has_alias($fqn = '', $for_class = '')
1065
-    {
1066
-        return $this->isAlias($fqn, $for_class);
1067
-    }
1068
-
1069
-
1070
-    /**
1071
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1072
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1073
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
1074
-     *  for example:
1075
-     *      if the following two entries were added to the _aliases array:
1076
-     *          array(
1077
-     *              'interface_alias'           => 'some\namespace\interface'
1078
-     *              'some\namespace\interface'  => 'some\namespace\classname'
1079
-     *          )
1080
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1081
-     *      to load an instance of 'some\namespace\classname'
1082
-     *
1083
-     * @deprecated 4.9.62.p
1084
-     * @param string $alias
1085
-     * @param string $for_class
1086
-     * @return string
1087
-     */
1088
-    public function get_alias($alias = '', $for_class = '')
1089
-    {
1090
-        return $this->getFqnForAlias($alias, $for_class);
1091
-    }
23
+	/**
24
+	 * This means that the requested class dependency is not present in the dependency map
25
+	 */
26
+	const not_registered = 0;
27
+
28
+	/**
29
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
+	 */
31
+	const load_new_object = 1;
32
+
33
+	/**
34
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
+	 */
37
+	const load_from_cache = 2;
38
+
39
+	/**
40
+	 * When registering a dependency,
41
+	 * this indicates to keep any existing dependencies that already exist,
42
+	 * and simply discard any new dependencies declared in the incoming data
43
+	 */
44
+	const KEEP_EXISTING_DEPENDENCIES = 0;
45
+
46
+	/**
47
+	 * When registering a dependency,
48
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
+	 */
50
+	const OVERWRITE_DEPENDENCIES = 1;
51
+
52
+
53
+	/**
54
+	 * @type EE_Dependency_Map $_instance
55
+	 */
56
+	protected static $_instance;
57
+
58
+	/**
59
+	 * @var ClassInterfaceCache $class_cache
60
+	 */
61
+	private $class_cache;
62
+
63
+	/**
64
+	 * @type RequestInterface $request
65
+	 */
66
+	protected $request;
67
+
68
+	/**
69
+	 * @type LegacyRequestInterface $legacy_request
70
+	 */
71
+	protected $legacy_request;
72
+
73
+	/**
74
+	 * @type ResponseInterface $response
75
+	 */
76
+	protected $response;
77
+
78
+	/**
79
+	 * @type LoaderInterface $loader
80
+	 */
81
+	protected $loader;
82
+
83
+	/**
84
+	 * @type array $_dependency_map
85
+	 */
86
+	protected $_dependency_map = array();
87
+
88
+	/**
89
+	 * @type array $_class_loaders
90
+	 */
91
+	protected $_class_loaders = array();
92
+
93
+
94
+	/**
95
+	 * EE_Dependency_Map constructor.
96
+	 *
97
+	 * @param ClassInterfaceCache $class_cache
98
+	 */
99
+	protected function __construct(ClassInterfaceCache $class_cache)
100
+	{
101
+		$this->class_cache = $class_cache;
102
+		do_action('EE_Dependency_Map____construct', $this);
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return void
108
+	 */
109
+	public function initialize()
110
+	{
111
+		$this->_register_core_dependencies();
112
+		$this->_register_core_class_loaders();
113
+		$this->_register_core_aliases();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @singleton method used to instantiate class object
119
+	 * @param ClassInterfaceCache|null $class_cache
120
+	 * @return EE_Dependency_Map
121
+	 */
122
+	public static function instance(ClassInterfaceCache $class_cache = null)
123
+	{
124
+		// check if class object is instantiated, and instantiated properly
125
+		if (! self::$_instance instanceof EE_Dependency_Map
126
+			&& $class_cache instanceof ClassInterfaceCache
127
+		) {
128
+			self::$_instance = new EE_Dependency_Map($class_cache);
129
+		}
130
+		return self::$_instance;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @param RequestInterface $request
136
+	 */
137
+	public function setRequest(RequestInterface $request)
138
+	{
139
+		$this->request = $request;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param LegacyRequestInterface $legacy_request
145
+	 */
146
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
+	{
148
+		$this->legacy_request = $legacy_request;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @param ResponseInterface $response
154
+	 */
155
+	public function setResponse(ResponseInterface $response)
156
+	{
157
+		$this->response = $response;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param LoaderInterface $loader
163
+	 */
164
+	public function setLoader(LoaderInterface $loader)
165
+	{
166
+		$this->loader = $loader;
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param string $class
172
+	 * @param array  $dependencies
173
+	 * @param int    $overwrite
174
+	 * @return bool
175
+	 */
176
+	public static function register_dependencies(
177
+		$class,
178
+		array $dependencies,
179
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
+	) {
181
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
+	}
183
+
184
+
185
+	/**
186
+	 * Assigns an array of class names and corresponding load sources (new or cached)
187
+	 * to the class specified by the first parameter.
188
+	 * IMPORTANT !!!
189
+	 * The order of elements in the incoming $dependencies array MUST match
190
+	 * the order of the constructor parameters for the class in question.
191
+	 * This is especially important when overriding any existing dependencies that are registered.
192
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
+	 *
194
+	 * @param string $class
195
+	 * @param array  $dependencies
196
+	 * @param int    $overwrite
197
+	 * @return bool
198
+	 */
199
+	public function registerDependencies(
200
+		$class,
201
+		array $dependencies,
202
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
+	) {
204
+		$class = trim($class, '\\');
205
+		$registered = false;
206
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
207
+			self::$_instance->_dependency_map[ $class ] = array();
208
+		}
209
+		// we need to make sure that any aliases used when registering a dependency
210
+		// get resolved to the correct class name
211
+		foreach ($dependencies as $dependency => $load_source) {
212
+			$alias = self::$_instance->getFqnForAlias($dependency);
213
+			if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
+			) {
216
+				unset($dependencies[ $dependency ]);
217
+				$dependencies[ $alias ] = $load_source;
218
+				$registered = true;
219
+			}
220
+		}
221
+		// now add our two lists of dependencies together.
222
+		// using Union (+=) favours the arrays in precedence from left to right,
223
+		// so $dependencies is NOT overwritten because it is listed first
224
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
+		// Union is way faster than array_merge() but should be used with caution...
226
+		// especially with numerically indexed arrays
227
+		$dependencies += self::$_instance->_dependency_map[ $class ];
228
+		// now we need to ensure that the resulting dependencies
229
+		// array only has the entries that are required for the class
230
+		// so first count how many dependencies were originally registered for the class
231
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
+		// if that count is non-zero (meaning dependencies were already registered)
233
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
234
+			// then truncate the  final array to match that count
235
+			? array_slice($dependencies, 0, $dependency_count)
236
+			// otherwise just take the incoming array because nothing previously existed
237
+			: $dependencies;
238
+		return $registered;
239
+	}
240
+
241
+
242
+	/**
243
+	 * @param string $class_name
244
+	 * @param string $loader
245
+	 * @return bool
246
+	 * @throws DomainException
247
+	 */
248
+	public static function register_class_loader($class_name, $loader = 'load_core')
249
+	{
250
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
+			throw new DomainException(
252
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
253
+			);
254
+		}
255
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
256
+		if (! is_callable($loader)
257
+			&& (
258
+				strpos($loader, 'load_') !== 0
259
+				|| ! method_exists('EE_Registry', $loader)
260
+			)
261
+		) {
262
+			throw new DomainException(
263
+				sprintf(
264
+					esc_html__(
265
+						'"%1$s" is not a valid loader method on EE_Registry.',
266
+						'event_espresso'
267
+					),
268
+					$loader
269
+				)
270
+			);
271
+		}
272
+		$class_name = self::$_instance->getFqnForAlias($class_name);
273
+		if (! isset(self::$_instance->_class_loaders[ $class_name ])) {
274
+			self::$_instance->_class_loaders[ $class_name ] = $loader;
275
+			return true;
276
+		}
277
+		return false;
278
+	}
279
+
280
+
281
+	/**
282
+	 * @return array
283
+	 */
284
+	public function dependency_map()
285
+	{
286
+		return $this->_dependency_map;
287
+	}
288
+
289
+
290
+	/**
291
+	 * returns TRUE if dependency map contains a listing for the provided class name
292
+	 *
293
+	 * @param string $class_name
294
+	 * @return boolean
295
+	 */
296
+	public function has($class_name = '')
297
+	{
298
+		// all legacy models have the same dependencies
299
+		if (strpos($class_name, 'EEM_') === 0) {
300
+			$class_name = 'LEGACY_MODELS';
301
+		}
302
+		return isset($this->_dependency_map[ $class_name ]) ? true : false;
303
+	}
304
+
305
+
306
+	/**
307
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
308
+	 *
309
+	 * @param string $class_name
310
+	 * @param string $dependency
311
+	 * @return bool
312
+	 */
313
+	public function has_dependency_for_class($class_name = '', $dependency = '')
314
+	{
315
+		// all legacy models have the same dependencies
316
+		if (strpos($class_name, 'EEM_') === 0) {
317
+			$class_name = 'LEGACY_MODELS';
318
+		}
319
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
320
+		return isset($this->_dependency_map[ $class_name ][ $dependency ])
321
+			? true
322
+			: false;
323
+	}
324
+
325
+
326
+	/**
327
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
328
+	 *
329
+	 * @param string $class_name
330
+	 * @param string $dependency
331
+	 * @return int
332
+	 */
333
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
334
+	{
335
+		// all legacy models have the same dependencies
336
+		if (strpos($class_name, 'EEM_') === 0) {
337
+			$class_name = 'LEGACY_MODELS';
338
+		}
339
+		$dependency = $this->getFqnForAlias($dependency);
340
+		return $this->has_dependency_for_class($class_name, $dependency)
341
+			? $this->_dependency_map[ $class_name ][ $dependency ]
342
+			: EE_Dependency_Map::not_registered;
343
+	}
344
+
345
+
346
+	/**
347
+	 * @param string $class_name
348
+	 * @return string | Closure
349
+	 */
350
+	public function class_loader($class_name)
351
+	{
352
+		// all legacy models use load_model()
353
+		if (strpos($class_name, 'EEM_') === 0) {
354
+			return 'load_model';
355
+		}
356
+		// EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
357
+		// perform strpos() first to avoid loading regex every time we load a class
358
+		if (strpos($class_name, 'EE_CPT_') === 0
359
+			&& preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
360
+		) {
361
+			return 'load_core';
362
+		}
363
+		$class_name = $this->getFqnForAlias($class_name);
364
+		return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
365
+	}
366
+
367
+
368
+	/**
369
+	 * @return array
370
+	 */
371
+	public function class_loaders()
372
+	{
373
+		return $this->_class_loaders;
374
+	}
375
+
376
+
377
+	/**
378
+	 * adds an alias for a classname
379
+	 *
380
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
381
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
382
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
383
+	 */
384
+	public function add_alias($fqcn, $alias, $for_class = '')
385
+	{
386
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
387
+	}
388
+
389
+
390
+	/**
391
+	 * Returns TRUE if the provided fully qualified name IS an alias
392
+	 * WHY?
393
+	 * Because if a class is type hinting for a concretion,
394
+	 * then why would we need to find another class to supply it?
395
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
396
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
397
+	 * Don't go looking for some substitute.
398
+	 * Whereas if a class is type hinting for an interface...
399
+	 * then we need to find an actual class to use.
400
+	 * So the interface IS the alias for some other FQN,
401
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
402
+	 * represents some other class.
403
+	 *
404
+	 * @param string $fqn
405
+	 * @param string $for_class
406
+	 * @return bool
407
+	 */
408
+	public function isAlias($fqn = '', $for_class = '')
409
+	{
410
+		return $this->class_cache->isAlias($fqn, $for_class);
411
+	}
412
+
413
+
414
+	/**
415
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
416
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
417
+	 *  for example:
418
+	 *      if the following two entries were added to the _aliases array:
419
+	 *          array(
420
+	 *              'interface_alias'           => 'some\namespace\interface'
421
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
422
+	 *          )
423
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
424
+	 *      to load an instance of 'some\namespace\classname'
425
+	 *
426
+	 * @param string $alias
427
+	 * @param string $for_class
428
+	 * @return string
429
+	 */
430
+	public function getFqnForAlias($alias = '', $for_class = '')
431
+	{
432
+		return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
433
+	}
434
+
435
+
436
+	/**
437
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
438
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
439
+	 * This is done by using the following class constants:
440
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
441
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
442
+	 */
443
+	protected function _register_core_dependencies()
444
+	{
445
+		$this->_dependency_map = array(
446
+			'EE_Request_Handler'                                                                                          => array(
447
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
448
+			),
449
+			'EE_System'                                                                                                   => array(
450
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
451
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
452
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
453
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
454
+			),
455
+			'EE_Session'                                                                                                  => array(
456
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
457
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
458
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
459
+				'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
460
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
461
+			),
462
+			'EE_Cart'                                                                                                     => array(
463
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
464
+			),
465
+			'EE_Front_Controller'                                                                                         => array(
466
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
467
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
468
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
469
+			),
470
+			'EE_Messenger_Collection_Loader'                                                                              => array(
471
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
472
+			),
473
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
474
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
475
+			),
476
+			'EE_Message_Resource_Manager'                                                                                 => array(
477
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
478
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
479
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
480
+			),
481
+			'EE_Message_Factory'                                                                                          => array(
482
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
483
+			),
484
+			'EE_messages'                                                                                                 => array(
485
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
+			),
487
+			'EE_Messages_Generator'                                                                                       => array(
488
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
489
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
490
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
491
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
492
+			),
493
+			'EE_Messages_Processor'                                                                                       => array(
494
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
495
+			),
496
+			'EE_Messages_Queue'                                                                                           => array(
497
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
498
+			),
499
+			'EE_Messages_Template_Defaults'                                                                               => array(
500
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
501
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
502
+			),
503
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
504
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
506
+			),
507
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
508
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
509
+			),
510
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
511
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
512
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
513
+			),
514
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
515
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
516
+			),
517
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
518
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
519
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
520
+			),
521
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
522
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
523
+			),
524
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
525
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
526
+			),
527
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
528
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
529
+			),
530
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
531
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
532
+			),
533
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
534
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
535
+			),
536
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
537
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
538
+			),
539
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
540
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
541
+			),
542
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
543
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
546
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
547
+			),
548
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
549
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
550
+			),
551
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
552
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
553
+			),
554
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
555
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
556
+			),
557
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
558
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
559
+			),
560
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
561
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
562
+			),
563
+			'EE_Data_Migration_Class_Base'                                                                                => array(
564
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
+			),
567
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
568
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
+			),
571
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
572
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
+			),
575
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
576
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
+			),
579
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
580
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
+			),
583
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
584
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
+			),
587
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
588
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
+			),
591
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
592
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
+			),
595
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
596
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
597
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
598
+			),
599
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
600
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
601
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
602
+			),
603
+			'EventEspresso\core\services\assets\I18nRegistry'                                                             => array(
604
+				array(),
605
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
606
+			),
607
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
608
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
609
+				'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
610
+			),
611
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
612
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
613
+			),
614
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
615
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
616
+			),
617
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
618
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
619
+			),
620
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
621
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
622
+			),
623
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
624
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
625
+			),
626
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
627
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
628
+			),
629
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
630
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
631
+			),
632
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
633
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
634
+			),
635
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
636
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
637
+			),
638
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => array(
639
+				'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
640
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
641
+			),
642
+			'EventEspresso\core\domain\values\EmailAddress'                                                               => array(
643
+				null,
644
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
645
+			),
646
+			'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => array(
647
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
648
+			),
649
+			'LEGACY_MODELS'                                                                                               => array(
650
+				null,
651
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
652
+			),
653
+			'EE_Module_Request_Router'                                                                                    => array(
654
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
655
+			),
656
+			'EE_Registration_Processor'                                                                                   => array(
657
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
658
+			),
659
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => array(
660
+				null,
661
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
662
+				'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
663
+			),
664
+			'EventEspresso\core\services\licensing\LicenseService'                                                        => array(
665
+				'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
666
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
667
+			),
668
+			'EE_Admin_Transactions_List_Table'                                                                            => array(
669
+				null,
670
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
671
+			),
672
+			'EventEspresso\core\domain\services\pue\Stats'                                                                => array(
673
+				'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
674
+				'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
675
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
676
+			),
677
+			'EventEspresso\core\domain\services\pue\Config'                                                               => array(
678
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
679
+				'EE_Config'         => EE_Dependency_Map::load_from_cache,
680
+			),
681
+			'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => array(
682
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
683
+				'EEM_Event'          => EE_Dependency_Map::load_from_cache,
684
+				'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
685
+				'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
686
+				'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
687
+				'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
688
+				'EE_Config'          => EE_Dependency_Map::load_from_cache,
689
+			),
690
+			'EventEspresso\core\domain\services\admin\ExitModal'                                                          => array(
691
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
692
+			),
693
+			'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => array(
694
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
695
+			),
696
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => array(
697
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
698
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
699
+			),
700
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => array(
701
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
702
+			),
703
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => array(
704
+				'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
705
+				'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
706
+				'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
707
+				'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
708
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
709
+			),
710
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => array(
711
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
712
+			),
713
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => array(
714
+				'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
715
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
716
+			),
717
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => array(
718
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
719
+			),
720
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => array(
721
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
722
+			),
723
+			'EE_CPT_Strategy'                                                                                             => array(
724
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
725
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
726
+			),
727
+			'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => array(
728
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
729
+			),
730
+			'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => array(
731
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
732
+				'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
733
+				'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
734
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
735
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
736
+			),
737
+			'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array(
738
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
739
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache
740
+			),
741
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array(
742
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
743
+			),
744
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array(
745
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
746
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache
747
+			),
748
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array(
749
+				'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
750
+			),
751
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array(
752
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
753
+			),
754
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array(
755
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
756
+			),
757
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array(
758
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
759
+			),
760
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array(
761
+				'EEM_Answer' => EE_Dependency_Map::load_from_cache,
762
+				'EEM_Question' => EE_Dependency_Map::load_from_cache,
763
+			),
764
+			'EventEspresso\core\CPTs\CptQueryModifier' => array(
765
+				null,
766
+				null,
767
+				null,
768
+				'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
769
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
770
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
771
+			),
772
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array(
773
+				'EE_Registry' => EE_Dependency_Map::load_from_cache,
774
+				'EE_Config' => EE_Dependency_Map::load_from_cache
775
+			),
776
+			'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => array(
777
+				'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache,
778
+				'EventEspresso\core\domain\entities\editor\BlockCollection'      => EE_Dependency_Map::load_from_cache,
779
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
780
+				'EventEspresso\core\services\request\Request'                    => EE_Dependency_Map::load_from_cache,
781
+			),
782
+			'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array(
783
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
784
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
785
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
786
+			),
787
+			'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array(
788
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
789
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
790
+			),
791
+			'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array(
792
+				'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache,
793
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
794
+				'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
795
+			),
796
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array(
797
+				'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache,
798
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
799
+				'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache,
800
+			),
801
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array(
802
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
803
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
804
+			),
805
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array(
806
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
807
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache,
808
+			),
809
+			'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array(
810
+				'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache
811
+			),
812
+			'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array(
813
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
814
+			),
815
+			'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array(
816
+				'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache
817
+			),
818
+			'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array(
819
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
820
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
821
+			),
822
+			'EventEspresso\core\libraries\rest_api\calculations\Event' => array(
823
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
824
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
825
+			),
826
+			'EventEspresso\core\libraries\rest_api\calculations\Registration' => array(
827
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache
828
+			),
829
+			'EventEspresso\core\services\session\SessionStartHandler' => array(
830
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
831
+			),
832
+			'EE_URL_Validation_Strategy' => array(
833
+				null,
834
+				null,
835
+				'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
836
+			),
837
+			'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array(
838
+				'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
839
+				'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
840
+				'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
841
+				'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
842
+				'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
843
+			),
844
+			'EventEspresso\core\services\address\CountrySubRegionDao' => array(
845
+				'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
846
+				'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache
847
+			),
848
+		);
849
+	}
850
+
851
+
852
+	/**
853
+	 * Registers how core classes are loaded.
854
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
855
+	 *        'EE_Request_Handler' => 'load_core'
856
+	 *        'EE_Messages_Queue'  => 'load_lib'
857
+	 *        'EEH_Debug_Tools'    => 'load_helper'
858
+	 * or, if greater control is required, by providing a custom closure. For example:
859
+	 *        'Some_Class' => function () {
860
+	 *            return new Some_Class();
861
+	 *        },
862
+	 * This is required for instantiating dependencies
863
+	 * where an interface has been type hinted in a class constructor. For example:
864
+	 *        'Required_Interface' => function () {
865
+	 *            return new A_Class_That_Implements_Required_Interface();
866
+	 *        },
867
+	 */
868
+	protected function _register_core_class_loaders()
869
+	{
870
+		$this->_class_loaders = array(
871
+			// load_core
872
+			'EE_Dependency_Map'                            => function () {
873
+				return $this;
874
+			},
875
+			'EE_Capabilities'                              => 'load_core',
876
+			'EE_Encryption'                                => 'load_core',
877
+			'EE_Front_Controller'                          => 'load_core',
878
+			'EE_Module_Request_Router'                     => 'load_core',
879
+			'EE_Registry'                                  => 'load_core',
880
+			'EE_Request'                                   => function () {
881
+				return $this->legacy_request;
882
+			},
883
+			'EventEspresso\core\services\request\Request'  => function () {
884
+				return $this->request;
885
+			},
886
+			'EventEspresso\core\services\request\Response' => function () {
887
+				return $this->response;
888
+			},
889
+			'EE_Base'                                      => 'load_core',
890
+			'EE_Request_Handler'                           => 'load_core',
891
+			'EE_Session'                                   => 'load_core',
892
+			'EE_Cron_Tasks'                                => 'load_core',
893
+			'EE_System'                                    => 'load_core',
894
+			'EE_Maintenance_Mode'                          => 'load_core',
895
+			'EE_Register_CPTs'                             => 'load_core',
896
+			'EE_Admin'                                     => 'load_core',
897
+			'EE_CPT_Strategy'                              => 'load_core',
898
+			// load_lib
899
+			'EE_Message_Resource_Manager'                  => 'load_lib',
900
+			'EE_Message_Type_Collection'                   => 'load_lib',
901
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
902
+			'EE_Messenger_Collection'                      => 'load_lib',
903
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
904
+			'EE_Messages_Processor'                        => 'load_lib',
905
+			'EE_Message_Repository'                        => 'load_lib',
906
+			'EE_Messages_Queue'                            => 'load_lib',
907
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
908
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
909
+			'EE_Payment_Method_Manager'                    => 'load_lib',
910
+			'EE_Messages_Generator'                        => function () {
911
+				return EE_Registry::instance()->load_lib(
912
+					'Messages_Generator',
913
+					array(),
914
+					false,
915
+					false
916
+				);
917
+			},
918
+			'EE_Messages_Template_Defaults'                => function ($arguments = array()) {
919
+				return EE_Registry::instance()->load_lib(
920
+					'Messages_Template_Defaults',
921
+					$arguments,
922
+					false,
923
+					false
924
+				);
925
+			},
926
+			// load_helper
927
+			'EEH_Parse_Shortcodes'                         => function () {
928
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
929
+					return new EEH_Parse_Shortcodes();
930
+				}
931
+				return null;
932
+			},
933
+			'EE_Template_Config'                           => function () {
934
+				return EE_Config::instance()->template_settings;
935
+			},
936
+			'EE_Currency_Config'                           => function () {
937
+				return EE_Config::instance()->currency;
938
+			},
939
+			'EE_Registration_Config'                       => function () {
940
+				return EE_Config::instance()->registration;
941
+			},
942
+			'EE_Core_Config'                               => function () {
943
+				return EE_Config::instance()->core;
944
+			},
945
+			'EventEspresso\core\services\loaders\Loader'   => function () {
946
+				return LoaderFactory::getLoader();
947
+			},
948
+			'EE_Network_Config'                            => function () {
949
+				return EE_Network_Config::instance();
950
+			},
951
+			'EE_Config'                                    => function () {
952
+				return EE_Config::instance();
953
+			},
954
+			'EventEspresso\core\domain\Domain'             => function () {
955
+				return DomainFactory::getEventEspressoCoreDomain();
956
+			},
957
+			'EE_Admin_Config'                              => function () {
958
+				return EE_Config::instance()->admin;
959
+			},
960
+			'EE_Organization_Config'                       => function () {
961
+				return EE_Config::instance()->organization;
962
+			},
963
+			'EE_Network_Core_Config'                            => function () {
964
+				return EE_Network_Config::instance()->core;
965
+			},
966
+		);
967
+	}
968
+
969
+
970
+	/**
971
+	 * can be used for supplying alternate names for classes,
972
+	 * or for connecting interface names to instantiable classes
973
+	 */
974
+	protected function _register_core_aliases()
975
+	{
976
+		$aliases = array(
977
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
978
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
979
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
980
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
981
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
982
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
983
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
984
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
985
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
986
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
987
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
988
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
989
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
990
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
991
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
992
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
993
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
994
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
995
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
996
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
997
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
998
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
999
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1000
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1001
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1002
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1003
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1004
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1005
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1006
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1007
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1008
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1009
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1010
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1011
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1012
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1013
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1014
+		);
1015
+		foreach ($aliases as $alias => $fqn) {
1016
+			if (is_array($fqn)) {
1017
+				foreach ($fqn as $class => $for_class) {
1018
+					$this->class_cache->addAlias($class, $alias, $for_class);
1019
+				}
1020
+				continue;
1021
+			}
1022
+			$this->class_cache->addAlias($fqn, $alias);
1023
+		}
1024
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1025
+			$this->class_cache->addAlias(
1026
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1027
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
1028
+			);
1029
+		}
1030
+	}
1031
+
1032
+
1033
+	/**
1034
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1035
+	 * request Primarily used by unit tests.
1036
+	 */
1037
+	public function reset()
1038
+	{
1039
+		$this->_register_core_class_loaders();
1040
+		$this->_register_core_dependencies();
1041
+	}
1042
+
1043
+
1044
+	/**
1045
+	 * PLZ NOTE: a better name for this method would be is_alias()
1046
+	 * because it returns TRUE if the provided fully qualified name IS an alias
1047
+	 * WHY?
1048
+	 * Because if a class is type hinting for a concretion,
1049
+	 * then why would we need to find another class to supply it?
1050
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1051
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1052
+	 * Don't go looking for some substitute.
1053
+	 * Whereas if a class is type hinting for an interface...
1054
+	 * then we need to find an actual class to use.
1055
+	 * So the interface IS the alias for some other FQN,
1056
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1057
+	 * represents some other class.
1058
+	 *
1059
+	 * @deprecated 4.9.62.p
1060
+	 * @param string $fqn
1061
+	 * @param string $for_class
1062
+	 * @return bool
1063
+	 */
1064
+	public function has_alias($fqn = '', $for_class = '')
1065
+	{
1066
+		return $this->isAlias($fqn, $for_class);
1067
+	}
1068
+
1069
+
1070
+	/**
1071
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1072
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1073
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
1074
+	 *  for example:
1075
+	 *      if the following two entries were added to the _aliases array:
1076
+	 *          array(
1077
+	 *              'interface_alias'           => 'some\namespace\interface'
1078
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
1079
+	 *          )
1080
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1081
+	 *      to load an instance of 'some\namespace\classname'
1082
+	 *
1083
+	 * @deprecated 4.9.62.p
1084
+	 * @param string $alias
1085
+	 * @param string $for_class
1086
+	 * @return string
1087
+	 */
1088
+	public function get_alias($alias = '', $for_class = '')
1089
+	{
1090
+		return $this->getFqnForAlias($alias, $for_class);
1091
+	}
1092 1092
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/calculations/Attendee.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -17,43 +17,43 @@
 block discarded – undo
17 17
 class Attendee extends AttendeeCalculationsBase
18 18
 {
19 19
 
20
-    /**
21
-     * @param array                  $wpdb_row
22
-     * @param WP_REST_Request        $request
23
-     * @param AttendeeControllerBase $controller
24
-     * @since 4.9.66.p
25
-     * @return string
26
-     */
27
-    public function userAvatar(array $wpdb_row, WP_REST_Request $request, AttendeeControllerBase $controller)
28
-    {
29
-        if (is_array($wpdb_row) && isset($wpdb_row['Attendee_Meta.ATT_email'])) {
30
-            $email_address = $wpdb_row['Attendee_Meta.ATT_email'];
31
-        }
32
-        if (empty($email_address)) {
33
-            return get_avatar_url('', array('default' => 'mm', 'force_default' => true));
34
-        }
35
-        $avatar = get_avatar_url($email_address);
36
-        return $avatar ? $avatar : '';
37
-    }
20
+	/**
21
+	 * @param array                  $wpdb_row
22
+	 * @param WP_REST_Request        $request
23
+	 * @param AttendeeControllerBase $controller
24
+	 * @since 4.9.66.p
25
+	 * @return string
26
+	 */
27
+	public function userAvatar(array $wpdb_row, WP_REST_Request $request, AttendeeControllerBase $controller)
28
+	{
29
+		if (is_array($wpdb_row) && isset($wpdb_row['Attendee_Meta.ATT_email'])) {
30
+			$email_address = $wpdb_row['Attendee_Meta.ATT_email'];
31
+		}
32
+		if (empty($email_address)) {
33
+			return get_avatar_url('', array('default' => 'mm', 'force_default' => true));
34
+		}
35
+		$avatar = get_avatar_url($email_address);
36
+		return $avatar ? $avatar : '';
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * Provides an array for all the calculations possible that outlines a json schema for those calculations.
42
-     * Array is indexed by calculation (snake case) and value is the schema for that calculation.
43
-     *
44
-     * @since 4.9.68.p
45
-     * @return array
46
-     */
47
-    public function schemaForCalculations()
48
-    {
49
-        return array(
50
-            'user_avatar' => array(
51
-                'description' => esc_html__(
52
-                    'The avatar url for the attendee (if available).',
53
-                    'event_espresso'
54
-                ),
55
-                'type'        => 'string',
56
-            ),
57
-        );
58
-    }
40
+	/**
41
+	 * Provides an array for all the calculations possible that outlines a json schema for those calculations.
42
+	 * Array is indexed by calculation (snake case) and value is the schema for that calculation.
43
+	 *
44
+	 * @since 4.9.68.p
45
+	 * @return array
46
+	 */
47
+	public function schemaForCalculations()
48
+	{
49
+		return array(
50
+			'user_avatar' => array(
51
+				'description' => esc_html__(
52
+					'The avatar url for the attendee (if available).',
53
+					'event_espresso'
54
+				),
55
+				'type'        => 'string',
56
+			),
57
+		);
58
+	}
59 59
 }
Please login to merge, or discard this patch.
core/EE_Session.core.php 2 patches
Indentation   +1328 added lines, -1328 removed lines patch added patch discarded remove patch
@@ -24,1326 +24,1326 @@  discard block
 block discarded – undo
24 24
 class EE_Session implements SessionIdentifierInterface
25 25
 {
26 26
 
27
-    const session_id_prefix = 'ee_ssn_';
28
-
29
-    const hash_check_prefix = 'ee_shc_';
30
-
31
-    const OPTION_NAME_SETTINGS = 'ee_session_settings';
32
-
33
-    const STATUS_CLOSED = 0;
34
-
35
-    const STATUS_OPEN = 1;
36
-
37
-    const SAVE_STATE_CLEAN = 'clean';
38
-    const SAVE_STATE_DIRTY = 'dirty';
39
-
40
-
41
-    /**
42
-     * instance of the EE_Session object
43
-     *
44
-     * @var EE_Session
45
-     */
46
-    private static $_instance;
47
-
48
-    /**
49
-     * @var CacheStorageInterface $cache_storage
50
-     */
51
-    protected $cache_storage;
52
-
53
-    /**
54
-     * @var EE_Encryption $encryption
55
-     */
56
-    protected $encryption;
57
-
58
-    /**
59
-     * @var SessionStartHandler $session_start_handler
60
-     */
61
-    protected $session_start_handler;
62
-
63
-    /**
64
-     * the session id
65
-     *
66
-     * @var string
67
-     */
68
-    private $_sid;
69
-
70
-    /**
71
-     * session id salt
72
-     *
73
-     * @var string
74
-     */
75
-    private $_sid_salt;
76
-
77
-    /**
78
-     * session data
79
-     *
80
-     * @var array
81
-     */
82
-    private $_session_data = array();
83
-
84
-    /**
85
-     * how long an EE session lasts
86
-     * default session lifespan of 1 hour (for not so instant IPNs)
87
-     *
88
-     * @var SessionLifespan $session_lifespan
89
-     */
90
-    private $session_lifespan;
91
-
92
-    /**
93
-     * session expiration time as Unix timestamp in GMT
94
-     *
95
-     * @var int
96
-     */
97
-    private $_expiration;
98
-
99
-    /**
100
-     * whether or not session has expired at some point
101
-     *
102
-     * @var boolean
103
-     */
104
-    private $_expired = false;
105
-
106
-    /**
107
-     * current time as Unix timestamp in GMT
108
-     *
109
-     * @var int
110
-     */
111
-    private $_time;
112
-
113
-    /**
114
-     * whether to encrypt session data
115
-     *
116
-     * @var bool
117
-     */
118
-    private $_use_encryption;
119
-
120
-    /**
121
-     * well... according to the server...
122
-     *
123
-     * @var null
124
-     */
125
-    private $_user_agent;
126
-
127
-    /**
128
-     * do you really trust the server ?
129
-     *
130
-     * @var null
131
-     */
132
-    private $_ip_address;
133
-
134
-    /**
135
-     * current WP user_id
136
-     *
137
-     * @var null
138
-     */
139
-    private $_wp_user_id;
140
-
141
-    /**
142
-     * array for defining default session vars
143
-     *
144
-     * @var array
145
-     */
146
-    private $_default_session_vars = array(
147
-        'id'            => null,
148
-        'user_id'       => null,
149
-        'ip_address'    => null,
150
-        'user_agent'    => null,
151
-        'init_access'   => null,
152
-        'last_access'   => null,
153
-        'expiration'    => null,
154
-        'pages_visited' => array(),
155
-    );
156
-
157
-    /**
158
-     * timestamp for when last garbage collection cycle was performed
159
-     *
160
-     * @var int $_last_gc
161
-     */
162
-    private $_last_gc;
163
-
164
-    /**
165
-     * @var RequestInterface $request
166
-     */
167
-    protected $request;
168
-
169
-    /**
170
-     * whether session is active or not
171
-     *
172
-     * @var int $status
173
-     */
174
-    private $status = EE_Session::STATUS_CLOSED;
175
-
176
-    /**
177
-     * whether session data has changed therefore requiring a session save
178
-     *
179
-     * @var string $save_state
180
-     */
181
-    private $save_state = EE_Session::SAVE_STATE_CLEAN;
182
-
183
-
184
-    /**
185
-     * @singleton method used to instantiate class object
186
-     * @param CacheStorageInterface $cache_storage
187
-     * @param SessionLifespan|null  $lifespan
188
-     * @param RequestInterface      $request
189
-     * @param SessionStartHandler   $session_start_handler
190
-     * @param EE_Encryption         $encryption
191
-     * @return EE_Session
192
-     * @throws InvalidArgumentException
193
-     * @throws InvalidDataTypeException
194
-     * @throws InvalidInterfaceException
195
-     */
196
-    public static function instance(
197
-        CacheStorageInterface $cache_storage = null,
198
-        SessionLifespan $lifespan = null,
199
-        RequestInterface $request = null,
200
-        SessionStartHandler $session_start_handler = null,
201
-        EE_Encryption $encryption = null
202
-    ) {
203
-        // check if class object is instantiated
204
-        // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via:
205
-        // add_filter( 'FHEE_load_EE_Session', '__return_false' );
206
-        if (! self::$_instance instanceof EE_Session
207
-            && $cache_storage instanceof CacheStorageInterface
208
-            && $lifespan instanceof SessionLifespan
209
-            && $request instanceof RequestInterface
210
-            && $session_start_handler instanceof SessionStartHandler
211
-            && apply_filters('FHEE_load_EE_Session', true)
212
-        ) {
213
-            self::$_instance = new self(
214
-                $cache_storage,
215
-                $lifespan,
216
-                $request,
217
-                $session_start_handler,
218
-                $encryption
219
-            );
220
-        }
221
-        return self::$_instance;
222
-    }
223
-
224
-
225
-    /**
226
-     * protected constructor to prevent direct creation
227
-     *
228
-     * @param CacheStorageInterface $cache_storage
229
-     * @param SessionLifespan       $lifespan
230
-     * @param RequestInterface      $request
231
-     * @param SessionStartHandler   $session_start_handler
232
-     * @param EE_Encryption         $encryption
233
-     * @throws InvalidArgumentException
234
-     * @throws InvalidDataTypeException
235
-     * @throws InvalidInterfaceException
236
-     */
237
-    protected function __construct(
238
-        CacheStorageInterface $cache_storage,
239
-        SessionLifespan $lifespan,
240
-        RequestInterface $request,
241
-        SessionStartHandler $session_start_handler,
242
-        EE_Encryption $encryption = null
243
-    ) {
244
-        // session loading is turned ON by default,
245
-        // but prior to the 'AHEE__EE_System__core_loaded_and_ready' hook
246
-        // (which currently fires on the init hook at priority 9),
247
-        // can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' );
248
-        if (! apply_filters('FHEE_load_EE_Session', true)) {
249
-            return;
250
-        }
251
-        $this->session_start_handler = $session_start_handler;
252
-        $this->session_lifespan = $lifespan;
253
-        $this->request = $request;
254
-        if (! defined('ESPRESSO_SESSION')) {
255
-            define('ESPRESSO_SESSION', true);
256
-        }
257
-        // retrieve session options from db
258
-        $session_settings = (array) get_option(EE_Session::OPTION_NAME_SETTINGS, array());
259
-        if (! empty($session_settings)) {
260
-            // cycle though existing session options
261
-            foreach ($session_settings as $var_name => $session_setting) {
262
-                // set values for class properties
263
-                $var_name = '_' . $var_name;
264
-                $this->{$var_name} = $session_setting;
265
-            }
266
-        }
267
-        $this->cache_storage = $cache_storage;
268
-        // are we using encryption?
269
-        $this->_use_encryption = $encryption instanceof EE_Encryption
270
-                                 && EE_Registry::instance()->CFG->admin->encode_session_data();
271
-        // encrypt data via: $this->encryption->encrypt();
272
-        $this->encryption = $encryption;
273
-        // filter hook allows outside functions/classes/plugins to change default empty cart
274
-        $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array());
275
-        array_merge($this->_default_session_vars, $extra_default_session_vars);
276
-        // apply default session vars
277
-        $this->_set_defaults();
278
-        add_action('AHEE__EE_System__initialize', array($this, 'open_session'));
279
-        // check request for 'clear_session' param
280
-        add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded'));
281
-        // once everything is all said and done,
282
-        add_action('shutdown', array($this, 'update'), 100);
283
-        add_action('shutdown', array($this, 'garbageCollection'), 1000);
284
-        $this->configure_garbage_collection_filters();
285
-    }
286
-
287
-
288
-    /**
289
-     * @return bool
290
-     * @throws InvalidArgumentException
291
-     * @throws InvalidDataTypeException
292
-     * @throws InvalidInterfaceException
293
-     */
294
-    public static function isLoadedAndActive()
295
-    {
296
-        return did_action('AHEE__EE_System__core_loaded_and_ready')
297
-               && EE_Session::instance() instanceof EE_Session
298
-               && EE_Session::instance()->isActive();
299
-    }
300
-
301
-
302
-    /**
303
-     * @return bool
304
-     */
305
-    public function isActive()
306
-    {
307
-        return $this->status === EE_Session::STATUS_OPEN;
308
-    }
309
-
310
-
311
-    /**
312
-     * @return void
313
-     * @throws EE_Error
314
-     * @throws InvalidArgumentException
315
-     * @throws InvalidDataTypeException
316
-     * @throws InvalidInterfaceException
317
-     * @throws InvalidSessionDataException
318
-     * @throws RuntimeException
319
-     * @throws ReflectionException
320
-     */
321
-    public function open_session()
322
-    {
323
-        // check for existing session and retrieve it from db
324
-        if (! $this->_espresso_session()) {
325
-            // or just start a new one
326
-            $this->_create_espresso_session();
327
-        }
328
-    }
329
-
330
-
331
-    /**
332
-     * @return bool
333
-     */
334
-    public function expired()
335
-    {
336
-        return $this->_expired;
337
-    }
338
-
339
-
340
-    /**
341
-     * @return void
342
-     */
343
-    public function reset_expired()
344
-    {
345
-        $this->_expired = false;
346
-    }
347
-
348
-
349
-    /**
350
-     * @return int
351
-     */
352
-    public function expiration()
353
-    {
354
-        return $this->_expiration;
355
-    }
356
-
357
-
358
-    /**
359
-     * @return int
360
-     */
361
-    public function extension()
362
-    {
363
-        return apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS);
364
-    }
365
-
366
-
367
-    /**
368
-     * @param int $time number of seconds to add to session expiration
369
-     */
370
-    public function extend_expiration($time = 0)
371
-    {
372
-        $time = $time ? $time : $this->extension();
373
-        $this->_expiration += absint($time);
374
-    }
375
-
376
-
377
-    /**
378
-     * @return int
379
-     */
380
-    public function lifespan()
381
-    {
382
-        return $this->session_lifespan->inSeconds();
383
-    }
384
-
385
-
386
-    /**
387
-     * Marks whether the session data has been updated or not.
388
-     * Valid options are:
389
-     *      EE_Session::SAVE_STATE_CLEAN - session data remains unchanged and updating is not necessary
390
-     *      EE_Session::SAVE_STATE_DIRTY - session data has changed since last save and needs to be updated
391
-     * default value is EE_Session::SAVE_STATE_DIRTY
392
-     *
393
-     * @param string $save_state
394
-     */
395
-    public function setSaveState($save_state = EE_Session::SAVE_STATE_DIRTY)
396
-    {
397
-        $valid_save_states = [
398
-            EE_Session::SAVE_STATE_CLEAN,
399
-            EE_Session::SAVE_STATE_DIRTY,
400
-        ];
401
-        if (! in_array($save_state, $valid_save_states, true)) {
402
-            $save_state = EE_Session::SAVE_STATE_DIRTY;
403
-        }
404
-        $this->save_state = $save_state;
405
-    }
406
-
407
-
408
-
409
-    /**
410
-     * This just sets some defaults for the _session data property
411
-     *
412
-     * @access private
413
-     * @return void
414
-     */
415
-    private function _set_defaults()
416
-    {
417
-        // set some defaults
418
-        foreach ($this->_default_session_vars as $key => $default_var) {
419
-            if (is_array($default_var)) {
420
-                $this->_session_data[ $key ] = array();
421
-            } else {
422
-                $this->_session_data[ $key ] = '';
423
-            }
424
-        }
425
-    }
426
-
427
-
428
-    /**
429
-     * @retrieve  session data
430
-     * @access    public
431
-     * @return    string
432
-     */
433
-    public function id()
434
-    {
435
-        return $this->_sid;
436
-    }
437
-
438
-
439
-    /**
440
-     * @param \EE_Cart $cart
441
-     * @return bool
442
-     */
443
-    public function set_cart(EE_Cart $cart)
444
-    {
445
-        $this->_session_data['cart'] = $cart;
446
-        $this->setSaveState();
447
-        return true;
448
-    }
449
-
450
-
451
-    /**
452
-     * reset_cart
453
-     */
454
-    public function reset_cart()
455
-    {
456
-        do_action('AHEE__EE_Session__reset_cart__before_reset', $this);
457
-        $this->_session_data['cart'] = null;
458
-        $this->setSaveState();
459
-    }
460
-
461
-
462
-    /**
463
-     * @return \EE_Cart
464
-     */
465
-    public function cart()
466
-    {
467
-        return isset($this->_session_data['cart']) && $this->_session_data['cart'] instanceof EE_Cart
468
-            ? $this->_session_data['cart']
469
-            : null;
470
-    }
471
-
472
-
473
-    /**
474
-     * @param \EE_Checkout $checkout
475
-     * @return bool
476
-     */
477
-    public function set_checkout(EE_Checkout $checkout)
478
-    {
479
-        $this->_session_data['checkout'] = $checkout;
480
-        $this->setSaveState();
481
-        return true;
482
-    }
483
-
484
-
485
-    /**
486
-     * reset_checkout
487
-     */
488
-    public function reset_checkout()
489
-    {
490
-        do_action('AHEE__EE_Session__reset_checkout__before_reset', $this);
491
-        $this->_session_data['checkout'] = null;
492
-        $this->setSaveState();
493
-    }
494
-
495
-
496
-    /**
497
-     * @return \EE_Checkout
498
-     */
499
-    public function checkout()
500
-    {
501
-        return isset($this->_session_data['checkout']) && $this->_session_data['checkout'] instanceof EE_Checkout
502
-            ? $this->_session_data['checkout']
503
-            : null;
504
-    }
505
-
506
-
507
-    /**
508
-     * @param \EE_Transaction $transaction
509
-     * @return bool
510
-     * @throws EE_Error
511
-     */
512
-    public function set_transaction(EE_Transaction $transaction)
513
-    {
514
-        // first remove the session from the transaction before we save the transaction in the session
515
-        $transaction->set_txn_session_data(null);
516
-        $this->_session_data['transaction'] = $transaction;
517
-        $this->setSaveState();
518
-        return true;
519
-    }
520
-
521
-
522
-    /**
523
-     * reset_transaction
524
-     */
525
-    public function reset_transaction()
526
-    {
527
-        do_action('AHEE__EE_Session__reset_transaction__before_reset', $this);
528
-        $this->_session_data['transaction'] = null;
529
-        $this->setSaveState();
530
-    }
531
-
532
-
533
-    /**
534
-     * @return \EE_Transaction
535
-     */
536
-    public function transaction()
537
-    {
538
-        return isset($this->_session_data['transaction'])
539
-               && $this->_session_data['transaction'] instanceof EE_Transaction
540
-            ? $this->_session_data['transaction']
541
-            : null;
542
-    }
543
-
544
-
545
-    /**
546
-     * retrieve session data
547
-     *
548
-     * @param null $key
549
-     * @param bool $reset_cache
550
-     * @return array
551
-     */
552
-    public function get_session_data($key = null, $reset_cache = false)
553
-    {
554
-        if ($reset_cache) {
555
-            $this->reset_cart();
556
-            $this->reset_checkout();
557
-            $this->reset_transaction();
558
-        }
559
-        if (! empty($key)) {
560
-            return isset($this->_session_data[ $key ]) ? $this->_session_data[ $key ] : null;
561
-        }
562
-        return $this->_session_data;
563
-    }
564
-
565
-
566
-    /**
567
-     * Returns TRUE on success, FALSE on fail
568
-     *
569
-     * @param array $data
570
-     * @return bool
571
-     */
572
-    public function set_session_data($data)
573
-    {
574
-        // nothing ??? bad data ??? go home!
575
-        if (empty($data) || ! is_array($data)) {
576
-            EE_Error::add_error(
577
-                esc_html__(
578
-                    'No session data or invalid session data was provided.',
579
-                    'event_espresso'
580
-                ),
581
-                __FILE__,
582
-                __FUNCTION__,
583
-                __LINE__
584
-            );
585
-            return false;
586
-        }
587
-        foreach ($data as $key => $value) {
588
-            if (isset($this->_default_session_vars[ $key ])) {
589
-                EE_Error::add_error(
590
-                    sprintf(
591
-                        esc_html__(
592
-                            'Sorry! %s is a default session datum and can not be reset.',
593
-                            'event_espresso'
594
-                        ),
595
-                        $key
596
-                    ),
597
-                    __FILE__,
598
-                    __FUNCTION__,
599
-                    __LINE__
600
-                );
601
-                return false;
602
-            }
603
-            $this->_session_data[ $key ] = $value;
604
-            $this->setSaveState();
605
-        }
606
-        return true;
607
-    }
608
-
609
-
610
-    /**
611
-     * @initiate session
612
-     * @access   private
613
-     * @return TRUE on success, FALSE on fail
614
-     * @throws EE_Error
615
-     * @throws InvalidArgumentException
616
-     * @throws InvalidDataTypeException
617
-     * @throws InvalidInterfaceException
618
-     * @throws InvalidSessionDataException
619
-     * @throws RuntimeException
620
-     * @throws ReflectionException
621
-     */
622
-    private function _espresso_session()
623
-    {
624
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
625
-        $this->session_start_handler->startSession();
626
-        $this->status = EE_Session::STATUS_OPEN;
627
-        // get our modified session ID
628
-        $this->_sid = $this->_generate_session_id();
629
-        // and the visitors IP
630
-        $this->_ip_address = $this->request->ipAddress();
631
-        // set the "user agent"
632
-        $this->_user_agent = $this->request->userAgent();
633
-        // now let's retrieve what's in the db
634
-        $session_data = $this->_retrieve_session_data();
635
-        if (! empty($session_data)) {
636
-            // get the current time in UTC
637
-            $this->_time = $this->_time !== null ? $this->_time : time();
638
-            // and reset the session expiration
639
-            $this->_expiration = isset($session_data['expiration'])
640
-                ? $session_data['expiration']
641
-                : $this->_time + $this->session_lifespan->inSeconds();
642
-        } else {
643
-            // set initial site access time and the session expiration
644
-            $this->_set_init_access_and_expiration();
645
-            // set referer
646
-            $this->_session_data['pages_visited'][ $this->_session_data['init_access'] ] = isset($_SERVER['HTTP_REFERER'])
647
-                ? esc_attr($_SERVER['HTTP_REFERER'])
648
-                : '';
649
-            // no previous session = go back and create one (on top of the data above)
650
-            return false;
651
-        }
652
-        // now the user agent
653
-        if ($session_data['user_agent'] !== $this->_user_agent) {
654
-            return false;
655
-        }
656
-        // wait a minute... how old are you?
657
-        if ($this->_time > $this->_expiration) {
658
-            // yer too old fer me!
659
-            $this->_expired = true;
660
-            // wipe out everything that isn't a default session datum
661
-            $this->clear_session(__CLASS__, __FUNCTION__);
662
-        }
663
-        // make event espresso session data available to plugin
664
-        $this->_session_data = array_merge($this->_session_data, $session_data);
665
-        return true;
666
-    }
667
-
668
-
669
-    /**
670
-     * _get_session_data
671
-     * Retrieves the session data, and attempts to correct any encoding issues that can occur due to improperly setup
672
-     * databases
673
-     *
674
-     * @return array
675
-     * @throws EE_Error
676
-     * @throws InvalidArgumentException
677
-     * @throws InvalidSessionDataException
678
-     * @throws InvalidDataTypeException
679
-     * @throws InvalidInterfaceException
680
-     * @throws RuntimeException
681
-     */
682
-    protected function _retrieve_session_data()
683
-    {
684
-        $ssn_key = EE_Session::session_id_prefix . $this->_sid;
685
-        try {
686
-            // we're using WP's Transient API to store session data using the PHP session ID as the option name
687
-            $session_data = $this->cache_storage->get($ssn_key, false);
688
-            if (empty($session_data)) {
689
-                return array();
690
-            }
691
-            if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
692
-                $hash_check = $this->cache_storage->get(
693
-                    EE_Session::hash_check_prefix . $this->_sid,
694
-                    false
695
-                );
696
-                if ($hash_check && $hash_check !== md5($session_data)) {
697
-                    EE_Error::add_error(
698
-                        sprintf(
699
-                            __(
700
-                                'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.',
701
-                                'event_espresso'
702
-                            ),
703
-                            EE_Session::session_id_prefix . $this->_sid
704
-                        ),
705
-                        __FILE__,
706
-                        __FUNCTION__,
707
-                        __LINE__
708
-                    );
709
-                }
710
-            }
711
-        } catch (Exception $e) {
712
-            // let's just eat that error for now and attempt to correct any corrupted data
713
-            global $wpdb;
714
-            $row = $wpdb->get_row(
715
-                $wpdb->prepare(
716
-                    "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
717
-                    '_transient_' . $ssn_key
718
-                )
719
-            );
720
-            $session_data = is_object($row) ? $row->option_value : null;
721
-            if ($session_data) {
722
-                $session_data = preg_replace_callback(
723
-                    '!s:(d+):"(.*?)";!',
724
-                    function ($match) {
725
-                        return $match[1] === strlen($match[2])
726
-                            ? $match[0]
727
-                            : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
728
-                    },
729
-                    $session_data
730
-                );
731
-            }
732
-            $session_data = maybe_unserialize($session_data);
733
-        }
734
-        // in case the data is encoded... try to decode it
735
-        $session_data = $this->encryption instanceof EE_Encryption
736
-            ? $this->encryption->base64_string_decode($session_data)
737
-            : $session_data;
738
-        if (! is_array($session_data)) {
739
-            try {
740
-                $session_data = maybe_unserialize($session_data);
741
-            } catch (Exception $e) {
742
-                $msg = esc_html__(
743
-                    'An error occurred while attempting to unserialize the session data.',
744
-                    'event_espresso'
745
-                );
746
-                $msg .= WP_DEBUG
747
-                    ? '<br><pre>'
748
-                      . print_r($session_data, true)
749
-                      . '</pre><br>'
750
-                      . $this->find_serialize_error($session_data)
751
-                    : '';
752
-                $this->cache_storage->delete(EE_Session::session_id_prefix . $this->_sid);
753
-                throw new InvalidSessionDataException($msg, 0, $e);
754
-            }
755
-        }
756
-        // just a check to make sure the session array is indeed an array
757
-        if (! is_array($session_data)) {
758
-            // no?!?! then something is wrong
759
-            $msg = esc_html__(
760
-                'The session data is missing, invalid, or corrupted.',
761
-                'event_espresso'
762
-            );
763
-            $msg .= WP_DEBUG
764
-                ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
765
-                : '';
766
-            $this->cache_storage->delete(EE_Session::session_id_prefix . $this->_sid);
767
-            throw new InvalidSessionDataException($msg);
768
-        }
769
-        if (isset($session_data['transaction']) && absint($session_data['transaction']) !== 0) {
770
-            $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
771
-                $session_data['transaction']
772
-            );
773
-        }
774
-        return $session_data;
775
-    }
776
-
777
-
778
-    /**
779
-     * _generate_session_id
780
-     * Retrieves the PHP session id either directly from the PHP session,
781
-     * or from the $_REQUEST array if it was passed in from an AJAX request.
782
-     * The session id is then salted and hashed (mmm sounds tasty)
783
-     * so that it can be safely used as a $_REQUEST param
784
-     *
785
-     * @return string
786
-     */
787
-    protected function _generate_session_id()
788
-    {
789
-        // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length
790
-        if (isset($_REQUEST['EESID'])) {
791
-            $session_id = sanitize_text_field($_REQUEST['EESID']);
792
-        } else {
793
-            $session_id = md5(session_id() . get_current_blog_id() . $this->_get_sid_salt());
794
-        }
795
-        return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id);
796
-    }
797
-
798
-
799
-    /**
800
-     * _get_sid_salt
801
-     *
802
-     * @return string
803
-     */
804
-    protected function _get_sid_salt()
805
-    {
806
-        // was session id salt already saved to db ?
807
-        if (empty($this->_sid_salt)) {
808
-            // no?  then maybe use WP defined constant
809
-            if (defined('AUTH_SALT')) {
810
-                $this->_sid_salt = AUTH_SALT;
811
-            }
812
-            // if salt doesn't exist or is too short
813
-            if (strlen($this->_sid_salt) < 32) {
814
-                // create a new one
815
-                $this->_sid_salt = wp_generate_password(64);
816
-            }
817
-            // and save it as a permanent session setting
818
-            $this->updateSessionSettings(array('sid_salt' => $this->_sid_salt));
819
-        }
820
-        return $this->_sid_salt;
821
-    }
822
-
823
-
824
-    /**
825
-     * _set_init_access_and_expiration
826
-     *
827
-     * @return void
828
-     */
829
-    protected function _set_init_access_and_expiration()
830
-    {
831
-        $this->_time = time();
832
-        $this->_expiration = $this->_time + $this->session_lifespan->inSeconds();
833
-        // set initial site access time
834
-        $this->_session_data['init_access'] = $this->_time;
835
-        // and the session expiration
836
-        $this->_session_data['expiration'] = $this->_expiration;
837
-    }
838
-
839
-
840
-    /**
841
-     * @update session data  prior to saving to the db
842
-     * @access public
843
-     * @param bool $new_session
844
-     * @return TRUE on success, FALSE on fail
845
-     * @throws EE_Error
846
-     * @throws InvalidArgumentException
847
-     * @throws InvalidDataTypeException
848
-     * @throws InvalidInterfaceException
849
-     * @throws ReflectionException
850
-     */
851
-    public function update($new_session = false)
852
-    {
853
-        $this->_session_data = $this->_session_data !== null
854
-                               && is_array($this->_session_data)
855
-                               && isset($this->_session_data['id'])
856
-            ? $this->_session_data
857
-            : array();
858
-        if (empty($this->_session_data)) {
859
-            $this->_set_defaults();
860
-        }
861
-        $session_data = array();
862
-        foreach ($this->_session_data as $key => $value) {
863
-            switch ($key) {
864
-                case 'id':
865
-                    // session ID
866
-                    $session_data['id'] = $this->_sid;
867
-                    break;
868
-                case 'ip_address':
869
-                    // visitor ip address
870
-                    $session_data['ip_address'] = $this->request->ipAddress();
871
-                    break;
872
-                case 'user_agent':
873
-                    // visitor user_agent
874
-                    $session_data['user_agent'] = $this->_user_agent;
875
-                    break;
876
-                case 'init_access':
877
-                    $session_data['init_access'] = absint($value);
878
-                    break;
879
-                case 'last_access':
880
-                    // current access time
881
-                    $session_data['last_access'] = $this->_time;
882
-                    break;
883
-                case 'expiration':
884
-                    // when the session expires
885
-                    $session_data['expiration'] = ! empty($this->_expiration)
886
-                        ? $this->_expiration
887
-                        : $session_data['init_access'] + $this->session_lifespan->inSeconds();
888
-                    break;
889
-                case 'user_id':
890
-                    // current user if logged in
891
-                    $session_data['user_id'] = $this->_wp_user_id();
892
-                    break;
893
-                case 'pages_visited':
894
-                    $page_visit = $this->_get_page_visit();
895
-                    if ($page_visit) {
896
-                        // set pages visited where the first will be the http referrer
897
-                        $this->_session_data['pages_visited'][ $this->_time ] = $page_visit;
898
-                        // we'll only save the last 10 page visits.
899
-                        $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10);
900
-                    }
901
-                    break;
902
-                default:
903
-                    // carry any other data over
904
-                    $session_data[ $key ] = $this->_session_data[ $key ];
905
-            }
906
-        }
907
-        $this->_session_data = $session_data;
908
-        // creating a new session does not require saving to the db just yet
909
-        if (! $new_session) {
910
-            // ready? let's save
911
-            if ($this->_save_session_to_db()) {
912
-                return true;
913
-            }
914
-            return false;
915
-        }
916
-        // meh, why not?
917
-        return true;
918
-    }
919
-
920
-
921
-    /**
922
-     * @create session data array
923
-     * @access public
924
-     * @return bool
925
-     * @throws EE_Error
926
-     * @throws InvalidArgumentException
927
-     * @throws InvalidDataTypeException
928
-     * @throws InvalidInterfaceException
929
-     * @throws ReflectionException
930
-     */
931
-    private function _create_espresso_session()
932
-    {
933
-        do_action('AHEE_log', __CLASS__, __FUNCTION__, '');
934
-        // use the update function for now with $new_session arg set to TRUE
935
-        return $this->update(true) ? true : false;
936
-    }
937
-
938
-    /**
939
-     * Detects if there is anything worth saving in the session (eg the cart is a good one, notices are pretty good
940
-     * too). This is used when determining if we want to save the session or not.
941
-     * @since 4.9.67.p
942
-     * @return bool
943
-     */
944
-    private function sessionHasStuffWorthSaving()
945
-    {
946
-        return $this->save_state === EE_Session::SAVE_STATE_DIRTY
947
-               // we may want to eventually remove the following
948
-               // on the assumption that the above check is enough
949
-               || $this->cart() instanceof EE_Cart
950
-               || (
951
-                   isset($this->_session_data['ee_notices'])
952
-                   && (
953
-                       ! empty($this->_session_data['ee_notices']['attention'])
954
-                       || ! empty($this->_session_data['ee_notices']['errors'])
955
-                       || ! empty($this->_session_data['ee_notices']['success'])
956
-                   )
957
-               );
958
-    }
959
-
960
-
961
-    /**
962
-     * _save_session_to_db
963
-     *
964
-     * @param bool $clear_session
965
-     * @return string
966
-     * @throws EE_Error
967
-     * @throws InvalidArgumentException
968
-     * @throws InvalidDataTypeException
969
-     * @throws InvalidInterfaceException
970
-     * @throws ReflectionException
971
-     */
972
-    private function _save_session_to_db($clear_session = false)
973
-    {
974
-        // don't save sessions for crawlers
975
-        // and unless we're deleting the session data, don't save anything if there isn't a cart
976
-        if ($this->request->isBot()
977
-            || (
978
-                ! $clear_session
979
-                && ! $this->sessionHasStuffWorthSaving()
980
-                && apply_filters('FHEE__EE_Session___save_session_to_db__abort_session_save', true)
981
-            )
982
-        ) {
983
-            return false;
984
-        }
985
-        $transaction = $this->transaction();
986
-        if ($transaction instanceof EE_Transaction) {
987
-            if (! $transaction->ID()) {
988
-                $transaction->save();
989
-            }
990
-            $this->_session_data['transaction'] = $transaction->ID();
991
-        }
992
-        // then serialize all of our session data
993
-        $session_data = serialize($this->_session_data);
994
-        // do we need to also encode it to avoid corrupted data when saved to the db?
995
-        $session_data = $this->_use_encryption
996
-            ? $this->encryption->base64_string_encode($session_data)
997
-            : $session_data;
998
-        // maybe save hash check
999
-        if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
1000
-            $this->cache_storage->add(
1001
-                EE_Session::hash_check_prefix . $this->_sid,
1002
-                md5($session_data),
1003
-                $this->session_lifespan->inSeconds()
1004
-            );
1005
-        }
1006
-        // we're using the Transient API for storing session data,
1007
-        $saved = $this->cache_storage->add(
1008
-            EE_Session::session_id_prefix . $this->_sid,
1009
-            $session_data,
1010
-            $this->session_lifespan->inSeconds()
1011
-        );
1012
-        $this->setSaveState(EE_Session::SAVE_STATE_CLEAN);
1013
-        return $saved;
1014
-    }
1015
-
1016
-
1017
-    /**
1018
-     * @get    the full page request the visitor is accessing
1019
-     * @access public
1020
-     * @return string
1021
-     */
1022
-    public function _get_page_visit()
1023
-    {
1024
-        $page_visit = home_url('/') . 'wp-admin/admin-ajax.php';
1025
-        // check for request url
1026
-        if (isset($_SERVER['REQUEST_URI'])) {
1027
-            $http_host = '';
1028
-            $page_id = '?';
1029
-            $e_reg = '';
1030
-            $request_uri = esc_url($_SERVER['REQUEST_URI']);
1031
-            $ru_bits = explode('?', $request_uri);
1032
-            $request_uri = $ru_bits[0];
1033
-            // check for and grab host as well
1034
-            if (isset($_SERVER['HTTP_HOST'])) {
1035
-                $http_host = esc_url($_SERVER['HTTP_HOST']);
1036
-            }
1037
-            // check for page_id in SERVER REQUEST
1038
-            if (isset($_REQUEST['page_id'])) {
1039
-                // rebuild $e_reg without any of the extra parameters
1040
-                $page_id = '?page_id=' . esc_attr($_REQUEST['page_id']) . '&amp;';
1041
-            }
1042
-            // check for $e_reg in SERVER REQUEST
1043
-            if (isset($_REQUEST['ee'])) {
1044
-                // rebuild $e_reg without any of the extra parameters
1045
-                $e_reg = 'ee=' . esc_attr($_REQUEST['ee']);
1046
-            }
1047
-            $page_visit = rtrim($http_host . $request_uri . $page_id . $e_reg, '?');
1048
-        }
1049
-        return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : '';
1050
-    }
1051
-
1052
-
1053
-    /**
1054
-     * @the    current wp user id
1055
-     * @access public
1056
-     * @return int
1057
-     */
1058
-    public function _wp_user_id()
1059
-    {
1060
-        // if I need to explain the following lines of code, then you shouldn't be looking at this!
1061
-        $this->_wp_user_id = get_current_user_id();
1062
-        return $this->_wp_user_id;
1063
-    }
1064
-
1065
-
1066
-    /**
1067
-     * Clear EE_Session data
1068
-     *
1069
-     * @access public
1070
-     * @param string $class
1071
-     * @param string $function
1072
-     * @return void
1073
-     * @throws EE_Error
1074
-     * @throws InvalidArgumentException
1075
-     * @throws InvalidDataTypeException
1076
-     * @throws InvalidInterfaceException
1077
-     * @throws ReflectionException
1078
-     */
1079
-    public function clear_session($class = '', $function = '')
1080
-    {
27
+	const session_id_prefix = 'ee_ssn_';
28
+
29
+	const hash_check_prefix = 'ee_shc_';
30
+
31
+	const OPTION_NAME_SETTINGS = 'ee_session_settings';
32
+
33
+	const STATUS_CLOSED = 0;
34
+
35
+	const STATUS_OPEN = 1;
36
+
37
+	const SAVE_STATE_CLEAN = 'clean';
38
+	const SAVE_STATE_DIRTY = 'dirty';
39
+
40
+
41
+	/**
42
+	 * instance of the EE_Session object
43
+	 *
44
+	 * @var EE_Session
45
+	 */
46
+	private static $_instance;
47
+
48
+	/**
49
+	 * @var CacheStorageInterface $cache_storage
50
+	 */
51
+	protected $cache_storage;
52
+
53
+	/**
54
+	 * @var EE_Encryption $encryption
55
+	 */
56
+	protected $encryption;
57
+
58
+	/**
59
+	 * @var SessionStartHandler $session_start_handler
60
+	 */
61
+	protected $session_start_handler;
62
+
63
+	/**
64
+	 * the session id
65
+	 *
66
+	 * @var string
67
+	 */
68
+	private $_sid;
69
+
70
+	/**
71
+	 * session id salt
72
+	 *
73
+	 * @var string
74
+	 */
75
+	private $_sid_salt;
76
+
77
+	/**
78
+	 * session data
79
+	 *
80
+	 * @var array
81
+	 */
82
+	private $_session_data = array();
83
+
84
+	/**
85
+	 * how long an EE session lasts
86
+	 * default session lifespan of 1 hour (for not so instant IPNs)
87
+	 *
88
+	 * @var SessionLifespan $session_lifespan
89
+	 */
90
+	private $session_lifespan;
91
+
92
+	/**
93
+	 * session expiration time as Unix timestamp in GMT
94
+	 *
95
+	 * @var int
96
+	 */
97
+	private $_expiration;
98
+
99
+	/**
100
+	 * whether or not session has expired at some point
101
+	 *
102
+	 * @var boolean
103
+	 */
104
+	private $_expired = false;
105
+
106
+	/**
107
+	 * current time as Unix timestamp in GMT
108
+	 *
109
+	 * @var int
110
+	 */
111
+	private $_time;
112
+
113
+	/**
114
+	 * whether to encrypt session data
115
+	 *
116
+	 * @var bool
117
+	 */
118
+	private $_use_encryption;
119
+
120
+	/**
121
+	 * well... according to the server...
122
+	 *
123
+	 * @var null
124
+	 */
125
+	private $_user_agent;
126
+
127
+	/**
128
+	 * do you really trust the server ?
129
+	 *
130
+	 * @var null
131
+	 */
132
+	private $_ip_address;
133
+
134
+	/**
135
+	 * current WP user_id
136
+	 *
137
+	 * @var null
138
+	 */
139
+	private $_wp_user_id;
140
+
141
+	/**
142
+	 * array for defining default session vars
143
+	 *
144
+	 * @var array
145
+	 */
146
+	private $_default_session_vars = array(
147
+		'id'            => null,
148
+		'user_id'       => null,
149
+		'ip_address'    => null,
150
+		'user_agent'    => null,
151
+		'init_access'   => null,
152
+		'last_access'   => null,
153
+		'expiration'    => null,
154
+		'pages_visited' => array(),
155
+	);
156
+
157
+	/**
158
+	 * timestamp for when last garbage collection cycle was performed
159
+	 *
160
+	 * @var int $_last_gc
161
+	 */
162
+	private $_last_gc;
163
+
164
+	/**
165
+	 * @var RequestInterface $request
166
+	 */
167
+	protected $request;
168
+
169
+	/**
170
+	 * whether session is active or not
171
+	 *
172
+	 * @var int $status
173
+	 */
174
+	private $status = EE_Session::STATUS_CLOSED;
175
+
176
+	/**
177
+	 * whether session data has changed therefore requiring a session save
178
+	 *
179
+	 * @var string $save_state
180
+	 */
181
+	private $save_state = EE_Session::SAVE_STATE_CLEAN;
182
+
183
+
184
+	/**
185
+	 * @singleton method used to instantiate class object
186
+	 * @param CacheStorageInterface $cache_storage
187
+	 * @param SessionLifespan|null  $lifespan
188
+	 * @param RequestInterface      $request
189
+	 * @param SessionStartHandler   $session_start_handler
190
+	 * @param EE_Encryption         $encryption
191
+	 * @return EE_Session
192
+	 * @throws InvalidArgumentException
193
+	 * @throws InvalidDataTypeException
194
+	 * @throws InvalidInterfaceException
195
+	 */
196
+	public static function instance(
197
+		CacheStorageInterface $cache_storage = null,
198
+		SessionLifespan $lifespan = null,
199
+		RequestInterface $request = null,
200
+		SessionStartHandler $session_start_handler = null,
201
+		EE_Encryption $encryption = null
202
+	) {
203
+		// check if class object is instantiated
204
+		// session loading is turned ON by default, but prior to the init hook, can be turned back OFF via:
205
+		// add_filter( 'FHEE_load_EE_Session', '__return_false' );
206
+		if (! self::$_instance instanceof EE_Session
207
+			&& $cache_storage instanceof CacheStorageInterface
208
+			&& $lifespan instanceof SessionLifespan
209
+			&& $request instanceof RequestInterface
210
+			&& $session_start_handler instanceof SessionStartHandler
211
+			&& apply_filters('FHEE_load_EE_Session', true)
212
+		) {
213
+			self::$_instance = new self(
214
+				$cache_storage,
215
+				$lifespan,
216
+				$request,
217
+				$session_start_handler,
218
+				$encryption
219
+			);
220
+		}
221
+		return self::$_instance;
222
+	}
223
+
224
+
225
+	/**
226
+	 * protected constructor to prevent direct creation
227
+	 *
228
+	 * @param CacheStorageInterface $cache_storage
229
+	 * @param SessionLifespan       $lifespan
230
+	 * @param RequestInterface      $request
231
+	 * @param SessionStartHandler   $session_start_handler
232
+	 * @param EE_Encryption         $encryption
233
+	 * @throws InvalidArgumentException
234
+	 * @throws InvalidDataTypeException
235
+	 * @throws InvalidInterfaceException
236
+	 */
237
+	protected function __construct(
238
+		CacheStorageInterface $cache_storage,
239
+		SessionLifespan $lifespan,
240
+		RequestInterface $request,
241
+		SessionStartHandler $session_start_handler,
242
+		EE_Encryption $encryption = null
243
+	) {
244
+		// session loading is turned ON by default,
245
+		// but prior to the 'AHEE__EE_System__core_loaded_and_ready' hook
246
+		// (which currently fires on the init hook at priority 9),
247
+		// can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' );
248
+		if (! apply_filters('FHEE_load_EE_Session', true)) {
249
+			return;
250
+		}
251
+		$this->session_start_handler = $session_start_handler;
252
+		$this->session_lifespan = $lifespan;
253
+		$this->request = $request;
254
+		if (! defined('ESPRESSO_SESSION')) {
255
+			define('ESPRESSO_SESSION', true);
256
+		}
257
+		// retrieve session options from db
258
+		$session_settings = (array) get_option(EE_Session::OPTION_NAME_SETTINGS, array());
259
+		if (! empty($session_settings)) {
260
+			// cycle though existing session options
261
+			foreach ($session_settings as $var_name => $session_setting) {
262
+				// set values for class properties
263
+				$var_name = '_' . $var_name;
264
+				$this->{$var_name} = $session_setting;
265
+			}
266
+		}
267
+		$this->cache_storage = $cache_storage;
268
+		// are we using encryption?
269
+		$this->_use_encryption = $encryption instanceof EE_Encryption
270
+								 && EE_Registry::instance()->CFG->admin->encode_session_data();
271
+		// encrypt data via: $this->encryption->encrypt();
272
+		$this->encryption = $encryption;
273
+		// filter hook allows outside functions/classes/plugins to change default empty cart
274
+		$extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array());
275
+		array_merge($this->_default_session_vars, $extra_default_session_vars);
276
+		// apply default session vars
277
+		$this->_set_defaults();
278
+		add_action('AHEE__EE_System__initialize', array($this, 'open_session'));
279
+		// check request for 'clear_session' param
280
+		add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded'));
281
+		// once everything is all said and done,
282
+		add_action('shutdown', array($this, 'update'), 100);
283
+		add_action('shutdown', array($this, 'garbageCollection'), 1000);
284
+		$this->configure_garbage_collection_filters();
285
+	}
286
+
287
+
288
+	/**
289
+	 * @return bool
290
+	 * @throws InvalidArgumentException
291
+	 * @throws InvalidDataTypeException
292
+	 * @throws InvalidInterfaceException
293
+	 */
294
+	public static function isLoadedAndActive()
295
+	{
296
+		return did_action('AHEE__EE_System__core_loaded_and_ready')
297
+			   && EE_Session::instance() instanceof EE_Session
298
+			   && EE_Session::instance()->isActive();
299
+	}
300
+
301
+
302
+	/**
303
+	 * @return bool
304
+	 */
305
+	public function isActive()
306
+	{
307
+		return $this->status === EE_Session::STATUS_OPEN;
308
+	}
309
+
310
+
311
+	/**
312
+	 * @return void
313
+	 * @throws EE_Error
314
+	 * @throws InvalidArgumentException
315
+	 * @throws InvalidDataTypeException
316
+	 * @throws InvalidInterfaceException
317
+	 * @throws InvalidSessionDataException
318
+	 * @throws RuntimeException
319
+	 * @throws ReflectionException
320
+	 */
321
+	public function open_session()
322
+	{
323
+		// check for existing session and retrieve it from db
324
+		if (! $this->_espresso_session()) {
325
+			// or just start a new one
326
+			$this->_create_espresso_session();
327
+		}
328
+	}
329
+
330
+
331
+	/**
332
+	 * @return bool
333
+	 */
334
+	public function expired()
335
+	{
336
+		return $this->_expired;
337
+	}
338
+
339
+
340
+	/**
341
+	 * @return void
342
+	 */
343
+	public function reset_expired()
344
+	{
345
+		$this->_expired = false;
346
+	}
347
+
348
+
349
+	/**
350
+	 * @return int
351
+	 */
352
+	public function expiration()
353
+	{
354
+		return $this->_expiration;
355
+	}
356
+
357
+
358
+	/**
359
+	 * @return int
360
+	 */
361
+	public function extension()
362
+	{
363
+		return apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS);
364
+	}
365
+
366
+
367
+	/**
368
+	 * @param int $time number of seconds to add to session expiration
369
+	 */
370
+	public function extend_expiration($time = 0)
371
+	{
372
+		$time = $time ? $time : $this->extension();
373
+		$this->_expiration += absint($time);
374
+	}
375
+
376
+
377
+	/**
378
+	 * @return int
379
+	 */
380
+	public function lifespan()
381
+	{
382
+		return $this->session_lifespan->inSeconds();
383
+	}
384
+
385
+
386
+	/**
387
+	 * Marks whether the session data has been updated or not.
388
+	 * Valid options are:
389
+	 *      EE_Session::SAVE_STATE_CLEAN - session data remains unchanged and updating is not necessary
390
+	 *      EE_Session::SAVE_STATE_DIRTY - session data has changed since last save and needs to be updated
391
+	 * default value is EE_Session::SAVE_STATE_DIRTY
392
+	 *
393
+	 * @param string $save_state
394
+	 */
395
+	public function setSaveState($save_state = EE_Session::SAVE_STATE_DIRTY)
396
+	{
397
+		$valid_save_states = [
398
+			EE_Session::SAVE_STATE_CLEAN,
399
+			EE_Session::SAVE_STATE_DIRTY,
400
+		];
401
+		if (! in_array($save_state, $valid_save_states, true)) {
402
+			$save_state = EE_Session::SAVE_STATE_DIRTY;
403
+		}
404
+		$this->save_state = $save_state;
405
+	}
406
+
407
+
408
+
409
+	/**
410
+	 * This just sets some defaults for the _session data property
411
+	 *
412
+	 * @access private
413
+	 * @return void
414
+	 */
415
+	private function _set_defaults()
416
+	{
417
+		// set some defaults
418
+		foreach ($this->_default_session_vars as $key => $default_var) {
419
+			if (is_array($default_var)) {
420
+				$this->_session_data[ $key ] = array();
421
+			} else {
422
+				$this->_session_data[ $key ] = '';
423
+			}
424
+		}
425
+	}
426
+
427
+
428
+	/**
429
+	 * @retrieve  session data
430
+	 * @access    public
431
+	 * @return    string
432
+	 */
433
+	public function id()
434
+	{
435
+		return $this->_sid;
436
+	}
437
+
438
+
439
+	/**
440
+	 * @param \EE_Cart $cart
441
+	 * @return bool
442
+	 */
443
+	public function set_cart(EE_Cart $cart)
444
+	{
445
+		$this->_session_data['cart'] = $cart;
446
+		$this->setSaveState();
447
+		return true;
448
+	}
449
+
450
+
451
+	/**
452
+	 * reset_cart
453
+	 */
454
+	public function reset_cart()
455
+	{
456
+		do_action('AHEE__EE_Session__reset_cart__before_reset', $this);
457
+		$this->_session_data['cart'] = null;
458
+		$this->setSaveState();
459
+	}
460
+
461
+
462
+	/**
463
+	 * @return \EE_Cart
464
+	 */
465
+	public function cart()
466
+	{
467
+		return isset($this->_session_data['cart']) && $this->_session_data['cart'] instanceof EE_Cart
468
+			? $this->_session_data['cart']
469
+			: null;
470
+	}
471
+
472
+
473
+	/**
474
+	 * @param \EE_Checkout $checkout
475
+	 * @return bool
476
+	 */
477
+	public function set_checkout(EE_Checkout $checkout)
478
+	{
479
+		$this->_session_data['checkout'] = $checkout;
480
+		$this->setSaveState();
481
+		return true;
482
+	}
483
+
484
+
485
+	/**
486
+	 * reset_checkout
487
+	 */
488
+	public function reset_checkout()
489
+	{
490
+		do_action('AHEE__EE_Session__reset_checkout__before_reset', $this);
491
+		$this->_session_data['checkout'] = null;
492
+		$this->setSaveState();
493
+	}
494
+
495
+
496
+	/**
497
+	 * @return \EE_Checkout
498
+	 */
499
+	public function checkout()
500
+	{
501
+		return isset($this->_session_data['checkout']) && $this->_session_data['checkout'] instanceof EE_Checkout
502
+			? $this->_session_data['checkout']
503
+			: null;
504
+	}
505
+
506
+
507
+	/**
508
+	 * @param \EE_Transaction $transaction
509
+	 * @return bool
510
+	 * @throws EE_Error
511
+	 */
512
+	public function set_transaction(EE_Transaction $transaction)
513
+	{
514
+		// first remove the session from the transaction before we save the transaction in the session
515
+		$transaction->set_txn_session_data(null);
516
+		$this->_session_data['transaction'] = $transaction;
517
+		$this->setSaveState();
518
+		return true;
519
+	}
520
+
521
+
522
+	/**
523
+	 * reset_transaction
524
+	 */
525
+	public function reset_transaction()
526
+	{
527
+		do_action('AHEE__EE_Session__reset_transaction__before_reset', $this);
528
+		$this->_session_data['transaction'] = null;
529
+		$this->setSaveState();
530
+	}
531
+
532
+
533
+	/**
534
+	 * @return \EE_Transaction
535
+	 */
536
+	public function transaction()
537
+	{
538
+		return isset($this->_session_data['transaction'])
539
+			   && $this->_session_data['transaction'] instanceof EE_Transaction
540
+			? $this->_session_data['transaction']
541
+			: null;
542
+	}
543
+
544
+
545
+	/**
546
+	 * retrieve session data
547
+	 *
548
+	 * @param null $key
549
+	 * @param bool $reset_cache
550
+	 * @return array
551
+	 */
552
+	public function get_session_data($key = null, $reset_cache = false)
553
+	{
554
+		if ($reset_cache) {
555
+			$this->reset_cart();
556
+			$this->reset_checkout();
557
+			$this->reset_transaction();
558
+		}
559
+		if (! empty($key)) {
560
+			return isset($this->_session_data[ $key ]) ? $this->_session_data[ $key ] : null;
561
+		}
562
+		return $this->_session_data;
563
+	}
564
+
565
+
566
+	/**
567
+	 * Returns TRUE on success, FALSE on fail
568
+	 *
569
+	 * @param array $data
570
+	 * @return bool
571
+	 */
572
+	public function set_session_data($data)
573
+	{
574
+		// nothing ??? bad data ??? go home!
575
+		if (empty($data) || ! is_array($data)) {
576
+			EE_Error::add_error(
577
+				esc_html__(
578
+					'No session data or invalid session data was provided.',
579
+					'event_espresso'
580
+				),
581
+				__FILE__,
582
+				__FUNCTION__,
583
+				__LINE__
584
+			);
585
+			return false;
586
+		}
587
+		foreach ($data as $key => $value) {
588
+			if (isset($this->_default_session_vars[ $key ])) {
589
+				EE_Error::add_error(
590
+					sprintf(
591
+						esc_html__(
592
+							'Sorry! %s is a default session datum and can not be reset.',
593
+							'event_espresso'
594
+						),
595
+						$key
596
+					),
597
+					__FILE__,
598
+					__FUNCTION__,
599
+					__LINE__
600
+				);
601
+				return false;
602
+			}
603
+			$this->_session_data[ $key ] = $value;
604
+			$this->setSaveState();
605
+		}
606
+		return true;
607
+	}
608
+
609
+
610
+	/**
611
+	 * @initiate session
612
+	 * @access   private
613
+	 * @return TRUE on success, FALSE on fail
614
+	 * @throws EE_Error
615
+	 * @throws InvalidArgumentException
616
+	 * @throws InvalidDataTypeException
617
+	 * @throws InvalidInterfaceException
618
+	 * @throws InvalidSessionDataException
619
+	 * @throws RuntimeException
620
+	 * @throws ReflectionException
621
+	 */
622
+	private function _espresso_session()
623
+	{
624
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
625
+		$this->session_start_handler->startSession();
626
+		$this->status = EE_Session::STATUS_OPEN;
627
+		// get our modified session ID
628
+		$this->_sid = $this->_generate_session_id();
629
+		// and the visitors IP
630
+		$this->_ip_address = $this->request->ipAddress();
631
+		// set the "user agent"
632
+		$this->_user_agent = $this->request->userAgent();
633
+		// now let's retrieve what's in the db
634
+		$session_data = $this->_retrieve_session_data();
635
+		if (! empty($session_data)) {
636
+			// get the current time in UTC
637
+			$this->_time = $this->_time !== null ? $this->_time : time();
638
+			// and reset the session expiration
639
+			$this->_expiration = isset($session_data['expiration'])
640
+				? $session_data['expiration']
641
+				: $this->_time + $this->session_lifespan->inSeconds();
642
+		} else {
643
+			// set initial site access time and the session expiration
644
+			$this->_set_init_access_and_expiration();
645
+			// set referer
646
+			$this->_session_data['pages_visited'][ $this->_session_data['init_access'] ] = isset($_SERVER['HTTP_REFERER'])
647
+				? esc_attr($_SERVER['HTTP_REFERER'])
648
+				: '';
649
+			// no previous session = go back and create one (on top of the data above)
650
+			return false;
651
+		}
652
+		// now the user agent
653
+		if ($session_data['user_agent'] !== $this->_user_agent) {
654
+			return false;
655
+		}
656
+		// wait a minute... how old are you?
657
+		if ($this->_time > $this->_expiration) {
658
+			// yer too old fer me!
659
+			$this->_expired = true;
660
+			// wipe out everything that isn't a default session datum
661
+			$this->clear_session(__CLASS__, __FUNCTION__);
662
+		}
663
+		// make event espresso session data available to plugin
664
+		$this->_session_data = array_merge($this->_session_data, $session_data);
665
+		return true;
666
+	}
667
+
668
+
669
+	/**
670
+	 * _get_session_data
671
+	 * Retrieves the session data, and attempts to correct any encoding issues that can occur due to improperly setup
672
+	 * databases
673
+	 *
674
+	 * @return array
675
+	 * @throws EE_Error
676
+	 * @throws InvalidArgumentException
677
+	 * @throws InvalidSessionDataException
678
+	 * @throws InvalidDataTypeException
679
+	 * @throws InvalidInterfaceException
680
+	 * @throws RuntimeException
681
+	 */
682
+	protected function _retrieve_session_data()
683
+	{
684
+		$ssn_key = EE_Session::session_id_prefix . $this->_sid;
685
+		try {
686
+			// we're using WP's Transient API to store session data using the PHP session ID as the option name
687
+			$session_data = $this->cache_storage->get($ssn_key, false);
688
+			if (empty($session_data)) {
689
+				return array();
690
+			}
691
+			if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
692
+				$hash_check = $this->cache_storage->get(
693
+					EE_Session::hash_check_prefix . $this->_sid,
694
+					false
695
+				);
696
+				if ($hash_check && $hash_check !== md5($session_data)) {
697
+					EE_Error::add_error(
698
+						sprintf(
699
+							__(
700
+								'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.',
701
+								'event_espresso'
702
+							),
703
+							EE_Session::session_id_prefix . $this->_sid
704
+						),
705
+						__FILE__,
706
+						__FUNCTION__,
707
+						__LINE__
708
+					);
709
+				}
710
+			}
711
+		} catch (Exception $e) {
712
+			// let's just eat that error for now and attempt to correct any corrupted data
713
+			global $wpdb;
714
+			$row = $wpdb->get_row(
715
+				$wpdb->prepare(
716
+					"SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
717
+					'_transient_' . $ssn_key
718
+				)
719
+			);
720
+			$session_data = is_object($row) ? $row->option_value : null;
721
+			if ($session_data) {
722
+				$session_data = preg_replace_callback(
723
+					'!s:(d+):"(.*?)";!',
724
+					function ($match) {
725
+						return $match[1] === strlen($match[2])
726
+							? $match[0]
727
+							: 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
728
+					},
729
+					$session_data
730
+				);
731
+			}
732
+			$session_data = maybe_unserialize($session_data);
733
+		}
734
+		// in case the data is encoded... try to decode it
735
+		$session_data = $this->encryption instanceof EE_Encryption
736
+			? $this->encryption->base64_string_decode($session_data)
737
+			: $session_data;
738
+		if (! is_array($session_data)) {
739
+			try {
740
+				$session_data = maybe_unserialize($session_data);
741
+			} catch (Exception $e) {
742
+				$msg = esc_html__(
743
+					'An error occurred while attempting to unserialize the session data.',
744
+					'event_espresso'
745
+				);
746
+				$msg .= WP_DEBUG
747
+					? '<br><pre>'
748
+					  . print_r($session_data, true)
749
+					  . '</pre><br>'
750
+					  . $this->find_serialize_error($session_data)
751
+					: '';
752
+				$this->cache_storage->delete(EE_Session::session_id_prefix . $this->_sid);
753
+				throw new InvalidSessionDataException($msg, 0, $e);
754
+			}
755
+		}
756
+		// just a check to make sure the session array is indeed an array
757
+		if (! is_array($session_data)) {
758
+			// no?!?! then something is wrong
759
+			$msg = esc_html__(
760
+				'The session data is missing, invalid, or corrupted.',
761
+				'event_espresso'
762
+			);
763
+			$msg .= WP_DEBUG
764
+				? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
765
+				: '';
766
+			$this->cache_storage->delete(EE_Session::session_id_prefix . $this->_sid);
767
+			throw new InvalidSessionDataException($msg);
768
+		}
769
+		if (isset($session_data['transaction']) && absint($session_data['transaction']) !== 0) {
770
+			$session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
771
+				$session_data['transaction']
772
+			);
773
+		}
774
+		return $session_data;
775
+	}
776
+
777
+
778
+	/**
779
+	 * _generate_session_id
780
+	 * Retrieves the PHP session id either directly from the PHP session,
781
+	 * or from the $_REQUEST array if it was passed in from an AJAX request.
782
+	 * The session id is then salted and hashed (mmm sounds tasty)
783
+	 * so that it can be safely used as a $_REQUEST param
784
+	 *
785
+	 * @return string
786
+	 */
787
+	protected function _generate_session_id()
788
+	{
789
+		// check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length
790
+		if (isset($_REQUEST['EESID'])) {
791
+			$session_id = sanitize_text_field($_REQUEST['EESID']);
792
+		} else {
793
+			$session_id = md5(session_id() . get_current_blog_id() . $this->_get_sid_salt());
794
+		}
795
+		return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id);
796
+	}
797
+
798
+
799
+	/**
800
+	 * _get_sid_salt
801
+	 *
802
+	 * @return string
803
+	 */
804
+	protected function _get_sid_salt()
805
+	{
806
+		// was session id salt already saved to db ?
807
+		if (empty($this->_sid_salt)) {
808
+			// no?  then maybe use WP defined constant
809
+			if (defined('AUTH_SALT')) {
810
+				$this->_sid_salt = AUTH_SALT;
811
+			}
812
+			// if salt doesn't exist or is too short
813
+			if (strlen($this->_sid_salt) < 32) {
814
+				// create a new one
815
+				$this->_sid_salt = wp_generate_password(64);
816
+			}
817
+			// and save it as a permanent session setting
818
+			$this->updateSessionSettings(array('sid_salt' => $this->_sid_salt));
819
+		}
820
+		return $this->_sid_salt;
821
+	}
822
+
823
+
824
+	/**
825
+	 * _set_init_access_and_expiration
826
+	 *
827
+	 * @return void
828
+	 */
829
+	protected function _set_init_access_and_expiration()
830
+	{
831
+		$this->_time = time();
832
+		$this->_expiration = $this->_time + $this->session_lifespan->inSeconds();
833
+		// set initial site access time
834
+		$this->_session_data['init_access'] = $this->_time;
835
+		// and the session expiration
836
+		$this->_session_data['expiration'] = $this->_expiration;
837
+	}
838
+
839
+
840
+	/**
841
+	 * @update session data  prior to saving to the db
842
+	 * @access public
843
+	 * @param bool $new_session
844
+	 * @return TRUE on success, FALSE on fail
845
+	 * @throws EE_Error
846
+	 * @throws InvalidArgumentException
847
+	 * @throws InvalidDataTypeException
848
+	 * @throws InvalidInterfaceException
849
+	 * @throws ReflectionException
850
+	 */
851
+	public function update($new_session = false)
852
+	{
853
+		$this->_session_data = $this->_session_data !== null
854
+							   && is_array($this->_session_data)
855
+							   && isset($this->_session_data['id'])
856
+			? $this->_session_data
857
+			: array();
858
+		if (empty($this->_session_data)) {
859
+			$this->_set_defaults();
860
+		}
861
+		$session_data = array();
862
+		foreach ($this->_session_data as $key => $value) {
863
+			switch ($key) {
864
+				case 'id':
865
+					// session ID
866
+					$session_data['id'] = $this->_sid;
867
+					break;
868
+				case 'ip_address':
869
+					// visitor ip address
870
+					$session_data['ip_address'] = $this->request->ipAddress();
871
+					break;
872
+				case 'user_agent':
873
+					// visitor user_agent
874
+					$session_data['user_agent'] = $this->_user_agent;
875
+					break;
876
+				case 'init_access':
877
+					$session_data['init_access'] = absint($value);
878
+					break;
879
+				case 'last_access':
880
+					// current access time
881
+					$session_data['last_access'] = $this->_time;
882
+					break;
883
+				case 'expiration':
884
+					// when the session expires
885
+					$session_data['expiration'] = ! empty($this->_expiration)
886
+						? $this->_expiration
887
+						: $session_data['init_access'] + $this->session_lifespan->inSeconds();
888
+					break;
889
+				case 'user_id':
890
+					// current user if logged in
891
+					$session_data['user_id'] = $this->_wp_user_id();
892
+					break;
893
+				case 'pages_visited':
894
+					$page_visit = $this->_get_page_visit();
895
+					if ($page_visit) {
896
+						// set pages visited where the first will be the http referrer
897
+						$this->_session_data['pages_visited'][ $this->_time ] = $page_visit;
898
+						// we'll only save the last 10 page visits.
899
+						$session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10);
900
+					}
901
+					break;
902
+				default:
903
+					// carry any other data over
904
+					$session_data[ $key ] = $this->_session_data[ $key ];
905
+			}
906
+		}
907
+		$this->_session_data = $session_data;
908
+		// creating a new session does not require saving to the db just yet
909
+		if (! $new_session) {
910
+			// ready? let's save
911
+			if ($this->_save_session_to_db()) {
912
+				return true;
913
+			}
914
+			return false;
915
+		}
916
+		// meh, why not?
917
+		return true;
918
+	}
919
+
920
+
921
+	/**
922
+	 * @create session data array
923
+	 * @access public
924
+	 * @return bool
925
+	 * @throws EE_Error
926
+	 * @throws InvalidArgumentException
927
+	 * @throws InvalidDataTypeException
928
+	 * @throws InvalidInterfaceException
929
+	 * @throws ReflectionException
930
+	 */
931
+	private function _create_espresso_session()
932
+	{
933
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, '');
934
+		// use the update function for now with $new_session arg set to TRUE
935
+		return $this->update(true) ? true : false;
936
+	}
937
+
938
+	/**
939
+	 * Detects if there is anything worth saving in the session (eg the cart is a good one, notices are pretty good
940
+	 * too). This is used when determining if we want to save the session or not.
941
+	 * @since 4.9.67.p
942
+	 * @return bool
943
+	 */
944
+	private function sessionHasStuffWorthSaving()
945
+	{
946
+		return $this->save_state === EE_Session::SAVE_STATE_DIRTY
947
+			   // we may want to eventually remove the following
948
+			   // on the assumption that the above check is enough
949
+			   || $this->cart() instanceof EE_Cart
950
+			   || (
951
+				   isset($this->_session_data['ee_notices'])
952
+				   && (
953
+					   ! empty($this->_session_data['ee_notices']['attention'])
954
+					   || ! empty($this->_session_data['ee_notices']['errors'])
955
+					   || ! empty($this->_session_data['ee_notices']['success'])
956
+				   )
957
+			   );
958
+	}
959
+
960
+
961
+	/**
962
+	 * _save_session_to_db
963
+	 *
964
+	 * @param bool $clear_session
965
+	 * @return string
966
+	 * @throws EE_Error
967
+	 * @throws InvalidArgumentException
968
+	 * @throws InvalidDataTypeException
969
+	 * @throws InvalidInterfaceException
970
+	 * @throws ReflectionException
971
+	 */
972
+	private function _save_session_to_db($clear_session = false)
973
+	{
974
+		// don't save sessions for crawlers
975
+		// and unless we're deleting the session data, don't save anything if there isn't a cart
976
+		if ($this->request->isBot()
977
+			|| (
978
+				! $clear_session
979
+				&& ! $this->sessionHasStuffWorthSaving()
980
+				&& apply_filters('FHEE__EE_Session___save_session_to_db__abort_session_save', true)
981
+			)
982
+		) {
983
+			return false;
984
+		}
985
+		$transaction = $this->transaction();
986
+		if ($transaction instanceof EE_Transaction) {
987
+			if (! $transaction->ID()) {
988
+				$transaction->save();
989
+			}
990
+			$this->_session_data['transaction'] = $transaction->ID();
991
+		}
992
+		// then serialize all of our session data
993
+		$session_data = serialize($this->_session_data);
994
+		// do we need to also encode it to avoid corrupted data when saved to the db?
995
+		$session_data = $this->_use_encryption
996
+			? $this->encryption->base64_string_encode($session_data)
997
+			: $session_data;
998
+		// maybe save hash check
999
+		if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
1000
+			$this->cache_storage->add(
1001
+				EE_Session::hash_check_prefix . $this->_sid,
1002
+				md5($session_data),
1003
+				$this->session_lifespan->inSeconds()
1004
+			);
1005
+		}
1006
+		// we're using the Transient API for storing session data,
1007
+		$saved = $this->cache_storage->add(
1008
+			EE_Session::session_id_prefix . $this->_sid,
1009
+			$session_data,
1010
+			$this->session_lifespan->inSeconds()
1011
+		);
1012
+		$this->setSaveState(EE_Session::SAVE_STATE_CLEAN);
1013
+		return $saved;
1014
+	}
1015
+
1016
+
1017
+	/**
1018
+	 * @get    the full page request the visitor is accessing
1019
+	 * @access public
1020
+	 * @return string
1021
+	 */
1022
+	public function _get_page_visit()
1023
+	{
1024
+		$page_visit = home_url('/') . 'wp-admin/admin-ajax.php';
1025
+		// check for request url
1026
+		if (isset($_SERVER['REQUEST_URI'])) {
1027
+			$http_host = '';
1028
+			$page_id = '?';
1029
+			$e_reg = '';
1030
+			$request_uri = esc_url($_SERVER['REQUEST_URI']);
1031
+			$ru_bits = explode('?', $request_uri);
1032
+			$request_uri = $ru_bits[0];
1033
+			// check for and grab host as well
1034
+			if (isset($_SERVER['HTTP_HOST'])) {
1035
+				$http_host = esc_url($_SERVER['HTTP_HOST']);
1036
+			}
1037
+			// check for page_id in SERVER REQUEST
1038
+			if (isset($_REQUEST['page_id'])) {
1039
+				// rebuild $e_reg without any of the extra parameters
1040
+				$page_id = '?page_id=' . esc_attr($_REQUEST['page_id']) . '&amp;';
1041
+			}
1042
+			// check for $e_reg in SERVER REQUEST
1043
+			if (isset($_REQUEST['ee'])) {
1044
+				// rebuild $e_reg without any of the extra parameters
1045
+				$e_reg = 'ee=' . esc_attr($_REQUEST['ee']);
1046
+			}
1047
+			$page_visit = rtrim($http_host . $request_uri . $page_id . $e_reg, '?');
1048
+		}
1049
+		return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : '';
1050
+	}
1051
+
1052
+
1053
+	/**
1054
+	 * @the    current wp user id
1055
+	 * @access public
1056
+	 * @return int
1057
+	 */
1058
+	public function _wp_user_id()
1059
+	{
1060
+		// if I need to explain the following lines of code, then you shouldn't be looking at this!
1061
+		$this->_wp_user_id = get_current_user_id();
1062
+		return $this->_wp_user_id;
1063
+	}
1064
+
1065
+
1066
+	/**
1067
+	 * Clear EE_Session data
1068
+	 *
1069
+	 * @access public
1070
+	 * @param string $class
1071
+	 * @param string $function
1072
+	 * @return void
1073
+	 * @throws EE_Error
1074
+	 * @throws InvalidArgumentException
1075
+	 * @throws InvalidDataTypeException
1076
+	 * @throws InvalidInterfaceException
1077
+	 * @throws ReflectionException
1078
+	 */
1079
+	public function clear_session($class = '', $function = '')
1080
+	{
1081 1081
 //         echo '
1082 1082
 // <h3 style="color:#999;line-height:.9em;">
1083 1083
 // <span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/>
1084 1084
 // <span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span>    <b style="font-size:10px;">  ' . __LINE__ . ' </b>
1085 1085
 // </h3>';
1086
-        do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()');
1087
-        $this->reset_cart();
1088
-        $this->reset_checkout();
1089
-        $this->reset_transaction();
1090
-        // wipe out everything that isn't a default session datum
1091
-        $this->reset_data(array_keys($this->_session_data));
1092
-        // reset initial site access time and the session expiration
1093
-        $this->_set_init_access_and_expiration();
1094
-        $this->setSaveState();
1095
-        $this->_save_session_to_db(true);
1096
-    }
1097
-
1098
-
1099
-    /**
1100
-     * resets all non-default session vars. Returns TRUE on success, FALSE on fail
1101
-     *
1102
-     * @param array|mixed $data_to_reset
1103
-     * @param bool        $show_all_notices
1104
-     * @return bool
1105
-     */
1106
-    public function reset_data($data_to_reset = array(), $show_all_notices = false)
1107
-    {
1108
-        // if $data_to_reset is not in an array, then put it in one
1109
-        if (! is_array($data_to_reset)) {
1110
-            $data_to_reset = array($data_to_reset);
1111
-        }
1112
-        // nothing ??? go home!
1113
-        if (empty($data_to_reset)) {
1114
-            EE_Error::add_error(
1115
-                __(
1116
-                    'No session data could be reset, because no session var name was provided.',
1117
-                    'event_espresso'
1118
-                ),
1119
-                __FILE__,
1120
-                __FUNCTION__,
1121
-                __LINE__
1122
-            );
1123
-            return false;
1124
-        }
1125
-        $return_value = true;
1126
-        // since $data_to_reset is an array, cycle through the values
1127
-        foreach ($data_to_reset as $reset) {
1128
-            // first check to make sure it is a valid session var
1129
-            if (isset($this->_session_data[ $reset ])) {
1130
-                // then check to make sure it is not a default var
1131
-                if (! array_key_exists($reset, $this->_default_session_vars)) {
1132
-                    // remove session var
1133
-                    unset($this->_session_data[ $reset ]);
1134
-                    $this->setSaveState();
1135
-                    if ($show_all_notices) {
1136
-                        EE_Error::add_success(
1137
-                            sprintf(
1138
-                                __('The session variable %s was removed.', 'event_espresso'),
1139
-                                $reset
1140
-                            ),
1141
-                            __FILE__,
1142
-                            __FUNCTION__,
1143
-                            __LINE__
1144
-                        );
1145
-                    }
1146
-                } else {
1147
-                    // yeeeeeeeeerrrrrrrrrrr OUT !!!!
1148
-                    if ($show_all_notices) {
1149
-                        EE_Error::add_error(
1150
-                            sprintf(
1151
-                                __(
1152
-                                    'Sorry! %s is a default session datum and can not be reset.',
1153
-                                    'event_espresso'
1154
-                                ),
1155
-                                $reset
1156
-                            ),
1157
-                            __FILE__,
1158
-                            __FUNCTION__,
1159
-                            __LINE__
1160
-                        );
1161
-                    }
1162
-                    $return_value = false;
1163
-                }
1164
-            } elseif ($show_all_notices) {
1165
-                // oops! that session var does not exist!
1166
-                EE_Error::add_error(
1167
-                    sprintf(
1168
-                        __(
1169
-                            'The session item provided, %s, is invalid or does not exist.',
1170
-                            'event_espresso'
1171
-                        ),
1172
-                        $reset
1173
-                    ),
1174
-                    __FILE__,
1175
-                    __FUNCTION__,
1176
-                    __LINE__
1177
-                );
1178
-                $return_value = false;
1179
-            }
1180
-        } // end of foreach
1181
-        return $return_value;
1182
-    }
1183
-
1184
-
1185
-    /**
1186
-     *   wp_loaded
1187
-     *
1188
-     * @access public
1189
-     * @throws EE_Error
1190
-     * @throws InvalidDataTypeException
1191
-     * @throws InvalidInterfaceException
1192
-     * @throws InvalidArgumentException
1193
-     * @throws ReflectionException
1194
-     */
1195
-    public function wp_loaded()
1196
-    {
1197
-        if ($this->request->requestParamIsSet('clear_session')) {
1198
-            $this->clear_session(__CLASS__, __FUNCTION__);
1199
-        }
1200
-    }
1201
-
1202
-
1203
-    /**
1204
-     * Used to reset the entire object (for tests).
1205
-     *
1206
-     * @since 4.3.0
1207
-     * @throws EE_Error
1208
-     * @throws InvalidDataTypeException
1209
-     * @throws InvalidInterfaceException
1210
-     * @throws InvalidArgumentException
1211
-     * @throws ReflectionException
1212
-     */
1213
-    public function reset_instance()
1214
-    {
1215
-        $this->clear_session();
1216
-        self::$_instance = null;
1217
-    }
1218
-
1219
-
1220
-    public function configure_garbage_collection_filters()
1221
-    {
1222
-        // run old filter we had for controlling session cleanup
1223
-        $expired_session_transient_delete_query_limit = absint(
1224
-            apply_filters(
1225
-                'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit',
1226
-                50
1227
-            )
1228
-        );
1229
-        // is there a value? or one that is different than the default 50 records?
1230
-        if ($expired_session_transient_delete_query_limit === 0) {
1231
-            // hook into TransientCacheStorage in case Session cleanup was turned off
1232
-            add_filter('FHEE__TransientCacheStorage__transient_cleanup_schedule', '__return_zero');
1233
-        } elseif ($expired_session_transient_delete_query_limit !== 50) {
1234
-            // or use that for the new transient cleanup query limit
1235
-            add_filter(
1236
-                'FHEE__TransientCacheStorage__clearExpiredTransients__limit',
1237
-                function () use ($expired_session_transient_delete_query_limit) {
1238
-                    return $expired_session_transient_delete_query_limit;
1239
-                }
1240
-            );
1241
-        }
1242
-    }
1243
-
1244
-
1245
-    /**
1246
-     * @see http://stackoverflow.com/questions/10152904/unserialize-function-unserialize-error-at-offset/21389439#10152996
1247
-     * @param $data1
1248
-     * @return string
1249
-     */
1250
-    private function find_serialize_error($data1)
1251
-    {
1252
-        $error = '<pre>';
1253
-        $data2 = preg_replace_callback(
1254
-            '!s:(\d+):"(.*?)";!',
1255
-            function ($match) {
1256
-                return ($match[1] === strlen($match[2]))
1257
-                    ? $match[0]
1258
-                    : 's:'
1259
-                      . strlen($match[2])
1260
-                      . ':"'
1261
-                      . $match[2]
1262
-                      . '";';
1263
-            },
1264
-            $data1
1265
-        );
1266
-        $max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2);
1267
-        $error .= $data1 . PHP_EOL;
1268
-        $error .= $data2 . PHP_EOL;
1269
-        for ($i = 0; $i < $max; $i++) {
1270
-            if (@$data1[ $i ] !== @$data2[ $i ]) {
1271
-                $error .= 'Difference ' . @$data1[ $i ] . ' != ' . @$data2[ $i ] . PHP_EOL;
1272
-                $error .= "\t-> ORD number " . ord(@$data1[ $i ]) . ' != ' . ord(@$data2[ $i ]) . PHP_EOL;
1273
-                $error .= "\t-> Line Number = $i" . PHP_EOL;
1274
-                $start = ($i - 20);
1275
-                $start = ($start < 0) ? 0 : $start;
1276
-                $length = 40;
1277
-                $point = $max - $i;
1278
-                if ($point < 20) {
1279
-                    $rlength = 1;
1280
-                    $rpoint = -$point;
1281
-                } else {
1282
-                    $rpoint = $length - 20;
1283
-                    $rlength = 1;
1284
-                }
1285
-                $error .= "\t-> Section Data1  = ";
1286
-                $error .= substr_replace(
1287
-                    substr($data1, $start, $length),
1288
-                    "<b style=\"color:green\">{$data1[ $i ]}</b>",
1289
-                    $rpoint,
1290
-                    $rlength
1291
-                );
1292
-                $error .= PHP_EOL;
1293
-                $error .= "\t-> Section Data2  = ";
1294
-                $error .= substr_replace(
1295
-                    substr($data2, $start, $length),
1296
-                    "<b style=\"color:red\">{$data2[ $i ]}</b>",
1297
-                    $rpoint,
1298
-                    $rlength
1299
-                );
1300
-                $error .= PHP_EOL;
1301
-            }
1302
-        }
1303
-        $error .= '</pre>';
1304
-        return $error;
1305
-    }
1306
-
1307
-
1308
-    /**
1309
-     * Saves an  array of settings used for configuring aspects of session behaviour
1310
-     *
1311
-     * @param array $updated_settings
1312
-     */
1313
-    private function updateSessionSettings(array $updated_settings = array())
1314
-    {
1315
-        // add existing settings, but only if not included in incoming $updated_settings array
1316
-        $updated_settings += get_option(EE_Session::OPTION_NAME_SETTINGS, array());
1317
-        update_option(EE_Session::OPTION_NAME_SETTINGS, $updated_settings);
1318
-    }
1319
-
1320
-
1321
-    /**
1322
-     * garbage_collection
1323
-     */
1324
-    public function garbageCollection()
1325
-    {
1326
-        // only perform during regular requests if last garbage collection was over an hour ago
1327
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && (time() - HOUR_IN_SECONDS) >= $this->_last_gc) {
1328
-            $this->_last_gc = time();
1329
-            $this->updateSessionSettings(array('last_gc' => $this->_last_gc));
1330
-            /** @type WPDB $wpdb */
1331
-            global $wpdb;
1332
-            // filter the query limit. Set to 0 to turn off garbage collection
1333
-            $expired_session_transient_delete_query_limit = absint(
1334
-                apply_filters(
1335
-                    'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit',
1336
-                    50
1337
-                )
1338
-            );
1339
-            // non-zero LIMIT means take out the trash
1340
-            if ($expired_session_transient_delete_query_limit) {
1341
-                $session_key = str_replace('_', '\_', EE_Session::session_id_prefix);
1342
-                $hash_check_key = str_replace('_', '\_', EE_Session::hash_check_prefix);
1343
-                // since transient expiration timestamps are set in the future, we can compare against NOW
1344
-                // but we only want to pick up any trash that's been around for more than a day
1345
-                $expiration = time() - DAY_IN_SECONDS;
1346
-                $SQL = "
1086
+		do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()');
1087
+		$this->reset_cart();
1088
+		$this->reset_checkout();
1089
+		$this->reset_transaction();
1090
+		// wipe out everything that isn't a default session datum
1091
+		$this->reset_data(array_keys($this->_session_data));
1092
+		// reset initial site access time and the session expiration
1093
+		$this->_set_init_access_and_expiration();
1094
+		$this->setSaveState();
1095
+		$this->_save_session_to_db(true);
1096
+	}
1097
+
1098
+
1099
+	/**
1100
+	 * resets all non-default session vars. Returns TRUE on success, FALSE on fail
1101
+	 *
1102
+	 * @param array|mixed $data_to_reset
1103
+	 * @param bool        $show_all_notices
1104
+	 * @return bool
1105
+	 */
1106
+	public function reset_data($data_to_reset = array(), $show_all_notices = false)
1107
+	{
1108
+		// if $data_to_reset is not in an array, then put it in one
1109
+		if (! is_array($data_to_reset)) {
1110
+			$data_to_reset = array($data_to_reset);
1111
+		}
1112
+		// nothing ??? go home!
1113
+		if (empty($data_to_reset)) {
1114
+			EE_Error::add_error(
1115
+				__(
1116
+					'No session data could be reset, because no session var name was provided.',
1117
+					'event_espresso'
1118
+				),
1119
+				__FILE__,
1120
+				__FUNCTION__,
1121
+				__LINE__
1122
+			);
1123
+			return false;
1124
+		}
1125
+		$return_value = true;
1126
+		// since $data_to_reset is an array, cycle through the values
1127
+		foreach ($data_to_reset as $reset) {
1128
+			// first check to make sure it is a valid session var
1129
+			if (isset($this->_session_data[ $reset ])) {
1130
+				// then check to make sure it is not a default var
1131
+				if (! array_key_exists($reset, $this->_default_session_vars)) {
1132
+					// remove session var
1133
+					unset($this->_session_data[ $reset ]);
1134
+					$this->setSaveState();
1135
+					if ($show_all_notices) {
1136
+						EE_Error::add_success(
1137
+							sprintf(
1138
+								__('The session variable %s was removed.', 'event_espresso'),
1139
+								$reset
1140
+							),
1141
+							__FILE__,
1142
+							__FUNCTION__,
1143
+							__LINE__
1144
+						);
1145
+					}
1146
+				} else {
1147
+					// yeeeeeeeeerrrrrrrrrrr OUT !!!!
1148
+					if ($show_all_notices) {
1149
+						EE_Error::add_error(
1150
+							sprintf(
1151
+								__(
1152
+									'Sorry! %s is a default session datum and can not be reset.',
1153
+									'event_espresso'
1154
+								),
1155
+								$reset
1156
+							),
1157
+							__FILE__,
1158
+							__FUNCTION__,
1159
+							__LINE__
1160
+						);
1161
+					}
1162
+					$return_value = false;
1163
+				}
1164
+			} elseif ($show_all_notices) {
1165
+				// oops! that session var does not exist!
1166
+				EE_Error::add_error(
1167
+					sprintf(
1168
+						__(
1169
+							'The session item provided, %s, is invalid or does not exist.',
1170
+							'event_espresso'
1171
+						),
1172
+						$reset
1173
+					),
1174
+					__FILE__,
1175
+					__FUNCTION__,
1176
+					__LINE__
1177
+				);
1178
+				$return_value = false;
1179
+			}
1180
+		} // end of foreach
1181
+		return $return_value;
1182
+	}
1183
+
1184
+
1185
+	/**
1186
+	 *   wp_loaded
1187
+	 *
1188
+	 * @access public
1189
+	 * @throws EE_Error
1190
+	 * @throws InvalidDataTypeException
1191
+	 * @throws InvalidInterfaceException
1192
+	 * @throws InvalidArgumentException
1193
+	 * @throws ReflectionException
1194
+	 */
1195
+	public function wp_loaded()
1196
+	{
1197
+		if ($this->request->requestParamIsSet('clear_session')) {
1198
+			$this->clear_session(__CLASS__, __FUNCTION__);
1199
+		}
1200
+	}
1201
+
1202
+
1203
+	/**
1204
+	 * Used to reset the entire object (for tests).
1205
+	 *
1206
+	 * @since 4.3.0
1207
+	 * @throws EE_Error
1208
+	 * @throws InvalidDataTypeException
1209
+	 * @throws InvalidInterfaceException
1210
+	 * @throws InvalidArgumentException
1211
+	 * @throws ReflectionException
1212
+	 */
1213
+	public function reset_instance()
1214
+	{
1215
+		$this->clear_session();
1216
+		self::$_instance = null;
1217
+	}
1218
+
1219
+
1220
+	public function configure_garbage_collection_filters()
1221
+	{
1222
+		// run old filter we had for controlling session cleanup
1223
+		$expired_session_transient_delete_query_limit = absint(
1224
+			apply_filters(
1225
+				'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit',
1226
+				50
1227
+			)
1228
+		);
1229
+		// is there a value? or one that is different than the default 50 records?
1230
+		if ($expired_session_transient_delete_query_limit === 0) {
1231
+			// hook into TransientCacheStorage in case Session cleanup was turned off
1232
+			add_filter('FHEE__TransientCacheStorage__transient_cleanup_schedule', '__return_zero');
1233
+		} elseif ($expired_session_transient_delete_query_limit !== 50) {
1234
+			// or use that for the new transient cleanup query limit
1235
+			add_filter(
1236
+				'FHEE__TransientCacheStorage__clearExpiredTransients__limit',
1237
+				function () use ($expired_session_transient_delete_query_limit) {
1238
+					return $expired_session_transient_delete_query_limit;
1239
+				}
1240
+			);
1241
+		}
1242
+	}
1243
+
1244
+
1245
+	/**
1246
+	 * @see http://stackoverflow.com/questions/10152904/unserialize-function-unserialize-error-at-offset/21389439#10152996
1247
+	 * @param $data1
1248
+	 * @return string
1249
+	 */
1250
+	private function find_serialize_error($data1)
1251
+	{
1252
+		$error = '<pre>';
1253
+		$data2 = preg_replace_callback(
1254
+			'!s:(\d+):"(.*?)";!',
1255
+			function ($match) {
1256
+				return ($match[1] === strlen($match[2]))
1257
+					? $match[0]
1258
+					: 's:'
1259
+					  . strlen($match[2])
1260
+					  . ':"'
1261
+					  . $match[2]
1262
+					  . '";';
1263
+			},
1264
+			$data1
1265
+		);
1266
+		$max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2);
1267
+		$error .= $data1 . PHP_EOL;
1268
+		$error .= $data2 . PHP_EOL;
1269
+		for ($i = 0; $i < $max; $i++) {
1270
+			if (@$data1[ $i ] !== @$data2[ $i ]) {
1271
+				$error .= 'Difference ' . @$data1[ $i ] . ' != ' . @$data2[ $i ] . PHP_EOL;
1272
+				$error .= "\t-> ORD number " . ord(@$data1[ $i ]) . ' != ' . ord(@$data2[ $i ]) . PHP_EOL;
1273
+				$error .= "\t-> Line Number = $i" . PHP_EOL;
1274
+				$start = ($i - 20);
1275
+				$start = ($start < 0) ? 0 : $start;
1276
+				$length = 40;
1277
+				$point = $max - $i;
1278
+				if ($point < 20) {
1279
+					$rlength = 1;
1280
+					$rpoint = -$point;
1281
+				} else {
1282
+					$rpoint = $length - 20;
1283
+					$rlength = 1;
1284
+				}
1285
+				$error .= "\t-> Section Data1  = ";
1286
+				$error .= substr_replace(
1287
+					substr($data1, $start, $length),
1288
+					"<b style=\"color:green\">{$data1[ $i ]}</b>",
1289
+					$rpoint,
1290
+					$rlength
1291
+				);
1292
+				$error .= PHP_EOL;
1293
+				$error .= "\t-> Section Data2  = ";
1294
+				$error .= substr_replace(
1295
+					substr($data2, $start, $length),
1296
+					"<b style=\"color:red\">{$data2[ $i ]}</b>",
1297
+					$rpoint,
1298
+					$rlength
1299
+				);
1300
+				$error .= PHP_EOL;
1301
+			}
1302
+		}
1303
+		$error .= '</pre>';
1304
+		return $error;
1305
+	}
1306
+
1307
+
1308
+	/**
1309
+	 * Saves an  array of settings used for configuring aspects of session behaviour
1310
+	 *
1311
+	 * @param array $updated_settings
1312
+	 */
1313
+	private function updateSessionSettings(array $updated_settings = array())
1314
+	{
1315
+		// add existing settings, but only if not included in incoming $updated_settings array
1316
+		$updated_settings += get_option(EE_Session::OPTION_NAME_SETTINGS, array());
1317
+		update_option(EE_Session::OPTION_NAME_SETTINGS, $updated_settings);
1318
+	}
1319
+
1320
+
1321
+	/**
1322
+	 * garbage_collection
1323
+	 */
1324
+	public function garbageCollection()
1325
+	{
1326
+		// only perform during regular requests if last garbage collection was over an hour ago
1327
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && (time() - HOUR_IN_SECONDS) >= $this->_last_gc) {
1328
+			$this->_last_gc = time();
1329
+			$this->updateSessionSettings(array('last_gc' => $this->_last_gc));
1330
+			/** @type WPDB $wpdb */
1331
+			global $wpdb;
1332
+			// filter the query limit. Set to 0 to turn off garbage collection
1333
+			$expired_session_transient_delete_query_limit = absint(
1334
+				apply_filters(
1335
+					'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit',
1336
+					50
1337
+				)
1338
+			);
1339
+			// non-zero LIMIT means take out the trash
1340
+			if ($expired_session_transient_delete_query_limit) {
1341
+				$session_key = str_replace('_', '\_', EE_Session::session_id_prefix);
1342
+				$hash_check_key = str_replace('_', '\_', EE_Session::hash_check_prefix);
1343
+				// since transient expiration timestamps are set in the future, we can compare against NOW
1344
+				// but we only want to pick up any trash that's been around for more than a day
1345
+				$expiration = time() - DAY_IN_SECONDS;
1346
+				$SQL = "
1347 1347
                     SELECT option_name
1348 1348
                     FROM {$wpdb->options}
1349 1349
                     WHERE
@@ -1352,17 +1352,17 @@  discard block
 block discarded – undo
1352 1352
                     AND option_value < {$expiration}
1353 1353
                     LIMIT {$expired_session_transient_delete_query_limit}
1354 1354
                 ";
1355
-                // produces something like:
1356
-                // SELECT option_name FROM wp_options
1357
-                // WHERE ( option_name LIKE '\_transient\_timeout\_ee\_ssn\_%'
1358
-                // OR option_name LIKE '\_transient\_timeout\_ee\_shc\_%' )
1359
-                // AND option_value < 1508368198 LIMIT 50
1360
-                $expired_sessions = $wpdb->get_col($SQL);
1361
-                // valid results?
1362
-                if (! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) {
1363
-                    $this->cache_storage->deleteMany($expired_sessions, true);
1364
-                }
1365
-            }
1366
-        }
1367
-    }
1355
+				// produces something like:
1356
+				// SELECT option_name FROM wp_options
1357
+				// WHERE ( option_name LIKE '\_transient\_timeout\_ee\_ssn\_%'
1358
+				// OR option_name LIKE '\_transient\_timeout\_ee\_shc\_%' )
1359
+				// AND option_value < 1508368198 LIMIT 50
1360
+				$expired_sessions = $wpdb->get_col($SQL);
1361
+				// valid results?
1362
+				if (! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) {
1363
+					$this->cache_storage->deleteMany($expired_sessions, true);
1364
+				}
1365
+			}
1366
+		}
1367
+	}
1368 1368
 }
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         // check if class object is instantiated
204 204
         // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via:
205 205
         // add_filter( 'FHEE_load_EE_Session', '__return_false' );
206
-        if (! self::$_instance instanceof EE_Session
206
+        if ( ! self::$_instance instanceof EE_Session
207 207
             && $cache_storage instanceof CacheStorageInterface
208 208
             && $lifespan instanceof SessionLifespan
209 209
             && $request instanceof RequestInterface
@@ -245,22 +245,22 @@  discard block
 block discarded – undo
245 245
         // but prior to the 'AHEE__EE_System__core_loaded_and_ready' hook
246 246
         // (which currently fires on the init hook at priority 9),
247 247
         // can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' );
248
-        if (! apply_filters('FHEE_load_EE_Session', true)) {
248
+        if ( ! apply_filters('FHEE_load_EE_Session', true)) {
249 249
             return;
250 250
         }
251 251
         $this->session_start_handler = $session_start_handler;
252 252
         $this->session_lifespan = $lifespan;
253 253
         $this->request = $request;
254
-        if (! defined('ESPRESSO_SESSION')) {
254
+        if ( ! defined('ESPRESSO_SESSION')) {
255 255
             define('ESPRESSO_SESSION', true);
256 256
         }
257 257
         // retrieve session options from db
258 258
         $session_settings = (array) get_option(EE_Session::OPTION_NAME_SETTINGS, array());
259
-        if (! empty($session_settings)) {
259
+        if ( ! empty($session_settings)) {
260 260
             // cycle though existing session options
261 261
             foreach ($session_settings as $var_name => $session_setting) {
262 262
                 // set values for class properties
263
-                $var_name = '_' . $var_name;
263
+                $var_name = '_'.$var_name;
264 264
                 $this->{$var_name} = $session_setting;
265 265
             }
266 266
         }
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     public function open_session()
322 322
     {
323 323
         // check for existing session and retrieve it from db
324
-        if (! $this->_espresso_session()) {
324
+        if ( ! $this->_espresso_session()) {
325 325
             // or just start a new one
326 326
             $this->_create_espresso_session();
327 327
         }
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
             EE_Session::SAVE_STATE_CLEAN,
399 399
             EE_Session::SAVE_STATE_DIRTY,
400 400
         ];
401
-        if (! in_array($save_state, $valid_save_states, true)) {
401
+        if ( ! in_array($save_state, $valid_save_states, true)) {
402 402
             $save_state = EE_Session::SAVE_STATE_DIRTY;
403 403
         }
404 404
         $this->save_state = $save_state;
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
         // set some defaults
418 418
         foreach ($this->_default_session_vars as $key => $default_var) {
419 419
             if (is_array($default_var)) {
420
-                $this->_session_data[ $key ] = array();
420
+                $this->_session_data[$key] = array();
421 421
             } else {
422
-                $this->_session_data[ $key ] = '';
422
+                $this->_session_data[$key] = '';
423 423
             }
424 424
         }
425 425
     }
@@ -556,8 +556,8 @@  discard block
 block discarded – undo
556 556
             $this->reset_checkout();
557 557
             $this->reset_transaction();
558 558
         }
559
-        if (! empty($key)) {
560
-            return isset($this->_session_data[ $key ]) ? $this->_session_data[ $key ] : null;
559
+        if ( ! empty($key)) {
560
+            return isset($this->_session_data[$key]) ? $this->_session_data[$key] : null;
561 561
         }
562 562
         return $this->_session_data;
563 563
     }
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
             return false;
586 586
         }
587 587
         foreach ($data as $key => $value) {
588
-            if (isset($this->_default_session_vars[ $key ])) {
588
+            if (isset($this->_default_session_vars[$key])) {
589 589
                 EE_Error::add_error(
590 590
                     sprintf(
591 591
                         esc_html__(
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
                 );
601 601
                 return false;
602 602
             }
603
-            $this->_session_data[ $key ] = $value;
603
+            $this->_session_data[$key] = $value;
604 604
             $this->setSaveState();
605 605
         }
606 606
         return true;
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
         $this->_user_agent = $this->request->userAgent();
633 633
         // now let's retrieve what's in the db
634 634
         $session_data = $this->_retrieve_session_data();
635
-        if (! empty($session_data)) {
635
+        if ( ! empty($session_data)) {
636 636
             // get the current time in UTC
637 637
             $this->_time = $this->_time !== null ? $this->_time : time();
638 638
             // and reset the session expiration
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
             // set initial site access time and the session expiration
644 644
             $this->_set_init_access_and_expiration();
645 645
             // set referer
646
-            $this->_session_data['pages_visited'][ $this->_session_data['init_access'] ] = isset($_SERVER['HTTP_REFERER'])
646
+            $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER'])
647 647
                 ? esc_attr($_SERVER['HTTP_REFERER'])
648 648
                 : '';
649 649
             // no previous session = go back and create one (on top of the data above)
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
      */
682 682
     protected function _retrieve_session_data()
683 683
     {
684
-        $ssn_key = EE_Session::session_id_prefix . $this->_sid;
684
+        $ssn_key = EE_Session::session_id_prefix.$this->_sid;
685 685
         try {
686 686
             // we're using WP's Transient API to store session data using the PHP session ID as the option name
687 687
             $session_data = $this->cache_storage->get($ssn_key, false);
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
             }
691 691
             if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
692 692
                 $hash_check = $this->cache_storage->get(
693
-                    EE_Session::hash_check_prefix . $this->_sid,
693
+                    EE_Session::hash_check_prefix.$this->_sid,
694 694
                     false
695 695
                 );
696 696
                 if ($hash_check && $hash_check !== md5($session_data)) {
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
                                 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.',
701 701
                                 'event_espresso'
702 702
                             ),
703
-                            EE_Session::session_id_prefix . $this->_sid
703
+                            EE_Session::session_id_prefix.$this->_sid
704 704
                         ),
705 705
                         __FILE__,
706 706
                         __FUNCTION__,
@@ -714,17 +714,17 @@  discard block
 block discarded – undo
714 714
             $row = $wpdb->get_row(
715 715
                 $wpdb->prepare(
716 716
                     "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
717
-                    '_transient_' . $ssn_key
717
+                    '_transient_'.$ssn_key
718 718
                 )
719 719
             );
720 720
             $session_data = is_object($row) ? $row->option_value : null;
721 721
             if ($session_data) {
722 722
                 $session_data = preg_replace_callback(
723 723
                     '!s:(d+):"(.*?)";!',
724
-                    function ($match) {
724
+                    function($match) {
725 725
                         return $match[1] === strlen($match[2])
726 726
                             ? $match[0]
727
-                            : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
727
+                            : 's:'.strlen($match[2]).':"'.$match[2].'";';
728 728
                     },
729 729
                     $session_data
730 730
                 );
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
         $session_data = $this->encryption instanceof EE_Encryption
736 736
             ? $this->encryption->base64_string_decode($session_data)
737 737
             : $session_data;
738
-        if (! is_array($session_data)) {
738
+        if ( ! is_array($session_data)) {
739 739
             try {
740 740
                 $session_data = maybe_unserialize($session_data);
741 741
             } catch (Exception $e) {
@@ -749,21 +749,21 @@  discard block
 block discarded – undo
749 749
                       . '</pre><br>'
750 750
                       . $this->find_serialize_error($session_data)
751 751
                     : '';
752
-                $this->cache_storage->delete(EE_Session::session_id_prefix . $this->_sid);
752
+                $this->cache_storage->delete(EE_Session::session_id_prefix.$this->_sid);
753 753
                 throw new InvalidSessionDataException($msg, 0, $e);
754 754
             }
755 755
         }
756 756
         // just a check to make sure the session array is indeed an array
757
-        if (! is_array($session_data)) {
757
+        if ( ! is_array($session_data)) {
758 758
             // no?!?! then something is wrong
759 759
             $msg = esc_html__(
760 760
                 'The session data is missing, invalid, or corrupted.',
761 761
                 'event_espresso'
762 762
             );
763 763
             $msg .= WP_DEBUG
764
-                ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
764
+                ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data)
765 765
                 : '';
766
-            $this->cache_storage->delete(EE_Session::session_id_prefix . $this->_sid);
766
+            $this->cache_storage->delete(EE_Session::session_id_prefix.$this->_sid);
767 767
             throw new InvalidSessionDataException($msg);
768 768
         }
769 769
         if (isset($session_data['transaction']) && absint($session_data['transaction']) !== 0) {
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
         if (isset($_REQUEST['EESID'])) {
791 791
             $session_id = sanitize_text_field($_REQUEST['EESID']);
792 792
         } else {
793
-            $session_id = md5(session_id() . get_current_blog_id() . $this->_get_sid_salt());
793
+            $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt());
794 794
         }
795 795
         return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id);
796 796
     }
@@ -894,19 +894,19 @@  discard block
 block discarded – undo
894 894
                     $page_visit = $this->_get_page_visit();
895 895
                     if ($page_visit) {
896 896
                         // set pages visited where the first will be the http referrer
897
-                        $this->_session_data['pages_visited'][ $this->_time ] = $page_visit;
897
+                        $this->_session_data['pages_visited'][$this->_time] = $page_visit;
898 898
                         // we'll only save the last 10 page visits.
899 899
                         $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10);
900 900
                     }
901 901
                     break;
902 902
                 default:
903 903
                     // carry any other data over
904
-                    $session_data[ $key ] = $this->_session_data[ $key ];
904
+                    $session_data[$key] = $this->_session_data[$key];
905 905
             }
906 906
         }
907 907
         $this->_session_data = $session_data;
908 908
         // creating a new session does not require saving to the db just yet
909
-        if (! $new_session) {
909
+        if ( ! $new_session) {
910 910
             // ready? let's save
911 911
             if ($this->_save_session_to_db()) {
912 912
                 return true;
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
         }
985 985
         $transaction = $this->transaction();
986 986
         if ($transaction instanceof EE_Transaction) {
987
-            if (! $transaction->ID()) {
987
+            if ( ! $transaction->ID()) {
988 988
                 $transaction->save();
989 989
             }
990 990
             $this->_session_data['transaction'] = $transaction->ID();
@@ -998,14 +998,14 @@  discard block
 block discarded – undo
998 998
         // maybe save hash check
999 999
         if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
1000 1000
             $this->cache_storage->add(
1001
-                EE_Session::hash_check_prefix . $this->_sid,
1001
+                EE_Session::hash_check_prefix.$this->_sid,
1002 1002
                 md5($session_data),
1003 1003
                 $this->session_lifespan->inSeconds()
1004 1004
             );
1005 1005
         }
1006 1006
         // we're using the Transient API for storing session data,
1007 1007
         $saved = $this->cache_storage->add(
1008
-            EE_Session::session_id_prefix . $this->_sid,
1008
+            EE_Session::session_id_prefix.$this->_sid,
1009 1009
             $session_data,
1010 1010
             $this->session_lifespan->inSeconds()
1011 1011
         );
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
      */
1022 1022
     public function _get_page_visit()
1023 1023
     {
1024
-        $page_visit = home_url('/') . 'wp-admin/admin-ajax.php';
1024
+        $page_visit = home_url('/').'wp-admin/admin-ajax.php';
1025 1025
         // check for request url
1026 1026
         if (isset($_SERVER['REQUEST_URI'])) {
1027 1027
             $http_host = '';
@@ -1037,14 +1037,14 @@  discard block
 block discarded – undo
1037 1037
             // check for page_id in SERVER REQUEST
1038 1038
             if (isset($_REQUEST['page_id'])) {
1039 1039
                 // rebuild $e_reg without any of the extra parameters
1040
-                $page_id = '?page_id=' . esc_attr($_REQUEST['page_id']) . '&amp;';
1040
+                $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&amp;';
1041 1041
             }
1042 1042
             // check for $e_reg in SERVER REQUEST
1043 1043
             if (isset($_REQUEST['ee'])) {
1044 1044
                 // rebuild $e_reg without any of the extra parameters
1045
-                $e_reg = 'ee=' . esc_attr($_REQUEST['ee']);
1045
+                $e_reg = 'ee='.esc_attr($_REQUEST['ee']);
1046 1046
             }
1047
-            $page_visit = rtrim($http_host . $request_uri . $page_id . $e_reg, '?');
1047
+            $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?');
1048 1048
         }
1049 1049
         return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : '';
1050 1050
     }
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
 // <span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/>
1084 1084
 // <span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span>    <b style="font-size:10px;">  ' . __LINE__ . ' </b>
1085 1085
 // </h3>';
1086
-        do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()');
1086
+        do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()');
1087 1087
         $this->reset_cart();
1088 1088
         $this->reset_checkout();
1089 1089
         $this->reset_transaction();
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
     public function reset_data($data_to_reset = array(), $show_all_notices = false)
1107 1107
     {
1108 1108
         // if $data_to_reset is not in an array, then put it in one
1109
-        if (! is_array($data_to_reset)) {
1109
+        if ( ! is_array($data_to_reset)) {
1110 1110
             $data_to_reset = array($data_to_reset);
1111 1111
         }
1112 1112
         // nothing ??? go home!
@@ -1126,11 +1126,11 @@  discard block
 block discarded – undo
1126 1126
         // since $data_to_reset is an array, cycle through the values
1127 1127
         foreach ($data_to_reset as $reset) {
1128 1128
             // first check to make sure it is a valid session var
1129
-            if (isset($this->_session_data[ $reset ])) {
1129
+            if (isset($this->_session_data[$reset])) {
1130 1130
                 // then check to make sure it is not a default var
1131
-                if (! array_key_exists($reset, $this->_default_session_vars)) {
1131
+                if ( ! array_key_exists($reset, $this->_default_session_vars)) {
1132 1132
                     // remove session var
1133
-                    unset($this->_session_data[ $reset ]);
1133
+                    unset($this->_session_data[$reset]);
1134 1134
                     $this->setSaveState();
1135 1135
                     if ($show_all_notices) {
1136 1136
                         EE_Error::add_success(
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
             // or use that for the new transient cleanup query limit
1235 1235
             add_filter(
1236 1236
                 'FHEE__TransientCacheStorage__clearExpiredTransients__limit',
1237
-                function () use ($expired_session_transient_delete_query_limit) {
1237
+                function() use ($expired_session_transient_delete_query_limit) {
1238 1238
                     return $expired_session_transient_delete_query_limit;
1239 1239
                 }
1240 1240
             );
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
         $error = '<pre>';
1253 1253
         $data2 = preg_replace_callback(
1254 1254
             '!s:(\d+):"(.*?)";!',
1255
-            function ($match) {
1255
+            function($match) {
1256 1256
                 return ($match[1] === strlen($match[2]))
1257 1257
                     ? $match[0]
1258 1258
                     : 's:'
@@ -1264,13 +1264,13 @@  discard block
 block discarded – undo
1264 1264
             $data1
1265 1265
         );
1266 1266
         $max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2);
1267
-        $error .= $data1 . PHP_EOL;
1268
-        $error .= $data2 . PHP_EOL;
1267
+        $error .= $data1.PHP_EOL;
1268
+        $error .= $data2.PHP_EOL;
1269 1269
         for ($i = 0; $i < $max; $i++) {
1270
-            if (@$data1[ $i ] !== @$data2[ $i ]) {
1271
-                $error .= 'Difference ' . @$data1[ $i ] . ' != ' . @$data2[ $i ] . PHP_EOL;
1272
-                $error .= "\t-> ORD number " . ord(@$data1[ $i ]) . ' != ' . ord(@$data2[ $i ]) . PHP_EOL;
1273
-                $error .= "\t-> Line Number = $i" . PHP_EOL;
1270
+            if (@$data1[$i] !== @$data2[$i]) {
1271
+                $error .= 'Difference '.@$data1[$i].' != '.@$data2[$i].PHP_EOL;
1272
+                $error .= "\t-> ORD number ".ord(@$data1[$i]).' != '.ord(@$data2[$i]).PHP_EOL;
1273
+                $error .= "\t-> Line Number = $i".PHP_EOL;
1274 1274
                 $start = ($i - 20);
1275 1275
                 $start = ($start < 0) ? 0 : $start;
1276 1276
                 $length = 40;
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
                 $error .= "\t-> Section Data1  = ";
1286 1286
                 $error .= substr_replace(
1287 1287
                     substr($data1, $start, $length),
1288
-                    "<b style=\"color:green\">{$data1[ $i ]}</b>",
1288
+                    "<b style=\"color:green\">{$data1[$i]}</b>",
1289 1289
                     $rpoint,
1290 1290
                     $rlength
1291 1291
                 );
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
                 $error .= "\t-> Section Data2  = ";
1294 1294
                 $error .= substr_replace(
1295 1295
                     substr($data2, $start, $length),
1296
-                    "<b style=\"color:red\">{$data2[ $i ]}</b>",
1296
+                    "<b style=\"color:red\">{$data2[$i]}</b>",
1297 1297
                     $rpoint,
1298 1298
                     $rlength
1299 1299
                 );
@@ -1324,7 +1324,7 @@  discard block
 block discarded – undo
1324 1324
     public function garbageCollection()
1325 1325
     {
1326 1326
         // only perform during regular requests if last garbage collection was over an hour ago
1327
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && (time() - HOUR_IN_SECONDS) >= $this->_last_gc) {
1327
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && (time() - HOUR_IN_SECONDS) >= $this->_last_gc) {
1328 1328
             $this->_last_gc = time();
1329 1329
             $this->updateSessionSettings(array('last_gc' => $this->_last_gc));
1330 1330
             /** @type WPDB $wpdb */
@@ -1359,7 +1359,7 @@  discard block
 block discarded – undo
1359 1359
                 // AND option_value < 1508368198 LIMIT 50
1360 1360
                 $expired_sessions = $wpdb->get_col($SQL);
1361 1361
                 // valid results?
1362
-                if (! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) {
1362
+                if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) {
1363 1363
                     $this->cache_storage->deleteMany($expired_sessions, true);
1364 1364
                 }
1365 1365
             }
Please login to merge, or discard this patch.
core/services/assets/BlockAssetManager.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 
143 143
 
144 144
     /**
145
-     * @param       $handle
145
+     * @param       string $handle
146 146
      * @param array $dependencies
147 147
      * @since $VID:$
148 148
      * @return JavascriptAsset
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
 
170 170
     /**
171
-     * @param        $handle
171
+     * @param        string $handle
172 172
      * @param array  $dependencies
173 173
      * @since $VID:$
174 174
      * @return StylesheetAsset
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 
194 194
 
195 195
     /**
196
-     * @param       $handle
196
+     * @param       string $handle
197 197
      * @param array $dependencies
198 198
      * @since $VID:$
199 199
      * @return JavascriptAsset
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
 
221 221
     /**
222
-     * @param        $handle
222
+     * @param        string $handle
223 223
      * @param array  $dependencies
224 224
      * @since $VID:$
225 225
      * @return StylesheetAsset
Please login to merge, or discard this patch.
Indentation   +305 added lines, -305 removed lines patch added patch discarded remove patch
@@ -22,310 +22,310 @@
 block discarded – undo
22 22
 abstract class BlockAssetManager extends AssetManager implements BlockAssetManagerInterface
23 23
 {
24 24
 
25
-    /**
26
-     * @var string $editor_script_handle
27
-     */
28
-    private $editor_script_handle;
29
-
30
-    /**
31
-     * @var string $editor_style_handle
32
-     */
33
-    private $editor_style_handle;
34
-
35
-    /**
36
-     * @var string $script_handle
37
-     */
38
-    private $script_handle;
39
-
40
-    /**
41
-     * @var string $style_handle
42
-     */
43
-    private $style_handle;
44
-
45
-
46
-    /**
47
-     * @return string
48
-     */
49
-    public function getEditorScriptHandle()
50
-    {
51
-        return $this->editor_script_handle;
52
-    }
53
-
54
-
55
-    /**
56
-     * @param string $editor_script_handle
57
-     */
58
-    public function setEditorScriptHandle($editor_script_handle)
59
-    {
60
-        if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
61
-            $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
62
-        }
63
-        $this->editor_script_handle = $editor_script_handle;
64
-    }
65
-
66
-
67
-    /**
68
-     * @return string
69
-     */
70
-    public function getEditorStyleHandle()
71
-    {
72
-        return $this->editor_style_handle;
73
-    }
74
-
75
-
76
-    /**
77
-     * @param string $editor_style_handle
78
-     */
79
-    public function setEditorStyleHandle($editor_style_handle)
80
-    {
81
-        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
82
-            $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
83
-        }
84
-        $this->editor_style_handle = $editor_style_handle;
85
-    }
86
-
87
-
88
-    /**
89
-     * @return string
90
-     */
91
-    public function getScriptHandle()
92
-    {
93
-        return $this->script_handle;
94
-    }
95
-
96
-
97
-    /**
98
-     * @param string $script_handle
99
-     */
100
-    public function setScriptHandle($script_handle)
101
-    {
102
-        if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
103
-            $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
104
-        }
105
-        $this->script_handle = $script_handle;
106
-    }
107
-
108
-
109
-    /**
110
-     * @return string
111
-     */
112
-    public function getStyleHandle()
113
-    {
114
-        return $this->style_handle;
115
-    }
116
-
117
-
118
-    /**
119
-     * @param string $style_handle
120
-     */
121
-    public function setStyleHandle($style_handle)
122
-    {
123
-        if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
124
-            $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
125
-        }
126
-        $this->style_handle = $style_handle;
127
-    }
128
-
129
-    /**
130
-     * @since $VID:$
131
-     * @throws InvalidDataTypeException
132
-     * @throws InvalidEntityException
133
-     * @throws DuplicateCollectionIdentifierException
134
-     */
135
-    public function addAssets()
136
-    {
137
-        $this->addEditorScript($this->getEditorScriptHandle());
138
-        $this->addEditorStyle($this->getEditorStyleHandle());
139
-        $this->addScript($this->getScriptHandle());
140
-        $this->addStyle($this->getStyleHandle());
141
-    }
142
-
143
-
144
-    /**
145
-     * @param       $handle
146
-     * @param array $dependencies
147
-     * @since $VID:$
148
-     * @return JavascriptAsset
149
-     * @throws InvalidDataTypeException
150
-     * @throws InvalidEntityException
151
-     * @throws DuplicateCollectionIdentifierException
152
-     */
153
-    public function addEditorScript($handle, array $dependencies = array())
154
-    {
155
-        if($this->assets->hasJavascriptAsset($handle)){
156
-            return $this->assets->getJavascriptAsset($handle);
157
-        }
158
-        return parent::addJavascript(
159
-            $handle,
160
-            $this->registry->getJsUrl(
161
-                $this->domain->assetNamespace(),
162
-                $handle
163
-            ),
164
-            $this->addDefaultBlockScriptDependencies($dependencies)
165
-        )
166
-        ->setRequiresTranslation();
167
-    }
168
-
169
-
170
-    /**
171
-     * @param        $handle
172
-     * @param array  $dependencies
173
-     * @since $VID:$
174
-     * @return StylesheetAsset
175
-     * @throws InvalidDataTypeException
176
-     * @throws InvalidEntityException
177
-     * @throws DuplicateCollectionIdentifierException
178
-     */
179
-    public function addEditorStyle($handle, array $dependencies = array())
180
-    {
181
-        if ($this->assets->hasStylesheetAsset($handle)) {
182
-            return $this->assets->getStylesheetAsset($handle);
183
-        }
184
-        return parent::addStylesheet(
185
-            $handle,
186
-            $this->registry->getCssUrl(
187
-                $this->domain->assetNamespace(),
188
-                $handle
189
-            ),
190
-            $this->addDefaultBlockStyleDependencies($dependencies)
191
-        );
192
-    }
193
-
194
-
195
-    /**
196
-     * @param       $handle
197
-     * @param array $dependencies
198
-     * @since $VID:$
199
-     * @return JavascriptAsset
200
-     * @throws InvalidDataTypeException
201
-     * @throws InvalidEntityException
202
-     * @throws DuplicateCollectionIdentifierException
203
-     */
204
-    public function addScript($handle, array $dependencies = array())
205
-    {
206
-        if ($this->assets->hasJavascriptAsset($handle)) {
207
-            return $this->assets->getJavascriptAsset($handle);
208
-        }
209
-        return parent::addJavascript(
210
-            $handle,
211
-            $this->registry->getJsUrl(
212
-                $this->domain->assetNamespace(),
213
-                $handle
214
-            ),
215
-            $dependencies + array( CoreAssetManager::JS_HANDLE_COMPONENTS )
216
-        )
217
-        ->setRequiresTranslation();
218
-    }
219
-
220
-
221
-    /**
222
-     * @param        $handle
223
-     * @param array  $dependencies
224
-     * @since $VID:$
225
-     * @return StylesheetAsset
226
-     * @throws InvalidDataTypeException
227
-     * @throws InvalidEntityException
228
-     * @throws DuplicateCollectionIdentifierException
229
-     */
230
-    public function addStyle($handle, array $dependencies = array())
231
-    {
232
-        if ($this->assets->hasStylesheetAsset($handle)) {
233
-            return $this->assets->getStylesheetAsset($handle);
234
-        }
235
-        return parent::addStylesheet(
236
-            $handle,
237
-            $this->registry->getCssUrl(
238
-                $this->domain->assetNamespace(),
239
-                $handle
240
-            ),
241
-            $dependencies + array( CoreAssetManager::CSS_HANDLE_COMPONENTS )
242
-        );
243
-    }
244
-
245
-
246
-    /**
247
-     * @param array $dependencies
248
-     * @return array
249
-     */
250
-    protected function addDefaultBlockScriptDependencies(array $dependencies)
251
-    {
252
-        $dependencies += array(
253
-                'wp-blocks',    // Provides useful functions and components for extending the editor
254
-                'wp-i18n',      // Provides localization functions
255
-                'wp-element',   // Provides React.Component
256
-                'wp-components', // Provides many prebuilt components and controls
257
-                CoreAssetManager::JS_HANDLE_EDITOR_HOCS,
258
-                $this->getScriptHandle(),
259
-            );
260
-        return $dependencies;
261
-    }
262
-
263
-
264
-    /**
265
-     * @param array $dependencies
266
-     * @return array
267
-     */
268
-    protected function addDefaultBlockStyleDependencies(array $dependencies)
269
-    {
270
-        $dependencies += array(
271
-            $this->getStyleHandle()
272
-        );
273
-        return $dependencies;
274
-    }
275
-
276
-
277
-    /**
278
-     * @return JavascriptAsset|null
279
-     */
280
-    public function getEditorScript()
281
-    {
282
-        return $this->assets->getJavascriptAsset($this->editor_script_handle);
283
-    }
284
-
285
-
286
-    /**
287
-     * @return StylesheetAsset|null
288
-     */
289
-    public function getEditorStyle()
290
-    {
291
-        return $this->assets->getStylesheetAsset($this->editor_style_handle);
292
-    }
293
-
294
-
295
-    /**
296
-     * @return JavascriptAsset|null
297
-     */
298
-    public function getScript()
299
-    {
300
-        return $this->assets->getJavascriptAsset($this->script_handle);
301
-    }
302
-
303
-
304
-    /**
305
-     * @return StylesheetAsset|null
306
-     */
307
-    public function getStyle()
308
-    {
309
-        return $this->assets->getStylesheetAsset($this->style_handle);
310
-    }
311
-
312
-
313
-    /**
314
-     * @return  void
315
-     */
316
-    public function enqueueAssets()
317
-    {
318
-        $assets = array(
319
-            $this->getEditorScript(),
320
-            $this->getEditorStyle(),
321
-            $this->getScript(),
322
-            $this->getStyle(),
323
-        );
324
-        foreach ($assets as $asset) {
325
-            if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
326
-                $asset->enqueueAsset();
327
-            }
328
-        }
329
-    }
25
+	/**
26
+	 * @var string $editor_script_handle
27
+	 */
28
+	private $editor_script_handle;
29
+
30
+	/**
31
+	 * @var string $editor_style_handle
32
+	 */
33
+	private $editor_style_handle;
34
+
35
+	/**
36
+	 * @var string $script_handle
37
+	 */
38
+	private $script_handle;
39
+
40
+	/**
41
+	 * @var string $style_handle
42
+	 */
43
+	private $style_handle;
44
+
45
+
46
+	/**
47
+	 * @return string
48
+	 */
49
+	public function getEditorScriptHandle()
50
+	{
51
+		return $this->editor_script_handle;
52
+	}
53
+
54
+
55
+	/**
56
+	 * @param string $editor_script_handle
57
+	 */
58
+	public function setEditorScriptHandle($editor_script_handle)
59
+	{
60
+		if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
61
+			$editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
62
+		}
63
+		$this->editor_script_handle = $editor_script_handle;
64
+	}
65
+
66
+
67
+	/**
68
+	 * @return string
69
+	 */
70
+	public function getEditorStyleHandle()
71
+	{
72
+		return $this->editor_style_handle;
73
+	}
74
+
75
+
76
+	/**
77
+	 * @param string $editor_style_handle
78
+	 */
79
+	public function setEditorStyleHandle($editor_style_handle)
80
+	{
81
+		if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
82
+			$editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
83
+		}
84
+		$this->editor_style_handle = $editor_style_handle;
85
+	}
86
+
87
+
88
+	/**
89
+	 * @return string
90
+	 */
91
+	public function getScriptHandle()
92
+	{
93
+		return $this->script_handle;
94
+	}
95
+
96
+
97
+	/**
98
+	 * @param string $script_handle
99
+	 */
100
+	public function setScriptHandle($script_handle)
101
+	{
102
+		if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
103
+			$script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
104
+		}
105
+		$this->script_handle = $script_handle;
106
+	}
107
+
108
+
109
+	/**
110
+	 * @return string
111
+	 */
112
+	public function getStyleHandle()
113
+	{
114
+		return $this->style_handle;
115
+	}
116
+
117
+
118
+	/**
119
+	 * @param string $style_handle
120
+	 */
121
+	public function setStyleHandle($style_handle)
122
+	{
123
+		if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
124
+			$style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
125
+		}
126
+		$this->style_handle = $style_handle;
127
+	}
128
+
129
+	/**
130
+	 * @since $VID:$
131
+	 * @throws InvalidDataTypeException
132
+	 * @throws InvalidEntityException
133
+	 * @throws DuplicateCollectionIdentifierException
134
+	 */
135
+	public function addAssets()
136
+	{
137
+		$this->addEditorScript($this->getEditorScriptHandle());
138
+		$this->addEditorStyle($this->getEditorStyleHandle());
139
+		$this->addScript($this->getScriptHandle());
140
+		$this->addStyle($this->getStyleHandle());
141
+	}
142
+
143
+
144
+	/**
145
+	 * @param       $handle
146
+	 * @param array $dependencies
147
+	 * @since $VID:$
148
+	 * @return JavascriptAsset
149
+	 * @throws InvalidDataTypeException
150
+	 * @throws InvalidEntityException
151
+	 * @throws DuplicateCollectionIdentifierException
152
+	 */
153
+	public function addEditorScript($handle, array $dependencies = array())
154
+	{
155
+		if($this->assets->hasJavascriptAsset($handle)){
156
+			return $this->assets->getJavascriptAsset($handle);
157
+		}
158
+		return parent::addJavascript(
159
+			$handle,
160
+			$this->registry->getJsUrl(
161
+				$this->domain->assetNamespace(),
162
+				$handle
163
+			),
164
+			$this->addDefaultBlockScriptDependencies($dependencies)
165
+		)
166
+		->setRequiresTranslation();
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param        $handle
172
+	 * @param array  $dependencies
173
+	 * @since $VID:$
174
+	 * @return StylesheetAsset
175
+	 * @throws InvalidDataTypeException
176
+	 * @throws InvalidEntityException
177
+	 * @throws DuplicateCollectionIdentifierException
178
+	 */
179
+	public function addEditorStyle($handle, array $dependencies = array())
180
+	{
181
+		if ($this->assets->hasStylesheetAsset($handle)) {
182
+			return $this->assets->getStylesheetAsset($handle);
183
+		}
184
+		return parent::addStylesheet(
185
+			$handle,
186
+			$this->registry->getCssUrl(
187
+				$this->domain->assetNamespace(),
188
+				$handle
189
+			),
190
+			$this->addDefaultBlockStyleDependencies($dependencies)
191
+		);
192
+	}
193
+
194
+
195
+	/**
196
+	 * @param       $handle
197
+	 * @param array $dependencies
198
+	 * @since $VID:$
199
+	 * @return JavascriptAsset
200
+	 * @throws InvalidDataTypeException
201
+	 * @throws InvalidEntityException
202
+	 * @throws DuplicateCollectionIdentifierException
203
+	 */
204
+	public function addScript($handle, array $dependencies = array())
205
+	{
206
+		if ($this->assets->hasJavascriptAsset($handle)) {
207
+			return $this->assets->getJavascriptAsset($handle);
208
+		}
209
+		return parent::addJavascript(
210
+			$handle,
211
+			$this->registry->getJsUrl(
212
+				$this->domain->assetNamespace(),
213
+				$handle
214
+			),
215
+			$dependencies + array( CoreAssetManager::JS_HANDLE_COMPONENTS )
216
+		)
217
+		->setRequiresTranslation();
218
+	}
219
+
220
+
221
+	/**
222
+	 * @param        $handle
223
+	 * @param array  $dependencies
224
+	 * @since $VID:$
225
+	 * @return StylesheetAsset
226
+	 * @throws InvalidDataTypeException
227
+	 * @throws InvalidEntityException
228
+	 * @throws DuplicateCollectionIdentifierException
229
+	 */
230
+	public function addStyle($handle, array $dependencies = array())
231
+	{
232
+		if ($this->assets->hasStylesheetAsset($handle)) {
233
+			return $this->assets->getStylesheetAsset($handle);
234
+		}
235
+		return parent::addStylesheet(
236
+			$handle,
237
+			$this->registry->getCssUrl(
238
+				$this->domain->assetNamespace(),
239
+				$handle
240
+			),
241
+			$dependencies + array( CoreAssetManager::CSS_HANDLE_COMPONENTS )
242
+		);
243
+	}
244
+
245
+
246
+	/**
247
+	 * @param array $dependencies
248
+	 * @return array
249
+	 */
250
+	protected function addDefaultBlockScriptDependencies(array $dependencies)
251
+	{
252
+		$dependencies += array(
253
+				'wp-blocks',    // Provides useful functions and components for extending the editor
254
+				'wp-i18n',      // Provides localization functions
255
+				'wp-element',   // Provides React.Component
256
+				'wp-components', // Provides many prebuilt components and controls
257
+				CoreAssetManager::JS_HANDLE_EDITOR_HOCS,
258
+				$this->getScriptHandle(),
259
+			);
260
+		return $dependencies;
261
+	}
262
+
263
+
264
+	/**
265
+	 * @param array $dependencies
266
+	 * @return array
267
+	 */
268
+	protected function addDefaultBlockStyleDependencies(array $dependencies)
269
+	{
270
+		$dependencies += array(
271
+			$this->getStyleHandle()
272
+		);
273
+		return $dependencies;
274
+	}
275
+
276
+
277
+	/**
278
+	 * @return JavascriptAsset|null
279
+	 */
280
+	public function getEditorScript()
281
+	{
282
+		return $this->assets->getJavascriptAsset($this->editor_script_handle);
283
+	}
284
+
285
+
286
+	/**
287
+	 * @return StylesheetAsset|null
288
+	 */
289
+	public function getEditorStyle()
290
+	{
291
+		return $this->assets->getStylesheetAsset($this->editor_style_handle);
292
+	}
293
+
294
+
295
+	/**
296
+	 * @return JavascriptAsset|null
297
+	 */
298
+	public function getScript()
299
+	{
300
+		return $this->assets->getJavascriptAsset($this->script_handle);
301
+	}
302
+
303
+
304
+	/**
305
+	 * @return StylesheetAsset|null
306
+	 */
307
+	public function getStyle()
308
+	{
309
+		return $this->assets->getStylesheetAsset($this->style_handle);
310
+	}
311
+
312
+
313
+	/**
314
+	 * @return  void
315
+	 */
316
+	public function enqueueAssets()
317
+	{
318
+		$assets = array(
319
+			$this->getEditorScript(),
320
+			$this->getEditorStyle(),
321
+			$this->getScript(),
322
+			$this->getStyle(),
323
+		);
324
+		foreach ($assets as $asset) {
325
+			if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
326
+				$asset->enqueueAsset();
327
+			}
328
+		}
329
+	}
330 330
 
331 331
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function setEditorScriptHandle($editor_script_handle)
59 59
     {
60
-        if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
61
-            $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
60
+        if (strpos($editor_script_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
61
+            $editor_script_handle = BlockInterface::NAME_SPACE.'-'.$editor_script_handle;
62 62
         }
63 63
         $this->editor_script_handle = $editor_script_handle;
64 64
     }
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function setEditorStyleHandle($editor_style_handle)
80 80
     {
81
-        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
82
-            $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
81
+        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
82
+            $editor_style_handle = BlockInterface::NAME_SPACE.'-'.$editor_style_handle;
83 83
         }
84 84
         $this->editor_style_handle = $editor_style_handle;
85 85
     }
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function setScriptHandle($script_handle)
101 101
     {
102
-        if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
103
-            $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
102
+        if (strpos($script_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
103
+            $script_handle = BlockInterface::NAME_SPACE.'-'.$script_handle;
104 104
         }
105 105
         $this->script_handle = $script_handle;
106 106
     }
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function setStyleHandle($style_handle)
122 122
     {
123
-        if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
124
-            $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
123
+        if (strpos($style_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
124
+            $style_handle = BlockInterface::NAME_SPACE.'-'.$style_handle;
125 125
         }
126 126
         $this->style_handle = $style_handle;
127 127
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public function addEditorScript($handle, array $dependencies = array())
154 154
     {
155
-        if($this->assets->hasJavascriptAsset($handle)){
155
+        if ($this->assets->hasJavascriptAsset($handle)) {
156 156
             return $this->assets->getJavascriptAsset($handle);
157 157
         }
158 158
         return parent::addJavascript(
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
                 $this->domain->assetNamespace(),
213 213
                 $handle
214 214
             ),
215
-            $dependencies + array( CoreAssetManager::JS_HANDLE_COMPONENTS )
215
+            $dependencies + array(CoreAssetManager::JS_HANDLE_COMPONENTS)
216 216
         )
217 217
         ->setRequiresTranslation();
218 218
     }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
                 $this->domain->assetNamespace(),
239 239
                 $handle
240 240
             ),
241
-            $dependencies + array( CoreAssetManager::CSS_HANDLE_COMPONENTS )
241
+            $dependencies + array(CoreAssetManager::CSS_HANDLE_COMPONENTS)
242 242
         );
243 243
     }
244 244
 
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
     protected function addDefaultBlockScriptDependencies(array $dependencies)
251 251
     {
252 252
         $dependencies += array(
253
-                'wp-blocks',    // Provides useful functions and components for extending the editor
254
-                'wp-i18n',      // Provides localization functions
255
-                'wp-element',   // Provides React.Component
253
+                'wp-blocks', // Provides useful functions and components for extending the editor
254
+                'wp-i18n', // Provides localization functions
255
+                'wp-element', // Provides React.Component
256 256
                 'wp-components', // Provides many prebuilt components and controls
257 257
                 CoreAssetManager::JS_HANDLE_EDITOR_HOCS,
258 258
                 $this->getScriptHandle(),
Please login to merge, or discard this patch.
core/domain/entities/editor/blocks/EventAttendees.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         EventAttendeesBlockRenderer $renderer
43 43
     ) {
44 44
         parent::__construct($block_asset_manager, $request);
45
-        $this->renderer= $renderer;
45
+        $this->renderer = $renderer;
46 46
     }
47 47
 
48 48
 
@@ -154,19 +154,19 @@  discard block
 block discarded – undo
154 154
         $sanitized_attributes = array();
155 155
         foreach ($attributes as $attribute => $value) {
156 156
             $convert = $this->getAttributesMap();
157
-            if (isset($convert[ $attribute ])) {
158
-                $sanitize = $convert[ $attribute ];
157
+            if (isset($convert[$attribute])) {
158
+                $sanitize = $convert[$attribute];
159 159
                 if ($sanitize === 'bool') {
160
-                    $sanitized_attributes[ $attribute ] = filter_var(
160
+                    $sanitized_attributes[$attribute] = filter_var(
161 161
                         $value,
162 162
                         FILTER_VALIDATE_BOOLEAN
163 163
                     );
164 164
                 } else {
165
-                    $sanitized_attributes[ $attribute ] = $sanitize($value);
165
+                    $sanitized_attributes[$attribute] = $sanitize($value);
166 166
                 }
167 167
                 // don't pass along attributes with a 0 value
168
-                if ($sanitized_attributes[ $attribute ] === 0) {
169
-                    unset($sanitized_attributes[ $attribute ]);
168
+                if ($sanitized_attributes[$attribute] === 0) {
169
+                    unset($sanitized_attributes[$attribute]);
170 170
                 }
171 171
             }
172 172
         }
Please login to merge, or discard this patch.
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -21,172 +21,172 @@
 block discarded – undo
21 21
 class EventAttendees extends Block
22 22
 {
23 23
 
24
-    const BLOCK_TYPE = 'event-attendees';
24
+	const BLOCK_TYPE = 'event-attendees';
25 25
 
26
-    /**
27
-     * @var EventAttendeesBlockRenderer $renderer
28
-     */
29
-    protected $renderer;
26
+	/**
27
+	 * @var EventAttendeesBlockRenderer $renderer
28
+	 */
29
+	protected $renderer;
30 30
 
31 31
 
32
-    /**
33
-     * EventAttendees constructor.
34
-     *
35
-     * @param CoreBlocksAssetManager      $block_asset_manager
36
-     * @param RequestInterface            $request
37
-     * @param EventAttendeesBlockRenderer $renderer
38
-     */
39
-    public function __construct(
40
-        CoreBlocksAssetManager $block_asset_manager,
41
-        RequestInterface $request,
42
-        EventAttendeesBlockRenderer $renderer
43
-    ) {
44
-        parent::__construct($block_asset_manager, $request);
45
-        $this->renderer= $renderer;
46
-    }
32
+	/**
33
+	 * EventAttendees constructor.
34
+	 *
35
+	 * @param CoreBlocksAssetManager      $block_asset_manager
36
+	 * @param RequestInterface            $request
37
+	 * @param EventAttendeesBlockRenderer $renderer
38
+	 */
39
+	public function __construct(
40
+		CoreBlocksAssetManager $block_asset_manager,
41
+		RequestInterface $request,
42
+		EventAttendeesBlockRenderer $renderer
43
+	) {
44
+		parent::__construct($block_asset_manager, $request);
45
+		$this->renderer= $renderer;
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * Perform any early setup required by the block
51
-     * including setting the block type and supported post types
52
-     *
53
-     * @return void
54
-     */
55
-    public function initialize()
56
-    {
57
-        $this->setBlockType(self::BLOCK_TYPE);
58
-        $this->setSupportedRoutes(
59
-            array(
60
-                'EventEspresso\core\domain\entities\route_match\specifications\admin\EspressoStandardPostTypeEditor',
61
-                'EventEspresso\core\domain\entities\route_match\specifications\admin\WordPressPostTypeEditor',
62
-                'EventEspresso\core\domain\entities\route_match\specifications\frontend\EspressoBlockRenderer',
63
-                'EventEspresso\core\domain\entities\route_match\specifications\frontend\AnyFrontendRequest'
64
-            )
65
-        );
66
-        $EVT_ID = $this->request->getRequestParam('page') === 'espresso_events'
67
-            ? $this->request->getRequestParam('post', 0)
68
-            : 0;
69
-        $this->setAttributes(
70
-            array(
71
-                'eventId'           => array(
72
-                    'type'    => 'number',
73
-                    'default' => $EVT_ID,
74
-                ),
75
-                'datetimeId'        => array(
76
-                    'type'    => 'number',
77
-                    'default' => 0,
78
-                ),
79
-                'ticketId'          => array(
80
-                    'type'    => 'number',
81
-                    'default' => 0,
82
-                ),
83
-                'status'            => array(
84
-                    'type'    => 'string',
85
-                    'default' => EEM_Registration::status_id_approved,
86
-                ),
87
-                'limit'             => array(
88
-                    'type'    => 'number',
89
-                    'default' => 10,
90
-                ),
91
-                'order' => array(
92
-                    'type' => 'string',
93
-                    'default' => 'ASC'
94
-                ),
95
-                'orderBy' => array(
96
-                    'type' => 'string',
97
-                    'default' => 'lastThenFirstName',
98
-                ),
99
-                'showGravatar'      => array(
100
-                    'type'    => 'boolean',
101
-                    'default' => false,
102
-                ),
103
-                'avatarClass' => array(
104
-                    'type' => 'string',
105
-                    'default' => 'contact',
106
-                ),
107
-                'avatarSize' => array(
108
-                    'type' => 'number',
109
-                    'default' => 24,
110
-                ),
111
-                'displayOnArchives' => array(
112
-                    'type'    => 'boolean',
113
-                    'default' => false,
114
-                ),
115
-            )
116
-        );
117
-        $this->setDynamic();
118
-    }
49
+	/**
50
+	 * Perform any early setup required by the block
51
+	 * including setting the block type and supported post types
52
+	 *
53
+	 * @return void
54
+	 */
55
+	public function initialize()
56
+	{
57
+		$this->setBlockType(self::BLOCK_TYPE);
58
+		$this->setSupportedRoutes(
59
+			array(
60
+				'EventEspresso\core\domain\entities\route_match\specifications\admin\EspressoStandardPostTypeEditor',
61
+				'EventEspresso\core\domain\entities\route_match\specifications\admin\WordPressPostTypeEditor',
62
+				'EventEspresso\core\domain\entities\route_match\specifications\frontend\EspressoBlockRenderer',
63
+				'EventEspresso\core\domain\entities\route_match\specifications\frontend\AnyFrontendRequest'
64
+			)
65
+		);
66
+		$EVT_ID = $this->request->getRequestParam('page') === 'espresso_events'
67
+			? $this->request->getRequestParam('post', 0)
68
+			: 0;
69
+		$this->setAttributes(
70
+			array(
71
+				'eventId'           => array(
72
+					'type'    => 'number',
73
+					'default' => $EVT_ID,
74
+				),
75
+				'datetimeId'        => array(
76
+					'type'    => 'number',
77
+					'default' => 0,
78
+				),
79
+				'ticketId'          => array(
80
+					'type'    => 'number',
81
+					'default' => 0,
82
+				),
83
+				'status'            => array(
84
+					'type'    => 'string',
85
+					'default' => EEM_Registration::status_id_approved,
86
+				),
87
+				'limit'             => array(
88
+					'type'    => 'number',
89
+					'default' => 10,
90
+				),
91
+				'order' => array(
92
+					'type' => 'string',
93
+					'default' => 'ASC'
94
+				),
95
+				'orderBy' => array(
96
+					'type' => 'string',
97
+					'default' => 'lastThenFirstName',
98
+				),
99
+				'showGravatar'      => array(
100
+					'type'    => 'boolean',
101
+					'default' => false,
102
+				),
103
+				'avatarClass' => array(
104
+					'type' => 'string',
105
+					'default' => 'contact',
106
+				),
107
+				'avatarSize' => array(
108
+					'type' => 'number',
109
+					'default' => 24,
110
+				),
111
+				'displayOnArchives' => array(
112
+					'type'    => 'boolean',
113
+					'default' => false,
114
+				),
115
+			)
116
+		);
117
+		$this->setDynamic();
118
+	}
119 119
 
120 120
 
121
-    /**
122
-     * Returns an array where the key corresponds to the incoming attribute name from the WP block
123
-     * and the value corresponds to the attribute name for the existing EspressoEventAttendees shortcode
124
-     *
125
-     * @since $VID:$
126
-     * @return array
127
-     */
128
-    private function getAttributesMap()
129
-    {
130
-        return array(
131
-            'eventId'           => 'absint',
132
-            'datetimeId'        => 'absint',
133
-            'ticketId'          => 'absint',
134
-            'status'            => 'sanitize_text_field',
135
-            'limit'             => 'intval',
136
-            'showGravatar'      => 'bool',
137
-            'avatarClass'       => 'sanitize_text_field',
138
-            'avatarSize'        => 'absint',
139
-            'displayOnArchives' => 'bool',
140
-            'order' => 'sanitize_text_field',
141
-            'orderBy' => 'sanitize_text_field',
142
-        );
143
-    }
121
+	/**
122
+	 * Returns an array where the key corresponds to the incoming attribute name from the WP block
123
+	 * and the value corresponds to the attribute name for the existing EspressoEventAttendees shortcode
124
+	 *
125
+	 * @since $VID:$
126
+	 * @return array
127
+	 */
128
+	private function getAttributesMap()
129
+	{
130
+		return array(
131
+			'eventId'           => 'absint',
132
+			'datetimeId'        => 'absint',
133
+			'ticketId'          => 'absint',
134
+			'status'            => 'sanitize_text_field',
135
+			'limit'             => 'intval',
136
+			'showGravatar'      => 'bool',
137
+			'avatarClass'       => 'sanitize_text_field',
138
+			'avatarSize'        => 'absint',
139
+			'displayOnArchives' => 'bool',
140
+			'order' => 'sanitize_text_field',
141
+			'orderBy' => 'sanitize_text_field',
142
+		);
143
+	}
144 144
 
145 145
 
146
-    /**
147
-     * Sanitizes attributes.
148
-     *
149
-     * @param array $attributes
150
-     * @return array
151
-     */
152
-    private function sanitizeAttributes(array $attributes)
153
-    {
154
-        $sanitized_attributes = array();
155
-        foreach ($attributes as $attribute => $value) {
156
-            $convert = $this->getAttributesMap();
157
-            if (isset($convert[ $attribute ])) {
158
-                $sanitize = $convert[ $attribute ];
159
-                if ($sanitize === 'bool') {
160
-                    $sanitized_attributes[ $attribute ] = filter_var(
161
-                        $value,
162
-                        FILTER_VALIDATE_BOOLEAN
163
-                    );
164
-                } else {
165
-                    $sanitized_attributes[ $attribute ] = $sanitize($value);
166
-                }
167
-                // don't pass along attributes with a 0 value
168
-                if ($sanitized_attributes[ $attribute ] === 0) {
169
-                    unset($sanitized_attributes[ $attribute ]);
170
-                }
171
-            }
172
-        }
173
-        return $attributes;
174
-    }
146
+	/**
147
+	 * Sanitizes attributes.
148
+	 *
149
+	 * @param array $attributes
150
+	 * @return array
151
+	 */
152
+	private function sanitizeAttributes(array $attributes)
153
+	{
154
+		$sanitized_attributes = array();
155
+		foreach ($attributes as $attribute => $value) {
156
+			$convert = $this->getAttributesMap();
157
+			if (isset($convert[ $attribute ])) {
158
+				$sanitize = $convert[ $attribute ];
159
+				if ($sanitize === 'bool') {
160
+					$sanitized_attributes[ $attribute ] = filter_var(
161
+						$value,
162
+						FILTER_VALIDATE_BOOLEAN
163
+					);
164
+				} else {
165
+					$sanitized_attributes[ $attribute ] = $sanitize($value);
166
+				}
167
+				// don't pass along attributes with a 0 value
168
+				if ($sanitized_attributes[ $attribute ] === 0) {
169
+					unset($sanitized_attributes[ $attribute ]);
170
+				}
171
+			}
172
+		}
173
+		return $attributes;
174
+	}
175 175
 
176 176
 
177
-    /**
178
-     * Returns the rendered HTML for the block
179
-     *
180
-     * @param array $attributes
181
-     * @return string
182
-     * @throws DomainException
183
-     * @throws EE_Error
184
-     */
185
-    public function renderBlock(array $attributes = array())
186
-    {
187
-        $attributes = $this->sanitizeAttributes($attributes);
188
-        return (is_archive() || is_front_page() || is_home()) && ! $attributes['displayOnArchives']
189
-            ? ''
190
-            : $this->renderer->render($attributes);
191
-    }
177
+	/**
178
+	 * Returns the rendered HTML for the block
179
+	 *
180
+	 * @param array $attributes
181
+	 * @return string
182
+	 * @throws DomainException
183
+	 * @throws EE_Error
184
+	 */
185
+	public function renderBlock(array $attributes = array())
186
+	{
187
+		$attributes = $this->sanitizeAttributes($attributes);
188
+		return (is_archive() || is_front_page() || is_home()) && ! $attributes['displayOnArchives']
189
+			? ''
190
+			: $this->renderer->render($attributes);
191
+	}
192 192
 }
Please login to merge, or discard this patch.
core/domain/services/blocks/EventAttendeesBlockRenderer.php 2 patches
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -20,104 +20,104 @@
 block discarded – undo
20 20
 class EventAttendeesBlockRenderer extends BlockRenderer
21 21
 {
22 22
 
23
-    /**
24
-     * @var EEM_Attendee
25
-     */
26
-    private $attendee_model;
23
+	/**
24
+	 * @var EEM_Attendee
25
+	 */
26
+	private $attendee_model;
27 27
 
28
-    public function __construct(DomainInterface $domain, EEM_Attendee $attendee_model)
29
-    {
30
-        $this->attendee_model = $attendee_model;
31
-        parent::__construct($domain);
32
-    }
28
+	public function __construct(DomainInterface $domain, EEM_Attendee $attendee_model)
29
+	{
30
+		$this->attendee_model = $attendee_model;
31
+		parent::__construct($domain);
32
+	}
33 33
 
34 34
 
35
-    /**
36
-     * Renders the block.
37
-     *
38
-     * @param array $attributes  Expect already validated and sanitized array of attributes for use in generating the
39
-     *                           query and the template output.
40
-     * @return string
41
-     * @throws DomainException
42
-     * @throws EE_Error
43
-     */
44
-    public function render(array $attributes)
45
-    {
46
-        $template_args['attributes'] = $attributes;
47
-        $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes));
48
-        return EEH_Template::display_template(
49
-            $this->templateRootPath() . 'event-attendees.php',
50
-            $template_args,
51
-            true
52
-        );
53
-    }
35
+	/**
36
+	 * Renders the block.
37
+	 *
38
+	 * @param array $attributes  Expect already validated and sanitized array of attributes for use in generating the
39
+	 *                           query and the template output.
40
+	 * @return string
41
+	 * @throws DomainException
42
+	 * @throws EE_Error
43
+	 */
44
+	public function render(array $attributes)
45
+	{
46
+		$template_args['attributes'] = $attributes;
47
+		$template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes));
48
+		return EEH_Template::display_template(
49
+			$this->templateRootPath() . 'event-attendees.php',
50
+			$template_args,
51
+			true
52
+		);
53
+	}
54 54
 
55 55
 
56
-    /**
57
-     * Get query parameters for model query.
58
-     *
59
-     * @param array $attributes
60
-     * @return array
61
-     */
62
-    private function getQueryParams(array $attributes)
63
-    {
64
-        return array(
65
-            0 => $this->getWhereQueryPart($attributes),
66
-            'default_where_conditions' => 'this_model_only',
67
-            'limit' => $attributes['limit'],
68
-            'group_by' => array('ATT_ID'),
69
-            'order_by' => $this->getOrderByQueryPart($attributes)
70
-        );
71
-    }
56
+	/**
57
+	 * Get query parameters for model query.
58
+	 *
59
+	 * @param array $attributes
60
+	 * @return array
61
+	 */
62
+	private function getQueryParams(array $attributes)
63
+	{
64
+		return array(
65
+			0 => $this->getWhereQueryPart($attributes),
66
+			'default_where_conditions' => 'this_model_only',
67
+			'limit' => $attributes['limit'],
68
+			'group_by' => array('ATT_ID'),
69
+			'order_by' => $this->getOrderByQueryPart($attributes)
70
+		);
71
+	}
72 72
 
73 73
 
74
-    /**
75
-     * Get where query part for query parameters for model query.
76
-     *
77
-     * @param array $attributes
78
-     * @return array
79
-     */
80
-    private function getWhereQueryPart(array $attributes)
81
-    {
82
-        $where = array();
83
-        if ($attributes['ticketId'] > 0) {
84
-            $where['Registration.TKT_ID'] = $attributes['ticketId'];
85
-        } elseif ($attributes['datetimeId'] > 0) {
86
-            $where['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetimeId'];
87
-        } else {
88
-            $where['Registration.EVT_ID'] = $attributes['eventId'];
89
-        }
90
-        $where['Registration.STS_ID'] = $attributes['status'];
91
-        return $where;
92
-    }
74
+	/**
75
+	 * Get where query part for query parameters for model query.
76
+	 *
77
+	 * @param array $attributes
78
+	 * @return array
79
+	 */
80
+	private function getWhereQueryPart(array $attributes)
81
+	{
82
+		$where = array();
83
+		if ($attributes['ticketId'] > 0) {
84
+			$where['Registration.TKT_ID'] = $attributes['ticketId'];
85
+		} elseif ($attributes['datetimeId'] > 0) {
86
+			$where['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetimeId'];
87
+		} else {
88
+			$where['Registration.EVT_ID'] = $attributes['eventId'];
89
+		}
90
+		$where['Registration.STS_ID'] = $attributes['status'];
91
+		return $where;
92
+	}
93 93
 
94 94
 
95
-    /**
96
-     * Get order by query part for query parameters for model query.
97
-     *
98
-     * @param array $attributes
99
-     * @return array
100
-     */
101
-    private function getOrderByQueryPart(array $attributes)
102
-    {
103
-        $order = $attributes['order'];
104
-        switch ($attributes['orderBy']) {
105
-            case 'id':
106
-                $order_by = array('ATT_ID' => $order);
107
-                break;
108
-            case 'lastNameOnly':
109
-                $order_by = array('ATT_lname' => $order);
110
-                break;
111
-            case 'firstNameOnly':
112
-                $order_by = array('ATT_fname' => $order);
113
-                break;
114
-            case 'firstThenLastName':
115
-                $order_by = array('ATT_fname' => $order, 'ATT_lname' => $order);
116
-                break;
117
-            default:
118
-                $order_by = array('ATT_lname' => $order, 'ATT_fname' => $order);
119
-                break;
120
-        }
121
-        return $order_by;
122
-    }
95
+	/**
96
+	 * Get order by query part for query parameters for model query.
97
+	 *
98
+	 * @param array $attributes
99
+	 * @return array
100
+	 */
101
+	private function getOrderByQueryPart(array $attributes)
102
+	{
103
+		$order = $attributes['order'];
104
+		switch ($attributes['orderBy']) {
105
+			case 'id':
106
+				$order_by = array('ATT_ID' => $order);
107
+				break;
108
+			case 'lastNameOnly':
109
+				$order_by = array('ATT_lname' => $order);
110
+				break;
111
+			case 'firstNameOnly':
112
+				$order_by = array('ATT_fname' => $order);
113
+				break;
114
+			case 'firstThenLastName':
115
+				$order_by = array('ATT_fname' => $order, 'ATT_lname' => $order);
116
+				break;
117
+			default:
118
+				$order_by = array('ATT_lname' => $order, 'ATT_fname' => $order);
119
+				break;
120
+		}
121
+		return $order_by;
122
+	}
123 123
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
         $template_args['attributes'] = $attributes;
47 47
         $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes));
48 48
         return EEH_Template::display_template(
49
-            $this->templateRootPath() . 'event-attendees.php',
49
+            $this->templateRootPath().'event-attendees.php',
50 50
             $template_args,
51 51
             true
52 52
         );
Please login to merge, or discard this patch.