@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | * |
749 | 749 | * @access public |
750 | 750 | * @param string $CNT_ISO |
751 | - * @return mixed string | array |
|
751 | + * @return string|null string | array |
|
752 | 752 | * @throws DomainException |
753 | 753 | */ |
754 | 754 | public function display_country_settings($CNT_ISO = '') |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | * delete_state |
1065 | 1065 | * |
1066 | 1066 | * @access public |
1067 | - * @return boolean |
|
1067 | + * @return false|null |
|
1068 | 1068 | */ |
1069 | 1069 | public function delete_state() |
1070 | 1070 | { |
@@ -17,1386 +17,1386 @@ |
||
17 | 17 | { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * _question_group |
|
22 | - * holds the specific question group object for the question group details screen |
|
23 | - * |
|
24 | - * @var object |
|
25 | - */ |
|
26 | - protected $_question_group; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * Initialize basic properties. |
|
31 | - */ |
|
32 | - protected function _init_page_props() |
|
33 | - { |
|
34 | - $this->page_slug = GEN_SET_PG_SLUG; |
|
35 | - $this->page_label = GEN_SET_LABEL; |
|
36 | - $this->_admin_base_url = GEN_SET_ADMIN_URL; |
|
37 | - $this->_admin_base_path = GEN_SET_ADMIN; |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Set ajax hooks |
|
43 | - */ |
|
44 | - protected function _ajax_hooks() |
|
45 | - { |
|
46 | - add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings')); |
|
47 | - add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states')); |
|
48 | - add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3); |
|
49 | - add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state')); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * More page properties initialization. |
|
55 | - */ |
|
56 | - protected function _define_page_props() |
|
57 | - { |
|
58 | - $this->_admin_page_title = GEN_SET_LABEL; |
|
59 | - $this->_labels = array( |
|
60 | - 'publishbox' => __('Update Settings', 'event_espresso'), |
|
61 | - ); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * Set page routes property. |
|
67 | - */ |
|
68 | - protected function _set_page_routes() |
|
69 | - { |
|
70 | - $this->_page_routes = array( |
|
71 | - |
|
72 | - 'critical_pages' => array( |
|
73 | - 'func' => '_espresso_page_settings', |
|
74 | - 'capability' => 'manage_options', |
|
75 | - ), |
|
76 | - 'update_espresso_page_settings' => array( |
|
77 | - 'func' => '_update_espresso_page_settings', |
|
78 | - 'capability' => 'manage_options', |
|
79 | - 'noheader' => true, |
|
80 | - ), |
|
81 | - 'default' => array( |
|
82 | - 'func' => '_your_organization_settings', |
|
83 | - 'capability' => 'manage_options', |
|
84 | - ), |
|
85 | - |
|
86 | - 'update_your_organization_settings' => array( |
|
87 | - 'func' => '_update_your_organization_settings', |
|
88 | - 'capability' => 'manage_options', |
|
89 | - 'noheader' => true, |
|
90 | - ), |
|
91 | - |
|
92 | - 'admin_option_settings' => array( |
|
93 | - 'func' => '_admin_option_settings', |
|
94 | - 'capability' => 'manage_options', |
|
95 | - ), |
|
96 | - |
|
97 | - 'update_admin_option_settings' => array( |
|
98 | - 'func' => '_update_admin_option_settings', |
|
99 | - 'capability' => 'manage_options', |
|
100 | - 'noheader' => true, |
|
101 | - ), |
|
102 | - |
|
103 | - 'country_settings' => array( |
|
104 | - 'func' => '_country_settings', |
|
105 | - 'capability' => 'manage_options', |
|
106 | - ), |
|
107 | - |
|
108 | - 'update_country_settings' => array( |
|
109 | - 'func' => '_update_country_settings', |
|
110 | - 'capability' => 'manage_options', |
|
111 | - 'noheader' => true, |
|
112 | - ), |
|
113 | - |
|
114 | - 'display_country_settings' => array( |
|
115 | - 'func' => 'display_country_settings', |
|
116 | - 'capability' => 'manage_options', |
|
117 | - 'noheader' => true, |
|
118 | - ), |
|
119 | - |
|
120 | - 'add_new_state' => array( |
|
121 | - 'func' => 'add_new_state', |
|
122 | - 'capability' => 'manage_options', |
|
123 | - 'noheader' => true, |
|
124 | - ), |
|
125 | - |
|
126 | - 'delete_state' => array( |
|
127 | - 'func' => 'delete_state', |
|
128 | - 'capability' => 'manage_options', |
|
129 | - 'noheader' => true, |
|
130 | - ), |
|
131 | - ); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * Set page configuration property |
|
137 | - */ |
|
138 | - protected function _set_page_config() |
|
139 | - { |
|
140 | - $this->_page_config = array( |
|
141 | - 'critical_pages' => array( |
|
142 | - 'nav' => array( |
|
143 | - 'label' => __('Critical Pages', 'event_espresso'), |
|
144 | - 'order' => 50, |
|
145 | - ), |
|
146 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
147 | - 'help_tabs' => array( |
|
148 | - 'general_settings_critical_pages_help_tab' => array( |
|
149 | - 'title' => __('Critical Pages', 'event_espresso'), |
|
150 | - 'filename' => 'general_settings_critical_pages', |
|
151 | - ), |
|
152 | - ), |
|
153 | - 'help_tour' => array('Critical_Pages_Help_Tour'), |
|
154 | - 'require_nonce' => false, |
|
155 | - ), |
|
156 | - 'default' => array( |
|
157 | - 'nav' => array( |
|
158 | - 'label' => __('Your Organization', 'event_espresso'), |
|
159 | - 'order' => 20, |
|
160 | - ), |
|
161 | - 'help_tabs' => array( |
|
162 | - 'general_settings_your_organization_help_tab' => array( |
|
163 | - 'title' => __('Your Organization', 'event_espresso'), |
|
164 | - 'filename' => 'general_settings_your_organization', |
|
165 | - ), |
|
166 | - ), |
|
167 | - 'help_tour' => array('Your_Organization_Help_Tour'), |
|
168 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
169 | - 'require_nonce' => false, |
|
170 | - ), |
|
171 | - 'admin_option_settings' => array( |
|
172 | - 'nav' => array( |
|
173 | - 'label' => __('Admin Options', 'event_espresso'), |
|
174 | - 'order' => 60, |
|
175 | - ), |
|
176 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
177 | - 'help_tabs' => array( |
|
178 | - 'general_settings_admin_options_help_tab' => array( |
|
179 | - 'title' => __('Admin Options', 'event_espresso'), |
|
180 | - 'filename' => 'general_settings_admin_options', |
|
181 | - ), |
|
182 | - ), |
|
183 | - 'help_tour' => array('Admin_Options_Help_Tour'), |
|
184 | - 'require_nonce' => false, |
|
185 | - ), |
|
186 | - 'country_settings' => array( |
|
187 | - 'nav' => array( |
|
188 | - 'label' => __('Countries', 'event_espresso'), |
|
189 | - 'order' => 70, |
|
190 | - ), |
|
191 | - 'help_tabs' => array( |
|
192 | - 'general_settings_countries_help_tab' => array( |
|
193 | - 'title' => __('Countries', 'event_espresso'), |
|
194 | - 'filename' => 'general_settings_countries', |
|
195 | - ), |
|
196 | - ), |
|
197 | - 'help_tour' => array('Countries_Help_Tour'), |
|
198 | - 'require_nonce' => false, |
|
199 | - ), |
|
200 | - ); |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - |
|
205 | - protected function _add_screen_options() |
|
206 | - { |
|
207 | - } |
|
208 | - |
|
209 | - protected function _add_feature_pointers() |
|
210 | - { |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * Enqueue global scripts and styles for all routes in the General Settings Admin Pages. |
|
216 | - */ |
|
217 | - public function load_scripts_styles() |
|
218 | - { |
|
219 | - //styles |
|
220 | - wp_enqueue_style('espresso-ui-theme'); |
|
221 | - //scripts |
|
222 | - wp_enqueue_script('ee_admin_js'); |
|
223 | - } |
|
224 | - |
|
225 | - |
|
226 | - /** |
|
227 | - * Execute logic running on `admin_init` |
|
228 | - */ |
|
229 | - public function admin_init() |
|
230 | - { |
|
231 | - EE_Registry::$i18n_js_strings['invalid_server_response'] = __( |
|
232 | - 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
233 | - 'event_espresso' |
|
234 | - ); |
|
235 | - EE_Registry::$i18n_js_strings['error_occurred'] = __( |
|
236 | - 'An error occurred! Please refresh the page and try again.', |
|
237 | - 'event_espresso' |
|
238 | - ); |
|
239 | - EE_Registry::$i18n_js_strings['confirm_delete_state'] = __( |
|
240 | - 'Are you sure you want to delete this State / Province?', |
|
241 | - 'event_espresso' |
|
242 | - ); |
|
243 | - $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
244 | - EE_Registry::$i18n_js_strings['ajax_url'] = admin_url( |
|
245 | - 'admin-ajax.php?page=espresso_general_settings', |
|
246 | - $protocol |
|
247 | - ); |
|
248 | - } |
|
249 | - |
|
250 | - public function admin_notices() |
|
251 | - { |
|
252 | - } |
|
253 | - |
|
254 | - public function admin_footer_scripts() |
|
255 | - { |
|
256 | - } |
|
257 | - |
|
258 | - |
|
259 | - /** |
|
260 | - * Enqueue scripts and styles for the default route. |
|
261 | - */ |
|
262 | - public function load_scripts_styles_default() |
|
263 | - { |
|
264 | - //styles |
|
265 | - wp_enqueue_style('thickbox'); |
|
266 | - //scripts |
|
267 | - wp_enqueue_script('media-upload'); |
|
268 | - wp_enqueue_script('thickbox'); |
|
269 | - wp_register_script( |
|
270 | - 'organization_settings', |
|
271 | - GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
272 | - array('jquery', 'media-upload', 'thickbox'), |
|
273 | - EVENT_ESPRESSO_VERSION, |
|
274 | - true |
|
275 | - ); |
|
276 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
277 | - wp_enqueue_script('organization_settings'); |
|
278 | - wp_enqueue_style('organization-css'); |
|
279 | - $confirm_image_delete = array( |
|
280 | - 'text' => __( |
|
281 | - 'Do you really want to delete this image? Please remember to save your settings to complete the removal.', |
|
282 | - 'event_espresso' |
|
283 | - ), |
|
284 | - ); |
|
285 | - wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete); |
|
286 | - } |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * Enqueue scripts and styles for the country settings route. |
|
291 | - */ |
|
292 | - public function load_scripts_styles_country_settings() |
|
293 | - { |
|
294 | - //scripts |
|
295 | - wp_register_script( |
|
296 | - 'gen_settings_countries', |
|
297 | - GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
298 | - array('ee_admin_js'), |
|
299 | - EVENT_ESPRESSO_VERSION, |
|
300 | - true |
|
301 | - ); |
|
302 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
303 | - wp_enqueue_script('gen_settings_countries'); |
|
304 | - wp_enqueue_style('organization-css'); |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - /************* Espresso Pages *************/ |
|
309 | - /** |
|
310 | - * _espresso_page_settings |
|
311 | - * |
|
312 | - * @throws \EE_Error |
|
313 | - */ |
|
314 | - protected function _espresso_page_settings() |
|
315 | - { |
|
316 | - // Check to make sure all of the main pages are setup properly, |
|
317 | - // if not create the default pages and display an admin notice |
|
318 | - EEH_Activation::verify_default_pages_exist(); |
|
319 | - $this->_transient_garbage_collection(); |
|
320 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
321 | - $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
322 | - ? EE_Registry::instance()->CFG->core->reg_page_id |
|
323 | - : null; |
|
324 | - $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
325 | - ? get_page(EE_Registry::instance()->CFG->core->reg_page_id) |
|
326 | - : false; |
|
327 | - $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
328 | - ? EE_Registry::instance()->CFG->core->txn_page_id |
|
329 | - : null; |
|
330 | - $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
331 | - ? get_page(EE_Registry::instance()->CFG->core->txn_page_id) |
|
332 | - : false; |
|
333 | - $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
334 | - ? EE_Registry::instance()->CFG->core->thank_you_page_id |
|
335 | - : null; |
|
336 | - $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
337 | - ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
338 | - : false; |
|
339 | - $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
340 | - ? EE_Registry::instance()->CFG->core->cancel_page_id |
|
341 | - : null; |
|
342 | - $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
343 | - ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
344 | - : false; |
|
345 | - $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
|
346 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
347 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
348 | - GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
349 | - $this->_template_args, |
|
350 | - true |
|
351 | - ); |
|
352 | - $this->display_admin_page_with_sidebar(); |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * Handler for updating espresso page settings. |
|
358 | - */ |
|
359 | - protected function _update_espresso_page_settings() |
|
360 | - { |
|
361 | - // capture incoming request data && set page IDs |
|
362 | - EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id']) |
|
363 | - ? absint($this->_req_data['reg_page_id']) |
|
364 | - : EE_Registry::instance()->CFG->core->reg_page_id; |
|
365 | - EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id']) |
|
366 | - ? absint($this->_req_data['txn_page_id']) |
|
367 | - : EE_Registry::instance()->CFG->core->txn_page_id; |
|
368 | - EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id']) |
|
369 | - ? absint($this->_req_data['thank_you_page_id']) |
|
370 | - : EE_Registry::instance()->CFG->core->thank_you_page_id; |
|
371 | - EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id']) |
|
372 | - ? absint($this->_req_data['cancel_page_id']) |
|
373 | - : EE_Registry::instance()->CFG->core->cancel_page_id; |
|
374 | - |
|
375 | - EE_Registry::instance()->CFG->core = apply_filters( |
|
376 | - 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', |
|
377 | - EE_Registry::instance()->CFG->core, |
|
378 | - $this->_req_data |
|
379 | - ); |
|
380 | - $what = __('Critical Pages & Shortcodes', 'event_espresso'); |
|
381 | - $this->_redirect_after_action( |
|
382 | - $this->_update_espresso_configuration( |
|
383 | - $what, |
|
384 | - EE_Registry::instance()->CFG->core, |
|
385 | - __FILE__, |
|
386 | - __FUNCTION__, |
|
387 | - __LINE__ |
|
388 | - ), |
|
389 | - $what, |
|
390 | - '', |
|
391 | - array( |
|
392 | - 'action' => 'critical_pages', |
|
393 | - ), |
|
394 | - true |
|
395 | - ); |
|
396 | - } |
|
397 | - |
|
398 | - |
|
399 | - /************* Your Organization *************/ |
|
400 | - |
|
401 | - |
|
402 | - /** |
|
403 | - * Output for the Your Organization settings route. |
|
404 | - * @throws DomainException |
|
405 | - * @throws EE_Error |
|
406 | - */ |
|
407 | - protected function _your_organization_settings() |
|
408 | - { |
|
409 | - |
|
410 | - $this->_template_args['site_license_key'] = isset( |
|
411 | - EE_Registry::instance()->NET_CFG->core->site_license_key |
|
412 | - ) |
|
413 | - ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key') |
|
414 | - : ''; |
|
415 | - $this->_template_args['organization_name'] = isset(EE_Registry::instance()->CFG->organization->name) |
|
416 | - ? EE_Registry::instance()->CFG->organization->get_pretty('name') |
|
417 | - : ''; |
|
418 | - $this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1) |
|
419 | - ? EE_Registry::instance()->CFG->organization->get_pretty('address_1') |
|
420 | - : ''; |
|
421 | - $this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2) |
|
422 | - ? EE_Registry::instance()->CFG->organization->get_pretty('address_2') |
|
423 | - : ''; |
|
424 | - $this->_template_args['organization_city'] = isset(EE_Registry::instance()->CFG->organization->city) |
|
425 | - ? EE_Registry::instance()->CFG->organization->get_pretty('city') |
|
426 | - : ''; |
|
427 | - $this->_template_args['organization_zip'] = isset(EE_Registry::instance()->CFG->organization->zip) |
|
428 | - ? EE_Registry::instance()->CFG->organization->get_pretty('zip') |
|
429 | - : ''; |
|
430 | - $this->_template_args['organization_email'] = isset(EE_Registry::instance()->CFG->organization->email) |
|
431 | - ? EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
432 | - : ''; |
|
433 | - $this->_template_args['organization_phone'] = isset(EE_Registry::instance()->CFG->organization->phone) |
|
434 | - ? EE_Registry::instance()->CFG->organization->get_pretty('phone') |
|
435 | - : ''; |
|
436 | - $this->_template_args['organization_vat'] = isset(EE_Registry::instance()->CFG->organization->vat) |
|
437 | - ? EE_Registry::instance()->CFG->organization->get_pretty('vat') |
|
438 | - : ''; |
|
439 | - $this->_template_args['currency_sign'] = isset(EE_Registry::instance()->CFG->currency->sign) |
|
440 | - ? EE_Registry::instance()->CFG->currency->get_pretty('sign') |
|
441 | - : '$'; |
|
442 | - $this->_template_args['organization_logo_url'] = isset(EE_Registry::instance()->CFG->organization->logo_url) |
|
443 | - ? EE_Registry::instance()->CFG->organization->get_pretty('logo_url') |
|
444 | - : false; |
|
445 | - $this->_template_args['organization_facebook'] = isset(EE_Registry::instance()->CFG->organization->facebook) |
|
446 | - ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') |
|
447 | - : ''; |
|
448 | - $this->_template_args['organization_twitter'] = isset(EE_Registry::instance()->CFG->organization->twitter) |
|
449 | - ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') |
|
450 | - : ''; |
|
451 | - $this->_template_args['organization_linkedin'] = isset(EE_Registry::instance()->CFG->organization->linkedin) |
|
452 | - ? EE_Registry::instance()->CFG->organization->get_pretty('linkedin') |
|
453 | - : ''; |
|
454 | - $this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest) |
|
455 | - ? EE_Registry::instance()->CFG->organization->get_pretty('pinterest') |
|
456 | - : ''; |
|
457 | - $this->_template_args['organization_google'] = isset(EE_Registry::instance()->CFG->organization->google) |
|
458 | - ? EE_Registry::instance()->CFG->organization->get_pretty('google') |
|
459 | - : ''; |
|
460 | - $this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram) |
|
461 | - ? EE_Registry::instance()->CFG->organization->get_pretty('instagram') |
|
462 | - : ''; |
|
463 | - //UXIP settings |
|
464 | - $this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin) |
|
465 | - ? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin') |
|
466 | - : true; |
|
467 | - |
|
468 | - $STA_ID = isset(EE_Registry::instance()->CFG->organization->STA_ID) |
|
469 | - ? EE_Registry::instance()->CFG->organization->STA_ID |
|
470 | - : 4; |
|
471 | - $this->_template_args['states'] = new EE_Question_Form_Input( |
|
472 | - EE_Question::new_instance(array( |
|
473 | - 'QST_ID' => 0, |
|
474 | - 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
475 | - 'QST_system' => 'admin-state', |
|
476 | - )), |
|
477 | - EE_Answer::new_instance(array( |
|
478 | - 'ANS_ID' => 0, |
|
479 | - 'ANS_value' => $STA_ID, |
|
480 | - )), |
|
481 | - array( |
|
482 | - 'input_id' => 'organization_state', |
|
483 | - 'input_name' => 'organization_state', |
|
484 | - 'input_prefix' => '', |
|
485 | - 'append_qstn_id' => false, |
|
486 | - ) |
|
487 | - ); |
|
488 | - |
|
489 | - $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
490 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
491 | - : 'US'; |
|
492 | - $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
493 | - EE_Question::new_instance(array( |
|
494 | - 'QST_ID' => 0, |
|
495 | - 'QST_display_text' => __('Country', 'event_espresso'), |
|
496 | - 'QST_system' => 'admin-country', |
|
497 | - )), |
|
498 | - EE_Answer::new_instance(array( |
|
499 | - 'ANS_ID' => 0, |
|
500 | - 'ANS_value' => $CNT_ISO, |
|
501 | - )), |
|
502 | - array( |
|
503 | - 'input_id' => 'organization_country', |
|
504 | - 'input_name' => 'organization_country', |
|
505 | - 'input_prefix' => '', |
|
506 | - 'append_qstn_id' => false, |
|
507 | - ) |
|
508 | - ); |
|
509 | - |
|
510 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
511 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
512 | - |
|
513 | - //PUE verification stuff |
|
514 | - $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
|
515 | - $verify_fail = get_option($ver_option_key); |
|
516 | - $this->_template_args['site_license_key_verified'] = $verify_fail |
|
517 | - || ! empty($verify_fail) |
|
518 | - || (empty($this->_template_args['site_license_key']) |
|
519 | - && empty($verify_fail) |
|
520 | - ) |
|
521 | - ? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' |
|
522 | - : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>'; |
|
523 | - |
|
524 | - $this->_set_add_edit_form_tags('update_your_organization_settings'); |
|
525 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
526 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
527 | - GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php', |
|
528 | - $this->_template_args, |
|
529 | - true |
|
530 | - ); |
|
531 | - |
|
532 | - $this->display_admin_page_with_sidebar(); |
|
533 | - } |
|
534 | - |
|
535 | - |
|
536 | - /** |
|
537 | - * Handler for updating organziation settings. |
|
538 | - */ |
|
539 | - protected function _update_your_organization_settings() |
|
540 | - { |
|
541 | - if (is_main_site()) { |
|
542 | - EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key']) |
|
543 | - ? sanitize_text_field($this->_req_data['site_license_key']) |
|
544 | - : EE_Registry::instance()->NET_CFG->core->site_license_key; |
|
545 | - } |
|
546 | - EE_Registry::instance()->CFG->organization->name = isset($this->_req_data['organization_name']) |
|
547 | - ? sanitize_text_field($this->_req_data['organization_name']) |
|
548 | - : EE_Registry::instance()->CFG->organization->name; |
|
549 | - EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1']) |
|
550 | - ? sanitize_text_field($this->_req_data['organization_address_1']) |
|
551 | - : EE_Registry::instance()->CFG->organization->address_1; |
|
552 | - EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2']) |
|
553 | - ? sanitize_text_field($this->_req_data['organization_address_2']) |
|
554 | - : EE_Registry::instance()->CFG->organization->address_2; |
|
555 | - EE_Registry::instance()->CFG->organization->city = isset($this->_req_data['organization_city']) |
|
556 | - ? sanitize_text_field($this->_req_data['organization_city']) |
|
557 | - : EE_Registry::instance()->CFG->organization->city; |
|
558 | - EE_Registry::instance()->CFG->organization->STA_ID = isset($this->_req_data['organization_state']) |
|
559 | - ? absint($this->_req_data['organization_state']) |
|
560 | - : EE_Registry::instance()->CFG->organization->STA_ID; |
|
561 | - EE_Registry::instance()->CFG->organization->CNT_ISO = isset($this->_req_data['organization_country']) |
|
562 | - ? sanitize_text_field($this->_req_data['organization_country']) |
|
563 | - : EE_Registry::instance()->CFG->organization->CNT_ISO; |
|
564 | - EE_Registry::instance()->CFG->organization->zip = isset($this->_req_data['organization_zip']) |
|
565 | - ? sanitize_text_field($this->_req_data['organization_zip']) |
|
566 | - : EE_Registry::instance()->CFG->organization->zip; |
|
567 | - EE_Registry::instance()->CFG->organization->email = isset($this->_req_data['organization_email']) |
|
568 | - ? sanitize_email($this->_req_data['organization_email']) |
|
569 | - : EE_Registry::instance()->CFG->organization->email; |
|
570 | - EE_Registry::instance()->CFG->organization->vat = isset($this->_req_data['organization_vat']) |
|
571 | - ? sanitize_text_field($this->_req_data['organization_vat']) |
|
572 | - : EE_Registry::instance()->CFG->organization->vat; |
|
573 | - EE_Registry::instance()->CFG->organization->phone = isset($this->_req_data['organization_phone']) |
|
574 | - ? sanitize_text_field($this->_req_data['organization_phone']) |
|
575 | - : EE_Registry::instance()->CFG->organization->phone; |
|
576 | - EE_Registry::instance()->CFG->organization->logo_url = isset($this->_req_data['organization_logo_url']) |
|
577 | - ? esc_url_raw($this->_req_data['organization_logo_url']) |
|
578 | - : EE_Registry::instance()->CFG->organization->logo_url; |
|
579 | - EE_Registry::instance()->CFG->organization->facebook = isset($this->_req_data['organization_facebook']) |
|
580 | - ? esc_url_raw($this->_req_data['organization_facebook']) |
|
581 | - : EE_Registry::instance()->CFG->organization->facebook; |
|
582 | - EE_Registry::instance()->CFG->organization->twitter = isset($this->_req_data['organization_twitter']) |
|
583 | - ? esc_url_raw($this->_req_data['organization_twitter']) |
|
584 | - : EE_Registry::instance()->CFG->organization->twitter; |
|
585 | - EE_Registry::instance()->CFG->organization->linkedin = isset($this->_req_data['organization_linkedin']) |
|
586 | - ? esc_url_raw($this->_req_data['organization_linkedin']) |
|
587 | - : EE_Registry::instance()->CFG->organization->linkedin; |
|
588 | - EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest']) |
|
589 | - ? esc_url_raw($this->_req_data['organization_pinterest']) |
|
590 | - : EE_Registry::instance()->CFG->organization->pinterest; |
|
591 | - EE_Registry::instance()->CFG->organization->google = isset($this->_req_data['organization_google']) |
|
592 | - ? esc_url_raw($this->_req_data['organization_google']) |
|
593 | - : EE_Registry::instance()->CFG->organization->google; |
|
594 | - EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram']) |
|
595 | - ? esc_url_raw($this->_req_data['organization_instagram']) |
|
596 | - : EE_Registry::instance()->CFG->organization->instagram; |
|
597 | - EE_Registry::instance()->CFG->core->ee_ueip_optin = isset($this->_req_data['ueip_optin']) |
|
598 | - && ! empty($this->_req_data['ueip_optin']) |
|
599 | - ? $this->_req_data['ueip_optin'] |
|
600 | - : EE_Registry::instance()->CFG->core->ee_ueip_optin; |
|
601 | - |
|
602 | - EE_Registry::instance()->CFG->currency = new EE_Currency_Config( |
|
603 | - EE_Registry::instance()->CFG->organization->CNT_ISO |
|
604 | - ); |
|
605 | - |
|
606 | - EE_Registry::instance()->CFG = apply_filters( |
|
607 | - 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', |
|
608 | - EE_Registry::instance()->CFG |
|
609 | - ); |
|
610 | - |
|
611 | - $what = 'Your Organization Settings'; |
|
612 | - $success = $this->_update_espresso_configuration( |
|
613 | - $what, |
|
614 | - EE_Registry::instance()->CFG, |
|
615 | - __FILE__, |
|
616 | - __FUNCTION__, |
|
617 | - __LINE__ |
|
618 | - ); |
|
619 | - |
|
620 | - $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default')); |
|
621 | - } |
|
622 | - |
|
623 | - |
|
624 | - |
|
625 | - /************* Admin Options *************/ |
|
626 | - |
|
627 | - |
|
628 | - /** |
|
629 | - * _admin_option_settings |
|
630 | - * |
|
631 | - * @throws \EE_Error |
|
632 | - * @throws \LogicException |
|
633 | - */ |
|
634 | - protected function _admin_option_settings() |
|
635 | - { |
|
636 | - $this->_template_args['admin_page_content'] = ''; |
|
637 | - try { |
|
638 | - $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
639 | - // still need this for the old school form in Extend_General_Settings_Admin_Page |
|
640 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
641 | - // also need to account for the do_action that was in the old template |
|
642 | - $admin_options_settings_form->setTemplateArgs($this->_template_args); |
|
643 | - $this->_template_args['admin_page_content'] = $admin_options_settings_form->display(); |
|
644 | - } catch (Exception $e) { |
|
645 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
646 | - } |
|
647 | - $this->_set_add_edit_form_tags('update_admin_option_settings'); |
|
648 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
649 | - $this->display_admin_page_with_sidebar(); |
|
650 | - } |
|
651 | - |
|
652 | - |
|
653 | - /** |
|
654 | - * _update_admin_option_settings |
|
655 | - * |
|
656 | - * @throws \EE_Error |
|
657 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
658 | - * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException |
|
659 | - * @throws \InvalidArgumentException |
|
660 | - * @throws \LogicException |
|
661 | - */ |
|
662 | - protected function _update_admin_option_settings() |
|
663 | - { |
|
664 | - try { |
|
665 | - $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
666 | - $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]); |
|
667 | - EE_Registry::instance()->CFG->admin = apply_filters( |
|
668 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
669 | - EE_Registry::instance()->CFG->admin |
|
670 | - ); |
|
671 | - } catch (Exception $e) { |
|
672 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
673 | - } |
|
674 | - $this->_redirect_after_action( |
|
675 | - apply_filters( |
|
676 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', |
|
677 | - $this->_update_espresso_configuration( |
|
678 | - 'Admin Options', |
|
679 | - EE_Registry::instance()->CFG->admin, |
|
680 | - __FILE__, __FUNCTION__, __LINE__ |
|
681 | - ) |
|
682 | - ), |
|
683 | - 'Admin Options', |
|
684 | - 'updated', |
|
685 | - array('action' => 'admin_option_settings') |
|
686 | - ); |
|
687 | - |
|
688 | - } |
|
689 | - |
|
690 | - |
|
691 | - /************* Countries *************/ |
|
692 | - |
|
693 | - |
|
694 | - /** |
|
695 | - * Output Country Settings view. |
|
696 | - * @throws DomainException |
|
697 | - * @throws EE_Error |
|
698 | - */ |
|
699 | - protected function _country_settings() |
|
700 | - { |
|
701 | - $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
702 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
703 | - : 'US'; |
|
704 | - $CNT_ISO = isset($this->_req_data['country']) |
|
705 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
706 | - : $CNT_ISO; |
|
707 | - |
|
708 | - //load field generator helper |
|
709 | - |
|
710 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
711 | - |
|
712 | - $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
713 | - EE_Question::new_instance(array( |
|
714 | - 'QST_ID' => 0, |
|
715 | - 'QST_display_text' => __('Select Country', 'event_espresso'), |
|
716 | - 'QST_system' => 'admin-country', |
|
717 | - )), |
|
718 | - EE_Answer::new_instance(array( |
|
719 | - 'ANS_ID' => 0, |
|
720 | - 'ANS_value' => $CNT_ISO, |
|
721 | - )), |
|
722 | - array( |
|
723 | - 'input_id' => 'country', |
|
724 | - 'input_name' => 'country', |
|
725 | - 'input_prefix' => '', |
|
726 | - 'append_qstn_id' => false, |
|
727 | - ) |
|
728 | - ); |
|
729 | - |
|
730 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
731 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
732 | - $this->_template_args['country_details_settings'] = $this->display_country_settings(); |
|
733 | - $this->_template_args['country_states_settings'] = $this->display_country_states(); |
|
734 | - |
|
735 | - $this->_set_add_edit_form_tags('update_country_settings'); |
|
736 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
737 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
738 | - GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
739 | - $this->_template_args, |
|
740 | - true |
|
741 | - ); |
|
742 | - $this->display_admin_page_with_no_sidebar(); |
|
743 | - } |
|
744 | - |
|
745 | - |
|
746 | - /** |
|
747 | - * display_country_settings |
|
748 | - * |
|
749 | - * @access public |
|
750 | - * @param string $CNT_ISO |
|
751 | - * @return mixed string | array |
|
752 | - * @throws DomainException |
|
753 | - */ |
|
754 | - public function display_country_settings($CNT_ISO = '') |
|
755 | - { |
|
756 | - |
|
757 | - $CNT_ISO = isset($this->_req_data['country']) |
|
758 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
759 | - : $CNT_ISO; |
|
760 | - if (! $CNT_ISO) { |
|
761 | - return ''; |
|
762 | - } |
|
763 | - |
|
764 | - // for ajax |
|
765 | - remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
766 | - remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
767 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
768 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
769 | - $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
770 | - |
|
771 | - $country_input_types = array( |
|
772 | - 'CNT_active' => array( |
|
773 | - 'type' => 'RADIO_BTN', |
|
774 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
775 | - 'class' => '', |
|
776 | - 'options' => $this->_yes_no_values, |
|
777 | - 'use_desc_4_label' => true, |
|
778 | - ), |
|
779 | - 'CNT_ISO' => array( |
|
780 | - 'type' => 'TEXT', |
|
781 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
782 | - 'class' => 'small-text', |
|
783 | - ), |
|
784 | - 'CNT_ISO3' => array( |
|
785 | - 'type' => 'TEXT', |
|
786 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
787 | - 'class' => 'small-text', |
|
788 | - ), |
|
789 | - 'RGN_ID' => array( |
|
790 | - 'type' => 'TEXT', |
|
791 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
792 | - 'class' => 'small-text', |
|
793 | - ), |
|
794 | - 'CNT_name' => array( |
|
795 | - 'type' => 'TEXT', |
|
796 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
797 | - 'class' => 'regular-text', |
|
798 | - ), |
|
799 | - 'CNT_cur_code' => array( |
|
800 | - 'type' => 'TEXT', |
|
801 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
802 | - 'class' => 'small-text', |
|
803 | - ), |
|
804 | - 'CNT_cur_single' => array( |
|
805 | - 'type' => 'TEXT', |
|
806 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
807 | - 'class' => 'medium-text', |
|
808 | - ), |
|
809 | - 'CNT_cur_plural' => array( |
|
810 | - 'type' => 'TEXT', |
|
811 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
812 | - 'class' => 'medium-text', |
|
813 | - ), |
|
814 | - 'CNT_cur_sign' => array( |
|
815 | - 'type' => 'TEXT', |
|
816 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
817 | - 'class' => 'small-text', |
|
818 | - 'htmlentities' => false, |
|
819 | - ), |
|
820 | - 'CNT_cur_sign_b4' => array( |
|
821 | - 'type' => 'RADIO_BTN', |
|
822 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
823 | - 'class' => '', |
|
824 | - 'options' => $this->_yes_no_values, |
|
825 | - 'use_desc_4_label' => true, |
|
826 | - ), |
|
827 | - 'CNT_cur_dec_plc' => array( |
|
828 | - 'type' => 'RADIO_BTN', |
|
829 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
830 | - 'class' => '', |
|
831 | - 'options' => array( |
|
832 | - array('id' => 0, 'text' => ''), |
|
833 | - array('id' => 1, 'text' => ''), |
|
834 | - array('id' => 2, 'text' => ''), |
|
835 | - array('id' => 3, 'text' => ''), |
|
836 | - ), |
|
837 | - ), |
|
838 | - 'CNT_cur_dec_mrk' => array( |
|
839 | - 'type' => 'RADIO_BTN', |
|
840 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
841 | - 'class' => '', |
|
842 | - 'options' => array( |
|
843 | - array( |
|
844 | - 'id' => ',', |
|
845 | - 'text' => __(', (comma)', 'event_espresso'), |
|
846 | - ), |
|
847 | - array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')), |
|
848 | - ), |
|
849 | - 'use_desc_4_label' => true, |
|
850 | - ), |
|
851 | - 'CNT_cur_thsnds' => array( |
|
852 | - 'type' => 'RADIO_BTN', |
|
853 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
854 | - 'class' => '', |
|
855 | - 'options' => array( |
|
856 | - array( |
|
857 | - 'id' => ',', |
|
858 | - 'text' => __(', (comma)', 'event_espresso'), |
|
859 | - ), |
|
860 | - array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')), |
|
861 | - ), |
|
862 | - 'use_desc_4_label' => true, |
|
863 | - ), |
|
864 | - 'CNT_tel_code' => array( |
|
865 | - 'type' => 'TEXT', |
|
866 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
867 | - 'class' => 'small-text', |
|
868 | - ), |
|
869 | - 'CNT_is_EU' => array( |
|
870 | - 'type' => 'RADIO_BTN', |
|
871 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
872 | - 'class' => '', |
|
873 | - 'options' => $this->_yes_no_values, |
|
874 | - 'use_desc_4_label' => true, |
|
875 | - ), |
|
876 | - ); |
|
877 | - $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
878 | - $country, |
|
879 | - $country_input_types |
|
880 | - ); |
|
881 | - $country_details_settings = EEH_Template::display_template( |
|
882 | - GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
883 | - $this->_template_args, |
|
884 | - true |
|
885 | - ); |
|
886 | - |
|
887 | - if (defined('DOING_AJAX')) { |
|
888 | - $notices = EE_Error::get_notices(false, false, false); |
|
889 | - echo wp_json_encode(array( |
|
890 | - 'return_data' => $country_details_settings, |
|
891 | - 'success' => $notices['success'], |
|
892 | - 'errors' => $notices['errors'], |
|
893 | - )); |
|
894 | - die(); |
|
895 | - } else { |
|
896 | - return $country_details_settings; |
|
897 | - } |
|
898 | - } |
|
899 | - |
|
900 | - |
|
901 | - /** |
|
902 | - * display_country_states |
|
903 | - * |
|
904 | - * @access public |
|
905 | - * @param string $CNT_ISO |
|
906 | - * @return string |
|
907 | - * @throws DomainException |
|
908 | - */ |
|
909 | - public function display_country_states($CNT_ISO = '') |
|
910 | - { |
|
911 | - |
|
912 | - $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; |
|
913 | - |
|
914 | - if (! $CNT_ISO) { |
|
915 | - return ''; |
|
916 | - } |
|
917 | - // for ajax |
|
918 | - remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
919 | - remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
920 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2); |
|
921 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2); |
|
922 | - $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO)); |
|
923 | - |
|
924 | - if ($states) { |
|
925 | - foreach ($states as $STA_ID => $state) { |
|
926 | - if ($state instanceof EE_State) { |
|
927 | - //STA_abbrev STA_name STA_active |
|
928 | - $state_input_types = array( |
|
929 | - 'STA_abbrev' => array( |
|
930 | - 'type' => 'TEXT', |
|
931 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
932 | - 'class' => 'mid-text', |
|
933 | - ), |
|
934 | - 'STA_name' => array( |
|
935 | - 'type' => 'TEXT', |
|
936 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
937 | - 'class' => 'regular-text', |
|
938 | - ), |
|
939 | - 'STA_active' => array( |
|
940 | - 'type' => 'RADIO_BTN', |
|
941 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
942 | - 'options' => $this->_yes_no_values, |
|
943 | - 'use_desc_4_label' => true, |
|
944 | - ), |
|
945 | - ); |
|
946 | - $this->_template_args['states'][$STA_ID]['inputs'] = |
|
947 | - EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
948 | - $state, |
|
949 | - $state_input_types |
|
950 | - ); |
|
951 | - $query_args = array( |
|
952 | - 'action' => 'delete_state', |
|
953 | - 'STA_ID' => $STA_ID, |
|
954 | - 'CNT_ISO' => $CNT_ISO, |
|
955 | - 'STA_abbrev' => $state->abbrev(), |
|
956 | - ); |
|
957 | - $this->_template_args['states'][$STA_ID]['delete_state_url'] = |
|
958 | - EE_Admin_Page::add_query_args_and_nonce( |
|
959 | - $query_args, |
|
960 | - GEN_SET_ADMIN_URL |
|
961 | - ); |
|
962 | - } |
|
963 | - } |
|
964 | - } else { |
|
965 | - $this->_template_args['states'] = false; |
|
966 | - } |
|
967 | - |
|
968 | - $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
969 | - array('action' => 'add_new_state'), |
|
970 | - GEN_SET_ADMIN_URL |
|
971 | - ); |
|
972 | - |
|
973 | - $state_details_settings = EEH_Template::display_template( |
|
974 | - GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
975 | - $this->_template_args, |
|
976 | - true |
|
977 | - ); |
|
978 | - |
|
979 | - if (defined('DOING_AJAX')) { |
|
980 | - $notices = EE_Error::get_notices(false, false, false); |
|
981 | - echo wp_json_encode(array( |
|
982 | - 'return_data' => $state_details_settings, |
|
983 | - 'success' => $notices['success'], |
|
984 | - 'errors' => $notices['errors'], |
|
985 | - )); |
|
986 | - die(); |
|
987 | - } else { |
|
988 | - return $state_details_settings; |
|
989 | - } |
|
990 | - } |
|
991 | - |
|
992 | - |
|
993 | - /** |
|
994 | - * add_new_state |
|
995 | - * |
|
996 | - * @access public |
|
997 | - * @return void |
|
998 | - * @throws EE_Error |
|
999 | - */ |
|
1000 | - public function add_new_state() |
|
1001 | - { |
|
1002 | - |
|
1003 | - $success = true; |
|
1004 | - |
|
1005 | - $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
1006 | - ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
1007 | - : false; |
|
1008 | - if (! $CNT_ISO) { |
|
1009 | - EE_Error::add_error( |
|
1010 | - __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
1011 | - __FILE__, |
|
1012 | - __FUNCTION__, |
|
1013 | - __LINE__ |
|
1014 | - ); |
|
1015 | - $success = false; |
|
1016 | - } |
|
1017 | - $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
1018 | - ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
1019 | - : false; |
|
1020 | - if (! $STA_abbrev) { |
|
1021 | - EE_Error::add_error( |
|
1022 | - __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
|
1023 | - __FILE__, |
|
1024 | - __FUNCTION__, |
|
1025 | - __LINE__ |
|
1026 | - ); |
|
1027 | - $success = false; |
|
1028 | - } |
|
1029 | - $STA_name = isset($this->_req_data['STA_name']) |
|
1030 | - ? sanitize_text_field($this->_req_data['STA_name']) |
|
1031 | - : false; |
|
1032 | - if (! $STA_name) { |
|
1033 | - EE_Error::add_error( |
|
1034 | - __('No State name or an invalid State name was received.', 'event_espresso'), |
|
1035 | - __FILE__, |
|
1036 | - __FUNCTION__, |
|
1037 | - __LINE__ |
|
1038 | - ); |
|
1039 | - $success = false; |
|
1040 | - } |
|
1041 | - |
|
1042 | - if ($success) { |
|
1043 | - $cols_n_values = array( |
|
1044 | - 'CNT_ISO' => $CNT_ISO, |
|
1045 | - 'STA_abbrev' => $STA_abbrev, |
|
1046 | - 'STA_name' => $STA_name, |
|
1047 | - 'STA_active' => true, |
|
1048 | - ); |
|
1049 | - $success = EEM_State::instance()->insert($cols_n_values); |
|
1050 | - EE_Error::add_success(__('The State was added successfully.', 'event_espresso')); |
|
1051 | - } |
|
1052 | - |
|
1053 | - if (defined('DOING_AJAX')) { |
|
1054 | - $notices = EE_Error::get_notices(false, false, false); |
|
1055 | - echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO))); |
|
1056 | - die(); |
|
1057 | - } else { |
|
1058 | - $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings')); |
|
1059 | - } |
|
1060 | - } |
|
1061 | - |
|
1062 | - |
|
1063 | - /** |
|
1064 | - * delete_state |
|
1065 | - * |
|
1066 | - * @access public |
|
1067 | - * @return boolean |
|
1068 | - */ |
|
1069 | - public function delete_state() |
|
1070 | - { |
|
1071 | - $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
1072 | - ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
1073 | - : false; |
|
1074 | - $STA_ID = isset($this->_req_data['STA_ID']) |
|
1075 | - ? sanitize_text_field($this->_req_data['STA_ID']) |
|
1076 | - : false; |
|
1077 | - $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
1078 | - ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
1079 | - : false; |
|
1080 | - if (! $STA_ID) { |
|
1081 | - EE_Error::add_error( |
|
1082 | - __('No State ID or an invalid State ID was received.', 'event_espresso'), |
|
1083 | - __FILE__, |
|
1084 | - __FUNCTION__, |
|
1085 | - __LINE__ |
|
1086 | - ); |
|
1087 | - return false; |
|
1088 | - } |
|
1089 | - |
|
1090 | - $success = EEM_State::instance()->delete_by_ID($STA_ID); |
|
1091 | - if ($success !== false) { |
|
1092 | - do_action( |
|
1093 | - 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
1094 | - $CNT_ISO, |
|
1095 | - $STA_ID, |
|
1096 | - array('STA_abbrev' => $STA_abbrev) |
|
1097 | - ); |
|
1098 | - EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso')); |
|
1099 | - } |
|
1100 | - if (defined('DOING_AJAX')) { |
|
1101 | - $notices = EE_Error::get_notices(false, false); |
|
1102 | - $notices['return_data'] = true; |
|
1103 | - echo wp_json_encode($notices); |
|
1104 | - die(); |
|
1105 | - } else { |
|
1106 | - $this->_redirect_after_action( |
|
1107 | - $success, |
|
1108 | - 'State', |
|
1109 | - 'deleted', |
|
1110 | - array('action' => 'country_settings') |
|
1111 | - ); |
|
1112 | - } |
|
1113 | - } |
|
1114 | - |
|
1115 | - |
|
1116 | - /** |
|
1117 | - * _update_country_settings |
|
1118 | - * |
|
1119 | - * @access protected |
|
1120 | - * @return void |
|
1121 | - * @throws EE_Error |
|
1122 | - */ |
|
1123 | - protected function _update_country_settings() |
|
1124 | - { |
|
1125 | - // grab the country ISO code |
|
1126 | - $CNT_ISO = isset($this->_req_data['country']) |
|
1127 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
1128 | - : false; |
|
1129 | - if (! $CNT_ISO) { |
|
1130 | - EE_Error::add_error( |
|
1131 | - __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
1132 | - __FILE__, |
|
1133 | - __FUNCTION__, |
|
1134 | - __LINE__ |
|
1135 | - ); |
|
1136 | - |
|
1137 | - return; |
|
1138 | - } |
|
1139 | - $cols_n_values = array(); |
|
1140 | - $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']) |
|
1141 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])) |
|
1142 | - : false; |
|
1143 | - $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) |
|
1144 | - ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) |
|
1145 | - : null; |
|
1146 | - $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) |
|
1147 | - ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) |
|
1148 | - : null; |
|
1149 | - $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']) |
|
1150 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) |
|
1151 | - : 'USD'; |
|
1152 | - $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) |
|
1153 | - ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) |
|
1154 | - : 'dollar'; |
|
1155 | - $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) |
|
1156 | - ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) |
|
1157 | - : 'dollars'; |
|
1158 | - $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) |
|
1159 | - ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) |
|
1160 | - : '$'; |
|
1161 | - $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) |
|
1162 | - ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) |
|
1163 | - : true; |
|
1164 | - $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) |
|
1165 | - ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) |
|
1166 | - : 2; |
|
1167 | - $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) |
|
1168 | - ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) |
|
1169 | - : '.'; |
|
1170 | - $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) |
|
1171 | - ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) |
|
1172 | - : ','; |
|
1173 | - $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) |
|
1174 | - ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) |
|
1175 | - : null; |
|
1176 | - $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) |
|
1177 | - ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) |
|
1178 | - : false; |
|
1179 | - $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) |
|
1180 | - ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) |
|
1181 | - : false; |
|
1182 | - // allow filtering of country data |
|
1183 | - $cols_n_values = apply_filters( |
|
1184 | - 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', |
|
1185 | - $cols_n_values |
|
1186 | - ); |
|
1187 | - |
|
1188 | - // where values |
|
1189 | - $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO)); |
|
1190 | - // run the update |
|
1191 | - $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values); |
|
1192 | - |
|
1193 | - if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) { |
|
1194 | - // allow filtering of states data |
|
1195 | - $states = apply_filters( |
|
1196 | - 'FHEE__General_Settings_Admin_Page___update_country_settings__states', |
|
1197 | - $this->_req_data['states'] |
|
1198 | - ); |
|
1199 | - |
|
1200 | - // loop thru state data ( looks like : states[75][STA_name] ) |
|
1201 | - foreach ($states as $STA_ID => $state) { |
|
1202 | - $cols_n_values = array( |
|
1203 | - 'CNT_ISO' => $CNT_ISO, |
|
1204 | - 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
|
1205 | - 'STA_name' => sanitize_text_field($state['STA_name']), |
|
1206 | - 'STA_active' => (bool)absint($state['STA_active']), |
|
1207 | - ); |
|
1208 | - // where values |
|
1209 | - $where_cols_n_values = array(array('STA_ID' => $STA_ID)); |
|
1210 | - // run the update |
|
1211 | - $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values); |
|
1212 | - if ($success !== false) { |
|
1213 | - do_action( |
|
1214 | - 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
1215 | - $CNT_ISO, |
|
1216 | - $STA_ID, |
|
1217 | - $cols_n_values |
|
1218 | - ); |
|
1219 | - } |
|
1220 | - } |
|
1221 | - } |
|
1222 | - // check if country being edited matches org option country, and if so, then update EE_Config with new settings |
|
1223 | - if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
1224 | - && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO |
|
1225 | - ) { |
|
1226 | - EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO); |
|
1227 | - EE_Registry::instance()->CFG->update_espresso_config(); |
|
1228 | - } |
|
1229 | - |
|
1230 | - if ($success !== false) { |
|
1231 | - EE_Error::add_success( |
|
1232 | - esc_html__('Country Settings updated successfully.', 'event_espresso') |
|
1233 | - ); |
|
1234 | - } |
|
1235 | - $this->_redirect_after_action( |
|
1236 | - $success, |
|
1237 | - '', |
|
1238 | - '', |
|
1239 | - array('action' => 'country_settings', 'country' => $CNT_ISO), |
|
1240 | - true |
|
1241 | - ); |
|
1242 | - } |
|
1243 | - |
|
1244 | - |
|
1245 | - /** |
|
1246 | - * form_form_field_label_wrap |
|
1247 | - * |
|
1248 | - * @access public |
|
1249 | - * @param string $label |
|
1250 | - * @return string |
|
1251 | - */ |
|
1252 | - public function country_form_field_label_wrap($label, $required_text) |
|
1253 | - { |
|
1254 | - return ' |
|
20 | + /** |
|
21 | + * _question_group |
|
22 | + * holds the specific question group object for the question group details screen |
|
23 | + * |
|
24 | + * @var object |
|
25 | + */ |
|
26 | + protected $_question_group; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * Initialize basic properties. |
|
31 | + */ |
|
32 | + protected function _init_page_props() |
|
33 | + { |
|
34 | + $this->page_slug = GEN_SET_PG_SLUG; |
|
35 | + $this->page_label = GEN_SET_LABEL; |
|
36 | + $this->_admin_base_url = GEN_SET_ADMIN_URL; |
|
37 | + $this->_admin_base_path = GEN_SET_ADMIN; |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Set ajax hooks |
|
43 | + */ |
|
44 | + protected function _ajax_hooks() |
|
45 | + { |
|
46 | + add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings')); |
|
47 | + add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states')); |
|
48 | + add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3); |
|
49 | + add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state')); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * More page properties initialization. |
|
55 | + */ |
|
56 | + protected function _define_page_props() |
|
57 | + { |
|
58 | + $this->_admin_page_title = GEN_SET_LABEL; |
|
59 | + $this->_labels = array( |
|
60 | + 'publishbox' => __('Update Settings', 'event_espresso'), |
|
61 | + ); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * Set page routes property. |
|
67 | + */ |
|
68 | + protected function _set_page_routes() |
|
69 | + { |
|
70 | + $this->_page_routes = array( |
|
71 | + |
|
72 | + 'critical_pages' => array( |
|
73 | + 'func' => '_espresso_page_settings', |
|
74 | + 'capability' => 'manage_options', |
|
75 | + ), |
|
76 | + 'update_espresso_page_settings' => array( |
|
77 | + 'func' => '_update_espresso_page_settings', |
|
78 | + 'capability' => 'manage_options', |
|
79 | + 'noheader' => true, |
|
80 | + ), |
|
81 | + 'default' => array( |
|
82 | + 'func' => '_your_organization_settings', |
|
83 | + 'capability' => 'manage_options', |
|
84 | + ), |
|
85 | + |
|
86 | + 'update_your_organization_settings' => array( |
|
87 | + 'func' => '_update_your_organization_settings', |
|
88 | + 'capability' => 'manage_options', |
|
89 | + 'noheader' => true, |
|
90 | + ), |
|
91 | + |
|
92 | + 'admin_option_settings' => array( |
|
93 | + 'func' => '_admin_option_settings', |
|
94 | + 'capability' => 'manage_options', |
|
95 | + ), |
|
96 | + |
|
97 | + 'update_admin_option_settings' => array( |
|
98 | + 'func' => '_update_admin_option_settings', |
|
99 | + 'capability' => 'manage_options', |
|
100 | + 'noheader' => true, |
|
101 | + ), |
|
102 | + |
|
103 | + 'country_settings' => array( |
|
104 | + 'func' => '_country_settings', |
|
105 | + 'capability' => 'manage_options', |
|
106 | + ), |
|
107 | + |
|
108 | + 'update_country_settings' => array( |
|
109 | + 'func' => '_update_country_settings', |
|
110 | + 'capability' => 'manage_options', |
|
111 | + 'noheader' => true, |
|
112 | + ), |
|
113 | + |
|
114 | + 'display_country_settings' => array( |
|
115 | + 'func' => 'display_country_settings', |
|
116 | + 'capability' => 'manage_options', |
|
117 | + 'noheader' => true, |
|
118 | + ), |
|
119 | + |
|
120 | + 'add_new_state' => array( |
|
121 | + 'func' => 'add_new_state', |
|
122 | + 'capability' => 'manage_options', |
|
123 | + 'noheader' => true, |
|
124 | + ), |
|
125 | + |
|
126 | + 'delete_state' => array( |
|
127 | + 'func' => 'delete_state', |
|
128 | + 'capability' => 'manage_options', |
|
129 | + 'noheader' => true, |
|
130 | + ), |
|
131 | + ); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * Set page configuration property |
|
137 | + */ |
|
138 | + protected function _set_page_config() |
|
139 | + { |
|
140 | + $this->_page_config = array( |
|
141 | + 'critical_pages' => array( |
|
142 | + 'nav' => array( |
|
143 | + 'label' => __('Critical Pages', 'event_espresso'), |
|
144 | + 'order' => 50, |
|
145 | + ), |
|
146 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
147 | + 'help_tabs' => array( |
|
148 | + 'general_settings_critical_pages_help_tab' => array( |
|
149 | + 'title' => __('Critical Pages', 'event_espresso'), |
|
150 | + 'filename' => 'general_settings_critical_pages', |
|
151 | + ), |
|
152 | + ), |
|
153 | + 'help_tour' => array('Critical_Pages_Help_Tour'), |
|
154 | + 'require_nonce' => false, |
|
155 | + ), |
|
156 | + 'default' => array( |
|
157 | + 'nav' => array( |
|
158 | + 'label' => __('Your Organization', 'event_espresso'), |
|
159 | + 'order' => 20, |
|
160 | + ), |
|
161 | + 'help_tabs' => array( |
|
162 | + 'general_settings_your_organization_help_tab' => array( |
|
163 | + 'title' => __('Your Organization', 'event_espresso'), |
|
164 | + 'filename' => 'general_settings_your_organization', |
|
165 | + ), |
|
166 | + ), |
|
167 | + 'help_tour' => array('Your_Organization_Help_Tour'), |
|
168 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
169 | + 'require_nonce' => false, |
|
170 | + ), |
|
171 | + 'admin_option_settings' => array( |
|
172 | + 'nav' => array( |
|
173 | + 'label' => __('Admin Options', 'event_espresso'), |
|
174 | + 'order' => 60, |
|
175 | + ), |
|
176 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
177 | + 'help_tabs' => array( |
|
178 | + 'general_settings_admin_options_help_tab' => array( |
|
179 | + 'title' => __('Admin Options', 'event_espresso'), |
|
180 | + 'filename' => 'general_settings_admin_options', |
|
181 | + ), |
|
182 | + ), |
|
183 | + 'help_tour' => array('Admin_Options_Help_Tour'), |
|
184 | + 'require_nonce' => false, |
|
185 | + ), |
|
186 | + 'country_settings' => array( |
|
187 | + 'nav' => array( |
|
188 | + 'label' => __('Countries', 'event_espresso'), |
|
189 | + 'order' => 70, |
|
190 | + ), |
|
191 | + 'help_tabs' => array( |
|
192 | + 'general_settings_countries_help_tab' => array( |
|
193 | + 'title' => __('Countries', 'event_espresso'), |
|
194 | + 'filename' => 'general_settings_countries', |
|
195 | + ), |
|
196 | + ), |
|
197 | + 'help_tour' => array('Countries_Help_Tour'), |
|
198 | + 'require_nonce' => false, |
|
199 | + ), |
|
200 | + ); |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + |
|
205 | + protected function _add_screen_options() |
|
206 | + { |
|
207 | + } |
|
208 | + |
|
209 | + protected function _add_feature_pointers() |
|
210 | + { |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * Enqueue global scripts and styles for all routes in the General Settings Admin Pages. |
|
216 | + */ |
|
217 | + public function load_scripts_styles() |
|
218 | + { |
|
219 | + //styles |
|
220 | + wp_enqueue_style('espresso-ui-theme'); |
|
221 | + //scripts |
|
222 | + wp_enqueue_script('ee_admin_js'); |
|
223 | + } |
|
224 | + |
|
225 | + |
|
226 | + /** |
|
227 | + * Execute logic running on `admin_init` |
|
228 | + */ |
|
229 | + public function admin_init() |
|
230 | + { |
|
231 | + EE_Registry::$i18n_js_strings['invalid_server_response'] = __( |
|
232 | + 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
233 | + 'event_espresso' |
|
234 | + ); |
|
235 | + EE_Registry::$i18n_js_strings['error_occurred'] = __( |
|
236 | + 'An error occurred! Please refresh the page and try again.', |
|
237 | + 'event_espresso' |
|
238 | + ); |
|
239 | + EE_Registry::$i18n_js_strings['confirm_delete_state'] = __( |
|
240 | + 'Are you sure you want to delete this State / Province?', |
|
241 | + 'event_espresso' |
|
242 | + ); |
|
243 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
244 | + EE_Registry::$i18n_js_strings['ajax_url'] = admin_url( |
|
245 | + 'admin-ajax.php?page=espresso_general_settings', |
|
246 | + $protocol |
|
247 | + ); |
|
248 | + } |
|
249 | + |
|
250 | + public function admin_notices() |
|
251 | + { |
|
252 | + } |
|
253 | + |
|
254 | + public function admin_footer_scripts() |
|
255 | + { |
|
256 | + } |
|
257 | + |
|
258 | + |
|
259 | + /** |
|
260 | + * Enqueue scripts and styles for the default route. |
|
261 | + */ |
|
262 | + public function load_scripts_styles_default() |
|
263 | + { |
|
264 | + //styles |
|
265 | + wp_enqueue_style('thickbox'); |
|
266 | + //scripts |
|
267 | + wp_enqueue_script('media-upload'); |
|
268 | + wp_enqueue_script('thickbox'); |
|
269 | + wp_register_script( |
|
270 | + 'organization_settings', |
|
271 | + GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
272 | + array('jquery', 'media-upload', 'thickbox'), |
|
273 | + EVENT_ESPRESSO_VERSION, |
|
274 | + true |
|
275 | + ); |
|
276 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
277 | + wp_enqueue_script('organization_settings'); |
|
278 | + wp_enqueue_style('organization-css'); |
|
279 | + $confirm_image_delete = array( |
|
280 | + 'text' => __( |
|
281 | + 'Do you really want to delete this image? Please remember to save your settings to complete the removal.', |
|
282 | + 'event_espresso' |
|
283 | + ), |
|
284 | + ); |
|
285 | + wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete); |
|
286 | + } |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * Enqueue scripts and styles for the country settings route. |
|
291 | + */ |
|
292 | + public function load_scripts_styles_country_settings() |
|
293 | + { |
|
294 | + //scripts |
|
295 | + wp_register_script( |
|
296 | + 'gen_settings_countries', |
|
297 | + GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
298 | + array('ee_admin_js'), |
|
299 | + EVENT_ESPRESSO_VERSION, |
|
300 | + true |
|
301 | + ); |
|
302 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
303 | + wp_enqueue_script('gen_settings_countries'); |
|
304 | + wp_enqueue_style('organization-css'); |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + /************* Espresso Pages *************/ |
|
309 | + /** |
|
310 | + * _espresso_page_settings |
|
311 | + * |
|
312 | + * @throws \EE_Error |
|
313 | + */ |
|
314 | + protected function _espresso_page_settings() |
|
315 | + { |
|
316 | + // Check to make sure all of the main pages are setup properly, |
|
317 | + // if not create the default pages and display an admin notice |
|
318 | + EEH_Activation::verify_default_pages_exist(); |
|
319 | + $this->_transient_garbage_collection(); |
|
320 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
321 | + $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
322 | + ? EE_Registry::instance()->CFG->core->reg_page_id |
|
323 | + : null; |
|
324 | + $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
325 | + ? get_page(EE_Registry::instance()->CFG->core->reg_page_id) |
|
326 | + : false; |
|
327 | + $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
328 | + ? EE_Registry::instance()->CFG->core->txn_page_id |
|
329 | + : null; |
|
330 | + $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
331 | + ? get_page(EE_Registry::instance()->CFG->core->txn_page_id) |
|
332 | + : false; |
|
333 | + $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
334 | + ? EE_Registry::instance()->CFG->core->thank_you_page_id |
|
335 | + : null; |
|
336 | + $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
337 | + ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
338 | + : false; |
|
339 | + $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
340 | + ? EE_Registry::instance()->CFG->core->cancel_page_id |
|
341 | + : null; |
|
342 | + $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
343 | + ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
344 | + : false; |
|
345 | + $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
|
346 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
347 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
348 | + GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
349 | + $this->_template_args, |
|
350 | + true |
|
351 | + ); |
|
352 | + $this->display_admin_page_with_sidebar(); |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * Handler for updating espresso page settings. |
|
358 | + */ |
|
359 | + protected function _update_espresso_page_settings() |
|
360 | + { |
|
361 | + // capture incoming request data && set page IDs |
|
362 | + EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id']) |
|
363 | + ? absint($this->_req_data['reg_page_id']) |
|
364 | + : EE_Registry::instance()->CFG->core->reg_page_id; |
|
365 | + EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id']) |
|
366 | + ? absint($this->_req_data['txn_page_id']) |
|
367 | + : EE_Registry::instance()->CFG->core->txn_page_id; |
|
368 | + EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id']) |
|
369 | + ? absint($this->_req_data['thank_you_page_id']) |
|
370 | + : EE_Registry::instance()->CFG->core->thank_you_page_id; |
|
371 | + EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id']) |
|
372 | + ? absint($this->_req_data['cancel_page_id']) |
|
373 | + : EE_Registry::instance()->CFG->core->cancel_page_id; |
|
374 | + |
|
375 | + EE_Registry::instance()->CFG->core = apply_filters( |
|
376 | + 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', |
|
377 | + EE_Registry::instance()->CFG->core, |
|
378 | + $this->_req_data |
|
379 | + ); |
|
380 | + $what = __('Critical Pages & Shortcodes', 'event_espresso'); |
|
381 | + $this->_redirect_after_action( |
|
382 | + $this->_update_espresso_configuration( |
|
383 | + $what, |
|
384 | + EE_Registry::instance()->CFG->core, |
|
385 | + __FILE__, |
|
386 | + __FUNCTION__, |
|
387 | + __LINE__ |
|
388 | + ), |
|
389 | + $what, |
|
390 | + '', |
|
391 | + array( |
|
392 | + 'action' => 'critical_pages', |
|
393 | + ), |
|
394 | + true |
|
395 | + ); |
|
396 | + } |
|
397 | + |
|
398 | + |
|
399 | + /************* Your Organization *************/ |
|
400 | + |
|
401 | + |
|
402 | + /** |
|
403 | + * Output for the Your Organization settings route. |
|
404 | + * @throws DomainException |
|
405 | + * @throws EE_Error |
|
406 | + */ |
|
407 | + protected function _your_organization_settings() |
|
408 | + { |
|
409 | + |
|
410 | + $this->_template_args['site_license_key'] = isset( |
|
411 | + EE_Registry::instance()->NET_CFG->core->site_license_key |
|
412 | + ) |
|
413 | + ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key') |
|
414 | + : ''; |
|
415 | + $this->_template_args['organization_name'] = isset(EE_Registry::instance()->CFG->organization->name) |
|
416 | + ? EE_Registry::instance()->CFG->organization->get_pretty('name') |
|
417 | + : ''; |
|
418 | + $this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1) |
|
419 | + ? EE_Registry::instance()->CFG->organization->get_pretty('address_1') |
|
420 | + : ''; |
|
421 | + $this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2) |
|
422 | + ? EE_Registry::instance()->CFG->organization->get_pretty('address_2') |
|
423 | + : ''; |
|
424 | + $this->_template_args['organization_city'] = isset(EE_Registry::instance()->CFG->organization->city) |
|
425 | + ? EE_Registry::instance()->CFG->organization->get_pretty('city') |
|
426 | + : ''; |
|
427 | + $this->_template_args['organization_zip'] = isset(EE_Registry::instance()->CFG->organization->zip) |
|
428 | + ? EE_Registry::instance()->CFG->organization->get_pretty('zip') |
|
429 | + : ''; |
|
430 | + $this->_template_args['organization_email'] = isset(EE_Registry::instance()->CFG->organization->email) |
|
431 | + ? EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
432 | + : ''; |
|
433 | + $this->_template_args['organization_phone'] = isset(EE_Registry::instance()->CFG->organization->phone) |
|
434 | + ? EE_Registry::instance()->CFG->organization->get_pretty('phone') |
|
435 | + : ''; |
|
436 | + $this->_template_args['organization_vat'] = isset(EE_Registry::instance()->CFG->organization->vat) |
|
437 | + ? EE_Registry::instance()->CFG->organization->get_pretty('vat') |
|
438 | + : ''; |
|
439 | + $this->_template_args['currency_sign'] = isset(EE_Registry::instance()->CFG->currency->sign) |
|
440 | + ? EE_Registry::instance()->CFG->currency->get_pretty('sign') |
|
441 | + : '$'; |
|
442 | + $this->_template_args['organization_logo_url'] = isset(EE_Registry::instance()->CFG->organization->logo_url) |
|
443 | + ? EE_Registry::instance()->CFG->organization->get_pretty('logo_url') |
|
444 | + : false; |
|
445 | + $this->_template_args['organization_facebook'] = isset(EE_Registry::instance()->CFG->organization->facebook) |
|
446 | + ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') |
|
447 | + : ''; |
|
448 | + $this->_template_args['organization_twitter'] = isset(EE_Registry::instance()->CFG->organization->twitter) |
|
449 | + ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') |
|
450 | + : ''; |
|
451 | + $this->_template_args['organization_linkedin'] = isset(EE_Registry::instance()->CFG->organization->linkedin) |
|
452 | + ? EE_Registry::instance()->CFG->organization->get_pretty('linkedin') |
|
453 | + : ''; |
|
454 | + $this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest) |
|
455 | + ? EE_Registry::instance()->CFG->organization->get_pretty('pinterest') |
|
456 | + : ''; |
|
457 | + $this->_template_args['organization_google'] = isset(EE_Registry::instance()->CFG->organization->google) |
|
458 | + ? EE_Registry::instance()->CFG->organization->get_pretty('google') |
|
459 | + : ''; |
|
460 | + $this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram) |
|
461 | + ? EE_Registry::instance()->CFG->organization->get_pretty('instagram') |
|
462 | + : ''; |
|
463 | + //UXIP settings |
|
464 | + $this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin) |
|
465 | + ? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin') |
|
466 | + : true; |
|
467 | + |
|
468 | + $STA_ID = isset(EE_Registry::instance()->CFG->organization->STA_ID) |
|
469 | + ? EE_Registry::instance()->CFG->organization->STA_ID |
|
470 | + : 4; |
|
471 | + $this->_template_args['states'] = new EE_Question_Form_Input( |
|
472 | + EE_Question::new_instance(array( |
|
473 | + 'QST_ID' => 0, |
|
474 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
475 | + 'QST_system' => 'admin-state', |
|
476 | + )), |
|
477 | + EE_Answer::new_instance(array( |
|
478 | + 'ANS_ID' => 0, |
|
479 | + 'ANS_value' => $STA_ID, |
|
480 | + )), |
|
481 | + array( |
|
482 | + 'input_id' => 'organization_state', |
|
483 | + 'input_name' => 'organization_state', |
|
484 | + 'input_prefix' => '', |
|
485 | + 'append_qstn_id' => false, |
|
486 | + ) |
|
487 | + ); |
|
488 | + |
|
489 | + $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
490 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
491 | + : 'US'; |
|
492 | + $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
493 | + EE_Question::new_instance(array( |
|
494 | + 'QST_ID' => 0, |
|
495 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
496 | + 'QST_system' => 'admin-country', |
|
497 | + )), |
|
498 | + EE_Answer::new_instance(array( |
|
499 | + 'ANS_ID' => 0, |
|
500 | + 'ANS_value' => $CNT_ISO, |
|
501 | + )), |
|
502 | + array( |
|
503 | + 'input_id' => 'organization_country', |
|
504 | + 'input_name' => 'organization_country', |
|
505 | + 'input_prefix' => '', |
|
506 | + 'append_qstn_id' => false, |
|
507 | + ) |
|
508 | + ); |
|
509 | + |
|
510 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
511 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
512 | + |
|
513 | + //PUE verification stuff |
|
514 | + $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
|
515 | + $verify_fail = get_option($ver_option_key); |
|
516 | + $this->_template_args['site_license_key_verified'] = $verify_fail |
|
517 | + || ! empty($verify_fail) |
|
518 | + || (empty($this->_template_args['site_license_key']) |
|
519 | + && empty($verify_fail) |
|
520 | + ) |
|
521 | + ? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' |
|
522 | + : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>'; |
|
523 | + |
|
524 | + $this->_set_add_edit_form_tags('update_your_organization_settings'); |
|
525 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
526 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
527 | + GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php', |
|
528 | + $this->_template_args, |
|
529 | + true |
|
530 | + ); |
|
531 | + |
|
532 | + $this->display_admin_page_with_sidebar(); |
|
533 | + } |
|
534 | + |
|
535 | + |
|
536 | + /** |
|
537 | + * Handler for updating organziation settings. |
|
538 | + */ |
|
539 | + protected function _update_your_organization_settings() |
|
540 | + { |
|
541 | + if (is_main_site()) { |
|
542 | + EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key']) |
|
543 | + ? sanitize_text_field($this->_req_data['site_license_key']) |
|
544 | + : EE_Registry::instance()->NET_CFG->core->site_license_key; |
|
545 | + } |
|
546 | + EE_Registry::instance()->CFG->organization->name = isset($this->_req_data['organization_name']) |
|
547 | + ? sanitize_text_field($this->_req_data['organization_name']) |
|
548 | + : EE_Registry::instance()->CFG->organization->name; |
|
549 | + EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1']) |
|
550 | + ? sanitize_text_field($this->_req_data['organization_address_1']) |
|
551 | + : EE_Registry::instance()->CFG->organization->address_1; |
|
552 | + EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2']) |
|
553 | + ? sanitize_text_field($this->_req_data['organization_address_2']) |
|
554 | + : EE_Registry::instance()->CFG->organization->address_2; |
|
555 | + EE_Registry::instance()->CFG->organization->city = isset($this->_req_data['organization_city']) |
|
556 | + ? sanitize_text_field($this->_req_data['organization_city']) |
|
557 | + : EE_Registry::instance()->CFG->organization->city; |
|
558 | + EE_Registry::instance()->CFG->organization->STA_ID = isset($this->_req_data['organization_state']) |
|
559 | + ? absint($this->_req_data['organization_state']) |
|
560 | + : EE_Registry::instance()->CFG->organization->STA_ID; |
|
561 | + EE_Registry::instance()->CFG->organization->CNT_ISO = isset($this->_req_data['organization_country']) |
|
562 | + ? sanitize_text_field($this->_req_data['organization_country']) |
|
563 | + : EE_Registry::instance()->CFG->organization->CNT_ISO; |
|
564 | + EE_Registry::instance()->CFG->organization->zip = isset($this->_req_data['organization_zip']) |
|
565 | + ? sanitize_text_field($this->_req_data['organization_zip']) |
|
566 | + : EE_Registry::instance()->CFG->organization->zip; |
|
567 | + EE_Registry::instance()->CFG->organization->email = isset($this->_req_data['organization_email']) |
|
568 | + ? sanitize_email($this->_req_data['organization_email']) |
|
569 | + : EE_Registry::instance()->CFG->organization->email; |
|
570 | + EE_Registry::instance()->CFG->organization->vat = isset($this->_req_data['organization_vat']) |
|
571 | + ? sanitize_text_field($this->_req_data['organization_vat']) |
|
572 | + : EE_Registry::instance()->CFG->organization->vat; |
|
573 | + EE_Registry::instance()->CFG->organization->phone = isset($this->_req_data['organization_phone']) |
|
574 | + ? sanitize_text_field($this->_req_data['organization_phone']) |
|
575 | + : EE_Registry::instance()->CFG->organization->phone; |
|
576 | + EE_Registry::instance()->CFG->organization->logo_url = isset($this->_req_data['organization_logo_url']) |
|
577 | + ? esc_url_raw($this->_req_data['organization_logo_url']) |
|
578 | + : EE_Registry::instance()->CFG->organization->logo_url; |
|
579 | + EE_Registry::instance()->CFG->organization->facebook = isset($this->_req_data['organization_facebook']) |
|
580 | + ? esc_url_raw($this->_req_data['organization_facebook']) |
|
581 | + : EE_Registry::instance()->CFG->organization->facebook; |
|
582 | + EE_Registry::instance()->CFG->organization->twitter = isset($this->_req_data['organization_twitter']) |
|
583 | + ? esc_url_raw($this->_req_data['organization_twitter']) |
|
584 | + : EE_Registry::instance()->CFG->organization->twitter; |
|
585 | + EE_Registry::instance()->CFG->organization->linkedin = isset($this->_req_data['organization_linkedin']) |
|
586 | + ? esc_url_raw($this->_req_data['organization_linkedin']) |
|
587 | + : EE_Registry::instance()->CFG->organization->linkedin; |
|
588 | + EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest']) |
|
589 | + ? esc_url_raw($this->_req_data['organization_pinterest']) |
|
590 | + : EE_Registry::instance()->CFG->organization->pinterest; |
|
591 | + EE_Registry::instance()->CFG->organization->google = isset($this->_req_data['organization_google']) |
|
592 | + ? esc_url_raw($this->_req_data['organization_google']) |
|
593 | + : EE_Registry::instance()->CFG->organization->google; |
|
594 | + EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram']) |
|
595 | + ? esc_url_raw($this->_req_data['organization_instagram']) |
|
596 | + : EE_Registry::instance()->CFG->organization->instagram; |
|
597 | + EE_Registry::instance()->CFG->core->ee_ueip_optin = isset($this->_req_data['ueip_optin']) |
|
598 | + && ! empty($this->_req_data['ueip_optin']) |
|
599 | + ? $this->_req_data['ueip_optin'] |
|
600 | + : EE_Registry::instance()->CFG->core->ee_ueip_optin; |
|
601 | + |
|
602 | + EE_Registry::instance()->CFG->currency = new EE_Currency_Config( |
|
603 | + EE_Registry::instance()->CFG->organization->CNT_ISO |
|
604 | + ); |
|
605 | + |
|
606 | + EE_Registry::instance()->CFG = apply_filters( |
|
607 | + 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', |
|
608 | + EE_Registry::instance()->CFG |
|
609 | + ); |
|
610 | + |
|
611 | + $what = 'Your Organization Settings'; |
|
612 | + $success = $this->_update_espresso_configuration( |
|
613 | + $what, |
|
614 | + EE_Registry::instance()->CFG, |
|
615 | + __FILE__, |
|
616 | + __FUNCTION__, |
|
617 | + __LINE__ |
|
618 | + ); |
|
619 | + |
|
620 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default')); |
|
621 | + } |
|
622 | + |
|
623 | + |
|
624 | + |
|
625 | + /************* Admin Options *************/ |
|
626 | + |
|
627 | + |
|
628 | + /** |
|
629 | + * _admin_option_settings |
|
630 | + * |
|
631 | + * @throws \EE_Error |
|
632 | + * @throws \LogicException |
|
633 | + */ |
|
634 | + protected function _admin_option_settings() |
|
635 | + { |
|
636 | + $this->_template_args['admin_page_content'] = ''; |
|
637 | + try { |
|
638 | + $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
639 | + // still need this for the old school form in Extend_General_Settings_Admin_Page |
|
640 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
641 | + // also need to account for the do_action that was in the old template |
|
642 | + $admin_options_settings_form->setTemplateArgs($this->_template_args); |
|
643 | + $this->_template_args['admin_page_content'] = $admin_options_settings_form->display(); |
|
644 | + } catch (Exception $e) { |
|
645 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
646 | + } |
|
647 | + $this->_set_add_edit_form_tags('update_admin_option_settings'); |
|
648 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
649 | + $this->display_admin_page_with_sidebar(); |
|
650 | + } |
|
651 | + |
|
652 | + |
|
653 | + /** |
|
654 | + * _update_admin_option_settings |
|
655 | + * |
|
656 | + * @throws \EE_Error |
|
657 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
658 | + * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException |
|
659 | + * @throws \InvalidArgumentException |
|
660 | + * @throws \LogicException |
|
661 | + */ |
|
662 | + protected function _update_admin_option_settings() |
|
663 | + { |
|
664 | + try { |
|
665 | + $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
666 | + $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]); |
|
667 | + EE_Registry::instance()->CFG->admin = apply_filters( |
|
668 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
669 | + EE_Registry::instance()->CFG->admin |
|
670 | + ); |
|
671 | + } catch (Exception $e) { |
|
672 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
673 | + } |
|
674 | + $this->_redirect_after_action( |
|
675 | + apply_filters( |
|
676 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', |
|
677 | + $this->_update_espresso_configuration( |
|
678 | + 'Admin Options', |
|
679 | + EE_Registry::instance()->CFG->admin, |
|
680 | + __FILE__, __FUNCTION__, __LINE__ |
|
681 | + ) |
|
682 | + ), |
|
683 | + 'Admin Options', |
|
684 | + 'updated', |
|
685 | + array('action' => 'admin_option_settings') |
|
686 | + ); |
|
687 | + |
|
688 | + } |
|
689 | + |
|
690 | + |
|
691 | + /************* Countries *************/ |
|
692 | + |
|
693 | + |
|
694 | + /** |
|
695 | + * Output Country Settings view. |
|
696 | + * @throws DomainException |
|
697 | + * @throws EE_Error |
|
698 | + */ |
|
699 | + protected function _country_settings() |
|
700 | + { |
|
701 | + $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
702 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
703 | + : 'US'; |
|
704 | + $CNT_ISO = isset($this->_req_data['country']) |
|
705 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
706 | + : $CNT_ISO; |
|
707 | + |
|
708 | + //load field generator helper |
|
709 | + |
|
710 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
711 | + |
|
712 | + $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
713 | + EE_Question::new_instance(array( |
|
714 | + 'QST_ID' => 0, |
|
715 | + 'QST_display_text' => __('Select Country', 'event_espresso'), |
|
716 | + 'QST_system' => 'admin-country', |
|
717 | + )), |
|
718 | + EE_Answer::new_instance(array( |
|
719 | + 'ANS_ID' => 0, |
|
720 | + 'ANS_value' => $CNT_ISO, |
|
721 | + )), |
|
722 | + array( |
|
723 | + 'input_id' => 'country', |
|
724 | + 'input_name' => 'country', |
|
725 | + 'input_prefix' => '', |
|
726 | + 'append_qstn_id' => false, |
|
727 | + ) |
|
728 | + ); |
|
729 | + |
|
730 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
731 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
732 | + $this->_template_args['country_details_settings'] = $this->display_country_settings(); |
|
733 | + $this->_template_args['country_states_settings'] = $this->display_country_states(); |
|
734 | + |
|
735 | + $this->_set_add_edit_form_tags('update_country_settings'); |
|
736 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
737 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
738 | + GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
739 | + $this->_template_args, |
|
740 | + true |
|
741 | + ); |
|
742 | + $this->display_admin_page_with_no_sidebar(); |
|
743 | + } |
|
744 | + |
|
745 | + |
|
746 | + /** |
|
747 | + * display_country_settings |
|
748 | + * |
|
749 | + * @access public |
|
750 | + * @param string $CNT_ISO |
|
751 | + * @return mixed string | array |
|
752 | + * @throws DomainException |
|
753 | + */ |
|
754 | + public function display_country_settings($CNT_ISO = '') |
|
755 | + { |
|
756 | + |
|
757 | + $CNT_ISO = isset($this->_req_data['country']) |
|
758 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
759 | + : $CNT_ISO; |
|
760 | + if (! $CNT_ISO) { |
|
761 | + return ''; |
|
762 | + } |
|
763 | + |
|
764 | + // for ajax |
|
765 | + remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
766 | + remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
767 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
768 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
769 | + $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
770 | + |
|
771 | + $country_input_types = array( |
|
772 | + 'CNT_active' => array( |
|
773 | + 'type' => 'RADIO_BTN', |
|
774 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
775 | + 'class' => '', |
|
776 | + 'options' => $this->_yes_no_values, |
|
777 | + 'use_desc_4_label' => true, |
|
778 | + ), |
|
779 | + 'CNT_ISO' => array( |
|
780 | + 'type' => 'TEXT', |
|
781 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
782 | + 'class' => 'small-text', |
|
783 | + ), |
|
784 | + 'CNT_ISO3' => array( |
|
785 | + 'type' => 'TEXT', |
|
786 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
787 | + 'class' => 'small-text', |
|
788 | + ), |
|
789 | + 'RGN_ID' => array( |
|
790 | + 'type' => 'TEXT', |
|
791 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
792 | + 'class' => 'small-text', |
|
793 | + ), |
|
794 | + 'CNT_name' => array( |
|
795 | + 'type' => 'TEXT', |
|
796 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
797 | + 'class' => 'regular-text', |
|
798 | + ), |
|
799 | + 'CNT_cur_code' => array( |
|
800 | + 'type' => 'TEXT', |
|
801 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
802 | + 'class' => 'small-text', |
|
803 | + ), |
|
804 | + 'CNT_cur_single' => array( |
|
805 | + 'type' => 'TEXT', |
|
806 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
807 | + 'class' => 'medium-text', |
|
808 | + ), |
|
809 | + 'CNT_cur_plural' => array( |
|
810 | + 'type' => 'TEXT', |
|
811 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
812 | + 'class' => 'medium-text', |
|
813 | + ), |
|
814 | + 'CNT_cur_sign' => array( |
|
815 | + 'type' => 'TEXT', |
|
816 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
817 | + 'class' => 'small-text', |
|
818 | + 'htmlentities' => false, |
|
819 | + ), |
|
820 | + 'CNT_cur_sign_b4' => array( |
|
821 | + 'type' => 'RADIO_BTN', |
|
822 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
823 | + 'class' => '', |
|
824 | + 'options' => $this->_yes_no_values, |
|
825 | + 'use_desc_4_label' => true, |
|
826 | + ), |
|
827 | + 'CNT_cur_dec_plc' => array( |
|
828 | + 'type' => 'RADIO_BTN', |
|
829 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
830 | + 'class' => '', |
|
831 | + 'options' => array( |
|
832 | + array('id' => 0, 'text' => ''), |
|
833 | + array('id' => 1, 'text' => ''), |
|
834 | + array('id' => 2, 'text' => ''), |
|
835 | + array('id' => 3, 'text' => ''), |
|
836 | + ), |
|
837 | + ), |
|
838 | + 'CNT_cur_dec_mrk' => array( |
|
839 | + 'type' => 'RADIO_BTN', |
|
840 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
841 | + 'class' => '', |
|
842 | + 'options' => array( |
|
843 | + array( |
|
844 | + 'id' => ',', |
|
845 | + 'text' => __(', (comma)', 'event_espresso'), |
|
846 | + ), |
|
847 | + array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')), |
|
848 | + ), |
|
849 | + 'use_desc_4_label' => true, |
|
850 | + ), |
|
851 | + 'CNT_cur_thsnds' => array( |
|
852 | + 'type' => 'RADIO_BTN', |
|
853 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
854 | + 'class' => '', |
|
855 | + 'options' => array( |
|
856 | + array( |
|
857 | + 'id' => ',', |
|
858 | + 'text' => __(', (comma)', 'event_espresso'), |
|
859 | + ), |
|
860 | + array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')), |
|
861 | + ), |
|
862 | + 'use_desc_4_label' => true, |
|
863 | + ), |
|
864 | + 'CNT_tel_code' => array( |
|
865 | + 'type' => 'TEXT', |
|
866 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
867 | + 'class' => 'small-text', |
|
868 | + ), |
|
869 | + 'CNT_is_EU' => array( |
|
870 | + 'type' => 'RADIO_BTN', |
|
871 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
872 | + 'class' => '', |
|
873 | + 'options' => $this->_yes_no_values, |
|
874 | + 'use_desc_4_label' => true, |
|
875 | + ), |
|
876 | + ); |
|
877 | + $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
878 | + $country, |
|
879 | + $country_input_types |
|
880 | + ); |
|
881 | + $country_details_settings = EEH_Template::display_template( |
|
882 | + GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
883 | + $this->_template_args, |
|
884 | + true |
|
885 | + ); |
|
886 | + |
|
887 | + if (defined('DOING_AJAX')) { |
|
888 | + $notices = EE_Error::get_notices(false, false, false); |
|
889 | + echo wp_json_encode(array( |
|
890 | + 'return_data' => $country_details_settings, |
|
891 | + 'success' => $notices['success'], |
|
892 | + 'errors' => $notices['errors'], |
|
893 | + )); |
|
894 | + die(); |
|
895 | + } else { |
|
896 | + return $country_details_settings; |
|
897 | + } |
|
898 | + } |
|
899 | + |
|
900 | + |
|
901 | + /** |
|
902 | + * display_country_states |
|
903 | + * |
|
904 | + * @access public |
|
905 | + * @param string $CNT_ISO |
|
906 | + * @return string |
|
907 | + * @throws DomainException |
|
908 | + */ |
|
909 | + public function display_country_states($CNT_ISO = '') |
|
910 | + { |
|
911 | + |
|
912 | + $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; |
|
913 | + |
|
914 | + if (! $CNT_ISO) { |
|
915 | + return ''; |
|
916 | + } |
|
917 | + // for ajax |
|
918 | + remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
919 | + remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
920 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2); |
|
921 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2); |
|
922 | + $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO)); |
|
923 | + |
|
924 | + if ($states) { |
|
925 | + foreach ($states as $STA_ID => $state) { |
|
926 | + if ($state instanceof EE_State) { |
|
927 | + //STA_abbrev STA_name STA_active |
|
928 | + $state_input_types = array( |
|
929 | + 'STA_abbrev' => array( |
|
930 | + 'type' => 'TEXT', |
|
931 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
932 | + 'class' => 'mid-text', |
|
933 | + ), |
|
934 | + 'STA_name' => array( |
|
935 | + 'type' => 'TEXT', |
|
936 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
937 | + 'class' => 'regular-text', |
|
938 | + ), |
|
939 | + 'STA_active' => array( |
|
940 | + 'type' => 'RADIO_BTN', |
|
941 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
942 | + 'options' => $this->_yes_no_values, |
|
943 | + 'use_desc_4_label' => true, |
|
944 | + ), |
|
945 | + ); |
|
946 | + $this->_template_args['states'][$STA_ID]['inputs'] = |
|
947 | + EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
948 | + $state, |
|
949 | + $state_input_types |
|
950 | + ); |
|
951 | + $query_args = array( |
|
952 | + 'action' => 'delete_state', |
|
953 | + 'STA_ID' => $STA_ID, |
|
954 | + 'CNT_ISO' => $CNT_ISO, |
|
955 | + 'STA_abbrev' => $state->abbrev(), |
|
956 | + ); |
|
957 | + $this->_template_args['states'][$STA_ID]['delete_state_url'] = |
|
958 | + EE_Admin_Page::add_query_args_and_nonce( |
|
959 | + $query_args, |
|
960 | + GEN_SET_ADMIN_URL |
|
961 | + ); |
|
962 | + } |
|
963 | + } |
|
964 | + } else { |
|
965 | + $this->_template_args['states'] = false; |
|
966 | + } |
|
967 | + |
|
968 | + $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
969 | + array('action' => 'add_new_state'), |
|
970 | + GEN_SET_ADMIN_URL |
|
971 | + ); |
|
972 | + |
|
973 | + $state_details_settings = EEH_Template::display_template( |
|
974 | + GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
975 | + $this->_template_args, |
|
976 | + true |
|
977 | + ); |
|
978 | + |
|
979 | + if (defined('DOING_AJAX')) { |
|
980 | + $notices = EE_Error::get_notices(false, false, false); |
|
981 | + echo wp_json_encode(array( |
|
982 | + 'return_data' => $state_details_settings, |
|
983 | + 'success' => $notices['success'], |
|
984 | + 'errors' => $notices['errors'], |
|
985 | + )); |
|
986 | + die(); |
|
987 | + } else { |
|
988 | + return $state_details_settings; |
|
989 | + } |
|
990 | + } |
|
991 | + |
|
992 | + |
|
993 | + /** |
|
994 | + * add_new_state |
|
995 | + * |
|
996 | + * @access public |
|
997 | + * @return void |
|
998 | + * @throws EE_Error |
|
999 | + */ |
|
1000 | + public function add_new_state() |
|
1001 | + { |
|
1002 | + |
|
1003 | + $success = true; |
|
1004 | + |
|
1005 | + $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
1006 | + ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
1007 | + : false; |
|
1008 | + if (! $CNT_ISO) { |
|
1009 | + EE_Error::add_error( |
|
1010 | + __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
1011 | + __FILE__, |
|
1012 | + __FUNCTION__, |
|
1013 | + __LINE__ |
|
1014 | + ); |
|
1015 | + $success = false; |
|
1016 | + } |
|
1017 | + $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
1018 | + ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
1019 | + : false; |
|
1020 | + if (! $STA_abbrev) { |
|
1021 | + EE_Error::add_error( |
|
1022 | + __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
|
1023 | + __FILE__, |
|
1024 | + __FUNCTION__, |
|
1025 | + __LINE__ |
|
1026 | + ); |
|
1027 | + $success = false; |
|
1028 | + } |
|
1029 | + $STA_name = isset($this->_req_data['STA_name']) |
|
1030 | + ? sanitize_text_field($this->_req_data['STA_name']) |
|
1031 | + : false; |
|
1032 | + if (! $STA_name) { |
|
1033 | + EE_Error::add_error( |
|
1034 | + __('No State name or an invalid State name was received.', 'event_espresso'), |
|
1035 | + __FILE__, |
|
1036 | + __FUNCTION__, |
|
1037 | + __LINE__ |
|
1038 | + ); |
|
1039 | + $success = false; |
|
1040 | + } |
|
1041 | + |
|
1042 | + if ($success) { |
|
1043 | + $cols_n_values = array( |
|
1044 | + 'CNT_ISO' => $CNT_ISO, |
|
1045 | + 'STA_abbrev' => $STA_abbrev, |
|
1046 | + 'STA_name' => $STA_name, |
|
1047 | + 'STA_active' => true, |
|
1048 | + ); |
|
1049 | + $success = EEM_State::instance()->insert($cols_n_values); |
|
1050 | + EE_Error::add_success(__('The State was added successfully.', 'event_espresso')); |
|
1051 | + } |
|
1052 | + |
|
1053 | + if (defined('DOING_AJAX')) { |
|
1054 | + $notices = EE_Error::get_notices(false, false, false); |
|
1055 | + echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO))); |
|
1056 | + die(); |
|
1057 | + } else { |
|
1058 | + $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings')); |
|
1059 | + } |
|
1060 | + } |
|
1061 | + |
|
1062 | + |
|
1063 | + /** |
|
1064 | + * delete_state |
|
1065 | + * |
|
1066 | + * @access public |
|
1067 | + * @return boolean |
|
1068 | + */ |
|
1069 | + public function delete_state() |
|
1070 | + { |
|
1071 | + $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
1072 | + ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
1073 | + : false; |
|
1074 | + $STA_ID = isset($this->_req_data['STA_ID']) |
|
1075 | + ? sanitize_text_field($this->_req_data['STA_ID']) |
|
1076 | + : false; |
|
1077 | + $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
1078 | + ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
1079 | + : false; |
|
1080 | + if (! $STA_ID) { |
|
1081 | + EE_Error::add_error( |
|
1082 | + __('No State ID or an invalid State ID was received.', 'event_espresso'), |
|
1083 | + __FILE__, |
|
1084 | + __FUNCTION__, |
|
1085 | + __LINE__ |
|
1086 | + ); |
|
1087 | + return false; |
|
1088 | + } |
|
1089 | + |
|
1090 | + $success = EEM_State::instance()->delete_by_ID($STA_ID); |
|
1091 | + if ($success !== false) { |
|
1092 | + do_action( |
|
1093 | + 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
1094 | + $CNT_ISO, |
|
1095 | + $STA_ID, |
|
1096 | + array('STA_abbrev' => $STA_abbrev) |
|
1097 | + ); |
|
1098 | + EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso')); |
|
1099 | + } |
|
1100 | + if (defined('DOING_AJAX')) { |
|
1101 | + $notices = EE_Error::get_notices(false, false); |
|
1102 | + $notices['return_data'] = true; |
|
1103 | + echo wp_json_encode($notices); |
|
1104 | + die(); |
|
1105 | + } else { |
|
1106 | + $this->_redirect_after_action( |
|
1107 | + $success, |
|
1108 | + 'State', |
|
1109 | + 'deleted', |
|
1110 | + array('action' => 'country_settings') |
|
1111 | + ); |
|
1112 | + } |
|
1113 | + } |
|
1114 | + |
|
1115 | + |
|
1116 | + /** |
|
1117 | + * _update_country_settings |
|
1118 | + * |
|
1119 | + * @access protected |
|
1120 | + * @return void |
|
1121 | + * @throws EE_Error |
|
1122 | + */ |
|
1123 | + protected function _update_country_settings() |
|
1124 | + { |
|
1125 | + // grab the country ISO code |
|
1126 | + $CNT_ISO = isset($this->_req_data['country']) |
|
1127 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
1128 | + : false; |
|
1129 | + if (! $CNT_ISO) { |
|
1130 | + EE_Error::add_error( |
|
1131 | + __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
1132 | + __FILE__, |
|
1133 | + __FUNCTION__, |
|
1134 | + __LINE__ |
|
1135 | + ); |
|
1136 | + |
|
1137 | + return; |
|
1138 | + } |
|
1139 | + $cols_n_values = array(); |
|
1140 | + $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']) |
|
1141 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])) |
|
1142 | + : false; |
|
1143 | + $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) |
|
1144 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) |
|
1145 | + : null; |
|
1146 | + $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) |
|
1147 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) |
|
1148 | + : null; |
|
1149 | + $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']) |
|
1150 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) |
|
1151 | + : 'USD'; |
|
1152 | + $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) |
|
1153 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) |
|
1154 | + : 'dollar'; |
|
1155 | + $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) |
|
1156 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) |
|
1157 | + : 'dollars'; |
|
1158 | + $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) |
|
1159 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) |
|
1160 | + : '$'; |
|
1161 | + $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) |
|
1162 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) |
|
1163 | + : true; |
|
1164 | + $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) |
|
1165 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) |
|
1166 | + : 2; |
|
1167 | + $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) |
|
1168 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) |
|
1169 | + : '.'; |
|
1170 | + $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) |
|
1171 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) |
|
1172 | + : ','; |
|
1173 | + $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) |
|
1174 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) |
|
1175 | + : null; |
|
1176 | + $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) |
|
1177 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) |
|
1178 | + : false; |
|
1179 | + $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) |
|
1180 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) |
|
1181 | + : false; |
|
1182 | + // allow filtering of country data |
|
1183 | + $cols_n_values = apply_filters( |
|
1184 | + 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', |
|
1185 | + $cols_n_values |
|
1186 | + ); |
|
1187 | + |
|
1188 | + // where values |
|
1189 | + $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO)); |
|
1190 | + // run the update |
|
1191 | + $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values); |
|
1192 | + |
|
1193 | + if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) { |
|
1194 | + // allow filtering of states data |
|
1195 | + $states = apply_filters( |
|
1196 | + 'FHEE__General_Settings_Admin_Page___update_country_settings__states', |
|
1197 | + $this->_req_data['states'] |
|
1198 | + ); |
|
1199 | + |
|
1200 | + // loop thru state data ( looks like : states[75][STA_name] ) |
|
1201 | + foreach ($states as $STA_ID => $state) { |
|
1202 | + $cols_n_values = array( |
|
1203 | + 'CNT_ISO' => $CNT_ISO, |
|
1204 | + 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
|
1205 | + 'STA_name' => sanitize_text_field($state['STA_name']), |
|
1206 | + 'STA_active' => (bool)absint($state['STA_active']), |
|
1207 | + ); |
|
1208 | + // where values |
|
1209 | + $where_cols_n_values = array(array('STA_ID' => $STA_ID)); |
|
1210 | + // run the update |
|
1211 | + $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values); |
|
1212 | + if ($success !== false) { |
|
1213 | + do_action( |
|
1214 | + 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
1215 | + $CNT_ISO, |
|
1216 | + $STA_ID, |
|
1217 | + $cols_n_values |
|
1218 | + ); |
|
1219 | + } |
|
1220 | + } |
|
1221 | + } |
|
1222 | + // check if country being edited matches org option country, and if so, then update EE_Config with new settings |
|
1223 | + if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
1224 | + && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO |
|
1225 | + ) { |
|
1226 | + EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO); |
|
1227 | + EE_Registry::instance()->CFG->update_espresso_config(); |
|
1228 | + } |
|
1229 | + |
|
1230 | + if ($success !== false) { |
|
1231 | + EE_Error::add_success( |
|
1232 | + esc_html__('Country Settings updated successfully.', 'event_espresso') |
|
1233 | + ); |
|
1234 | + } |
|
1235 | + $this->_redirect_after_action( |
|
1236 | + $success, |
|
1237 | + '', |
|
1238 | + '', |
|
1239 | + array('action' => 'country_settings', 'country' => $CNT_ISO), |
|
1240 | + true |
|
1241 | + ); |
|
1242 | + } |
|
1243 | + |
|
1244 | + |
|
1245 | + /** |
|
1246 | + * form_form_field_label_wrap |
|
1247 | + * |
|
1248 | + * @access public |
|
1249 | + * @param string $label |
|
1250 | + * @return string |
|
1251 | + */ |
|
1252 | + public function country_form_field_label_wrap($label, $required_text) |
|
1253 | + { |
|
1254 | + return ' |
|
1255 | 1255 | <tr> |
1256 | 1256 | <th> |
1257 | 1257 | ' . $label . ' |
1258 | 1258 | </th>'; |
1259 | - } |
|
1260 | - |
|
1261 | - |
|
1262 | - /** |
|
1263 | - * form_form_field_input__wrap |
|
1264 | - * |
|
1265 | - * @access public |
|
1266 | - * @param string $label |
|
1267 | - * @return string |
|
1268 | - */ |
|
1269 | - public function country_form_field_input__wrap($input, $label) |
|
1270 | - { |
|
1271 | - return ' |
|
1259 | + } |
|
1260 | + |
|
1261 | + |
|
1262 | + /** |
|
1263 | + * form_form_field_input__wrap |
|
1264 | + * |
|
1265 | + * @access public |
|
1266 | + * @param string $label |
|
1267 | + * @return string |
|
1268 | + */ |
|
1269 | + public function country_form_field_input__wrap($input, $label) |
|
1270 | + { |
|
1271 | + return ' |
|
1272 | 1272 | <td class="general-settings-country-input-td"> |
1273 | 1273 | ' . $input . ' |
1274 | 1274 | </td> |
1275 | 1275 | </tr>'; |
1276 | - } |
|
1277 | - |
|
1278 | - |
|
1279 | - /** |
|
1280 | - * form_form_field_label_wrap |
|
1281 | - * |
|
1282 | - * @access public |
|
1283 | - * @param string $label |
|
1284 | - * @param string $required_text |
|
1285 | - * @return string |
|
1286 | - */ |
|
1287 | - public function state_form_field_label_wrap($label, $required_text) |
|
1288 | - { |
|
1289 | - return $required_text; |
|
1290 | - } |
|
1291 | - |
|
1292 | - |
|
1293 | - /** |
|
1294 | - * form_form_field_input__wrap |
|
1295 | - * |
|
1296 | - * @access public |
|
1297 | - * @param string $label |
|
1298 | - * @return string |
|
1299 | - */ |
|
1300 | - public function state_form_field_input__wrap($input, $label) |
|
1301 | - { |
|
1302 | - return ' |
|
1276 | + } |
|
1277 | + |
|
1278 | + |
|
1279 | + /** |
|
1280 | + * form_form_field_label_wrap |
|
1281 | + * |
|
1282 | + * @access public |
|
1283 | + * @param string $label |
|
1284 | + * @param string $required_text |
|
1285 | + * @return string |
|
1286 | + */ |
|
1287 | + public function state_form_field_label_wrap($label, $required_text) |
|
1288 | + { |
|
1289 | + return $required_text; |
|
1290 | + } |
|
1291 | + |
|
1292 | + |
|
1293 | + /** |
|
1294 | + * form_form_field_input__wrap |
|
1295 | + * |
|
1296 | + * @access public |
|
1297 | + * @param string $label |
|
1298 | + * @return string |
|
1299 | + */ |
|
1300 | + public function state_form_field_input__wrap($input, $label) |
|
1301 | + { |
|
1302 | + return ' |
|
1303 | 1303 | <td class="general-settings-country-state-input-td"> |
1304 | 1304 | ' . $input . ' |
1305 | 1305 | </td>'; |
1306 | - } |
|
1307 | - |
|
1308 | - |
|
1309 | - /***********/ |
|
1310 | - |
|
1311 | - |
|
1312 | - /** |
|
1313 | - * displays edit and view links for critical EE pages |
|
1314 | - * |
|
1315 | - * @access public |
|
1316 | - * @param int $ee_page_id |
|
1317 | - * @return string |
|
1318 | - */ |
|
1319 | - public static function edit_view_links($ee_page_id) |
|
1320 | - { |
|
1321 | - $links = '<a href="' |
|
1322 | - . add_query_arg( |
|
1323 | - array('post' => $ee_page_id, 'action' => 'edit'), |
|
1324 | - admin_url('post.php') |
|
1325 | - ) |
|
1326 | - . '" >' |
|
1327 | - . __('Edit', 'event_espresso') |
|
1328 | - . '</a>'; |
|
1329 | - $links .= ' | '; |
|
1330 | - $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>'; |
|
1331 | - |
|
1332 | - return $links; |
|
1333 | - } |
|
1334 | - |
|
1335 | - |
|
1336 | - /** |
|
1337 | - * displays page and shortcode status for critical EE pages |
|
1338 | - * |
|
1339 | - * @param WP page object $ee_page |
|
1340 | - * @return string |
|
1341 | - */ |
|
1342 | - public static function page_and_shortcode_status($ee_page, $shortcode) |
|
1343 | - { |
|
1344 | - |
|
1345 | - // page status |
|
1346 | - if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') { |
|
1347 | - $pg_colour = 'green'; |
|
1348 | - $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), ' ', ' '); |
|
1349 | - } else { |
|
1350 | - $pg_colour = 'red'; |
|
1351 | - $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
|
1352 | - } |
|
1353 | - |
|
1354 | - // shortcode status |
|
1355 | - if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) { |
|
1356 | - $sc_colour = 'green'; |
|
1357 | - $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), ' '); |
|
1358 | - } else { |
|
1359 | - $sc_colour = 'red'; |
|
1360 | - $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
|
1361 | - } |
|
1362 | - |
|
1363 | - return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
1364 | - . $pg_status |
|
1365 | - . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1366 | - } |
|
1367 | - |
|
1368 | - |
|
1369 | - /** |
|
1370 | - * generates a dropdown of all parent pages - copied from WP core |
|
1371 | - * |
|
1372 | - * @param int $default |
|
1373 | - * @param int $parent |
|
1374 | - * @param int $level |
|
1375 | - */ |
|
1376 | - public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0) |
|
1377 | - { |
|
1378 | - global $wpdb; |
|
1379 | - $items = $wpdb->get_results( |
|
1380 | - $wpdb->prepare( |
|
1381 | - "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", |
|
1382 | - $parent |
|
1383 | - ) |
|
1384 | - ); |
|
1385 | - |
|
1386 | - if ($items) { |
|
1387 | - foreach ($items as $item) { |
|
1388 | - $pad = str_repeat(' ', $level * 3); |
|
1389 | - if ($item->ID == $default) { |
|
1390 | - $current = ' selected="selected"'; |
|
1391 | - } else { |
|
1392 | - $current = ''; |
|
1393 | - } |
|
1394 | - |
|
1395 | - echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " |
|
1396 | - . esc_html($item->post_title) |
|
1397 | - . "</option>"; |
|
1398 | - parent_dropdown($default, $item->ID, $level + 1); |
|
1399 | - } |
|
1400 | - } |
|
1401 | - } |
|
1306 | + } |
|
1307 | + |
|
1308 | + |
|
1309 | + /***********/ |
|
1310 | + |
|
1311 | + |
|
1312 | + /** |
|
1313 | + * displays edit and view links for critical EE pages |
|
1314 | + * |
|
1315 | + * @access public |
|
1316 | + * @param int $ee_page_id |
|
1317 | + * @return string |
|
1318 | + */ |
|
1319 | + public static function edit_view_links($ee_page_id) |
|
1320 | + { |
|
1321 | + $links = '<a href="' |
|
1322 | + . add_query_arg( |
|
1323 | + array('post' => $ee_page_id, 'action' => 'edit'), |
|
1324 | + admin_url('post.php') |
|
1325 | + ) |
|
1326 | + . '" >' |
|
1327 | + . __('Edit', 'event_espresso') |
|
1328 | + . '</a>'; |
|
1329 | + $links .= ' | '; |
|
1330 | + $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>'; |
|
1331 | + |
|
1332 | + return $links; |
|
1333 | + } |
|
1334 | + |
|
1335 | + |
|
1336 | + /** |
|
1337 | + * displays page and shortcode status for critical EE pages |
|
1338 | + * |
|
1339 | + * @param WP page object $ee_page |
|
1340 | + * @return string |
|
1341 | + */ |
|
1342 | + public static function page_and_shortcode_status($ee_page, $shortcode) |
|
1343 | + { |
|
1344 | + |
|
1345 | + // page status |
|
1346 | + if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') { |
|
1347 | + $pg_colour = 'green'; |
|
1348 | + $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), ' ', ' '); |
|
1349 | + } else { |
|
1350 | + $pg_colour = 'red'; |
|
1351 | + $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
|
1352 | + } |
|
1353 | + |
|
1354 | + // shortcode status |
|
1355 | + if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) { |
|
1356 | + $sc_colour = 'green'; |
|
1357 | + $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), ' '); |
|
1358 | + } else { |
|
1359 | + $sc_colour = 'red'; |
|
1360 | + $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
|
1361 | + } |
|
1362 | + |
|
1363 | + return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
1364 | + . $pg_status |
|
1365 | + . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1366 | + } |
|
1367 | + |
|
1368 | + |
|
1369 | + /** |
|
1370 | + * generates a dropdown of all parent pages - copied from WP core |
|
1371 | + * |
|
1372 | + * @param int $default |
|
1373 | + * @param int $parent |
|
1374 | + * @param int $level |
|
1375 | + */ |
|
1376 | + public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0) |
|
1377 | + { |
|
1378 | + global $wpdb; |
|
1379 | + $items = $wpdb->get_results( |
|
1380 | + $wpdb->prepare( |
|
1381 | + "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", |
|
1382 | + $parent |
|
1383 | + ) |
|
1384 | + ); |
|
1385 | + |
|
1386 | + if ($items) { |
|
1387 | + foreach ($items as $item) { |
|
1388 | + $pad = str_repeat(' ', $level * 3); |
|
1389 | + if ($item->ID == $default) { |
|
1390 | + $current = ' selected="selected"'; |
|
1391 | + } else { |
|
1392 | + $current = ''; |
|
1393 | + } |
|
1394 | + |
|
1395 | + echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " |
|
1396 | + . esc_html($item->post_title) |
|
1397 | + . "</option>"; |
|
1398 | + parent_dropdown($default, $item->ID, $level + 1); |
|
1399 | + } |
|
1400 | + } |
|
1401 | + } |
|
1402 | 1402 | } |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
233 | 233 | 'event_espresso' |
234 | 234 | ); |
235 | - EE_Registry::$i18n_js_strings['error_occurred'] = __( |
|
235 | + EE_Registry::$i18n_js_strings['error_occurred'] = __( |
|
236 | 236 | 'An error occurred! Please refresh the page and try again.', |
237 | 237 | 'event_espresso' |
238 | 238 | ); |
239 | - EE_Registry::$i18n_js_strings['confirm_delete_state'] = __( |
|
239 | + EE_Registry::$i18n_js_strings['confirm_delete_state'] = __( |
|
240 | 240 | 'Are you sure you want to delete this State / Province?', |
241 | 241 | 'event_espresso' |
242 | 242 | ); |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | wp_enqueue_script('thickbox'); |
269 | 269 | wp_register_script( |
270 | 270 | 'organization_settings', |
271 | - GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
271 | + GEN_SET_ASSETS_URL.'your_organization_settings.js', |
|
272 | 272 | array('jquery', 'media-upload', 'thickbox'), |
273 | 273 | EVENT_ESPRESSO_VERSION, |
274 | 274 | true |
275 | 275 | ); |
276 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
276 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
277 | 277 | wp_enqueue_script('organization_settings'); |
278 | 278 | wp_enqueue_style('organization-css'); |
279 | 279 | $confirm_image_delete = array( |
@@ -294,12 +294,12 @@ discard block |
||
294 | 294 | //scripts |
295 | 295 | wp_register_script( |
296 | 296 | 'gen_settings_countries', |
297 | - GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
297 | + GEN_SET_ASSETS_URL.'gen_settings_countries.js', |
|
298 | 298 | array('ee_admin_js'), |
299 | 299 | EVENT_ESPRESSO_VERSION, |
300 | 300 | true |
301 | 301 | ); |
302 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
302 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
303 | 303 | wp_enqueue_script('gen_settings_countries'); |
304 | 304 | wp_enqueue_style('organization-css'); |
305 | 305 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
346 | 346 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
347 | 347 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
348 | - GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
348 | + GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php', |
|
349 | 349 | $this->_template_args, |
350 | 350 | true |
351 | 351 | ); |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | EE_Registry::instance()->CFG->core, |
378 | 378 | $this->_req_data |
379 | 379 | ); |
380 | - $what = __('Critical Pages & Shortcodes', 'event_espresso'); |
|
380 | + $what = __('Critical Pages & Shortcodes', 'event_espresso'); |
|
381 | 381 | $this->_redirect_after_action( |
382 | 382 | $this->_update_espresso_configuration( |
383 | 383 | $what, |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | protected function _your_organization_settings() |
408 | 408 | { |
409 | 409 | |
410 | - $this->_template_args['site_license_key'] = isset( |
|
410 | + $this->_template_args['site_license_key'] = isset( |
|
411 | 411 | EE_Registry::instance()->NET_CFG->core->site_license_key |
412 | 412 | ) |
413 | 413 | ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key') |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
512 | 512 | |
513 | 513 | //PUE verification stuff |
514 | - $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
|
514 | + $ver_option_key = 'puvererr_'.basename(EE_PLUGIN_BASENAME); |
|
515 | 515 | $verify_fail = get_option($ver_option_key); |
516 | 516 | $this->_template_args['site_license_key_verified'] = $verify_fail |
517 | 517 | || ! empty($verify_fail) |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | $this->_set_add_edit_form_tags('update_your_organization_settings'); |
525 | 525 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
526 | 526 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
527 | - GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php', |
|
527 | + GEN_SET_TEMPLATE_PATH.'your_organization_settings.template.php', |
|
528 | 528 | $this->_template_args, |
529 | 529 | true |
530 | 530 | ); |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | $this->_set_add_edit_form_tags('update_country_settings'); |
736 | 736 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
737 | 737 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
738 | - GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
738 | + GEN_SET_TEMPLATE_PATH.'countries_settings.template.php', |
|
739 | 739 | $this->_template_args, |
740 | 740 | true |
741 | 741 | ); |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | $CNT_ISO = isset($this->_req_data['country']) |
758 | 758 | ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
759 | 759 | : $CNT_ISO; |
760 | - if (! $CNT_ISO) { |
|
760 | + if ( ! $CNT_ISO) { |
|
761 | 761 | return ''; |
762 | 762 | } |
763 | 763 | |
@@ -768,65 +768,65 @@ discard block |
||
768 | 768 | add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
769 | 769 | $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
770 | 770 | |
771 | - $country_input_types = array( |
|
771 | + $country_input_types = array( |
|
772 | 772 | 'CNT_active' => array( |
773 | 773 | 'type' => 'RADIO_BTN', |
774 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
774 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
775 | 775 | 'class' => '', |
776 | 776 | 'options' => $this->_yes_no_values, |
777 | 777 | 'use_desc_4_label' => true, |
778 | 778 | ), |
779 | 779 | 'CNT_ISO' => array( |
780 | 780 | 'type' => 'TEXT', |
781 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
781 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
782 | 782 | 'class' => 'small-text', |
783 | 783 | ), |
784 | 784 | 'CNT_ISO3' => array( |
785 | 785 | 'type' => 'TEXT', |
786 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
786 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
787 | 787 | 'class' => 'small-text', |
788 | 788 | ), |
789 | 789 | 'RGN_ID' => array( |
790 | 790 | 'type' => 'TEXT', |
791 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
791 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
792 | 792 | 'class' => 'small-text', |
793 | 793 | ), |
794 | 794 | 'CNT_name' => array( |
795 | 795 | 'type' => 'TEXT', |
796 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
796 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
797 | 797 | 'class' => 'regular-text', |
798 | 798 | ), |
799 | 799 | 'CNT_cur_code' => array( |
800 | 800 | 'type' => 'TEXT', |
801 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
801 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
802 | 802 | 'class' => 'small-text', |
803 | 803 | ), |
804 | 804 | 'CNT_cur_single' => array( |
805 | 805 | 'type' => 'TEXT', |
806 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
806 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
807 | 807 | 'class' => 'medium-text', |
808 | 808 | ), |
809 | 809 | 'CNT_cur_plural' => array( |
810 | 810 | 'type' => 'TEXT', |
811 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
811 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
812 | 812 | 'class' => 'medium-text', |
813 | 813 | ), |
814 | 814 | 'CNT_cur_sign' => array( |
815 | 815 | 'type' => 'TEXT', |
816 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
816 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
817 | 817 | 'class' => 'small-text', |
818 | 818 | 'htmlentities' => false, |
819 | 819 | ), |
820 | 820 | 'CNT_cur_sign_b4' => array( |
821 | 821 | 'type' => 'RADIO_BTN', |
822 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
822 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
823 | 823 | 'class' => '', |
824 | 824 | 'options' => $this->_yes_no_values, |
825 | 825 | 'use_desc_4_label' => true, |
826 | 826 | ), |
827 | 827 | 'CNT_cur_dec_plc' => array( |
828 | 828 | 'type' => 'RADIO_BTN', |
829 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
829 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
830 | 830 | 'class' => '', |
831 | 831 | 'options' => array( |
832 | 832 | array('id' => 0, 'text' => ''), |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | ), |
838 | 838 | 'CNT_cur_dec_mrk' => array( |
839 | 839 | 'type' => 'RADIO_BTN', |
840 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
840 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
841 | 841 | 'class' => '', |
842 | 842 | 'options' => array( |
843 | 843 | array( |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | ), |
851 | 851 | 'CNT_cur_thsnds' => array( |
852 | 852 | 'type' => 'RADIO_BTN', |
853 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
853 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
854 | 854 | 'class' => '', |
855 | 855 | 'options' => array( |
856 | 856 | array( |
@@ -863,12 +863,12 @@ discard block |
||
863 | 863 | ), |
864 | 864 | 'CNT_tel_code' => array( |
865 | 865 | 'type' => 'TEXT', |
866 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
866 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
867 | 867 | 'class' => 'small-text', |
868 | 868 | ), |
869 | 869 | 'CNT_is_EU' => array( |
870 | 870 | 'type' => 'RADIO_BTN', |
871 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
871 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
872 | 872 | 'class' => '', |
873 | 873 | 'options' => $this->_yes_no_values, |
874 | 874 | 'use_desc_4_label' => true, |
@@ -878,8 +878,8 @@ discard block |
||
878 | 878 | $country, |
879 | 879 | $country_input_types |
880 | 880 | ); |
881 | - $country_details_settings = EEH_Template::display_template( |
|
882 | - GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
881 | + $country_details_settings = EEH_Template::display_template( |
|
882 | + GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php', |
|
883 | 883 | $this->_template_args, |
884 | 884 | true |
885 | 885 | ); |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | |
912 | 912 | $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; |
913 | 913 | |
914 | - if (! $CNT_ISO) { |
|
914 | + if ( ! $CNT_ISO) { |
|
915 | 915 | return ''; |
916 | 916 | } |
917 | 917 | // for ajax |
@@ -925,20 +925,20 @@ discard block |
||
925 | 925 | foreach ($states as $STA_ID => $state) { |
926 | 926 | if ($state instanceof EE_State) { |
927 | 927 | //STA_abbrev STA_name STA_active |
928 | - $state_input_types = array( |
|
928 | + $state_input_types = array( |
|
929 | 929 | 'STA_abbrev' => array( |
930 | 930 | 'type' => 'TEXT', |
931 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
931 | + 'input_name' => 'states['.$STA_ID.']', |
|
932 | 932 | 'class' => 'mid-text', |
933 | 933 | ), |
934 | 934 | 'STA_name' => array( |
935 | 935 | 'type' => 'TEXT', |
936 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
936 | + 'input_name' => 'states['.$STA_ID.']', |
|
937 | 937 | 'class' => 'regular-text', |
938 | 938 | ), |
939 | 939 | 'STA_active' => array( |
940 | 940 | 'type' => 'RADIO_BTN', |
941 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
941 | + 'input_name' => 'states['.$STA_ID.']', |
|
942 | 942 | 'options' => $this->_yes_no_values, |
943 | 943 | 'use_desc_4_label' => true, |
944 | 944 | ), |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | $state, |
949 | 949 | $state_input_types |
950 | 950 | ); |
951 | - $query_args = array( |
|
951 | + $query_args = array( |
|
952 | 952 | 'action' => 'delete_state', |
953 | 953 | 'STA_ID' => $STA_ID, |
954 | 954 | 'CNT_ISO' => $CNT_ISO, |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | ); |
972 | 972 | |
973 | 973 | $state_details_settings = EEH_Template::display_template( |
974 | - GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
974 | + GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php', |
|
975 | 975 | $this->_template_args, |
976 | 976 | true |
977 | 977 | ); |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
1006 | 1006 | ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
1007 | 1007 | : false; |
1008 | - if (! $CNT_ISO) { |
|
1008 | + if ( ! $CNT_ISO) { |
|
1009 | 1009 | EE_Error::add_error( |
1010 | 1010 | __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
1011 | 1011 | __FILE__, |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
1018 | 1018 | ? sanitize_text_field($this->_req_data['STA_abbrev']) |
1019 | 1019 | : false; |
1020 | - if (! $STA_abbrev) { |
|
1020 | + if ( ! $STA_abbrev) { |
|
1021 | 1021 | EE_Error::add_error( |
1022 | 1022 | __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
1023 | 1023 | __FILE__, |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | $STA_name = isset($this->_req_data['STA_name']) |
1030 | 1030 | ? sanitize_text_field($this->_req_data['STA_name']) |
1031 | 1031 | : false; |
1032 | - if (! $STA_name) { |
|
1032 | + if ( ! $STA_name) { |
|
1033 | 1033 | EE_Error::add_error( |
1034 | 1034 | __('No State name or an invalid State name was received.', 'event_espresso'), |
1035 | 1035 | __FILE__, |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | 'STA_name' => $STA_name, |
1047 | 1047 | 'STA_active' => true, |
1048 | 1048 | ); |
1049 | - $success = EEM_State::instance()->insert($cols_n_values); |
|
1049 | + $success = EEM_State::instance()->insert($cols_n_values); |
|
1050 | 1050 | EE_Error::add_success(__('The State was added successfully.', 'event_espresso')); |
1051 | 1051 | } |
1052 | 1052 | |
@@ -1077,7 +1077,7 @@ discard block |
||
1077 | 1077 | $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
1078 | 1078 | ? sanitize_text_field($this->_req_data['STA_abbrev']) |
1079 | 1079 | : false; |
1080 | - if (! $STA_ID) { |
|
1080 | + if ( ! $STA_ID) { |
|
1081 | 1081 | EE_Error::add_error( |
1082 | 1082 | __('No State ID or an invalid State ID was received.', 'event_espresso'), |
1083 | 1083 | __FILE__, |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | $CNT_ISO = isset($this->_req_data['country']) |
1127 | 1127 | ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
1128 | 1128 | : false; |
1129 | - if (! $CNT_ISO) { |
|
1129 | + if ( ! $CNT_ISO) { |
|
1130 | 1130 | EE_Error::add_error( |
1131 | 1131 | __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
1132 | 1132 | __FILE__, |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | 'CNT_ISO' => $CNT_ISO, |
1204 | 1204 | 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
1205 | 1205 | 'STA_name' => sanitize_text_field($state['STA_name']), |
1206 | - 'STA_active' => (bool)absint($state['STA_active']), |
|
1206 | + 'STA_active' => (bool) absint($state['STA_active']), |
|
1207 | 1207 | ); |
1208 | 1208 | // where values |
1209 | 1209 | $where_cols_n_values = array(array('STA_ID' => $STA_ID)); |
@@ -1254,7 +1254,7 @@ discard block |
||
1254 | 1254 | return ' |
1255 | 1255 | <tr> |
1256 | 1256 | <th> |
1257 | - ' . $label . ' |
|
1257 | + ' . $label.' |
|
1258 | 1258 | </th>'; |
1259 | 1259 | } |
1260 | 1260 | |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | { |
1271 | 1271 | return ' |
1272 | 1272 | <td class="general-settings-country-input-td"> |
1273 | - ' . $input . ' |
|
1273 | + ' . $input.' |
|
1274 | 1274 | </td> |
1275 | 1275 | </tr>'; |
1276 | 1276 | } |
@@ -1301,7 +1301,7 @@ discard block |
||
1301 | 1301 | { |
1302 | 1302 | return ' |
1303 | 1303 | <td class="general-settings-country-state-input-td"> |
1304 | - ' . $input . ' |
|
1304 | + ' . $input.' |
|
1305 | 1305 | </td>'; |
1306 | 1306 | } |
1307 | 1307 | |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | . __('Edit', 'event_espresso') |
1328 | 1328 | . '</a>'; |
1329 | 1329 | $links .= ' | '; |
1330 | - $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>'; |
|
1330 | + $links .= '<a href="'.get_permalink($ee_page_id).'" >'.__('View', 'event_espresso').'</a>'; |
|
1331 | 1331 | |
1332 | 1332 | return $links; |
1333 | 1333 | } |
@@ -1360,9 +1360,9 @@ discard block |
||
1360 | 1360 | $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
1361 | 1361 | } |
1362 | 1362 | |
1363 | - return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
1363 | + return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>' |
|
1364 | 1364 | . $pg_status |
1365 | - . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1365 | + . '</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>'; |
|
1366 | 1366 | } |
1367 | 1367 | |
1368 | 1368 |
@@ -23,449 +23,449 @@ |
||
23 | 23 | class Registry |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @var EE_Template_Config $template_config |
|
28 | - */ |
|
29 | - protected $template_config; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var EE_Currency_Config $currency_config |
|
33 | - */ |
|
34 | - protected $currency_config; |
|
35 | - |
|
36 | - /** |
|
37 | - * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script. |
|
38 | - * |
|
39 | - * @var array |
|
40 | - */ |
|
41 | - protected $jsdata = array(); |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * This keeps track of all scripts with registered data. It is used to prevent duplicate data objects setup in the |
|
46 | - * page source. |
|
47 | - * @var array |
|
48 | - */ |
|
49 | - protected $script_handles_with_data = array(); |
|
50 | - |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * Registry constructor. |
|
55 | - * Hooking into WP actions for script registry. |
|
56 | - * |
|
57 | - * @param EE_Template_Config $template_config |
|
58 | - * @param EE_Currency_Config $currency_config |
|
59 | - */ |
|
60 | - public function __construct(EE_Template_Config $template_config, EE_Currency_Config $currency_config) |
|
61 | - { |
|
62 | - $this->template_config = $template_config; |
|
63 | - $this->currency_config = $currency_config; |
|
64 | - add_action('wp_enqueue_scripts', array($this, 'scripts'), 1); |
|
65 | - add_action('admin_enqueue_scripts', array($this, 'scripts'), 1); |
|
66 | - add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
67 | - add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
68 | - add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
69 | - add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * Callback for the WP script actions. |
|
76 | - * Used to register globally accessible core scripts. |
|
77 | - * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency. |
|
78 | - */ |
|
79 | - public function scripts() |
|
80 | - { |
|
81 | - global $wp_version; |
|
82 | - wp_register_script( |
|
83 | - 'eejs-core', |
|
84 | - EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js', |
|
85 | - array(), |
|
86 | - EVENT_ESPRESSO_VERSION, |
|
87 | - true |
|
88 | - ); |
|
89 | - //only run this if WordPress 4.4.0 > is in use. |
|
90 | - if (version_compare($wp_version, '4.4.0', '>')) { |
|
91 | - //js.api |
|
92 | - wp_register_script( |
|
93 | - 'eejs-api', |
|
94 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
95 | - array('underscore', 'eejs-core'), |
|
96 | - EVENT_ESPRESSO_VERSION, |
|
97 | - true |
|
98 | - ); |
|
99 | - $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest'); |
|
100 | - $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/')); |
|
101 | - } |
|
102 | - if (! is_admin()) { |
|
103 | - $this->loadCoreCss(); |
|
104 | - } |
|
105 | - $this->loadCoreJs(); |
|
106 | - $this->loadJqueryValidate(); |
|
107 | - $this->loadAccountingJs(); |
|
108 | - $this->loadQtipJs(); |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * Call back for the script print in frontend and backend. |
|
115 | - * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point. |
|
116 | - * |
|
117 | - * @since 4.9.31.rc.015 |
|
118 | - */ |
|
119 | - public function enqueueData() |
|
120 | - { |
|
121 | - $this->removeAlreadyRegisteredDataForScriptHandles(); |
|
122 | - wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata)); |
|
123 | - wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
124 | - $this->localizeAccountingJs(); |
|
125 | - $this->addRegisteredScriptHandlesWithData('eejs-core'); |
|
126 | - $this->addRegisteredScriptHandlesWithData('espresso_core'); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * Used to add data to eejs.data object. |
|
133 | - * Note: Overriding existing data is not allowed. |
|
134 | - * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript. |
|
135 | - * If the data you add is something like this: |
|
136 | - * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) ); |
|
137 | - * It will be exposed in the page source as: |
|
138 | - * eejs.data.my_plugin_data.foo == gar |
|
139 | - * |
|
140 | - * @param string $key Key used to access your data |
|
141 | - * @param string|array $value Value to attach to key |
|
142 | - * @throws InvalidArgumentException |
|
143 | - */ |
|
144 | - public function addData($key, $value) |
|
145 | - { |
|
146 | - if ($this->verifyDataNotExisting($key)) { |
|
147 | - $this->jsdata[$key] = $value; |
|
148 | - } |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * Similar to addData except this allows for users to push values to an existing key where the values on key are |
|
155 | - * elements in an array. |
|
156 | - * When you use this method, the value you include will be appended to the end of an array on $key. |
|
157 | - * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript |
|
158 | - * object like this, eejs.data.test = [ my_data, |
|
159 | - * ] |
|
160 | - * If there has already been a scalar value attached to the data object given key, then |
|
161 | - * this will throw an exception. |
|
162 | - * |
|
163 | - * @param string $key Key to attach data to. |
|
164 | - * @param string|array $value Value being registered. |
|
165 | - * @throws InvalidArgumentException |
|
166 | - */ |
|
167 | - public function pushData($key, $value) |
|
168 | - { |
|
169 | - if (isset($this->jsdata[$key]) |
|
170 | - && ! is_array($this->jsdata[$key]) |
|
171 | - ) { |
|
172 | - throw new invalidArgumentException( |
|
173 | - sprintf( |
|
174 | - __( |
|
175 | - 'The value for %1$s is already set and it is not an array. The %2$s method can only be used to |
|
26 | + /** |
|
27 | + * @var EE_Template_Config $template_config |
|
28 | + */ |
|
29 | + protected $template_config; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var EE_Currency_Config $currency_config |
|
33 | + */ |
|
34 | + protected $currency_config; |
|
35 | + |
|
36 | + /** |
|
37 | + * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script. |
|
38 | + * |
|
39 | + * @var array |
|
40 | + */ |
|
41 | + protected $jsdata = array(); |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * This keeps track of all scripts with registered data. It is used to prevent duplicate data objects setup in the |
|
46 | + * page source. |
|
47 | + * @var array |
|
48 | + */ |
|
49 | + protected $script_handles_with_data = array(); |
|
50 | + |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * Registry constructor. |
|
55 | + * Hooking into WP actions for script registry. |
|
56 | + * |
|
57 | + * @param EE_Template_Config $template_config |
|
58 | + * @param EE_Currency_Config $currency_config |
|
59 | + */ |
|
60 | + public function __construct(EE_Template_Config $template_config, EE_Currency_Config $currency_config) |
|
61 | + { |
|
62 | + $this->template_config = $template_config; |
|
63 | + $this->currency_config = $currency_config; |
|
64 | + add_action('wp_enqueue_scripts', array($this, 'scripts'), 1); |
|
65 | + add_action('admin_enqueue_scripts', array($this, 'scripts'), 1); |
|
66 | + add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
67 | + add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
68 | + add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
69 | + add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * Callback for the WP script actions. |
|
76 | + * Used to register globally accessible core scripts. |
|
77 | + * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency. |
|
78 | + */ |
|
79 | + public function scripts() |
|
80 | + { |
|
81 | + global $wp_version; |
|
82 | + wp_register_script( |
|
83 | + 'eejs-core', |
|
84 | + EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js', |
|
85 | + array(), |
|
86 | + EVENT_ESPRESSO_VERSION, |
|
87 | + true |
|
88 | + ); |
|
89 | + //only run this if WordPress 4.4.0 > is in use. |
|
90 | + if (version_compare($wp_version, '4.4.0', '>')) { |
|
91 | + //js.api |
|
92 | + wp_register_script( |
|
93 | + 'eejs-api', |
|
94 | + EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
95 | + array('underscore', 'eejs-core'), |
|
96 | + EVENT_ESPRESSO_VERSION, |
|
97 | + true |
|
98 | + ); |
|
99 | + $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest'); |
|
100 | + $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/')); |
|
101 | + } |
|
102 | + if (! is_admin()) { |
|
103 | + $this->loadCoreCss(); |
|
104 | + } |
|
105 | + $this->loadCoreJs(); |
|
106 | + $this->loadJqueryValidate(); |
|
107 | + $this->loadAccountingJs(); |
|
108 | + $this->loadQtipJs(); |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * Call back for the script print in frontend and backend. |
|
115 | + * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point. |
|
116 | + * |
|
117 | + * @since 4.9.31.rc.015 |
|
118 | + */ |
|
119 | + public function enqueueData() |
|
120 | + { |
|
121 | + $this->removeAlreadyRegisteredDataForScriptHandles(); |
|
122 | + wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata)); |
|
123 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
124 | + $this->localizeAccountingJs(); |
|
125 | + $this->addRegisteredScriptHandlesWithData('eejs-core'); |
|
126 | + $this->addRegisteredScriptHandlesWithData('espresso_core'); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * Used to add data to eejs.data object. |
|
133 | + * Note: Overriding existing data is not allowed. |
|
134 | + * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript. |
|
135 | + * If the data you add is something like this: |
|
136 | + * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) ); |
|
137 | + * It will be exposed in the page source as: |
|
138 | + * eejs.data.my_plugin_data.foo == gar |
|
139 | + * |
|
140 | + * @param string $key Key used to access your data |
|
141 | + * @param string|array $value Value to attach to key |
|
142 | + * @throws InvalidArgumentException |
|
143 | + */ |
|
144 | + public function addData($key, $value) |
|
145 | + { |
|
146 | + if ($this->verifyDataNotExisting($key)) { |
|
147 | + $this->jsdata[$key] = $value; |
|
148 | + } |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * Similar to addData except this allows for users to push values to an existing key where the values on key are |
|
155 | + * elements in an array. |
|
156 | + * When you use this method, the value you include will be appended to the end of an array on $key. |
|
157 | + * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript |
|
158 | + * object like this, eejs.data.test = [ my_data, |
|
159 | + * ] |
|
160 | + * If there has already been a scalar value attached to the data object given key, then |
|
161 | + * this will throw an exception. |
|
162 | + * |
|
163 | + * @param string $key Key to attach data to. |
|
164 | + * @param string|array $value Value being registered. |
|
165 | + * @throws InvalidArgumentException |
|
166 | + */ |
|
167 | + public function pushData($key, $value) |
|
168 | + { |
|
169 | + if (isset($this->jsdata[$key]) |
|
170 | + && ! is_array($this->jsdata[$key]) |
|
171 | + ) { |
|
172 | + throw new invalidArgumentException( |
|
173 | + sprintf( |
|
174 | + __( |
|
175 | + 'The value for %1$s is already set and it is not an array. The %2$s method can only be used to |
|
176 | 176 | push values to this data element when it is an array.', |
177 | - 'event_espresso' |
|
178 | - ), |
|
179 | - $key, |
|
180 | - __METHOD__ |
|
181 | - ) |
|
182 | - ); |
|
183 | - } |
|
184 | - $this->jsdata[$key][] = $value; |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - |
|
189 | - /** |
|
190 | - * Used to set content used by javascript for a template. |
|
191 | - * Note: Overrides of existing registered templates are not allowed. |
|
192 | - * |
|
193 | - * @param string $template_reference |
|
194 | - * @param string $template_content |
|
195 | - * @throws InvalidArgumentException |
|
196 | - */ |
|
197 | - public function addTemplate($template_reference, $template_content) |
|
198 | - { |
|
199 | - if (! isset($this->jsdata['templates'])) { |
|
200 | - $this->jsdata['templates'] = array(); |
|
201 | - } |
|
202 | - //no overrides allowed. |
|
203 | - if (isset($this->jsdata['templates'][$template_reference])) { |
|
204 | - throw new invalidArgumentException( |
|
205 | - sprintf( |
|
206 | - __( |
|
207 | - 'The %1$s key already exists for the templates array in the js data array. No overrides are allowed.', |
|
208 | - 'event_espresso' |
|
209 | - ), |
|
210 | - $template_reference |
|
211 | - ) |
|
212 | - ); |
|
213 | - } |
|
214 | - $this->jsdata['templates'][$template_reference] = $template_content; |
|
215 | - } |
|
216 | - |
|
217 | - |
|
218 | - |
|
219 | - /** |
|
220 | - * Retrieve the template content already registered for the given reference. |
|
221 | - * |
|
222 | - * @param string $template_reference |
|
223 | - * @return string |
|
224 | - */ |
|
225 | - public function getTemplate($template_reference) |
|
226 | - { |
|
227 | - return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference]) |
|
228 | - ? $this->jsdata['templates'][$template_reference] |
|
229 | - : ''; |
|
230 | - } |
|
231 | - |
|
232 | - |
|
233 | - |
|
234 | - /** |
|
235 | - * Retrieve registered data. |
|
236 | - * |
|
237 | - * @param string $key Name of key to attach data to. |
|
238 | - * @return mixed If there is no for the given key, then false is returned. |
|
239 | - */ |
|
240 | - public function getData($key) |
|
241 | - { |
|
242 | - return isset($this->jsdata[$key]) |
|
243 | - ? $this->jsdata[$key] |
|
244 | - : false; |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - |
|
249 | - /** |
|
250 | - * Verifies whether the given data exists already on the jsdata array. |
|
251 | - * Overriding data is not allowed. |
|
252 | - * |
|
253 | - * @param string $key Index for data. |
|
254 | - * @return bool If valid then return true. |
|
255 | - * @throws InvalidArgumentException if data already exists. |
|
256 | - */ |
|
257 | - protected function verifyDataNotExisting($key) |
|
258 | - { |
|
259 | - if (isset($this->jsdata[$key])) { |
|
260 | - if (is_array($this->jsdata[$key])) { |
|
261 | - throw new InvalidArgumentException( |
|
262 | - sprintf( |
|
263 | - __( |
|
264 | - 'The value for %1$s already exists in the Registry::eejs object. |
|
177 | + 'event_espresso' |
|
178 | + ), |
|
179 | + $key, |
|
180 | + __METHOD__ |
|
181 | + ) |
|
182 | + ); |
|
183 | + } |
|
184 | + $this->jsdata[$key][] = $value; |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + |
|
189 | + /** |
|
190 | + * Used to set content used by javascript for a template. |
|
191 | + * Note: Overrides of existing registered templates are not allowed. |
|
192 | + * |
|
193 | + * @param string $template_reference |
|
194 | + * @param string $template_content |
|
195 | + * @throws InvalidArgumentException |
|
196 | + */ |
|
197 | + public function addTemplate($template_reference, $template_content) |
|
198 | + { |
|
199 | + if (! isset($this->jsdata['templates'])) { |
|
200 | + $this->jsdata['templates'] = array(); |
|
201 | + } |
|
202 | + //no overrides allowed. |
|
203 | + if (isset($this->jsdata['templates'][$template_reference])) { |
|
204 | + throw new invalidArgumentException( |
|
205 | + sprintf( |
|
206 | + __( |
|
207 | + 'The %1$s key already exists for the templates array in the js data array. No overrides are allowed.', |
|
208 | + 'event_espresso' |
|
209 | + ), |
|
210 | + $template_reference |
|
211 | + ) |
|
212 | + ); |
|
213 | + } |
|
214 | + $this->jsdata['templates'][$template_reference] = $template_content; |
|
215 | + } |
|
216 | + |
|
217 | + |
|
218 | + |
|
219 | + /** |
|
220 | + * Retrieve the template content already registered for the given reference. |
|
221 | + * |
|
222 | + * @param string $template_reference |
|
223 | + * @return string |
|
224 | + */ |
|
225 | + public function getTemplate($template_reference) |
|
226 | + { |
|
227 | + return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference]) |
|
228 | + ? $this->jsdata['templates'][$template_reference] |
|
229 | + : ''; |
|
230 | + } |
|
231 | + |
|
232 | + |
|
233 | + |
|
234 | + /** |
|
235 | + * Retrieve registered data. |
|
236 | + * |
|
237 | + * @param string $key Name of key to attach data to. |
|
238 | + * @return mixed If there is no for the given key, then false is returned. |
|
239 | + */ |
|
240 | + public function getData($key) |
|
241 | + { |
|
242 | + return isset($this->jsdata[$key]) |
|
243 | + ? $this->jsdata[$key] |
|
244 | + : false; |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + |
|
249 | + /** |
|
250 | + * Verifies whether the given data exists already on the jsdata array. |
|
251 | + * Overriding data is not allowed. |
|
252 | + * |
|
253 | + * @param string $key Index for data. |
|
254 | + * @return bool If valid then return true. |
|
255 | + * @throws InvalidArgumentException if data already exists. |
|
256 | + */ |
|
257 | + protected function verifyDataNotExisting($key) |
|
258 | + { |
|
259 | + if (isset($this->jsdata[$key])) { |
|
260 | + if (is_array($this->jsdata[$key])) { |
|
261 | + throw new InvalidArgumentException( |
|
262 | + sprintf( |
|
263 | + __( |
|
264 | + 'The value for %1$s already exists in the Registry::eejs object. |
|
265 | 265 | Overrides are not allowed. Since the value of this data is an array, you may want to use the |
266 | 266 | %2$s method to push your value to the array.', |
267 | - 'event_espresso' |
|
268 | - ), |
|
269 | - $key, |
|
270 | - 'pushData()' |
|
271 | - ) |
|
272 | - ); |
|
273 | - } |
|
274 | - throw new InvalidArgumentException( |
|
275 | - sprintf( |
|
276 | - __( |
|
277 | - 'The value for %1$s already exists in the Registry::eejs object. Overrides are not |
|
267 | + 'event_espresso' |
|
268 | + ), |
|
269 | + $key, |
|
270 | + 'pushData()' |
|
271 | + ) |
|
272 | + ); |
|
273 | + } |
|
274 | + throw new InvalidArgumentException( |
|
275 | + sprintf( |
|
276 | + __( |
|
277 | + 'The value for %1$s already exists in the Registry::eejs object. Overrides are not |
|
278 | 278 | allowed. Consider attaching your value to a different key', |
279 | - 'event_espresso' |
|
280 | - ), |
|
281 | - $key |
|
282 | - ) |
|
283 | - ); |
|
284 | - } |
|
285 | - return true; |
|
286 | - } |
|
287 | - |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * registers core default stylesheets |
|
292 | - */ |
|
293 | - private function loadCoreCss() |
|
294 | - { |
|
295 | - if ($this->template_config->enable_default_style) { |
|
296 | - $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
297 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
298 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css'; |
|
299 | - wp_register_style( |
|
300 | - 'espresso_default', |
|
301 | - $default_stylesheet_path, |
|
302 | - array('dashicons'), |
|
303 | - EVENT_ESPRESSO_VERSION |
|
304 | - ); |
|
305 | - //Load custom style sheet if available |
|
306 | - if ($this->template_config->custom_style_sheet !== null) { |
|
307 | - wp_register_style( |
|
308 | - 'espresso_custom_css', |
|
309 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
310 | - array('espresso_default'), |
|
311 | - EVENT_ESPRESSO_VERSION |
|
312 | - ); |
|
313 | - } |
|
314 | - } |
|
315 | - } |
|
316 | - |
|
317 | - |
|
318 | - |
|
319 | - /** |
|
320 | - * registers core default javascript |
|
321 | - */ |
|
322 | - private function loadCoreJs() |
|
323 | - { |
|
324 | - // load core js |
|
325 | - wp_register_script( |
|
326 | - 'espresso_core', |
|
327 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
328 | - array('jquery'), |
|
329 | - EVENT_ESPRESSO_VERSION, |
|
330 | - true |
|
331 | - ); |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * registers jQuery Validate for form validation |
|
338 | - */ |
|
339 | - private function loadJqueryValidate() |
|
340 | - { |
|
341 | - // register jQuery Validate and additional methods |
|
342 | - wp_register_script( |
|
343 | - 'jquery-validate', |
|
344 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
345 | - array('jquery'), |
|
346 | - '1.15.0', |
|
347 | - true |
|
348 | - ); |
|
349 | - wp_register_script( |
|
350 | - 'jquery-validate-extra-methods', |
|
351 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
352 | - array('jquery', 'jquery-validate'), |
|
353 | - '1.15.0', |
|
354 | - true |
|
355 | - ); |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * registers accounting.js for performing client-side calculations |
|
362 | - */ |
|
363 | - private function loadAccountingJs() |
|
364 | - { |
|
365 | - //accounting.js library |
|
366 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
367 | - wp_register_script( |
|
368 | - 'ee-accounting-core', |
|
369 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
370 | - array('underscore'), |
|
371 | - '0.3.2', |
|
372 | - true |
|
373 | - ); |
|
374 | - wp_register_script( |
|
375 | - 'ee-accounting', |
|
376 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
377 | - array('ee-accounting-core'), |
|
378 | - EVENT_ESPRESSO_VERSION, |
|
379 | - true |
|
380 | - ); |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * registers accounting.js for performing client-side calculations |
|
387 | - */ |
|
388 | - private function localizeAccountingJs() |
|
389 | - { |
|
390 | - wp_localize_script( |
|
391 | - 'ee-accounting', |
|
392 | - 'EE_ACCOUNTING_CFG', |
|
393 | - array( |
|
394 | - 'currency' => array( |
|
395 | - 'symbol' => $this->currency_config->sign, |
|
396 | - 'format' => array( |
|
397 | - 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
398 | - 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
399 | - 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
400 | - ), |
|
401 | - 'decimal' => $this->currency_config->dec_mrk, |
|
402 | - 'thousand' => $this->currency_config->thsnds, |
|
403 | - 'precision' => $this->currency_config->dec_plc, |
|
404 | - ), |
|
405 | - 'number' => array( |
|
406 | - 'precision' => $this->currency_config->dec_plc, |
|
407 | - 'thousand' => $this->currency_config->thsnds, |
|
408 | - 'decimal' => $this->currency_config->dec_mrk, |
|
409 | - ), |
|
410 | - ) |
|
411 | - ); |
|
412 | - $this->addRegisteredScriptHandlesWithData('ee-accounting'); |
|
413 | - } |
|
414 | - |
|
415 | - |
|
416 | - |
|
417 | - /** |
|
418 | - * registers assets for cleaning your ears |
|
419 | - */ |
|
420 | - private function loadQtipJs() |
|
421 | - { |
|
422 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
423 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
424 | - if (apply_filters('FHEE_load_qtip', false)) { |
|
425 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
426 | - } |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - /** |
|
431 | - * This is used to set registered script handles that have data. |
|
432 | - * @param string $script_handle |
|
433 | - */ |
|
434 | - private function addRegisteredScriptHandlesWithData($script_handle) |
|
435 | - { |
|
436 | - $this->script_handles_with_data[$script_handle] = $script_handle; |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - /** |
|
441 | - * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the |
|
442 | - * Dependency stored in WP_Scripts if its set. |
|
443 | - */ |
|
444 | - private function removeAlreadyRegisteredDataForScriptHandles() |
|
445 | - { |
|
446 | - if (empty($this->script_handles_with_data)) { |
|
447 | - return; |
|
448 | - } |
|
449 | - foreach ($this->script_handles_with_data as $script_handle) { |
|
450 | - $this->removeAlreadyRegisteredDataForScriptHandle($script_handle); |
|
451 | - } |
|
452 | - } |
|
453 | - |
|
454 | - |
|
455 | - /** |
|
456 | - * Removes any data dependency registered in WP_Scripts if its set. |
|
457 | - * @param string $script_handle |
|
458 | - */ |
|
459 | - private function removeAlreadyRegisteredDataForScriptHandle($script_handle) |
|
460 | - { |
|
461 | - if (isset($this->script_handles_with_data[$script_handle])) { |
|
462 | - global $wp_scripts; |
|
463 | - if ($wp_scripts->get_data($script_handle, 'data')) { |
|
464 | - unset($wp_scripts->registered[$script_handle]->extra['data']); |
|
465 | - unset($this->script_handles_with_data[$script_handle]); |
|
466 | - } |
|
467 | - } |
|
468 | - } |
|
279 | + 'event_espresso' |
|
280 | + ), |
|
281 | + $key |
|
282 | + ) |
|
283 | + ); |
|
284 | + } |
|
285 | + return true; |
|
286 | + } |
|
287 | + |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * registers core default stylesheets |
|
292 | + */ |
|
293 | + private function loadCoreCss() |
|
294 | + { |
|
295 | + if ($this->template_config->enable_default_style) { |
|
296 | + $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
297 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
298 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css'; |
|
299 | + wp_register_style( |
|
300 | + 'espresso_default', |
|
301 | + $default_stylesheet_path, |
|
302 | + array('dashicons'), |
|
303 | + EVENT_ESPRESSO_VERSION |
|
304 | + ); |
|
305 | + //Load custom style sheet if available |
|
306 | + if ($this->template_config->custom_style_sheet !== null) { |
|
307 | + wp_register_style( |
|
308 | + 'espresso_custom_css', |
|
309 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
310 | + array('espresso_default'), |
|
311 | + EVENT_ESPRESSO_VERSION |
|
312 | + ); |
|
313 | + } |
|
314 | + } |
|
315 | + } |
|
316 | + |
|
317 | + |
|
318 | + |
|
319 | + /** |
|
320 | + * registers core default javascript |
|
321 | + */ |
|
322 | + private function loadCoreJs() |
|
323 | + { |
|
324 | + // load core js |
|
325 | + wp_register_script( |
|
326 | + 'espresso_core', |
|
327 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
328 | + array('jquery'), |
|
329 | + EVENT_ESPRESSO_VERSION, |
|
330 | + true |
|
331 | + ); |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * registers jQuery Validate for form validation |
|
338 | + */ |
|
339 | + private function loadJqueryValidate() |
|
340 | + { |
|
341 | + // register jQuery Validate and additional methods |
|
342 | + wp_register_script( |
|
343 | + 'jquery-validate', |
|
344 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
345 | + array('jquery'), |
|
346 | + '1.15.0', |
|
347 | + true |
|
348 | + ); |
|
349 | + wp_register_script( |
|
350 | + 'jquery-validate-extra-methods', |
|
351 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
352 | + array('jquery', 'jquery-validate'), |
|
353 | + '1.15.0', |
|
354 | + true |
|
355 | + ); |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * registers accounting.js for performing client-side calculations |
|
362 | + */ |
|
363 | + private function loadAccountingJs() |
|
364 | + { |
|
365 | + //accounting.js library |
|
366 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
367 | + wp_register_script( |
|
368 | + 'ee-accounting-core', |
|
369 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
370 | + array('underscore'), |
|
371 | + '0.3.2', |
|
372 | + true |
|
373 | + ); |
|
374 | + wp_register_script( |
|
375 | + 'ee-accounting', |
|
376 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
377 | + array('ee-accounting-core'), |
|
378 | + EVENT_ESPRESSO_VERSION, |
|
379 | + true |
|
380 | + ); |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * registers accounting.js for performing client-side calculations |
|
387 | + */ |
|
388 | + private function localizeAccountingJs() |
|
389 | + { |
|
390 | + wp_localize_script( |
|
391 | + 'ee-accounting', |
|
392 | + 'EE_ACCOUNTING_CFG', |
|
393 | + array( |
|
394 | + 'currency' => array( |
|
395 | + 'symbol' => $this->currency_config->sign, |
|
396 | + 'format' => array( |
|
397 | + 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
398 | + 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
399 | + 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
400 | + ), |
|
401 | + 'decimal' => $this->currency_config->dec_mrk, |
|
402 | + 'thousand' => $this->currency_config->thsnds, |
|
403 | + 'precision' => $this->currency_config->dec_plc, |
|
404 | + ), |
|
405 | + 'number' => array( |
|
406 | + 'precision' => $this->currency_config->dec_plc, |
|
407 | + 'thousand' => $this->currency_config->thsnds, |
|
408 | + 'decimal' => $this->currency_config->dec_mrk, |
|
409 | + ), |
|
410 | + ) |
|
411 | + ); |
|
412 | + $this->addRegisteredScriptHandlesWithData('ee-accounting'); |
|
413 | + } |
|
414 | + |
|
415 | + |
|
416 | + |
|
417 | + /** |
|
418 | + * registers assets for cleaning your ears |
|
419 | + */ |
|
420 | + private function loadQtipJs() |
|
421 | + { |
|
422 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
423 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
424 | + if (apply_filters('FHEE_load_qtip', false)) { |
|
425 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
426 | + } |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + /** |
|
431 | + * This is used to set registered script handles that have data. |
|
432 | + * @param string $script_handle |
|
433 | + */ |
|
434 | + private function addRegisteredScriptHandlesWithData($script_handle) |
|
435 | + { |
|
436 | + $this->script_handles_with_data[$script_handle] = $script_handle; |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + /** |
|
441 | + * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the |
|
442 | + * Dependency stored in WP_Scripts if its set. |
|
443 | + */ |
|
444 | + private function removeAlreadyRegisteredDataForScriptHandles() |
|
445 | + { |
|
446 | + if (empty($this->script_handles_with_data)) { |
|
447 | + return; |
|
448 | + } |
|
449 | + foreach ($this->script_handles_with_data as $script_handle) { |
|
450 | + $this->removeAlreadyRegisteredDataForScriptHandle($script_handle); |
|
451 | + } |
|
452 | + } |
|
453 | + |
|
454 | + |
|
455 | + /** |
|
456 | + * Removes any data dependency registered in WP_Scripts if its set. |
|
457 | + * @param string $script_handle |
|
458 | + */ |
|
459 | + private function removeAlreadyRegisteredDataForScriptHandle($script_handle) |
|
460 | + { |
|
461 | + if (isset($this->script_handles_with_data[$script_handle])) { |
|
462 | + global $wp_scripts; |
|
463 | + if ($wp_scripts->get_data($script_handle, 'data')) { |
|
464 | + unset($wp_scripts->registered[$script_handle]->extra['data']); |
|
465 | + unset($this->script_handles_with_data[$script_handle]); |
|
466 | + } |
|
467 | + } |
|
468 | + } |
|
469 | 469 | |
470 | 470 | |
471 | 471 | } |
@@ -18,92 +18,92 @@ |
||
18 | 18 | class PostRelatedCacheManager extends BasicCacheManager |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @type string |
|
23 | - */ |
|
24 | - const POST_CACHE_PREFIX = 'ee_cache_post_'; |
|
25 | - |
|
26 | - /** |
|
27 | - * wp-option option_name for tracking post related cache |
|
28 | - * |
|
29 | - * @type string |
|
30 | - */ |
|
31 | - const POST_CACHE_OPTIONS_KEY = 'ee_post_cache'; |
|
32 | - |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * PostRelatedCacheManager constructor. |
|
37 | - * |
|
38 | - * @param CacheStorageInterface $cache_storage |
|
39 | - */ |
|
40 | - public function __construct(CacheStorageInterface $cache_storage) |
|
41 | - { |
|
42 | - parent::__construct($cache_storage); |
|
43 | - add_action('save_post', array($this, 'clearPostRelatedCache')); |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * returns a string that will be prepended to all cache identifiers |
|
50 | - * |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function cachePrefix() |
|
54 | - { |
|
55 | - return PostRelatedCacheManager::POST_CACHE_PREFIX; |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * If you are caching content that pertains to a Post of any type, |
|
62 | - * then it is recommended to pass the post id and cache id prefix to this method |
|
63 | - * so that it can be added to the post related cache tracking. |
|
64 | - * Then, whenever that post is updated, the cache will automatically be deleted, |
|
65 | - * which helps to ensure that outdated cache content will not be served |
|
66 | - * |
|
67 | - * @param int $post_ID [required] |
|
68 | - * @param string $id_prefix [required] Appended to all cache IDs. Can be helpful in finding specific cache types. |
|
69 | - * May also be helpful to include an additional specific identifier, |
|
70 | - * such as a post ID as part of the $id_prefix so that individual caches |
|
71 | - * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
|
72 | - * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
|
73 | - */ |
|
74 | - public function clearPostRelatedCacheOnUpdate($post_ID, $id_prefix) |
|
75 | - { |
|
76 | - $post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array()); |
|
77 | - // if post is not already being tracked |
|
78 | - if ( ! isset($post_related_cache[$post_ID])) { |
|
79 | - // add array to add cache ids to |
|
80 | - $post_related_cache[$post_ID] = array(); |
|
81 | - } |
|
82 | - // add cache id to be tracked |
|
83 | - $post_related_cache[$post_ID][] = $id_prefix; |
|
84 | - update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * callback hooked into the WordPress "save_post" action |
|
91 | - * deletes any cache content associated with the post |
|
92 | - * |
|
93 | - * @param int $post_ID [required] |
|
94 | - */ |
|
95 | - public function clearPostRelatedCache($post_ID) |
|
96 | - { |
|
97 | - $post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array()); |
|
98 | - // if post is not being tracked |
|
99 | - if ( ! isset($post_related_cache[$post_ID])) { |
|
100 | - return; |
|
101 | - } |
|
102 | - // get cache id prefixes for post, and delete their corresponding transients |
|
103 | - $this->clear($post_related_cache[$post_ID]); |
|
104 | - unset($post_related_cache[$post_ID]); |
|
105 | - update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache); |
|
106 | - } |
|
21 | + /** |
|
22 | + * @type string |
|
23 | + */ |
|
24 | + const POST_CACHE_PREFIX = 'ee_cache_post_'; |
|
25 | + |
|
26 | + /** |
|
27 | + * wp-option option_name for tracking post related cache |
|
28 | + * |
|
29 | + * @type string |
|
30 | + */ |
|
31 | + const POST_CACHE_OPTIONS_KEY = 'ee_post_cache'; |
|
32 | + |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * PostRelatedCacheManager constructor. |
|
37 | + * |
|
38 | + * @param CacheStorageInterface $cache_storage |
|
39 | + */ |
|
40 | + public function __construct(CacheStorageInterface $cache_storage) |
|
41 | + { |
|
42 | + parent::__construct($cache_storage); |
|
43 | + add_action('save_post', array($this, 'clearPostRelatedCache')); |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * returns a string that will be prepended to all cache identifiers |
|
50 | + * |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function cachePrefix() |
|
54 | + { |
|
55 | + return PostRelatedCacheManager::POST_CACHE_PREFIX; |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * If you are caching content that pertains to a Post of any type, |
|
62 | + * then it is recommended to pass the post id and cache id prefix to this method |
|
63 | + * so that it can be added to the post related cache tracking. |
|
64 | + * Then, whenever that post is updated, the cache will automatically be deleted, |
|
65 | + * which helps to ensure that outdated cache content will not be served |
|
66 | + * |
|
67 | + * @param int $post_ID [required] |
|
68 | + * @param string $id_prefix [required] Appended to all cache IDs. Can be helpful in finding specific cache types. |
|
69 | + * May also be helpful to include an additional specific identifier, |
|
70 | + * such as a post ID as part of the $id_prefix so that individual caches |
|
71 | + * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
|
72 | + * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
|
73 | + */ |
|
74 | + public function clearPostRelatedCacheOnUpdate($post_ID, $id_prefix) |
|
75 | + { |
|
76 | + $post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array()); |
|
77 | + // if post is not already being tracked |
|
78 | + if ( ! isset($post_related_cache[$post_ID])) { |
|
79 | + // add array to add cache ids to |
|
80 | + $post_related_cache[$post_ID] = array(); |
|
81 | + } |
|
82 | + // add cache id to be tracked |
|
83 | + $post_related_cache[$post_ID][] = $id_prefix; |
|
84 | + update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * callback hooked into the WordPress "save_post" action |
|
91 | + * deletes any cache content associated with the post |
|
92 | + * |
|
93 | + * @param int $post_ID [required] |
|
94 | + */ |
|
95 | + public function clearPostRelatedCache($post_ID) |
|
96 | + { |
|
97 | + $post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array()); |
|
98 | + // if post is not being tracked |
|
99 | + if ( ! isset($post_related_cache[$post_ID])) { |
|
100 | + return; |
|
101 | + } |
|
102 | + // get cache id prefixes for post, and delete their corresponding transients |
|
103 | + $this->clear($post_related_cache[$post_ID]); |
|
104 | + unset($post_related_cache[$post_ID]); |
|
105 | + update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache); |
|
106 | + } |
|
107 | 107 | |
108 | 108 | |
109 | 109 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('ABSPATH')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | 42 | if (function_exists('espresso_version')) { |
43 | - /** |
|
44 | - * espresso_duplicate_plugin_error |
|
45 | - * displays if more than one version of EE is activated at the same time |
|
46 | - */ |
|
47 | - function espresso_duplicate_plugin_error() |
|
48 | - { |
|
49 | - ?> |
|
43 | + /** |
|
44 | + * espresso_duplicate_plugin_error |
|
45 | + * displays if more than one version of EE is activated at the same time |
|
46 | + */ |
|
47 | + function espresso_duplicate_plugin_error() |
|
48 | + { |
|
49 | + ?> |
|
50 | 50 | <div class="error"> |
51 | 51 | <p> |
52 | 52 | <?php echo esc_html__( |
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | 61 | |
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - /** |
|
97 | - * espresso_version |
|
98 | - * Returns the plugin version |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - function espresso_version() |
|
103 | - { |
|
104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.44.rc.010'); |
|
105 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + /** |
|
97 | + * espresso_version |
|
98 | + * Returns the plugin version |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + function espresso_version() |
|
103 | + { |
|
104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.44.rc.010'); |
|
105 | + } |
|
106 | 106 | |
107 | - // define versions |
|
108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | - if ( ! defined('DS')) { |
|
115 | - define('DS', '/'); |
|
116 | - } |
|
117 | - if ( ! defined('PS')) { |
|
118 | - define('PS', PATH_SEPARATOR); |
|
119 | - } |
|
120 | - if ( ! defined('SP')) { |
|
121 | - define('SP', ' '); |
|
122 | - } |
|
123 | - if ( ! defined('EENL')) { |
|
124 | - define('EENL', "\n"); |
|
125 | - } |
|
126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | - // define the plugin directory and URL |
|
128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | - // main root folder paths |
|
132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | - // core system paths |
|
141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | - // gateways |
|
154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | - // asset URL paths |
|
157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | - // define upload paths |
|
164 | - $uploads = wp_upload_dir(); |
|
165 | - // define the uploads directory and URL |
|
166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | - // define the templates directory and URL |
|
169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | - // define the gateway directory and URL |
|
172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | - // languages folder/path |
|
175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | - //check for dompdf fonts in uploads |
|
178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | - } |
|
181 | - //ajax constants |
|
182 | - define( |
|
183 | - 'EE_FRONT_AJAX', |
|
184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | - ); |
|
186 | - define( |
|
187 | - 'EE_ADMIN_AJAX', |
|
188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | - ); |
|
190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | - //want to change its default value! or find when -1 means infinity |
|
193 | - define('EE_INF_IN_DB', -1); |
|
194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | - define('EE_DEBUG', false); |
|
196 | - // for older WP versions |
|
197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | - } |
|
200 | - /** |
|
201 | - * espresso_plugin_activation |
|
202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | - */ |
|
204 | - function espresso_plugin_activation() |
|
205 | - { |
|
206 | - update_option('ee_espresso_activation', true); |
|
207 | - } |
|
107 | + // define versions |
|
108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | + if ( ! defined('DS')) { |
|
115 | + define('DS', '/'); |
|
116 | + } |
|
117 | + if ( ! defined('PS')) { |
|
118 | + define('PS', PATH_SEPARATOR); |
|
119 | + } |
|
120 | + if ( ! defined('SP')) { |
|
121 | + define('SP', ' '); |
|
122 | + } |
|
123 | + if ( ! defined('EENL')) { |
|
124 | + define('EENL', "\n"); |
|
125 | + } |
|
126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | + // define the plugin directory and URL |
|
128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | + // main root folder paths |
|
132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | + // core system paths |
|
141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | + // gateways |
|
154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | + // asset URL paths |
|
157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | + // define upload paths |
|
164 | + $uploads = wp_upload_dir(); |
|
165 | + // define the uploads directory and URL |
|
166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | + // define the templates directory and URL |
|
169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | + // define the gateway directory and URL |
|
172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | + // languages folder/path |
|
175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | + //check for dompdf fonts in uploads |
|
178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | + } |
|
181 | + //ajax constants |
|
182 | + define( |
|
183 | + 'EE_FRONT_AJAX', |
|
184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | + ); |
|
186 | + define( |
|
187 | + 'EE_ADMIN_AJAX', |
|
188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | + ); |
|
190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | + //want to change its default value! or find when -1 means infinity |
|
193 | + define('EE_INF_IN_DB', -1); |
|
194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | + define('EE_DEBUG', false); |
|
196 | + // for older WP versions |
|
197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | + } |
|
200 | + /** |
|
201 | + * espresso_plugin_activation |
|
202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | + */ |
|
204 | + function espresso_plugin_activation() |
|
205 | + { |
|
206 | + update_option('ee_espresso_activation', true); |
|
207 | + } |
|
208 | 208 | |
209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | - /** |
|
211 | - * espresso_load_error_handling |
|
212 | - * this function loads EE's class for handling exceptions and errors |
|
213 | - */ |
|
214 | - function espresso_load_error_handling() |
|
215 | - { |
|
216 | - // load debugging tools |
|
217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | - EEH_Debug_Tools::instance(); |
|
220 | - } |
|
221 | - // load error handling |
|
222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | - } else { |
|
225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | - } |
|
227 | - } |
|
209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | + /** |
|
211 | + * espresso_load_error_handling |
|
212 | + * this function loads EE's class for handling exceptions and errors |
|
213 | + */ |
|
214 | + function espresso_load_error_handling() |
|
215 | + { |
|
216 | + // load debugging tools |
|
217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | + EEH_Debug_Tools::instance(); |
|
220 | + } |
|
221 | + // load error handling |
|
222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | + } else { |
|
225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * espresso_load_required |
|
231 | - * given a class name and path, this function will load that file or throw an exception |
|
232 | - * |
|
233 | - * @param string $classname |
|
234 | - * @param string $full_path_to_file |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - function espresso_load_required($classname, $full_path_to_file) |
|
238 | - { |
|
239 | - static $error_handling_loaded = false; |
|
240 | - if ( ! $error_handling_loaded) { |
|
241 | - espresso_load_error_handling(); |
|
242 | - $error_handling_loaded = true; |
|
243 | - } |
|
244 | - if (is_readable($full_path_to_file)) { |
|
245 | - require_once($full_path_to_file); |
|
246 | - } else { |
|
247 | - throw new EE_Error ( |
|
248 | - sprintf( |
|
249 | - esc_html__( |
|
250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | - 'event_espresso' |
|
252 | - ), |
|
253 | - $classname |
|
254 | - ) |
|
255 | - ); |
|
256 | - } |
|
257 | - } |
|
229 | + /** |
|
230 | + * espresso_load_required |
|
231 | + * given a class name and path, this function will load that file or throw an exception |
|
232 | + * |
|
233 | + * @param string $classname |
|
234 | + * @param string $full_path_to_file |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + function espresso_load_required($classname, $full_path_to_file) |
|
238 | + { |
|
239 | + static $error_handling_loaded = false; |
|
240 | + if ( ! $error_handling_loaded) { |
|
241 | + espresso_load_error_handling(); |
|
242 | + $error_handling_loaded = true; |
|
243 | + } |
|
244 | + if (is_readable($full_path_to_file)) { |
|
245 | + require_once($full_path_to_file); |
|
246 | + } else { |
|
247 | + throw new EE_Error ( |
|
248 | + sprintf( |
|
249 | + esc_html__( |
|
250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | + 'event_espresso' |
|
252 | + ), |
|
253 | + $classname |
|
254 | + ) |
|
255 | + ); |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | - new EE_Bootstrap(); |
|
263 | - } |
|
259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | + new EE_Bootstrap(); |
|
263 | + } |
|
264 | 264 | } |
265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
266 | - /** |
|
267 | - * deactivate_plugin |
|
268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | - * |
|
270 | - * @access public |
|
271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | - { |
|
276 | - if ( ! function_exists('deactivate_plugins')) { |
|
277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | - } |
|
279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | - deactivate_plugins($plugin_basename); |
|
281 | - } |
|
266 | + /** |
|
267 | + * deactivate_plugin |
|
268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | + * |
|
270 | + * @access public |
|
271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | + { |
|
276 | + if ( ! function_exists('deactivate_plugins')) { |
|
277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | + } |
|
279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | + deactivate_plugins($plugin_basename); |
|
281 | + } |
|
282 | 282 | } |
283 | 283 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\services\loaders\LoaderInterface; |
5 | 5 | |
6 | 6 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('No direct script access allowed'); |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -21,742 +21,742 @@ discard block |
||
21 | 21 | class EE_Dependency_Map |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * This means that the requested class dependency is not present in the dependency map |
|
26 | - */ |
|
27 | - const not_registered = 0; |
|
28 | - |
|
29 | - /** |
|
30 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
31 | - */ |
|
32 | - const load_new_object = 1; |
|
33 | - |
|
34 | - /** |
|
35 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
36 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
37 | - */ |
|
38 | - const load_from_cache = 2; |
|
39 | - |
|
40 | - /** |
|
41 | - * When registering a dependency, |
|
42 | - * this indicates to keep any existing dependencies that already exist, |
|
43 | - * and simply discard any new dependencies declared in the incoming data |
|
44 | - */ |
|
45 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
46 | - |
|
47 | - /** |
|
48 | - * When registering a dependency, |
|
49 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
50 | - */ |
|
51 | - const OVERWRITE_DEPENDENCIES = 1; |
|
52 | - |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @type EE_Dependency_Map $_instance |
|
57 | - */ |
|
58 | - protected static $_instance; |
|
59 | - |
|
60 | - /** |
|
61 | - * @type EE_Request $request |
|
62 | - */ |
|
63 | - protected $_request; |
|
64 | - |
|
65 | - /** |
|
66 | - * @type EE_Response $response |
|
67 | - */ |
|
68 | - protected $_response; |
|
69 | - |
|
70 | - /** |
|
71 | - * @type LoaderInterface $loader |
|
72 | - */ |
|
73 | - protected $loader; |
|
74 | - |
|
75 | - /** |
|
76 | - * @type array $_dependency_map |
|
77 | - */ |
|
78 | - protected $_dependency_map = array(); |
|
79 | - |
|
80 | - /** |
|
81 | - * @type array $_class_loaders |
|
82 | - */ |
|
83 | - protected $_class_loaders = array(); |
|
84 | - |
|
85 | - /** |
|
86 | - * @type array $_aliases |
|
87 | - */ |
|
88 | - protected $_aliases = array(); |
|
89 | - |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * EE_Dependency_Map constructor. |
|
94 | - * |
|
95 | - * @param EE_Request $request |
|
96 | - * @param EE_Response $response |
|
97 | - */ |
|
98 | - protected function __construct(EE_Request $request, EE_Response $response) |
|
99 | - { |
|
100 | - $this->_request = $request; |
|
101 | - $this->_response = $response; |
|
102 | - add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
103 | - do_action('EE_Dependency_Map____construct'); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * @throws InvalidDataTypeException |
|
110 | - * @throws InvalidInterfaceException |
|
111 | - * @throws InvalidArgumentException |
|
112 | - */ |
|
113 | - public function initialize() |
|
114 | - { |
|
115 | - $this->_register_core_dependencies(); |
|
116 | - $this->_register_core_class_loaders(); |
|
117 | - $this->_register_core_aliases(); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @singleton method used to instantiate class object |
|
124 | - * @access public |
|
125 | - * @param EE_Request $request |
|
126 | - * @param EE_Response $response |
|
127 | - * @return EE_Dependency_Map |
|
128 | - */ |
|
129 | - public static function instance(EE_Request $request = null, EE_Response $response = null) |
|
130 | - { |
|
131 | - // check if class object is instantiated, and instantiated properly |
|
132 | - if (! self::$_instance instanceof EE_Dependency_Map) { |
|
133 | - self::$_instance = new EE_Dependency_Map($request, $response); |
|
134 | - } |
|
135 | - return self::$_instance; |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @param LoaderInterface $loader |
|
142 | - */ |
|
143 | - public function setLoader(LoaderInterface $loader) |
|
144 | - { |
|
145 | - $this->loader = $loader; |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * @param string $class |
|
152 | - * @param array $dependencies |
|
153 | - * @param int $overwrite |
|
154 | - * @return bool |
|
155 | - */ |
|
156 | - public static function register_dependencies( |
|
157 | - $class, |
|
158 | - array $dependencies, |
|
159 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
160 | - ) { |
|
161 | - return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
168 | - * to the class specified by the first parameter. |
|
169 | - * IMPORTANT !!! |
|
170 | - * The order of elements in the incoming $dependencies array MUST match |
|
171 | - * the order of the constructor parameters for the class in question. |
|
172 | - * This is especially important when overriding any existing dependencies that are registered. |
|
173 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
174 | - * |
|
175 | - * @param string $class |
|
176 | - * @param array $dependencies |
|
177 | - * @param int $overwrite |
|
178 | - * @return bool |
|
179 | - */ |
|
180 | - public function registerDependencies( |
|
181 | - $class, |
|
182 | - array $dependencies, |
|
183 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
184 | - ) { |
|
185 | - $class = trim($class, '\\'); |
|
186 | - $registered = false; |
|
187 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
188 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
189 | - } |
|
190 | - // we need to make sure that any aliases used when registering a dependency |
|
191 | - // get resolved to the correct class name |
|
192 | - foreach ((array)$dependencies as $dependency => $load_source) { |
|
193 | - $alias = self::$_instance->get_alias($dependency); |
|
194 | - if ( |
|
195 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
196 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
197 | - ) { |
|
198 | - unset($dependencies[$dependency]); |
|
199 | - $dependencies[$alias] = $load_source; |
|
200 | - $registered = true; |
|
201 | - } |
|
202 | - } |
|
203 | - // now add our two lists of dependencies together. |
|
204 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
205 | - // so $dependencies is NOT overwritten because it is listed first |
|
206 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
207 | - // Union is way faster than array_merge() but should be used with caution... |
|
208 | - // especially with numerically indexed arrays |
|
209 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
210 | - // now we need to ensure that the resulting dependencies |
|
211 | - // array only has the entries that are required for the class |
|
212 | - // so first count how many dependencies were originally registered for the class |
|
213 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
214 | - // if that count is non-zero (meaning dependencies were already registered) |
|
215 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
216 | - // then truncate the final array to match that count |
|
217 | - ? array_slice($dependencies, 0, $dependency_count) |
|
218 | - // otherwise just take the incoming array because nothing previously existed |
|
219 | - : $dependencies; |
|
220 | - return $registered; |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - |
|
225 | - /** |
|
226 | - * @param string $class_name |
|
227 | - * @param string $loader |
|
228 | - * @return bool |
|
229 | - * @throws DomainException |
|
230 | - */ |
|
231 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
232 | - { |
|
233 | - if (strpos($class_name, '\\') !== false) { |
|
234 | - throw new DomainException( |
|
235 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
236 | - ); |
|
237 | - } |
|
238 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
239 | - if ( |
|
240 | - ! is_callable($loader) |
|
241 | - && ( |
|
242 | - strpos($loader, 'load_') !== 0 |
|
243 | - || ! method_exists('EE_Registry', $loader) |
|
244 | - ) |
|
245 | - ) { |
|
246 | - throw new DomainException( |
|
247 | - sprintf( |
|
248 | - esc_html__( |
|
249 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
250 | - 'event_espresso' |
|
251 | - ), |
|
252 | - $loader |
|
253 | - ) |
|
254 | - ); |
|
255 | - } |
|
256 | - $class_name = self::$_instance->get_alias($class_name); |
|
257 | - if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
258 | - self::$_instance->_class_loaders[$class_name] = $loader; |
|
259 | - return true; |
|
260 | - } |
|
261 | - return false; |
|
262 | - } |
|
263 | - |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * @return array |
|
268 | - */ |
|
269 | - public function dependency_map() |
|
270 | - { |
|
271 | - return $this->_dependency_map; |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
278 | - * |
|
279 | - * @param string $class_name |
|
280 | - * @return boolean |
|
281 | - */ |
|
282 | - public function has($class_name = '') |
|
283 | - { |
|
284 | - return isset($this->_dependency_map[$class_name]) ? true : false; |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
291 | - * |
|
292 | - * @param string $class_name |
|
293 | - * @param string $dependency |
|
294 | - * @return bool |
|
295 | - */ |
|
296 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
297 | - { |
|
298 | - $dependency = $this->get_alias($dependency); |
|
299 | - return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency]) |
|
300 | - ? true |
|
301 | - : false; |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - |
|
306 | - /** |
|
307 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
308 | - * |
|
309 | - * @param string $class_name |
|
310 | - * @param string $dependency |
|
311 | - * @return int |
|
312 | - */ |
|
313 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
314 | - { |
|
315 | - $dependency = $this->get_alias($dependency); |
|
316 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
317 | - ? $this->_dependency_map[$class_name][$dependency] |
|
318 | - : EE_Dependency_Map::not_registered; |
|
319 | - } |
|
320 | - |
|
321 | - |
|
322 | - |
|
323 | - /** |
|
324 | - * @param string $class_name |
|
325 | - * @return string | Closure |
|
326 | - */ |
|
327 | - public function class_loader($class_name) |
|
328 | - { |
|
329 | - // don't use loaders for FQCNs |
|
330 | - if(strpos($class_name, '\\') !== false){ |
|
331 | - return ''; |
|
332 | - } |
|
333 | - $class_name = $this->get_alias($class_name); |
|
334 | - return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - |
|
339 | - /** |
|
340 | - * @return array |
|
341 | - */ |
|
342 | - public function class_loaders() |
|
343 | - { |
|
344 | - return $this->_class_loaders; |
|
345 | - } |
|
346 | - |
|
347 | - |
|
348 | - |
|
349 | - /** |
|
350 | - * adds an alias for a classname |
|
351 | - * |
|
352 | - * @param string $class_name the class name that should be used (concrete class to replace interface) |
|
353 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
354 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
355 | - */ |
|
356 | - public function add_alias($class_name, $alias, $for_class = '') |
|
357 | - { |
|
358 | - if ($for_class !== '') { |
|
359 | - if (! isset($this->_aliases[$for_class])) { |
|
360 | - $this->_aliases[$for_class] = array(); |
|
361 | - } |
|
362 | - $this->_aliases[$for_class][$class_name] = $alias; |
|
363 | - } |
|
364 | - $this->_aliases[$class_name] = $alias; |
|
365 | - } |
|
366 | - |
|
367 | - |
|
368 | - |
|
369 | - /** |
|
370 | - * returns TRUE if the provided class name has an alias |
|
371 | - * |
|
372 | - * @param string $class_name |
|
373 | - * @param string $for_class |
|
374 | - * @return bool |
|
375 | - */ |
|
376 | - public function has_alias($class_name = '', $for_class = '') |
|
377 | - { |
|
378 | - return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name]) |
|
379 | - || ( |
|
380 | - isset($this->_aliases[$class_name]) |
|
381 | - && ! is_array($this->_aliases[$class_name]) |
|
382 | - ); |
|
383 | - } |
|
384 | - |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * returns alias for class name if one exists, otherwise returns the original classname |
|
389 | - * functions recursively, so that multiple aliases can be used to drill down to a classname |
|
390 | - * for example: |
|
391 | - * if the following two entries were added to the _aliases array: |
|
392 | - * array( |
|
393 | - * 'interface_alias' => 'some\namespace\interface' |
|
394 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
395 | - * ) |
|
396 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
397 | - * to load an instance of 'some\namespace\classname' |
|
398 | - * |
|
399 | - * @param string $class_name |
|
400 | - * @param string $for_class |
|
401 | - * @return string |
|
402 | - */ |
|
403 | - public function get_alias($class_name = '', $for_class = '') |
|
404 | - { |
|
405 | - if (! $this->has_alias($class_name, $for_class)) { |
|
406 | - return $class_name; |
|
407 | - } |
|
408 | - if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
409 | - return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
|
410 | - } |
|
411 | - return $this->get_alias($this->_aliases[$class_name]); |
|
412 | - } |
|
413 | - |
|
414 | - |
|
415 | - |
|
416 | - /** |
|
417 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
418 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
419 | - * This is done by using the following class constants: |
|
420 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
421 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
422 | - */ |
|
423 | - protected function _register_core_dependencies() |
|
424 | - { |
|
425 | - $this->_dependency_map = array( |
|
426 | - 'EE_Request_Handler' => array( |
|
427 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
428 | - ), |
|
429 | - 'EE_System' => array( |
|
430 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
431 | - ), |
|
432 | - 'EE_Session' => array( |
|
433 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
434 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
435 | - ), |
|
436 | - 'EE_Cart' => array( |
|
437 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
438 | - ), |
|
439 | - 'EE_Front_Controller' => array( |
|
440 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
441 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
442 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
443 | - ), |
|
444 | - 'EE_Messenger_Collection_Loader' => array( |
|
445 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
446 | - ), |
|
447 | - 'EE_Message_Type_Collection_Loader' => array( |
|
448 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
449 | - ), |
|
450 | - 'EE_Message_Resource_Manager' => array( |
|
451 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
452 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
453 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
454 | - ), |
|
455 | - 'EE_Message_Factory' => array( |
|
456 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
457 | - ), |
|
458 | - 'EE_messages' => array( |
|
459 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
460 | - ), |
|
461 | - 'EE_Messages_Generator' => array( |
|
462 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
463 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
464 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
465 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
466 | - ), |
|
467 | - 'EE_Messages_Processor' => array( |
|
468 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
469 | - ), |
|
470 | - 'EE_Messages_Queue' => array( |
|
471 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
472 | - ), |
|
473 | - 'EE_Messages_Template_Defaults' => array( |
|
474 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
475 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
476 | - ), |
|
477 | - 'EE_Message_To_Generate_From_Request' => array( |
|
478 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
479 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
480 | - ), |
|
481 | - 'EventEspresso\core\services\commands\CommandBus' => array( |
|
482 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
483 | - ), |
|
484 | - 'EventEspresso\services\commands\CommandHandler' => array( |
|
485 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
486 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
487 | - ), |
|
488 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
489 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
490 | - ), |
|
491 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
492 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
493 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
494 | - ), |
|
495 | - 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
496 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
497 | - ), |
|
498 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
499 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
500 | - ), |
|
501 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
502 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
503 | - ), |
|
504 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
505 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
506 | - ), |
|
507 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
508 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
509 | - ), |
|
510 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
511 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
512 | - ), |
|
513 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
514 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
515 | - ), |
|
516 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
517 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
518 | - ), |
|
519 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
520 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
521 | - ), |
|
522 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
523 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
524 | - ), |
|
525 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
526 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
527 | - ), |
|
528 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
529 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
530 | - ), |
|
531 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
532 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
533 | - ), |
|
534 | - 'EventEspresso\core\services\database\TableManager' => array( |
|
535 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
536 | - ), |
|
537 | - 'EE_Data_Migration_Class_Base' => array( |
|
538 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
539 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
540 | - ), |
|
541 | - 'EE_DMS_Core_4_1_0' => array( |
|
542 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
543 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
544 | - ), |
|
545 | - 'EE_DMS_Core_4_2_0' => array( |
|
546 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
547 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
548 | - ), |
|
549 | - 'EE_DMS_Core_4_3_0' => array( |
|
550 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
551 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
552 | - ), |
|
553 | - 'EE_DMS_Core_4_4_0' => array( |
|
554 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
555 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
556 | - ), |
|
557 | - 'EE_DMS_Core_4_5_0' => array( |
|
558 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
559 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
560 | - ), |
|
561 | - 'EE_DMS_Core_4_6_0' => array( |
|
562 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
563 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
564 | - ), |
|
565 | - 'EE_DMS_Core_4_7_0' => array( |
|
566 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
567 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
568 | - ), |
|
569 | - 'EE_DMS_Core_4_8_0' => array( |
|
570 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
571 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
572 | - ), |
|
573 | - 'EE_DMS_Core_4_9_0' => array( |
|
574 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
575 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
576 | - ), |
|
577 | - 'EventEspresso\core\services\assets\Registry' => array( |
|
578 | - 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
579 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
580 | - ), |
|
581 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
582 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
583 | - ), |
|
584 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
585 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
586 | - ), |
|
587 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
588 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
589 | - ), |
|
590 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
591 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
592 | - ), |
|
593 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
594 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
595 | - ), |
|
596 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
597 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
598 | - ), |
|
599 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
600 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
601 | - ), |
|
602 | - 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
603 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
604 | - ), |
|
605 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
606 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
607 | - ), |
|
608 | - ); |
|
609 | - } |
|
610 | - |
|
611 | - |
|
612 | - |
|
613 | - /** |
|
614 | - * Registers how core classes are loaded. |
|
615 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
616 | - * 'EE_Request_Handler' => 'load_core' |
|
617 | - * 'EE_Messages_Queue' => 'load_lib' |
|
618 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
619 | - * or, if greater control is required, by providing a custom closure. For example: |
|
620 | - * 'Some_Class' => function () { |
|
621 | - * return new Some_Class(); |
|
622 | - * }, |
|
623 | - * This is required for instantiating dependencies |
|
624 | - * where an interface has been type hinted in a class constructor. For example: |
|
625 | - * 'Required_Interface' => function () { |
|
626 | - * return new A_Class_That_Implements_Required_Interface(); |
|
627 | - * }, |
|
628 | - */ |
|
629 | - protected function _register_core_class_loaders() |
|
630 | - { |
|
631 | - //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
632 | - //be used in a closure. |
|
633 | - $request = &$this->_request; |
|
634 | - $response = &$this->_response; |
|
635 | - $loader = &$this->loader; |
|
636 | - $this->_class_loaders = array( |
|
637 | - //load_core |
|
638 | - 'EE_Capabilities' => 'load_core', |
|
639 | - 'EE_Encryption' => 'load_core', |
|
640 | - 'EE_Front_Controller' => 'load_core', |
|
641 | - 'EE_Module_Request_Router' => 'load_core', |
|
642 | - 'EE_Registry' => 'load_core', |
|
643 | - 'EE_Request' => function () use (&$request) { |
|
644 | - return $request; |
|
645 | - }, |
|
646 | - 'EE_Response' => function () use (&$response) { |
|
647 | - return $response; |
|
648 | - }, |
|
649 | - 'EE_Request_Handler' => 'load_core', |
|
650 | - 'EE_Session' => 'load_core', |
|
651 | - 'EE_System' => 'load_core', |
|
652 | - //load_lib |
|
653 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
654 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
655 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
656 | - 'EE_Messenger_Collection' => 'load_lib', |
|
657 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
658 | - 'EE_Messages_Processor' => 'load_lib', |
|
659 | - 'EE_Message_Repository' => 'load_lib', |
|
660 | - 'EE_Messages_Queue' => 'load_lib', |
|
661 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
662 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
663 | - 'EE_Messages_Generator' => function () { |
|
664 | - return EE_Registry::instance()->load_lib( |
|
665 | - 'Messages_Generator', |
|
666 | - array(), |
|
667 | - false, |
|
668 | - false |
|
669 | - ); |
|
670 | - }, |
|
671 | - 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
672 | - return EE_Registry::instance()->load_lib( |
|
673 | - 'Messages_Template_Defaults', |
|
674 | - $arguments, |
|
675 | - false, |
|
676 | - false |
|
677 | - ); |
|
678 | - }, |
|
679 | - //load_model |
|
680 | - 'EEM_Attendee' => 'load_model', |
|
681 | - 'EEM_Message_Template_Group' => 'load_model', |
|
682 | - 'EEM_Message_Template' => 'load_model', |
|
683 | - //load_helper |
|
684 | - 'EEH_Parse_Shortcodes' => function () { |
|
685 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
686 | - return new EEH_Parse_Shortcodes(); |
|
687 | - } |
|
688 | - return null; |
|
689 | - }, |
|
690 | - 'EE_Template_Config' => function () { |
|
691 | - return EE_Config::instance()->template_settings; |
|
692 | - }, |
|
693 | - 'EE_Currency_Config' => function () { |
|
694 | - return EE_Config::instance()->currency; |
|
695 | - }, |
|
696 | - 'EventEspresso\core\services\loaders\Loader' => function () use (&$loader) { |
|
697 | - return $loader; |
|
698 | - }, |
|
699 | - ); |
|
700 | - } |
|
701 | - |
|
702 | - |
|
703 | - |
|
704 | - /** |
|
705 | - * can be used for supplying alternate names for classes, |
|
706 | - * or for connecting interface names to instantiable classes |
|
707 | - */ |
|
708 | - protected function _register_core_aliases() |
|
709 | - { |
|
710 | - $this->_aliases = array( |
|
711 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
712 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
713 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
714 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
715 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
716 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
717 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
718 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
719 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
720 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
721 | - 'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
|
722 | - 'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
|
723 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
724 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
725 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
726 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
727 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
728 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
729 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
730 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
731 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
732 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
733 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
734 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
735 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
736 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
737 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
738 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
739 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
740 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
741 | - 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
742 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
743 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
744 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
745 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
746 | - ); |
|
747 | - } |
|
748 | - |
|
749 | - |
|
750 | - |
|
751 | - /** |
|
752 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
753 | - * request Primarily used by unit tests. |
|
754 | - */ |
|
755 | - public function reset() |
|
756 | - { |
|
757 | - $this->_register_core_class_loaders(); |
|
758 | - $this->_register_core_dependencies(); |
|
759 | - } |
|
24 | + /** |
|
25 | + * This means that the requested class dependency is not present in the dependency map |
|
26 | + */ |
|
27 | + const not_registered = 0; |
|
28 | + |
|
29 | + /** |
|
30 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
31 | + */ |
|
32 | + const load_new_object = 1; |
|
33 | + |
|
34 | + /** |
|
35 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
36 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
37 | + */ |
|
38 | + const load_from_cache = 2; |
|
39 | + |
|
40 | + /** |
|
41 | + * When registering a dependency, |
|
42 | + * this indicates to keep any existing dependencies that already exist, |
|
43 | + * and simply discard any new dependencies declared in the incoming data |
|
44 | + */ |
|
45 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
46 | + |
|
47 | + /** |
|
48 | + * When registering a dependency, |
|
49 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
50 | + */ |
|
51 | + const OVERWRITE_DEPENDENCIES = 1; |
|
52 | + |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @type EE_Dependency_Map $_instance |
|
57 | + */ |
|
58 | + protected static $_instance; |
|
59 | + |
|
60 | + /** |
|
61 | + * @type EE_Request $request |
|
62 | + */ |
|
63 | + protected $_request; |
|
64 | + |
|
65 | + /** |
|
66 | + * @type EE_Response $response |
|
67 | + */ |
|
68 | + protected $_response; |
|
69 | + |
|
70 | + /** |
|
71 | + * @type LoaderInterface $loader |
|
72 | + */ |
|
73 | + protected $loader; |
|
74 | + |
|
75 | + /** |
|
76 | + * @type array $_dependency_map |
|
77 | + */ |
|
78 | + protected $_dependency_map = array(); |
|
79 | + |
|
80 | + /** |
|
81 | + * @type array $_class_loaders |
|
82 | + */ |
|
83 | + protected $_class_loaders = array(); |
|
84 | + |
|
85 | + /** |
|
86 | + * @type array $_aliases |
|
87 | + */ |
|
88 | + protected $_aliases = array(); |
|
89 | + |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * EE_Dependency_Map constructor. |
|
94 | + * |
|
95 | + * @param EE_Request $request |
|
96 | + * @param EE_Response $response |
|
97 | + */ |
|
98 | + protected function __construct(EE_Request $request, EE_Response $response) |
|
99 | + { |
|
100 | + $this->_request = $request; |
|
101 | + $this->_response = $response; |
|
102 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
103 | + do_action('EE_Dependency_Map____construct'); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * @throws InvalidDataTypeException |
|
110 | + * @throws InvalidInterfaceException |
|
111 | + * @throws InvalidArgumentException |
|
112 | + */ |
|
113 | + public function initialize() |
|
114 | + { |
|
115 | + $this->_register_core_dependencies(); |
|
116 | + $this->_register_core_class_loaders(); |
|
117 | + $this->_register_core_aliases(); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @singleton method used to instantiate class object |
|
124 | + * @access public |
|
125 | + * @param EE_Request $request |
|
126 | + * @param EE_Response $response |
|
127 | + * @return EE_Dependency_Map |
|
128 | + */ |
|
129 | + public static function instance(EE_Request $request = null, EE_Response $response = null) |
|
130 | + { |
|
131 | + // check if class object is instantiated, and instantiated properly |
|
132 | + if (! self::$_instance instanceof EE_Dependency_Map) { |
|
133 | + self::$_instance = new EE_Dependency_Map($request, $response); |
|
134 | + } |
|
135 | + return self::$_instance; |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @param LoaderInterface $loader |
|
142 | + */ |
|
143 | + public function setLoader(LoaderInterface $loader) |
|
144 | + { |
|
145 | + $this->loader = $loader; |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * @param string $class |
|
152 | + * @param array $dependencies |
|
153 | + * @param int $overwrite |
|
154 | + * @return bool |
|
155 | + */ |
|
156 | + public static function register_dependencies( |
|
157 | + $class, |
|
158 | + array $dependencies, |
|
159 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
160 | + ) { |
|
161 | + return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
168 | + * to the class specified by the first parameter. |
|
169 | + * IMPORTANT !!! |
|
170 | + * The order of elements in the incoming $dependencies array MUST match |
|
171 | + * the order of the constructor parameters for the class in question. |
|
172 | + * This is especially important when overriding any existing dependencies that are registered. |
|
173 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
174 | + * |
|
175 | + * @param string $class |
|
176 | + * @param array $dependencies |
|
177 | + * @param int $overwrite |
|
178 | + * @return bool |
|
179 | + */ |
|
180 | + public function registerDependencies( |
|
181 | + $class, |
|
182 | + array $dependencies, |
|
183 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
184 | + ) { |
|
185 | + $class = trim($class, '\\'); |
|
186 | + $registered = false; |
|
187 | + if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
188 | + self::$_instance->_dependency_map[ $class ] = array(); |
|
189 | + } |
|
190 | + // we need to make sure that any aliases used when registering a dependency |
|
191 | + // get resolved to the correct class name |
|
192 | + foreach ((array)$dependencies as $dependency => $load_source) { |
|
193 | + $alias = self::$_instance->get_alias($dependency); |
|
194 | + if ( |
|
195 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
196 | + || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
197 | + ) { |
|
198 | + unset($dependencies[$dependency]); |
|
199 | + $dependencies[$alias] = $load_source; |
|
200 | + $registered = true; |
|
201 | + } |
|
202 | + } |
|
203 | + // now add our two lists of dependencies together. |
|
204 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
205 | + // so $dependencies is NOT overwritten because it is listed first |
|
206 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
207 | + // Union is way faster than array_merge() but should be used with caution... |
|
208 | + // especially with numerically indexed arrays |
|
209 | + $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
210 | + // now we need to ensure that the resulting dependencies |
|
211 | + // array only has the entries that are required for the class |
|
212 | + // so first count how many dependencies were originally registered for the class |
|
213 | + $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
214 | + // if that count is non-zero (meaning dependencies were already registered) |
|
215 | + self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
216 | + // then truncate the final array to match that count |
|
217 | + ? array_slice($dependencies, 0, $dependency_count) |
|
218 | + // otherwise just take the incoming array because nothing previously existed |
|
219 | + : $dependencies; |
|
220 | + return $registered; |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + |
|
225 | + /** |
|
226 | + * @param string $class_name |
|
227 | + * @param string $loader |
|
228 | + * @return bool |
|
229 | + * @throws DomainException |
|
230 | + */ |
|
231 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
232 | + { |
|
233 | + if (strpos($class_name, '\\') !== false) { |
|
234 | + throw new DomainException( |
|
235 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
236 | + ); |
|
237 | + } |
|
238 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
239 | + if ( |
|
240 | + ! is_callable($loader) |
|
241 | + && ( |
|
242 | + strpos($loader, 'load_') !== 0 |
|
243 | + || ! method_exists('EE_Registry', $loader) |
|
244 | + ) |
|
245 | + ) { |
|
246 | + throw new DomainException( |
|
247 | + sprintf( |
|
248 | + esc_html__( |
|
249 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
250 | + 'event_espresso' |
|
251 | + ), |
|
252 | + $loader |
|
253 | + ) |
|
254 | + ); |
|
255 | + } |
|
256 | + $class_name = self::$_instance->get_alias($class_name); |
|
257 | + if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
258 | + self::$_instance->_class_loaders[$class_name] = $loader; |
|
259 | + return true; |
|
260 | + } |
|
261 | + return false; |
|
262 | + } |
|
263 | + |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * @return array |
|
268 | + */ |
|
269 | + public function dependency_map() |
|
270 | + { |
|
271 | + return $this->_dependency_map; |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
278 | + * |
|
279 | + * @param string $class_name |
|
280 | + * @return boolean |
|
281 | + */ |
|
282 | + public function has($class_name = '') |
|
283 | + { |
|
284 | + return isset($this->_dependency_map[$class_name]) ? true : false; |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
291 | + * |
|
292 | + * @param string $class_name |
|
293 | + * @param string $dependency |
|
294 | + * @return bool |
|
295 | + */ |
|
296 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
297 | + { |
|
298 | + $dependency = $this->get_alias($dependency); |
|
299 | + return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency]) |
|
300 | + ? true |
|
301 | + : false; |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + |
|
306 | + /** |
|
307 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
308 | + * |
|
309 | + * @param string $class_name |
|
310 | + * @param string $dependency |
|
311 | + * @return int |
|
312 | + */ |
|
313 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
314 | + { |
|
315 | + $dependency = $this->get_alias($dependency); |
|
316 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
317 | + ? $this->_dependency_map[$class_name][$dependency] |
|
318 | + : EE_Dependency_Map::not_registered; |
|
319 | + } |
|
320 | + |
|
321 | + |
|
322 | + |
|
323 | + /** |
|
324 | + * @param string $class_name |
|
325 | + * @return string | Closure |
|
326 | + */ |
|
327 | + public function class_loader($class_name) |
|
328 | + { |
|
329 | + // don't use loaders for FQCNs |
|
330 | + if(strpos($class_name, '\\') !== false){ |
|
331 | + return ''; |
|
332 | + } |
|
333 | + $class_name = $this->get_alias($class_name); |
|
334 | + return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + |
|
339 | + /** |
|
340 | + * @return array |
|
341 | + */ |
|
342 | + public function class_loaders() |
|
343 | + { |
|
344 | + return $this->_class_loaders; |
|
345 | + } |
|
346 | + |
|
347 | + |
|
348 | + |
|
349 | + /** |
|
350 | + * adds an alias for a classname |
|
351 | + * |
|
352 | + * @param string $class_name the class name that should be used (concrete class to replace interface) |
|
353 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
354 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
355 | + */ |
|
356 | + public function add_alias($class_name, $alias, $for_class = '') |
|
357 | + { |
|
358 | + if ($for_class !== '') { |
|
359 | + if (! isset($this->_aliases[$for_class])) { |
|
360 | + $this->_aliases[$for_class] = array(); |
|
361 | + } |
|
362 | + $this->_aliases[$for_class][$class_name] = $alias; |
|
363 | + } |
|
364 | + $this->_aliases[$class_name] = $alias; |
|
365 | + } |
|
366 | + |
|
367 | + |
|
368 | + |
|
369 | + /** |
|
370 | + * returns TRUE if the provided class name has an alias |
|
371 | + * |
|
372 | + * @param string $class_name |
|
373 | + * @param string $for_class |
|
374 | + * @return bool |
|
375 | + */ |
|
376 | + public function has_alias($class_name = '', $for_class = '') |
|
377 | + { |
|
378 | + return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name]) |
|
379 | + || ( |
|
380 | + isset($this->_aliases[$class_name]) |
|
381 | + && ! is_array($this->_aliases[$class_name]) |
|
382 | + ); |
|
383 | + } |
|
384 | + |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * returns alias for class name if one exists, otherwise returns the original classname |
|
389 | + * functions recursively, so that multiple aliases can be used to drill down to a classname |
|
390 | + * for example: |
|
391 | + * if the following two entries were added to the _aliases array: |
|
392 | + * array( |
|
393 | + * 'interface_alias' => 'some\namespace\interface' |
|
394 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
395 | + * ) |
|
396 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
397 | + * to load an instance of 'some\namespace\classname' |
|
398 | + * |
|
399 | + * @param string $class_name |
|
400 | + * @param string $for_class |
|
401 | + * @return string |
|
402 | + */ |
|
403 | + public function get_alias($class_name = '', $for_class = '') |
|
404 | + { |
|
405 | + if (! $this->has_alias($class_name, $for_class)) { |
|
406 | + return $class_name; |
|
407 | + } |
|
408 | + if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
409 | + return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
|
410 | + } |
|
411 | + return $this->get_alias($this->_aliases[$class_name]); |
|
412 | + } |
|
413 | + |
|
414 | + |
|
415 | + |
|
416 | + /** |
|
417 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
418 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
419 | + * This is done by using the following class constants: |
|
420 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
421 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
422 | + */ |
|
423 | + protected function _register_core_dependencies() |
|
424 | + { |
|
425 | + $this->_dependency_map = array( |
|
426 | + 'EE_Request_Handler' => array( |
|
427 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
428 | + ), |
|
429 | + 'EE_System' => array( |
|
430 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
431 | + ), |
|
432 | + 'EE_Session' => array( |
|
433 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
434 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
435 | + ), |
|
436 | + 'EE_Cart' => array( |
|
437 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
438 | + ), |
|
439 | + 'EE_Front_Controller' => array( |
|
440 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
441 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
442 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
443 | + ), |
|
444 | + 'EE_Messenger_Collection_Loader' => array( |
|
445 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
446 | + ), |
|
447 | + 'EE_Message_Type_Collection_Loader' => array( |
|
448 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
449 | + ), |
|
450 | + 'EE_Message_Resource_Manager' => array( |
|
451 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
452 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
453 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
454 | + ), |
|
455 | + 'EE_Message_Factory' => array( |
|
456 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
457 | + ), |
|
458 | + 'EE_messages' => array( |
|
459 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
460 | + ), |
|
461 | + 'EE_Messages_Generator' => array( |
|
462 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
463 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
464 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
465 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
466 | + ), |
|
467 | + 'EE_Messages_Processor' => array( |
|
468 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
469 | + ), |
|
470 | + 'EE_Messages_Queue' => array( |
|
471 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
472 | + ), |
|
473 | + 'EE_Messages_Template_Defaults' => array( |
|
474 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
475 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
476 | + ), |
|
477 | + 'EE_Message_To_Generate_From_Request' => array( |
|
478 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
479 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
480 | + ), |
|
481 | + 'EventEspresso\core\services\commands\CommandBus' => array( |
|
482 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
483 | + ), |
|
484 | + 'EventEspresso\services\commands\CommandHandler' => array( |
|
485 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
486 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
487 | + ), |
|
488 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
489 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
490 | + ), |
|
491 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
492 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
493 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
494 | + ), |
|
495 | + 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
496 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
497 | + ), |
|
498 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
499 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
500 | + ), |
|
501 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
502 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
503 | + ), |
|
504 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
505 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
506 | + ), |
|
507 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
508 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
509 | + ), |
|
510 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
511 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
512 | + ), |
|
513 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
514 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
515 | + ), |
|
516 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
517 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
518 | + ), |
|
519 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
520 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
521 | + ), |
|
522 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
523 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
524 | + ), |
|
525 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
526 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
527 | + ), |
|
528 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
529 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
530 | + ), |
|
531 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
532 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
533 | + ), |
|
534 | + 'EventEspresso\core\services\database\TableManager' => array( |
|
535 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
536 | + ), |
|
537 | + 'EE_Data_Migration_Class_Base' => array( |
|
538 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
539 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
540 | + ), |
|
541 | + 'EE_DMS_Core_4_1_0' => array( |
|
542 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
543 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
544 | + ), |
|
545 | + 'EE_DMS_Core_4_2_0' => array( |
|
546 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
547 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
548 | + ), |
|
549 | + 'EE_DMS_Core_4_3_0' => array( |
|
550 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
551 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
552 | + ), |
|
553 | + 'EE_DMS_Core_4_4_0' => array( |
|
554 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
555 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
556 | + ), |
|
557 | + 'EE_DMS_Core_4_5_0' => array( |
|
558 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
559 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
560 | + ), |
|
561 | + 'EE_DMS_Core_4_6_0' => array( |
|
562 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
563 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
564 | + ), |
|
565 | + 'EE_DMS_Core_4_7_0' => array( |
|
566 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
567 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
568 | + ), |
|
569 | + 'EE_DMS_Core_4_8_0' => array( |
|
570 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
571 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
572 | + ), |
|
573 | + 'EE_DMS_Core_4_9_0' => array( |
|
574 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
575 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
576 | + ), |
|
577 | + 'EventEspresso\core\services\assets\Registry' => array( |
|
578 | + 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
579 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
580 | + ), |
|
581 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
582 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
583 | + ), |
|
584 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
585 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
586 | + ), |
|
587 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
588 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
589 | + ), |
|
590 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
591 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
592 | + ), |
|
593 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
594 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
595 | + ), |
|
596 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
597 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
598 | + ), |
|
599 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
600 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
601 | + ), |
|
602 | + 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
603 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
604 | + ), |
|
605 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
606 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
607 | + ), |
|
608 | + ); |
|
609 | + } |
|
610 | + |
|
611 | + |
|
612 | + |
|
613 | + /** |
|
614 | + * Registers how core classes are loaded. |
|
615 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
616 | + * 'EE_Request_Handler' => 'load_core' |
|
617 | + * 'EE_Messages_Queue' => 'load_lib' |
|
618 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
619 | + * or, if greater control is required, by providing a custom closure. For example: |
|
620 | + * 'Some_Class' => function () { |
|
621 | + * return new Some_Class(); |
|
622 | + * }, |
|
623 | + * This is required for instantiating dependencies |
|
624 | + * where an interface has been type hinted in a class constructor. For example: |
|
625 | + * 'Required_Interface' => function () { |
|
626 | + * return new A_Class_That_Implements_Required_Interface(); |
|
627 | + * }, |
|
628 | + */ |
|
629 | + protected function _register_core_class_loaders() |
|
630 | + { |
|
631 | + //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
632 | + //be used in a closure. |
|
633 | + $request = &$this->_request; |
|
634 | + $response = &$this->_response; |
|
635 | + $loader = &$this->loader; |
|
636 | + $this->_class_loaders = array( |
|
637 | + //load_core |
|
638 | + 'EE_Capabilities' => 'load_core', |
|
639 | + 'EE_Encryption' => 'load_core', |
|
640 | + 'EE_Front_Controller' => 'load_core', |
|
641 | + 'EE_Module_Request_Router' => 'load_core', |
|
642 | + 'EE_Registry' => 'load_core', |
|
643 | + 'EE_Request' => function () use (&$request) { |
|
644 | + return $request; |
|
645 | + }, |
|
646 | + 'EE_Response' => function () use (&$response) { |
|
647 | + return $response; |
|
648 | + }, |
|
649 | + 'EE_Request_Handler' => 'load_core', |
|
650 | + 'EE_Session' => 'load_core', |
|
651 | + 'EE_System' => 'load_core', |
|
652 | + //load_lib |
|
653 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
654 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
655 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
656 | + 'EE_Messenger_Collection' => 'load_lib', |
|
657 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
658 | + 'EE_Messages_Processor' => 'load_lib', |
|
659 | + 'EE_Message_Repository' => 'load_lib', |
|
660 | + 'EE_Messages_Queue' => 'load_lib', |
|
661 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
662 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
663 | + 'EE_Messages_Generator' => function () { |
|
664 | + return EE_Registry::instance()->load_lib( |
|
665 | + 'Messages_Generator', |
|
666 | + array(), |
|
667 | + false, |
|
668 | + false |
|
669 | + ); |
|
670 | + }, |
|
671 | + 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
672 | + return EE_Registry::instance()->load_lib( |
|
673 | + 'Messages_Template_Defaults', |
|
674 | + $arguments, |
|
675 | + false, |
|
676 | + false |
|
677 | + ); |
|
678 | + }, |
|
679 | + //load_model |
|
680 | + 'EEM_Attendee' => 'load_model', |
|
681 | + 'EEM_Message_Template_Group' => 'load_model', |
|
682 | + 'EEM_Message_Template' => 'load_model', |
|
683 | + //load_helper |
|
684 | + 'EEH_Parse_Shortcodes' => function () { |
|
685 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
686 | + return new EEH_Parse_Shortcodes(); |
|
687 | + } |
|
688 | + return null; |
|
689 | + }, |
|
690 | + 'EE_Template_Config' => function () { |
|
691 | + return EE_Config::instance()->template_settings; |
|
692 | + }, |
|
693 | + 'EE_Currency_Config' => function () { |
|
694 | + return EE_Config::instance()->currency; |
|
695 | + }, |
|
696 | + 'EventEspresso\core\services\loaders\Loader' => function () use (&$loader) { |
|
697 | + return $loader; |
|
698 | + }, |
|
699 | + ); |
|
700 | + } |
|
701 | + |
|
702 | + |
|
703 | + |
|
704 | + /** |
|
705 | + * can be used for supplying alternate names for classes, |
|
706 | + * or for connecting interface names to instantiable classes |
|
707 | + */ |
|
708 | + protected function _register_core_aliases() |
|
709 | + { |
|
710 | + $this->_aliases = array( |
|
711 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
712 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
713 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
714 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
715 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
716 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
717 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
718 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
719 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
720 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
721 | + 'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
|
722 | + 'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
|
723 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
724 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
725 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
726 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
727 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
728 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
729 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
730 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
731 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
732 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
733 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
734 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
735 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
736 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
737 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
738 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
739 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
740 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
741 | + 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
742 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
743 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
744 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
745 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
746 | + ); |
|
747 | + } |
|
748 | + |
|
749 | + |
|
750 | + |
|
751 | + /** |
|
752 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
753 | + * request Primarily used by unit tests. |
|
754 | + */ |
|
755 | + public function reset() |
|
756 | + { |
|
757 | + $this->_register_core_class_loaders(); |
|
758 | + $this->_register_core_dependencies(); |
|
759 | + } |
|
760 | 760 | |
761 | 761 | |
762 | 762 | } |